e212905a62d72ccc3309b0c6530b9b9e0d4b1ae1
[external/binutils.git] / gdb / testsuite / gdb.hp / gdb.base-hp / dollar.exp
1 #   Copyright (C) 1997-1998, 2007-2012 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
35 if { [skip_hp_tests] } { continue }
36
37 set testfile "dollar"
38 set srcfile ${testfile}.c
39 set binfile ${objdir}/${subdir}/${testfile}
40
41 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
42      untested dollar.exp
43      return -1
44 }
45
46 #source ${binfile}.ci
47
48 gdb_exit
49 gdb_start
50 gdb_reinitialize_dir $srcdir/$subdir
51 gdb_load ${binfile}
52
53 #
54 # set it up at a breakpoint so we can play with the variable values
55 #
56
57 if ![runto_main] then {
58     perror "couldn't run to breakpoint"
59     continue
60 }
61
62 # Test for millicode routines
63 # hppa64 does not support dyncall
64 if ![istarget "hppa64*-*-*"] {
65 send_gdb "print \$\$dyncall\n"   
66 gdb_expect {   
67    -re "\\$\[0-9\]* = \\{<text variable, no debug info>\\} $hex <>.*$gdb_prompt $" { pass "print \$\$dyncall" }
68    -re "\\$\[0-9\]* = \\{<text variable, no debug info>\\} $hex <.*dyncall>.*$gdb_prompt $" { pass "print \$\$dyncall" }
69    -re "\\$\[0-9\]* = void"            { fail "print \$\$dyncall -- interpreted as convenience var" }
70    -re "$gdb_prompt $"                     { fail "print \$\$dyncall" }
71    timeout                             { fail "(timeout) print \$\$dyncall" }
72 }
73 send_gdb "print \$\$dyncall_external\n"   
74 gdb_expect {   
75    -re "\\$\[0-9\]* = \\{<text variable, no debug info>\\} $hex <>.*$gdb_prompt $" { pass "print \$\$dyncall_external" }
76         -re "\\$\[0-9\]* = \\{<text variable, no debug info>\\} $hex <.*dyncall_external>.*$gdb_prompt $" { pass "print \$\$dyncall_external" }
77    -re "\\$\[0-9\]* = void"            { fail "print \$\$dyncall_external -- interpreted as convenience var" }
78    -re "$gdb_prompt $"                     { fail "print \$\$dyncall_external" }
79    timeout                             { fail "(timeout) print \$\$dyncall_external" }
80 }
81
82 # Set a breakpoint on a millicode routine
83 send_gdb "break \$\$dyncall\n"   
84 gdb_expect {   
85    -re "Breakpoint \[0-9\]* at $hex.*$gdb_prompt $" { pass "break \$\$dyncall" }
86    -re "Function.*not defined.*$gdb_prompt $" {fail "break \$\$dyncall -- no \$\$dyncall?" }
87    -re "Convenience variables used in line specs must have integer values\\..*$gdb_prompt $" {
88              fail "break \$\$dyncall -- treated as convenince variable"
89        }          
90    -re "$gdb_prompt $"                     { fail "print break \$\$dyncall" }
91    timeout                             { fail "(timeout) print break \$\$dyncall" }
92 }
93
94 # Disassemble $$dyncall
95 send_gdb "disassemble \$\$dyncall\n"   
96 gdb_expect {   
97    -re "Dump of assembler code for function.*$gdb_prompt $" { pass "disas \$\$dyncall" }
98    -re "$gdb_prompt $"                     { fail "disas \$\$dyncall" }
99    timeout                             { fail "(timeout) disas \$\$dyncall" }
100 }
101
102 # Try to set $$dyncall like a convenience var.
103 send_gdb "set \$\$dyncall = 77\n"   
104 gdb_expect {   
105    -re "Invalid cast.*$gdb_prompt $" { pass "set \$\$dyncall = 77" }
106    -re "$gdb_prompt $"                     { fail "set \$\$dyncall = 77" }
107    timeout                             { fail "(timeout) set \$\$dyncall = 77" }
108 }
109 }
110
111 # Try out some other $ name, not millicode
112 if [istarget "hppa64*-*-*"] {
113     #hppa64 uses __argv instead of $ARGV.
114     send_gdb "print \__argv\n"   
115     gdb_expect {   
116         -re "\\$\[0-9\]* = \[0-9\]*.*$gdb_prompt $" { pass "print \__argv" }
117         -re "\\$\[0-9\]* = void.*$gdb_prompt $" {
118             fail "print \__argv (interpreted as convenience var)"
119         }
120         -re "$gdb_prompt $" { fail "print \__argv" }
121         timeout { fail "(timeout) print \__argv" }
122     }
123
124     send_gdb "ptype \__argv\n"   
125     gdb_expect {   
126         -re "type = <data variable, no debug info>.*$gdb_prompt $" {
127             pass "ptype \__argv"
128         }
129         -re "type = void.*$gdb_prompt $" {
130             fail "ptype \__argv (interpreted as convenience var)"
131         }
132         -re "$gdb_prompt $" { fail "ptype \__argv" }
133         timeout { fail "(timeout) ptype \__argv" }
134     }
135 } else {
136 send_gdb "print \$ARGV\n"   
137 gdb_expect {   
138    -re "\\$\[0-9\]* = \[0-9\]*.*$gdb_prompt $" { pass "print \$ARGV" }
139    -re "\\$\[0-9\]* = void.*$gdb_prompt $" { fail "print \$ARGV (interpreted as convenience var)" }
140    -re "$gdb_prompt $"                     { fail "print \$ARGV" }
141    timeout                             { fail "(timeout) print \$ARGV" }
142 }
143 send_gdb "ptype \$ARGV\n"   
144 gdb_expect {   
145    -re "type = <data variable, no debug info>.*$gdb_prompt $" { pass "ptype \$ARGV" }
146    -re "type = void.*$gdb_prompt $" { fail "ptype \$ARGV (interpreted as convenience var)" }
147    -re "$gdb_prompt $"                     { fail "ptype \$ARGV" }
148    timeout                             { fail "(timeout) ptype \$ARGV" }
149 }
150 }