[Lldb-commits] [lldb] r136055 - in /lldb/trunk/tools/debugserver/source: RNBRemote.cpp RNBRemote.h

Jason Molenda jmolenda at apple.com
Mon Jul 25 20:34:52 PDT 2011

Author: jmolenda
Date: Mon Jul 25 22:34:52 2011
New Revision: 136055

URL: http://llvm.org/viewvc/llvm-project?rev=136055&view=rev
RNBRemote.cpp, RNBRemote.h: Add a new qGetPid packet which returns
the pid of the process currently being debugged by debugserer in
hex, or 0 if unavailable.

This is effectively the same as the qC packet but that packet is
not clear in either its documentation or implementation (in gdb et al)
as to whether it is intended to return a pid or a thread id.  qGetPid
is unambiguous.

If qGetPid is unimplemented in the remote debugserver, the debugger may
try qC and see what kind of value is returned..


Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=136055&r1=136054&r2=136055&view=diff
--- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original)
+++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Mon Jul 25 22:34:52 2011
@@ -154,6 +154,7 @@
 //  t.push_back (Packet (insert_access_watch_bp,        &RNBRemote::HandlePacket_UNIMPLEMENTED, NULL, "Z4", "Insert access watchpoint"));
 //  t.push_back (Packet (remove_access_watch_bp,        &RNBRemote::HandlePacket_UNIMPLEMENTED, NULL, "z4", "Remove access watchpoint"));
     t.push_back (Packet (query_current_thread_id,       &RNBRemote::HandlePacket_qC,            NULL, "qC", "Query current thread ID"));
+    t.push_back (Packet (query_get_pid,                 &RNBRemote::HandlePacket_qGetPid,       NULL, "qGetPid", "Query process id"));
 //  t.push_back (Packet (query_memory_crc,              &RNBRemote::HandlePacket_UNIMPLEMENTED, NULL, "qCRC:", "Compute CRC of memory region"));
     t.push_back (Packet (query_thread_ids_first,        &RNBRemote::HandlePacket_qThreadInfo,   NULL, "qfThreadInfo", "Get list of active threads (first req)"));
     t.push_back (Packet (query_thread_ids_subsequent,   &RNBRemote::HandlePacket_qThreadInfo,   NULL, "qsThreadInfo", "Get list of active threads (subsequent req)"));
@@ -1394,6 +1395,21 @@
+RNBRemote::HandlePacket_qGetPid (const char *p)
+    nub_process_t pid;
+    std::ostringstream rep;
+    // If we haven't run the process yet, we tell the debugger the
+    // pid is 0.  That way it can know to tell use to run later on.
+    if (m_ctx.HasValidProcessID())
+        pid = m_ctx.ProcessID();
+    else
+        pid = 0;
+    rep << std::hex << pid;
+    return SendPacket (rep.str());
 RNBRemote::HandlePacket_qRegisterInfo (const char *p)
     if (g_num_reg_entries == 0)

Modified: lldb/trunk/tools/debugserver/source/RNBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.h?rev=136055&r1=136054&r2=136055&view=diff
--- lldb/trunk/tools/debugserver/source/RNBRemote.h (original)
+++ lldb/trunk/tools/debugserver/source/RNBRemote.h Mon Jul 25 22:34:52 2011
@@ -79,6 +79,7 @@
         remove_access_watch_bp,         // 'z4'
         query_current_thread_id,        // 'qC'
+        query_get_pid,                  // 'qGetPid'
         query_memory_crc,               // 'qCRC:'
         query_thread_ids_first,         // 'qfThreadInfo'
         query_thread_ids_subsequent,    // 'qsThreadInfo'
@@ -155,6 +156,7 @@
     rnb_err_t HandlePacket_A (const char *p);
     rnb_err_t HandlePacket_H (const char *p);
     rnb_err_t HandlePacket_qC (const char *p);
+    rnb_err_t HandlePacket_qGetPid (const char *p);
     rnb_err_t HandlePacket_qLaunchSuccess (const char *p);
     rnb_err_t HandlePacket_qRegisterInfo (const char *p);
     rnb_err_t HandlePacket_qShlibInfoAddr (const char *p);

More information about the lldb-commits mailing list