[PATCH v5 2/2] gdb, breakpoint: output multiple bp locations
Gerlicher, Klaus
klaus.gerlicher@intel.com
Mon Sep 16 14:21:58 GMT 2024
Eli,
thanks for the review, I'll address these once I have a review on the rest.
Klaus
> From: Eli Zaretskii <eliz@gnu.org>
> Sent: Monday, September 16, 2024 3:16 PM
> To: Gerlicher, Klaus <klaus.gerlicher@intel.com>
> Cc: gdb-patches@sourceware.org; blarsen@redhat.com
> Subject: Re: [PATCH v5 2/2] gdb, breakpoint: output multiple bp locations
>
> > From: Klaus Gerlicher <klaus.gerlicher@intel.com>
> > Date: Mon, 16 Sep 2024 08:19:30 +0000
> >
> > From: "Gerlicher, Klaus" <klaus.gerlicher@intel.com>
> >
> > When setting a breakpoint that resolves to multiple locations
> > only the address of the first location is printed but multiple
> > locations are indicated.
> >
> > See this example:
> >
> > 01 template <typename T>
> > 02 T
> > 03 f (T t)
> > 04 {
> > 05 return t;
> > 06 }
> > 07
> > 08 int
> > 09 main (void)
> > 10 {
> > 11 return f<int> (1) + f<float> (1.0f) + f<char> (1)
> > 12 + f<short> (1) + f<bool> (1);
> > 13 }
> >
> > Setting a breakpoint on line 5 will yield 5 locations:
> >
> > (gdb) b 5
> > Breakpoint 1 at 0x11cf: main.cpp:5. (5 locations)
> >
> > Even though this indicates multiple locations, it only shows
> > the first one. A better way would be:
> >
> > Set how many locations to be printed, then...
> > (gdb) set max-breakpoint-locations-printed 4
> >
> > ... set breakpoint.
> >
> > (gdb) b 5
> > Breakpoint 1 for main.cpp:5 at 5 locations:
> > Location 1 at 0x11cf in function f<int>(int) in file main.cpp, line 5.
> > Location 2 at 0x11e1 in function f<float>(float) in file main.cpp, line 5.
> > Location 3 at 0x11f5 in function f<char>(char) in file main.cpp, line 5.
> > Location 4 at 0x1209 in function f<short>(short) in file main.cpp, line 5.
> > 1 additional location not printed.
> >
> > Make the number of breakpoint locations printed configurable. Introduce
> > the "set max-breakpoint-locations-printed" command.
> >
> > Convert tests that use gdb_test "break" to using gdb_breakpoint because
> > previously the "break" output was parseable with a single regex. Now that
> > it has become multi-line, tests that were previously creating multiple
> > locations unknowingly need to be fixed to use the right regex which is
> > simpler (and more properly) done by using the gdb_breakpoint.
> gdb_breakpoint
> > knows which regex to use for any case.
> >
> > This also adds two more options to gdb_breakpoint, -add_locs and -inferior:
> >
> > -add_locs is used for testing the additional print when there are more
> > locations then allowed to be printed with the "set
> > max-breakpoint-locations-printed" command.
> > -inferior is used to match "on inferior X" output when multiple locations
> > are on different inferiors.
> > ---
> > gdb/NEWS | 5 +
> > gdb/breakpoint.c | 125 ++++++++++++++----
> > gdb/doc/gdb.texinfo | 45 ++++++-
> > gdb/testsuite/gdb.base/ctxobj.exp | 4 +-
> > .../run-control-while-bg-execution.exp | 2 +-
> > gdb/testsuite/gdb.cp/ovldbreak.exp | 4 +-
> > gdb/testsuite/gdb.linespec/cpcompletion.exp | 2 +
> > gdb/testsuite/gdb.linespec/linespec.exp | 2 +-
> > gdb/testsuite/gdb.linespec/multiple-locs.cc | 41 ++++++
> > gdb/testsuite/gdb.linespec/multiple-locs.exp | 56 ++++++++
> > .../mi-breakpoint-multiple-locations.exp | 4 +-
> > .../gdb.mi/user-selected-context-sync.exp | 16 +--
> > .../gdb.multi/inferior-specific-bp.exp | 2 +-
> > .../gdb.multi/multi-target-continue.exp | 3 +-
> > .../gdb.multi/multi-target-ping-pong-next.exp | 6 +-
> > gdb/testsuite/gdb.python/py-breakpoint.exp | 2 +-
> > gdb/testsuite/lib/completion-support.exp | 3 +
> > gdb/testsuite/lib/gdb.exp | 33 ++++-
> > 18 files changed, 295 insertions(+), 60 deletions(-)
> > create mode 100644 gdb/testsuite/gdb.linespec/multiple-locs.cc
> > create mode 100644 gdb/testsuite/gdb.linespec/multiple-locs.exp
>
> Thanks.
>
> > diff --git a/gdb/NEWS b/gdb/NEWS
> > index cfc9cb05f77..4adbf0f2a66 100644
> > --- a/gdb/NEWS
> > +++ b/gdb/NEWS
> > @@ -3,6 +3,11 @@
> >
> > *** Changes since GDB 15
> >
> > +* Printing multiple breakpoint locations when setting a breakpoint
> > +
> > + Setting a breakpoint that is instantiated for multiple locations now prints
> > + locations limited by "set max-breakpoint-location-printed <count>".
> > +
>
> This part is okay.
>
> > + add_setshow_uinteger_cmd ("max-breakpoint-locations-printed",
> class_support,
> > + &breakpoint_show_max_locations,_("\
> > +Set number of locations printed when setting a breakpoint."), _("\
> > +Show number of locations printed when setting a breakpoint."), _("\
> > +Use this to choose how many number of locations are printed\n\
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> This should be "how many locations".
Yes, good catch, thanks.
>
> > +Breakpoint 2 for some_func at 3 locations:
> > + Location 1 at 0x118e in function some_func in file somefunc.cc, line 23.
> > + Location 2 at 0x11ee in function some_func in file somefunc.cc, line 38.
> > + Location 3 at 0x12fe in function some_func in file someother.cc, line 58.
>
> Can you make these lines shorter by changing the function name and the
> file names? 76 columns is too much, even for @smallexample.
>
> > +Breakpoint 2 for some_func at 3 locations:
> > + Location 1 at 0x118e in function some_func in file somefunc.cc, line 23.
> > + Location 2 at 0x11ee in function some_func in file somefunc.cc, line 38.
> > +1 additional location not printed.
>
> Likewise here.
>
> > +Breakpoint 1 for func at 3 locations:
> > + Location 1 at 0x11ce in function func in file somefunc.cc, line 23.
> > + Location 2 at 0x11b6 in function func in file somefunc.cc, line 38.
> > + Location 3 at 0x12fe in function func in file someother.cc, line 58.
> > @end smallexample
>
> And here.
>
> > +Breakpoint 1 for func at 3 locations:
> > + Location 1 at 0x1158 in function func in file test.c, line 18.
> > + Location 2 at 0x11b6 in function func in file test.c, line 28.
> > + Location 3 at 0x12fe in function func in file test.c, line 58.
> > @end smallexample
>
> And here.
>
I'll shorten these once I have a review on the implementation and test files. Thank you.
> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
More information about the Gdb-patches
mailing list