summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/MacOSX/MachThreadList.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/MacOSX/MachThreadList.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/MacOSX/MachThreadList.cpp')
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
index db2a00a304a..7a5e9bb8588 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
@@ -12,6 +12,9 @@
//===----------------------------------------------------------------------===//
#include "MachThreadList.h"
+
+#include <sys/sysctl.h>
+
#include "DNBLog.h"
#include "DNBThreadResumeActions.h"
#include "MachProcess.h"
@@ -104,6 +107,15 @@ MachThreadList::GetThreadInfo(nub_thread_t tid) const
return NULL;
}
+MachThread *
+MachThreadList::GetThreadByID (nub_thread_t tid) const
+{
+ uint32_t idx = GetThreadIndexByID(tid);
+ if (idx < m_threads.size())
+ return m_threads[idx].get();
+ return NULL;
+}
+
bool
MachThreadList::GetRegisterValue ( nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, DNBRegisterValue *reg_value ) const
{
@@ -202,9 +214,28 @@ uint32_t
MachThreadList::UpdateThreadList(MachProcess *process, bool update)
{
// locker will keep a mutex locked until it goes out of scope
- DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThreadList::UpdateThreadList (pid = %4.4x, update = %u )", process->ProcessID(), update);
+ DNBLogThreadedIf (LOG_THREAD, "MachThreadList::UpdateThreadList (pid = %4.4x, update = %u) process stop count = %u", process->ProcessID(), update, process->StopCount());
PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
+#if defined (__i386__) || defined (__x86_64__)
+ if (process->StopCount() == 0)
+ {
+ int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process->ProcessID() };
+ struct kinfo_proc processInfo;
+ size_t bufsize = sizeof(processInfo);
+ bool is_64_bit = false;
+ if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), &processInfo, &bufsize, NULL, 0) == 0 && bufsize > 0)
+ {
+ if (processInfo.kp_proc.p_flag & P_LP64)
+ is_64_bit = true;
+ }
+ if (is_64_bit)
+ DNBArchProtocol::SetDefaultArchitecture(CPU_TYPE_X86_64);
+ else
+ DNBArchProtocol::SetDefaultArchitecture(CPU_TYPE_I386);
+ }
+#endif
+
if (m_threads.empty() || update)
{
thread_array_t thread_list = NULL;
OpenPOWER on IntegriCloud