]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Fix some test-cases for check-read1 (gdb_test_lines)
authorTom de Vries <tdevries@suse.de>
Fri, 25 Oct 2024 04:14:03 +0000 (06:14 +0200)
committerTom de Vries <tdevries@suse.de>
Fri, 25 Oct 2024 04:14:03 +0000 (06:14 +0200)
I ran the testsuite in an environment simulating a stressed system in
combination with check-read1.  This exposes a few more FAILs.

Fix some by using gdb_test_lines, as well as related gdb_get_lines.

Tested on x86_64-linux.

gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp
gdb/testsuite/gdb.btrace/exception.exp
gdb/testsuite/gdb.cp/overload.exp
gdb/testsuite/gdb.python/py-framefilter.exp
gdb/testsuite/gdb.reverse/sigall-precsave.exp
gdb/testsuite/gdb.server/bkpt-other-inferior.exp
gdb/testsuite/gdb.server/ext-run.exp

index 19e28bb66314e6d259e5d675de9972e722538306..c813fbeb3d23f7d2b4fdac1d135f786ed95ce977 100644 (file)
@@ -80,12 +80,10 @@ gdb_test_multiple "p some_func ()" "" {
 # debug, to format of which isn't fixed.  All we care about is that
 # GDB is still running afterwards.
 #
-# All of the debug output makes this really slow when testing with the
-# special read1 version of expect, hence the timeout factor.
-with_read1_timeout_factor 10 {
-    gdb_test_no_output "set debug frame on"
-    gdb_test "p some_func ()" ".*" \
-       "repeat p some_func () with frame debug on"
-    gdb_test_no_output "set debug frame off"
-}
+gdb_test_no_output "set debug frame on"
+gdb_test_lines "p some_func ()" \
+    "repeat p some_func () with frame debug on" \
+    ".*"
+gdb_test_no_output "set debug frame off"
+
 gdb_test "p 1 + 2 + 3" " = 6"
index 61cc6c904b61b23159ee9546f292f1b7d8bc9266..6ffdd2b5df4d1257faadab8d3d23095d0acd6683 100755 (executable)
@@ -64,17 +64,14 @@ gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \
   ]
 
 # show the branch trace with calls indented
-send_gdb "record function-call-history /c 1\n"
-gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \
-  [multi_line \
-    "1\tmain\\(\\)" \
-    "2\t  test\\(\\)" \
-    "3\t    foo\\(\\)" \
-    "4\t      bar\\(\\)" \
-    "5\t        bad\\(\\)\r" \
-  ] "" \
-  [multi_line \
-    "\[0-9\]*\t  test\\(\\)" \
-    "\[0-9\]*\tmain\\(\\)" \
-  ] "" \
-  ]
+gdb_test_lines "record function-call-history /c 1" \
+    "indented" \
+    [multi_line \
+        "1\tmain\\(\\)" \
+        "2\t  test\\(\\)" \
+        "3\t    foo\\(\\)" \
+        "4\t      bar\\(\\)" \
+        "5\t        bad\\(\\)" \
+        ".*" \
+        "$decimal\t  test\\(\\)" \
+        "$decimal\tmain\\(\\)"]
index ef26ae57a7f75ac7e7f9cff6f9336692b14de45e..da9deefb79051e3f1dd7f26d7b4ab0ac2bab6460 100644 (file)
@@ -89,42 +89,39 @@ set re_synth        "foo & operator=\\(foo const ?&\\);"
 
 gdb_test "print foo_instance1" "\\$\[0-9\]+ = \{ifoo = 111, ccpfoo = 0x0\}"
 
