summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/DNB.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/tools/debugserver/source/DNB.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/tools/debugserver/source/DNB.cpp')
-rw-r--r--lldb/tools/debugserver/source/DNB.cpp95
1 files changed, 58 insertions, 37 deletions
diff --git a/lldb/tools/debugserver/source/DNB.cpp b/lldb/tools/debugserver/source/DNB.cpp
index 948125b9714..17a17d32f0d 100644
--- a/lldb/tools/debugserver/source/DNB.cpp
+++ b/lldb/tools/debugserver/source/DNB.cpp
@@ -265,10 +265,8 @@ DNBProcessAttachByName (const char *name, struct timespec *timeout, char *err_st
DNBLogError ("%6u - %s\n", matching_proc_infos[i].kp_proc.p_pid, matching_proc_infos[i].kp_proc.p_comm);
return INVALID_NUB_PROCESS;
}
- else
- {
- return DNBProcessAttach (matching_proc_infos[0].kp_proc.p_pid, timeout, err_str, err_len);
- }
+
+ return DNBProcessAttach (matching_proc_infos[0].kp_proc.p_pid, timeout, err_str, err_len);
}
nub_process_t
@@ -294,15 +292,20 @@ DNBProcessAttach (nub_process_t attach_pid, struct timespec *timeout, char *err_
while (pid != INVALID_NUB_PROCESS)
{
// Wait for process to start up and hit entry point
- DNBLogThreadedIf (LOG_PROCESS, "%s DNBProcessWaitForEvent (%4.4x, eEventProcessRunningStateChanged "
- "| eEventProcessStoppedStateChanged, true, INFINITE)...",
- __FUNCTION__, pid);
+ DNBLogThreadedIf (LOG_PROCESS,
+ "%s DNBProcessWaitForEvent (%4.4x, eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged, true, INFINITE)...",
+ __FUNCTION__,
+ pid);
nub_event_t set_events = DNBProcessWaitForEvents (pid,
- eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged,
- true, timeout);
- DNBLogThreadedIf (LOG_PROCESS, "%s DNBProcessWaitForEvent (%4.4x, eEventProcessRunningStateChanged "
- "| eEventProcessStoppedStateChanged, true, INFINITE) => 0x%8.8x",
- __FUNCTION__, pid, set_events);
+ eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged,
+ true,
+ timeout);
+
+ DNBLogThreadedIf (LOG_PROCESS,
+ "%s DNBProcessWaitForEvent (%4.4x, eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged, true, INFINITE) => 0x%8.8x",
+ __FUNCTION__,
+ pid,
+ set_events);
if (set_events == 0)
{
@@ -320,29 +323,30 @@ DNBProcessAttach (nub_process_t attach_pid, struct timespec *timeout, char *err_
switch (pid_state)
{
- default:
- case eStateInvalid:
- case eStateUnloaded:
- case eStateAttaching:
- case eStateLaunching:
- case eStateSuspended:
- break; // Ignore
-
- case eStateRunning:
- case eStateStepping:
- // Still waiting to stop at entry point...
- break;
-
- case eStateStopped:
- case eStateCrashed:
- return pid;
- case eStateDetached:
- case eStateExited:
- if (err_str && err_len > 0)
- snprintf(err_str, err_len, "process exited");
- return INVALID_NUB_PROCESS;
- }
- }
+ default:
+ case eStateInvalid:
+ case eStateUnloaded:
+ case eStateAttaching:
+ case eStateLaunching:
+ case eStateSuspended:
+ break; // Ignore
+
+ case eStateRunning:
+ case eStateStepping:
+ // Still waiting to stop at entry point...
+ break;
+
+ case eStateStopped:
+ case eStateCrashed:
+ return pid;
+
+ case eStateDetached:
+ case eStateExited:
+ if (err_str && err_len > 0)
+ snprintf(err_str, err_len, "process exited");
+ return INVALID_NUB_PROCESS;
+ }
+ }
DNBProcessResetEvents(pid, set_events);
}
@@ -352,7 +356,7 @@ DNBProcessAttach (nub_process_t attach_pid, struct timespec *timeout, char *err_
}
static size_t
-GetAllInfos(std::vector<struct kinfo_proc>& proc_infos)
+GetAllInfos (std::vector<struct kinfo_proc>& proc_infos)
{
size_t size;
int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL };
@@ -1722,7 +1726,7 @@ DNBProcessGetSharedLibraryInfo (nub_process_t pid, nub_bool_t only_changed, stru
const DNBRegisterSetInfo *
DNBGetRegisterSetInfo (nub_size_t *num_reg_sets)
{
- return DNBArch::GetRegisterSetInfo (num_reg_sets);
+ return DNBArchProtocol::GetRegisterSetInfo (num_reg_sets);
}
@@ -1998,3 +2002,20 @@ DNBResolveExecutablePath (const char *path, char *resolved_path, size_t resolved
return false;
}
+
+void
+DNBInitialize()
+{
+ DNBLogThreadedIf (LOG_PROCESS, "DNBInitialize ()");
+#if defined (__i386__) || defined (__x86_64__)
+ DNBArchImplI386::Initialize();
+ DNBArchImplX86_64::Initialize();
+#elif defined (__arm__)
+ DNBArchMachARM::Initialize();
+#endif
+}
+
+void
+DNBTerminate()
+{
+}
OpenPOWER on IntegriCloud