rpms/gdb/F-13 gdb-bz614604-bt-cfi-without-die.patch, NONE, 1.1 gdb-bz614659-prelink-dynbss.patch, NONE, 1.1 gdb.spec, 1.446, 1.447

Jan Kratochvil jkratoch at fedoraproject.org
Tue Jul 20 17:21:23 UTC 2010


Author: jkratoch

Update of /cvs/pkgs/rpms/gdb/F-13
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv31375

Modified Files:
	gdb.spec 
Added Files:
	gdb-bz614604-bt-cfi-without-die.patch 
	gdb-bz614659-prelink-dynbss.patch 
Log Message:
* Tue Jul 20 2010 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.1-29.fc13
- Fix prelinked executables with sepdebug and copy relocations (BZ 614659).
- [delayed-symfile] Fix a backtrace regression on CFIs without DIE (BZ 614604).


gdb-bz614604-bt-cfi-without-die.patch:
 dwarf2-frame.c                              |    8 +--
 testsuite/gdb.base/cfi-without-die-caller.c |   28 +++++++++++
 testsuite/gdb.base/cfi-without-die-main.c   |   32 +++++++++++++
 testsuite/gdb.base/cfi-without-die.exp      |   68 +++++++++++++++++++++++++++-
 4 files changed, 130 insertions(+), 6 deletions(-)