-gdb_test_multiple "ptype foo_instance1" "ptype foo_instance1" {
-    -re "type = $re_class${ws}$XX_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
-       # gcc 2.95.3 -gstabs+, no "const" on "const char *"
-       # TODO: gdb.base/constvar.exp has XFAILed this kind of problem for a
-       # long time, but an XFAIL really needs an external bug report.
-       # -- chastain 2003-12-31
-       # setup_xfail "*-*-*"
-       # fail "ptype foo_instance1"
-       # TODO: this should be a KFAIL.
-       pass "ptype foo_instance1 (shorter match)"
-    }
-    -re "type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
-       # gcc 2.95.3 -gstabs+ if "const char *" ever gets fixed
-       pass "ptype foo_instance1"
-    }
-    -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$XX_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
-       # gcc 3.3.2 -gdwarf-2, "~foo(int)"
-       # TODO: kfail this
-       # kfail "gdb/1113" "ptype foo_instance1"
-       pass "ptype foo_instance1 (shorter match)"
-    }
-    -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
-       # gcc 3.3.2 -gdwarf-2, if the dtor bug gets fixed
-       # gcc HEAD -gdwarf-2 (abi-2)
-       # TODO: just pass this
-       pass "ptype foo_instance1 (shorter match)"
-    }
-    -re "type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
-       # gcc 3.3.2 -gstabs+
-       # TODO: enough with the "shorter match"
-       pass "ptype foo_instance1 (shorter match)"
-    }
-    -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods${ws}$re_synth$nl\}$nl$gdb_prompt $" {
-       # gcc HEAD -gstabs+ (abi-2)
-       pass "ptype foo_instance1 (shorter match)"
-    }
+set lines [gdb_get_lines "ptype foo_instance1"]
+set test "ptype foo_instance1 output"
+if { [regexp "^type = $re_class${ws}$XX_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}\r\n$" $lines] } {
+    # gcc 2.95.3 -gstabs+, no "const" on "const char *"
+    # TODO: gdb.base/constvar.exp has XFAILed this kind of problem for a
+    # long time, but an XFAIL really needs an external bug report.
+    # -- chastain 2003-12-31
+    # setup_xfail "*-*-*"
+    # fail "ptype foo_instance1"
+    # TODO: this should be a KFAIL.
+    pass "$test (shorter match)"
+} elseif { [regexp "^type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}\r\n$" $lines] } {
+    # gcc 2.95.3 -gstabs+ if "const char *" ever gets fixed
+    pass "$test"
+} elseif { [regexp "^type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$XX_dtor${ws}$re_methods$nl\}\r\n$" $lines] } {
+    # gcc 3.3.2 -gdwarf-2, "~foo(int)"
+    # TODO: kfail this
+    # kfail "gdb/1113" "ptype foo_instance1"
+    pass "$test (shorter match)"
+} elseif { [regexp "^type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}\r\n$" $lines] } {
+    # gcc 3.3.2 -gdwarf-2, if the dtor bug gets fixed
+    # gcc HEAD -gdwarf-2 (abi-2)
+    # TODO: just pass this
+    pass "$test (shorter match)"
+} elseif { [regexp "^type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}\r\n$" $lines] } {
+    # gcc 3.3.2 -gstabs+
+    # TODO: enough with the "shorter match"
+    pass "$test (shorter match)"
+} elseif { [regexp "^type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods${ws}$re_synth$nl\}\r\n$" $lines] } {
+    # gcc HEAD -gstabs+ (abi-2)
+    pass "$test (shorter match)"
+} else {
+    fail $test
 }
 
 # Print variables and method calls.
index 374d352c981d3c7fbe36412bbe4db7e06b24b768..3a325bd6e0b5cc279689ba4ac9e9742d62c624db 100644 (file)
@@ -82,11 +82,10 @@ gdb_breakpoint [gdb_get_line_number "Inner test breakpoint"]
 gdb_continue_to_breakpoint "Inner test breakpoint"
 
 # Test multiple local blocks.
-gdb_test "bt full no-filters" \
+gdb_test_lines "bt full no-filters" "" \
     ".*#0.*end_func.*h = 9.*f = 42.*g = 19.*bar = $hex \"Inside block x2\".*d = 15.*e = 14.*foo = $hex \"Inside block\".*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*"
-gdb_test "bt full" \
-    ".*#0.*cnuf_dne.*h = 9.*f = 42.*g = 19.*bar = $hex \"Inside block x2\".*d = 15.*e = 14.*foo = $hex \"Inside block\".*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*" \
-    "bt full with filters"
+gdb_test_lines "bt full" "bt full with filters" \
+    ".*#0.*cnuf_dne.*h = 9.*f = 42.*g = 19.*bar = $hex \"Inside block x2\".*d = 15.*e = 14.*foo = $hex \"Inside block\".*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*"
 
 # Test pagination can be aborted even for frame filters.
 gdb_test_no_output "set height 5" "pagination quit - set height limited"
@@ -161,15 +160,12 @@ gdb_test "bt -2" \
 gdb_test "bt 3" \
     ".*#0.*end_func.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\)\[^#\]*More stack frames follow.*" \
     "bt 3 with frame-filter Reverse disabled"
