Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org,  Stan Shebs <stan@codesourcery.com>
Subject: tracing broken if target doesn't do disconnected tracing
Date: Mon, 05 Apr 2010 00:01:00 -0000	[thread overview]
Message-ID: <201004050101.02067.pedro@codesourcery.com> (raw)

The gdbserver tracepoints patch I just posted doesn't
include disconnected tracing yet.  Note what
happens then:

 (gdb) tar remote :9999
 Remote debugging using :9999
 Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug/lib/ld-2.10.1.so...done.
 done.
 Loaded symbols for /lib64/ld-linux-x86-64.so.2
 0x00007f62e8519af0 in _start () from /lib64/ld-linux-x86-64.so.2
 (gdb) trace main
 Tracepoint 1 at 0x400640: file threads.c, line 35.
 (gdb) tstart
 Target does not support this command.

Taking a closer look, here's the problem:

 (gdb) set debug remote 1
 (gdb) tstart
 Sending packet: $QTinit#59...Packet received: OK
 Sending packet: $QTDP:1:0000000000400640:E:0:0#3f...Packet received: OK
 Sending packet: $QTDPsrc:1:400640:at:0:4:6d61696e#80...Packet received: OK
 Sending packet: $QTro:0000000000400200,000000000040021c:000000000040021c,000000000040023c:0000000000400240,0000000000400278:0000000000400278,0000000000400294:0000000000400298,0000000000400370:0000000000400370,00000000004003fc:00000000004003fc,000000000040040e:0000000000400410,0000000000400450:0000000000400450,0000000000400468:0000000000400468,00000000004004f8:00000000004004f8,0000000000400510:0000000000400510,0000000000400580:0000000000400580,0000000000400868:0000000000400868,0000000000400876:0000000000400878,000000000040087c:000000000040087c,00000000004008b0:00000000004008b0,00000000004009a4#5c...Packet received: OK
 Sending packet: $QTDisconnected:0#e2...Packet received:
 Target does not support this command.
 (gdb)

Below's the patch I'm using to get around this.

You'll still see GDB offering to leave the
trace running after disconnecting:

 ...
 (gdb) trace main
 Tracepoint 1 at 0x400640: file threads.c, line 35.
 (gdb) tstart
 (gdb) detach
 Trace is running.  Continue tracing after detach? (y or n) y
 warning: Target does not support disconnected tracing.
 Ending remote debugging.
 (gdb)

This is because common code outside remote.c has no clue
whether the target supports or not disconnected tracing, and
just assumes it does.  Exposing that property seems to
conflict a bit with the desire to allow
"set disconnected-tracing on" before actually being connected,
so, I've avoided doing it so far.  Maybe we could get away with
a tristate "yes|no|not-known-yet-maybe".

WDYT?  Shall I proceed with this as is?  Would you like to
address this?

-- 
Pedro Alves

2010-04-05  Pedro Alves  <pedro@codesourcery.com>

	gdb/
	* remote.c (remote_set_disconnected_tracing): Only set
	QTDisconnected if the remote end supports disconnected tracing.
	Warn otherwise, if trying to enable disconnected tracing.

---
 gdb/remote.c |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Index: src/gdb/remote.c
===================================================================
--- src.orig/gdb/remote.c	2010-04-04 23:55:38.000000000 +0100
+++ src/gdb/remote.c	2010-04-05 00:40:57.000000000 +0100
@@ -9776,11 +9776,16 @@ remote_set_disconnected_tracing (int val
 {
   struct remote_state *rs = get_remote_state ();
 
-  sprintf (rs->buf, "QTDisconnected:%x", val);
-  putpkt (rs->buf);
-  remote_get_noisy_reply (&target_buf, &target_buf_size);
-  if (strcmp (target_buf, "OK"))
-    error (_("Target does not support this command."));
+  if (rs->disconnected_tracing)
+    {
+      sprintf (rs->buf, "QTDisconnected:%x", val);
+      putpkt (rs->buf);
+      remote_get_noisy_reply (&target_buf, &target_buf_size);
+      if (strcmp (target_buf, "OK"))
+	error (_("Target does not support this command."));
+    }
+  else if (val)
+    warning (_("Target does not support disconnected tracing."));
 }
 
 static int


             reply	other threads:[~2010-04-05  0:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-05  0:01 Pedro Alves [this message]
2010-04-05  1:08 ` Stan Shebs
2010-04-05 11:04   ` Pedro Alves
2010-04-07  1:34     ` Stan Shebs
2010-04-07 11:40       ` Pedro Alves
2010-04-07 13:33         ` Stan Shebs
2010-04-07 13:47           ` Pedro Alves
2010-04-07 14:07           ` Pedro Alves
2010-04-07 20:21             ` Stan Shebs
2010-04-07 22:06               ` Pedro Alves
2010-04-07 13:35         ` Pedro Alves
2010-04-07 22:04           ` Stan Shebs
2010-04-08 17:25             ` Pedro Alves
2010-04-08 18:19               ` Stan Shebs
2010-04-08 18:32                 ` Pedro Alves
2010-04-08 19:10                   ` Stan Shebs
2010-04-09  3:10                     ` Stan Shebs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201004050101.02067.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=stan@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox