public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>,
	gdb-patches@sourceware.org
Subject: Re: [RFAv4] Show locno for 'multi location' breakpoint hit msg+conv var $_hit_bbnum $_hit_locno.
Date: Sat, 19 Nov 2022 21:06:38 -0500	[thread overview]
Message-ID: <563d4081-5eda-6c9c-048d-0db1a77bfd8f@simark.ca> (raw)
In-Reply-To: <20221112224146.3148234-1-philippe.waroquiers@skynet.be>



On 11/12/22 17:41, Philippe Waroquiers via Gdb-patches wrote:
> Before this patch, when a breakpoint that has multiple locations is reached,
> GDB printed:
>   Thread 1 "zeoes" hit Breakpoint 1, some_func () at somefunc1.c:5
> 
> This patch changes the message so that bkpt_print_id prints the precise
> encountered breakpoint:
>   Thread 1 "zeoes" hit Breakpoint 1.2, some_func () at somefunc1.c:5
> 
> In mi mode, bkpt_print_id also (optionally) prints a new table field "locno":
>   locno is printed when the breakpoint hit has more than one location.
> Note that according to the GDB user manual node 'GDB/MI Development and Front
> Ends', it is ok to add new fields without changing the MI version.
> 
> Also, when a breakpoint is reached, the convenience variables
> $_hit_bpnum and $_hit_locno are set to the encountered breakpoint number
> and location number.
> 
> $_hit_bpnum and $_hit_locno can a.o. be used in the command list of a
> breakpoint, to disable the specific encountered breakpoint, e.g.
>    disable $_hit_bpnum.$_hit_locno
> 
> In case the breakpoint has only one location, $_hit_locno is set to
> the value 1, so as to allow a command such as:
>   disable $_hit_bpnum.$_hit_locno
> to disable the breakpoint even when the breakpoint has only one location.
> 
> This also fixes a strange behaviour: when a breakpoint X has only
> one location,
>   enable|disable X.1
> is accepted but transforms the breakpoint in a multiple locations
> breakpoint having only one location.
> 
> The changes in RFA v4 handle the comments of Tom Tromey:
>  - Changed convenience var names from $bkptno/$locno to
>    $_hit_bpnum/$_hit_locno.
>  - updated the tests and user manual accordingly.
>    User manual also explictly describes that $_hit_locno is set to 1
>    for a breakpoint with a single location.
>  - The variable values are now set in bpstat_do_actions_1 so that
>    they are set for silent breakpoints, and when several breakpoints
>    are hit at the same time, that the variables are set to the printed
>    breakpoint.
> 
> The changes in RFA v3 handle the additional comments of Eli:
>  GDB/NEW:
>   - Use max 80-column
>   - Use 'code location' instead of 'location'.
>   - Fix typo $bkpno
>   - Ensure that disable $bkptno and disable $bkptno.$locno have
>     each their explanation inthe example
>   - Reworded the 'breakpoint-hit' paragraph.
>  gdb.texinfo:
>   - Use 'code location' instead of 'location'.
>   - Add a note to clarify the distinction between $bkptno and $bpnum.
>   - Use @kbd instead of examples with only one command.
> 
> Compared to RFA v1, the changes in v2 handle the comments given by
> Keith Seitz and Eli Zaretskii:
>   - Use %s for the result of paddress
>   - Use bkptno_numopt_re instead of 2 different -re cases
>   - use C@t{++}
>   - Add index entries for $bkptno and $locno
>   - Added an example for "locno" in the mi interface
>   - Added examples in the Break command manual.

Hi Philippe,

I am getting some new failures starting with your patch, at least when
building with ASan.  I bisected using gdb.mi/mi-break.exp as a test:


PASS: gdb.mi/mi-break.exp: mi-mode=main: test_breakpoint_commands: intermediate stop and continue, mi running
=================================================================

