[Lldb-commits] [lldb] r160765 - in /lldb/branches/lldb-platform-work: ./ include/lldb/Target/ source/Plugins/Process/gdb-remote/ source/Symbol/ test/functionalities/load_unload/hidden/ test/functionalities/single-quote-in-filename-to-lldb/path with '09/ test/source-manager/hidden/ tools/debugserver/source/ tools/debugserver/source/MacOSX/ tools/debugserver/source/MacOSX/x86_64/

Johnny Chen johnny.chen at apple.com
Wed Jul 25 15:25:17 PDT 2012


Author: johnny
Date: Wed Jul 25 17:25:17 2012
New Revision: 160765

URL: http://llvm.org/viewvc/llvm-project?rev=160765&view=rev
Log:
Merge changes from ToT trunk.

Added:
    lldb/branches/lldb-platform-work/test/functionalities/load_unload/hidden/.keep
      - copied unchanged from r160756, lldb/trunk/test/functionalities/load_unload/hidden/.keep
    lldb/branches/lldb-platform-work/test/functionalities/single-quote-in-filename-to-lldb/path with '09/.keep
      - copied unchanged from r160756, lldb/trunk/test/functionalities/single-quote-in-filename-to-lldb/path with '09/.keep
    lldb/branches/lldb-platform-work/test/source-manager/hidden/.keep
      - copied unchanged from r160756, lldb/trunk/test/source-manager/hidden/.keep
Modified:
    lldb/branches/lldb-platform-work/   (props changed)
    lldb/branches/lldb-platform-work/include/lldb/Target/RegisterContext.h
    lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
    lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
    lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/branches/lldb-platform-work/source/Symbol/Symbol.cpp
    lldb/branches/lldb-platform-work/tools/debugserver/source/DNB.cpp
    lldb/branches/lldb-platform-work/tools/debugserver/source/DNB.h
    lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/MachProcess.cpp
    lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/MachProcess.h
    lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
    lldb/branches/lldb-platform-work/tools/debugserver/source/RNBRemote.cpp
    lldb/branches/lldb-platform-work/tools/debugserver/source/RNBRemote.h
    lldb/branches/lldb-platform-work/tools/debugserver/source/RNBServices.cpp

Propchange: lldb/branches/lldb-platform-work/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 25 17:25:17 2012
@@ -1 +1 @@
-/lldb/trunk:154223-160596
+/lldb/trunk:154223-160756

Modified: lldb/branches/lldb-platform-work/include/lldb/Target/RegisterContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/Target/RegisterContext.h?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/Target/RegisterContext.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/Target/RegisterContext.h Wed Jul 25 17:25:17 2012
@@ -59,6 +59,13 @@
     virtual bool
     WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value) = 0;
     
+    // These two functions are used to implement "push" and "pop" of register states.  They are used primarily
+    // for expression evaluation, where we need to push a new state (storing the old one in data_sp) and then
+    // restoring the original state by passing the data_sp we got from ReadAllRegisters to WriteAllRegisterValues.
+    // ReadAllRegisters will do what is necessary to return a coherent set of register values for this thread, which
+    // may mean e.g. interrupting a thread that is sitting in a kernel trap.  That is a somewhat disruptive operation,
+    // so these API's should only be used when this behavior is needed.
+    
     virtual bool
     ReadAllRegisterValues (lldb::DataBufferSP &data_sp) = 0;
 

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Wed Jul 25 17:25:17 2012
@@ -52,6 +52,7 @@
     m_supports_watchpoint_support_info  (eLazyBoolCalculate),
     m_watchpoints_trigger_after_instruction(eLazyBoolCalculate),
     m_attach_or_wait_reply(eLazyBoolCalculate),
+    m_prepare_for_reg_writing_reply (eLazyBoolCalculate),
     m_supports_qProcessInfoPID (true),
     m_supports_qfProcessInfo (true),
     m_supports_qUserName (true),
@@ -155,6 +156,26 @@
         return false;
 }
 
