This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfc v2][2/6] Always enable multi-process remote extension if possible


Hello,

this is basically Pedro's patch 04-allow_multi_on_remote.diff from:
http://sourceware.org/ml/gdb-patches/2012-01/msg00353.html
to allow the remote protocol thread id extension on plain target remote.

The only difference is that I've also changed remote_pid_to_str to
continue using the "Thread TID" syntax instead of "Thread PID.TID"
if extended mode is not used; this is to avoid unnecessary UI changes
(which actually triggered test suite fails ...).

Bye,
Ulrich


From: Pedro Alves <palves@redhat.com>

ChangeLog:

	* remote.c (remote_multi_process_p): Only check for multi-process
	protocol feature, do not check for extended protocol.
	(remote_supports_multi_process): Check for extended protocol here.
	(set_general_process): Likewise.
	(extended_remote_kill): Likewise.
	(remote_pid_to_str): Likewise.
	(remote_query_supported): Always query multiprocess mode.

gdbserver/ChangeLog:

	* server.c (handle_v_requests): Only support vAttach and vRun to
	start multiple processes when in extended protocol mode.


Index: gdb-head/gdb/gdbserver/server.c
===================================================================
--- gdb-head.orig/gdb/gdbserver/server.c	2012-01-13 18:44:36.000000000 +0100
+++ gdb-head/gdb/gdbserver/server.c	2012-01-13 18:45:56.000000000 +0100
@@ -2140,7 +2140,7 @@ handle_v_requests (char *own_buf, int pa
 
   if (strncmp (own_buf, "vAttach;", 8) == 0)
     {
-      if (!multi_process && target_running ())
+      if ((!extended_protocol || !multi_process) && target_running ())
 	{
 	  fprintf (stderr, "Already debugging a process\n");
 	  write_enn (own_buf);
@@ -2152,7 +2152,7 @@ handle_v_requests (char *own_buf, int pa
 
   if (strncmp (own_buf, "vRun;", 5) == 0)
     {
-      if (!multi_process && target_running ())
+      if ((!extended_protocol || !multi_process) && target_running ())
 	{
 	  fprintf (stderr, "Already debugging a process\n");
 	  write_enn (own_buf);
Index: gdb-head/gdb/remote.c
===================================================================
--- gdb-head.orig/gdb/remote.c	2012-01-13 18:45:55.000000000 +0100
+++ gdb-head/gdb/remote.c	2012-01-13 18:45:56.000000000 +0100
@@ -359,7 +359,7 @@ free_private_thread_info (struct private
 static int
 remote_multi_process_p (struct remote_state *rs)
 {
-  return rs->extended && rs->multi_process_aware;
+  return rs->multi_process_aware;
 }
 
 /* This data could be associated with a target, but we do not always
@@ -1713,7 +1713,7 @@ set_general_process (void)
   struct remote_state *rs = get_remote_state ();
 
   /* If the remote can't handle multiple processes, don't bother.  */
-  if (!remote_multi_process_p (rs))
+  if (!rs->extended || !remote_multi_process_p (rs))
     return;
 
   /* We only need to change the remote current thread if it's pointing
@@ -3885,8 +3885,7 @@ remote_query_supported (void)
       char *q = NULL;
       struct cleanup *old_chain = make_cleanup (free_current_contents, &q);
 
-      if (rs->extended)
-	q = remote_query_supported_append (q, "multiprocess+");
+      q = remote_query_supported_append (q, "multiprocess+");
 
       if (remote_support_xml)
 	q = remote_query_supported_append (q, remote_support_xml);
@@ -7440,7 +7439,7 @@ extended_remote_kill (struct target_ops 
   struct remote_state *rs = get_remote_state ();
 
   res = remote_vkill (pid, rs);
-  if (res == -1 && !remote_multi_process_p (rs))
+  if (res == -1 && !(rs->extended && remote_multi_process_p (rs)))
     {
       /* Don't try 'k' on a multi-process aware stub -- it has no way
 	 to specify the pid.  */
@@ -8832,7 +8831,7 @@ remote_pid_to_str (struct target_ops *op
     {
       if (ptid_equal (magic_null_ptid, ptid))
 	xsnprintf (buf, sizeof buf, "Thread <main>");
-      else if (remote_multi_process_p (rs))
+      else if (rs->extended && remote_multi_process_p (rs))
 	xsnprintf (buf, sizeof buf, "Thread %d.%ld",
 		   ptid_get_pid (ptid), ptid_get_tid (ptid));
       else
@@ -9773,7 +9772,11 @@ remote_supports_multi_process (void)
 {
   struct remote_state *rs = get_remote_state ();
 
-  return remote_multi_process_p (rs);
+  /* Only extended-remote handles being attached to multiple
+     processes, even though plain remote can use the multi-process
+     thread id extensions, so that GDB knows the target process's
+     PID.  */
+  return rs->extended && remote_multi_process_p (rs);
 }
 
 int

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]