Implement pahole-like 'ptype /o' option
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / catch-signal.exp
index cae200f0bcf04ae6b019848705f28a02ad467bc8..618255785bc4a53750073dec54cea3a3a1240437 100644 (file)
@@ -1,4 +1,4 @@
-#   Copyright 2012 Free Software Foundation, Inc.
+# Copyright 2012-2017 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@ if [target_info exists gdb,nosignals] {
 
 standard_testfile
 
-if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
     return -1
 }
 
@@ -71,6 +71,19 @@ proc test_catch_signal {signame} {
        gdb_breakpoint ${srcfile}:[gdb_get_line_number "fourth HUP"]
        gdb_continue_to_breakpoint "fourth HUP"
        delete_breakpoints
+
+       # Verify an internal signal used by gdb is properly caught.
+       gdb_breakpoint ${srcfile}:[gdb_get_line_number "first INT"]
+       gdb_continue_to_breakpoint "first INT"
+       set test "override SIGINT to catch"
+       gdb_test "handle SIGINT nostop print nopass" \
+           "SIGINT.*No.*Yes.*No.*" \
+           "$test" \
+           "SIGINT is used by the debugger.*Are you sure you want to change it.*y or n.*" \
+           y
+       gdb_test "catch signal SIGINT" "Catchpoint .*"
+       gdb_test "continue" "Catchpoint .* SIGINT.*"
+        
     }
 }
 
@@ -104,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'"
@@ -111,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 == ""} {
@@ -119,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
 }
This page took 0.025561 seconds and 4 git commands to generate.