aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2014-06-16 15:38:13 +0100
committerPedro Alves <palves@redhat.com>2014-06-16 15:38:13 +0100
commitd03de42190b3b55fb195340dde8e595714a35090 (patch)
treecb1c4765e29cd4a9c49bf5ee473ce8789657c217 /gdb/breakpoint.c
parent99f4262f2c7e3457f45bd9921889456285d8b025 (diff)
downloadgdb-d03de42190b3b55fb195340dde8e595714a35090.zip
gdb-d03de42190b3b55fb195340dde8e595714a35090.tar.gz
gdb-d03de42190b3b55fb195340dde8e595714a35090.tar.bz2
"$ gdb PROGRAM" vs "(gdb) file PROGRAM" difference; warn on failure to remove breakpoint.
Turns out there's a difference between loading the program with "gdb PROGRAM", vs loading it with "(gdb) file PROGRAM". The latter results in the objfile ending up with OBJF_USERLOADED set, while not with the former. (That difference seems bogus, but still that's not the point of this patch. We can revisit that afterwards.) The new code that suppresses breakpoint removal errors for add-symbol-file objects ends up being too greedy: /* In some cases, we might not be able to remove a breakpoint in a shared library that has already been removed, but we have not yet processed the shlib unload event. Similarly for an unloaded add-symbol-file object - the user might not yet have had the chance to remove-symbol-file it. shlib_disabled will be set if the library/object has already been removed, but the breakpoint hasn't been uninserted yet, e.g., after "nosharedlibrary" or "remove-symbol-file" with breakpoints always-inserted mode. */ if (val && (bl->loc_type == bp_loc_software_breakpoint && (bl->shlib_disabled || solib_name_from_address (bl->pspace, bl->address) || userloaded_objfile_contains_address_p (bl->pspace, bl->address)))) val = 0; as it turns out that OBJF_USERLOADED can be set for objfiles loaded by some other means not add-symbol-file. In this case, symbol-file (or "file", which is really just "exec-file"+"symbol-file"). Recall that add-symbol-file is documented as: (gdb) help add-symbol-file Load symbols from FILE, assuming FILE has been dynamically loaded. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ And it's the "dynamically loaded" aspect that the breakpoint.c code cares about. So make add-symbol-file set OBJF_SHARED on its objfiles too, and tweak the breakpoint.c code to look for OBJF_SHARED instead of OBJF_USERLOADED. This restores back the missing breakpoint removal warning when we let sss-bp-on-user-bp-2.exp run on native GNU/Linux (https://sourceware.org/ml/gdb-patches/2014-06/msg00335.html): (gdb) PASS: gdb.base/sss-bp-on-user-bp-2.exp: define stepi_del_break stepi_del_break warning: Error removing breakpoint 3 (gdb) FAIL: gdb.base/sss-bp-on-user-bp-2.exp: stepi_del_break I say "restores" because this was GDB's behavior in 7.7 and earlier. And, likewise, "file" with no arguments only started turning breakpoints set in the main executable to "<pending>" with the remote-symbol-file patch (63644780). The old behavior is now restored, and we break-unload-file.exp test now exercizes both "gdb; file PROGRAM" and "gdb PROGRAM". gdb/ 2014-06-16 Pedro Alves <palves@redhat.com> * breakpoint.c (insert_bp_location, remove_breakpoint_1): Adjust. (disable_breakpoints_in_freed_objfile): Skip objfiles that don't have OBJF_SHARED set. * objfiles.c (userloaded_objfile_contains_address_p): Rename to... (shared_objfile_contains_address_p): ... this. Check OBJF_SHARED instead of OBJF_USERLOADED. * objfiles.h (OBJF_SHARED): Update comment. (userloaded_objfile_contains_address_p): Rename to ... (shared_objfile_contains_address_p): ... this, and update comments. * symfile.c (add_symbol_file_command): Also set OBJF_SHARED in the new objfile. (remove_symbol_file_command): Skip objfiles that don't have OBJF_SHARED set. gdb/testsuite/ 2014-06-16 Pedro Alves <palves@redhat.com> * gdb.base/break-main-file-remove-fail.c: New file. * gdb.base/break-main-file-remove-fail.exp: New file. * gdb.base/break-unload-file.exp: Use build_executable instead of prepare_for_testing. (test_break): New parameter "initial_load". Handle it. (top level): Add initial_load cmdline/file axis.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 8f702e2..2240f08 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2665,8 +2665,8 @@ insert_bp_location (struct bp_location *bl,
if ((bp_err == GENERIC_ERROR || bp_err == MEMORY_ERROR)
&& bl->loc_type == bp_loc_software_breakpoint
&& (solib_name_from_address (bl->pspace, bl->address)
- || userloaded_objfile_contains_address_p (bl->pspace,
- bl->address)))
+ || shared_objfile_contains_address_p (bl->pspace,
+ bl->address)))
{
/* See also: disable_breakpoints_in_shlibs. */
bl->shlib_disabled = 1;
@@ -3805,7 +3805,7 @@ remove_breakpoint_1 (struct bp_location *bl, insertion_state_t is)
whether another dynamic object might have loaded over the
breakpoint's address -- the user might well let us know
about it next with add-symbol-file (the whole point of
- OBJF_USERLOADED is letting the user manually maintain a
+ add-symbol-file is letting the user manually maintain a
list of dynamically loaded objects). If we have the
breakpoint's shadow memory, that is, this is a software
breakpoint managed by GDB, check whether the breakpoint
@@ -3878,8 +3878,8 @@ remove_breakpoint_1 (struct bp_location *bl, insertion_state_t is)
&& (bl->loc_type == bp_loc_software_breakpoint
&& (bl->shlib_disabled
|| solib_name_from_address (bl->pspace, bl->address)
- || userloaded_objfile_contains_address_p (bl->pspace,
- bl->address))))
+ || shared_objfile_contains_address_p (bl->pspace,
+ bl->address))))
val = 0;
if (val)
@@ -7729,18 +7729,19 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile)
if (objfile == NULL)
return;
- /* OBJF_USERLOADED are dynamic modules manually managed by the user
- with add-symbol-file/remove-symbol-file. Similarly to how
- breakpoints in shared libraries are handled in response to
- "nosharedlibrary", mark breakpoints in OBJF_USERLOADED modules
+ /* OBJF_SHARED|OBJF_USERLOADED objfiles are dynamic modules manually
+ managed by the user with add-symbol-file/remove-symbol-file.
+ Similarly to how breakpoints in shared libraries are handled in
+ response to "nosharedlibrary", mark breakpoints in such modules
shlib_disabled so they end up uninserted on the next global
location list update. Shared libraries not loaded by the user
aren't handled here -- they're already handled in
disable_breakpoints_in_unloaded_shlib, called by solib.c's
solib_unloaded observer. We skip objfiles that are not
- OBJF_USERLOADED (nor OBJF_SHARED) as those aren't considered
- dynamic objects (e.g. the main objfile). */
- if ((objfile->flags & OBJF_USERLOADED) == 0)
+ OBJF_SHARED as those aren't considered dynamic objects (e.g. the
+ main objfile). */
+ if ((objfile->flags & OBJF_SHARED) == 0
+ || (objfile->flags & OBJF_USERLOADED) == 0)
return;
ALL_BREAKPOINTS (b)