[patchv2] save breakpoints does not save signal catchpoints correctly

Message ID 20141012194328.GA15430@host2.jankratochvil.net
State New, archived
Headers

Commit Message

Jan Kratochvil Oct. 12, 2014, 7:43 p.m. UTC
  On Fri, 10 Oct 2014 02:59:01 +0200, Yao Qi wrote:
> I didn't mean to compare two lists.  We only have one list here, and we
> can check each element in it, for example,

Done.


Thanks,
Jan
gdb/
2014-10-03  Miroslav Franc  <mfranc@redhat.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix "save breakpoints" for "catch" command.
	* break-catch-sig.c (signal_catchpoint_print_recreate): Add trailing
	newline.

gdb/testsuite/
2014-10-12  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Yao Qi  <yao@codesourcery.com>

	Fix "save breakpoints" for "catch" command.
	* gdb.base/catch-signal.exp: Add gdb_breakpoint "main".
	Remove -nonewline.  Match also the added "main" line.
  

Comments

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

> gdb/
> 2014-10-03  Miroslav Franc  <mfranc@redhat.com>
> 	    Jan Kratochvil  <jan.kratochvil@redhat.com>
>
> 	Fix "save breakpoints" for "catch" command.
> 	* break-catch-sig.c (signal_catchpoint_print_recreate): Add trailing
> 	newline.
>
> gdb/testsuite/
> 2014-10-12  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 	    Yao Qi  <yao@codesourcery.com>
>
> 	Fix "save breakpoints" for "catch" command.
> 	* gdb.base/catch-signal.exp: Add gdb_breakpoint "main".
> 	Remove -nonewline.  Match also the added "main" line.

Looks good to me.
  
Jan Kratochvil Oct. 13, 2014, 11:41 a.m. UTC | #2
On Mon, 13 Oct 2014 11:16:38 +0200, Yao Qi wrote:
> Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> 
> > gdb/
> > 2014-10-03  Miroslav Franc  <mfranc@redhat.com>
> > 	    Jan Kratochvil  <jan.kratochvil@redhat.com>
> >
> > 	Fix "save breakpoints" for "catch" command.
> > 	* break-catch-sig.c (signal_catchpoint_print_recreate): Add trailing
> > 	newline.
> >
> > gdb/testsuite/
> > 2014-10-12  Jan Kratochvil  <jan.kratochvil@redhat.com>
> > 	    Yao Qi  <yao@codesourcery.com>
> >
> > 	Fix "save breakpoints" for "catch" command.
> > 	* gdb.base/catch-signal.exp: Add gdb_breakpoint "main".
> > 	Remove -nonewline.  Match also the added "main" line.
> 
> Looks good to me.

Checked in:
	c780cc2f5062451a568458b6ef9b8aef7cc1dd8a


Thanks,
Jan
  

Patch

diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index c41bf33..579fb78 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -346,6 +346,7 @@  signal_catchpoint_print_recreate (struct breakpoint *b, struct ui_file *fp)
     }
   else if (c->catch_all)
     fprintf_unfiltered (fp, " all");
+  fputc_unfiltered ('\n', fp);
 }
 
 /* Implement the "explains_signal" breakpoint_ops method for signal
diff --git a/gdb/testsuite/gdb.base/catch-signal.exp b/gdb/testsuite/gdb.base/catch-signal.exp
index 22caf40..616b2a8 100644
--- a/gdb/testsuite/gdb.base/catch-signal.exp
+++ b/gdb/testsuite/gdb.base/catch-signal.exp
@@ -117,6 +117,7 @@  foreach {arg desc} {"" "standard signals" \
 	"set catchpoint '$arg' for printing"
     gdb_test "info break" "$decimal.*catchpoint.*signal.*$desc.*" \
 	"info break for '$arg'"
+    gdb_breakpoint "main"
     gdb_test "save breakpoints [standard_output_file bps.$i]" \
 	"Saved to file .*bps.$i.*" \
 	"save breakpoints for '$arg'"
@@ -124,7 +125,8 @@  foreach {arg desc} {"" "standard signals" \
     set filename [remote_upload host [standard_output_file bps.$i] \
 		      [standard_output_file bps-local.$i]]
     set fd [open $filename]
-    set contents [read -nonewline $fd]
+    set file_data [read $fd]
+    set data [split $file_data "\n"]
     close $fd
 
     if {$arg == ""} {
@@ -132,11 +134,17 @@  foreach {arg desc} {"" "standard signals" \
     } else {
 	set pattern "catch signal $arg"
     }
-    if {[string match $pattern $contents]} {
-	pass "results of save breakpoints for '$arg'"
-    } else {
-	fail "results of save breakpoints for '$arg'"
-    }
+    gdb_assert {[expr [llength $data] == 3]} \
+	"Number of lines of save breakpoints for '$arg'"
+    # Check the first line.
+    gdb_assert {[string match $pattern [lindex $data 0]]} \
+	"1st line of save breakpoints for '$arg'"
+    # Check the second line.
+    gdb_assert {[string match "break main" [lindex $data 1]]} \
+        "2nd line of save breakpoints for '$arg'"
+    # Check the trailing newline.
+    gdb_assert {[string match "" [lindex $data 2]]} \
+        "Trailing newline of save breakpoints for '$arg'"
 
     incr i
 }