Compare commits

...

3 Commits

Author SHA1 Message Date
Pedro Alves
1c7b382fcc Extra indent & extra line
Comment out the "#define EXTRA_LINE" line to stop emitting the extra
line.

Change-Id: I174b00d956a0e1585269778570e0ed810906d68c
2022-05-24 10:56:10 +01:00
Pedro Alves
205bb562e7 Introduce "info breakpoints -hide-locations"
This commit adds a new option to "info breakpoints",
"-hide-locations".  It's purpose is to tell GDB to skip printing
breakpoint locations, printing only the breakpoint header rows.

And then, since only code breakpoint locations print anything in the
"Address" column, "-hide-breakpoints" also disables the "Address"
column.

For example, when debugging GDB, you can use the new options to get
this:

 (top-gdb) i b -h
 Num     Type           Disp Enb What
 1       breakpoint     keep y   internal_error
 2       breakpoint     keep y   info_command
	 silent
	 return
 3       breakpoint     keep y   main
	 breakpoint already hit 1 time
 4       breakpoint     keep y   error
 (top-gdb)

instead of:

 (top-gdb) i b
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y                      internal_error
  1.1                        y   0x0000555555f81d12 in internal_error(char const*, int, char const*, ...) at /home/pedro/gdb/binutils-gdb/src/gdbsupport/errors.cc:51
 2       breakpoint     keep y                      info_command
	 silent
	 return
  2.1                        y   0x00005555557b3097 in info_command(char const*, int) at /home/pedro/gdb/binutils-gdb/src/gdb/cli/cli-cmds.c:217
 3       breakpoint     keep y                      main
	 breakpoint already hit 1 time
  3.1                        y   0x000055555564106c in main(int, char**) at /home/pedro/gdb/binutils-gdb/src/gdb/gdb.c:25
  3.2                        y   0x0000555555dba524 in selftests::string_view::capacity_1::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/capacity/1.cc:167
  3.3                        y   0x0000555555dba943 in selftests::string_view::cons_1::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/cons/char/1.cc:62
  3.4                        y   0x0000555555dbaa34 in selftests::string_view::cons_2::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/cons/char/2.cc:41
  3.5                        y   0x0000555555dbaa9a in selftests::string_view::cons_3::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/cons/char/3.cc:34
  3.6                        y   0x0000555555dbac6b in selftests::string_view::element_access_1::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/element_access/char/1.cc:66
  3.7                        y   0x0000555555dbac83 in selftests::string_view::element_access_empty::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/element_access/char/empty.cc:25
  3.8                        y   0x0000555555dbae91 in selftests::string_view::element_access_front_back::main()
						    at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/element_access/char/front_back.cc:38
  3.9                        y   0x0000555555dbb2bd in selftests::string_view::inserters_2::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/inserters/char/2.cc:84
  3.10                       y   0x0000555555dbb429 in selftests::string_view::modifiers_remove_prefix::main()
						    at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc:58
  3.11                       y   0x0000555555dbb575 in selftests::string_view::modifiers_remove_suffix::main()
						    at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc:58
  3.12                       y   0x0000555555dbbd38 in selftests::string_view::operations_compare_1::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/operations/compare/char/1.cc:127
  3.13                       y   0x0000555555dbbe7b in selftests::string_view::operations_compare_13650::main()
						    at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/operations/compare/char/13650.cc:45
  3.14                       y   0x0000555555dbbf6a in selftests::string_view::operations_copy_1::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/operations/copy/char/1.cc:41
  3.15                       y   0x0000555555dbc03b in selftests::string_view::operations_data_1::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/operations/data/char/1.cc:39
  3.16                       y   0x0000555555dbc5fe in selftests::string_view::operations_find_1::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/operations/find/char/1.cc:160
  3.17                       y   0x0000555555dbcb60 in selftests::string_view::operations_find_2::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/operations/find/char/2.cc:158
  3.18                       y   0x0000555555dbd1c1 in selftests::string_view::operations_find_3::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/operations/find/char/3.cc:158
  3.19                       y   0x0000555555dbd26c in selftests::string_view::operations_find_4::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/operations/find/char/4.cc:40
  3.20                       y   0x0000555555dbd83f in selftests::string_view::operations_rfind_1::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/operations/rfind/char/1.cc:90
  3.21                       y   0x0000555555dbda98 in selftests::string_view::operations_rfind_2::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/operations/rfind/char/2.cc:48
  3.22                       y   0x0000555555dbde4c in selftests::string_view::operations_rfind_3::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/operations/rfind/char/3.cc:63
  3.23                       y   0x0000555555dbe189 in selftests::string_view::operations_substr_1::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/operations/substr/char/1.cc:74
  3.24                       y   0x0000555555dbffdb in selftests::string_view::operators_2::main() at /home/pedro/gdb/binutils-gdb/src/gdb/unittests/basic_string_view/operators/char/2.cc:366
 4       breakpoint     keep y                      error
  4.1                        y   0x00005555557f5142 in gcc_c_plugin::error(char const*) const at /home/pedro/gdb/binutils-gdb/src/gdb/../include/gcc-c-fe.def:198
  4.2                        y   0x00005555557fe1f4 in gcc_cp_plugin::error(char const*) const at /home/pedro/gdb/binutils-gdb/src/gdb/../include/gcc-cp-fe.def:983
  4.3                        y   0x0000555555f81c5e in error(char const*, ...) at /home/pedro/gdb/binutils-gdb/src/gdbsupport/errors.cc:39
  4.4                        y   0x00007ffff65ee4e0 <icu_66::RBBIRuleScanner::error(UErrorCode)>
  4.5                        y   0x00007ffff685e070 <icu_66::RegexCompile::error(UErrorCode)>
  4.6                        y   0x00007ffff6cd4e86 in error at /usr/include/x86_64-linux-gnu/bits/error.h:40
  4.7                        y   0x00007ffff71c2190 in __error at error.c:274

Documentation change included.  No testsuite changes yet until there's
agreement on the previous patch.

Change-Id: Ic42ad8565e79ca67bfebb22cbb4794ea816fd08b
2022-05-23 20:31:44 +01:00
Pedro Alves
11d68f5901 Always show locations for breakpoints & show canonical location spec
I've thought for a few years that "info breakpoints" should show BOTH
the canonical location spec behind each breakpoint, and the actual
resolved location(s) where the breakpoint is inserted.  It currently
only shows the latter.

