mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-15 04:31:49 +08:00
7934cb137a
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.
67 lines
1.5 KiB
C
67 lines
1.5 KiB
C
/* Copyright 2023-2024 Free Software Foundation, Inc.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#include <dlfcn.h>
|
|
#include <stdlib.h>
|
|
|
|
void
|
|
breakpt (void)
|
|
{
|
|
/* Nothing. */
|
|
}
|
|
|
|
volatile int global_counter = 0;
|
|
|
|
volatile int call_count = 1;
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
void *handle;
|
|
void (*func)(int);
|
|
|
|
/* Some filler work so that we don't initially stop on the breakpt call
|
|
below. */
|
|
++global_counter;
|
|
|
|
breakpt (); /* Break before open. */
|
|
|
|
/* Now load the shared library. */
|
|
handle = dlopen (SHLIB_NAME, RTLD_LAZY);
|
|
if (handle == NULL)
|
|
abort ();
|
|
|
|
breakpt (); /* Break after open. */
|
|
|
|
/* Find the function symbol. */
|
|
func = (void (*)(int)) dlsym (handle, "foo");
|
|
|
|
for (; call_count > 0; --call_count)
|
|
{
|
|
/* Call the library function. */
|
|
func (1);
|
|
}
|
|
|
|
breakpt (); /* Break before close. */
|
|
|
|
/* Unload the shared library. */
|
|
if (dlclose (handle) != 0)
|
|
abort ();
|
|
|
|
breakpt (); /* Break after close. */
|
|
|
|
return 0;
|
|
}
|