diff options
author | Greg Clayton <gclayton@apple.com> | 2014-03-24 23:10:19 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2014-03-24 23:10:19 +0000 |
commit | 23f8c95a4439767cf9c7dc9d7a35eb55dc78b9d0 (patch) | |
tree | 3e56f285be57acf15b3fb73195567727a329aca9 /lldb/source/Host/common/Host.cpp | |
parent | 2256d0dcedf887593ebfb35db860827e8682807e (diff) | |
download | bcm5719-llvm-23f8c95a4439767cf9c7dc9d7a35eb55dc78b9d0.tar.gz bcm5719-llvm-23f8c95a4439767cf9c7dc9d7a35eb55dc78b9d0.zip |
JITed functions can now have debug info and be debugged with debug and source info:
(lldb) b puts
(lldb) expr -g -i0 -- (int)puts("hello")
First we will stop at the entry point of the expression before it runs, then we can step over a few times and hit the breakpoint in "puts", then we can continue and finishing stepping and fininsh the expression.
Main features:
- New ObjectFileJIT class that can be easily created for JIT functions
- debug info can now be enabled when parsing expressions
- source for any function that is run throught the JIT is now saved in LLDB process specific temp directory and cleaned up on exit
- "expr -g --" allows you to single step through your expression function with source code
<rdar://problem/16382881>
llvm-svn: 204682
Diffstat (limited to 'lldb/source/Host/common/Host.cpp')
-rw-r--r-- | lldb/source/Host/common/Host.cpp | 69 |
1 files changed, 66 insertions, 3 deletions
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index eb45f4a82a5..e5a0f339e9d 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -12,6 +12,7 @@ // C includes #include <errno.h> #include <limits.h> +#include <stdlib.h> #include <sys/types.h> #ifdef _WIN32 #include "lldb/Host/windows/windows.h" @@ -1008,6 +1009,20 @@ Host::GetModuleFileSpecForHostAddress (const void *host_addr) #endif + +static void CleanupProcessSpecificLLDBTempDir () +{ + // Get the process specific LLDB temporary directory and delete it. + FileSpec tmpdir_file_spec; + if (Host::GetLLDBPath (ePathTypeLLDBTempSystemDir, tmpdir_file_spec)) + { + // Remove the LLDB temporary directory if we have one. Set "recurse" to + // true to all files that were created for the LLDB process can be cleaned up. + const bool recurse = true; + Host::RemoveDirectory(tmpdir_file_spec.GetDirectory().GetCString(), recurse); + } +} + bool Host::GetLLDBPath (PathType path_type, FileSpec &file_spec) { @@ -1279,9 +1294,22 @@ Host::GetLLDBPath (PathType path_type, FileSpec &file_spec) } if (tmpdir_cstr) { - g_lldb_tmp_dir.SetCString(tmpdir_cstr); - if (log) - log->Printf("Host::GetLLDBPath(ePathTypeLLDBTempSystemDir) => '%s'", g_lldb_tmp_dir.GetCString()); + StreamString pid_tmpdir; + pid_tmpdir.Printf("%s/lldb", tmpdir_cstr); + if (Host::MakeDirectory(pid_tmpdir.GetString().c_str(), eFilePermissionsDirectoryDefault).Success()) + { + pid_tmpdir.Printf("/%" PRIu64, Host::GetCurrentProcessID()); + if (Host::MakeDirectory(pid_tmpdir.GetString().c_str(), eFilePermissionsDirectoryDefault).Success()) + { + // Make an atexit handler to clean up the process specify LLDB temp dir + // and all of its contents. + ::atexit (CleanupProcessSpecificLLDBTempDir); + g_lldb_tmp_dir.SetCString(pid_tmpdir.GetString().c_str()); + if (log) + log->Printf("Host::GetLLDBPath(ePathTypeLLDBTempSystemDir) => '%s'", g_lldb_tmp_dir.GetCString()); + + } + } } } file_spec.GetDirectory() = g_lldb_tmp_dir; @@ -2141,6 +2169,14 @@ Host::Unlink (const char *path) return error; } +Error +Host::RemoveDirectory (const char* path, bool recurse) +{ + Error error; + error.SetErrorStringWithFormat("%s is not supported on this host", __PRETTY_FUNCTION__); + return error; +} + #else Error @@ -2189,6 +2225,33 @@ Host::MakeDirectory (const char* path, uint32_t file_permissions) } return error; } + +Error +Host::RemoveDirectory (const char* path, bool recurse) +{ + Error error; + if (path && path[0]) + { + if (recurse) + { + StreamString command; + command.Printf("rm -rf \"%s\"", path); + int status = ::system(command.GetString().c_str()); + if (status != 0) + error.SetError(status, eErrorTypeGeneric); + } + else + { + if (::rmdir(path) != 0) + error.SetErrorToErrno(); + } + } + else + { + error.SetErrorString("empty path"); + } + return error; +} Error Host::GetFilePermissions (const char* path, uint32_t &file_permissions) |