Here are for example 3 breakpoints that I set while debugging gdb:

 (top-gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   0x0000000000575127 in internal_error(char const*, int, char const*, ...) at src/gdb/common/errors.c:54
 2       breakpoint     keep y   0x0000000000575127 in internal_error(char const*, int, char const*, ...) at src/gdb/common/errors.c:54
 3       breakpoint     keep y   <MULTIPLE>
 3.1                         y   0x0000000000575127 in internal_error(char const*, int, char const*, ...) at src/gdb/common/errors.c:54
 3.2                         y   0x00007ffff6d50410 in PyErr_SetObject at /usr/src/debug/python2-2.7.15-4.fc27.x86_64/Python/errors.c:54
 (top-gdb)

From looking at those, you have no idea how I created the breakpoints
in the first place, which specs I used.  Breakpoints 1 and 2 look like
the same from that output, but really aren't.  I'll have forgotten
after a while which was which though.  And what's with the third
breakpoint, showing seemingly unrelated functions in its locations?

GDB of course knows all those breakpoints were set differently.  It
needs to remember the location specs in order to re_set the locations
properly.  And it needs to remember the spec in order to save the
breakpoints, like:

 (top-gdb) save breakpoints bpts.cmd
 Saved to file 'bpts.cmd'.

Let's look at the file, see how the breakpoints had been created:

 (top-gdb) shell cat bpts.cmd
 break internal_error
 break -qualified internal_error
 break errors.c:54
 (top-gdb)

Ah, the "-qualified" information for breakpoint 2 was lost from "info
breakpoints" output.  And now it's obvious why we have two locations
for breakpoint 3 -- that breakpoint was set by FILE:LINE, and GDB
resolved that to two locations in unrelated functions that happen to
be implemented in files with the same name.

I propose that we show this info in "info breakpoints" too, with a
conceptualy simple change that just removes special cases.  To get
there, let's observe a fact -- there are a couple cases where "info
breakpoints" prints the breakpoint's locations in their own rows:

#1 - when the breakpoint has multiple locations:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         y   0x0000000000a2d874 in func(int) at func.c:51
 1.2                         y   0x0000000000b2d640 in func(int) at func2.c:51

#2 - when the breakpoint only has one location, but it is disabled,
     while the breakpoint itself is enabled.  E.g.:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   0x0000000000a2d874 in func(int) at func.c:51
 (gdb) disable 1.1
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y   <MULTIPLE>
 1.1                         n   0x0000000000a2d874 in func(int) at func.c:51

(the last example shows <MULTIPLE> when there's only one location, but
let's ignore that...)

Note that when we print the locations in a separate row, the "What"
column for the breakpoint header row is empty.  That seems to me to be
the perfect spot to put the breakpoint's location spec.

Then, if we make it such that breakpoints always print their locations
in separate rows, even if they only have one location, that space is
always there to use.  The result for the confusing example at the top
would be this:

 (top-gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y                      internal_error
 1.1                         y   0x00000000005755a5 in internal_error(char const*, int, char const*, ...) at src/gdb/common/errors.c:54
 2       breakpoint     keep y                      -qualified internal_error
 2.1                         y   0x00000000005755a5 in internal_error(char const*, int, char const*, ...) at src/gdb/common/errors.c:54
 3       breakpoint     keep y                      errors.c:54
 3.1                         y   0x00000000005755a5 in internal_error(char const*, int, char const*, ...) at src/gdb/common/errors.c:54
 3.2                         y   0x00007ffff6d50410 in PyErr_SetObject at /usr/src/debug/python2-2.7.15-4.fc27.x86_64/Python/errors.c:54

(Note: this looks better on a terminal with color.)

Breakpoints would no longer move from single-location to
multiple-location "display modes" as locations were added/removed
(e.g., when a shared library is loaded), they'd always be in
multi-location display mode.  And we'd get rid of the "breakpoint has
a single location that is disabled" special case.

Now, after using this for a while, I came to wish that the output
would give a better visual clue on each group of "breakpoint + its
locations".  This commit implements that by simply indenting the
location number by one space, like so:

 (top-gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 1       breakpoint     keep y                      internal_error
  1.1                        y   0x00000000005755a5 in internal_error(char const*, int, char const*, ...) at src/gdb/common/errors.c:54
 2       breakpoint     keep y                      -qualified internal_error
  2.1                        y   0x00000000005755a5 in internal_error(char const*, int, char const*, ...) at src/gdb/common/errors.c:54
 3       breakpoint     keep y                      errors.c:54
  3.1                        y   0x00000000005755a5 in internal_error(char const*, int, char const*, ...) at src/gdb/common/errors.c:54
  3.2                        y   0x00007ffff6d50410 in PyErr_SetObject at /usr/src/debug/python2-2.7.15-4.fc27.x86_64/Python/errors.c:54

The need for grouping is clearer if you have breakpoints with dozens
of locations, such as when you do "b main" when debugging GDB.

Another interesting case where this commit helps is when the user sets
a breakpoint by line number, and the line corresponds to a comment or
empty line, or to code that was optimized away.  E.g., again when
debugging GDB:

 (top-gdb) b 27
 Breakpoint 4 at 0x469aa6: file src/gdb/gdb.c, line 28.

Note I asked for line 27 but got line 28.

"info breakpoints" currently says:

 (top-gdb) info breakpoints 4
 Num     Type           Disp Enb Address            What
 4       breakpoint     keep y   0x0000000000469aa6 in main(int, char**) at src/gdb/gdb.c:28

Again here we lost the info about the original location spec, line 27.
While after this commit, we get:

 (top-gdb) info breakpoints 4
 Num     Type           Disp Enb Address            What
 4       breakpoint     keep y                      src/gdb/gdb.c:27
  4.1                        y   0x0000000000469aa6 in main(int, char**) at src/gdb/gdb.c:28

Lancelot is working on a GDB change that will make GDB slide each
breakpoint location's line independently, so we could end up with
something like this, even:

 (top-gdb) info breakpoints 4
 Num     Type           Disp Enb Address            What
 4       breakpoint     keep y                      func.cc:27
  4.1                        y   0x0000000000469aa6 in func<float>(float) at func.cc:28
  4.2                        y   0x000000000047abb8 in func<int>(int) at func.cc:30

The output for watchpoints and catchpoints is unmodified, they will
continue being printed like before, as we never print locations for
those:

 Num     Type           Disp Enb Address            What
 2       catchpoint     keep y                      syscall "<any syscall>"
 3       hw watchpoint  keep y                      *main

Before this commit can go in, I'll need to address testsuite fallout,
of course.  I expect this will be a significant effort, so I'm hoping
we can come to agreement on whether the GDB change is OK before
wasting time adjusting the testsuite.

Documentation adjustments included.  They also clean up a few tangent
things in the area of the docs I was adjusting to better match
reality.

Change-Id: Ic42ad8565e79ca67bfebb22cbb4794ea816fd08b
2022-05-23 20:31:43 +01:00
14 changed files with 492 additions and 283 deletions

View File

@@ -12153,7 +12153,7 @@ struct ada_catchpoint : public code_breakpoint
void re_set () override;
void check_status (struct bpstat *bs) override;
enum print_stop_action print_it (const bpstat *bs) const override;
bool print_one (bp_location **) const override;
bool print_one (bp_location **, bool) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
@@ -12421,14 +12421,11 @@ ada_catchpoint::print_it (const bpstat *bs) const
catchpoint kinds. */
bool
ada_catchpoint::print_one (bp_location **last_loc) const
ada_catchpoint::print_one (bp_location **last_loc, bool print_address_col) const
{
struct ui_out *uiout = current_uiout;
struct value_print_options opts;
get_user_print_options (&opts);
if (opts.addressprint)
if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);

View File

@@ -49,7 +49,7 @@ struct exec_catchpoint : public catchpoint
CORE_ADDR bp_addr,
const target_waitstatus &ws) override;
enum print_stop_action print_it (const bpstat *bs) const override;
bool print_one (bp_location **) const override;
bool print_one (bp_location **, bool) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
@@ -110,17 +110,15 @@ exec_catchpoint::print_it (const bpstat *bs) const
}
bool
exec_catchpoint::print_one (bp_location **last_loc) const
exec_catchpoint::print_one (bp_location **last_loc,
bool print_address_col) const
{
struct value_print_options opts;
struct ui_out *uiout = current_uiout;
get_user_print_options (&opts);
/* Field 4, the address, is omitted (which makes the columns
not line up too nicely with the headers, but the effect
is relatively readable). */
if (opts.addressprint)
if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);
uiout->text ("exec");

View File

@@ -49,7 +49,7 @@ struct fork_catchpoint : public catchpoint
CORE_ADDR bp_addr,
const target_waitstatus &ws) override;
enum print_stop_action print_it (const bpstat *bs) const override;
bool print_one (bp_location **) const override;
bool print_one (bp_location **, bool print_address_col) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
@@ -136,17 +136,15 @@ fork_catchpoint::print_it (const bpstat *bs) const
/* Implement the "print_one" method for fork catchpoints. */
bool
fork_catchpoint::print_one (bp_location **last_loc) const
fork_catchpoint::print_one (bp_location **last_loc,
bool print_address_col) const
{
struct value_print_options opts;
struct ui_out *uiout = current_uiout;
get_user_print_options (&opts);
/* Field 4, the address, is omitted (which makes the columns not
line up too nicely with the headers, but the effect is relatively
readable). */
if (opts.addressprint)
if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);
const char *name = is_vfork ? "vfork" : "fork";

View File

@@ -56,7 +56,7 @@ struct solib_catchpoint : public catchpoint
const target_waitstatus &ws) override;
void check_status (struct bpstat *bs) override;
enum print_stop_action print_it (const bpstat *bs) const override;
bool print_one (bp_location **) const override;
bool print_one (bp_location **, bool) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
@@ -159,16 +159,14 @@ solib_catchpoint::print_it (const bpstat *bs) const
}
bool
solib_catchpoint::print_one (bp_location **locs) const
solib_catchpoint::print_one (bp_location **locs, bool print_address_col) const
{
struct value_print_options opts;
struct ui_out *uiout = current_uiout;
get_user_print_options (&opts);
/* Field 4, the address, is omitted (which makes the columns not
line up too nicely with the headers, but the effect is relatively
readable). */
if (opts.addressprint)
if (print_address_col)
{
annotate_field (4);
uiout->field_skip ("addr");

View File

@@ -57,7 +57,7 @@ struct signal_catchpoint : public catchpoint
CORE_ADDR bp_addr,
const target_waitstatus &ws) override;
enum print_stop_action print_it (const bpstat *bs) const override;
bool print_one (bp_location **) const override;
bool print_one (bp_location **, bool) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
bool explains_signal (enum gdb_signal) override;
@@ -213,17 +213,15 @@ signal_catchpoint::print_it (const bpstat *bs) const
/* Implement the "print_one" method for signal catchpoints. */
bool
signal_catchpoint::print_one (bp_location **last_loc) const
signal_catchpoint::print_one (bp_location **last_loc,
bool print_address_col) const
{
struct value_print_options opts;
struct ui_out *uiout = current_uiout;
get_user_print_options (&opts);
/* Field 4, the address, is omitted (which makes the columns
not line up too nicely with the headers, but the effect
is relatively readable). */
if (opts.addressprint)
if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);

View File

@@ -52,7 +52,7 @@ struct syscall_catchpoint : public catchpoint
CORE_ADDR bp_addr,
const target_waitstatus &ws) override;
enum print_stop_action print_it (const bpstat *bs) const override;
bool print_one (bp_location **) const override;
bool print_one (bp_location **, bool) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
@@ -238,17 +238,16 @@ syscall_catchpoint::print_it (const bpstat *bs) const
/* Implement the "print_one" method for syscall catchpoints. */
bool
syscall_catchpoint::print_one (bp_location **last_loc) const
syscall_catchpoint::print_one (bp_location **last_loc,
bool print_address_col) const
{
struct value_print_options opts;
struct ui_out *uiout = current_uiout;
struct gdbarch *gdbarch = loc->owner->gdbarch;
get_user_print_options (&opts);
/* Field 4, the address, is omitted (which makes the columns not
line up too nicely with the headers, but the effect is relatively
readable). */
if (opts.addressprint)
if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);

