74f680b
Fix resolving of variables at locations lists in prelinked libs (BZ 466901).
74f680b
806f8c8
Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked.exp
407ebe9
===================================================================
407ebe9
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
806f8c8
+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked.exp	2009-09-09 20:10:35.000000000 +0200
74f680b
@@ -0,0 +1,102 @@
917bed5
+# Copyright 2008 Free Software Foundation, Inc.
74f680b
+
74f680b
+# This program is free software; you can redistribute it and/or modify
74f680b
+# it under the terms of the GNU General Public License as published by
74f680b
+# the Free Software Foundation; either version 2 of the License, or
74f680b
+# (at your option) any later version.
74f680b
+# 
74f680b
+# This program is distributed in the hope that it will be useful,
74f680b
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
74f680b
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
74f680b
+# GNU General Public License for more details.
74f680b
+# 
74f680b
+# You should have received a copy of the GNU General Public License
74f680b
+# along with this program; if not, write to the Free Software
74f680b
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
74f680b
+
74f680b
+# Minimal DWARF-2 unit test
74f680b
+
74f680b
+# This test can only be run on i386/x86_64 targets which support DWARF-2.
74f680b
+# For now pick a sampling of likely targets.
74f680b
+if {(![istarget *-*-linux*]
74f680b
+     && ![istarget *-*-gnu*]
74f680b
+     && ![istarget *-*-elf*]
74f680b
+     && ![istarget *-*-openbsd*])
74f680b
+    || (![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"])} {
74f680b
+    return 0  
74f680b
+}
74f680b
+
74f680b
+set testfile "dw2-loclist-prelinked"
74f680b
+set srcfuncfile ${testfile}-func.S
dd7d988
+set binsharedfuncfile [standard_output_file ${testfile}.so]
74f680b
+set srcmainfile ${testfile}-main.c
dd7d988
+set binfile [standard_output_file ${testfile}]
74f680b
+
74f680b
+remote_exec build "rm -f ${binfile}"
74f680b
+
74f680b
+# get the value of gcc_compiled
74f680b
+if [get_compiler_info ${binfile}] {
74f680b
+    return -1
74f680b
+}
74f680b
+
74f680b
+# This test can only be run on gcc as we use additional_flags=FIXME
74f680b
+if {$gcc_compiled == 0} {
74f680b
+    return 0
74f680b
+}
74f680b
+
74f680b
+if  { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfuncfile}" "${binsharedfuncfile}" {debug additional_flags=-m32}] != "" } {
74f680b
+    untested "Couldn't compile test library"
74f680b
+    return -1
74f680b
+}
74f680b
+
74f680b
+# The new separate debug info file will be stored in the .debug subdirectory.
74f680b
+
74f680b
+if [gdb_gnu_strip_debug ${binsharedfuncfile}] {
74f680b
+    # check that you have a recent version of strip and objcopy installed
74f680b
+    unsupported "cannot produce separate debug info files"
74f680b
+    return -1
74f680b
+}
74f680b
+
74f680b
+if {[catch "system \"/usr/sbin/prelink -qNR --no-exec-shield ${binsharedfuncfile}\""] != 0} {
74f680b
+    # Maybe we don't have prelink.
74f680b
+    return -1
74f680b
+}
74f680b
+
74f680b
+if  { [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" \
74f680b
+		   "${binfile}" executable [list debug additional_flags=-m32 shlib=${binsharedfuncfile}]] != "" } {
74f680b
+    return -1
74f680b
+}
74f680b
+
74f680b
+gdb_exit
74f680b
+gdb_start
74f680b
+gdb_reinitialize_dir $srcdir/$subdir
74f680b
+gdb_load ${binfile}
74f680b
+
74f680b
+gdb_run_cmd
74f680b
+
74f680b
+gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
74f680b
+
74f680b
+# Incorrect:
74f680b
+# #0  0x00110430 in __kernel_vsyscall ()
74f680b
+# No symbol table info available.
74f680b
+# #1  0x003d44c0 in raise () from /lib/libc.so.6
74f680b
+# No symbol table info available.
74f680b
+# #2  0x003d5e88 in abort () from /lib/libc.so.6
74f680b
+# No symbol table info available.
74f680b
+# #3  0x44f10437 in func () at dw2-loclist-prelinked.c:8
74f680b
+# 	i = Could not find the frame base for "func".
74f680b
+
74f680b
+# Correct:
74f680b
+# #0  0x00110430 in __kernel_vsyscall ()
74f680b
+# No symbol table info available.
74f680b
+# #1  0x003d44c0 in raise () from /lib/libc.so.6
74f680b
+# No symbol table info available.
74f680b
+# #2  0x003d5e88 in abort () from /lib/libc.so.6
74f680b
+# No symbol table info available.
74f680b
+# #3  0x4ae36437 in func () at dw2-loclist-prelinked.c:8
74f680b
+# 	i = 3827288
74f680b
+# #4  0x0804851a in main () at ../../../gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c:24
74f680b
+# No locals.
74f680b
+
74f680b
+# `abort' can get expressed as `*__GI_abort'.
81783d0
+gdb_test "bt full" "in \[^ \]*abort \\(.*in func \\(.*\r\n\[\t \]+i = -?\[0-9\].*in main \\(.*" "Backtrace after abort()"
806f8c8
Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c
407ebe9
===================================================================
407ebe9
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
806f8c8
+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c	2009-09-09 20:10:35.000000000 +0200
74f680b
@@ -0,0 +1,26 @@
74f680b
+/* This testcase is part of GDB, the GNU debugger.
74f680b
+
74f680b
+   Copyright 2008 Free Software Foundation, Inc.
74f680b
+
74f680b
+   This program is free software; you can redistribute it and/or modify
74f680b
+   it under the terms of the GNU General Public License as published by
74f680b
+   the Free Software Foundation; either version 3 of the License, or
74f680b
+   (at your option) any later version.
74f680b
+
74f680b
+   This program is distributed in the hope that it will be useful,
74f680b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
74f680b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
74f680b
+   GNU General Public License for more details.
74f680b
+
74f680b
+   You should have received a copy of the GNU General Public License
74f680b
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
74f680b
+
74f680b
+/* dw2-loclist-prelinked-func.S */
74f680b
+extern void func (void);
74f680b
+
74f680b
+int
74f680b
+main (void)
74f680b
+{
74f680b
+  func ();
74f680b
+  return 0;
74f680b
+}
806f8c8
Index: gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-func.S
407ebe9
===================================================================
407ebe9
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
806f8c8
+++ gdb-6.8.50.20090909/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-func.S	2009-09-09 20:10:35.000000000 +0200
74f680b
@@ -0,0 +1,328 @@
74f680b
+/* This testcase is part of GDB, the GNU debugger.
74f680b
+
74f680b
+   Copyright 2008 Free Software Foundation, Inc.
74f680b
+
74f680b
+   This program is free software; you can redistribute it and/or modify
74f680b
+   it under the terms of the GNU General Public License as published by
74f680b
+   the Free Software Foundation; either version 3 of the License, or
74f680b
+   (at your option) any later version.
74f680b
+
74f680b
+   This program is distributed in the hope that it will be useful,
74f680b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
74f680b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
74f680b
+   GNU General Public License for more details.
74f680b
+
74f680b
+   You should have received a copy of the GNU General Public License
74f680b
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
74f680b
+
74f680b
+/*
74f680b
+#include <stdlib.h>
74f680b
+
74f680b
+void
74f680b
+func (void)
74f680b
+{
74f680b
+  int i;
74f680b
+
74f680b
+  abort ();
74f680b
+}
74f680b
+*/
74f680b
+	.file	"dw2-loclist-prelinked.c"
74f680b
+	.section	.debug_abbrev,"",@progbits
74f680b
+.Ldebug_abbrev0:
74f680b
+	.section	.debug_info,"",@progbits
74f680b
+.Ldebug_info0:
74f680b
+	.section	.debug_line,"",@progbits
74f680b
+.Ldebug_line0:
74f680b
+	.text
74f680b
+.Ltext0:
74f680b
+.globl func
74f680b
+	.type	func, @function
74f680b
+func:
74f680b
+.LFB2:
74f680b
+	.file 1 "dw2-loclist-prelinked.c"
74f680b
+	.loc 1 5 0
74f680b
+	pushl	%ebp
74f680b
+.LCFI0:
74f680b
+	movl	%esp, %ebp
74f680b
+.LCFI1:
74f680b
+	subl	$24, %esp
74f680b
+.LCFI2:
74f680b
+	.loc 1 8 0
74f680b
+	call	abort
74f680b
+.LFE2:
74f680b
+	.size	func, .-func
74f680b
+	.section	.debug_frame,"",@progbits
74f680b
+.Lframe0:
74f680b
+	.long	.LECIE0-.LSCIE0
74f680b
+.LSCIE0:
74f680b
+	.long	0xffffffff
74f680b
+	.byte	0x1
74f680b
+	.string	""
74f680b
+	.uleb128 0x1
74f680b
+	.sleb128 -4
74f680b
+	.byte	0x8
74f680b
+	.byte	0xc
74f680b
+	.uleb128 0x4
74f680b
+	.uleb128 0x4
74f680b
+	.byte	0x88
74f680b
+	.uleb128 0x1
74f680b
+	.align 4
74f680b
+.LECIE0:
74f680b
+.LSFDE0:
74f680b
+	.long	.LEFDE0-.LASFDE0
74f680b
+.LASFDE0:
74f680b
+	.long	.Lframe0
74f680b
+	.long	.LFB2
74f680b
+	.long	.LFE2-.LFB2
74f680b
+	.byte	0x4
74f680b
+	.long	.LCFI0-.LFB2
74f680b
+	.byte	0xe
74f680b
+	.uleb128 0x8
74f680b
+	.byte	0x85
74f680b
+	.uleb128 0x2
74f680b
+	.byte	0x4
74f680b
+	.long	.LCFI1-.LCFI0
74f680b
+	.byte	0xd
74f680b
+	.uleb128 0x5
74f680b
+	.align 4
74f680b
+.LEFDE0:
74f680b
+	.text
74f680b
+.Letext0:
74f680b
+	.section	.debug_loc,"",@progbits
74f680b
+.Ldebug_loc0:
74f680b
+.LLST0:
74f680b
+	.long	.LFB2-.Ltext0
74f680b
+	.long	.LCFI0-.Ltext0
74f680b
+	.value	0x2
74f680b
+	.byte	0x74
74f680b
+	.sleb128 4
74f680b
+	.long	.LCFI0-.Ltext0
74f680b
+	.long	.LCFI1-.Ltext0
74f680b
+	.value	0x2
74f680b
+	.byte	0x74
74f680b
+	.sleb128 8
74f680b
+	.long	.LCFI1-.Ltext0
74f680b
+	.long	.LFE2-.Ltext0
74f680b
+	.value	0x2
74f680b
+	.byte	0x75
74f680b
+	.sleb128 8
74f680b
+	.long	0x0
74f680b
+	.long	0x0
74f680b
+	.section	.debug_info
74f680b
+	.long	0x94
74f680b
+	.value	0x2
74f680b
+	.long	.Ldebug_abbrev0
74f680b
+	.byte	0x4
74f680b
+	.uleb128 0x1
74f680b
+	.long	.LASF10
74f680b
+	.byte	0x1
74f680b
+	.long	.LASF11
74f680b
+	.long	.LASF12
74f680b
+	.long	.Ltext0
74f680b
+	.long	.Letext0
74f680b
+	.long	.Ldebug_line0
74f680b
+	.uleb128 0x2
74f680b
+	.byte	0x4
74f680b
+	.byte	0x7
74f680b
+	.long	.LASF0
74f680b
+	.uleb128 0x3
74f680b
+	.byte	0x4
74f680b
+	.byte	0x5
74f680b
+	.string	"int"
74f680b
+	.uleb128 0x2
74f680b
+	.byte	0x4
74f680b
+	.byte	0x5
74f680b
+	.long	.LASF1
74f680b
+	.uleb128 0x2
74f680b
+	.byte	0x1
74f680b
+	.byte	0x8
74f680b
+	.long	.LASF2
74f680b
+	.uleb128 0x2
74f680b
+	.byte	0x2
74f680b
+	.byte	0x7
74f680b
+	.long	.LASF3
74f680b
+	.uleb128 0x2
74f680b
+	.byte	0x4
74f680b
+	.byte	0x7
74f680b
+	.long	.LASF4
74f680b
+	.uleb128 0x2
74f680b
+	.byte	0x1
74f680b
+	.byte	0x6
74f680b
+	.long	.LASF5
74f680b
+	.uleb128 0x2
74f680b
+	.byte	0x2
74f680b
+	.byte	0x5
74f680b
+	.long	.LASF6
74f680b
+	.uleb128 0x2
74f680b
+	.byte	0x8
74f680b
+	.byte	0x5
74f680b
+	.long	.LASF7
74f680b
+	.uleb128 0x2
74f680b
+	.byte	0x8
74f680b
+	.byte	0x7
74f680b
+	.long	.LASF8
74f680b
+	.uleb128 0x4
74f680b
+	.byte	0x4
74f680b
+	.byte	0x7
74f680b
+	.uleb128 0x2
74f680b
+	.byte	0x1
74f680b
+	.byte	0x6
74f680b
+	.long	.LASF9
74f680b
+	.uleb128 0x5
74f680b
+	.byte	0x1
74f680b
+	.long	.LASF13
74f680b
+	.byte	0x1
74f680b
+	.byte	0x5
74f680b
+	.byte	0x1
74f680b
+	.long	.LFB2
74f680b
+	.long	.LFE2
74f680b
+	.long	.LLST0
74f680b
+	.uleb128 0x6
74f680b
+	.string	"i"
74f680b
+	.byte	0x1
74f680b
+	.byte	0x6
74f680b
+	.long	0x2c
74f680b
+	.byte	0x2
74f680b
+	.byte	0x91
74f680b
+	.sleb128 -12
74f680b
+	.byte	0x0
74f680b
+	.byte	0x0
74f680b
+	.section	.debug_abbrev
74f680b
+	.uleb128 0x1
74f680b
+	.uleb128 0x11
74f680b
+	.byte	0x1
74f680b
+	.uleb128 0x25
74f680b
+	.uleb128 0xe
74f680b
+	.uleb128 0x13
74f680b
+	.uleb128 0xb
74f680b
+	.uleb128 0x3
74f680b
+	.uleb128 0xe
74f680b
+	.uleb128 0x1b
74f680b
+	.uleb128 0xe
74f680b
+	.uleb128 0x11
74f680b
+	.uleb128 0x1
74f680b
+	.uleb128 0x12
74f680b
+	.uleb128 0x1
74f680b
+	.uleb128 0x10
74f680b
+	.uleb128 0x6
74f680b
+	.byte	0x0
74f680b
+	.byte	0x0
74f680b
+	.uleb128 0x2
74f680b
+	.uleb128 0x24
74f680b
+	.byte	0x0
74f680b
+	.uleb128 0xb
74f680b
+	.uleb128 0xb
74f680b
+	.uleb128 0x3e
74f680b
+	.uleb128 0xb
74f680b
+	.uleb128 0x3
74f680b
+	.uleb128 0xe
74f680b
+	.byte	0x0
74f680b
+	.byte	0x0
74f680b
+	.uleb128 0x3
74f680b
+	.uleb128 0x24
74f680b
+	.byte	0x0
74f680b
+	.uleb128 0xb
74f680b
+	.uleb128 0xb
74f680b
+	.uleb128 0x3e
74f680b
+	.uleb128 0xb
74f680b
+	.uleb128 0x3
74f680b
+	.uleb128 0x8
74f680b
+	.byte	0x0
74f680b
+	.byte	0x0
74f680b
+	.uleb128 0x4
74f680b
+	.uleb128 0x24
74f680b
+	.byte	0x0
74f680b
+	.uleb128 0xb
74f680b
+	.uleb128 0xb
74f680b
+	.uleb128 0x3e
74f680b
+	.uleb128 0xb
74f680b
+	.byte	0x0
74f680b
+	.byte	0x0
74f680b
+	.uleb128 0x5
74f680b
+	.uleb128 0x2e
74f680b
+	.byte	0x1
74f680b
+	.uleb128 0x3f
74f680b
+	.uleb128 0xc
74f680b
+	.uleb128 0x3
74f680b
+	.uleb128 0xe
74f680b
+	.uleb128 0x3a
74f680b
+	.uleb128 0xb
74f680b
+	.uleb128 0x3b
74f680b
+	.uleb128 0xb
74f680b
+	.uleb128 0x27
74f680b
+	.uleb128 0xc
74f680b
+	.uleb128 0x11
74f680b
+	.uleb128 0x1
74f680b
+	.uleb128 0x12
74f680b
+	.uleb128 0x1
74f680b
+	.uleb128 0x40
74f680b
+	.uleb128 0x6
74f680b
+	.byte	0x0
74f680b
+	.byte	0x0
74f680b
+	.uleb128 0x6
74f680b
+	.uleb128 0x34
74f680b
+	.byte	0x0
74f680b
+	.uleb128 0x3
74f680b
+	.uleb128 0x8
74f680b
+	.uleb128 0x3a
74f680b
+	.uleb128 0xb
74f680b
+	.uleb128 0x3b
74f680b
+	.uleb128 0xb
74f680b
+	.uleb128 0x49
74f680b
+	.uleb128 0x13
74f680b
+	.uleb128 0x2
74f680b
+	.uleb128 0xa
74f680b
+	.byte	0x0
74f680b
+	.byte	0x0
74f680b
+	.byte	0x0
74f680b
+	.section	.debug_pubnames,"",@progbits
74f680b
+	.long	0x17
74f680b
+	.value	0x2
74f680b
+	.long	.Ldebug_info0
74f680b
+	.long	0x98
74f680b
+	.long	0x75
74f680b
+	.string	"func"
74f680b
+	.long	0x0
74f680b
+	.section	.debug_aranges,"",@progbits
74f680b
+	.long	0x1c
74f680b
+	.value	0x2
74f680b
+	.long	.Ldebug_info0
74f680b
+	.byte	0x4
74f680b
+	.byte	0x0
74f680b
+	.value	0x0
74f680b
+	.value	0x0
74f680b
+	.long	.Ltext0
74f680b
+	.long	.Letext0-.Ltext0
74f680b
+	.long	0x0
74f680b
+	.long	0x0
74f680b
+	.section	.debug_str,"MS",@progbits,1
74f680b
+.LASF7:
74f680b
+	.string	"long long int"
74f680b
+.LASF0:
74f680b
+	.string	"unsigned int"
74f680b
+.LASF11:
74f680b
+	.string	"dw2-loclist-prelinked.c"
74f680b
+.LASF12:
74f680b
+	.string	"gdb-6.8/gdb/testsuite/gdb.dwarf2"
74f680b
+.LASF4:
74f680b
+	.string	"long unsigned int"
74f680b
+.LASF8:
74f680b
+	.string	"long long unsigned int"
74f680b
+.LASF2:
74f680b
+	.string	"unsigned char"
74f680b
+.LASF9:
74f680b
+	.string	"char"
74f680b
+.LASF1:
74f680b
+	.string	"long int"
74f680b
+.LASF3:
74f680b
+	.string	"short unsigned int"
74f680b
+.LASF5:
74f680b
+	.string	"signed char"
74f680b
+.LASF10:
74f680b
+	.string	"GNU C 4.3.2 20081007 (Red Hat 4.3.2-6)"
74f680b
+.LASF13:
74f680b
+	.string	"func"
74f680b
+.LASF6:
74f680b
+	.string	"short int"
74f680b
+	.ident	"GCC: (GNU) 4.3.2 20081007 (Red Hat 4.3.2-6)"
74f680b
+	.section	.note.GNU-stack,"",@progbits