From Rob Savoye (rob@poseidon.cygnus.com)
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / nodebug.exp
1 # Test that things still (sort of) work when compiled without -g.
2
3 if $tracelevel then {
4 strace $tracelevel
5 }
6
7 set prms_id 0
8 set bug_id 0
9
10 set testfile nodebug
11 set srcfile ${srcdir}/$subdir/${testfile}.c
12 set binfile ${objdir}/${subdir}/${testfile}
13 if { [compile "${srcfile} -o ${binfile}"] != "" } {
14 perror "Couldn't compile ${srcfile}"
15 return -1
16 }
17
18 execute_anywhere "rm -f ${binfile}.ci"
19 if { [compile "-E ${srcdir}/${subdir}/compiler.c > ${binfile}.ci"] != "" } {
20 perror "Couldn't make ${testfile}.ci file"
21 return -1
22 }
23 gdb_reinitialize_dir $srcdir/$subdir
24 gdb_load $binfile
25 source ${binfile}.ci
26
27 if [runto inner] then {
28
29 # Expect to find global/local symbols in each of text/data/bss.
30
31 # The exact format for some of this output is not necessarily
32 # ideal, particularly interpreting "p top" requires a fair bit of
33 # savvy about gdb's workings and the meaning of the "{}"
34 # construct. So the details maybe could be tweaked. But the
35 # basic purpose should be maintained, which is (a) users should be
36 # able to interact with these variables with some care (they have
37 # to know how to interpret them according to their real type,
38 # since gdb doesn't know the type), but (b) users should be able
39 # to detect that gdb does not know the type, rather than just
40 # being told they are ints or functions returning int like old
41 # versions of gdb used to do.
42
43 # On alpha (and other ecoff systems) the native compilers put
44 # out debugging info for non-aggregate return values of functions
45 # even without -g, which should be accepted.
46 # Irix5, even though it is ELF, counts as "ecoff" because it
47 # encapsulates ecoff debugging info in a .mdebug section.
48
49 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix5*" }
50 gdb_test "p top" \
51 "{(<(text variable|function), no debug info>|short \\(\\))} \[0-9a-fx]* <top>"
52 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix5*" }
53 gdb_test "whatis top" \
54 "(<(text variable|function), no debug info>|short \\(\\))"
55 gdb_test "ptype top" "(short|int) \\((|<non-float parameter>|<non-float parameter>, <non-float parameter>)\\)"
56
57 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix5*" }
58 gdb_test "p middle" \
59 "{(<(text variable|function), no debug info>|short \\(\\))} \[0-9a-fx]* <middle>"
60 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix5*" }
61 gdb_test "whatis middle" \
62 "(<(text variable|function), no debug info>|short \\(\\))"
63 gdb_test "ptype middle" "(short|int) \\((|<non-float parameter>|<non-float parameter>, <non-float parameter>)\\)"
64
65 gdb_test "p dataglobal" "= 3"
66 gdb_test "whatis dataglobal" \
67 "<(data variable|variable), no debug info>"
68 gdb_test "ptype dataglobal" "<(data variable|variable), no debug info>"
69
70 # The only symbol xcoff puts out for statics is for the TOC entry.
71 # Possible, but hairy, for gdb to deal. Right now it doesn't, it
72 # doesn't know the variables exist at all.
73 setup_xfail "rs6000*-*-aix*"
74 setup_xfail "powerpc*-*-aix*"
75 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
76 gdb_test "p datalocal" "= 4"
77 setup_xfail "rs6000*-*-aix*"
78 setup_xfail "powerpc*-*-aix*"
79 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
80 gdb_test "whatis datalocal" "<(data variable|variable), no debug info>"
81 setup_xfail "rs6000*-*-aix*"
82 setup_xfail "powerpc*-*-aix*"
83 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
84 gdb_test "ptype datalocal" "<(data variable|variable), no debug info>"
85
86 gdb_test "p bssglobal" "= 0"
87 gdb_test "whatis bssglobal" "<(data variable|variable), no debug info>"
88 gdb_test "ptype bssglobal" "<(data variable|variable), no debug info>"
89
90 setup_xfail "rs6000*-*-aix*"
91 setup_xfail "powerpc*-*-aix*"
92 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
93 gdb_test "p bsslocal" "= 0"
94 setup_xfail "rs6000*-*-aix*"
95 setup_xfail "powerpc*-*-aix*"
96 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
97 gdb_test "whatis bsslocal" "<(data variable|variable), no debug info>"
98 setup_xfail "rs6000*-*-aix*"
99 setup_xfail "powerpc*-*-aix*"
100 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
101 gdb_test "ptype bsslocal" "<(data variable|variable), no debug info>"
102
103 gdb_test "backtrace" "#0.*inner.*#1.*middle.*#2.*top.*#3.*main.*" \
104 "backtrace from inner in nodebug.exp"
105 # Or if that doesn't work, at least hope for the external symbols
106 # Commented out because if we aren't going to xfail the above test
107 # ever, why bother with a weaker test?
108 #gdb_test "backtrace" "#0.*inner.*#1.*#2.*top.*#3.*main.*" \
109 # "backtrace from inner in nodebug.exp for externals"
110
111 # This test is not as obscure as it might look. `p getenv ("TERM")'
112 # is a real-world example, at least on many systems.
113 gdb_test {p/c array_index("abcdef",2)} " = 99 'c'"
114
115 # Now, try that we can give names of file-local symbols which happen
116 # to be unique, and have it still work
117 if [runto middle] then {
118 gdb_test "backtrace" "#0.*middle.*#1.*top.*#2.*main.*" \
119 "backtrace from middle in nodebug.exp"
120 }
121 }
This page took 0.033734 seconds and 5 git commands to generate.