[Lldb-commits] [lldb] r207699 - Allow for a task port to change when we exec.
Greg Clayton
gclayton at apple.com
Wed Apr 30 13:27:02 PDT 2014
Author: gclayton
Date: Wed Apr 30 15:27:01 2014
New Revision: 207699
URL: http://llvm.org/viewvc/llvm-project?rev=207699&view=rev
Log:
Allow for a task port to change when we exec.
Modified:
lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h
lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h?rev=207699&r1=207698&r2=207699&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h Wed Apr 30 15:27:01 2014
@@ -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)
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm?rev=207699&r1=207698&r2=207699&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.mm Wed Apr 30 15:27:01 2014
@@ -1180,7 +1180,7 @@ MachProcess::ExceptionMessageReceived (c
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::ExceptionMessageBundleCompl
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::ExceptionMessageBundleCompl
{
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);
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h?rev=207699&r1=207698&r2=207699&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h Wed Apr 30 15:27:01 2014
@@ -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; }
Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm?rev=207699&r1=207698&r2=207699&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachTask.mm Wed Apr 30 15:27:01 2014
@@ -471,9 +471,9 @@ MachTask::GetProfileData (DNBProfileData
// 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
More information about the lldb-commits
mailing list