[Lldb-commits] [lldb] r192319 - Add exec support for Linux including common support for POSIX.
Matt Kopec
Matt.Kopec at intel.com
Wed Oct 9 12:39:56 PDT 2013
Author: mkopec
Date: Wed Oct 9 14:39:55 2013
New Revision: 192319
URL: http://llvm.org/viewvc/llvm-project?rev=192319&view=rev
Log:
Add exec support for Linux including common support for POSIX.
Modified:
lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp
lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.h
lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h
lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.h
Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=192319&r1=192318&r2=192319&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Wed Oct 9 14:39:55 2013
@@ -1487,8 +1487,10 @@ ProcessMonitor::MonitorSIGTRAP(ProcessMo
}
case (SIGTRAP | (PTRACE_EVENT_EXEC << 8)):
- // Don't follow the child by default and resume
- monitor->Resume(pid, SIGCONT);
+ if (log)
+ log->Printf ("ProcessMonitor::%s() received exec event, code = %d", __FUNCTION__, info->si_code ^ SIGTRAP);
+
+ message = ProcessMessage::Exec(pid);
break;
case (SIGTRAP | (PTRACE_EVENT_EXIT << 8)):
Modified: lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp?rev=192319&r1=192318&r2=192319&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.cpp Wed Oct 9 14:39:55 2013
@@ -352,6 +352,10 @@ POSIXThread::Notify(const ProcessMessage
case ProcessMessage::eNewThreadMessage:
ThreadNotify(message);
break;
+
+ case ProcessMessage::eExecMessage:
+ ExecNotify(message);
+ break;
}
}
@@ -574,6 +578,12 @@ POSIXThread::GetRegisterIndexFromOffset(
return reg;
}
+void
+POSIXThread::ExecNotify(const ProcessMessage &message)
+{
+ SetStopInfo (StopInfo::CreateStopReasonWithExec(*this));
+}
+
const char *
POSIXThread::GetRegisterName(unsigned reg)
{
Modified: lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.h?rev=192319&r1=192318&r2=192319&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.h (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/POSIXThread.h Wed Oct 9 14:39:55 2013
@@ -123,6 +123,7 @@ protected:
void CrashNotify(const ProcessMessage &message);
void ThreadNotify(const ProcessMessage &message);
void ExitNotify(const ProcessMessage &message);
+ void ExecNotify(const ProcessMessage &message);
lldb_private::Unwind *
GetUnwinder();
Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h?rev=192319&r1=192318&r2=192319&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h Wed Oct 9 14:39:55 2013
@@ -32,7 +32,8 @@ public:
eBreakpointMessage,
eWatchpointMessage,
eCrashMessage,
- eNewThreadMessage
+ eNewThreadMessage,
+ eExecMessage
};
enum CrashReason
@@ -133,6 +134,11 @@ public:
return ProcessMessage(tid, eExitMessage, status);
}
+ /// Indicates that the thread @p pid has exec'd.
+ static ProcessMessage Exec(lldb::tid_t tid) {
+ return ProcessMessage(tid, eExecMessage);
+ }
+
int GetExitStatus() const {
assert(GetKind() == eExitMessage || GetKind() == eLimboMessage);
return m_status;
Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp?rev=192319&r1=192318&r2=192319&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp Wed Oct 9 14:39:55 2013
@@ -353,6 +353,31 @@ ProcessPOSIX::DoDestroy()
}
void
+ProcessPOSIX::DoDidExec()
+{
+ Target *target = &GetTarget();
+ if (target)
+ {
+ PlatformSP platform_sp (target->GetPlatform());
+ assert (platform_sp.get());
+ if (platform_sp)
+ {
+ ProcessInstanceInfo process_info;
+ platform_sp->GetProcessInfo(GetID(), process_info);
+ ModuleSP exe_module_sp;
+ FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths());
+ Error error = platform_sp->ResolveExecutable(process_info.GetExecutableFile(),
+ target->GetArchitecture(),
+ exe_module_sp,
+ executable_search_paths.GetSize() ? &executable_search_paths : NULL);
+ if (!error.Success())
+ return;
+ target->SetExecutableModule(exe_module_sp, true);
+ }
+ }
+}
+
+void
ProcessPOSIX::SendMessage(const ProcessMessage &message)
{
Mutex::Locker lock(m_message_mutex);
@@ -426,7 +451,7 @@ ProcessPOSIX::SendMessage(const ProcessM
break;
case ProcessMessage::eNewThreadMessage:
- {
+ {
lldb::tid_t new_tid = message.GetChildTID();
if (WaitingForInitialStop(new_tid))
{
@@ -437,9 +462,19 @@ ProcessPOSIX::SendMessage(const ProcessM
StopAllThreads(message.GetTID());
SetPrivateState(eStateStopped);
break;
- }
}
+ case ProcessMessage::eExecMessage:
+ {
+ assert(thread);
+ thread->SetState(eStateStopped);
+ StopAllThreads(message.GetTID());
+ SetPrivateState(eStateStopped);
+ break;
+ }
+ }
+
+
m_message_queue.push(message);
}
Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.h?rev=192319&r1=192318&r2=192319&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.h (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.h Wed Oct 9 14:39:55 2013
@@ -79,6 +79,9 @@ public:
DoDestroy();
virtual void
+ DoDidExec();
+
+ virtual void
RefreshStateAfterStop();
virtual bool
More information about the lldb-commits
mailing list