OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [relocate.exp] - Blame information for rev 842

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# Copyright 2002, 2003, 2005, 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
# relocate.exp -- Expect script to test loading symbols from unrelocated
18
#                 object files.
19
 
20
if $tracelevel then {
21
    strace $tracelevel
22
}
23
 
24
set testfile relocate
25
set srcfile ${testfile}.c
26
set binfile ${objdir}/${subdir}/${testfile}.o
27
 
28
remote_exec build "rm -f ${binfile}"
29
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}] != "" } {
30
     untested relocate.exp
31
     return -1
32
}
33
 
34
proc get_var_address { var } {
35
  global gdb_prompt hex
36
 
37
  send_gdb "print &${var}\n"
38
  # Match output like:
39
  # $1 = (int *) 0x0
40
  # $5 = (int (*)()) 0
41
  # $6 = (int (*)()) 0x24 
42
  gdb_expect {
43
    -re "\\\$\[0-9\]+ = \\(.*\\) (0|$hex)( <${var}>)?\[\r\n\]+${gdb_prompt} $"
44
        {
45
          pass "get address of ${var}"
46
          if { $expect_out(1,string) == "0" } {
47
            return "0x0"
48
          } else {
49
            return $expect_out(1,string)
50
          }
51
        }
52
    -re "${gdb_prompt} $"
53
        { fail "get address of ${var} (unknown output)" }
54
    timeout
55
        { fail "get address of ${var} (timeout)" }
56
  }
57
  return ""
58
}
59
 
60
 
61
 
62
gdb_exit
63
gdb_start
64
gdb_reinitialize_dir $srcdir/$subdir
65
 
66
# Load the object file.
67
gdb_test "add-symbol-file ${binfile} 0" \
68
        "Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
69
        "add-symbol-file ${testfile}.o 0" \
70
        "add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = 0x0\[\r\n\]+\\(y or n\\) " \
71
        "y"
72
 
73
# Print the addresses of static variables.
74
set static_foo_addr [get_var_address static_foo]
75
set static_bar_addr [get_var_address static_bar]
76
 
77
# Make sure they have different addresses.
78
if { "${static_foo_addr}" == "${static_bar_addr}" } {
79
  fail "static variables have different addresses"
80
} else {
81
  pass "static variables have different addresses"
82
}
83
 
84
# Print the addresses of global variables.
85
set global_foo_addr [get_var_address global_foo]
86
set global_bar_addr [get_var_address global_bar]
87
 
88
# Make sure they have different addresses.
89
if { "${global_foo_addr}" == "${global_bar_addr}" } {
90
  fail "global variables have different addresses"
91
} else {
92
  pass "global variables have different addresses"
93
}
94
 
95
# Print the addresses of functions.
96
set function_foo_addr [get_var_address function_foo]
97
set function_bar_addr [get_var_address function_bar]
98
 
99
# Make sure they have different addresses.
100
if { "${function_foo_addr}" == "${function_bar_addr}" } {
101
  fail "functions have different addresses"
102
} else {
103
  pass "functions have different addresses"
104
}
105
 
106
# Now use a variable as an offset to add-symbol-file, and check that
107
# the functions' addresses change.
108
 
109
gdb_exit
110
gdb_start
111
gdb_reinitialize_dir $srcdir/$subdir
112
 
113
gdb_test "set \$offset = 0x10000" ""
114
 
115
# Load the object file.
116
gdb_test "add-symbol-file ${binfile} \$offset" \
117
        "Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
118
        "add-symbol-file ${testfile}.o \$offset" \
119
        "add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = 0x10000\[\r\n\]+\\(y or n\\) " \
120
        "y"
121
 
122
# Print the addresses of functions.
123
set new_function_foo_addr [get_var_address function_foo]
124
 
125
# Make sure they have different addresses.
126
if { "${function_foo_addr}" == "${new_function_foo_addr}" } {
127
  fail "function foo has a different address"
128
} else {
129
  pass "function foo has a different address"
130
}
131
 
132
# Now try loading the object as an exec-file; we should be able to print
133
# the values of variables after we do this.
134
 
135
gdb_exit
136
gdb_start
137
gdb_reinitialize_dir $srcdir/$subdir
138
gdb_file_cmd ${binfile}
139
 
140
# Check the values of the variables.
141
gdb_test "print static_foo" "\\\$$decimal = 1"
142
gdb_test "print static_bar" "\\\$$decimal = 2"
143
gdb_test "print global_foo" "\\\$$decimal = 3"
144
gdb_test "print global_bar" "\\\$$decimal = 4"

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.