+bool
+GDBRemoteCommunicationClient::GetSyncThreadStateSupported ()
+{
+    if (m_prepare_for_reg_writing_reply == eLazyBoolCalculate)
+    {
+        m_prepare_for_reg_writing_reply = eLazyBoolNo;
+        
+        StringExtractorGDBRemote response;
+        if (SendPacketAndWaitForResponse("qSyncThreadStateSupported", response, false))
+        {
+            if (response.IsOKResponse())
+                m_prepare_for_reg_writing_reply = eLazyBoolYes;
+        }
+    }
+    if (m_prepare_for_reg_writing_reply == eLazyBoolYes)
+        return true;
+    else
+        return false;
+}
+
 
 void
 GDBRemoteCommunicationClient::ResetDiscoverableSettings()
@@ -169,6 +190,8 @@
     m_qHostInfo_is_valid = eLazyBoolCalculate;
     m_supports_alloc_dealloc_memory = eLazyBoolCalculate;
     m_supports_memory_region_info = eLazyBoolCalculate;
+    m_prepare_for_reg_writing_reply = eLazyBoolCalculate;
+    m_attach_or_wait_reply = eLazyBoolCalculate;
 
     m_supports_qProcessInfoPID = true;
     m_supports_qfProcessInfo = true;

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Wed Jul 25 17:25:17 2012
@@ -224,6 +224,9 @@
     bool
     GetVAttachOrWaitSupported ();
     
+    bool
+    GetSyncThreadStateSupported();
+    
     void
     ResetDiscoverableSettings();
 
@@ -409,6 +412,7 @@
     lldb_private::LazyBool m_supports_watchpoint_support_info;
     lldb_private::LazyBool m_watchpoints_trigger_after_instruction;
     lldb_private::LazyBool m_attach_or_wait_reply;
+    lldb_private::LazyBool m_prepare_for_reg_writing_reply;
     
     bool
         m_supports_qProcessInfoPID:1,

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Wed Jul 25 17:25:17 2012
@@ -286,7 +286,6 @@
     return true;
 }
 
-
 bool
 GDBRemoteRegisterContext::WriteRegister (const RegisterInfo *reg_info,
                                          const RegisterValue &value)
@@ -326,6 +325,29 @@
     }
     return false;
 }