--- NEW FILE gdb-bz614604-bt-cfi-without-die.patch ---
http://sourceware.org/ml/archer/2010-q3/msg00028.html
Subject: [delayed-symfile] [commit] Fix a regression on CFI without DIE  [Re:

On Wed, 25 Feb 2009 00:14:29 +0100, Jan Kratochvil wrote:
> commit 6a37c2b9962258ecf9299cc34a650e64a06acaa5
> 
> There was a regression on gdb.base/savedregs.exp.
> 
> quick_addrmap/require_partial_symbols should be used even for the unwind debug
> info checking as its load has been also delayed by this branch.
[...]
> --- a/gdb/dwarf2-frame.c
> +++ b/gdb/dwarf2-frame.c
[...]
> @@ -1499,6 +1500,14 @@ dwarf2_frame_find_fde (CORE_ADDR *pc)
>        struct dwarf2_fde *fde;
>        CORE_ADDR offset;
>  
> +      if (objfile->quick_addrmap)
> +	{
> +	  if (!addrmap_find (objfile->quick_addrmap, *pc))
> +	    continue;
> +	}
> +      /* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info?  */
> +      require_partial_symbols (objfile);
> +

but this has caused a different regression (as discussed in the confcall).

QUICK_ADDRMAP is built only from .debug_aranges.  But we can have existing
built .debug_aranges for CUs in OBJFILE but still some CUs do not need to have
DWARF at all while they can feature CFIs (.eh_frame or .debug_frame).
It has been described by Daniel Jacobowitz at:
	Re: [2/4] RFC: check psymtabs_addrmap before reading FDEs
	http://sourceware.org/ml/gdb-patches/2010-07/msg00012.html

Sorry for this regression by me (in that fix of a different regression).

Fixed it the "slow way" as this branch is now obsoleted by .gdb-index.

No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.

Checked-in.


Thanks,
Jan


eb8df8566acc1ed963e3e9b77c13b9c2c3db03fb

Test CFI is parsed even for range (function) not described by any DIE.

https://bugzilla.redhat.com/show_bug.cgi?id=614028

gdb/
	* dwarf2-frame.c (dwarf2_frame_find_fde): Remove the
	OBJFILE->QUICK_ADDRMAP check.  New comment why.

gdb/testsuite/
	* gdb.base/cfi-without-die.exp, gdb.base/cfi-without-die-main.c,
	gdb.base/cfi-without-die-caller.c: New files.
---
 gdb/dwarf2-frame.c                              |    8 +--
 gdb/testsuite/gdb.base/cfi-without-die-caller.c |   28 ++++++++++
 gdb/testsuite/gdb.base/cfi-without-die-main.c   |   32 +++++++++++
 gdb/testsuite/gdb.base/cfi-without-die.exp      |   67 +++++++++++++++++++++++
 4 files changed, 130 insertions(+), 5 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/cfi-without-die-caller.c
 create mode 100644 gdb/testsuite/gdb.base/cfi-without-die-main.c
 create mode 100644 gdb/testsuite/gdb.base/cfi-without-die.exp

diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index 5915249..1dc2754 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -1583,11 +1583,9 @@ dwarf2_frame_find_fde (CORE_ADDR *pc)
       CORE_ADDR offset;
       CORE_ADDR seek_pc;
 
-      if (objfile->quick_addrmap)
-	{
-	  if (!addrmap_find (objfile->quick_addrmap, *pc))
-	    continue;
-	}
+      /* OBJFILE->QUICK_ADDRMAP contains offsets only for DIEs.  It does not
+         contain ranges of CFIs.  */
+
       /* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info?  */
       require_partial_symbols (objfile);
 
diff --git a/gdb/testsuite/gdb.base/cfi-without-die-caller.c b/gdb/testsuite/gdb.base/cfi-without-die-caller.c
new file mode 100644
index 0000000..afdfd53
--- /dev/null
+++ b/gdb/testsuite/gdb.base/cfi-without-die-caller.c
@@ -0,0 +1,28 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+typedef int (*callback_t) (void);
+
+int
+caller (callback_t callback)
+{
+  /* Ensure some frame content to push away the return address.  */
+  volatile const long one = 1;
+
+  /* Modify the return value to prevent any tail-call optimization.  */
+  return (*callback) () - one;
+}
diff --git a/gdb/testsuite/gdb.base/cfi-without-die-main.c b/gdb/testsuite/gdb.base/cfi-without-die-main.c
new file mode 100644
index 0000000..8451c4b
--- /dev/null
+++ b/gdb/testsuite/gdb.base/cfi-without-die-main.c
@@ -0,0 +1,32 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+typedef int (*callback_t) (void);
+
+extern int caller (callback_t callback);
+
+int
+callback (void)
+{
+  return 1;
+}
+
+int
+main (void)
+{
+  return caller (callback);
+}
diff --git a/gdb/testsuite/gdb.base/cfi-without-die.exp b/gdb/testsuite/gdb.base/cfi-without-die.exp
new file mode 100644
index 0000000..db6d248
--- /dev/null
+++ b/gdb/testsuite/gdb.base/cfi-without-die.exp
@@ -0,0 +1,67 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test CFI is parsed even for range (function) not described by any DIE.
+
+set testfile cfi-without-die
+set srcmainfile ${testfile}-main.c
+set srccallerfile ${testfile}-caller.c
+set executable ${testfile}
+set objmainfile ${objdir}/${subdir}/${testfile}-main.o
+set objcallerfile ${objdir}/${subdir}/${testfile}-caller.o
+set binfile ${objdir}/${subdir}/${executable}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \
+      object [list {additional_flags=-fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables}]] != ""
+     || [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != ""
+     || [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } {
+     untested ${testfile}.exp
+     return -1
+}
+
+clean_restart $executable
+
+if ![runto callback] then {
+   fail "verify unwinding: Can't run to callback"
+   return 0
+}
+set test "verify unwinding breaks without CFI"
+gdb_test_multiple "bt" $test {
+    -re " in main .*\r\n$gdb_prompt $" {
+	fail $test
+    }
+    -re "\r\n$gdb_prompt $" {
+	pass $test
+    }
+}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srccallerfile}" ${objcallerfile} \
+      object [list {additional_flags=-fomit-frame-pointer -funwind-tables -fasynchronous-unwind-tables}]] != ""
+     || [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" ${objmainfile} object {debug}] != ""
+     || [gdb_compile "${objmainfile} ${objcallerfile}" ${binfile} executable {}] != "" } {
+     untested ${testfile}.exp
+     return -1
+}
+
+clean_restart $executable
+
+if ![runto callback] then {
+   fail "test CFI without DIEs: Can't run to callback"
+   return 0
+}
+# #0  callback () at ...
+# #1  0x00000000004004e9 in caller ()
+# #2  0x00000000004004cd in main () at ...
+gdb_test "bt" "#0 +callback \[^\r\n\]+\r\n#1 \[^\r\n\]+ in caller \[^\r\n\]+\r\n#2 \[^\r\n\]+ in main \[^\r\n\]+" "verify unwindin works for CFI without DIEs"
-- 
1.7.1.1


