]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Handle PAC marker
authorTom de Vries <tdevries@suse.de>
Thu, 4 Jan 2024 12:42:45 +0000 (13:42 +0100)
committerTom de Vries <tdevries@suse.de>
Thu, 4 Jan 2024 12:42:45 +0000 (13:42 +0100)
On aarch64-linux, I run into:
...
FAIL: gdb.base/annota1.exp: backtrace from shlibrary (timeout)
...
due to the PAC marker showing up:
...
^Z^Zframe-address^M
0x000000000041025c [PAC]^M
^Z^Zframe-address-end^M
...

In the docs the marker is documented as follows:
...
When GDB is debugging the AArch64 architecture, and the program is using the
v8.3-A feature Pointer Authentication (PAC), then whenever the link register
$lr is pointing to an PAC function its value will be masked.  When GDB prints
a backtrace, any addresses that required unmasking will be postfixed with the
marker [PAC].  When using the MI, this is printed as part of the addr_flags
field.
...

Update the test-case to allow the PAC marker.

Likewise in a few other test-cases.

While we're at it, rewrite the affected pattern pat_begin in annota1.exp into
a more readable form.  Likewise for the corresponding pat_end.

Tested on aarch64-linux.

Approved-By: Luis Machado <luis.machado@arm.com>
PR testsuite/31202
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31202

gdb/testsuite/gdb.base/annota1.exp
gdb/testsuite/gdb.cp/exception.exp
gdb/testsuite/gdb.dwarf2/entry-value-typedef.exp
gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
gdb/testsuite/gdb.mi/mi-syn-frame.exp
gdb/testsuite/gdb.threads/pthread_cond_wait.exp
gdb/testsuite/gdb.threads/tls.exp

