diff mbox

save breakpoints does not save disabled breakpoints correctly

Message ID 20141003203228.GB30562@host2.jankratochvil.net
State New
Headers show

Commit Message

Jan Kratochvil Oct. 3, 2014, 8:32 p.m. UTC
Hi,

Miroslav Franc submitted a fix
	https://bugzilla.redhat.com/show_bug.cgi?id=1146170#c1

so posting it with a testcase.

No regressions on {x86_64,x86_64-m32,i686}-fedora21pre-linux-gnu.


Jan
gdb/
2014-10-03  Miroslav Franc  <mfranc@redhat.com>

	Fix "save breakpoints" for "disable $bpnum" command.
	* breakpoint.c (save_breakpoints): Add $bpnum for disable.

gdb/testsuite/
2014-10-03  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix "save breakpoints" for "disable $bpnum" command.
	* gdb.base/save-bp.c (main): Add label.
	* gdb.base/save-bp.exp: Add 8th disabled breakpoint.  Match it.

Comments

Yao Qi Oct. 9, 2014, 1:55 p.m. UTC | #1
Jan Kratochvil <jan.kratochvil@redhat.com> writes:

The fix looks right to me.  One comment on the test,

> +set disabled_row_start "\[0-9\]+ +breakpoint +keep +n +0x\[0-9a-f\]+ +in"
>  set dprintf_row_start "\[0-9\]+ +dprintf +keep +y +0x\[0-9a-f\]+ +in"
>  gdb_test "info break" \
> -  " *Num +Type +Disp +Enb +Address +What\r\n$bp_row_start break_me at .*$srcfile:\[0-9\]+\r\n$bp_row_start main at .*$srcfile:$loc_bp2\r\n$bp_row_start main at .*$srcfile:$loc_bp3 +thread 1\r\n\[ \t]+stop only in thread 1\r\n$bp_row_start main at .*$srcfile:$loc_bp4\r\n\[ \t\]+stop only if i == 1( \\((host|target) evals\\))?\r\n$bp_row_start main at .*$srcfile:$loc_bp5\r\n\[ \t\]+silent\r\n$dprintf_row_start main at .*$srcfile:$loc_bp5\r\n\[ \t\]+printf.*"
> +  " *Num +Type +Disp +Enb +Address +What\r\n$bp_row_start break_me at .*$srcfile:\[0-9\]+\r\n$bp_row_start main at .*$srcfile:$loc_bp2\r\n$bp_row_start main at .*$srcfile:$loc_bp3 +thread 1\r\n\[ \t]+stop only in thread 1\r\n$bp_row_start main at .*$srcfile:$loc_bp4\r\n\[ \t\]+stop only if i == 1( \\((host|target) evals\\))?\r\n$bp_row_start main at .*$srcfile:$loc_bp5\r\n\[ \t\]+silent\r\n$dprintf_row_start main at .*$srcfile:$loc_bp5\r\n\[ \t\]+printf\[^\r\n\]+\r\n$disabled_row_start main at .*$srcfile:$loc_bp8"

This line is too long... IWBN to convert gdb_test to gdb_test_sequence,
so that the patterns are written for each line, and will be more clear.
diff mbox

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index e2170b4..0a438d1 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -16131,7 +16131,7 @@  save_breakpoints (char *filename, int from_tty,
       }
 
     if (tp->enable_state == bp_disabled)
-      fprintf_unfiltered (fp, "disable\n");
+      fprintf_unfiltered (fp, "disable $bpnum\n");
 
     /* If this is a multi-location breakpoint, check if the locations
        should be individually disabled.  Watchpoint locations are
diff --git a/gdb/testsuite/gdb.base/save-bp.c b/gdb/testsuite/gdb.base/save-bp.c
index 9a72fe8..f01f031 100644
--- a/gdb/testsuite/gdb.base/save-bp.c
+++ b/gdb/testsuite/gdb.base/save-bp.c
@@ -31,6 +31,6 @@  main (void)
     break_me (); /* Try a condition-specific breakpoint.  */
 
   break_me (); /* Finally, try a breakpoint with commands.  */
-  return 0;
+  return 0; /* Return line. */
 }
 
diff --git a/gdb/testsuite/gdb.base/save-bp.exp b/gdb/testsuite/gdb.base/save-bp.exp
index ba98633..7bc8ab6 100644
--- a/gdb/testsuite/gdb.base/save-bp.exp
+++ b/gdb/testsuite/gdb.base/save-bp.exp
@@ -47,6 +47,10 @@  gdb_test "commands\nsilent\nend" "End with.*" "add breakpoint commands"
 
 gdb_test "dprintf ${srcfile}:${loc_bp5},\"At foo entry\\n\"" "Dprintf .*"
 
+set loc_bp8 [gdb_get_line_number "Return line"]
+gdb_breakpoint "${srcfile}:${loc_bp8}"
+gdb_test_no_output {disable $bpnum}
+
 # Now, save the breakpoints into a file...
 if {[is_remote host]} {
     set bps bps
@@ -71,6 +75,7 @@  gdb_test "source $bps" "" "source bps"
 
 # Now, verify that all breakpoints have been created correctly...
 set bp_row_start "\[0-9\]+ +breakpoint +keep +y +0x\[0-9a-f\]+ +in"
+set disabled_row_start "\[0-9\]+ +breakpoint +keep +n +0x\[0-9a-f\]+ +in"
 set dprintf_row_start "\[0-9\]+ +dprintf +keep +y +0x\[0-9a-f\]+ +in"
 gdb_test "info break" \
-  " *Num +Type +Disp +Enb +Address +What\r\n$bp_row_start break_me at .*$srcfile:\[0-9\]+\r\n$bp_row_start main at .*$srcfile:$loc_bp2\r\n$bp_row_start main at .*$srcfile:$loc_bp3 +thread 1\r\n\[ \t]+stop only in thread 1\r\n$bp_row_start main at .*$srcfile:$loc_bp4\r\n\[ \t\]+stop only if i == 1( \\((host|target) evals\\))?\r\n$bp_row_start main at .*$srcfile:$loc_bp5\r\n\[ \t\]+silent\r\n$dprintf_row_start main at .*$srcfile:$loc_bp5\r\n\[ \t\]+printf.*"
+  " *Num +Type +Disp +Enb +Address +What\r\n$bp_row_start break_me at .*$srcfile:\[0-9\]+\r\n$bp_row_start main at .*$srcfile:$loc_bp2\r\n$bp_row_start main at .*$srcfile:$loc_bp3 +thread 1\r\n\[ \t]+stop only in thread 1\r\n$bp_row_start main at .*$srcfile:$loc_bp4\r\n\[ \t\]+stop only if i == 1( \\((host|target) evals\\))?\r\n$bp_row_start main at .*$srcfile:$loc_bp5\r\n\[ \t\]+silent\r\n$dprintf_row_start main at .*$srcfile:$loc_bp5\r\n\[ \t\]+printf\[^\r\n\]+\r\n$disabled_row_start main at .*$srcfile:$loc_bp8"