gdb-bz614659-prelink-dynbss.patch:
 symfile.c                        |   42 ++++++++++++++++++++++++++++++++++-----
 testsuite/gdb.base/prelink-lib.c |    2 +
 testsuite/gdb.base/prelink.c     |    6 +++++
 testsuite/gdb.base/prelink.exp   |   11 +++++++++-
 4 files changed, 55 insertions(+), 6 deletions(-)

--- NEW FILE gdb-bz614659-prelink-dynbss.patch ---
http://sourceware.org/ml/gdb-patches/2010-07/msg00237.html
Subject: [patch] Fix regression on prelinked executables

Hi,

there is a regression since gdb-7.0 for a combination of:
 * prelinked
 * main executable
 * using separate debug info
 * using copy relocations

It is since a patch for both PIE and (AFAIK) OSX support:
	[commit] syms_from_objfile: Relativize also MAINLINE
	http://sourceware.org/ml/gdb-patches/2010-01/msg00080.html

which started to use problematic addr_info_make_relative even for main
executables.  prelink<->gdb discussion at:
	https://bugzilla.redhat.com/show_bug.cgi?id=614659

Currently in the unfortunately executables GDB has invalid displcement for
symbols in .bss:
	int bssvar, *bssvarp = &bssvar;
	(gdb) p &bssvar
	$1 = (int *) 0x600b54
	(gdb) p bssvarp
	$2 = (int *) 0x600b50

<abstract-higher-point-of-view>
addr_info_make_relative could just simply subtract entry point address and
provide single CORE_ADDR objfile->offset (instead of the current
section_offsets array with offsets specific for each section).  Linux systems
use always single offset for the whole objfile.  AFAIK these per-section
offsets are there for some embedded targets.  Curiously GDB already uses at
many places
	baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
instead of using offset for the appropriate section at that place and nobody
complains.
</abstract-higher-point-of-view>

No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.

Proposing for the gdb-7.2 branch.  I had problems fixing up my crashing X.


Thanks,
Jan


gdb/
2010-07-15  Jan Kratochvil  <jan.kratochvil at redhat.com>

	* symfile.c (addr_section_name): New function.
	(addrs_section_compar): Use it.
	(addr_info_make_relative): Use it.  Move variable sect_name into a more
	inner block.  Make ".dynbss" and ".sdynbss" checks more strict.

gdb/testsuite/
2010-07-15  Jan Kratochvil  <jan.kratochvil at redhat.com>

	* gdb.base/prelink-lib.c (copyreloc): New initialized variable.
	* gdb.base/prelink.c (copyreloc, bssvar, bssvarp): New variables.
	(main): Use copyreloc.
	* gdb.base/prelink.exp (split debug of executable)
	(.dynbss vs. .bss address shift): New tests.

Index: gdb-7.1/gdb/symfile.c
===================================================================
--- gdb-7.1.orig/gdb/symfile.c	2010-07-19 23:11:10.000000000 +0200
+++ gdb-7.1/gdb/symfile.c	2010-07-20 18:34:50.000000000 +0200
@@ -557,6 +557,23 @@ relative_addr_info_to_section_offsets (s
     }
 }
 
