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
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
index c5c1e7f..3ca7fe8 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
@@ -115,6 +115,7 @@
m_image_infos_baton(NULL)
{
DNBLogThreadedIf(LOG_PROCESS | LOG_VERBOSE, "%s", __PRETTY_FUNCTION__);
+ bzero(&m_arch_plugin_info, sizeof(m_arch_plugin_info));
}
MachProcess::~MachProcess()
@@ -208,7 +209,15 @@
const DNBRegisterSetInfo *
MachProcess::GetRegisterSetInfo(nub_thread_t tid, nub_size_t *num_reg_sets ) const
{
- return DNBArch::GetRegisterSetInfo (num_reg_sets);
+ MachThread *thread = m_thread_list.GetThreadByID (tid);
+ if (thread)
+ {
+ DNBArchProtocol *arch = thread->GetArchProtocol();
+ if (arch)
+ return arch->GetRegisterSetInfo (num_reg_sets);
+ }
+ *num_reg_sets = 0;
+ return NULL;
}
bool
@@ -766,7 +775,7 @@
const nub_size_t break_op_size = bp->ByteSize();
assert (break_op_size > 0);
- const uint8_t * const break_op = DNBArch::SoftwareBreakpointOpcode(bp->ByteSize());
+ const uint8_t * const break_op = DNBArchProtocol::GetBreakpointOpcode (bp->ByteSize());
if (break_op_size > 0)
{
// Clear a software breakoint instruction
@@ -954,7 +963,7 @@
const nub_size_t break_op_size = bp->ByteSize();
assert (break_op_size != 0);
- const uint8_t * const break_op = DNBArch::SoftwareBreakpointOpcode(break_op_size);
+ const uint8_t * const break_op = DNBArchProtocol::GetBreakpointOpcode (break_op_size);
if (break_op_size > 0)
{
// Save the original opcode by reading it
@@ -1507,7 +1516,14 @@
break;
case eLaunchFlavorPosixSpawn:
- m_pid = MachProcess::PosixSpawnChildForPTraceDebugging (path, argv, envp, stdio_path, this, disable_aslr, launch_err);
+ m_pid = MachProcess::PosixSpawnChildForPTraceDebugging (path,
+ m_arch_plugin_info.cpu_type,
+ argv,
+ envp,
+ stdio_path,
+ this,
+ disable_aslr,
+ launch_err);
break;
#if defined (__arm__)
@@ -1590,6 +1606,7 @@
MachProcess::PosixSpawnChildForPTraceDebugging
(
const char *path,
+ cpu_type_t cpu_type,
char const *argv[],
char const *envp[],
const char *stdio_path,
@@ -1628,7 +1645,6 @@
// We don't need to do this for ARM, and we really shouldn't now that we
// have multiple CPU subtypes and no posix_spawnattr call that allows us
// to set which CPU subtype to launch...
- cpu_type_t cpu_type = DNBArch::GetCPUType();
size_t ocount = 0;
err.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu_type, &ocount), DNBError::POSIX);
if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS))