OLD | NEW |
1 # Copyright 2002-2003, 2005, 2007-2012 Free Software Foundation, Inc. | 1 # Copyright 2002-2003, 2005, 2007-2012 Free Software Foundation, Inc. |
2 | 2 |
3 # This program is free software; you can redistribute it and/or modify | 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 | 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 | 5 # the Free Software Foundation; either version 3 of the License, or |
6 # (at your option) any later version. | 6 # (at your option) any later version. |
7 # | 7 # |
8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
12 # | 12 # |
13 # You should have received a copy of the GNU General Public License | 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/>. */ | 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
15 | 15 |
16 # code_elim.exp -- tests that GDB can handle executables where some data/code | 16 # code_elim.exp -- tests that GDB can handle executables where some data/code |
17 # has been eliminated by the linker. | 17 # has been eliminated by the linker. |
18 | 18 |
19 if $tracelevel then { | |
20 strace $tracelevel | |
21 } | |
22 | |
23 set testfile1 code_elim1 | 19 set testfile1 code_elim1 |
24 set testfile2 code_elim2 | 20 set testfile2 code_elim2 |
25 set srcfile1 ${testfile1}.c | 21 set srcfile1 ${testfile1}.c |
26 set srcfile2 ${testfile2}.c | 22 set srcfile2 ${testfile2}.c |
27 set binfile1 ${objdir}/${subdir}/${testfile1} | 23 set binfile1 ${objdir}/${subdir}/${testfile1} |
28 set binfile2 ${objdir}/${subdir}/${testfile2} | 24 set binfile2 ${objdir}/${subdir}/${testfile2} |
29 set opts [list debug] | 25 set opts [list debug] |
30 lappend opts "additional_flags=-ffunction-sections" | 26 lappend opts "additional_flags=-ffunction-sections" |
31 lappend opts "additional_flags=-fdata-sections" | 27 lappend opts "additional_flags=-fdata-sections" |
32 lappend opts "additional_flags=-Wl,-gc-sections" | 28 lappend opts "additional_flags=-Wl,-gc-sections" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 88 } |
93 } | 89 } |
94 } | 90 } |
95 | 91 |
96 # Check that the code and data eliminated in binfile1 are not included | 92 # Check that the code and data eliminated in binfile1 are not included |
97 # into partial symtab... and that non-eliminated symbols are still there. | 93 # into partial symtab... and that non-eliminated symbols are still there. |
98 | 94 |
99 gdb_exit | 95 gdb_exit |
100 gdb_start | 96 gdb_start |
101 | 97 |
102 gdb_test "add-symbol-file ${binfile1} 0x100000" \ | 98 gdb_test "symbol-file ${binfile1}" \ |
103 "Reading symbols from .*${testfile1}\\.\\.\\.done\\.(|\r\nUsing host lib
thread_db library .*libthread_db.so.*\\.)" \ | 99 "Reading symbols from .*${testfile1}\\.\\.\\.done\\.(|\r\nUsing host lib
thread_db library .*libthread_db.so.*\\.)" \ |
104 » "add-symbol-file ${testfile1} 0x100000" \ | 100 » "symbol-file ${testfile1}" |
105 » "add symbol table from file \".*${testfile1}\" at\[ \t\r\n\]+\.text_addr
= 0x100000\[\r\n\]+\\(y or n\\) " \ | |
106 » "y" | |
107 | 101 |
108 test_eliminated_var my_global_symbol | 102 with_test_prefix "single psymtabs" { |
109 test_eliminated_var my_static_symbol | 103 test_eliminated_var my_global_symbol |
110 test_eliminated_var my_global_func | 104 test_eliminated_var my_static_symbol |
111 not_null_var_address main | 105 test_eliminated_var my_global_func |
| 106 not_null_var_address main |
| 107 } |
112 | 108 |
113 # Same thing for symtabs | 109 # Same thing for symtabs |
114 | 110 |
115 gdb_exit | 111 gdb_exit |
116 global GDBFLAGS | 112 global GDBFLAGS |
117 set saved_gdbflags $GDBFLAGS | 113 set saved_gdbflags $GDBFLAGS |
118 set GDBFLAGS "$GDBFLAGS --readnow $binfile1" | 114 set GDBFLAGS "$GDBFLAGS --readnow $binfile1" |
119 gdb_start | 115 gdb_start |
120 set GDBFLAGS $saved_gdbflags | 116 set GDBFLAGS $saved_gdbflags |
121 | 117 |
122 test_eliminated_var my_global_symbol | 118 with_test_prefix "single symtabs" { |
123 test_eliminated_var my_static_symbol | 119 test_eliminated_var my_global_symbol |
124 test_eliminated_var my_global_func | 120 test_eliminated_var my_static_symbol |
125 not_null_var_address main | 121 test_eliminated_var my_global_func |
| 122 not_null_var_address main |
| 123 } |
126 | 124 |
127 # binfile2 contains the symbols that have been eliminated in binfile1. Check | 125 # binfile2 contains the symbols that have been eliminated in binfile1. Check |
128 # the eliminated symbols does not hide these valid ones. | 126 # the eliminated symbols does not hide these valid ones. |
129 | 127 |
130 gdb_exit | 128 gdb_exit |
131 gdb_start | 129 gdb_start |
132 | 130 |
133 gdb_test "add-symbol-file ${binfile1} 0x100000" \ | 131 with_test_prefix "order1" { |
134 » "Reading symbols from .*${testfile1}\\.\\.\\.done\\." \ | 132 gdb_test "add-symbol-file ${binfile1} 0x100000 -s .bss 0x120000" \ |
135 » "add-symbol-file ${testfile1} 0x100000" \ | 133 » "Reading symbols from .*${testfile1}\\.\\.\\.done\\." \ |
136 » "add symbol table from file \".*${testfile1}\" at\[ \t\r\n\]+\.text_addr
= 0x100000\[\r\n\]+\\(y or n\\) " \ | 134 » "add-symbol-file ${testfile1} 0x100000" \ |
137 » "y" | 135 » "add symbol table from file \".*${testfile1}\" at.*\\(y or n\\) " \ |
| 136 » "y" |
138 | 137 |
139 gdb_test "add-symbol-file ${binfile2} 0x200000" \ | 138 gdb_test "add-symbol-file ${binfile2} 0x200000 -s .data 0x210000 -s .bss 0x2
20000" \ |
140 » "Reading symbols from .*${testfile2}\\.\\.\\.done\\." \ | 139 » "Reading symbols from .*${testfile2}\\.\\.\\.done\\." \ |
141 » "add-symbol-file ${testfile2} 0x200000" \ | 140 » "add-symbol-file ${testfile2} 0x200000" \ |
142 » "add symbol table from file \".*${testfile2}\" at\[ \t\r\n\]+\.text_addr
= 0x200000\[\r\n\]+\\(y or n\\) " \ | 141 » "add symbol table from file \".*${testfile2}\" at.*\\(y or n\\) " \ |
143 » "y" | 142 » "y" |
144 | 143 |
145 not_null_var_address my_global_symbol | 144 not_null_var_address my_global_symbol |
146 not_null_var_address my_static_symbol | 145 not_null_var_address my_static_symbol |
147 not_null_var_address my_global_func | 146 not_null_var_address my_global_func |
148 not_null_var_address main | 147 not_null_var_address main |
| 148 } |
149 | 149 |
150 # Same thing, but loading binfile2 before binfile1. | 150 # Same thing, but loading binfile2 before binfile1. |
151 | 151 |
152 gdb_exit | 152 gdb_exit |
153 gdb_start | 153 gdb_start |
154 | 154 |
155 gdb_test "add-symbol-file ${binfile2} 0x200000" \ | 155 with_test_prefix "order2" { |
156 » "Reading symbols from .*${testfile2}\\.\\.\\.done\\." \ | 156 gdb_test "add-symbol-file ${binfile2} 0x200000 -s .data 0x210000 -s .bss 0x2
20000" \ |
157 » "add-symbol-file ${testfile2} 0x200000" \ | 157 » "Reading symbols from .*${testfile2}\\.\\.\\.done\\." \ |
158 » "add symbol table from file \".*${testfile2}\" at\[ \t\r\n\]+\.text_addr
= 0x200000\[\r\n\]+\\(y or n\\) " \ | 158 » "add-symbol-file ${testfile2} 0x200000" \ |
159 » "y" | 159 » "add symbol table from file \".*${testfile2}\" at.*\\(y or n\\) " \ |
| 160 » "y" |
160 | 161 |
161 gdb_test "add-symbol-file ${binfile1} 0x100000" \ | 162 gdb_test "add-symbol-file ${binfile1} 0x100000 -s .bss 0x120000" \ |
162 » "Reading symbols from .*${testfile1}\\.\\.\\.done\\." \ | 163 » "Reading symbols from .*${testfile1}\\.\\.\\.done\\." \ |
163 » "add-symbol-file ${testfile1} 0x100000" \ | 164 » "add-symbol-file ${testfile1} 0x100000" \ |
164 » "add symbol table from file \".*${testfile1}\" at\[ \t\r\n\]+\.text_addr
= 0x100000\[\r\n\]+\\(y or n\\) " \ | 165 » "add symbol table from file \".*${testfile1}\" at.*\\(y or n\\) " \ |
165 » "y" | 166 » "y" |
166 | 167 |
167 not_null_var_address my_global_symbol | 168 not_null_var_address my_global_symbol |
168 not_null_var_address my_static_symbol | 169 not_null_var_address my_static_symbol |
169 not_null_var_address my_global_func | 170 not_null_var_address my_global_func |
170 not_null_var_address main | 171 not_null_var_address main |
171 | 172 } |
172 | |
OLD | NEW |