+/* Transform section name S for a name comparison.  prelink can split section
+   `.bss' into two sections `.dynbss' and `.bss' (in this order).  Similarly
+   prelink can split `.sbss' into `.sdynbss' and `.sbss'.  Use virtual address
+   of the new `.dynbss' (`.sdynbss') section as the adjacent new `.bss'
+   (`.sbss') section has invalid (increased) virtual address.  */
+
+static const char *
+addr_section_name (const char *s)
+{
+  if (strcmp (s, ".dynbss") == 0)
+    return ".bss";
+  if (strcmp (s, ".sdynbss") == 0)
+    return ".sbss";
+
+  return s;
+}
+
 /* Relativize absolute addresses in ADDRS into offsets based on ABFD.  Fill-in
    also SECTINDEXes specific to ABFD there.  This function can be used to
    rebase ADDRS to start referencing different BFD than before.  */
@@ -607,8 +624,17 @@ addr_info_make_relative (struct section_
       if (sect && strcmp (sect_name, bfd_get_section_name (abfd, sect)) != 0)
 	sect = NULL;
 
-      if (sect == NULL)
-	sect = bfd_get_section_by_name (abfd, sect_name);
+      /* Prevent the search by name if `.bss' has the address already set from
+	 `.dynbss'.  */
+      if (sect == NULL
+          && !(0
+	       || (strcmp (sect_name, ".bss") == 0
+		   && i > 0
+		   && strcmp (addrs->other[i - 1].name, ".dynbss") == 0)
+	       || (strcmp (sect_name, ".sbss") == 0
+		   && i > 0
+		   && strcmp (addrs->other[i - 1].name, ".sdynbss") == 0)))
+	sect = bfd_get_section_by_name (abfd, addr_section_name (sect_name));
       if (sect)
 	{
 	  /* This is the index used by BFD. */
@@ -634,12 +660,18 @@ addr_info_make_relative (struct section_
 	     a warning.  Shared libraries contain just the section
 	     ".gnu.liblist" but it is not marked as loadable there.  There is
 	     no other way to identify them than by their name as the sections
-	     created by prelink have no special flags.  */
+	     created by prelink have no special flags.
+
+	     For the sections `.bss' and `.sbss' see addr_section_name.  */
 
 	  if (!(strcmp (sect_name, ".gnu.liblist") == 0
 		|| strcmp (sect_name, ".gnu.conflict") == 0
-		|| strcmp (sect_name, ".dynbss") == 0
-		|| strcmp (sect_name, ".sdynbss") == 0))
+		|| (strcmp (sect_name, ".bss") == 0
+		    && i > 0
+		    && strcmp (addrs->other[i - 1].name, ".dynbss") == 0)
+		|| (strcmp (sect_name, ".sbss") == 0
+		    && i > 0
+		    && strcmp (addrs->other[i - 1].name, ".sdynbss") == 0)))
 	    warning (_("section %s not found in %s"), sect_name,
 		     bfd_get_filename (abfd));
 
Index: gdb-7.1/gdb/testsuite/gdb.base/prelink-lib.c
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.base/prelink-lib.c	2010-01-01 08:32:01.000000000 +0100
+++ gdb-7.1/gdb/testsuite/gdb.base/prelink-lib.c	2010-07-19 23:11:56.000000000 +0200
@@ -16,6 +16,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+int copyreloc = 1;
+
 int
 g (void (*p)(void))
 {
Index: gdb-7.1/gdb/testsuite/gdb.base/prelink.c
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.base/prelink.c	2010-01-01 08:32:01.000000000 +0100
+++ gdb-7.1/gdb/testsuite/gdb.base/prelink.c	2010-07-19 23:11:56.000000000 +0200
@@ -18,6 +18,11 @@
 
 #include <stdio.h>
 
+extern int copyreloc;
+
+/* Test GDB itself finds `&bssvar' right.   */
+static int bssvar, *bssvarp = &bssvar;
+
 extern void (*h (void)) (void (*)(void));
 
 int
@@ -25,5 +30,6 @@ main (void)
 {
   void (*f) (void (*)(void)) = h ();
   printf ("%p\n", f);
+  printf ("%d\n", copyreloc);
   f (0);
 }
Index: gdb-7.1/gdb/testsuite/gdb.base/prelink.exp
===================================================================
--- gdb-7.1.orig/gdb/testsuite/gdb.base/prelink.exp	2010-07-19 23:11:12.000000000 +0200
+++ gdb-7.1/gdb/testsuite/gdb.base/prelink.exp	2010-07-20 00:06:18.000000000 +0200
@@ -84,6 +84,13 @@ if { [gdb_compile "${srcdir}/${subdir}/$
     return -1;
 }
 
+set test "split debug of executable"
+if [gdb_gnu_strip_debug $binfile] {
+    fail $test
+} else {
+    pass $test
+}
+
 set found 0
 set coredir "${objdir}/${subdir}/coredir.[getpid]"
 file mkdir $coredir
@@ -118,7 +125,7 @@ if {[catch "system \"/usr/sbin/prelink -
     untested "${testfile}.so was not prelinked, maybe system libraries are not prelinked?"
     return 0
 }
-catch "system \"/usr/sbin/prelink -qNR --no-exec-shield ${libfile}\""
+catch "system \"/usr/sbin/prelink -qNR --no-exec-shield ${libfile} ${binfile}\""
 
 # Start with a fresh gdb
 
@@ -131,3 +138,5 @@ gdb_load ${binfile}
 gdb_test "set verbose on"
 
 gdb_test "core-file $objdir/$subdir/prelink.core" {Using PIC \(Position Independent Code\) prelink displacement.*} "prelink"
+
+gdb_test "p &bssvar == bssvarp" " = 1" ".dynbss vs. .bss address shift"


Index: gdb.spec
===================================================================
RCS file: /cvs/pkgs/rpms/gdb/F-13/gdb.spec,v
retrieving revision 1.446
retrieving revision 1.447
diff -u -p -r1.446 -r1.447
--- gdb.spec	30 Jun 2010 14:11:31 -0000	1.446
+++ gdb.spec	20 Jul 2010 17:21:23 -0000	1.447
@@ -36,7 +36,7 @@ Version: 7.1
 
 # The release always contains a leading reserved number, start it at 1.
 # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
-Release: 28%{?_with_upstream:.upstream}%{dist}
+Release: 29%{?_with_upstream:.upstream}%{dist}
 
 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and GFDL and BSD and Public Domain
 Group: Development/Debuggers
@@ -527,6 +527,12 @@ Patch485: gdb-bz562763-pretty-print-2d-v
 Patch486: gdb-bz562763-pretty-print-2d-vectors.patch
 Patch487: gdb-bz562763-pretty-print-2d-vectors-libstdcxx.patch
 
+# Fix prelinked executables with sepdebug and copy relocations (BZ 614659).
+Patch489: gdb-bz614659-prelink-dynbss.patch
+
+# [delayed-symfile] Fix a backtrace regression on CFIs without DIE (BZ 614604).
+Patch490: gdb-bz614604-bt-cfi-without-die.patch
+
 BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa}
 Requires: readline%{?_isa}
 BuildRequires: readline-devel%{?_isa}
@@ -829,6 +835,8 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc
 %patch485 -p1
 %patch486 -p1
 %patch487 -p1
+%patch489 -p1
+%patch490 -p1
 
 %patch415 -p1
 %patch393 -p1
@@ -1161,6 +1169,10 @@ fi
 %endif
 
 %changelog
+* Tue Jul 20 2010 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.1-29.fc13
+- Fix prelinked executables with sepdebug and copy relocations (BZ 614659).
+- [delayed-symfile] Fix a backtrace regression on CFIs without DIE (BZ 614604).
+
 * Wed Jun 30 2010 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.1-28.fc13
 - Print 2D C++ vectors as matrices (BZ 562763, sourceware10659, Chris Moller).
 



More information about the scm-commits mailing list