public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 1/4] tracepoint multithread and multiprocess support (GDB remote)
@ 2013-12-19  3:29 Hui Zhu
  0 siblings, 0 replies; only message in thread
From: Hui Zhu @ 2013-12-19  3:29 UTC (permalink / raw)
  To: gdb-patches ml

This version doesn't have big change, just update follow GDB trunk
and update Changelog.

GDB tracepoint had supported multithread and multiprocess.
But in GDB remote, GDBRSP and gdbserver doesn't support it.

These patches add tracepoint multithread and multiprocess support to GDB.

The GDBRSP format of this support is add P@var{thread-id} to QTDP packets.
If gdbstub support tracepoint multithread and multiprocess, it will send
"MultiProcessTracepoint+" to GDB.
Then GDB remote will add P@var{thread-id} with QTDP.
If a thread is specified with tracepoint, send the ptid of thread.
It doesn't need process info because the ptid's pid is OK for process.
If this tracepoint is not specified a thread and GDB/gdbserver support
multiprocess(remote_multi_process_p), send ptid with the pid of the
process and 0 for lwp and tid means that any thread of this process is OK.
So even if this tracepoint is not for current process, GDB still send
this tracepoint to stub because support or not support multiprocess
tracepoint based on gdbstub (There is already a gdbstub support
multiprocess tracepoint, KGTP).

These patches is tested and pass the regression test in x86_64 linux
native-extended-gdbserver and native-gdbserver.

Following patch is patch for GDB remote.c.  Please help me review it.

Thanks,
Hui

2013-12-19  Hui Zhu  <teawater@gmail.com>

	* remote.c (PACKET_MultiPorcessTracepoint): New.
	(remote_protocol_features): Add "MultiProcessTracepoint".
	(remote_download_tracepoint): Send ptid with packets if need.
	(_initialize_remote): Add "multi-process-tracepoint".

--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1367,6 +1367,7 @@ enum {
    PACKET_Qbtrace_off,
    PACKET_Qbtrace_bts,
    PACKET_qXfer_btrace,
+  PACKET_MultiPorcessTracepoint,
    PACKET_MAX
  };
  
@@ -4063,7 +4064,9 @@ static const struct protocol_feature rem
    { "Qbtrace:off", PACKET_DISABLE, remote_supported_packet, PACKET_Qbtrace_off },
    { "Qbtrace:bts", PACKET_DISABLE, remote_supported_packet, PACKET_Qbtrace_bts },
    { "qXfer:btrace:read", PACKET_DISABLE, remote_supported_packet,
-    PACKET_qXfer_btrace }
+    PACKET_qXfer_btrace },
+  { "MultiProcessTracepoint", PACKET_DISABLE,
+    remote_supported_packet, PACKET_MultiPorcessTracepoint },
  };
  
  static char *remote_support_xml;
@@ -10593,6 +10596,48 @@ remote_download_tracepoint (struct bp_lo
  	   to give up on the trace run.  */
  	error (_("Target does not support static tracepoints"));
      }
+
+  /* If target support multiprocess tracepoint, send pid of the location's
+     program space with packets.  */
+  if (remote_protocol_packets[PACKET_MultiPorcessTracepoint].support
+	== PACKET_ENABLE)
+    {
+      ptid_t tracepoint_ptid;
+      struct remote_state *rs = get_remote_state ();
+      int got_tracepoint_ptid = 0;
+
+      if (loc->owner->thread != -1)
+        {
+	  tracepoint_ptid = thread_id_to_pid (loc->owner->thread);
+	  if (!in_thread_list (tracepoint_ptid))
+	    error (_("Cannot find thread %d for tracepoint %d"),
+		   loc->owner->thread, loc->owner->number);
+	  got_tracepoint_ptid = 1;
+	}
+      else if (remote_multi_process_p (rs))
+        {
+	  struct inferior *inf;
+
+	  ALL_INFERIORS (inf)
+	    {
+	      if (inf->pspace == loc->pspace)
+		{
+		  tracepoint_ptid = ptid_build (inf->pid, 0, 0);
+		  got_tracepoint_ptid = 1;
+		  break;
+		}
+	    }
+	  if (got_tracepoint_ptid == 0)
+	    error (_("Cannot find inferior for tracepoint %d"),
+		   loc->owner->number);
+	}
+      if (got_tracepoint_ptid)
+        {
+	  strcat (buf, ":P");
+	  write_ptid (buf + strlen (buf), buf + BUF_SIZE, tracepoint_ptid);
+	}
+    }
+
    /* If the tracepoint has a conditional, make it into an agent
       expression and append to the definition.  */
    if (loc->cond)
@@ -12183,6 +12228,9 @@ Show the maximum size of the address (in
    add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_btrace],
         "qXfer:btrace", "read-btrace", 0);
  
+  add_packet_config_cmd (&remote_protocol_packets[PACKET_MultiPorcessTracepoint],
+       "MultiProcessTracepoint", "multi-process-tracepoint", 0);
+
    /* Keep the old ``set remote Z-packet ...'' working.  Each individual
       Z sub-packet has its own set and show commands, but users may
       have sets to this variable in their .gdbinit files (or in their

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-12-19  3:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-19  3:29 [PATCH v2 1/4] tracepoint multithread and multiprocess support (GDB remote) Hui Zhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).