diff options
4 files changed, 33 insertions, 11 deletions
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.h b/lldb/tools/debugserver/source/MacOSX/MachProcess.h index fd5bdc9bb55..78be93c6976 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.h +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.h @@ -147,7 +147,7 @@ public: bool StartSTDIOThread (); static void * STDIOThread (void *arg); void ExceptionMessageReceived (const MachException::Message& exceptionMessage); - void ExceptionMessageBundleComplete (); + task_t ExceptionMessageBundleComplete (); void SharedLibrariesUpdated (); nub_size_t CopyImageInfos (struct DNBExecutableImageInfo **image_infos, bool only_changed); @@ -227,10 +227,7 @@ public: return m_exit_info.c_str(); } - void SetExitInfo (const char *info) - { - m_exit_info.assign(info); - } + void SetExitInfo (const char *info); uint32_t StopCount() const { return m_stop_count; } void SetChildFileDescriptors (int stdin_fileno, int stdout_fileno, int stderr_fileno) diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm index 6c270b9fe65..0ac985b1cb6 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm @@ -1180,7 +1180,7 @@ MachProcess::ExceptionMessageReceived (const MachException::Message& exceptionMe m_exception_messages.push_back(exceptionMessage); } -void +task_t MachProcess::ExceptionMessageBundleComplete() { // We have a complete bundle of exceptions for our child process. @@ -1216,7 +1216,15 @@ MachProcess::ExceptionMessageBundleComplete() if (m_task.ReadMemory(info_array_count_addr, 4, &info_array_count) == 4) { if (info_array_count == 0) + { m_did_exec = true; + // Force the task port to update itself in case the task port changed after exec + DNBError err; + const task_t old_task = m_task.TaskPort(); + const task_t new_task = m_task.TaskPortForProcessID (err, true); + if (old_task != new_task) + DNBLogThreadedIf(LOG_PROCESS, "exec: task changed from 0x%4.4x to 0x%4.4x", old_task, new_task); + } } else { @@ -1317,6 +1325,7 @@ MachProcess::ExceptionMessageBundleComplete() { DNBLogThreadedIf(LOG_EXCEPTIONS, "%s empty exception messages bundle (%llu exceptions).", __PRETTY_FUNCTION__, (uint64_t)m_exception_messages.size()); } + return m_task.TaskPort(); } nub_size_t @@ -1339,6 +1348,21 @@ MachProcess::SharedLibrariesUpdated ( ) } void +MachProcess::SetExitInfo (const char *info) +{ + if (info && info[0]) + { + DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s(\"%s\")", __FUNCTION__, info); + m_exit_info.assign(info); + } + else + { + DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s(NULL)", __FUNCTION__); + m_exit_info.clear(); + } +} + +void MachProcess::AppendSTDOUT (char* s, size_t len) { DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (<%llu> %s) ...", __FUNCTION__, (uint64_t)len, s); diff --git a/lldb/tools/debugserver/source/MacOSX/MachTask.h b/lldb/tools/debugserver/source/MacOSX/MachTask.h index 65d7446474d..96b991478c7 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachTask.h +++ b/lldb/tools/debugserver/source/MacOSX/MachTask.h @@ -86,7 +86,7 @@ public: static bool IsValid (task_t task); static void * ExceptionThread (void *arg); task_t TaskPort () const { return m_task; } - task_t TaskPortForProcessID (DNBError &err); + task_t TaskPortForProcessID (DNBError &err, bool force = false); static task_t TaskPortForProcessID (pid_t pid, DNBError &err, uint32_t num_retries = 10, uint32_t usec_interval = 10000); MachProcess * Process () { return m_process; } diff --git a/lldb/tools/debugserver/source/MacOSX/MachTask.mm b/lldb/tools/debugserver/source/MacOSX/MachTask.mm index 8b3a4f076e1..42e07ee0f28 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachTask.mm +++ b/lldb/tools/debugserver/source/MacOSX/MachTask.mm @@ -471,9 +471,9 @@ MachTask::GetProfileData (DNBProfileDataScanType scanType) // MachTask::TaskPortForProcessID //---------------------------------------------------------------------- task_t -MachTask::TaskPortForProcessID (DNBError &err) +MachTask::TaskPortForProcessID (DNBError &err, bool force) { - if (m_task == TASK_NULL && m_process != NULL) + if (((m_task == TASK_NULL) || force) && m_process != NULL) m_task = MachTask::TaskPortForProcessID(m_process->ProcessID(), err); return m_task; } @@ -802,8 +802,9 @@ MachTask::ExceptionThread (void *arg) num_exceptions_received = 0; // Notify our main thread we have a complete exception message - // bundle available. - mach_proc->ExceptionMessageBundleComplete(); + // bundle available and get the possibly updated task port back + // from the process in case we exec'ed and our task port changed + task = mach_proc->ExceptionMessageBundleComplete(); // in case we use a timeout value when getting exceptions... // Make sure our task is still valid |