]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
gdb/testsuite: remove use of then keyword from gdb.arch/*.exp
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-gnu-cfi.exp
index 4ad49028de096a32e25244dd5c65015601700a76..04f80acf44a225c10fb7b8fd464d45428fdb3f03 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+# Copyright 2007-2022 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
 
 # Unwinding of DW_CFA_GNU_negative_offset_extended test program.
 
-if $tracelevel {
-    strace $tracelevel
-}
-
 # Test i386 unwinder.
 
 
-if {(![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]) || ![is_ilp32_target] } then {
+if {![is_x86_like_target]} {
     verbose "Skipping i386 unwinder tests."
     return
 }
@@ -35,17 +31,13 @@ if {(![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]) || ![is_ilp32_target] }
 set testfile "i386-gnu-cfi"
 set srcfilec ${testfile}.c
 set srcfileasm ${testfile}-asm.S
-set binfile ${objdir}/${subdir}/${testfile}
+set binfile [standard_output_file ${testfile}]
 
 # some targets have leading underscores on assembly symbols.
-# TODO: detect this automatically
-set additional_flags ""
-if { [istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"] } then {
-  set additional_flags "additional_flags=-DSYMBOL_PREFIX=\"_\""
-}
+set additional_flags [gdb_target_symbol_prefix_flags]
 
 if { [gdb_compile "${srcdir}/${subdir}/${srcfilec} ${srcdir}/${subdir}/${srcfileasm}" "${binfile}" executable [list debug $additional_flags]] != "" } {
-    untested i386-gnu-cfi.exp
+    untested "failed to compile"
     return -1
 }
 
@@ -66,26 +58,38 @@ gdb_test_multiple {} "continue to abort()" {
     }
 }
 
-# Backtrace would crash before.
-
-gdb_test "bt" \
-         "main \\(\\) at .*${testfile}.c.*" \
-         "backtrace"
+# Verify that the backtrace works (it would crash before).  Use the backtrace
+# output to find the frame number for function "gate".
+set gate_n ""
+set backtrace_re \
+    [multi_line \
+        "" \
+        "#($decimal) *$hex in gate \[^\r\n\]*" \
+        "#$decimal *$hex in main \\(\\) at .*${testfile}.c.*"]
+gdb_test_multiple "backtrace" "" {
+    -re -wrap $backtrace_re {
+       set gate_n $expect_out(1,string)
+       pass $gdb_test_name
+    }
+}
+if { $gate_n == "" } {
+    return -1
+}
 
 # Check we see the inserted `DW_CFA_GNU_negative_offset_extended' CFI.
 # We see there the original CFI-stored filename `gate.c'.
 
-gdb_test "up 3" \
+gdb_test "frame $gate_n" \
          "gate \\(\[^()\]*\\) at .*gate.c.*" \
          "shift up to the modified frame"
 
-gdb_test_multiple "info frame" "Existence of the CFI inserted register" {
-    -re "Stack level 3, frame at (0x\[0-9a-f\]+):.*Saved registers:.* ecx at (0x\[0-9a-f\]+),.*" {
-       pass "Existence of the CFI inserted register"
-       if { [string compare $expect_out(1,string) $expect_out(2,string)] } then {
-           fail "Value of the CFI inserted register"
+gdb_test_multiple "info frame" "existence of the CFI inserted register" {
+    -re "Stack level $gate_n, frame at (0x\[0-9a-f\]+):.*Saved registers:.* ecx at (0x\[0-9a-f\]+),.*" {
+       pass "existence of the CFI inserted register"
+       if {[string compare $expect_out(1,string) $expect_out(2,string)]} {
+           fail "value of the CFI inserted register"
        } else {
-           pass "Value of the CFI inserted register"
+           pass "value of the CFI inserted register"
        }
     }
 }