-gdb_test "bt no-filter full" \
-    ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*" \
-    "bt no-filters full with Reverse disabled"
-gdb_test "bt full" \
-    ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*#22.*in func1 \\(\\).*#23.*in func2 \\(f=3\\).*elided = $hex \"Elided frame\".*fb = \{nothing = $hex \"Elided Foo Bar\", f = 84, s = 38\}.*bf = $hex.*" \
-    "bt full with Reverse disabled"
-gdb_test "bt full hide" \
-    ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*#22.*in func1 \\(\\)\[^#\]*#24.*in func3 \\(i=3\\).*" \
-    "bt full hide with Reverse disabled"
+gdb_test_lines "bt no-filter full" "bt no-filters full with Reverse disabled" \
+    ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*"
+gdb_test_lines "bt full" "bt full with Reverse disabled" \
+    ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*#22.*in func1 \\(\\).*#23.*in func2 \\(f=3\\).*elided = $hex \"Elided frame\".*fb = \{nothing = $hex \"Elided Foo Bar\", f = 84, s = 38\}.*bf = $hex.*"
+gdb_test_lines "bt full hide" "bt full hide with Reverse disabled" \
+    ".*#0.*end_func.*str = $hex \"The End\".*st2 = $hex \"Is Near\".*b = 12.*c = 5.*#1.*in funca \\(\\).*#2.*in funcb \\(j=10\\).*bar = \{a = 42, b = 84\}.*#22.*in func1 \\(\\)\[^#\]*#24.*in func3 \\(i=3\\).*"
 
 # Re-enable Reverse
 gdb_test_no_output "enable frame-filter global Reverse" \
index aab4551c87453a3e8a27d2ac8a7b504ecaaaac1f..902772a4ef143a490a9c9380ae5bd88f22ea05c5 100644 (file)
@@ -155,7 +155,7 @@ gdb_test "break $breakloc" \
     "breakpoint at end of main"
 
 # Signal handlers must be disabled
-gdb_test "handle all nostop noprint"
+gdb_test_lines "handle all nostop noprint" "" ""
 
 # The list of signals that the program generates, in the order they
 # are generated.
@@ -276,7 +276,7 @@ gdb_test "record restore $precsave" \
     "reload precord save file"
 
 # Signal handlers must be re-enabled
-gdb_test "handle all stop print"
+gdb_test_lines "handle all stop print" "" ""
 
 # Make the first signal SIGABRT because it is always supported.
 set sig_supported 1
index 78d1ae029cbd92784295437172c890a2eb1d6ee2..46c07d1926abbb934fb0ea872db91311d0fe6990 100644 (file)
@@ -77,19 +77,23 @@ foreach inf_sel {1 2} {
 
        gdb_test_no_output "set debug remote 1"
 
-       gdb_test_multiple "break -q main" "set breakpoint" {
-           -re "Sending packet: \\\$qXfer:auxv:read.*$gdb_prompt $" {
-               # Symbol lookup may access the target to read AUXV in
-               # order to determine the debug base for SVR4 linker
-               # namespaces.
-               xfail "$gdb_test_name"
-           }
-           -re "Sending packet.*$gdb_prompt $" {
-               fail "$gdb_test_name"
-           }
-           -re "^break -q main\r\nBreakpoint .* at .*$gdb_prompt $" {
-               pass "$gdb_test_name"
-           }
+       set lines [gdb_get_lines "break -q main"]
+
+       set test "set breakpoint"
+       set re_xfail \
+           [string_to_regexp {Sending packet: $qXfer:auxv:read}]
+       if { [regexp $re_xfail $lines] } {
+           # Symbol lookup may access the target to read AUXV in
+           # order to determine the debug base for SVR4 linker
+           # namespaces.
+           xfail $test
+       } elseif { [regexp "Sending packet:" $lines] } {
+           fail $test
+       } else {
+           set re \
+               "Breakpoint $decimal at $hex: \[^\r\n\]+"
+           set re "^$re\r\n$"
+           gdb_assert { [regexp $re $lines] } $test
        }
 
        gdb_test_no_output "set debug remote 0"
index 6f7b5bdf44637fa9cdd8dbc99453961ed83d0cd3..296af984703960d5e5016b145d42237afadfe2a8 100644 (file)
@@ -58,8 +58,8 @@ if { [istarget *-*-linux*] } {
     if { $do_xml_test } {
        # This is done in a way to avoid the timeout that can occur from
        # applying .* regexp to large output.
-       gdb_test_sequence "info os processes" "get process list" \
-           { "pid +user +command" "1 +root +\[/a-z\]*(init|systemd|bash)" }
+       gdb_test_lines "info os processes" "get process list" \
+           "^pid +user +command.*\r\n1 +root +\[/a-z\]*(init|systemd|bash)"
     }
 }