becomes enabled, or the duplicate is removed, gdb will try to
insert all breakpoints. If we don't set shlib_disabled here,
we'll try to insert those breakpoints and fail. */
- if (((b->type == bp_breakpoint)
- || (b->type == bp_jit_event)
- || (b->type == bp_hardware_breakpoint)
- || (is_tracepoint (b)))
+ if (((b->type == bp_jit_event)
+ || is_breakpoint (b)
+ || is_tracepoint (b))
&& loc->pspace == pspace
&& !loc->shlib_disabled
&& solib_name_from_address (loc->pspace, loc->address)
{
bool bp_modified = false;
- if (b.type != bp_breakpoint
- && b.type != bp_jit_event
- && b.type != bp_hardware_breakpoint
+ if (b.type != bp_jit_event
+ && !is_breakpoint (&b)
&& !is_tracepoint (&b))
continue;
}
}
+# Check that GDB disables dprintf breakpoints within a shared library
+# when the shared library is unloaded.
+proc_with_prefix test_dprintf_after_unload {} {
+ clean_restart $::binfile
+
+ if {![runto_main]} {
+ return
+ }
+
+ gdb_breakpoint $::srcfile:$::bp_line
+ gdb_continue_to_breakpoint "stop before dlclose"
+
+ # Setup a dprintf within the shared library.
+ gdb_test "dprintf foo,\"In foo\""
+ set bp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*" \
+ "get b/p number"]
+
+ # Unload the shared library, GDB should disable our b/p.
+ gdb_test "next" $::stop_after_bp_re
+
+ # Check that our b/p is now showing as disabled.
+ gdb_test "info breakpoints $bp_num" \
+ [multi_line \
+ "^Num\\s+Type\\s+Disp\\s+Enb\\s+Address\\s+What" \
+ "$bp_num\\s+dprintf\\s+keep\\s+y\\s+<PENDING>\\s+foo" \
+ "\\s+printf \"In foo\""]
+}
+
+# Create a dprintf breakpoint in a shared library. Restart the
+# inferior. We should not get an error about re-setting the dprintf
+# breakpoint.
+proc_with_prefix test_dprintf_with_rerun {} {
+ clean_restart $::binfile
+
+ if {![runto_main]} {
+ return
+ }
+
+ gdb_breakpoint $::srcfile:$::bp_line
+ gdb_continue_to_breakpoint "stop before dlclose"
+
+ # Setup a dprintf within the shared library.
+ gdb_test "dprintf foo,\"In foo\""
+ set bp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*" \
+ "get b/p number"]
+
+ # Check that the dprintf b/p is initially not pending.
+ gdb_test "info breakpoints $bp_num" \
+ [multi_line \
+ "^Num\\s+Type\\s+Disp\\s+Enb\\s+Address\\s+What" \
+ "$bp_num\\s+dprintf\\s+keep\\s+y\\s+$::hex\\s+in foo at \[^\r\n\]+" \
+ "\\s+printf \"In foo\""] \
+ "dprintf is non-pending before restart"
+
+ # Restart the inferior.
+ gdb_run_cmd
+
+ # The inferior will stop at the initial 'main' breakpoint. This
+ # is at a location before any of the shlibs have been loaded.
+ set saw_bp_reset_error false
+ set saw_bp_disable_warning false
+ gdb_test_multiple "" "stop before shlib are reloaded" {
+ -re "warning: Temporarily disabling breakpoints for unloaded shared library \"\[^\r\n\]+/$::libname\"\r\n" {
+ set saw_bp_disable_warning true
+ exp_continue
+ }
+
+ -re "Error in re-setting breakpoint $bp_num: \[^\r\n\]+" {
+ set saw_bp_reset_error true
+ exp_continue
+ }
+
+ -re "Breakpoint $::decimal, main \\(\\) at \[^\r\n\]+\r\n$::decimal\\s+\[^\r\n\]+\r\n$::gdb_prompt $" {
+ gdb_assert { !$saw_bp_reset_error && !$saw_bp_disable_warning } $gdb_test_name
+ }
+ }
+
+ # Check that the dprintf b/p is still enabled, but marked pending
+ # before the shlib are loaded.
+ gdb_test "info breakpoints $bp_num" \
+ [multi_line \
+ "^Num\\s+Type\\s+Disp\\s+Enb\\s+Address\\s+What" \
+ "$bp_num\\s+dprintf\\s+keep\\s+y\\s+<PENDING>\\s+foo" \
+ "\\s+printf \"In foo\""] \
+ "dprintf is pending before shlib reload"
+
+ set saw_in_foo_output false
+ gdb_test_multiple "continue" "stop after libraries are reloaded" {
+ -re "^continue\r\n" {
+ exp_continue
+ }
+ -re "^Continuing\\.\r\n" {
+ exp_continue
+ }
+ -re "^In foo\r\n" {
+ set saw_in_foo_output true
+ exp_continue
+ }
+ -re "^Breakpoint $::decimal, main \\(\\) at .* Break here\\. \\*/\r\n$::gdb_prompt $" {
+ gdb_assert { $saw_in_foo_output } $gdb_test_name
+ }
+ }
+
+ # Check that the dprintf b/p is still enabled, but is now, no
+ # longer pending.
+ gdb_test "info breakpoints $bp_num" \
+ [multi_line \
+ "^Num\\s+Type\\s+Disp\\s+Enb\\s+Address\\s+What" \
+ "$bp_num\\s+dprintf\\s+keep\\s+y\\s+$::hex\\s+in foo at \[^\r\n\]+" \
+ "\\s+breakpoint already hit 1 time" \
+ "\\s+printf \"In foo\""] \
+ "dprintf is non-pending after restart"
+}
+
test_bp_modified_events
+test_dprintf_after_unload
+test_dprintf_with_rerun