gdb: don't display inferior list for pending breakpoints

I noticed that in the 'info breakpoints' output, GDB sometimes prints
the inferior list for pending breakpoints, this doesn't seem right to
me.  A pending breakpoint has no locations (at least, as far as we
display things in the 'info breakpoints' output), so including an
inferior list seems odd.

Here's what I see right now:

  (gdb) info breakpoint 5
  Num     Type           Disp Enb Address            What
  5       breakpoint     keep y   <PENDING>          foo inf 1
  (gdb)

It's the 'inf 1' at the end of the line that I'm objecting too.

To trigger this behaviour we need to be in a multi-inferior debug
session.  The breakpoint must have been non-pending at some point in
the past, and so have a location assigned to it.

The breakpoint becomes pending again as a result of a shared library
being unloaded.  When this happens the location itself is marked
pending (via bp_location::shlib_disabled).

In print_one_breakpoint_location, in order to print the inferior list
we check that the breakpoint has a location, and that we have multiple
inferiors, but we don't check if the location itself is pending.

This commit adds that check, which means the output is now:

  (gdb) info breakpoint 5
  Num     Type           Disp Enb Address            What
  5       breakpoint     keep y   <PENDING>          foo
  (gdb)

Which I think makes more sense -- indeed, the format without the
inferior list is what we display for a pending breakpoint that has
never had any locations assigned, so I think this change in behaviour
makes GDB more consistent.
This commit is contained in:
Andrew Burgess
2023-04-13 15:12:17 +01:00
parent 9f26b04c3e
commit 7934cb137a
4 changed files with 215 additions and 1 deletions

View File

@@ -6592,7 +6592,7 @@ print_one_breakpoint_location (struct breakpoint *b,
}
}
if (loc != NULL && !header_of_multiple)
if (loc != nullptr && !header_of_multiple && !loc->shlib_disabled)
{
std::vector<int> inf_nums;
int mi_only = 1;