1 |
227 |
jeremybenn |
# Copyright (C) 1997, 1998, 2007, 2008, 2009, 2010
|
2 |
|
|
# Free Software Foundation, Inc.
|
3 |
|
|
|
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.
|
8 |
|
|
#
|
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.
|
13 |
|
|
#
|
14 |
|
|
# You should have received a copy of the GNU General Public License
|
15 |
|
|
# along with this program. If not, see .
|
16 |
|
|
|
17 |
|
|
# GDB tests for names beginning with '$'
|
18 |
|
|
|
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.
|
24 |
|
|
|
25 |
|
|
# This file was written by Satish Pai
|
26 |
|
|
# 1997-09-24
|
27 |
|
|
|
28 |
|
|
if $tracelevel then {
|
29 |
|
|
strace $tracelevel
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
#
|
33 |
|
|
# test running programs
|
34 |
|
|
#
|
35 |
|
|
set prms_id 0
|
36 |
|
|
set bug_id 0
|
37 |
|
|
|
38 |
|
|
if { [skip_hp_tests] } { continue }
|
39 |
|
|
|
40 |
|
|
set testfile "dollar"
|
41 |
|
|
set srcfile ${testfile}.c
|
42 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
43 |
|
|
|
44 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
45 |
|
|
untested dollar.exp
|
46 |
|
|
return -1
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
#source ${binfile}.ci
|
50 |
|
|
|
51 |
|
|
gdb_exit
|
52 |
|
|
gdb_start
|
53 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
54 |
|
|
gdb_load ${binfile}
|
55 |
|
|
|
56 |
|
|
#
|
57 |
|
|
# set it up at a breakpoint so we can play with the variable values
|
58 |
|
|
#
|
59 |
|
|
|
60 |
|
|
if ![runto_main] then {
|
61 |
|
|
perror "couldn't run to breakpoint"
|
62 |
|
|
continue
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
# Test for millicode routines
|
66 |
|
|
# hppa64 does not support dyncall
|
67 |
|
|
if ![istarget "hppa64*-*-*"] {
|
68 |
|
|
send_gdb "print \$\$dyncall\n"
|
69 |
|
|
gdb_expect {
|
70 |
|
|
-re "\\$\[0-9\]* = \\{\\} $hex <>.*$gdb_prompt $" { pass "print \$\$dyncall" }
|
71 |
|
|
-re "\\$\[0-9\]* = \\{\\} $hex <.*dyncall>.*$gdb_prompt $" { pass "print \$\$dyncall" }
|
72 |
|
|
-re "\\$\[0-9\]* = void" { fail "print \$\$dyncall -- interpreted as convenience var" }
|
73 |
|
|
-re "$gdb_prompt $" { fail "print \$\$dyncall" }
|
74 |
|
|
timeout { fail "(timeout) print \$\$dyncall" }
|
75 |
|
|
}
|
76 |
|
|
send_gdb "print \$\$dyncall_external\n"
|
77 |
|
|
gdb_expect {
|
78 |
|
|
-re "\\$\[0-9\]* = \\{\\} $hex <>.*$gdb_prompt $" { pass "print \$\$dyncall_external" }
|
79 |
|
|
-re "\\$\[0-9\]* = \\{\\} $hex <.*dyncall_external>.*$gdb_prompt $" { pass "print \$\$dyncall_external" }
|
80 |
|
|
-re "\\$\[0-9\]* = void" { fail "print \$\$dyncall_external -- interpreted as convenience var" }
|
81 |
|
|
-re "$gdb_prompt $" { fail "print \$\$dyncall_external" }
|
82 |
|
|
timeout { fail "(timeout) print \$\$dyncall_external" }
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
# Set a breakpoint on a millicode routine
|
86 |
|
|
send_gdb "break \$\$dyncall\n"
|
87 |
|
|
gdb_expect {
|
88 |
|
|
-re "Breakpoint \[0-9\]* at $hex.*$gdb_prompt $" { pass "break \$\$dyncall" }
|
89 |
|
|
-re "Function.*not defined.*$gdb_prompt $" {fail "break \$\$dyncall -- no \$\$dyncall?" }
|
90 |
|
|
-re "Convenience variables used in line specs must have integer values\\..*$gdb_prompt $" {
|
91 |
|
|
fail "break \$\$dyncall -- treated as convenince variable"
|
92 |
|
|
}
|
93 |
|
|
-re "$gdb_prompt $" { fail "print break \$\$dyncall" }
|
94 |
|
|
timeout { fail "(timeout) print break \$\$dyncall" }
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
# Disassemble $$dyncall
|
98 |
|
|
send_gdb "disassemble \$\$dyncall\n"
|
99 |
|
|
gdb_expect {
|
100 |
|
|
-re "Dump of assembler code for function.*$gdb_prompt $" { pass "disas \$\$dyncall" }
|
101 |
|
|
-re "$gdb_prompt $" { fail "disas \$\$dyncall" }
|
102 |
|
|
timeout { fail "(timeout) disas \$\$dyncall" }
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
# Try to set $$dyncall like a convenience var.
|
106 |
|
|
send_gdb "set \$\$dyncall = 77\n"
|
107 |
|
|
gdb_expect {
|
108 |
|
|
-re "Invalid cast.*$gdb_prompt $" { pass "set \$\$dyncall = 77" }
|
109 |
|
|
-re "$gdb_prompt $" { fail "set \$\$dyncall = 77" }
|
110 |
|
|
timeout { fail "(timeout) set \$\$dyncall = 77" }
|
111 |
|
|
}
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
# Try out some other $ name, not millicode
|
115 |
|
|
if [istarget "hppa64*-*-*"] {
|
116 |
|
|
#hppa64 uses __argv instead of $ARGV.
|
117 |
|
|
send_gdb "print \__argv\n"
|
118 |
|
|
gdb_expect {
|
119 |
|
|
-re "\\$\[0-9\]* = \[0-9\]*.*$gdb_prompt $" { pass "print \__argv" }
|
120 |
|
|
-re "\\$\[0-9\]* = void.*$gdb_prompt $" {
|
121 |
|
|
fail "print \__argv (interpreted as convenience var)"
|
122 |
|
|
}
|
123 |
|
|
-re "$gdb_prompt $" { fail "print \__argv" }
|
124 |
|
|
timeout { fail "(timeout) print \__argv" }
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
send_gdb "ptype \__argv\n"
|
128 |
|
|
gdb_expect {
|
129 |
|
|
-re "type = .*$gdb_prompt $" {
|
130 |
|
|
pass "ptype \__argv"
|
131 |
|
|
}
|
132 |
|
|
-re "type = void.*$gdb_prompt $" {
|
133 |
|
|
fail "ptype \__argv (interpreted as convenience var)"
|
134 |
|
|
}
|
135 |
|
|
-re "$gdb_prompt $" { fail "ptype \__argv" }
|
136 |
|
|
timeout { fail "(timeout) ptype \__argv" }
|
137 |
|
|
}
|
138 |
|
|
} else {
|
139 |
|
|
send_gdb "print \$ARGV\n"
|
140 |
|
|
gdb_expect {
|
141 |
|
|
-re "\\$\[0-9\]* = \[0-9\]*.*$gdb_prompt $" { pass "print \$ARGV" }
|
142 |
|
|
-re "\\$\[0-9\]* = void.*$gdb_prompt $" { fail "print \$ARGV (interpreted as convenience var)" }
|
143 |
|
|
-re "$gdb_prompt $" { fail "print \$ARGV" }
|
144 |
|
|
timeout { fail "(timeout) print \$ARGV" }
|
145 |
|
|
}
|
146 |
|
|
send_gdb "ptype \$ARGV\n"
|
147 |
|
|
gdb_expect {
|
148 |
|
|
-re "type = .*$gdb_prompt $" { pass "ptype \$ARGV" }
|
149 |
|
|
-re "type = void.*$gdb_prompt $" { fail "ptype \$ARGV (interpreted as convenience var)" }
|
150 |
|
|
-re "$gdb_prompt $" { fail "ptype \$ARGV" }
|
151 |
|
|
timeout { fail "(timeout) ptype \$ARGV" }
|
152 |
|
|
}
|
153 |
|
|
}
|