+
+void
+GDBRemoteRegisterContext::SyncThreadState(Process *process)
+{
+    // NB.  We assume our caller has locked the sequence mutex.
+    
+    GDBRemoteCommunicationClient &gdb_comm (((ProcessGDBRemote *) process)->GetGDBRemote());
+    if (!gdb_comm.GetSyncThreadStateSupported())
+        return;
+
+    StreamString packet;
+    StringExtractorGDBRemote response;
+    packet.Printf ("QSyncThreadState:%4.4llx;", m_thread.GetID());
+    if (gdb_comm.SendPacketAndWaitForResponse(packet.GetString().c_str(),
+                                              packet.GetString().size(),
+                                              response,
+                                              false))
+    {
+        if (response.IsOKResponse())
+            InvalidateAllRegisters();
+    }
+}
+
 bool
 GDBRemoteRegisterContext::WriteRegisterBytes (const lldb_private::RegisterInfo *reg_info, DataExtractor &data, uint32_t data_offset)
 {
@@ -479,6 +501,8 @@
     Mutex::Locker locker;
     if (gdb_comm.GetSequenceMutex (locker, "Didn't get sequence mutex for read all registers."))
     {
+        SyncThreadState(process);
+        
         char packet[32];
         const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported();
         ProcessSP process_sp (m_thread.GetProcess());

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h Wed Jul 25 17:25:17 2012
@@ -243,6 +243,9 @@
     void
     SetAllRegisterValid (bool b);
 
+    void
+    SyncThreadState(lldb_private::Process *process);  // Assumes the sequence mutex has already been acquired.
+    
     GDBRemoteDynamicRegisterInfo &m_reg_info;
     std::vector<bool> m_reg_valid;
     lldb_private::DataExtractor m_reg_data;

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Jul 25 17:25:17 2012
@@ -48,13 +48,13 @@
 // Project includes
 #include "lldb/Host/Host.h"
 #include "Plugins/Process/Utility/InferiorCallPOSIX.h"
+#include "Plugins/Process/Utility/StopInfoMachException.h"
 #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
 #include "Utility/StringExtractorGDBRemote.h"
 #include "GDBRemoteRegisterContext.h"
 #include "ProcessGDBRemote.h"
 #include "ProcessGDBRemoteLog.h"
 #include "ThreadGDBRemote.h"
-#include "StopInfoMachException.h"
 
 namespace lldb
 {

Modified: lldb/branches/lldb-platform-work/source/Symbol/Symbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Symbol/Symbol.cpp?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Symbol/Symbol.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Symbol/Symbol.cpp Wed Jul 25 17:25:17 2012
@@ -277,6 +277,12 @@
                                                                         sc))
             {
                 m_type_data = sc.line_entry.range.GetByteSize();
+                // Sanity check - this may be a function in the middle of code that has debug information, but
+                // not for this symbol.  So the line entries surrounding us won't lie inside our function.
+                // In that case, the line entry will be bigger than we are, so we do that quick check and
+                // if that is true, we just return 0.
+                if (m_type_data >= m_addr_range.GetByteSize())
+                    m_type_data = 0;
             }
             else
             {

Modified: lldb/branches/lldb-platform-work/tools/debugserver/source/DNB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/tools/debugserver/source/DNB.cpp?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/tools/debugserver/source/DNB.cpp (original)
+++ lldb/branches/lldb-platform-work/tools/debugserver/source/DNB.cpp Wed Jul 25 17:25:17 2012
@@ -1797,6 +1797,19 @@
     return INVALID_NUB_THREAD;
 }
 
+//----------------------------------------------------------------------
+// Do whatever is needed to sync the thread's register state with it's kernel values.
+//----------------------------------------------------------------------
+nub_bool_t
+DNBProcessSyncThreadState (nub_process_t pid, nub_thread_t tid)
+{
+    MachProcessSP procSP;
+    if (GetProcessSP (pid, procSP))
+        return procSP->SyncThreadState (tid);
+    return false;
+
+}
+
 nub_addr_t
 DNBProcessGetSharedLibraryInfoAddress (nub_process_t pid)
 {

Modified: lldb/branches/lldb-platform-work/tools/debugserver/source/DNB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/tools/debugserver/source/DNB.h?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/tools/debugserver/source/DNB.h (original)
+++ lldb/branches/lldb-platform-work/tools/debugserver/source/DNB.h Wed Jul 25 17:25:17 2012
@@ -79,6 +79,7 @@
 nub_thread_t    DNBProcessGetCurrentThread              (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;
 nub_addr_t      DNBProcessGetSharedLibraryInfoAddress   (nub_process_t pid) DNB_EXPORT;
 nub_bool_t      DNBProcessSharedLibrariesUpdated        (nub_process_t pid) DNB_EXPORT;
 nub_size_t      DNBProcessGetSharedLibraryInfo          (nub_process_t pid, nub_bool_t only_changed, DNBExecutableImageInfo **image_infos) DNB_EXPORT;

Modified: lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/MachProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/MachProcess.cpp (original)
+++ lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/MachProcess.cpp Wed Jul 25 17:25:17 2012
@@ -49,28 +49,8 @@
 static bool
 IsSBProcess (nub_process_t pid)
 {
-    bool opt_runningApps = true;
-    bool opt_debuggable = false;
-
-    CFReleaser<CFArrayRef> sbsAppIDs (::SBSCopyApplicationDisplayIdentifiers (opt_runningApps, opt_debuggable));
-    if (sbsAppIDs.get() != NULL)
-    {
-        CFIndex count = ::CFArrayGetCount (sbsAppIDs.get());
-        CFIndex i = 0;
-        for (i = 0; i < count; i++)
-        {
-            CFStringRef displayIdentifier = (CFStringRef)::CFArrayGetValueAtIndex (sbsAppIDs.get(), i);
-
-            // Get the process id for the app (if there is one)
-            pid_t sbs_pid = INVALID_NUB_PROCESS;
-            if (::SBSProcessIDForDisplayIdentifier ((CFStringRef)displayIdentifier, &sbs_pid) == TRUE)
-            {
-                if (sbs_pid == pid)
-                    return true;
-            }
-        }
-    }
-    return false;
+    CFReleaser<CFArrayRef> appIdsForPID (::SBSCopyDisplayIdentifiersForProcessID(pid));
+    return appIdsForPID.get() != NULL;
 }
 
 #endif
@@ -171,6 +151,22 @@
     return m_thread_list.ThreadIDAtIndex(thread_idx);
 }
 
+nub_bool_t
+MachProcess::SyncThreadState (nub_thread_t tid)
+{
+    MachThreadSP thread_sp(m_thread_list.GetThreadByID(tid));
+    if (!thread_sp)
+        return false;
+    kern_return_t kret = ::thread_abort_safely(thread_sp->ThreadID());
+    DNBLogThreadedIf (LOG_THREAD, "thread = 0x%4.4x calling thread_abort_safely (tid) => %u (GetGPRState() for stop_count = %u)", thread_sp->ThreadID(), kret, thread_sp->Process()->StopCount());
+
+    if (kret == KERN_SUCCESS)
+        return true;
+    else
+        return false;
+    
+}
+
 nub_thread_t
 MachProcess::GetCurrentThread ()
 {

Modified: lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/MachProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/MachProcess.h?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/MachProcess.h (original)
+++ lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/MachProcess.h Wed Jul 25 17:25:17 2012
@@ -159,6 +159,7 @@
                             GetRegisterSetInfo (nub_thread_t tid, nub_size_t *num_reg_sets) const;
     bool                    GetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, DNBRegisterValue *reg_value) const;
     bool                    SetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, const DNBRegisterValue *value) const;
+    nub_bool_t              SyncThreadState (nub_thread_t tid);
     const char *            ThreadGetName (nub_thread_t tid);
     nub_state_t             ThreadGetState (nub_thread_t tid);
     nub_size_t              GetNumThreads () const;

Modified: lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original)
+++ lldb/branches/lldb-platform-work/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Wed Jul 25 17:25:17 2012
@@ -155,9 +155,6 @@
 {
     if (force || m_state.GetError(e_regSetGPR, Read))
     {
-        kern_return_t kret = ::thread_abort_safely(m_thread->ThreadID());
-        DNBLogThreadedIf (LOG_THREAD, "thread = 0x%4.4x calling thread_abort_safely (tid) => %u (GetGPRState() for stop_count = %u)", m_thread->ThreadID(), kret, m_thread->Process()->StopCount());    
-
 #if DEBUG_GPR_VALUES
         m_state.context.gpr.__rax = ('a' << 8) + 'x';
         m_state.context.gpr.__rbx = ('b' << 8) + 'x';

Modified: lldb/branches/lldb-platform-work/tools/debugserver/source/RNBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/tools/debugserver/source/RNBRemote.cpp?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/tools/debugserver/source/RNBRemote.cpp (original)
+++ lldb/branches/lldb-platform-work/tools/debugserver/source/RNBRemote.cpp Wed Jul 25 17:25:17 2012
@@ -171,6 +171,7 @@
     t.push_back (Packet (query_shlib_notify_info_addr,  &RNBRemote::HandlePacket_qShlibInfoAddr,NULL, "qShlibInfoAddr", "Returns the address that contains info needed for getting shared library notifications"));
     t.push_back (Packet (query_step_packet_supported,   &RNBRemote::HandlePacket_qStepPacketSupported,NULL, "qStepPacketSupported", "Replys with OK if the 's' packet is supported."));
     t.push_back (Packet (query_vattachorwait_supported, &RNBRemote::HandlePacket_qVAttachOrWaitSupported,NULL, "qVAttachOrWaitSupported", "Replys with OK if the 'vAttachOrWait' packet is supported."));
+    t.push_back (Packet (query_sync_thread_state_supported, &RNBRemote::HandlePacket_qSyncThreadStateSupported,NULL, "qSyncThreadStateSupported", "Replys with OK if the 'QSyncThreadState:' packet is supported."));
     t.push_back (Packet (query_host_info,               &RNBRemote::HandlePacket_qHostInfo,     NULL, "qHostInfo", "Replies with multiple 'key:value;' tuples appended to each other."));
 //  t.push_back (Packet (query_symbol_lookup,           &RNBRemote::HandlePacket_UNIMPLEMENTED, NULL, "qSymbol", "Notify that host debugger is ready to do symbol lookups"));
     t.push_back (Packet (start_noack_mode,              &RNBRemote::HandlePacket_QStartNoAckMode        , NULL, "QStartNoAckMode", "Request that " DEBUGSERVER_PROGRAM_NAME " stop acking remote protocol packets"));
@@ -187,6 +188,7 @@
     t.push_back (Packet (set_stderr,                    &RNBRemote::HandlePacket_QSetSTDIO              , NULL, "QSetSTDERR:", "Set the standard error for a process to be launched with the 'A' packet"));
     t.push_back (Packet (set_working_dir,               &RNBRemote::HandlePacket_QSetWorkingDir         , NULL, "QSetWorkingDir:", "Set the working directory for a process to be launched with the 'A' packet"));
     t.push_back (Packet (set_list_threads_in_stop_reply,&RNBRemote::HandlePacket_QListThreadsInStopReply , NULL, "QListThreadsInStopReply", "Set if the 'threads' key should be added to the stop reply packets with a list of all thread IDs."));
+    t.push_back (Packet (sync_thread_state,             &RNBRemote::HandlePacket_QSyncThreadState , NULL, "QSyncThreadState:", "Do whatever is necessary to make sure 'thread' is in a safe state to call functions on."));
 //  t.push_back (Packet (pass_signals_to_inferior,      &RNBRemote::HandlePacket_UNIMPLEMENTED, NULL, "QPassSignals:", "Specify which signals are passed to the inferior"));
     t.push_back (Packet (allocate_memory,               &RNBRemote::HandlePacket_AllocateMemory, NULL, "_M", "Allocate memory in the inferior process."));
     t.push_back (Packet (deallocate_memory,             &RNBRemote::HandlePacket_DeallocateMemory, NULL, "_m", "Deallocate memory in the inferior process."));
@@ -1304,6 +1306,13 @@
 }
 
 rnb_err_t
+RNBRemote::HandlePacket_qSyncThreadStateSupported (const char *p)
+{
+    // We support attachOrWait meaning attach if the process exists, otherwise wait to attach.
+    return SendPacket("OK");
+}
+
+rnb_err_t
 RNBRemote::HandlePacket_qVAttachOrWaitSupported (const char *p)
 {
     // We support attachOrWait meaning attach if the process exists, otherwise wait to attach.
@@ -1881,6 +1890,30 @@
 }
 
 rnb_err_t
+RNBRemote::HandlePacket_QSyncThreadState (const char *p)
+{
+    if (!m_ctx.HasValidProcessID())
+    {
+        // We allow gdb to connect to a server that hasn't started running
+        // the target yet.  gdb still wants to ask questions about it and
+        // freaks out if it gets an error.  So just return OK here.
+        return SendPacket ("OK");
+    }
+
+    errno = 0;
+    p += strlen("QSyncThreadState:");
+    nub_thread_t tid = strtoul (p, NULL, 16);
+    if (errno != 0 && tid == 0)
+    {
+        return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Invalid thread number in QSyncThreadState packet");
+    }
+    if (DNBProcessSyncThreadState(m_ctx.ProcessID(), tid))
+        return SendPacket("OK");
+    else
+        return SendPacket ("E61");
+}
+
+rnb_err_t
 RNBRemote::HandlePacket_QListThreadsInStopReply (const char *p)
 {
     // If this packet is received, it allows us to send an extra key/value

Modified: lldb/branches/lldb-platform-work/tools/debugserver/source/RNBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/tools/debugserver/source/RNBRemote.h?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/tools/debugserver/source/RNBRemote.h (original)
+++ lldb/branches/lldb-platform-work/tools/debugserver/source/RNBRemote.h Wed Jul 25 17:25:17 2012
@@ -93,6 +93,7 @@
         query_shlib_notify_info_addr,   // 'qShlibInfoAddr'
         query_step_packet_supported,    // 'qStepPacketSupported'
         query_vattachorwait_supported,  // 'qVAttachOrWaitSupported'
+        query_sync_thread_state_supported,// 'QSyncThreadState'
         query_host_info,                // 'qHostInfo'
         pass_signals_to_inferior,       // 'QPassSignals'
         start_noack_mode,               // 'QStartNoAckMode'
@@ -109,6 +110,7 @@
         set_stderr,                     // 'QSetSTDERR:'
         set_working_dir,                // 'QSetWorkingDir:'
         set_list_threads_in_stop_reply, // 'QListThreadsInStopReply:'
+        sync_thread_state,              // 'QSyncThreadState:'
         memory_region_info,             // 'qMemoryRegionInfo:'
         watchpoint_support_info,        // 'qWatchpointSupportInfo:'
         allocate_memory,                // '_M'
@@ -167,6 +169,7 @@
     rnb_err_t HandlePacket_qShlibInfoAddr (const char *p);
     rnb_err_t HandlePacket_qStepPacketSupported (const char *p);
     rnb_err_t HandlePacket_qVAttachOrWaitSupported (const char *p);
+    rnb_err_t HandlePacket_qSyncThreadStateSupported (const char *p);
     rnb_err_t HandlePacket_qThreadInfo (const char *p);
     rnb_err_t HandlePacket_qThreadExtraInfo (const char *p);
     rnb_err_t HandlePacket_qThreadStopInfo (const char *p);
@@ -183,6 +186,7 @@
     rnb_err_t HandlePacket_QEnvironmentHexEncoded (const char *p);
     rnb_err_t HandlePacket_QLaunchArch (const char *p);
     rnb_err_t HandlePacket_QListThreadsInStopReply (const char *p);
+    rnb_err_t HandlePacket_QSyncThreadState (const char *p);
     rnb_err_t HandlePacket_QPrefixRegisterPacketsWithThreadID (const char *p);
     rnb_err_t HandlePacket_last_signal (const char *p);
     rnb_err_t HandlePacket_m (const char *p);

Modified: lldb/branches/lldb-platform-work/tools/debugserver/source/RNBServices.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/tools/debugserver/source/RNBServices.cpp?rev=160765&r1=160764&r2=160765&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/tools/debugserver/source/RNBServices.cpp (original)
+++ lldb/branches/lldb-platform-work/tools/debugserver/source/RNBServices.cpp Wed Jul 25 17:25:17 2012
@@ -120,28 +120,10 @@
 IsSBProcess (nub_process_t pid)
 {
 #ifdef WITH_SPRINGBOARD
-    bool opt_runningApps = true;
-    bool opt_debuggable = false;
-
-    CFReleaser<CFArrayRef> sbsAppIDs (::SBSCopyApplicationDisplayIdentifiers (opt_runningApps, opt_debuggable));
-    if (sbsAppIDs.get() != NULL)
-    {
-        CFIndex count = ::CFArrayGetCount (sbsAppIDs.get());
-        CFIndex i = 0;
-        for (i = 0; i < count; i++)
-        {
-            CFStringRef displayIdentifier = (CFStringRef)::CFArrayGetValueAtIndex (sbsAppIDs.get(), i);
-
-            // Get the process id for the app (if there is one)
-            pid_t sbs_pid = INVALID_NUB_PROCESS;
-            if (::SBSProcessIDForDisplayIdentifier ((CFStringRef)displayIdentifier, &sbs_pid) == TRUE)
-            {
-                if (sbs_pid == pid)
-                    return true;
-            }
-        }
-    }
-#endif
+    CFReleaser<CFArrayRef> appIdsForPID (::SBSCopyDisplayIdentifiersForProcessID(pid));
+    return appIdsForPID.get() != NULL;
+#else
     return false;
+#endif
 }
 





More information about the lldb-commits mailing list