View File

@@ -87,7 +87,7 @@ struct exception_catchpoint : public code_breakpoint
void re_set () override;
enum print_stop_action print_it (const bpstat *bs) const override;
bool print_one (bp_location **) const override;
bool print_one (bp_location **, bool) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
void print_one_detail (struct ui_out *) const override;
@@ -271,14 +271,12 @@ exception_catchpoint::print_it (const bpstat *bs) const
}
bool
exception_catchpoint::print_one (bp_location **last_loc) const
exception_catchpoint::print_one (bp_location **last_loc,
bool print_address_col) const
{
struct value_print_options opts;
struct ui_out *uiout = current_uiout;
get_user_print_options (&opts);
if (opts.addressprint)
if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);

View File

@@ -370,7 +370,7 @@ struct ranged_breakpoint : public ordinary_breakpoint
const target_waitstatus &ws) override;
int resources_needed (const struct bp_location *) override;
enum print_stop_action print_it (const bpstat *bs) const override;
bool print_one (bp_location **) const override;
bool print_one (bp_location **, bool) const override;
void print_one_detail (struct ui_out *) const override;
void print_mention () const override;
void print_recreate (struct ui_file *fp) const override;
@@ -6010,6 +6010,11 @@ print_breakpoint_location (const breakpoint *b,
{
struct ui_out *uiout = current_uiout;
/* Indent by a space for a better grouping hint. We can get by with
calling text just once, because the "what" column is the last
column. Otherwise, following columns would be misaligned. */
uiout->text (" ");
scoped_restore_current_program_space restore_pspace;
if (loc != NULL && loc->shlib_disabled)
@@ -6030,7 +6035,8 @@ print_breakpoint_location (const breakpoint *b,
uiout->field_string ("func", sym->print_name (),
function_name_style.style ());
uiout->text (" ");
uiout->wrap_hint (wrap_indent_at_field (uiout, "what"));
/* +1 for the location's grouping hint indentation. */
uiout->wrap_hint (wrap_indent_at_field (uiout, "what") + 1);
uiout->text ("at ");
}
uiout->field_string ("file",
@@ -6174,6 +6180,34 @@ output_thread_groups (struct ui_out *uiout,
}
}
/* The options for the "info breakpoints" command. */
struct info_breakpoints_opts
{
/* For "-hide-locations". */
bool hide_locations = 0;
};
static const gdb::option::option_def info_breakpoints_option_defs[] = {
gdb::option::flag_option_def<info_breakpoints_opts> {
"hide-locations",
[] (info_breakpoints_opts *opts) { return &opts->hide_locations; },
N_("Hide breakpoint locations."),
},
};
/* Create an option_def_group for the "info breakpoints" options, with
OPTS as context. */
static inline gdb::option::option_def_group
make_info_breakpoints_options_def_group (info_breakpoints_opts *opts)
{
return {{info_breakpoints_option_defs}, opts};
}
/* Print B to gdb_stdout. If RAW_LOC, print raw breakpoint locations
instead of going via breakpoint_ops::print_one. This makes "maint
info breakpoints" show the software breakpoint locations of
@@ -6186,67 +6220,71 @@ print_one_breakpoint_location (struct breakpoint *b,
struct bp_location *loc,
int loc_number,
struct bp_location **last_loc,
int allflag, bool raw_loc)
int allflag, bool raw_loc,
bool print_address_col)
{
struct command_line *l;
static char bpenables[] = "nynny";
struct ui_out *uiout = current_uiout;
int header_of_multiple = 0;
int part_of_multiple = (loc != NULL);
struct value_print_options opts;
get_user_print_options (&opts);
gdb_assert (!loc || loc_number != 0);
/* See comment in print_one_breakpoint concerning treatment of
breakpoints with single disabled location. */
if (loc == NULL
&& (b->loc != NULL
&& (b->loc->next != NULL
|| !b->loc->enabled || b->loc->disabled_by_cond)))
header_of_multiple = 1;
if (loc == NULL)
loc = b->loc;
annotate_record ();
/* 1 */
annotate_field (0);
if (part_of_multiple)
uiout->field_fmt ("number", "%d.%d", b->number, loc_number);
if (loc != nullptr)
{
if (uiout->is_mi_like_p ())
uiout->field_fmt ("number", "%d.%d", b->number, loc_number);
else
uiout->field_fmt ("number", " %d.%d", b->number, loc_number);
}
else
uiout->field_signed ("number", b->number);
/* 2 */
annotate_field (1);
if (part_of_multiple)
if (loc != nullptr)
uiout->field_skip ("type");
else
uiout->field_string ("type", bptype_string (b->type));
/* 3 */
annotate_field (2);
if (part_of_multiple)
if (loc != nullptr)
uiout->field_skip ("disp");
else
uiout->field_string ("disp", bpdisp_text (b->disposition));
/* 4 */
annotate_field (3);
/* For locations that are disabled because of an invalid condition,
display "N*" on CLI, where "*" refers to a footnote below the
table. For MI, simply display a "N" without a footnote. */
const char *N = (uiout->is_mi_like_p ()) ? "N" : "N*";
if (part_of_multiple)
uiout->field_string ("enabled", (loc->disabled_by_cond ? N
: (loc->enabled ? "y" : "n")));
if (loc != nullptr)
{
/* For locations that are disabled because of an invalid
condition, display "N*" on CLI, where "*" refers to a
footnote below the table. For MI, simply display a "N"
without a footnote. */
if (uiout->is_mi_like_p ())
{
uiout->field_string ("enabled", (loc->disabled_by_cond
? "N"
: (loc->enabled ? "y" : "n")));
}
else
{
uiout->field_string ("enabled", (loc->disabled_by_cond
? " N*"
: (loc->enabled ? " y" : " n")));
}
}
else
uiout->field_fmt ("enabled", "%c", bpenables[(int) b->enable_state]);
/* 5 and 6 */
bool result = false;
if (!raw_loc && b->print_one (last_loc))
if (!raw_loc && b->print_one (last_loc, print_address_col))
result = true;
else
{
@@ -6257,7 +6295,7 @@ print_one_breakpoint_location (struct breakpoint *b,
/* Field 4, the address, is omitted (which makes the columns
not line up too nicely with the headers, but the effect
is relatively readable). */
if (opts.addressprint)
if (print_address_col)
uiout->field_skip ("addr");
annotate_field (5);
uiout->field_string ("what", w->exp_string.get ());
@@ -6265,12 +6303,11 @@ print_one_breakpoint_location (struct breakpoint *b,
else if (!is_catchpoint (b) || is_exception_catchpoint (b)
|| is_ada_exception_catchpoint (b))
{
if (opts.addressprint)
if (print_address_col)
{
annotate_field (4);
if (header_of_multiple)
uiout->field_string ("addr", "<MULTIPLE>",
metadata_style.style ());
if (loc == nullptr)
uiout->field_skip ("addr");
else if (b->loc == NULL || loc->shlib_disabled)
uiout->field_string ("addr", "<PENDING>",
metadata_style.style ());
@@ -6279,14 +6316,22 @@ print_one_breakpoint_location (struct breakpoint *b,
loc->gdbarch, loc->address);
}
annotate_field (5);
if (!header_of_multiple)
if (loc == nullptr)
{
if (b->location != nullptr)
uiout->field_string
("what", event_location_to_string (b->location.get ()));
else
uiout->field_skip ("what");
}
else
print_breakpoint_location (b, loc);
if (b->loc)
*last_loc = b->loc;
}
}
if (loc != NULL && !header_of_multiple)
if (loc != nullptr)
{
std::vector<int> inf_nums;
int mi_only = 1;
@@ -6309,8 +6354,7 @@ print_one_breakpoint_location (struct breakpoint *b,
mi_only = 0;
output_thread_groups (uiout, "thread-groups", inf_nums, mi_only);
}
if (!part_of_multiple)
else
{
if (b->thread != -1)
{
@@ -6328,10 +6372,10 @@ print_one_breakpoint_location (struct breakpoint *b,
uiout->text ("\n");
if (!part_of_multiple)
if (loc == nullptr)
b->print_one_detail (uiout);
if (part_of_multiple && frame_id_p (b->frame_id))
if (loc != nullptr && frame_id_p (b->frame_id))
{
annotate_field (6);
uiout->text ("\tstop only in stack frame at ");
@@ -6342,7 +6386,7 @@ print_one_breakpoint_location (struct breakpoint *b,
uiout->text ("\n");
}
if (!part_of_multiple && b->cond_string)
if (loc == nullptr && b->cond_string)
{
annotate_field (7);
if (is_tracepoint (b))
@@ -6364,7 +6408,7 @@ print_one_breakpoint_location (struct breakpoint *b,
uiout->text ("\n");
}
if (!part_of_multiple && b->thread != -1)
if (loc == nullptr && b->thread != -1)
{
/* FIXME should make an annotation for this. */
uiout->text ("\tstop only in thread ");
@@ -6379,7 +6423,7 @@ print_one_breakpoint_location (struct breakpoint *b,
uiout->text ("\n");
}
if (!part_of_multiple)
if (loc == nullptr)
{
if (b->hit_count)
{
@@ -6405,7 +6449,7 @@ print_one_breakpoint_location (struct breakpoint *b,
}
}
if (!part_of_multiple && b->ignore_count)
if (loc == nullptr && b->ignore_count)
{
annotate_field (8);
uiout->message ("\tignore next %pF hits\n",
@@ -6415,7 +6459,7 @@ print_one_breakpoint_location (struct breakpoint *b,
/* Note that an enable count of 1 corresponds to "enable once"
behavior, which is reported by the combination of enablement and
disposition, so we don't need to mention it here. */
if (!part_of_multiple && b->enable_count > 1)
if (loc == nullptr && b->enable_count > 1)
{
annotate_field (8);
uiout->text ("\tdisable after ");
@@ -6429,7 +6473,7 @@ print_one_breakpoint_location (struct breakpoint *b,
uiout->text (" hits\n");
}
if (!part_of_multiple && is_tracepoint (b))
if (loc == nullptr && is_tracepoint (b))
{
struct tracepoint *tp = (struct tracepoint *) b;
@@ -6442,7 +6486,7 @@ print_one_breakpoint_location (struct breakpoint *b,
}
l = b->commands ? b->commands.get () : NULL;
if (!part_of_multiple && l)
if (loc == nullptr && l)
{
annotate_field (9);
ui_out_emit_tuple tuple_emitter (uiout, "script");
@@ -6453,7 +6497,7 @@ print_one_breakpoint_location (struct breakpoint *b,
{
struct tracepoint *t = (struct tracepoint *) b;
if (!part_of_multiple && t->pass_count)
if (loc == nullptr && t->pass_count)
{
annotate_field (10);
uiout->text ("\tpass count ");
@@ -6463,7 +6507,7 @@ print_one_breakpoint_location (struct breakpoint *b,
/* Don't display it when tracepoint or tracepoint location is
pending. */
if (!header_of_multiple && loc != NULL && !loc->shlib_disabled)
if (loc != nullptr && !loc->shlib_disabled)
{
annotate_field (11);
@@ -6481,7 +6525,7 @@ print_one_breakpoint_location (struct breakpoint *b,
}
}
if (uiout->is_mi_like_p () && !part_of_multiple)
if (uiout->is_mi_like_p () && loc == nullptr)
{
if (is_watchpoint (b))
{
@@ -6498,6 +6542,18 @@ print_one_breakpoint_location (struct breakpoint *b,
return result;
}
/* Return whether to print the "Address" column. The "Address" column
is suppressed with either "set print address off", or "info
breakpoints -hide-locations". */
static bool
should_print_address_col (const info_breakpoints_opts &ib_opts)
{
struct value_print_options opts;
get_user_print_options (&opts);
return opts.addressprint && !ib_opts.hide_locations;
}
/* See breakpoint.h. */
bool fix_multi_location_breakpoint_output_globally = false;
@@ -6505,46 +6561,42 @@ bool fix_multi_location_breakpoint_output_globally = false;
static void
print_one_breakpoint (struct breakpoint *b,
struct bp_location **last_loc,
int allflag)
int allflag,
const info_breakpoints_opts &ib_opts)
{
struct ui_out *uiout = current_uiout;
bool use_fixed_output
= (uiout->test_flags (fix_multi_location_breakpoint_output)
|| fix_multi_location_breakpoint_output_globally);
bool print_address_col = should_print_address_col (ib_opts);
gdb::optional<ui_out_emit_tuple> bkpt_tuple_emitter (gdb::in_place, uiout, "bkpt");
bool printed = print_one_breakpoint_location (b, NULL, 0, last_loc,
allflag, false);
allflag, false, print_address_col);
/* The mi2 broken format: the main breakpoint tuple ends here, the locations
are outside. */
if (!use_fixed_output)
bkpt_tuple_emitter.reset ();
/* If this breakpoint has custom print function,
it's already printed. Otherwise, print individual
locations, if any. */
if (!printed || allflag)
/* If this breakpoint has a custom print function, it's already
printed. Otherwise, print individual locations, if any, and if
not explicitly disabled by the user. */
if (!ib_opts.hide_locations && (!printed || allflag))
{
/* If breakpoint has a single location that is disabled, we
print it as if it had several locations, since otherwise it's
hard to represent "breakpoint enabled, location disabled"
situation.
Note that while hardware watchpoints have several locations
/* Note that while hardware watchpoints have several locations
internally, that's not a property exposed to users.
Likewise, while catchpoints may be implemented with
breakpoints (e.g., catch throw), that's not a property
exposed to users. We do however display the internal
breakpoint locations with "maint info breakpoints". */
if (!is_hardware_watchpoint (b)
&& (!is_catchpoint (b) || is_exception_catchpoint (b)
|| is_ada_exception_catchpoint (b))
&& (allflag
|| (b->loc && (b->loc->next
|| !b->loc->enabled
|| b->loc->disabled_by_cond))))
if (!is_watchpoint (b)
&& (!is_catchpoint (b)
|| ((is_exception_catchpoint (b)
|| is_ada_exception_catchpoint (b))
&& allflag)))
{
gdb::optional<ui_out_emit_list> locations_list;
@@ -6559,7 +6611,8 @@ print_one_breakpoint (struct breakpoint *b,
{
ui_out_emit_tuple loc_tuple_emitter (uiout, NULL);
print_one_breakpoint_location (b, loc, n, last_loc,
allflag, allflag);
allflag, allflag,
print_address_col);
n++;
}
}
@@ -6589,8 +6642,9 @@ breakpoint_address_bits (struct breakpoint *b)
void
print_breakpoint (breakpoint *b)
{
info_breakpoints_opts ib_opts;
struct bp_location *dummy_loc = NULL;
print_one_breakpoint (b, &dummy_loc, 0);
print_one_breakpoint (b, &dummy_loc, 0, ib_opts);
}
/* Return true if this breakpoint was set by the user, false if it is
@@ -6612,9 +6666,9 @@ pending_breakpoint_p (struct breakpoint *b)
/* Print information on breakpoints (including watchpoints and tracepoints).
If non-NULL, BP_NUM_LIST is a list of numbers and number ranges as
understood by number_or_range_parser. Only breakpoints included in this
list are then printed.
If non-NULL, ARGS possibly contains options, followed by a list of
numbers and number ranges as understood by number_or_range_parser.
Only breakpoints included in this list are then printed.
If SHOW_INTERNAL is true, print internal breakpoints.
@@ -6624,18 +6678,30 @@ pending_breakpoint_p (struct breakpoint *b)
Return the total number of breakpoints listed. */
static int
breakpoint_1 (const char *bp_num_list, bool show_internal,
breakpoint_1 (const char *args, bool show_internal,
bool (*filter) (const struct breakpoint *))
{
struct bp_location *last_loc = NULL;
int nr_printable_breakpoints;
struct value_print_options opts;
int print_address_bits = 0;
int print_type_col_width = 14;
struct ui_out *uiout = current_uiout;
bool has_disabled_by_cond_location = false;
get_user_print_options (&opts);
info_breakpoints_opts ib_opts;
auto grp = make_info_breakpoints_options_def_group (&ib_opts);
gdb::option::process_options
(&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp);
if (args != nullptr
&& args[0] == '-' && (!show_internal || !isdigit (args[1])))
gdb::option::error_unrecognized_option_at (args);
const char *bp_num_list = args;
bool print_address_col = should_print_address_col (ib_opts);
/* Compute the number of rows in the table, as well as the size
required for address fields. */
@@ -6674,7 +6740,7 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
{
ui_out_emit_table table_emitter (uiout,
opts.addressprint ? 6 : 5,
print_address_col ? 6 : 5,
nr_printable_breakpoints,
"BreakpointTable");
@@ -6692,7 +6758,7 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
if (nr_printable_breakpoints > 0)
annotate_field (3);
uiout->table_header (3, ui_left, "enabled", "Enb"); /* 4 */
if (opts.addressprint)
if (print_address_col)
{
if (nr_printable_breakpoints > 0)
annotate_field (4);
@@ -6708,6 +6774,10 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
if (nr_printable_breakpoints > 0)
annotate_breakpoints_table ();
#define EXTRA_LINE
#ifdef EXTRA_LINE
bool printed_one = false;
#endif
for (breakpoint *b : all_breakpoints ())
{
QUIT;
@@ -6735,7 +6805,13 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
show_internal is set. */
if (show_internal || user_breakpoint_p (b))
{
print_one_breakpoint (b, &last_loc, show_internal);
#ifdef EXTRA_LINE
if (printed_one && !ib_opts.hide_locations)
uiout->text ("\n");
printed_one = true;
#endif
print_one_breakpoint (b, &last_loc, show_internal, ib_opts);
for (bp_location *loc : b->locations ())
if (loc->disabled_by_cond)
has_disabled_by_cond_location = true;
@@ -6773,6 +6849,29 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
return nr_printable_breakpoints;
}
/* Completer for the "info breakpoints" command. */
static void
info_breakpoints_command_completer (struct cmd_list_element *ignore,
completion_tracker &tracker,
const char *text, const char *word_ignored)
{
const auto grp = make_info_breakpoints_options_def_group (nullptr);
if (gdb::option::complete_options
(tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp))
return;
/* Convenience to let the user know what the command can accept. */
if (*text == '\0')
{
gdb::option::complete_on_all_options (tracker, grp);
/* Keep this "ID" in sync with what "help info breakpoints"
says. */
tracker.add_completion (make_unique_xstrdup ("ID"));
}
}
/* Display the value of default-collect in a way that is generally
compatible with the breakpoint list. */
@@ -9160,7 +9259,7 @@ ranged_breakpoint::print_it (const bpstat *bs) const
/* Implement the "print_one" method for ranged breakpoints. */
bool
ranged_breakpoint::print_one (bp_location **last_loc) const
ranged_breakpoint::print_one (bp_location **last_loc, bool print_address_col) const
{
struct bp_location *bl = loc;
struct value_print_options opts;
@@ -9171,7 +9270,7 @@ ranged_breakpoint::print_one (bp_location **last_loc) const
get_user_print_options (&opts);
if (opts.addressprint)
if (print_address_col)
/* We don't print the address range here, it will be printed later
by print_one_detail_ranged_breakpoint. */
uiout->field_skip ("addr");
@@ -14376,10 +14475,13 @@ are set to the address of the last breakpoint listed unless the command\n\
is prefixed with \"server \".\n\n\
Convenience variable \"$bpnum\" contains the number of the last\n\
breakpoint set."));
set_cmd_completer_handle_brkchars (info_breakpoints_cmd,
info_breakpoints_command_completer);
add_info_alias ("b", info_breakpoints_cmd, 1);
add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints, _("\
cmd_list_element *breakpoints_cmd
= add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints, _("\
Status of all breakpoints, or breakpoint number NUMBER.\n\
The \"Type\" column indicates one of:\n\
\tbreakpoint - normal breakpoint\n\
@@ -14399,6 +14501,8 @@ is prefixed with \"server \".\n\n\
Convenience variable \"$bpnum\" contains the number of the last\n\
breakpoint set."),
&maintenanceinfolist);
set_cmd_completer_handle_brkchars (breakpoints_cmd,
info_breakpoints_command_completer);
add_basic_prefix_cmd ("catch", class_breakpoint, _("\
Set catchpoints to catch events."),

View File

@@ -679,8 +679,9 @@ struct breakpoint
/* Display information about this breakpoint, for "info
breakpoints". Returns false if this method should use the
default behavior. */
virtual bool print_one (bp_location **) const
default behavior. PRINT_ADDRESS_COL specifies whether the "addr"
column should be printed. */
virtual bool print_one (bp_location **, bool print_address_col) const
{
return false;
}

View File

@@ -174,6 +174,14 @@ complete_on_all_options (completion_tracker &tracker,
complete_on_options (options_group, tracker, opt + 1, opt);
}
/* See cli-option.h. */
void
error_unrecognized_option_at (const char *at)
{
error (_("Unrecognized option at: %s"), at);
}
/* Parse ARGS, guided by OPTIONS_GROUP. HAVE_DELIMITER is true if the
whole ARGS line included the "--" options-terminator delimiter. */
@@ -189,7 +197,7 @@ parse_option (gdb::array_view<const option_def_group> options_group,
else if (**args != '-')
{
if (have_delimiter)
error (_("Unrecognized option at: %s"), *args);
error_unrecognized_option_at (*args);
return {};
}
else if (check_for_argument (args, "--"))
@@ -235,7 +243,7 @@ parse_option (gdb::array_view<const option_def_group> options_group,
if (match == nullptr)
{
if (have_delimiter || mode != PROCESS_OPTIONS_UNKNOWN_IS_OPERAND)
error (_("Unrecognized option at: %s"), *args);
error_unrecognized_option_at (*args);
return {};
}

View File

@@ -335,6 +335,12 @@ extern void
complete_on_all_options (completion_tracker &tracker,
gdb::array_view<const option_def_group> options_group);
/* Throw an error indicating an unrecognized option was detected at
AT. Use this in conjunction with UNKNOWN_IS_OPERAND instead of
UNKNOWN_IS_ERROR when the operand may or may not begin with '-'
depending on some condition determined at run time. */
extern void error_unrecognized_option_at (const char *at);
/* Return a string with the result of replacing %OPTIONS% in HELP_TMLP
with an auto-generated "help" string fragment for all the options
in OPTIONS_GROUP. */

View File

@@ -2024,7 +2024,7 @@ func<int>() func<float>()
(@value{GDBP}) p 'func<
@end smallexample
When setting breakpoints however (@pxref{Specify Location}), you don't
When setting breakpoints however (@pxref{Location Specifications}), you don't
usually need to type a quote before the function name, because
@value{GDBN} understands that you want to set a breakpoint on a
function:
@@ -4344,16 +4344,24 @@ convenience variables.
@table @code
@item break @var{location}
Set a breakpoint at the given @var{location}, which can specify a
function name, a line number, or an address of an instruction.
(@xref{Specify Location}, for a list of all the possible ways to
specify a @var{location}.) The breakpoint will stop your program just
before it executes any of the code in the specified @var{location}.
Set a breakpoint at all the locations the given location specification
matches. @var{location} can specify a function name, a line number,
an address of an instruction, and more. @xref{Location
Specifications}, for the various forms of @var{location}.
When using source languages that permit overloading of symbols, such as
C@t{++}, a function name may refer to more than one possible place to break.
@xref{Ambiguous Expressions,,Ambiguous Expressions}, for a discussion of
that situation.
When using source languages that permit overloading of symbols, such
as C@t{++}, a function name may refer to more than one symbol, and
thus more than one place to break. @xref{Ambiguous
Expressions,,Ambiguous Expressions}, for a discussion of that
situation.
It is possible that a given function is instantiated more than once in
the program, resulting in a breakpoint with multiple addresses, and
thus multiple locations. This can happen e.g., with inlined
functions, or template functions.
The breakpoint will stop your program just before it executes any of
the instructions at its locations' addresses.
It is also possible to insert a breakpoint that will stop the program
only if a specific thread (@pxref{Thread-Specific Breakpoints})
@@ -4407,11 +4415,11 @@ command:
@smallexample
(@value{GDBP}) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1 breakpoint keep y func
stop only if a == 10
1.1 N* 0x00000000000011b6 in ...
1.2 y 0x00000000000011c2 in ...
1.3 N* 0x00000000000011ce in ...
1.1 N* 0x00000000000011b6 in ...
1.2 y 0x00000000000011c2 in ...
1.3 N* 0x00000000000011ce in ...
(*): Breakpoint condition is invalid at this location.
@end smallexample
@@ -4543,34 +4551,48 @@ optionally be surrounded by spaces.
@kindex info breakpoints
@cindex @code{$_} and @code{info breakpoints}
@item info breakpoints @r{[}@var{list}@dots{}@r{]}
@itemx info break @r{[}@var{list}@dots{}@r{]}
Print a table of all breakpoints, watchpoints, and catchpoints set and
not deleted. Optional argument @var{n} means print information only
about the specified breakpoint(s) (or watchpoint(s) or catchpoint(s)).
For each breakpoint, following columns are printed:
@item info breakpoints [-hide-locations] @r{[}@var{list}@dots{}@r{]}
@itemx info break [-hide-locations] @r{[}@var{list}@dots{}@r{]}
Print a table of all breakpoints, watchpoints, tracepoints, and
catchpoints set and not deleted. The optional argument @var{n} means
print information only about the specified breakpoint(s) (or
watchpoint(s) or tracepoint(s) or catchpoint(s)).
Unless the @code{-hide-locations} option is specified, for each code
breakpoint and tracepoint (i.e., not for watchpoints, nor
catchpoints), after printing a row for the breakpoint itself,
@value{GDBN} prints one row for each of the breakpoint's locations.
More on this further below.
For each breakpoint (and watchpoint, tracepoint, catchpoint) and
breakpoint location, the following columns are printed:
@table @emph
@item Breakpoint Numbers
@item Type
Breakpoint, watchpoint, or catchpoint.
Breakpoint, watchpoint, tracepoint, or catchpoint. This is empty for
breakpoint location rows.
@item Disposition
Whether the breakpoint is marked to be disabled or deleted when hit.
This is empty for breakpoint location rows.
@item Enabled or Disabled
Enabled breakpoints are marked with @samp{y}. @samp{n} marks breakpoints
that are not enabled.
Enabled breakpoints and breakpoint locations are marked with @samp{y}.
@samp{n} marks breakpoints and breakpoint locations that are not
enabled. Note individual locations can be enabled/disabled
independently of their parent breakpoint.
@item Address
Where the breakpoint is in your program, as a memory address. For a
pending breakpoint whose address is not yet known, this field will
contain @samp{<PENDING>}. Such breakpoint won't fire until a shared
library that has the symbol or line referred by breakpoint is loaded.
See below for details. A breakpoint with several locations will
have @samp{<MULTIPLE>} in this field---see below for details.
Where the breakpoint location is in your program, as a memory address.
For a breakpoint with no locations, this field will contain
@samp{<PENDING>}. This column is not printed if you specify the
@code{-hide-locations} option, nor if you disable printing of
addresses with @code{set print address off} (@pxref{set print
address}).
@item What
Where the breakpoint is in the source for your program, as a file and
line number. For a pending breakpoint, the original string passed to
the breakpoint command will be listed as it cannot be resolved until
the appropriate shared library is loaded in the future.
For a breakpoint header row, this shows the breakpoint's location
specification, derived from the string passed to the breakpoint
command. For a breakpoint location row, this shows where the
breakpoint location is in the source for your program, as a file and
line number.
@end table
@noindent
@@ -4583,8 +4605,7 @@ its condition evaluation mode in between parentheses.
Breakpoint commands, if any, are listed after that. A pending breakpoint is
allowed to have a condition specified for it. The condition is not parsed for
validity until a shared library is loaded that allows the pending
breakpoint to resolve to a valid location.
validity until the pending breakpoint is resolved to a valid location.
@noindent
@code{info break} with a breakpoint
@@ -4614,46 +4635,102 @@ the breakpoints are conditional, this is even useful
@cindex multiple locations, breakpoints
@cindex breakpoints, multiple locations
It is possible that a breakpoint corresponds to several locations
in your program. Examples of this situation are:
It is possible that a breakpoint corresponds to several locations in
your program. @value{GDBN} will insert a breakpoint at all the
locations its location specification resolves to.
@xref{Location Specifications}.
@itemize @bullet
@item
Multiple functions in the program may have the same name.
@value{GDBN} may add new locations to existing breakpoints when new
symbols are loaded. For example, if you have a breakpoint in a
C@t{++} template function, and a newly loaded shared library has an
instantiation of that template, a new location is added to the list of
locations for the breakpoint. More on this further below.
@item
For a C@t{++} constructor, the @value{NGCC} compiler generates several
instances of the function body, used in different cases.
@item
For a C@t{++} template function, a given line in the function can
correspond to any number of instantiations.
@item
For an inlined function, a given source line can correspond to
several places where that function is inlined.
@end itemize
In all those cases, @value{GDBN} will insert a breakpoint at all
the relevant locations.
A breakpoint with multiple locations is displayed in the breakpoint
table using several rows---one header row, followed by one row for
each breakpoint location. The header row has @samp{<MULTIPLE>} in the
address column. The rows for individual locations contain the actual
addresses for locations, and show the functions to which those
locations belong. The number column for a location is of the form
@var{breakpoint-number}.@var{location-number}.
As mentioned above, regular code breakpoints and tracepoints are normally
displayed in the breakpoint table using several rows---one header row
per breakpoint, followed by one row for each of the breakpoint's
locations. The header row has an empty address column, and the
breakpoint's location specification in the what column. The rows for
individual locations contain the addresses for the locations, and show
the functions to which those addresses belong. The number column for
a location is indented by one space to the right for grouping, and is
of the form @var{breakpoint-number}.@var{location-number}.
For example:
@smallexample
(@value{GDBP}) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1 breakpoint keep y foo
stop only if i==1
breakpoint already hit 1 time
1.1 y 0x080486a2 in void foo<int>() at t.cc:8
1.2 y 0x080486ca in void foo<double>() at t.cc:8
1.1 y 0x080486a2 in void foo<int>() at t.cc:8
1.2 y 0x080486ca in void foo<double>() at t.cc:8
2 breakpoint keep y bar
2.1 y 0x080646a8 in void bar() at t.cc:20
@end smallexample
Above you can tell from the what column that the breakpoint had been
created with @code{break foo}, and that @value{GDBN} found two actual
locations that matched that location specification, each of them a
different instanciation of the foo function template.
When the @code{-hide-locations} flag is used, @value{GDBN} doesn't
print breakpoint locations, and doesn't print the address column
either, since only breakpoint locations have addresses. With the same
breakpoints as the previous example, you'd get:
@smallexample
(@value{GDBP}) info breakpoints -hide-locations
Num Type Disp Enb What
1 breakpoint keep y foo
stop only if i==1
breakpoint already hit 1 time
2 breakpoint keep y bar
@end smallexample
Breakpoints created with the @code{-qualified} option show that fact
in the breakpoint row's what column, as part of the breakpoint's
location specification. For example:
@smallexample
Num Type Disp Enb Address What
1 breakpoint keep y -qualified func
1.1 y 0x080486a2 in void func() at func.cc:30
2 breakpoint keep y func
2.1 y 0x080486a2 in void func() at func.cc:30
@end smallexample
Note how above both breakpoints resolved to the same location, while
they show different location specifications. If the program
subsequently loads a shared library that defines a C@t{++} method
named @code{A::func()}, then breakpoint 2 will gain a new location,
but not breakpoint 1, like so:
@smallexample
Num Type Disp Enb Address What
1 breakpoint keep y -qualified func
1.1 y 0x0000080486a2 in void func() at func.cc:30
2 breakpoint keep y func
2.1 y 0x0000080486a2 in void func() at func.cc:30
2.2 y 0x7ffff6caa000 in int A::func(int) at shlib.cc:102
@end smallexample
If you set a breakpoint by line number, @value{GDBN} may determine
that there is no actual code at the given line number, and arm the
breakpoint at the next line number with code instead. This can happen
for example if the line number you specify corresponds to a source
location that only contains comments, or contains source code that was
completely optimized out. You can identify such a situation happened
in @code{info breakpoints} output, as the location specification for
the breakpoint as shown in the what column gives you the line you
requested, while the breakpoint's location row shows the line the
breakpoint was actually planted at:
@smallexample
Num Type Disp Enb Address What
1 breakpoint keep y file.c:18
1.1 y 0x08028832 in void func() at path/to/file.c:20
@end smallexample
You cannot delete the individual locations from a breakpoint. However,
@@ -4677,53 +4754,54 @@ any shared library is loaded or unloaded. Typically, you would
set a breakpoint in a shared library at the beginning of your
debugging session, when the library is not loaded, and when the
symbols from the library are not available. When you try to set
breakpoint, @value{GDBN} will ask you if you want to set
a so called @dfn{pending breakpoint}---breakpoint whose address
is not yet resolved.
a breakpoint, @value{GDBN} will ask you for confirmation of whether
you want to set a so called @dfn{pending breakpoint}---a breakpoint with
no resolved locations yet.
After the program is run, whenever a new shared library is loaded,
@value{GDBN} reevaluates all the breakpoints. When a newly loaded
shared library contains the symbol or line referred to by some
pending breakpoint, that breakpoint is resolved and becomes an
ordinary breakpoint. When a library is unloaded, all breakpoints
that refer to its symbols or source lines become pending again.
@value{GDBN} reevaluates all the breakpoints' location specs. When a
newly loaded shared library contains the symbol or line referred to by
some pending breakpoint, a location for the breakpoint is found and
the breakpoint becomes an ordinary breakpoint. When a library is
unloaded, breakpoint locations that refer to its symbols or source
lines are not deleted -- they are instead displayed with a
@code{<PENDING>} address. This is so that if the shared library is
loaded again, the location's enabled/disabled state is preserved.
This logic works for breakpoints with multiple locations, too. For
example, if you have a breakpoint in a C@t{++} template function, and
a newly loaded shared library has an instantiation of that template,
a new location is added to the list of locations for the breakpoint.
Except for having unresolved address, pending breakpoints do not
Except for having no resolved locations, pending breakpoints do not
differ from regular breakpoints. You can set conditions or commands,
enable and disable them and perform other breakpoint operations.
@value{GDBN} provides some additional commands for controlling what
happens when the @samp{break} command cannot resolve breakpoint
address specification to an address:
happens when the @samp{break} command cannot resolve its breakpoint
location specification to any location:
@kindex set breakpoint pending
@kindex show breakpoint pending
@table @code
@item set breakpoint pending auto
This is the default behavior. When @value{GDBN} cannot find the breakpoint
location, it queries you whether a pending breakpoint should be created.
This is the default behavior. When @value{GDBN} cannot find any
location for the location specification, it queries you whether a
pending breakpoint should be created.
@item set breakpoint pending on
This indicates that an unrecognized breakpoint location should automatically
result in a pending breakpoint being created.
This indicates that when @value{GDBN} cannot resolve any location for
the location specification, it should create a pending breakpoint
without asking for confirmation.
@item set breakpoint pending off
This indicates that pending breakpoints are not to be created. Any
unrecognized breakpoint location results in an error. This setting does
not affect any pending breakpoints previously created.
This indicates that pending breakpoints are not to be created. If
@value{GDBN} cannot resolve any location for the location
specification, it aborts the breakpoint creation with an error. This
setting does not affect any pending breakpoints previously created.
@item show breakpoint pending
Show the current behavior setting for creating pending breakpoints.
@end table
The settings above only affect the @code{break} command and its
variants. Once breakpoint is set, it will be automatically updated
as shared libraries are loaded and unloaded.
variants. Once a breakpoint is created, it will be automatically
updated as shared libraries are loaded and unloaded.
@cindex automatic hardware breakpoints
For some targets, @value{GDBN} can automatically decide if hardware or
@@ -5444,8 +5522,8 @@ breakpoint where your program just stopped.
@item clear @var{location}
Delete any breakpoints set at the specified @var{location}.
@xref{Specify Location}, for the various forms of @var{location}; the
most useful ones are listed below:
@xref{Location Specifications}, for the various forms of
@var{location}; the most useful ones are listed below:
@table @code
@item clear @var{function}
@@ -5852,12 +5930,14 @@ you could do the following:
(gdb) set dprintf-style call
(gdb) set dprintf-function fprintf
(gdb) set dprintf-channel mylog
(gdb) dprintf 25,"at line 25, glob=%d\n",glob
(gdb) dprintf main.c:25,"at line 25, glob=%d\n",glob
Dprintf 1 at 0x123456: file main.c, line 25.
(gdb) info break
1 dprintf keep y 0x00123456 in main at main.c:25
Num Type Disp Enb Address What
1 dprintf keep y main.c:25
call (void) fprintf (mylog,"at line 25, glob=%d\n",glob)
continue
1.1 y 0x00123456 in main at main.c:25
(gdb)
@end example
@@ -6304,7 +6384,7 @@ argument.
@itemx u @var{location}
Continue running your program until either the specified @var{location} is
reached, or the current stack frame returns. The location is any of
the forms described in @ref{Specify Location}.
the forms described in @ref{Location Specifications}.
This form of the command uses temporary breakpoints, and
hence is quicker than @code{until} without an argument. The specified
location is actually reached only if it is in the current frame. This
@@ -6329,7 +6409,7 @@ invocations have returned.
@item advance @var{location}
Continue running the program up to the given @var{location}. An argument is
required, which should be of one of the forms described in
@ref{Specify Location}.
@ref{Location Specifications}.
Execution will also stop upon exit from the current stack
frame. This command is similar to @code{until}, but @code{advance} will
not skip over recursive function calls, and the target location doesn't
@@ -6429,7 +6509,7 @@ A more flexible solution is to execute @kbd{skip boring}. This instructs
@code{foo}.
Functions may be skipped by providing either a function name, linespec
(@pxref{Specify Location}), regular expression that matches the function's
(@pxref{Location Specifications}), regular expression that matches the function's
name, file name or a @code{glob}-style pattern that matches the file name.
On Posix systems the form of the regular expression is
@@ -6466,7 +6546,7 @@ over when stepping.
@itemx -fu @var{linespec}
Functions named by @var{linespec} or the function containing the line
named by @var{linespec} will be skipped over when stepping.
@xref{Specify Location}.
@xref{Location Specifications}.
@item -rfunction @var{regexp}
@itemx -rfu @var{regexp}
@@ -6499,7 +6579,7 @@ will be skipped.
@item skip function @r{[}@var{linespec}@r{]}
After running this command, the function named by @var{linespec} or the
function containing the line named by @var{linespec} will be skipped over when
stepping. @xref{Specify Location}.
stepping. @xref{Location Specifications}.
If you do not specify @var{linespec}, the function you're currently debugging
will be skipped.
@@ -7130,9 +7210,8 @@ breakpoints on all threads, or on a particular thread.
@kindex break @dots{} thread @var{thread-id}
@item break @var{location} thread @var{thread-id}
@itemx break @var{location} thread @var{thread-id} if @dots{}
@var{location} specifies source lines; there are several ways of
writing them (@pxref{Specify Location}), but the effect is always to
specify some source line.
@var{location} specifies a location or locations in your program's
code. @xref{Location Specifications}, for details.
Use the qualifier @samp{thread @var{thread-id}} with a breakpoint command
to specify that you only want @value{GDBN} to stop the program when a
@@ -8932,7 +9011,7 @@ prefer to use Emacs facilities to view source; see @ref{Emacs, ,Using
@menu
* List:: Printing source lines
* Specify Location:: How to specify code locations
* Location Specifications:: How to specify code locations
* Edit:: Editing source files
* Search:: Searching source files
* Source Path:: Specifying source directories
@@ -8948,7 +9027,7 @@ prefer to use Emacs facilities to view source; see @ref{Emacs, ,Using
To print lines from a source file, use the @code{list} command
(abbreviated @code{l}). By default, ten lines are printed.
There are several ways to specify what part of the file you want to
print; see @ref{Specify Location}, for the full list.
print; see @ref{Location Specifications}, for the full list.
Here are the forms of the @code{list} command most commonly used:
@@ -8997,7 +9076,7 @@ each repetition moves up in the source file.
In general, the @code{list} command expects you to supply zero, one or two
@dfn{locations}. Locations specify source lines; there are several ways
of writing them (@pxref{Specify Location}), but the effect is always
of writing them (@pxref{Location Specifications}), but the effect is always
to specify some source line.
Here is a complete description of the possible arguments for @code{list}:
@@ -9028,17 +9107,41 @@ Print lines just before the lines last printed.
As described in the preceding table.
@end table
@node Specify Location
@section Specifying a Location
@node Location Specifications
@section Location Specifications
@cindex specifying location
@cindex location
@cindex source location
Several @value{GDBN} commands accept arguments that specify a location
of your program's code. Since @value{GDBN} is a source-level
debugger, a location usually specifies some line in the source code.
Locations may be specified using three different formats:
linespec locations, explicit locations, or address locations.
debugger, a location specification usually indicates some line in the
source code, but it can also indicate a function name, an address, and
more.
A location specification serves as a blueprint, and it may match more
than one actual location in your program. Examples of this situation
are:
@itemize @bullet
@item
Multiple functions in the program may have the same name.
@item
For a C@t{++} constructor, the @value{NGCC} compiler generates several
instances of the function body, used in different cases.
@item
For a C@t{++} template function, a given line in the function can
correspond to any number of instantiations.
@item
For an inlined function, a given source line can correspond to several
places where that function is inlined.
@end itemize
Locations may be specified using three different formats: linespec
locations, explicit locations, or address locations.
@menu
* Linespec Locations:: Linespec locations
@@ -9260,9 +9363,9 @@ want to print if you want to see other parts of the program:
@item edit @var{location}
Edit the source file specified by @code{location}. Editing starts at
that @var{location}, e.g., at the specified source line of the
specified file. @xref{Specify Location}, for all the possible forms
of the @var{location} argument; here are the forms of the @code{edit}
command most commonly used:
specified file. @xref{Location Specifications}, for all the possible
forms of the @var{location} argument; here are the forms of the
@code{edit} command most commonly used:
@table @code
@item edit @var{number}
@@ -9645,8 +9748,8 @@ well as hex.
@itemx info line @var{location}
Print the starting and ending addresses of the compiled code for
source line @var{location}. You can specify source lines in any of
the ways documented in @ref{Specify Location}. With no @var{location}
information about the current source line is printed.
the ways documented in @ref{Location Specifications}. With no
@var{location} information about the current source line is printed.
@end table
For example, we can use @code{info line} to discover the location of
@@ -9870,10 +9973,10 @@ Dump of assembler code from 0x400281 to 0x40028b:
End of assembler dump.
@end smallexample
Addresses cannot be specified as a location (@pxref{Specify Location}).
So, for example, if you want to disassemble function @code{bar}
in file @file{foo.c}, you must type @samp{disassemble 'foo.c'::bar}
and not @samp{disassemble foo.c:bar}.
Addresses cannot be specified as a location (@pxref{Location
Specifications}). So, for example, if you want to disassemble
function @code{bar} in file @file{foo.c}, you must type
@samp{disassemble 'foo.c'::bar} and not @samp{disassemble foo.c:bar}.
Some architectures have more than one commonly-used set of instruction
mnemonics or other syntax.
@@ -14466,8 +14569,8 @@ conditions and actions.
@kindex trace
@item trace @var{location}
The @code{trace} command is very similar to the @code{break} command.
Its argument @var{location} can be any valid location.
@xref{Specify Location}. The @code{trace} command defines a tracepoint,
Its argument @var{location} can be any valid location specification.
@xref{Location Specifications}. The @code{trace} command defines a tracepoint,
which is a point in the target program where the debugger will briefly stop,
collect some data, and then allow the program to continue. Setting a tracepoint
or changing its actions takes effect immediately if the remote stub
@@ -14986,21 +15089,22 @@ the state about installed on target of each location
@smallexample
(@value{GDBP}) @b{info trace}
Num Type Disp Enb Address What
1 tracepoint keep y 0x0804ab57 in foo() at main.cxx:7
1 tracepoint keep y foo1
while-stepping 20
collect globfoo, $regs
end
collect globfoo2
end
pass count 1200
2 tracepoint keep y <MULTIPLE>
1.1 y 0x0804ab57 in foo1() at main.cxx:7
2 tracepoint keep y func4
collect $eip
2.1 y 0x0804859c in func4 at change-loc.h:35
2.1 y 0x0804859c in func4 at change-loc.h:35
installed on target
2.2 y 0xb7ffc480 in func4 at change-loc.h:35
2.2 y 0xb7ffc480 in func4 at change-loc.h:35
installed on target
2.3 y <PENDING> set_tracepoint
3 tracepoint keep y 0x080485b1 in foo at change-loc.c:29
3 tracepoint keep y foo2
3.1 y 0x080485b1 in foo2 at change-loc.c:29
not installed on target
(@value{GDBP})
@end smallexample
@@ -16946,7 +17050,8 @@ tag. For example:
Breakpoint 2 at 0x40060d: file main.cc, line 10.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x0040060d in function[abi:cxx11](int)
1 breakpoint keep y function(int)
1.1 y 0x0040060d in function[abi:cxx11](int)
at main.cc:10
@end smallexample
@@ -17426,9 +17531,9 @@ peculiarities and holes to be aware of.
@itemize @bullet
@item
Linespecs (@pxref{Specify Location}) are never relative to the current
crate. Instead, they act as if there were a global namespace of
crates, somewhat similar to the way @code{extern crate} behaves.
Linespecs (@pxref{Location Specifications}) are never relative to the
current crate. Instead, they act as if there were a global namespace
of crates, somewhat similar to the way @code{extern crate} behaves.
That is, if @value{GDBN} is stopped at a breakpoint in a function in
crate @samp{A}, module @samp{B}, then @code{break B::f} will attempt
@@ -18757,7 +18862,7 @@ Flags @code{-c} and @code{-s} cannot be used together.
These commands are like the @code{break @dots{} thread @dots{}}
command (@pxref{Thread Stops}). The
@var{location} argument specifies source lines, as described
in @ref{Specify Location}.
in @ref{Location Specifications}.
Use the qualifier @samp{task @var{taskno}} with a breakpoint command
to specify that you only want @value{GDBN} to stop the program when a
@@ -19520,10 +19625,11 @@ These commands can be used to enable or disable type printers.
@cindex local variables
@item info scope @var{location}
List all the variables local to a particular scope. This command
accepts a @var{location} argument---a function name, a source line, or
an address preceded by a @samp{*}, and prints all the variables local
to the scope defined by that location. (@xref{Specify Location}, for
details about supported forms of @var{location}.) For example:
accepts a location specification argument---a function name, a source
line, or an address preceded by a @samp{*}, and prints all the
variables local to the scope defined by that location specification.
(@xref{Location Specifications}, for details about supported forms of
@var{location}.) For example:
@smallexample
(@value{GDBP}) @b{info scope command_line_handler}
@@ -20114,8 +20220,8 @@ an address of your own choosing, with the following commands:
@item jump @var{location}
@itemx j @var{location}
Resume execution at @var{location}. Execution stops again immediately
if there is a breakpoint there. @xref{Specify Location}, for a description
of the different forms of @var{location}. It is common
if there is a breakpoint there. @xref{Location Specifications}, for a
description of the different forms of @var{location}. It is common
practice to use the @code{tbreak} command in conjunction with
@code{jump}. @xref{Set Breaks, ,Setting Breakpoints}.
@@ -25356,7 +25462,7 @@ use the @code{break-range} command.
Set a breakpoint for an address range given by
@var{start-location} and @var{end-location}, which can specify a function name,
a line number, an offset of lines from the current line or from the start
location, or an address of an instruction (see @ref{Specify Location},
location, or an address of an instruction (see @ref{Location Specifications},
for a list of all the possible ways to specify a @var{location}.)
The breakpoint will stop execution of the inferior whenever it
executes an instruction at any address within the specified range,
@@ -30544,11 +30650,10 @@ value is @samp{y}, or disabled, in which case the value is @samp{n}.
Note that this is not the same as the field @code{enable}.
@item addr
The address of the breakpoint. This may be a hexidecimal number,
The address of the breakpoint. This may be a hexadecimal number,
giving the address; or the string @samp{<PENDING>}, for a pending
breakpoint; or the string @samp{<MULTIPLE>}, for a breakpoint with
multiple locations. This field will not be present if no address can
be determined. For example, a watchpoint does not have an address.
breakpoint; This field will not be present if no address can be
determined. For example, a watchpoint does not have an address.
@item addr_flags
Optional field containing any flags related to the address. These flags are
@@ -30629,16 +30734,14 @@ is not.
Some extra data, the exact contents of which are type-dependent.
@item locations
This field is present if the breakpoint has multiple locations. It is also
exceptionally present if the breakpoint is enabled and has a single, disabled
location.
This field is present for ordinary breakpoints and tracepoints.
The value is a list of locations. The format of a location is described below.
@end table
A location in a multi-location breakpoint is represented as a tuple with the
following fields:
Each location in an ordinary breakpoint or tracepoint is represented
as a tuple with the following fields:
@table @code
@@ -30660,7 +30763,7 @@ at this location.
@end table
@item addr
The address of this location as an hexidecimal number.
The address of this location as an hexadecimal number.
@item addr_flags
Optional field containing any flags related to the address. These flags are
@@ -32542,8 +32645,8 @@ fullname="/home/foo/bar/try.c",line="13",arch="i386:x86_64"@}
@end smallexample
Resumes execution of the inferior program at the location specified by
parameter. @xref{Specify Location}, for a description of the
different forms of @var{location}.
the parameter. @xref{Location Specifications}, for a description of
the different forms of @var{location}.
@subsubheading @value{GDBN} Command
@@ -34922,7 +35025,7 @@ next trace frame that corresponds to a tracepoint at an address outside
the specified range. Both bounds are considered to be inside the range.
@item line
Line specification is required as parameter. @xref{Specify Location}.
Line specification is required as parameter. @xref{Location Specifications}.
Finds next trace frame that corresponds to a tracepoint at
the specified location.

View File

@@ -1965,7 +1965,7 @@ This constant means that filename completion should be performed.
@item COMPLETE_LOCATION
This constant means that location completion should be done.
@xref{Specify Location}.
@xref{Location Specifications}.
@item COMPLETE_COMMAND
This constant means that completion should examine @value{GDBN}

View File

@@ -577,7 +577,8 @@ either @code{None} or another tuple that contains all the locations
that match the expression represented as @code{gdb.Symtab_and_line}
objects (@pxref{Symbol Tables In Python}). If @var{expression} is
provided, it is decoded the way that @value{GDBN}'s inbuilt
@code{break} or @code{edit} commands do (@pxref{Specify Location}).
@code{break} or @code{edit} commands do (@pxref{Location
Specifications}).
@end defun
@defun gdb.prompt_hook (current_prompt)
@@ -4186,7 +4187,7 @@ This constant means that filename completion should be performed.
@vindex COMPLETE_LOCATION
@item gdb.COMPLETE_LOCATION
This constant means that location completion should be done.
@xref{Specify Location}.
@xref{Location Specifications}.
@vindex COMPLETE_COMMAND
@item gdb.COMPLETE_COMMAND