1 Fix resolving of variables at locations lists in prelinked libs (BZ 466901).
3 Index: gdb-6.8.50.20090909/gdb/dwarf2loc.c
4 ===================================================================
5 --- gdb-6.8.50.20090909.orig/gdb/dwarf2loc.c 2009-09-09 20:08:03.000000000 +0200
6 +++ gdb-6.8.50.20090909/gdb/dwarf2loc.c 2009-09-09 20:10:35.000000000 +0200
7 @@ -56,7 +56,9 @@ find_location_expression (struct dwarf2_
9 gdb_byte *loc_ptr, *buf_end;
11 - struct objfile *objfile = dwarf2_per_cu_objfile (baton->per_cu);
12 + struct objfile *objfile1 = dwarf2_per_cu_objfile (baton->per_cu);
13 + struct objfile *objfile = objfile1->separate_debug_objfile
14 + ? objfile1->separate_debug_objfile : objfile1;
15 struct gdbarch *gdbarch = get_objfile_arch (objfile);
16 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
17 unsigned int addr_size = dwarf2_per_cu_addr_size (baton->per_cu);
18 Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked.exp
19 ===================================================================
20 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
21 +++ gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked.exp 2009-09-09 20:10:35.000000000 +0200
23 +# Copyright 2008 Free Software Foundation, Inc.
25 +# This program is free software; you can redistribute it and/or modify
26 +# it under the terms of the GNU General Public License as published by
27 +# the Free Software Foundation; either version 2 of the License, or
28 +# (at your option) any later version.
30 +# This program is distributed in the hope that it will be useful,
31 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
32 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 +# GNU General Public License for more details.
35 +# You should have received a copy of the GNU General Public License
36 +# along with this program; if not, write to the Free Software
37 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39 +# Minimal DWARF-2 unit test
41 +# This test can only be run on i386/x86_64 targets which support DWARF-2.
42 +# For now pick a sampling of likely targets.
43 +if {(![istarget *-*-linux*]
44 + && ![istarget *-*-gnu*]
45 + && ![istarget *-*-elf*]
46 + && ![istarget *-*-openbsd*])
47 + || (![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"])} {
51 +set testfile "dw2-loclist-prelinked"
52 +set srcfuncfile ${testfile}-func.S
53 +set binsharedfuncfile ${objdir}/${subdir}/${testfile}.so
54 +set srcmainfile ${testfile}-main.c
55 +set binfile ${objdir}/${subdir}/${testfile}
57 +remote_exec build "rm -f ${binfile}"
59 +# get the value of gcc_compiled
60 +if [get_compiler_info ${binfile}] {
64 +# This test can only be run on gcc as we use additional_flags=FIXME
65 +if {$gcc_compiled == 0} {
69 +if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfuncfile}" "${binsharedfuncfile}" {debug additional_flags=-m32}] != "" } {
70 + untested "Couldn't compile test library"
74 +# The new separate debug info file will be stored in the .debug subdirectory.
76 +if [gdb_gnu_strip_debug ${binsharedfuncfile}] {
77 + # check that you have a recent version of strip and objcopy installed
78 + unsupported "cannot produce separate debug info files"
82 +if {[catch "system \"/usr/sbin/prelink -qNR --no-exec-shield ${binsharedfuncfile}\""] != 0} {
83 + # Maybe we don't have prelink.
87 +if { [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" \
88 + "${binfile}" executable [list debug additional_flags=-m32 shlib=${binsharedfuncfile}]] != "" } {
94 +gdb_reinitialize_dir $srcdir/$subdir
99 +gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
102 +# #0 0x00110430 in __kernel_vsyscall ()
103 +# No symbol table info available.
104 +# #1 0x003d44c0 in raise () from /lib/libc.so.6
105 +# No symbol table info available.
106 +# #2 0x003d5e88 in abort () from /lib/libc.so.6
107 +# No symbol table info available.
108 +# #3 0x44f10437 in func () at dw2-loclist-prelinked.c:8
109 +# i = Could not find the frame base for "func".
112 +# #0 0x00110430 in __kernel_vsyscall ()
113 +# No symbol table info available.
114 +# #1 0x003d44c0 in raise () from /lib/libc.so.6
115 +# No symbol table info available.
116 +# #2 0x003d5e88 in abort () from /lib/libc.so.6
117 +# No symbol table info available.
118 +# #3 0x4ae36437 in func () at dw2-loclist-prelinked.c:8
120 +# #4 0x0804851a in main () at ../../../gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c:24
123 +# `abort' can get expressed as `*__GI_abort'.
124 +gdb_test "bt full" "in \[^ \]*abort \\(.*in func \\(.*\r\n\[\t \]+i = -?\[0-9\].*in main \\(.*" "Backtrace after abort()"
125 Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c
126 ===================================================================
127 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
128 +++ gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c 2009-09-09 20:10:35.000000000 +0200
130 +/* This testcase is part of GDB, the GNU debugger.
132 + Copyright 2008 Free Software Foundation, Inc.
134 + This program is free software; you can redistribute it and/or modify
135 + it under the terms of the GNU General Public License as published by
136 + the Free Software Foundation; either version 3 of the License, or
137 + (at your option) any later version.
139 + This program is distributed in the hope that it will be useful,
140 + but WITHOUT ANY WARRANTY; without even the implied warranty of
141 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
142 + GNU General Public License for more details.
144 + You should have received a copy of the GNU General Public License
145 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
147 +/* dw2-loclist-prelinked-func.S */
148 +extern void func (void);
156 Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-func.S
157 ===================================================================
158 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
159 +++ gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-func.S 2009-09-09 20:10:35.000000000 +0200
161 +/* This testcase is part of GDB, the GNU debugger.
163 + Copyright 2008 Free Software Foundation, Inc.
165 + This program is free software; you can redistribute it and/or modify
166 + it under the terms of the GNU General Public License as published by
167 + the Free Software Foundation; either version 3 of the License, or
168 + (at your option) any later version.
170 + This program is distributed in the hope that it will be useful,
171 + but WITHOUT ANY WARRANTY; without even the implied warranty of
172 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
173 + GNU General Public License for more details.
175 + You should have received a copy of the GNU General Public License
176 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
189 + .file "dw2-loclist-prelinked.c"
190 + .section .debug_abbrev,"",@progbits
192 + .section .debug_info,"",@progbits
194 + .section .debug_line,"",@progbits
199 + .type func, @function
202 + .file 1 "dw2-loclist-prelinked.c"
214 + .section .debug_frame,"",@progbits
216 + .long .LECIE0-.LSCIE0
232 + .long .LEFDE0-.LASFDE0
244 + .long .LCFI1-.LCFI0
251 + .section .debug_loc,"",@progbits
254 + .long .LFB2-.Ltext0
255 + .long .LCFI0-.Ltext0
259 + .long .LCFI0-.Ltext0
260 + .long .LCFI1-.Ltext0
264 + .long .LCFI1-.Ltext0
265 + .long .LFE2-.Ltext0
271 + .section .debug_info
274 + .long .Ldebug_abbrev0
283 + .long .Ldebug_line0
350 + .section .debug_abbrev
438 + .section .debug_pubnames,"",@progbits
441 + .long .Ldebug_info0
446 + .section .debug_aranges,"",@progbits
449 + .long .Ldebug_info0
455 + .long .Letext0-.Ltext0
458 + .section .debug_str,"MS",@progbits,1
460 + .string "long long int"
462 + .string "unsigned int"
464 + .string "dw2-loclist-prelinked.c"
466 + .string "gdb-6.8/gdb/testsuite/gdb.dwarf2"
468 + .string "long unsigned int"
470 + .string "long long unsigned int"
472 + .string "unsigned char"
478 + .string "short unsigned int"
480 + .string "signed char"
482 + .string "GNU C 4.3.2 20081007 (Red Hat 4.3.2-6)"
486 + .string "short int"
487 + .ident "GCC: (GNU) 4.3.2 20081007 (Red Hat 4.3.2-6)"
488 + .section .note.GNU-stack,"",@progbits