Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Stan Shebs <stanshebs@earthlink.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] dynamic printf
Date: Fri, 18 May 2012 15:38:00 -0000	[thread overview]
Message-ID: <4FB66CFE.6050500@redhat.com> (raw)
In-Reply-To: <87396zmuyk.fsf@fleche.redhat.com>

On 05/17/2012 02:56 AM, Tom Tromey wrote:

> In this particular case, though, I think you could do it by just having
> the 'printf' invocation not be 'commands' stuck onto a breakpoint, but
> instead a per-dprintf method that is run at the appropriate moment, a la
> the Python 'Breakpoint.stop' method.


I agree.

I can't be within bkpt_ops->check_status (even though that'd be hacky),
as I think you'd want to support conditions on dprintf, and those are
checked after check_status is consulted.

Another question is, is the user supposed to set commands on dprintf?  Currently
you get:

(gdb) dprintf 36, "hello"
Dprintf 2 at 0x4005e0: file ../../../src/gdb/testsuite/gdb.base/dprintf.c, line 36.
(gdb) info breakpoints
2       dprintf        keep y   0x00000000004005e0 in main at ../../../src/gdb/testsuite/gdb.base/dprintf.c:36
        printf "hello"
        continue

(gdb) commands 2
Type commands for breakpoint(s) 2, one per line.
End with a line saying just "end".
>echo "world"
>end
(gdb) info breakpoints
Num     Type           Disp Enb Address            What
2       dprintf        keep y   0x00000000004005e0 in main at ../../../src/gdb/testsuite/gdb.base/dprintf.c:36
        breakpoint already hit 1 time
        echo "world"


Another related weekness of the current implementation is that a regular
breakpoint that should cause a stop set at the same address as a dprintf
no longer works correctly, due to the forced "continue".  E.g.,

(gdb) dprintf 36, "hello"
Dprintf 2 at 0x4005e0: file ../../../src/gdb/testsuite/gdb.base/dprintf.c, line 36.
(gdb) b 36
Note: breakpoint 2 also set at pc 0x4005e0.
Breakpoint 3 at 0x4005e0: file ../../../src/gdb/testsuite/gdb.base/dprintf.c, line 36.
(gdb) info breakpoints
Num     Type           Disp Enb Address            What
2       dprintf        keep y   0x00000000004005e0 in main at ../../../src/gdb/testsuite/gdb.base/dprintf.c:36
        printf "hello"
        continue
3       breakpoint     keep y   0x00000000004005e0 in main at ../../../src/gdb/testsuite/gdb.base/dprintf.c:36
(gdb) b 39
Breakpoint 4 at 0x40060e: file ../../../src/gdb/testsuite/gdb.base/dprintf.c, line 39.
(gdb) c
Continuing.

Breakpoint 2, main (argc=1, argv=0x7fffffffdd48) at ../../../src/gdb/testsuite/gdb.base/dprintf.c:36
36        printf ("kickoff\n");
hellokickoff
also to stderr

Breakpoint 4, main (argc=1, argv=0x7fffffffdd48) at ../../../src/gdb/testsuite/gdb.base/dprintf.c:39
39        foo (loc++);
(gdb)


Breakpoint 3 causes a stop, but GDB starts by running the commands of breakpoint 2 (the dprintf),
just because it has a lower number, and that includes the "continue", so breakpoint 3 is lost.

A similar issue happens with more than one dprintf installed on the same location -- only one
would run.  Multiple dprintfs on the same location would be useful when you set different
conditions on each (like with multiple breakpoints on the same location).

-- 
Pedro Alves


  reply	other threads:[~2012-05-18 15:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-08  6:27 Stan Shebs
2012-05-08  7:50 ` Yao Qi
2012-05-14 15:54   ` Stan Shebs
2012-05-15  4:10     ` [commit] Fix spu-tdep.c build regression [Re: [PATCH v2] dynamic printf] Jan Kratochvil
2012-05-15 10:24       ` Jim Meyering
2012-05-15 13:10     ` [commit] testsuite: gdb.base/dprintf.exp PR 12649 race " Jan Kratochvil
2012-05-15 13:34       ` Joel Brobecker
2012-05-15 13:37         ` [commit#2] " Jan Kratochvil
2012-05-16 20:17     ` [PATCH v2] dynamic printf Tom Tromey
2012-05-16 20:46       ` Stan Shebs
2012-05-16 20:52         ` Pedro Alves
2012-05-16 22:25           ` Stan Shebs
2012-05-17  1:56             ` Tom Tromey
2012-05-18 15:38               ` Pedro Alves [this message]
2012-05-16 20:53         ` Pedro Alves
2012-05-16 21:06         ` Tom Tromey

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=4FB66CFE.6050500@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=stanshebs@earthlink.net \
    --cc=tromey@redhat.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