summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-11-18 05:57:03 +0000
committerGreg Clayton <gclayton@apple.com>2010-11-18 05:57:03 +0000
commit3af9ea56d30ca97a5ce31cb1024501b324f8fa47 (patch)
tree6c613eee05c2d066b9a58e727f079725ffc34964 /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
parent19ca5608db90bf06bfaba3e1b28af6ed68165d7d (diff)
downloadbcm5719-llvm-3af9ea56d30ca97a5ce31cb1024501b324f8fa47.tar.gz
bcm5719-llvm-3af9ea56d30ca97a5ce31cb1024501b324f8fa47.zip
Fixed Process::Halt() as it was broken for "process halt" after recent changes
to the DoHalt down in ProcessGDBRemote. I also moved the functionality that was in ProcessGDBRemote::DoHalt up into Process::Halt so not every class has to implement a tricky halt/resume on the internal state thread. The functionality is the same as it was before with two changes: - when we eat the event we now just reuse the event we consume when the private state thread is paused and set the interrupted bool on the event if needed - we also properly update the Process::m_public_state with the state of the event we consume. Prior to this, if you issued a "process halt" it would eat the event, not update the process state, and then produce a new event with the interrupted bit set and send it. Anyone listening to the event would get the stopped event with a process that whose state was set to "running". Fixed debugserver to not have to be spawned with the architecture of the inferior process. This worked fine for launching processes, but when attaching to processes by name or pid without a file in lldb, it would fail. Now debugserver can support multiple architectures for a native debug session on the current host. This currently means i386 and x86_64 are supported in the same binary and a x86_64 debugserver can attach to a i386 executable. This change involved a lot of changes to make sure we dynamically detect the correct registers for the inferior process. llvm-svn: 119680
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp74
1 files changed, 15 insertions, 59 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index fcbd523699f..5496a02343a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -105,7 +105,6 @@ ProcessGDBRemote::ProcessGDBRemote(Target& target, Listener &listener) :
m_dynamic_loader_ap (),
m_flags (0),
m_stdio_mutex (Mutex::eMutexTypeRecursive),
- m_byte_order (eByteOrderHost),
m_gdb_comm(),
m_debugserver_pid (LLDB_INVALID_PROCESS_ID),
m_debugserver_thread (LLDB_INVALID_HOST_THREAD),
@@ -339,13 +338,13 @@ ProcessGDBRemote::WillLaunch (Module* module)
}
Error
-ProcessGDBRemote::WillAttach (lldb::pid_t pid)
+ProcessGDBRemote::WillAttachToProcessWithID (lldb::pid_t pid)
{
return WillLaunchOrAttach ();
}
Error
-ProcessGDBRemote::WillAttach (const char *process_name, bool wait_for_launch)
+ProcessGDBRemote::WillAttachToProcessWithName (const char *process_name, bool wait_for_launch)
{
return WillLaunchOrAttach ();
}
@@ -556,8 +555,6 @@ ProcessGDBRemote::ConnectToDebugserver (const char *host_port)
if (response.IsOKPacket())
m_gdb_comm.SetAckMode (false);
}
-
- BuildDynamicRegisterInfo ();
}
return error;
}
@@ -574,22 +571,23 @@ ProcessGDBRemote::DidLaunchOrAttach ()
{
m_dispatch_queue_offsets_addr = LLDB_INVALID_ADDRESS;
- Module * exe_module = GetTarget().GetExecutableModule ().get();
+ BuildDynamicRegisterInfo ();
+
+ m_byte_order = m_gdb_comm.GetByteOrder();
+
+ Module * exe_module = GetTarget().GetExecutableModule().get();
assert(exe_module);
ObjectFile *exe_objfile = exe_module->GetObjectFile();
assert(exe_objfile);
- m_byte_order = exe_objfile->GetByteOrder();
- assert (m_byte_order != eByteOrderInvalid);
-
StreamString strm;
ArchSpec inferior_arch;
// See if the GDB server supports the qHostInfo information
const char *vendor = m_gdb_comm.GetVendorString().AsCString();
const char *os_type = m_gdb_comm.GetOSString().AsCString();
- ArchSpec arch_spec = GetTarget().GetArchitecture();
+ ArchSpec arch_spec (GetTarget().GetArchitecture());
if (arch_spec.IsValid() && arch_spec == ArchSpec ("arm"))
{
@@ -858,25 +856,8 @@ ProcessGDBRemote::DoAttachToProcessWithName (const char *process_name, bool wait
void
ProcessGDBRemote::DidAttach ()
{
- // If we haven't got an executable module yet, then we should make a dynamic loader, and
- // see if it can find the executable module for us. If we do have an executable module,
- // make sure it matches the process we've just attached to.
-
- ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
- if (!m_dynamic_loader_ap.get())
- {
- m_dynamic_loader_ap.reset(DynamicLoader::FindPlugin(this, "dynamic-loader.macosx-dyld"));
- }
-
if (m_dynamic_loader_ap.get())
m_dynamic_loader_ap->DidAttach();
-
- Module * new_exe_module = GetTarget().GetExecutableModule().get();
- if (new_exe_module == NULL)
- {
-
- }
-
DidLaunchOrAttach ();
}
@@ -1124,45 +1105,26 @@ Error
ProcessGDBRemote::DoHalt (bool &caused_stop)
{
Error error;
- caused_stop = false;
if (m_gdb_comm.IsRunning())
{
- PausePrivateStateThread();
+ caused_stop = true;
bool timed_out = false;
Mutex::Locker locker;
- if (m_gdb_comm.SendInterrupt (locker, 2, &timed_out))
- {
- EventSP event_sp;
- TimeValue timeout_time;
- timeout_time = TimeValue::Now();
- timeout_time.OffsetWithSeconds(2);
-
- StateType state = WaitForStateChangedEventsPrivate (&timeout_time, event_sp);
-
- if (!StateIsStoppedState (state))
- {
- LogSP log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
- if (log)
- log->Printf("ProcessGDBRemote::DoHalt() failed to stop after sending interrupt");
- error.SetErrorString ("Did not get stopped event after interrupt succeeded.");
- }
- else
- caused_stop = true;
- }
- else
+ if (!m_gdb_comm.SendInterrupt (locker, 2, &timed_out))
{
if (timed_out)
error.SetErrorString("timed out sending interrupt packet");
else
error.SetErrorString("unknown error sending interrupt packet");
}
-
- // Resume the private state thread at this point.
- ResumePrivateStateThread();
-
}
+ else
+ {
+ caused_stop = false;
+ }
+
return error;
}
@@ -1265,12 +1227,6 @@ ProcessGDBRemote::DoDestroy ()
return error;
}
-ByteOrder
-ProcessGDBRemote::GetByteOrder () const
-{
- return m_byte_order;
-}
-
//------------------------------------------------------------------
// Process Queries
//------------------------------------------------------------------
OpenPOWER on IntegriCloud