index 90c03d0d38553f3a1d1c193d7e2a0380941b162f..c38c3556e95a6d441fa8e6a46e31efe026fa51dc 100644 (file)
@@ -284,9 +284,52 @@ gdb_test_multiple "continue" "continue to printf" {
 # annotate-frame-address
 # annotate-frame-address-end
 #
-set pat_begin "\r\n\032\032post-prompt\r\n\r\n\032\032frame-begin 0 $hex\r\n.0  \r\n(\032\032frame-address\r\n$hex\r\n\032\032frame-address-end\r\n in \r\n)*\032\032frame-function-name\r\n.*printf(@.*)?\r\n\032\032frame-args\r\n \\(.*frame-end\r\n\r\n\032\032frame-begin 1 $hex\r\n.1  \r\n\032\032frame-address\r\n$hex\r\n\032\032frame-address-end\r\n in \r\n\032\032frame-function-name\r\nmain\r\n\032\032frame-args\r\n \\(\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n"
+set pat_begin \
+    [list \
+        "\r\n\032\032post-prompt\r\n" \
+        "\r\n\032\032frame-begin 0 $hex\r\n" \
+        ".0  \r\n" \
+        "(" \
+        "\032\032frame-address\r\n" \
+        "${hex}( \\\[PAC\\\])?" \
+        "\r\n\032\032frame-address-end\r\n" \
+        " in \r\n" \
+        ")*" \
+        "\032\032frame-function-name\r\n" \
+        ".*printf(@.*)?" \
+        "\r\n\032\032frame-args\r\n" \
+        " \\(.*frame-end\r\n" \
+        "\r\n\032\032frame-begin 1 $hex\r\n" \
+        ".1  " \
+        "\r\n\032\032frame-address\r\n" \
+        "${hex}( \\\[PAC\\\])?" \
+        "\r\n\032\032frame-address-end\r\n" \
+        " in " \
+        "\r\n\032\032frame-function-name\r\n" \
+        "main" \
+        "\r\n\032\032frame-args\r\n" \
+        " \\(\\)" \
+        "\r\n\032\032frame-source-begin\r\n" \
+        " at " \
+        "\r\n\032\032frame-source-file\r\n"]
+
+set pat_begin [join $pat_begin ""]
+
+set pat_end \
+    [list \
+        "\r\n\032\032frame-source-file-end\r\n" \
+        ":" \
+        "\r\n\032\032frame-source-line\r\n" \
+        ".*" \
+        "\r\n\032\032frame-source-end\r\n\r\n" \
+        "\r\n\032\032frame-end\r\n" \
+        "(" \
+        "\r\n\032\032frame-begin .*\r\n" \
+        "\r\n\032\032frame-end\r\n" \
+        ")*" \
+        "$gdb_prompt$"]
 
-set pat_end "\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n.*\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032frame-end\r\n(\r\n\032\032frame-begin .*\r\n\r\n\032\032frame-end\r\n)*$gdb_prompt$"
+set pat_end [join $pat_end ""]
 
 gdb_test_multiple "backtrace" "backtrace from shlibrary" {
     -re "$pat_begin$escapedsrcfile$pat_end" {
index 2c7ef7793eee61e9fa18e0799e8c891ea57126ea..03dd0cb3aeb26a2baf14d8e6e74e94c2df3f2f88 100644 (file)
@@ -111,7 +111,7 @@ gdb_test "continue"  \
 
 set name "backtrace after first throw"
 gdb_test_multiple "backtrace" $name {
-    -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_throw\[\[:>:\]\].*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
+    -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_throw\[\[:>:\]\].*#\[0-9\]+${ws}$hex (\\\[PAC\\\] )?in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
        # Either __cxxabiv1::__cxa_throw or __cxa_throw can be printed
        # depending on debug info presence.
        pass $name
@@ -129,7 +129,7 @@ gdb_test "continue" \
 
 set name "backtrace after first catch"
 gdb_test_multiple "backtrace" $name {
-    -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_begin_catch\[\[:>:\]\].*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
+    -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_begin_catch\[\[:>:\]\].*#\[0-9\]+${ws}$hex (\\\[PAC\\\] )?in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
        pass $name
     }
 }
@@ -148,7 +148,7 @@ gdb_test "continue" \
 
 set name "backtrace after second throw"
 gdb_test_multiple "backtrace" $name {
-    -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_throw\[\[:>:\]\].*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
+    -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_throw\[\[:>:\]\].*#\[0-9\]+${ws}$hex (\\\[PAC\\\] )?in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" {
        pass $name
     }
 }
@@ -164,7 +164,7 @@ gdb_test "continue" \
 
 set name "backtrace after second catch"
 gdb_test_multiple "backtrace" $name {
-    -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_begin_catch\[\[:>:\]\].*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
+    -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_begin_catch\[\[:>:\]\].*#\[0-9\]+${ws}$hex (\\\[PAC\\\] )?in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" {
        pass $name
     }
 }
index b56c9ceab6a3188dc413c4f3d8f0a51296fd3f48..3d25e2a50b90eaaabd4a37ea72fc55b3e0afa3c5 100644 (file)
@@ -42,4 +42,4 @@ gdb_test "continue" "Catchpoint $::decimal \\(exception thrown\\).*"
 
 # Without the corresponding fix, GDB would hit an internal error before
 # printing the frame for main.
-gdb_test "backtrace" " $::hex in func \\(t=t@entry=@$::hex: 1234\\).* $::hex in main .*"
+gdb_test "backtrace" " $::hex (\\\[PAC\\\] )?in func \\(t=t@entry=@$::hex: 1234\\).* $::hex in main .*"
index 595ae929e9ae4109c890752037b68ae4f33a60b6..1f119ec3a878f688f2afa7f95d6c90e31d24c807 100644 (file)
@@ -68,7 +68,7 @@ proc continue_to_next_exception { func line testname } {
     mi_expect_stop "exception-caught" ".*" ".*" ".*" ".*" \
        {} "run until an exception is caught: $testname"
     mi_gdb_test "-stack-list-frames 1 1" \
-       "\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"${func}\",.*,line=\"${line}\".*\}\\\]" \
+       "\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",(addr_flags=\"PAC\",)?func=\"${func}\",.*,line=\"${line}\".*\}\\\]" \
        "check previous frame: $testname"
 }
 
index 40df312a1cc64557a6e688744dac7bac23b42522..dd484cd80fa4b45c4b87a80e677ef1893ecc01e1 100644 (file)
@@ -76,7 +76,7 @@ mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" \
 # in this next output.
 
 mi_gdb_test "407-stack-list-frames" \
-  "407\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\",arch=\"$any\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"handler\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\",arch=\"$any\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"<signal handler called>\"\},.*frame=\{level=\"$decimal\",addr=\"$hex\",func=\"have_a_very_merry_interrupt\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\",arch=\"$any\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\",arch=\"$any\"\}.*\\\]" \
+    "407\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\",arch=\"$any\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"handler\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\",arch=\"$any\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"<signal handler called>\"\},.*frame=\{level=\"$decimal\",addr=\"$hex\",(addr_flags=\"PAC\",)?func=\"have_a_very_merry_interrupt\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\",arch=\"$any\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\",arch=\"$any\"\}.*\\\]" \
   "list stack frames, with signal handler and dummy frame"
 
 
index ff3097cb51941b82ee0d9dee8a45accf5022c1b4..b29be9e419136be49c50b98b914ae92dfe0927d7 100644 (file)
@@ -51,7 +51,7 @@ global decimal
 #
 # This is a "backtrace break" ("btb"):
 #
-set btb "\[^\r\n\]+\[\r\n\]+\#${decimal}\[ \t\]+${hex} in "
+set btb "\[^\r\n\]+\[\r\n\]+\#${decimal}\[ \t\]+${hex} (\\\[PAC\\\] )?in "
 
 # One of the threads is blocked on a call to pthread_cond_wait, and
 # we want to verify that we are able to get a sensible backtrace for
index 89f6fb89bacf46724009ccbd245c164a11aa27a0..91a7f80b438923abbac9a250a146b820249e281a 100644 (file)
@@ -132,7 +132,7 @@ proc check_thread_stack {number spin_threads spin_threads_level} {
     }
     send_gdb "where\n"
     gdb_expect {
-       -re ".*(\[0-9\]+)\[ \t\]+$hex in spin \\(vp=(0x\[0-9a-f\]+).*\r\n$gdb_prompt $" {
+       -re ".*(\[0-9\]+)\[ \t\]+$hex (\\\[PAC\\\] )?in spin \\(vp=(0x\[0-9a-f\]+).*\r\n$gdb_prompt $" {
            if {[info exists tarr($number)]} {
                fail "backtrace of thread number $number in spin"
            } else {