^[[1m^[[31m==1105569==ERROR: AddressSanitizer: heap-use-after-free on address 0x606000055110 at pc 0x55eabe71b268 bp 0x7ffcc2697a20 sp 0x7ffcc2697a10

^[[1m^[[0m^[[1m^[[34mREAD of size 8 at 0x606000055110 thread T0^[[1m^[[0m

    #0 0x55eabe71b267 in set_hit_convenience_vars /home/simark/src/binutils-gdb/gdb/breakpoint.c:4581

    #1 0x55eabe71b7b5 in bpstat_do_actions_1 /home/simark/src/binutils-gdb/gdb/breakpoint.c:4698

    #2 0x55eabe71ba45 in bpstat_do_actions() /home/simark/src/binutils-gdb/gdb/breakpoint.c:4731

    #3 0x55eabefd4b62 in inferior_event_handler(inferior_event_type) /home/simark/src/binutils-gdb/gdb/inf-loop.c:70

    #4 0x55eabf03f005 in fetch_inferior_event() /home/simark/src/binutils-gdb/gdb/infrun.c:4270

    #5 0x55eabefd4a4f in inferior_event_handler(inferior_event_type) /home/simark/src/binutils-gdb/gdb/inf-loop.c:41

    #6 0x55eabf0661c2 in infrun_async_inferior_event_handler /home/simark/src/binutils-gdb/gdb/infrun.c:9554

    #7 0x55eabe6728bb in check_async_event_handlers() /home/simark/src/binutils-gdb/gdb/async-event.c:337

    #8 0x55eac00a6cda in gdb_do_one_event(int) /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:221

    #9 0x55eabf1ebbfb in start_event_loop /home/simark/src/binutils-gdb/gdb/main.c:411

    #10 0x55eabf1ebf15 in captured_command_loop /home/simark/src/binutils-gdb/gdb/main.c:471

    #11 0x55eabf1f03cb in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1330

    #12 0x55eabf1f045b in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1345

    #13 0x55eabe4bfe6d in main /home/simark/src/binutils-gdb/gdb/gdb.c:32

    #14 0x7fad6ce2a28f  (/usr/lib/libc.so.6+0x2328f)

    #15 0x7fad6ce2a349 in __libc_start_main (/usr/lib/libc.so.6+0x23349)

    #16 0x55eabe4bfc34 in _start ../sysdeps/x86_64/start.S:115



^[[1m^[[32m0x606000055110 is located 16 bytes inside of 56-byte region [0x606000055100,0x606000055138)

^[[1m^[[0m^[[1m^[[35mfreed by thread T0 here:^[[1m^[[0m

    #0 0x7fad6de0b78a in operator delete(void*, unsigned long) /usr/src/debug/gcc/libsanitizer/asan/asan_new_delete.cpp:164

    #1 0x55eabe71a14e in bpstat_clear(bpstat**) /home/simark/src/binutils-gdb/gdb/breakpoint.c:4370

    #2 0x55eabf03380d in clear_proceed_status_thread /home/simark/src/binutils-gdb/gdb/infrun.c:2781

    #3 0x55eabf033e9e in clear_proceed_status(int) /home/simark/src/binutils-gdb/gdb/infrun.c:2808

    #4 0x55eabeff4dab in continue_1(int) /home/simark/src/binutils-gdb/gdb/infcmd.c:659

    #5 0x55eabeff5531 in continue_command /home/simark/src/binutils-gdb/gdb/infcmd.c:752

    #6 0x55eabe92b954 in do_simple_func /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:95

    #7 0x55eabe939998 in cmd_func(cmd_list_element*, char const*, int) /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:2543

    #8 0x55eabf9986c2 in execute_command(char const*, int) /home/simark/src/binutils-gdb/gdb/top.c:692

    #9 0x55eabe973c1d in execute_control_command_1 /home/simark/src/binutils-gdb/gdb/cli/cli-script.c:528

    #10 0x55eabe974b41 in execute_control_command(command_line*, int) /home/simark/src/binutils-gdb/gdb/cli/cli-script.c:708

    #11 0x55eabe71b652 in bpstat_do_actions_1 /home/simark/src/binutils-gdb/gdb/breakpoint.c:4661

    #12 0x55eabe71ba45 in bpstat_do_actions() /home/simark/src/binutils-gdb/gdb/breakpoint.c:4731

    #13 0x55eabefd4b62 in inferior_event_handler(inferior_event_type) /home/simark/src/binutils-gdb/gdb/inf-loop.c:70

    #14 0x55eabf03f005 in fetch_inferior_event() /home/simark/src/binutils-gdb/gdb/infrun.c:4270

    #15 0x55eabefd4a4f in inferior_event_handler(inferior_event_type) /home/simark/src/binutils-gdb/gdb/inf-loop.c:41

    #16 0x55eabf0661c2 in infrun_async_inferior_event_handler /home/simark/src/binutils-gdb/gdb/infrun.c:9554

    #17 0x55eabe6728bb in check_async_event_handlers() /home/simark/src/binutils-gdb/gdb/async-event.c:337

    #18 0x55eac00a6cda in gdb_do_one_event(int) /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:221

    #19 0x55eabf1ebbfb in start_event_loop /home/simark/src/binutils-gdb/gdb/main.c:411

    #20 0x55eabf1ebf15 in captured_command_loop /home/simark/src/binutils-gdb/gdb/main.c:471

    #21 0x55eabf1f03cb in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1330

    #22 0x55eabf1f045b in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1345

    #23 0x55eabe4bfe6d in main /home/simark/src/binutils-gdb/gdb/gdb.c:32

    #24 0x7fad6ce2a28f  (/usr/lib/libc.so.6+0x2328f)



^[[1m^[[35mpreviously allocated by thread T0 here:^[[1m^[[0m

    #0 0x7fad6de0a672 in operator new(unsigned long) /usr/src/debug/gcc/libsanitizer/asan/asan_new_delete.cpp:95

    #1 0x55eabe7222ef in build_bpstat_chain(address_space const*, unsigned long, target_waitstatus const&) /home/simark/src/binutils-gdb/gdb/breakpoint.c:5591

    #2 0x55eabf04dcfa in handle_signal_stop /home/simark/src/binutils-gdb/gdb/infrun.c:6334

    #3 0x55eabf04a8fb in handle_inferior_event /home/simark/src/binutils-gdb/gdb/infrun.c:5866

    #4 0x55eabf03ecb3 in fetch_inferior_event() /home/simark/src/binutils-gdb/gdb/infrun.c:4231

    #5 0x55eabefd4a4f in inferior_event_handler(inferior_event_type) /home/simark/src/binutils-gdb/gdb/inf-loop.c:41

    #6 0x55eabf0661c2 in infrun_async_inferior_event_handler /home/simark/src/binutils-gdb/gdb/infrun.c:9554

    #7 0x55eabe6728bb in check_async_event_handlers() /home/simark/src/binutils-gdb/gdb/async-event.c:337

    #8 0x55eac00a6cda in gdb_do_one_event(int) /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:221

    #9 0x55eabf1ebbfb in start_event_loop /home/simark/src/binutils-gdb/gdb/main.c:411

    #10 0x55eabf1ebf15 in captured_command_loop /home/simark/src/binutils-gdb/gdb/main.c:471

    #11 0x55eabf1f03cb in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1330

    #12 0x55eabf1f045b in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1345

    #13 0x55eabe4bfe6d in main /home/simark/src/binutils-gdb/gdb/gdb.c:32

    #14 0x7fad6ce2a28f  (/usr/lib/libc.so.6+0x2328f)



SUMMARY: AddressSanitizer: heap-use-after-free /home/simark/src/binutils-gdb/gdb/breakpoint.c:4581 in set_hit_convenience_vars


Here are the other failures I get.  I didn't check if they were caused
by your patch, but since they appeared at the same time, it's likely.

 - gdb.threads/multi-create-ns-info-thr.exp
 - gdb.base/dprintf-execution-x-script.exp
 - gdb.base/commands.exp
 - gdb.base/bp-cmds-execution-x-script.exp
 - gdb.base/bp-cmds-continue-ctrl-c.exp

Simon

  parent reply	other threads:[~2022-11-20  2:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-12 22:41 Philippe Waroquiers
2022-11-18 20:17 ` Tom Tromey
2022-11-20  2:06 ` Simon Marchi [this message]
2022-11-20  8:35   ` Philippe Waroquiers
2022-11-20 10:54     ` Philippe Waroquiers

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=563d4081-5eda-6c9c-048d-0db1a77bfd8f@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=philippe.waroquiers@skynet.be \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).