diff options
Diffstat (limited to 'lldb/source/Plugins')
| -rw-r--r-- | lldb/source/Plugins/Process/Linux/ProcessLinux.cpp | 55 | ||||
| -rw-r--r-- | lldb/source/Plugins/Process/Linux/ProcessLinux.h | 10 | ||||
| -rw-r--r-- | lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp | 76 |
3 files changed, 119 insertions, 22 deletions
diff --git a/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp index 323b8631472..6a0c54c36ad 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp @@ -87,10 +87,16 @@ ProcessLinux::ProcessLinux(Target& target, Listener &listener) m_in_limbo(false), m_exit_now(false) { + +#if 0 // FIXME: Putting this code in the ctor and saving the byte order in a // member variable is a hack to avoid const qual issues in GetByteOrder. ObjectFile *obj_file = GetTarget().GetExecutableModule()->GetObjectFile(); m_byte_order = obj_file->GetByteOrder(); +#else + // XXX: Will work only for local processes. + m_byte_order = lldb::endian::InlHostByteOrder(); +#endif } ProcessLinux::~ProcessLinux() @@ -138,23 +144,48 @@ ProcessLinux::WillLaunch(Module* module) } Error -ProcessLinux::DoLaunch(Module *module, - char const *argv[], - char const *envp[], - uint32_t launch_flags, - const char *stdin_path, - const char *stdout_path, - const char *stderr_path, - const char *working_directory) +ProcessLinux::DoLaunch (Module *module, + const ProcessLaunchInfo &launch_info) { Error error; assert(m_monitor == NULL); SetPrivateState(eStateLaunching); - m_monitor = new ProcessMonitor(this, module, - argv, envp, - stdin_path, stdout_path, stderr_path, - error); + + uint32_t launch_flags = launch_info.GetFlags().Get(); + const char *stdin_path = NULL; + const char *stdout_path = NULL; + const char *stderr_path = NULL; + const char *working_dir = launch_info.GetWorkingDirectory(); + + const ProcessLaunchInfo::FileAction *file_action; + file_action = launch_info.GetFileActionForFD (STDIN_FILENO); + if (file_action) + { + if (file_action->GetAction () == ProcessLaunchInfo::FileAction::eFileActionOpen) + stdin_path = file_action->GetPath(); + } + file_action = launch_info.GetFileActionForFD (STDOUT_FILENO); + if (file_action) + { + if (file_action->GetAction () == ProcessLaunchInfo::FileAction::eFileActionOpen) + stdout_path = file_action->GetPath(); + } + file_action = launch_info.GetFileActionForFD (STDERR_FILENO); + if (file_action) + { + if (file_action->GetAction () == ProcessLaunchInfo::FileAction::eFileActionOpen) + stderr_path = file_action->GetPath(); + } + + m_monitor = new ProcessMonitor (this, + module, + launch_info.GetArguments().GetConstArgumentVector(), + launch_info.GetEnvironmentEntries().GetConstArgumentVector(), + stdin_path, + stdout_path, + stderr_path, + error); m_module = module; diff --git a/lldb/source/Plugins/Process/Linux/ProcessLinux.h b/lldb/source/Plugins/Process/Linux/ProcessLinux.h index 1a984431cc7..1f67d54de63 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessLinux.h +++ b/lldb/source/Plugins/Process/Linux/ProcessLinux.h @@ -67,14 +67,8 @@ public: DoAttachToProcessWithID(lldb::pid_t pid); virtual lldb_private::Error - DoLaunch(lldb_private::Module *module, - char const *argv[], - char const *envp[], - uint32_t launch_flags, - const char *stdin_path, - const char *stdout_path, - const char *stderr_path, - const char *working_directory); + DoLaunch (lldb_private::Module *exe_module, + const lldb_private::ProcessLaunchInfo &launch_info); virtual void DidLaunch(); diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp index ff1e024f94b..66c4c4c674e 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp +++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp @@ -34,6 +34,8 @@ #include "ProcessMonitor.h" +#define DEBUG_PTRACE_MAXBYTES 20 + using namespace lldb_private; // FIXME: this code is host-dependent with respect to types and @@ -46,21 +48,91 @@ using namespace lldb_private; // avoid the additional indirection and checks. #ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION +static void +DisplayBytes (lldb_private::StreamString &s, void *bytes, uint32_t count) +{ + uint8_t *ptr = (uint8_t *)bytes; + const uint32_t loop_count = std::min<uint32_t>(DEBUG_PTRACE_MAXBYTES, count); + for(uint32_t i=0; i<loop_count; i++) + { + s.Printf ("[%x]", *ptr); + ptr++; + } +} + +static void PtraceDisplayBytes(__ptrace_request &req, void *data) +{ + StreamString buf; + LogSP verbose_log (ProcessLinuxLog::GetLogIfAllCategoriesSet ( + LINUX_LOG_PTRACE | LINUX_LOG_VERBOSE)); + + if (verbose_log) + { + switch(req) + { + case PTRACE_POKETEXT: + { + DisplayBytes(buf, &data, 8); + verbose_log->Printf("PTRACE_POKETEXT %s", buf.GetData()); + break; + } + case PTRACE_POKEDATA: + { + DisplayBytes(buf, &data, 8); + verbose_log->Printf("PTRACE_POKEDATA %s", buf.GetData()); + break; + } + case PTRACE_POKEUSER: + { + DisplayBytes(buf, &data, 8); + verbose_log->Printf("PTRACE_POKEUSER %s", buf.GetData()); + break; + } + case PTRACE_SETREGS: + { + DisplayBytes(buf, data, sizeof(user_regs_struct)); + verbose_log->Printf("PTRACE_SETREGS %s", buf.GetData()); + break; + } + case PTRACE_SETFPREGS: + { + DisplayBytes(buf, data, sizeof(user_fpregs_struct)); + verbose_log->Printf("PTRACE_SETFPREGS %s", buf.GetData()); + break; + } + case PTRACE_SETSIGINFO: + { + DisplayBytes(buf, data, sizeof(siginfo_t)); + verbose_log->Printf("PTRACE_SETSIGINFO %s", buf.GetData()); + break; + } + default: + { + } + } + } +} + // Wrapper for ptrace to catch errors and log calls. extern long PtraceWrapper(__ptrace_request req, pid_t pid, void *addr, void *data, const char* reqName, const char* file, int line) { - int result; + long int result; LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PTRACE)); + if (log) log->Printf("ptrace(%s, %u, %p, %p) called from file %s line %d", reqName, pid, addr, data, file, line); + + PtraceDisplayBytes(req, data); errno = 0; result = ptrace(req, pid, addr, data); + PtraceDisplayBytes(req, data); + if (log && (result == -1 || errno != 0)) { const char* str; @@ -352,7 +424,7 @@ ReadRegOperation::Execute(ProcessMonitor *monitor) // Set errno to zero so that we can detect a failed peek. errno = 0; - uint32_t data = PTRACE(PTRACE_PEEKUSER, pid, (void*)m_offset, NULL); + lldb::addr_t data = PTRACE(PTRACE_PEEKUSER, pid, (void*)m_offset, NULL); if (data == -1UL && errno) m_result = false; else |

