From d5318c0c35354b22b9b676b9e2bc7076306a3d08 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Wed, 3 Apr 2013 04:18:47 +0000 Subject: [PATCH] Fix another old usage of GetCurrentThread() to get a mach port number in RNBRemote::HandlePacket_qProcessInfo -- add a new GetCurrentThreadMachPort() so callers who need to make a mach thred_get_state() call at the RNBRemote level will have a way to get the port number. llvm-svn: 178619 --- lldb/tools/debugserver/source/DNB.cpp | 12 ++++++++++++ lldb/tools/debugserver/source/DNB.h | 1 + lldb/tools/debugserver/source/MacOSX/MachProcess.cpp | 6 ++++++ lldb/tools/debugserver/source/MacOSX/MachProcess.h | 1 + lldb/tools/debugserver/source/RNBRemote.cpp | 2 +- 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lldb/tools/debugserver/source/DNB.cpp b/lldb/tools/debugserver/source/DNB.cpp index ed19b0973274..fb780c8ca352 100644 --- a/lldb/tools/debugserver/source/DNB.cpp +++ b/lldb/tools/debugserver/source/DNB.cpp @@ -1772,6 +1772,18 @@ DNBProcessGetCurrentThread (nub_process_t pid) return 0; } +//---------------------------------------------------------------------- +// Get the mach port number of the current thread. +//---------------------------------------------------------------------- +nub_thread_t +DNBProcessGetCurrentThreadMachPort (nub_process_t pid) +{ + MachProcessSP procSP; + if (GetProcessSP (pid, procSP)) + return procSP->GetCurrentThreadMachPort(); + return 0; +} + //---------------------------------------------------------------------- // Change the current thread. //---------------------------------------------------------------------- diff --git a/lldb/tools/debugserver/source/DNB.h b/lldb/tools/debugserver/source/DNB.h index 83366dbf9999..c6acf5bbf7de 100644 --- a/lldb/tools/debugserver/source/DNB.h +++ b/lldb/tools/debugserver/source/DNB.h @@ -75,6 +75,7 @@ nub_bool_t DNBProcessGetExitStatus (nub_process_t pid, int nub_bool_t DNBProcessSetExitStatus (nub_process_t pid, int status) DNB_EXPORT; nub_size_t DNBProcessGetNumThreads (nub_process_t pid) DNB_EXPORT; nub_thread_t DNBProcessGetCurrentThread (nub_process_t pid) DNB_EXPORT; +nub_thread_t DNBProcessGetCurrentThreadMachPort (nub_process_t pid) DNB_EXPORT; nub_thread_t DNBProcessSetCurrentThread (nub_process_t pid, nub_thread_t tid) DNB_EXPORT; nub_thread_t DNBProcessGetThreadAtIndex (nub_process_t pid, nub_size_t thread_idx) DNB_EXPORT; nub_bool_t DNBProcessSyncThreadState (nub_process_t pid, nub_thread_t tid) DNB_EXPORT; diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp index de11cc8cecc8..8176f10a1b41 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp @@ -185,6 +185,12 @@ MachProcess::GetCurrentThread () return m_thread_list.CurrentThreadID(); } +nub_thread_t +MachProcess::GetCurrentThreadMachPort () +{ + return m_thread_list.GetMachPortNumberByThreadID(m_thread_list.CurrentThreadID()); +} + nub_thread_t MachProcess::SetCurrentThread(nub_thread_t tid) { diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.h b/lldb/tools/debugserver/source/MacOSX/MachProcess.h index 542c3dbc93af..eee40e469df6 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.h +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.h @@ -176,6 +176,7 @@ public: nub_size_t GetNumThreads () const; nub_thread_t GetThreadAtIndex (nub_size_t thread_idx) const; nub_thread_t GetCurrentThread (); + nub_thread_t GetCurrentThreadMachPort (); nub_thread_t SetCurrentThread (nub_thread_t tid); MachThreadList & GetThreadList() { return m_thread_list; } bool GetThreadStoppedReason(nub_thread_t tid, struct DNBThreadStopInfo *stop_info) const; diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index 4c515f403654..35d960b8e3af 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -4099,7 +4099,7 @@ RNBRemote::HandlePacket_qProcessInfo (const char *p) #endif #if (defined (__x86_64__) || defined (__i386__)) && defined (x86_THREAD_STATE) - nub_thread_t thread = DNBProcessGetCurrentThread (pid); + nub_thread_t thread = DNBProcessGetCurrentThreadMachPort (pid); kern_return_t kr; x86_thread_state_t gp_regs; mach_msg_type_number_t gp_count = x86_THREAD_STATE_COUNT;