* gdb.arch/i386-gnu-cfi.exp, gdb.arch/i386-gnu-cfi.c,
[external/binutils.git] / gdb / testsuite / gdb.arch / i386-gnu-cfi.exp
1 # Copyright 2007 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@gnu.org
19
20 # This file is part of the gdb testsuite.
21
22 # Unwinding of DW_CFA_GNU_negative_offset_extended test program.
23
24 if $tracelevel {
25     strace $tracelevel
26 }
27
28 # Test i386 unwinder.
29
30 set prms_id 0
31 set bug_id 0
32
33 if ![istarget "i?86-*-*"] then {
34     verbose "Skipping i386 unwinder tests."
35     return
36 }
37
38 set testfile "i386-gnu-cfi"
39 set srcfilec ${testfile}.c
40 set srcfileasm ${testfile}-asm.S
41 set binfile ${objdir}/${subdir}/${testfile}
42
43 # some targets have leading underscores on assembly symbols.
44 # TODO: detect this automatically
45 set additional_flags ""
46 if [istarget "i?86-*-cygwin*"] then {
47   set additional_flags "additional_flags=-DSYMBOL_PREFIX=\"_\""
48 }
49
50 if { [gdb_compile "${srcdir}/${subdir}/${srcfilec} ${srcdir}/${subdir}/${srcfileasm}" "${binfile}" executable [list debug $additional_flags]] != "" } {
51     untested i386-gnu-cfi.exp
52     return -1
53 }
54
55 # Get things started.
56
57 gdb_exit
58 gdb_start
59 gdb_reinitialize_dir $srcdir/$subdir
60 gdb_load ${binfile}
61
62 # We should stop in abort(3).
63
64 gdb_run_cmd
65
66 gdb_test_multiple {} "continue to abort()" {
67     -re ".*Program received signal SIGABRT,.*$gdb_prompt $" {
68         pass "continue to abort()"
69     }
70 }
71
72 # Backtrace would crash before.
73
74 gdb_test "bt" \
75          "main \\(\\) at .*${testfile}.c.*" \
76          "backtrace"
77
78 # Check we see the inserted `DW_CFA_GNU_negative_offset_extended' CFI.
79 # We see there the original CFI-stored filename `gate.c'.
80
81 gdb_test "up 3" \
82          "gate \\(\[^()\]*\\) at .*gate.c.*" \
83          "shift up to the modified frame"
84
85 gdb_test_multiple "info frame" "Existence of the CFI inserted register" {
86     -re "Stack level 3, frame at (0x\[0-9a-f\]+):.*Saved registers:.* ecx at (0x\[0-9a-f\]+),.*" {
87         pass "Existence of the CFI inserted register"
88         if { [string compare $expect_out(1,string) $expect_out(2,string)] } then {
89             fail "Value of the CFI inserted register"
90         } else {
91             pass "Value of the CFI inserted register"
92         }
93     }
94 }