1 # Copyright (C) 1997, 1998, 2007, 2008, 2009, 2010, 2011
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # GDB tests for names beginning with '$'
19 # This is aimed at HP-UX systems where a lot of system
20 # routines and names begin with '$' or '$$'. GDB 4.16 was
21 # unable to deal with these names as they clashed with
22 # convenience variables. Wildebeest should accept such
23 # names in preference to convenience variables.
25 # This file was written by Satish Pai <pai@apollo.hp.com>
33 # test running programs
36 if { [skip_hp_tests] } { continue }
39 set srcfile ${testfile}.c
40 set binfile ${objdir}/${subdir}/${testfile}
42 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
51 gdb_reinitialize_dir $srcdir/$subdir
55 # set it up at a breakpoint so we can play with the variable values
58 if ![runto_main] then {
59 perror "couldn't run to breakpoint"
63 # Test for millicode routines
64 # hppa64 does not support dyncall
65 if ![istarget "hppa64*-*-*"] {
66 send_gdb "print \$\$dyncall\n"
68 -re "\\$\[0-9\]* = \\{<text variable, no debug info>\\} $hex <>.*$gdb_prompt $" { pass "print \$\$dyncall" }
69 -re "\\$\[0-9\]* = \\{<text variable, no debug info>\\} $hex <.*dyncall>.*$gdb_prompt $" { pass "print \$\$dyncall" }
70 -re "\\$\[0-9\]* = void" { fail "print \$\$dyncall -- interpreted as convenience var" }
71 -re "$gdb_prompt $" { fail "print \$\$dyncall" }
72 timeout { fail "(timeout) print \$\$dyncall" }
74 send_gdb "print \$\$dyncall_external\n"
76 -re "\\$\[0-9\]* = \\{<text variable, no debug info>\\} $hex <>.*$gdb_prompt $" { pass "print \$\$dyncall_external" }
77 -re "\\$\[0-9\]* = \\{<text variable, no debug info>\\} $hex <.*dyncall_external>.*$gdb_prompt $" { pass "print \$\$dyncall_external" }
78 -re "\\$\[0-9\]* = void" { fail "print \$\$dyncall_external -- interpreted as convenience var" }
79 -re "$gdb_prompt $" { fail "print \$\$dyncall_external" }
80 timeout { fail "(timeout) print \$\$dyncall_external" }
83 # Set a breakpoint on a millicode routine
84 send_gdb "break \$\$dyncall\n"
86 -re "Breakpoint \[0-9\]* at $hex.*$gdb_prompt $" { pass "break \$\$dyncall" }
87 -re "Function.*not defined.*$gdb_prompt $" {fail "break \$\$dyncall -- no \$\$dyncall?" }
88 -re "Convenience variables used in line specs must have integer values\\..*$gdb_prompt $" {
89 fail "break \$\$dyncall -- treated as convenince variable"
91 -re "$gdb_prompt $" { fail "print break \$\$dyncall" }
92 timeout { fail "(timeout) print break \$\$dyncall" }
95 # Disassemble $$dyncall
96 send_gdb "disassemble \$\$dyncall\n"
98 -re "Dump of assembler code for function.*$gdb_prompt $" { pass "disas \$\$dyncall" }
99 -re "$gdb_prompt $" { fail "disas \$\$dyncall" }
100 timeout { fail "(timeout) disas \$\$dyncall" }
103 # Try to set $$dyncall like a convenience var.
104 send_gdb "set \$\$dyncall = 77\n"
106 -re "Invalid cast.*$gdb_prompt $" { pass "set \$\$dyncall = 77" }
107 -re "$gdb_prompt $" { fail "set \$\$dyncall = 77" }
108 timeout { fail "(timeout) set \$\$dyncall = 77" }
112 # Try out some other $ name, not millicode
113 if [istarget "hppa64*-*-*"] {
114 #hppa64 uses __argv instead of $ARGV.
115 send_gdb "print \__argv\n"
117 -re "\\$\[0-9\]* = \[0-9\]*.*$gdb_prompt $" { pass "print \__argv" }
118 -re "\\$\[0-9\]* = void.*$gdb_prompt $" {
119 fail "print \__argv (interpreted as convenience var)"
121 -re "$gdb_prompt $" { fail "print \__argv" }
122 timeout { fail "(timeout) print \__argv" }
125 send_gdb "ptype \__argv\n"
127 -re "type = <data variable, no debug info>.*$gdb_prompt $" {
130 -re "type = void.*$gdb_prompt $" {
131 fail "ptype \__argv (interpreted as convenience var)"
133 -re "$gdb_prompt $" { fail "ptype \__argv" }
134 timeout { fail "(timeout) ptype \__argv" }
137 send_gdb "print \$ARGV\n"
139 -re "\\$\[0-9\]* = \[0-9\]*.*$gdb_prompt $" { pass "print \$ARGV" }
140 -re "\\$\[0-9\]* = void.*$gdb_prompt $" { fail "print \$ARGV (interpreted as convenience var)" }
141 -re "$gdb_prompt $" { fail "print \$ARGV" }
142 timeout { fail "(timeout) print \$ARGV" }
144 send_gdb "ptype \$ARGV\n"
146 -re "type = <data variable, no debug info>.*$gdb_prompt $" { pass "ptype \$ARGV" }
147 -re "type = void.*$gdb_prompt $" { fail "ptype \$ARGV (interpreted as convenience var)" }
148 -re "$gdb_prompt $" { fail "ptype \$ARGV" }
149 timeout { fail "(timeout) ptype \$ARGV" }