From 4dddad42514ad1523a585d5b2536a847ca518360 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Jan 13 2007 09:18:58 +0000 Subject: - Fix unwinding of non-debug (.eh_frame) PPC code, Andreas Schwab (BZ 140532). - Fix unwinding of debug (.debug_frame) PPC code, workaround GCC (BZ 140532). - Fix missing testsuite .log output of testcases using get_compiler_info(). - Resolves: rhbz#140532 --- diff --git a/gdb-6.5-bz140532-ppc-debug_frame-return_address-test.patch b/gdb-6.5-bz140532-ppc-debug_frame-return_address-test.patch new file mode 100644 index 0000000..0da2d99 --- /dev/null +++ b/gdb-6.5-bz140532-ppc-debug_frame-return_address-test.patch @@ -0,0 +1,141 @@ +2007-01-13 Jan Kratochvil + + * gdb.base/bt-ppc.c, gdb.base/bt-ppc.exp: New files. + + +diff -u -rupN gdb-6.5-ppc/gdb/testsuite/gdb.base/bt-ppc.c gdb-6.5/gdb/testsuite/gdb.base/bt-ppc.c +--- gdb-6.5-ppc/gdb/testsuite/gdb.base/bt-ppc.c 1969-12-31 19:00:00.000000000 -0500 ++++ gdb-6.5/gdb/testsuite/gdb.base/bt-ppc.c 2007-01-12 21:34:55.000000000 -0500 +@@ -0,0 +1,41 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2007 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 2 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, write to the Free Software ++ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ++ ++#include ++ ++/* Force `-fpie' double jump bl->blrl. */ ++volatile int var; ++ ++int func0 (void) __attribute__((__noinline__)); ++int func0 (void) ++{ ++ abort (); ++ return var; ++} ++ ++int func1 (void) __attribute__((__noinline__)); ++int func1 (void) ++{ ++ return func0 () + var; ++} ++ ++int main (void) ++{ ++ func1 (); ++ return 0; ++} +diff -u -rupN gdb-6.5-ppc/gdb/testsuite/gdb.base/bt-ppc.exp gdb-6.5/gdb/testsuite/gdb.base/bt-ppc.exp +--- gdb-6.5-ppc/gdb/testsuite/gdb.base/bt-ppc.exp 1969-12-31 19:00:00.000000000 -0500 ++++ gdb-6.5/gdb/testsuite/gdb.base/bt-ppc.exp 2007-01-12 21:27:25.000000000 -0500 +@@ -0,0 +1,86 @@ ++# Copyright 2006, 2007 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 2 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, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++# Test multiple unwinding fixes of PPC platform. ++# As the tests are platform independent we can run it everywhere. ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set prms_id 0 ++set bug_id 0 ++ ++# This test uses GCC-specific syntax. ++if [get_compiler_info not-used] { ++ return -1 ++} ++ ++if {![test_compiler_info "gcc-*"]} { ++ return 0 ++} ++ ++proc do_test { opts addons } { ++ global objdir srcdir subdir gdb_prompt ++ ++ set testfile "bt-ppc" ++ set srcfile ${testfile}.c ++ set binfile ${objdir}/${subdir}/${testfile} ++ ++ # `additional_flags' should be last as it eats arguments till eol. ++ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable [list $opts additional_flags=$addons]] != ""} { ++ return -1 ++ } ++ ++ gdb_exit ++ gdb_start ++ gdb_reinitialize_dir $srcdir/$subdir ++ gdb_load ${binfile} ++ ++ # We should stop in abort(3). ++ ++ gdb_run_cmd ++ ++ gdb_test_multiple {} "continue to abort()" { ++ -re ".*Program received signal SIGABRT,.*$gdb_prompt $" { ++ pass "continue to abort()" ++ } ++ } ++ ++ # Check backtrace: ++ # #3 0x0804835f in func0 () ++ # #4 0x0804836a in func1 () ++ # #5 0x0804838c in main () ++ # (gdb) ++ # `\\.?' prefixes are needed for ppc64 without `debug' (another bug). ++ ++ set show [concat $opts $addons] ++ gdb_test_multiple "bt" "Correct unwind for: $show" { ++ -re "\r\n#\[0-9\]\[^\r\n\]* in \\.?func0 \\(\[^\r\n\]*\r\n#\[0-9\]\[^\r\n\]* in \\.?func1 \\(\[^\r\n\]*\r\n#\[0-9\]\[^\r\n\]* in \\.?main \\(\[^\r\n\]*\r\n$gdb_prompt $" { ++ pass "Correct unwind for: $show" ++ } ++ } ++} ++ ++foreach eh_frame {{-fno-asynchronous-unwind-tables} ++ {-fasynchronous-unwind-tables}} { ++ foreach pie {{} {-fpie -pie}} { ++ foreach optim {{} {-O2}} { ++ foreach is_debug {{} {debug}} { ++ do_test $is_debug [concat $eh_frame $pie $optim] ++ } ++ } ++ } ++} diff --git a/gdb-6.5-bz140532-ppc-debug_frame-return_address.patch b/gdb-6.5-bz140532-ppc-debug_frame-return_address.patch new file mode 100644 index 0000000..5d69c96 --- /dev/null +++ b/gdb-6.5-bz140532-ppc-debug_frame-return_address.patch @@ -0,0 +1,145 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=140532 + + +2007-01-13 Jan Kratochvil + + * dwarf2-frame.c (decode_frame_entry_1): Call + dwarf2_frame_return_address_regnum when processing CIE return address. + (struct dwarf2_frame_ops): Add return_address_regnum. + (dwarf2_frame_set_return_address_regnum): Define. + (dwarf2_frame_return_address_regnum): Define. + * dwarf2-frame.h (dwarf2_frame_set_return_address_regnum): Declare. + (dwarf2_frame_return_address_regnum): Declare. + * rs6000-tdep.c (rs6000_dwarf2_reg_to_regnum): Map also 64(CR) and + 65(FPSCR) DWARF2 registers. + (rs6000_return_address_regnum): Define. + (rs6000_gdbarch_init): Register rs6000_return_address_regnum. + + +--- gdb-6.5-ppc/gdb/dwarf2-frame.c 2007-01-12 14:40:32.000000000 -0500 ++++ gdb-6.5/gdb/dwarf2-frame.c 2007-01-12 18:46:32.000000000 -0500 +@@ -586,6 +586,10 @@ struct dwarf2_frame_ops + + /* Convert .eh_frame register number to DWARF register number. */ + int (*eh_frame_regnum) (struct gdbarch *, int); ++ ++ /* Convert .eh_frame/.debug_frame CIE return address register number to DWARF ++ register number. */ ++ int (*return_address_regnum) (struct gdbarch *, int, int); + }; + + /* Default architecture-specific register state initialization +@@ -693,6 +697,32 @@ dwarf2_frame_signal_frame_p (struct gdba + return ops->signal_frame_p (gdbarch, next_frame); + } + ++/* Set the architecture-specific mapping of .eh_frame/.debug_frame CIE return ++ address register number to DWARF register number. */ ++ ++void ++dwarf2_frame_set_return_address_regnum (struct gdbarch *gdbarch, ++ int (*return_address_regnum) ++ (struct gdbarch *, int, int)) ++{ ++ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data); ++ ++ ops->return_address_regnum = return_address_regnum; ++} ++ ++/* Translate a .eh_frame/.debug_frame CIE register to DWARF register. */ ++ ++int ++dwarf2_frame_return_address_regnum (struct gdbarch *gdbarch, int regnum, ++ int eh_frame_p) ++{ ++ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data); ++ ++ if (ops->return_address_regnum == NULL) ++ return regnum; ++ return ops->return_address_regnum (gdbarch, regnum, eh_frame_p); ++} ++ + /* Set the architecture-specific mapping of .eh_frame register numbers to + DWARF register numbers. */ + +@@ -1618,6 +1648,11 @@ decode_frame_entry_1 (struct comp_unit * + else + cie->return_address_register = read_unsigned_leb128 (unit->abfd, buf, + &bytes_read); ++ ++ cie->return_address_register ++ = dwarf2_frame_return_address_regnum (current_gdbarch, ++ cie->return_address_register, ++ eh_frame_p); + if (eh_frame_p) + cie->return_address_register + = dwarf2_frame_eh_frame_regnum (current_gdbarch, +--- gdb-6.5-ppc/gdb/dwarf2-frame.h 2007-01-12 14:40:32.000000000 -0500 ++++ gdb-6.5/gdb/dwarf2-frame.h 2007-01-12 18:36:47.000000000 -0500 +@@ -107,6 +107,20 @@ extern void + extern int + dwarf2_frame_eh_frame_regnum (struct gdbarch *gdbarch, int regnum); + ++/* Set the architecture-specific mapping of .eh_frame/.debug_frame CIE return ++ address register number to DWARF register number. */ ++ ++extern void ++ dwarf2_frame_set_return_address_regnum (struct gdbarch *gdbarch, ++ int (*return_address_regnum) ++ (struct gdbarch *, int, int)); ++ ++/* Translate a .eh_frame/.debug_frame CIE register to DWARF register. */ ++ ++extern int ++ dwarf2_frame_return_address_regnum (struct gdbarch *gdbarch, int regnum, ++ int eh_frame_p); ++ + /* Return the frame unwind methods for the function that contains PC, + or NULL if it can't be handled by DWARF CFI frame unwinder. */ + +--- gdb-6.5-ppc/gdb/rs6000-tdep.c 2007-01-12 14:40:32.000000000 -0500 ++++ gdb-6.5/gdb/rs6000-tdep.c 2007-01-12 18:44:21.000000000 -0500 +@@ -2307,6 +2307,11 @@ rs6000_dwarf2_reg_to_regnum (int num) + else + switch (num) + { ++ case 64: ++ return tdep->ppc_cr_regnum; ++ /* Broken GCC uses it for CIE `Return address column' as LR. */ ++ case 65: ++ return tdep->ppc_fpscr_regnum; + case 67: + return tdep->ppc_vrsave_regnum - 1; /* vscr */ + case 99: +@@ -2363,6 +2368,22 @@ rs6000_eh_frame_regnum (struct gdbarch * + } + } + ++/* Convert a .eh_frame/.debug_frame CIE return address register number to DWARF ++ register number. */ ++static int ++rs6000_return_address_regnum (struct gdbarch *gdbarch, int regnum, ++ int eh_frame_p) ++{ ++ if (eh_frame_p != 0) ++ return regnum; ++ ++ /* Broken GCC uses it for CIE `Return address column' as LR. */ ++ if (regnum == 65) ++ return 108; ++ ++ return regnum; ++} ++ + static void + rs6000_store_return_value (struct type *type, + struct regcache *regcache, +@@ -3584,6 +3605,8 @@ rs6000_gdbarch_init (struct gdbarch_info + /* Hook in the DWARF CFI frame unwinder. */ + frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer); + dwarf2_frame_set_eh_frame_regnum (gdbarch, rs6000_eh_frame_regnum); ++ dwarf2_frame_set_return_address_regnum (gdbarch, ++ rs6000_return_address_regnum); + + /* Hook in ABI-specific overrides, if they have been registered. */ + gdbarch_init_osabi (info, gdbarch); diff --git a/gdb-6.5-bz140532-ppc-eh_frame-regnum.patch b/gdb-6.5-bz140532-ppc-eh_frame-regnum.patch new file mode 100644 index 0000000..2def3a6 --- /dev/null +++ b/gdb-6.5-bz140532-ppc-eh_frame-regnum.patch @@ -0,0 +1,91 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=140532 + + +2006-05-09 Andreas Schwab + + * rs6000-tdep.c: Include "dwarf2-frame.h". + (rs6000_eh_frame_regnum): Define. + (rs6000_gdbarch_init): Enable use of DWARF CFI frame unwinder. + Register rs6000_eh_frame_regnum. + + * Makefile.in (rs6000-tdep.o): Update dependencies. + + +http://sourceware.org/ml/gdb-patches/2006-05/msg00341.html + Selectively enabling them on platforms that are unlikely to have ever + used GCC versions before 3.4 should be fine. + + +--- ./gdb/Makefile.in 5 May 2006 22:39:12 -0000 1.812 ++++ ./gdb/Makefile.in 9 May 2006 14:10:40 -0000 +@@ -2515,7 +2515,7 @@ rs6000-tdep.o: rs6000-tdep.c $(defs_h) $ + $(reggroups_h) $(libbfd_h) $(coff_internal_h) $(libcoff_h) \ + $(coff_xcoff_h) $(libxcoff_h) $(elf_bfd_h) $(solib_svr4_h) \ + $(ppc_tdep_h) $(gdb_assert_h) $(dis_asm_h) $(trad_frame_h) \ +- $(frame_unwind_h) $(frame_base_h) $(rs6000_tdep_h) ++ $(frame_unwind_h) $(frame_base_h) $(rs6000_tdep_h) $(dwarf2_frame_h) + rs6000-aix-tdep.o: rs6000-aix-tdep.c $(defs_h) $(osabi_h) $(rs6000_tdep_h) + s390-nat.o: s390-nat.c $(defs_h) $(tm_h) $(regcache_h) $(inferior_h) \ + $(s390_tdep_h) $(target_h) $(linux_nat_h) +--- ./gdb/rs6000-tdep.c 23 Apr 2006 14:15:01 -0000 1.258 ++++ ./gdb/rs6000-tdep.c 9 May 2006 14:10:15 -0000 +@@ -40,6 +40,7 @@ + #include "sim-regno.h" + #include "gdb/sim-ppc.h" + #include "reggroups.h" ++#include "dwarf2-frame.h" + + #include "libbfd.h" /* for bfd_default_set_arch_mach */ + #include "coff/internal.h" /* for libcoff.h */ +@@ -2243,6 +2244,40 @@ rs6000_dwarf2_reg_to_regnum (int num) + } + + ++/* Convert a .eh_frame register number to a Dwarf 2 register number. */ ++static int ++rs6000_eh_frame_regnum (struct gdbarch *gdbarch, int num) ++{ ++ if (0 <= num && num <= 63) /* r0-r31,fp0-fp31 */ ++ return num; ++ else if (68 <= num && num <= 75) /* cr0-cr8 */ ++ return num - 68 + 86; ++ else if (77 <= num && num <= 108) /* vr0-vr31 */ ++ return num - 77 + 1124; ++ else ++ switch (num) ++ { ++ case 64: /* mq */ ++ return 100; ++ case 65: /* lr */ ++ return 108; ++ case 66: /* ctr */ ++ return 109; ++ case 76: /* xer */ ++ return 101; ++ case 109: /* vrsave */ ++ return 356; ++ case 110: /* vscr */ ++ return 67; ++ case 111: /* spe_acc */ ++ return 99; ++ case 112: /* spefscr */ ++ return 612; ++ default: ++ return num; ++ } ++} ++ + static void + rs6000_store_return_value (struct type *type, + struct regcache *regcache, +@@ -3461,6 +3496,10 @@ rs6000_gdbarch_init (struct gdbarch_info + /* Helpers for function argument information. */ + set_gdbarch_fetch_pointer_argument (gdbarch, rs6000_fetch_pointer_argument); + ++ /* Hook in the DWARF CFI frame unwinder. */ ++ frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer); ++ dwarf2_frame_set_eh_frame_regnum (gdbarch, rs6000_eh_frame_regnum); ++ + /* Hook in ABI-specific overrides, if they have been registered. */ + gdbarch_init_osabi (info, gdbarch); + diff --git a/gdb-6.5-testsuite-log.patch b/gdb-6.5-testsuite-log.patch new file mode 100644 index 0000000..87e3e5c --- /dev/null +++ b/gdb-6.5-testsuite-log.patch @@ -0,0 +1,20 @@ +2007-01-13 Jan Kratochvil + + * lib/gdb.exp (get_compiler_info): Cope with nondefault output logs. + + +diff -u -rupN gdb-6.5-ppc/gdb/testsuite/lib/gdb.exp gdb-6.5/gdb/testsuite/lib/gdb.exp +--- gdb-6.5-ppc/gdb/testsuite/lib/gdb.exp 2007-01-12 14:33:26.000000000 -0500 ++++ gdb-6.5/gdb/testsuite/lib/gdb.exp 2007-01-12 21:15:02.000000000 -0500 +@@ -1351,9 +1351,10 @@ proc get_compiler_info {binfile args} { + + # Run $ifile through the right preprocessor. + # Toggle gdb.log to keep the compiler output out of the log. ++ set log_old [log_file -info] + log_file + set cppout [ gdb_compile "${ifile}" "" preprocess [list "$args" quiet] ] +- log_file -a "$outdir/$tool.log" ++ eval "log_file $log_old" + + # Eval the output. + set unknown 0 diff --git a/gdb.spec b/gdb.spec index 899795f..a59e70a 100644 --- a/gdb.spec +++ b/gdb.spec @@ -11,7 +11,7 @@ Name: gdb Version: 6.5 # The release always contains a leading reserved number, start it at 0. -Release: 25%{?dist} +Release: 26%{?dist} License: GPL Group: Development/Debuggers @@ -106,9 +106,6 @@ Patch124: gdb-6.3-pie-20050110.patch # Get selftest working with sep-debug-info Patch125: gdb-6.3-test-self-20050110.patch -# Enable PPC CFI support. -Patch127: gdb-6.3-ppccfi-20041104.patch - # Fix for non-threaded watchpoints. Patch128: gdb-6.3-nonthreaded-wp-20050117.patch @@ -324,6 +321,14 @@ Patch225: gdb-6.5-bz109921-DW_AT_decl_file-test.patch # Fix unwinding of non-CFI (w/o debuginfo) PPC code by recent GCC (BZ 140532). Patch226: gdb-6.3-bz140532-ppcnoncfi-skip_prologue-PIC.patch +# Fix unwinding of non-debug (.eh_frame) PPC code, Andreas Schwab (BZ 140532). +Patch227: gdb-6.5-bz140532-ppc-eh_frame-regnum.patch +# Fix unwinding of debug (.debug_frame) PPC code, workaround GCC (BZ 140532). +Patch228: gdb-6.5-bz140532-ppc-debug_frame-return_address.patch +Patch229: gdb-6.5-bz140532-ppc-debug_frame-return_address-test.patch + +# Fix missing testsuite .log output of testcases using get_compiler_info(). +Patch230: gdb-6.5-testsuite-log.patch BuildRequires: ncurses-devel glibc-devel gcc make gzip texinfo dejagnu gettext BuildRequires: flex bison sharutils @@ -380,7 +385,6 @@ and printing their data. %patch122 -p1 %patch124 -p1 %patch125 -p1 -%patch127 -p1 %patch128 -p1 %patch130 -p1 %patch133 -p1 @@ -455,6 +459,10 @@ and printing their data. %patch224 -p1 %patch225 -p1 %patch226 -p1 +%patch227 -p1 +%patch228 -p1 +%patch229 -p1 +%patch230 -p1 # Change the version that gets printed at GDB startup, so it is RedHat # specific. @@ -617,6 +625,11 @@ fi # don't include the files in include, they are part of binutils %changelog +* Fri Jan 13 2007 Jan Kratochvil - 6.5-26 +- Fix unwinding of non-debug (.eh_frame) PPC code, Andreas Schwab (BZ 140532). +- Fix unwinding of debug (.debug_frame) PPC code, workaround GCC (BZ 140532). +- Fix missing testsuite .log output of testcases using get_compiler_info(). + * Fri Jan 12 2007 Jan Kratochvil - 6.5-25 - Fix unwinding of non-CFI (w/o debuginfo) PPC code by recent GCC (BZ 140532).