]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.hp/gdb.base-hp/dollar.exp
Fix for PR gdb/1543.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.hp / gdb.base-hp / dollar.exp
1 # Copyright (C) 1997, 1998, 2007, 2008 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 3 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, see <http://www.gnu.org/licenses/>.
15
16 # GDB tests for names beginning with '$'
17
18 # This is aimed at HP-UX systems where a lot of system
19 # routines and names begin with '$' or '$$'. GDB 4.16 was
20 # unable to deal with these names as they clashed with
21 # convenience variables. Wildebeest should accept such
22 # names in preference to convenience variables.
23
24 # This file was written by Satish Pai <pai@apollo.hp.com>
25 # 1997-09-24
26
27 if $tracelevel then {
28 strace $tracelevel
29 }
30
31 #
32 # test running programs
33 #
34 set prms_id 0
35 set bug_id 0
36
37 if { [skip_hp_tests] } { continue }
38
39 set testfile "dollar"
40 set srcfile ${testfile}.c
41 set binfile ${objdir}/${subdir}/${testfile}
42
43 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
44 untested dollar.exp
45 return -1
46 }
47
48 #source ${binfile}.ci
49
50 gdb_exit
51 gdb_start
52 gdb_reinitialize_dir $srcdir/$subdir
53 gdb_load ${binfile}
54
55 #
56 # set it up at a breakpoint so we can play with the variable values
57 #
58
59 if ![runto_main] then {
60 perror "couldn't run to breakpoint"
61 continue
62 }
63
64 # Test for millicode routines
65 # hppa64 does not support dyncall
66 if ![istarget "hppa64*-*-*"] {
67 send_gdb "print \$\$dyncall\n"
68 gdb_expect {
69 -re "\\$\[0-9\]* = \\{<text variable, no debug info>\\} $hex <>.*$gdb_prompt $" { pass "print \$\$dyncall" }
70 -re "\\$\[0-9\]* = \\{<text variable, no debug info>\\} $hex <.*dyncall>.*$gdb_prompt $" { pass "print \$\$dyncall" }
71 -re "\\$\[0-9\]* = void" { fail "print \$\$dyncall -- interpreted as convenience var" }
72 -re "$gdb_prompt $" { fail "print \$\$dyncall" }
73 timeout { fail "(timeout) print \$\$dyncall" }
74 }
75 send_gdb "print \$\$dyncall_external\n"
76 gdb_expect {
77 -re "\\$\[0-9\]* = \\{<text variable, no debug info>\\} $hex <>.*$gdb_prompt $" { pass "print \$\$dyncall_external" }
78 -re "\\$\[0-9\]* = \\{<text variable, no debug info>\\} $hex <.*dyncall_external>.*$gdb_prompt $" { pass "print \$\$dyncall_external" }
79 -re "\\$\[0-9\]* = void" { fail "print \$\$dyncall_external -- interpreted as convenience var" }
80 -re "$gdb_prompt $" { fail "print \$\$dyncall_external" }
81 timeout { fail "(timeout) print \$\$dyncall_external" }
82 }
83
84 # Set a breakpoint on a millicode routine
85 send_gdb "break \$\$dyncall\n"
86 gdb_expect {
87 -re "Breakpoint \[0-9\]* at $hex.*$gdb_prompt $" { pass "break \$\$dyncall" }
88 -re "Function.*not defined.*$gdb_prompt $" {fail "break \$\$dyncall -- no \$\$dyncall?" }
89 -re "Convenience variables used in line specs must have integer values\\..*$gdb_prompt $" {
90 fail "break \$\$dyncall -- treated as convenince variable"
91 }
92 -re "$gdb_prompt $" { fail "print break \$\$dyncall" }
93 timeout { fail "(timeout) print break \$\$dyncall" }
94 }
95
96 # Disassemble $$dyncall
97 send_gdb "disassemble \$\$dyncall\n"
98 gdb_expect {
99 -re "Dump of assembler code for function.*$gdb_prompt $" { pass "disas \$\$dyncall" }
100 -re "$gdb_prompt $" { fail "disas \$\$dyncall" }
101 timeout { fail "(timeout) disas \$\$dyncall" }
102 }
103
104 # Try to set $$dyncall like a convenience var.
105 send_gdb "set \$\$dyncall = 77\n"
106 gdb_expect {
107 -re "Invalid cast.*$gdb_prompt $" { pass "set \$\$dyncall = 77" }
108 -re "$gdb_prompt $" { fail "set \$\$dyncall = 77" }
109 timeout { fail "(timeout) set \$\$dyncall = 77" }
110 }
111 }
112
113 # Try out some other $ name, not millicode
114 if [istarget "hppa64*-*-*"] {
115 #hppa64 uses __argv instead of $ARGV.
116 send_gdb "print \__argv\n"
117 gdb_expect {
118 -re "\\$\[0-9\]* = \[0-9\]*.*$gdb_prompt $" { pass "print \__argv" }
119 -re "\\$\[0-9\]* = void.*$gdb_prompt $" {
120 fail "print \__argv (interpreted as convenience var)"
121 }
122 -re "$gdb_prompt $" { fail "print \__argv" }
123 timeout { fail "(timeout) print \__argv" }
124 }
125
126 send_gdb "ptype \__argv\n"
127 gdb_expect {
128 -re "type = <data variable, no debug info>.*$gdb_prompt $" {
129 pass "ptype \__argv"
130 }
131 -re "type = void.*$gdb_prompt $" {
132 fail "ptype \__argv (interpreted as convenience var)"
133 }
134 -re "$gdb_prompt $" { fail "ptype \__argv" }
135 timeout { fail "(timeout) ptype \__argv" }
136 }
137 } else {
138 send_gdb "print \$ARGV\n"
139 gdb_expect {
140 -re "\\$\[0-9\]* = \[0-9\]*.*$gdb_prompt $" { pass "print \$ARGV" }
141 -re "\\$\[0-9\]* = void.*$gdb_prompt $" { fail "print \$ARGV (interpreted as convenience var)" }
142 -re "$gdb_prompt $" { fail "print \$ARGV" }
143 timeout { fail "(timeout) print \$ARGV" }
144 }
145 send_gdb "ptype \$ARGV\n"
146 gdb_expect {
147 -re "type = <data variable, no debug info>.*$gdb_prompt $" { pass "ptype \$ARGV" }
148 -re "type = void.*$gdb_prompt $" { fail "ptype \$ARGV (interpreted as convenience var)" }
149 -re "$gdb_prompt $" { fail "ptype \$ARGV" }
150 timeout { fail "(timeout) ptype \$ARGV" }
151 }
152 }