diff options
author | Pedro Alves <palves@redhat.com> | 2014-06-16 15:38:13 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2014-06-16 15:38:13 +0100 |
commit | d03de42190b3b55fb195340dde8e595714a35090 (patch) | |
tree | cb1c4765e29cd4a9c49bf5ee473ce8789657c217 /gdb/testsuite/gdb.base/break-unload-file.exp | |
parent | 99f4262f2c7e3457f45bd9921889456285d8b025 (diff) | |
download | fsf-binutils-gdb-d03de42190b3b55fb195340dde8e595714a35090.zip fsf-binutils-gdb-d03de42190b3b55fb195340dde8e595714a35090.tar.gz fsf-binutils-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/testsuite/gdb.base/break-unload-file.exp')
-rw-r--r-- | gdb/testsuite/gdb.base/break-unload-file.exp | 71 |
1 files changed, 50 insertions, 21 deletions
diff --git a/gdb/testsuite/gdb.base/break-unload-file.exp b/gdb/testsuite/gdb.base/break-unload-file.exp index 342bcf5..20762bb 100644 --- a/gdb/testsuite/gdb.base/break-unload-file.exp +++ b/gdb/testsuite/gdb.base/break-unload-file.exp @@ -18,24 +18,46 @@ standard_testfile -if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { +if {[build_executable "failed to prepare" $testfile $srcfile debug]} { return -1 } -if ![runto_main] then { - fail "Can't run to main" - return 0 -} - -# Run the test proper. ALWAYS_INSERT determines whether -# always-inserted mode is on/off, and BREAK_COMMAND is the break -# command being tested. +# Run the test proper. INITIAL_LOAD determines whether the program is +# initially loaded by the "file" command or by passing it to GDB on +# the command line. ALWAYS_INSERT determines whether always-inserted +# mode is on/off. BREAK_COMMAND is the break command being tested. # -proc test_break { always_inserted break_command } { - global gdb_prompt binfile hex +proc test_break { initial_load always_inserted break_command } { + global srcdir subdir binfile + global gdb_prompt hex + global GDBFLAGS + + append prefix "$initial_load: " + append prefix "always-inserted $always_inserted: " + append prefix "$break_command" + with_test_prefix "$prefix" { + gdb_exit + + set saved_gdbflags $GDBFLAGS + + # See "used to behave differently" further below. + if { $initial_load == "file" } { + gdb_start + gdb_file_cmd $binfile + } else { + global last_loaded_file + + # gdb_file_cmd sets this. This is what gdb_reload + # implementations use as binary. + set last_loaded_file $binfile + + set GDBFLAGS "$GDBFLAGS $binfile" + gdb_start + } - with_test_prefix "always-inserted $always_inserted: $break_command" { - clean_restart $binfile + gdb_reinitialize_dir $srcdir/$subdir + gdb_reload + set GDBFLAGS $saved_gdbflags if ![runto_main] then { fail "Can't run to main" @@ -88,8 +110,12 @@ proc test_break { always_inserted break_command } { } } - gdb_test "info break" "y.*PENDING.*foo" \ - "breakpoint is pending" + # This test used to behave differently depending on whether + # the program was first loaded through "file PROGRAM" or "gdb + # PROGRAM". + set ws "\[ \t\]" + gdb_test "info break" "breakpoint${ws}+keep${ws}+n${ws}+$hex${ws}*" \ + "breakpoint is disabled" # Now delete the breakpoint from GDB's tables, to make sure # GDB doesn't reinsert it, masking the bug (with the bug, on @@ -118,11 +144,14 @@ proc test_break { always_inserted break_command } { } } -# While it doesn't trigger the original bug this is a regression test -# for, test with breakpoint always-inserted off for extra coverage. -foreach always_inserted { "off" "on" } { - test_break $always_inserted "break" - if {![skip_hw_breakpoint_tests]} { - test_break $always_inserted "hbreak" +foreach initial_load { "cmdline" "file" } { + # While it doesn't trigger the original bug this is a regression + # test for, test with breakpoint always-inserted off for extra + # coverage. + foreach always_inserted { "off" "on" } { + test_break $initial_load $always_inserted "break" + if {![skip_hw_breakpoint_tests]} { + test_break $initial_load $always_inserted "hbreak" + } } } |