summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Target/Process.h8
-rw-r--r--lldb/source/Target/Process.cpp74
2 files changed, 75 insertions, 7 deletions
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 1486484d6fe..d7a626bedff 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2962,13 +2962,9 @@ protected:
class AttachCompletionHandler : public NextEventAction
{
public:
- AttachCompletionHandler (Process *process, uint32_t exec_count) :
- NextEventAction (process),
- m_exec_count (exec_count)
- {
- }
+ AttachCompletionHandler (Process *process, uint32_t exec_count);
- virtual
+ virtual
~AttachCompletionHandler()
{
}
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 4092aa7f80b..140b0d09fb1 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -2891,12 +2891,25 @@ Process::GetSystemRuntime ()
return m_system_runtime_ap.get();
}
+Process::AttachCompletionHandler::AttachCompletionHandler (Process *process, uint32_t exec_count) :
+ NextEventAction (process),
+ m_exec_count (exec_count)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+ if (log)
+ log->Printf ("Process::AttachCompletionHandler::%s process=%p, exec_count=%" PRIu32, __FUNCTION__, static_cast<void*>(process), exec_count);
+}
Process::NextEventAction::EventActionResult
Process::AttachCompletionHandler::PerformAction (lldb::EventSP &event_sp)
{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+
StateType state = ProcessEventData::GetStateFromEvent (event_sp.get());
- switch (state)
+ if (log)
+ log->Printf ("Process::AttachCompletionHandler::%s called with state %s (%d)", __FUNCTION__, StateAsCString(state), static_cast<int> (state));
+
+ switch (state)
{
case eStateRunning:
case eStateConnected:
@@ -2914,11 +2927,18 @@ Process::AttachCompletionHandler::PerformAction (lldb::EventSP &event_sp)
if (m_exec_count > 0)
{
--m_exec_count;
+
+ if (log)
+ log->Printf ("Process::AttachCompletionHandler::%s state %s: reduced remaining exec count to %" PRIu32 ", requesting resume", __FUNCTION__, StateAsCString(state), m_exec_count);
+
RequestResume();
return eEventActionRetry;
}
else
{
+ if (log)
+ log->Printf ("Process::AttachCompletionHandler::%s state %s: no more execs expected to start, continuing with attach", __FUNCTION__, StateAsCString(state));
+
m_process->CompleteAttach ();
return eEventActionSuccess;
}
@@ -3100,13 +3120,26 @@ Process::Attach (ProcessAttachInfo &attach_info)
void
Process::CompleteAttach ()
{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+ if (log)
+ log->Printf ("Process::%s()", __FUNCTION__);
+
// Let the process subclass figure out at much as it can about the process
// before we go looking for a dynamic loader plug-in.
ArchSpec process_arch;
DidAttach(process_arch);
if (process_arch.IsValid())
+ {
m_target.SetArchitecture(process_arch);
+ if (log)
+ {
+ const char *triple_str = process_arch.GetTriple().getTriple().c_str ();
+ log->Printf ("Process::%s replacing process architecture with DidAttach() architecture: %s",
+ __FUNCTION__,
+ triple_str ? triple_str : "<null>");
+ }
+ }
// We just attached. If we have a platform, ask it for the process architecture, and if it isn't
// the same as the one we've already set, switch architectures.
@@ -3123,6 +3156,8 @@ Process::CompleteAttach ()
{
m_target.SetPlatform (platform_sp);
m_target.SetArchitecture(platform_arch);
+ if (log)
+ log->Printf ("Process::%s switching platform to %s and architecture to %s based on info from attach", __FUNCTION__, platform_sp->GetName().AsCString (""), platform_arch.GetTriple().getTriple().c_str ());
}
}
else if (!process_arch.IsValid())
@@ -3131,7 +3166,11 @@ Process::CompleteAttach ()
platform_sp->GetProcessInfo (GetID(), process_info);
const ArchSpec &process_arch = process_info.GetArchitecture();
if (process_arch.IsValid() && !m_target.GetArchitecture().IsExactMatch(process_arch))
+ {
m_target.SetArchitecture (process_arch);
+ if (log)
+ log->Printf ("Process::%s switching architecture to %s based on info the platform retrieved for pid %" PRIu64, __FUNCTION__, process_arch.GetTriple().getTriple().c_str (), GetID ());
+ }
}
}
@@ -3139,13 +3178,33 @@ Process::CompleteAttach ()
// plug-in
DynamicLoader *dyld = GetDynamicLoader ();
if (dyld)
+ {
dyld->DidAttach();
+ if (log)
+ {
+ ModuleSP exe_module_sp = m_target.GetExecutableModule ();
+ log->Printf ("Process::%s after DynamicLoader::DidAttach(), target executable is %s (using %s plugin)",
+ __FUNCTION__,
+ exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str () : "<none>",
+ dyld->GetPluginName().AsCString ("<unnamed>"));
+ }
+ }
GetJITLoaders().DidAttach();
SystemRuntime *system_runtime = GetSystemRuntime ();
if (system_runtime)
+ {
system_runtime->DidAttach();
+ if (log)
+ {
+ ModuleSP exe_module_sp = m_target.GetExecutableModule ();
+ log->Printf ("Process::%s after SystemRuntime::DidAttach(), target executable is %s (using %s plugin)",
+ __FUNCTION__,
+ exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str () : "<none>",
+ system_runtime->GetPluginName().AsCString("<unnamed>"));
+ }
+ }
m_os_ap.reset (OperatingSystem::FindPlugin (this, NULL));
// Figure out which one is the executable, and set that in our target:
@@ -3165,7 +3224,16 @@ Process::CompleteAttach ()
}
}
if (new_executable_module_sp)
+ {
m_target.SetExecutableModule (new_executable_module_sp, false);
+ if (log)
+ {
+ ModuleSP exe_module_sp = m_target.GetExecutableModule ();
+ log->Printf ("Process::%s after looping through modules, target executable is %s",
+ __FUNCTION__,
+ exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str () : "<none>");
+ }
+ }
}
Error
@@ -5859,6 +5927,10 @@ Process::Flush ()
void
Process::DidExec ()
{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+ if (log)
+ log->Printf ("Process::%s()", __FUNCTION__);
+
Target &target = GetTarget();
target.CleanupProcess ();
target.ClearModules(false);
OpenPOWER on IntegriCloud