From 5430618261f1ab04a8a74b5a4071b30669f92fac Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior Date: Tue, 1 Oct 2013 00:38:47 -0300 Subject: [PATCH 01/10] - Fix the case when GDB leaks memory because value_struct_elt does not call check_typedef. (Doug Evans, BZ 15695, filed as RH BZ 1013453). --- ...1013453-value-struct-elt-memory-leak.patch | 136 ++++++++++++++++++ gdb.spec | 12 +- 2 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 gdb-rhbz1013453-value-struct-elt-memory-leak.patch diff --git a/gdb-rhbz1013453-value-struct-elt-memory-leak.patch b/gdb-rhbz1013453-value-struct-elt-memory-leak.patch new file mode 100644 index 0000000..a1af0ea --- /dev/null +++ b/gdb-rhbz1013453-value-struct-elt-memory-leak.patch @@ -0,0 +1,136 @@ +https://sourceware.org/ml/gdb-patches/2013-07/msg00469.html + +Hi. +This patch adds the missing calls to check_typedef +and adds a testcase to show the issue. + +The PR is not closeable yet, but the remaining issues are more cleanups +than actual bug fixes. + +Regression tested on amd64-linux. + +I will check this in in a few days if there are no objections. + +[The multiple calls to check_typedef (value_type (*argp)) are +bothersome, but the code is simpler this way, and I expect +resolving the rest of the issues in 15695 to potentially change this +code significantly.] + +--- + +commit cbb25189b69e501ddca64917d810b54bb1466c93 +Author: Doug Evans +Date: Thu Aug 1 23:59:47 2013 +0000 + + PR symtab/15695 + * valops.c (value_struct_elt): Add missing call to check_typedef. + (value_find_oload_method_list): Ditto. + + testsuite/ + * gdb.base/func-ptr.exp: New file. + * gdb.base/func-ptr.c: New file. + +2013-08-01 Doug Evans + + PR symtab/15695 + * valops.c (value_struct_elt): Add missing call to check_typedef. + (value_find_oload_method_list): Ditto. + +2013-08-01 Doug Evans + + PR symtab/15695 + * gdb.base/func-ptr.exp: New file. + * gdb.base/func-ptr.c: New file. + +Index: gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.base/func-ptr.c +=================================================================== +--- /dev/null ++++ gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.base/func-ptr.c +@@ -0,0 +1,30 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2013 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 . */ ++ ++void ++bar () ++{ ++} ++ ++typedef void foo (void); ++foo *pbar = bar; ++ ++int ++main () ++{ ++ return 0; ++} +Index: gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.base/func-ptr.exp +=================================================================== +--- /dev/null ++++ gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.base/func-ptr.exp +@@ -0,0 +1,30 @@ ++# Copyright 2013 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 . ++ ++# This testcase exercises bug 15695. ++# Trying to print foo->bar if foo is a pointer to a typedef of a pointer ++# to a function will put gdb into an infinite loop. ++ ++if { [prepare_for_testing func-ptr.exp "func-ptr" {func-ptr.c} {debug}] } { ++ return -1 ++} ++ ++if ![runto_main] { ++ fail "Can't run to main" ++ return 0 ++} ++ ++# This would put gdb into an infinite loop. ++gdb_test "print pbar->baz" "Attempt to extract .*" +Index: gdb-7.6.50.20130731-cvs/gdb/valops.c +=================================================================== +--- gdb-7.6.50.20130731-cvs.orig/gdb/valops.c ++++ gdb-7.6.50.20130731-cvs/gdb/valops.c +@@ -2275,7 +2275,7 @@ value_struct_elt (struct value **argp, s + { + *argp = value_ind (*argp); + /* Don't coerce fn pointer to fn and then back again! */ +- if (TYPE_CODE (value_type (*argp)) != TYPE_CODE_FUNC) ++ if (TYPE_CODE (check_typedef (value_type (*argp))) != TYPE_CODE_FUNC) + *argp = coerce_array (*argp); + t = check_typedef (value_type (*argp)); + } +@@ -2439,7 +2439,7 @@ value_find_oload_method_list (struct val + { + *argp = value_ind (*argp); + /* Don't coerce fn pointer to fn and then back again! */ +- if (TYPE_CODE (value_type (*argp)) != TYPE_CODE_FUNC) ++ if (TYPE_CODE (check_typedef (value_type (*argp))) != TYPE_CODE_FUNC) + *argp = coerce_array (*argp); + t = check_typedef (value_type (*argp)); + } diff --git a/gdb.spec b/gdb.spec index b786703..2aa7178 100644 --- a/gdb.spec +++ b/gdb.spec @@ -38,7 +38,7 @@ Version: 7.6.50.%{snap} # 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: 11%{?dist} +Release: 12%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain Group: Development/Debuggers @@ -524,6 +524,11 @@ Patch832: gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch # Fix crash on 'enable count' (Simon Marchi, BZ 993118). Patch843: gdb-enable-count-crash.patch +# Fix the case when GDB leaks memory because value_struct_elt +# does not call check_typedef. (Doug Evans, BZ 15695, filed as +# RH BZ 1013453). +Patch844: gdb-rhbz1013453-value-struct-elt-memory-leak.patch + %if 0%{!?rhel:1} || 0%{?rhel} > 6 # RL_STATE_FEDORA_GDB would not be found for: # Patch642: gdb-readline62-ask-more-rh.patch @@ -816,6 +821,7 @@ find -name "*.info*"|xargs rm -f %patch818 -p1 %patch832 -p1 %patch843 -p1 +%patch844 -p1 %patch393 -p1 %if 0%{!?el5:1} || 0%{?scl:1} @@ -1334,6 +1340,10 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Mon Sep 30 2013 Sergio Durigan Junior - 7.6.50.20130731-12.fc20 +- Fix the case when GDB leaks memory because value_struct_elt does not call + check_typedef. (Doug Evans, BZ 15695, filed as RH BZ 1013453). + * Wed Sep 25 2013 Jan Kratochvil - 7.6.50.20130731-11.fc20 - Enable arm-linux-gnu and aarch64-linux-gnu targets on all archs (BZ 1011647). From 0015e2ee6e6b603129b775e59bbe5d315d5f730c Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Wed, 30 Oct 2013 12:49:53 +0100 Subject: [PATCH 02/10] [rhel5] Fix /etc/gdbinit compatibility with python-2.4. --- gdb.spec | 5 ++++- gdbinit | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gdb.spec b/gdb.spec index 2aa7178..b46c835 100644 --- a/gdb.spec +++ b/gdb.spec @@ -38,7 +38,7 @@ Version: 7.6.50.%{snap} # 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: 12%{?dist} +Release: 13%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain Group: Development/Debuggers @@ -1340,6 +1340,9 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Wed Oct 30 2013 Jan Kratochvil - 7.6.50.20130731-13.fc20 +- [rhel5] Fix /etc/gdbinit compatibility with python-2.4. + * Mon Sep 30 2013 Sergio Durigan Junior - 7.6.50.20130731-12.fc20 - Fix the case when GDB leaks memory because value_struct_elt does not call check_typedef. (Doug Evans, BZ 15695, filed as RH BZ 1013453). diff --git a/gdbinit b/gdbinit index 9f431dc..b59fb0d 100644 --- a/gdbinit +++ b/gdbinit @@ -1,8 +1,9 @@ # System-wide GDB initialization file. python import glob -for f in glob.iglob('%{_sysconfdir}/gdbinit.d/*.gdb'): +# glob.iglob is not available in python-2.4 (RHEL-5). +for f in glob.glob('%{_sysconfdir}/gdbinit.d/*.gdb'): gdb.execute('source %s' % f) -for f in glob.iglob('%{_sysconfdir}/gdbinit.d/*.py'): +for f in glob.glob('%{_sysconfdir}/gdbinit.d/*.py'): gdb.execute('source %s' % f) end From 7492fba56d86c2ceb1b7f75ecc831e4e731a9408 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sun, 3 Nov 2013 16:06:52 +0100 Subject: [PATCH 03/10] Fix %{_bindir}gdb-add-index to also use -iex 'set auto-load no'. --- gdb-gdb-add-index-script.patch | 2 +- gdb.spec | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gdb-gdb-add-index-script.patch b/gdb-gdb-add-index-script.patch index 81c197c..d63077c 100644 --- a/gdb-gdb-add-index-script.patch +++ b/gdb-gdb-add-index-script.patch @@ -169,7 +169,7 @@ Index: gdb-7.6.50.20130731-cvs/gdb/gdb-add-index +dir="${file%/*}" + +# We don't care if gdb gives an error. -+gdb -nx --batch-silent -ex "file $file" -ex "save gdb-index $dir" ++gdb -nx -iex 'set auto-load no' --batch-silent -ex "file $file" -ex "save gdb-index $dir" + +if test -f "${file}.gdb-index"; then + objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file" diff --git a/gdb.spec b/gdb.spec index b46c835..54ba871 100644 --- a/gdb.spec +++ b/gdb.spec @@ -38,7 +38,7 @@ Version: 7.6.50.%{snap} # 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: 13%{?dist} +Release: 14%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain Group: Development/Debuggers @@ -1340,6 +1340,9 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Sun Nov 3 2013 Jan Kratochvil - 7.6.50.20130731-14.fc20 +- Fix %{_bindir}gdb-add-index to also use -iex 'set auto-load no'. + * Wed Oct 30 2013 Jan Kratochvil - 7.6.50.20130731-13.fc20 - [rhel5] Fix /etc/gdbinit compatibility with python-2.4. From 2598b60bc9825d24463454023d5dd572a95f3ac1 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Tue, 5 Nov 2013 14:58:36 +0100 Subject: [PATCH 04/10] [aarch64] Backport two fixes (BZ 1026484). --- gdb-upstream.patch | 77 ++++++++++++++++++++++++++++++++++++++++++++++ gdb.spec | 9 ++++-- 2 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 gdb-upstream.patch diff --git a/gdb-upstream.patch b/gdb-upstream.patch new file mode 100644 index 0000000..776aa40 --- /dev/null +++ b/gdb-upstream.patch @@ -0,0 +1,77 @@ +commit 1aa4cd774ca674ee6061e2068a410bb67c8bc812 +Author: Andrew Pinski +Date: Thu Sep 12 07:14:37 2013 +0000 + + 2013-09-12 Andrew Pinski + + * aarch64-linux-nat.c (aarch64_linux_set_debug_regs): Zero out regs. + +diff --git a/gdb/ChangeLog b/gdb/ChangeLog +index fa3de16..903dcba 100644 +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,3 +1,7 @@ ++2013-09-12 Andrew Pinski ++ ++ * aarch64-linux-nat.c (aarch64_linux_set_debug_regs): Zero out regs. ++ + 2013-09-10 Andreas Arnez + + * config/s390/s390.mh (NATDEPFILES): Add linux-waitpid.o. +diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c +index 846f156..f685619 100644 +--- a/gdb/aarch64-linux-nat.c ++++ b/gdb/aarch64-linux-nat.c +@@ -312,6 +312,7 @@ aarch64_linux_set_debug_regs (const struct aarch64_debug_reg_state *state, + const CORE_ADDR *addr; + const unsigned int *ctrl; + ++ memset (®s, 0, sizeof (regs)); + iov.iov_base = ®s; + iov.iov_len = sizeof (regs); + count = watchpoint ? aarch64_num_wp_regs : aarch64_num_bp_regs; + + + +commit 05feb1933f80f2d55e132adc657d3152947af3d1 +Author: Will Newton +Date: Thu Oct 10 10:40:42 2013 +0000 + + gdb/aarch64-linux-tdep.c: Call linux_init_abi. + + If we are running on a Linux platform we should call linux_init_abi + in order to get all the useful hooks it enables. + + gdb/ChangeLog: + + 2013-10-10 Will Newton + + * aarch64-linux-tdep.c (aarch64_linux_init_abi): Call + linux_init_abi. + +diff --git a/gdb/ChangeLog b/gdb/ChangeLog +index 4372579..7a41967 100644 +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,3 +1,8 @@ ++2013-10-10 Will Newton ++ ++ * aarch64-linux-tdep.c (aarch64_linux_init_abi): Call ++ linux_init_abi. ++ + 2013-10-10 Joel Brobecker + + * cli/cli-cmds.c (show_baud_rate): Moved to serial.c as +diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c +index 8e66425..bcfcce2 100644 +--- a/gdb/aarch64-linux-tdep.c ++++ b/gdb/aarch64-linux-tdep.c +@@ -270,6 +270,8 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) + + tdep->lowest_pc = 0x8000; + ++ linux_init_abi (info, gdbarch); ++ + set_solib_svr4_fetch_link_map_offsets (gdbarch, + svr4_lp64_fetch_link_map_offsets); + diff --git a/gdb.spec b/gdb.spec index 54ba871..adbeb7c 100644 --- a/gdb.spec +++ b/gdb.spec @@ -38,7 +38,7 @@ Version: 7.6.50.%{snap} # 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: 14%{?dist} +Release: 15%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain Group: Development/Debuggers @@ -235,7 +235,7 @@ Patch231: gdb-6.3-bz202689-exec-from-pthread-test.patch # Backported fixups post the source tarball. #Xdrop: Just backports. -#Patch232: gdb-upstream.patch +Patch232: gdb-upstream.patch # Testcase for PPC Power6/DFP instructions disassembly (BZ 230000). #=fedoratest+ppc @@ -723,7 +723,7 @@ find -name "*.info*"|xargs rm -f %patch2 -p1 %patch349 -p1 -#patch232 -p1 +%patch232 -p1 %patch1 -p1 %patch105 -p1 @@ -1340,6 +1340,9 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Tue Nov 5 2013 Jan Kratochvil - 7.6.50.20130731-15.fc20 +- [aarch64] Backport two fixes (BZ 1026484). + * Sun Nov 3 2013 Jan Kratochvil - 7.6.50.20130731-14.fc20 - Fix %{_bindir}gdb-add-index to also use -iex 'set auto-load no'. From f823fec325a8ea5bdb3b4a189de37dd2b0547ef9 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sat, 9 Nov 2013 19:27:47 +0100 Subject: [PATCH 05/10] Fix explicit Class:: inside class scope (BZ 874817, Keith Seitz). --- gdb-implicit-this.patch | 299 ++++++++++++++++++++++++++++++++++++++++ gdb.spec | 9 +- 2 files changed, 307 insertions(+), 1 deletion(-) create mode 100644 gdb-implicit-this.patch diff --git a/gdb-implicit-this.patch b/gdb-implicit-this.patch new file mode 100644 index 0000000..0ce72dd --- /dev/null +++ b/gdb-implicit-this.patch @@ -0,0 +1,299 @@ +Index: gdb-7.6.50.20130731-cvs/gdb/c-exp.y +=================================================================== +--- gdb-7.6.50.20130731-cvs.orig/gdb/c-exp.y 2013-11-09 18:41:48.706718127 +0100 ++++ gdb-7.6.50.20130731-cvs/gdb/c-exp.y 2013-11-09 18:42:19.291697661 +0100 +@@ -2944,6 +2944,30 @@ classify_inner_name (const struct block + { + case LOC_BLOCK: + case LOC_LABEL: ++ { ++ struct field_of_this_result fot; ++ ++ /* We might have erroneously found a constructor where we wanted ++ a type name. The trick is ascertaining what the user wanted. ++ If cp_lookup_nested_symbol found a constructor, but it is for a ++ different type than CONTEXT, then this is really a type, not a ++ constructor. Look for the type and return that. */ ++ memset (&fot, 0, sizeof (fot)); ++ check_field (type, copy, &fot); ++ if (fot.fn_field != NULL ++ && TYPE_FN_FIELD_CONSTRUCTOR (fot.fn_field->fn_fields, 0) ++ && !types_equal (type, fot.type)) ++ { ++ struct symbol *sym; ++ ++ sym = lookup_symbol (copy, block, STRUCT_DOMAIN, NULL); ++ if (sym != NULL) ++ { ++ yylval.tsym.type = SYMBOL_TYPE (sym); ++ return TYPENAME; ++ } ++ } ++ } + return ERROR; + + case LOC_TYPEDEF: +Index: gdb-7.6.50.20130731-cvs/gdb/symtab.c +=================================================================== +--- gdb-7.6.50.20130731-cvs.orig/gdb/symtab.c 2013-11-09 18:41:48.708718125 +0100 ++++ gdb-7.6.50.20130731-cvs/gdb/symtab.c 2013-11-09 18:42:19.293697660 +0100 +@@ -1293,7 +1293,7 @@ lookup_language_this (const struct langu + return 1 if the component named NAME from the ultimate target + structure/union is defined, otherwise, return 0. */ + +-static int ++int + check_field (struct type *type, const char *name, + struct field_of_this_result *is_a_field_of_this) + { +Index: gdb-7.6.50.20130731-cvs/gdb/symtab.h +=================================================================== +--- gdb-7.6.50.20130731-cvs.orig/gdb/symtab.h 2013-11-09 18:42:19.293697660 +0100 ++++ gdb-7.6.50.20130731-cvs/gdb/symtab.h 2013-11-09 18:42:34.023687872 +0100 +@@ -1377,4 +1377,9 @@ void initialize_symbol (struct symbol *) + + struct template_symbol *allocate_template_symbol (struct objfile *); + ++/* See comment in symtab.c. */ ++ ++int check_field (struct type *type, const char *name, ++ struct field_of_this_result *is_a_field_of_this); ++ + #endif /* !defined(SYMTAB_H) */ +Index: gdb-7.6.50.20130731-cvs/gdb/valops.c +=================================================================== +--- gdb-7.6.50.20130731-cvs.orig/gdb/valops.c 2013-11-09 18:41:48.712718123 +0100 ++++ gdb-7.6.50.20130731-cvs/gdb/valops.c 2013-11-09 18:42:19.294697659 +0100 +@@ -3226,10 +3226,35 @@ value_struct_elt_for_reference (struct t + return value_from_longest + (lookup_memberptr_type (TYPE_FIELD_TYPE (t, i), domain), + offset + (TYPE_FIELD_BITPOS (t, i) >> 3)); +- else if (noside == EVAL_AVOID_SIDE_EFFECTS) ++ else if (noside != EVAL_NORMAL) + return allocate_value (TYPE_FIELD_TYPE (t, i)); + else +- error (_("Cannot reference non-static field \"%s\""), name); ++ { ++ /* Try to evaluate NAME as a qualified name with implicit ++ this pointer. In this case, attempt to return the ++ equivalent to `this->*(&TYPE::NAME)'. */ ++ v = value_of_this_silent (current_language); ++ if (v != NULL) ++ { ++ struct value *ptr; ++ long mem_offset; ++ struct type *type, *tmp; ++ ++ ptr = value_aggregate_elt (domain, name, NULL, 1, noside); ++ type = check_typedef (value_type (ptr)); ++ gdb_assert (type != NULL ++ && TYPE_CODE (type) == TYPE_CODE_MEMBERPTR); ++ tmp = lookup_pointer_type (TYPE_DOMAIN_TYPE (type)); ++ v = value_cast_pointers (tmp, v, 1); ++ mem_offset = value_as_long (ptr); ++ tmp = lookup_pointer_type (TYPE_TARGET_TYPE (type)); ++ result = value_from_pointer (tmp, ++ value_as_long (v) + mem_offset); ++ return value_ind (result); ++ } ++ ++ error (_("Cannot reference non-static field \"%s\""), name); ++ } + } + } + +Index: gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.cp/impl-this.cc +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.cp/impl-this.cc 2013-11-09 18:42:19.294697659 +0100 +@@ -0,0 +1,96 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2013 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 . */ ++ ++#ifdef DEBUG ++#include ++#endif ++ ++class A ++{ ++public: ++ int i; ++ int z; ++ A () : i (1), z (10) {} ++}; ++ ++class B : public virtual A ++{ ++public: ++ int i; ++ B () : i (2) {} ++}; ++ ++class C : public virtual A ++{ ++public: ++ int i; ++ int c; ++ C () : i (3), c (30) {} ++}; ++ ++class D : public B, public C ++{ ++public: ++ int i; ++ int x; ++ D () : i (4), x (40) {} ++ ++#ifdef DEBUG ++#define SUM(X) \ ++ do \ ++ { \ ++ sum += (X); \ ++ printf ("" #X " = %d\n", (X)); \ ++ } \ ++ while (0) ++#else ++#define SUM(X) sum += (X) ++#endif ++ ++int ++f (void) ++ { ++ int sum = 0; ++ ++ SUM (i); ++ SUM (D::i); ++ SUM (D::B::i); ++ SUM (B::i); ++ SUM (D::C::i); ++ SUM (C::i); ++ SUM (D::B::A::i); ++ SUM (B::A::i); ++ SUM (A::i); ++ SUM (D::C::A::i); ++ SUM (C::A::i); ++ SUM (D::x); ++ SUM (x); ++ SUM (D::C::c); ++ SUM (C::c); ++ SUM (c); ++ ++ return sum; ++ } ++}; ++ ++int ++main (void) ++{ ++ D d; ++ ++ return d.f (); ++} +Index: gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.cp/impl-this.exp +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.cp/impl-this.exp 2013-11-09 18:42:19.295697659 +0100 +@@ -0,0 +1,89 @@ ++# Copyright 2013 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 . ++ ++# This file is part of the gdb testsuite ++ ++# Test expressions which assume an implicit "this" with a qualified ++# name. ++ ++if {[skip_cplus_tests]} { continue } ++ ++standard_testfile .cc ++ ++if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { ++ return -1 ++} ++ ++# First test expressions when there is no context. ++gdb_test "print i" "No symbol \"i\" in current context." ++gdb_test "print D::i" "Cannot reference non-static field \"i\"" ++gdb_test "print D::B::i" "Cannot reference non-static field \"i\"" ++gdb_test "print B::i" "Cannot reference non-static field \"i\"" ++gdb_test "print D::C::i" "Cannot reference non-static field \"i\"" ++gdb_test "print C::i" "Cannot reference non-static field \"i\"" ++gdb_test "print D::B::A::i" "Cannot reference non-static field \"i\"" ++gdb_test "print B::A::i" "Cannot reference non-static field \"i\"" ++gdb_test "print A::i" "Cannot reference non-static field \"i\"" ++gdb_test "print D::C::A::i" "Cannot reference non-static field \"i\"" ++gdb_test "print C::A::i" "Cannot reference non-static field \"i\"" ++gdb_test "print D::x" "Cannot reference non-static field \"x\"" ++gdb_test "print x" "No symbol \"x\" in current context." ++gdb_test "print D::C::c" "Cannot reference non-static field \"c\"" ++gdb_test "print C::c" "Cannot reference non-static field \"c\"" ++gdb_test "print c" "No symbol \"c\" in current context." ++ ++# Run to D::f. ++if {![runto_main]} { ++ perror "couldn't run to main" ++ continue ++} ++ ++gdb_breakpoint "D::f" ++gdb_continue_to_breakpoint "run to D::f" ++ ++# Now test valid expressions in the class hierarchy for D. ++gdb_test "print i" "= 4" ++gdb_test "print D::i" "= 4" ++gdb_test "print D::B::i" "= 2" ++gdb_test "print B::i" "= 2" ++gdb_test "print D::C::i" "= 3" ++gdb_test "print C::i" "= 3" ++gdb_test "print D::B::A::i" "= 1" ++gdb_test "print B::A::i" "= 1" ++gdb_test "print A::i" "= 1" ++gdb_test "print D::C::A::i" "= 1" ++gdb_test "print C::A::i" "= 1" ++gdb_test "print D::x" "= 40" ++gdb_test "print x" "= 40" ++gdb_test "print D::C::c" "= 30" ++gdb_test "print C::c" "= 30" ++gdb_test "print c" "= 30" ++ ++# Test some invalid expressions ++gdb_test "print D::B::c" "There is no field named c" ++gdb_test "print D::B::A::c" "There is no field named c" ++gdb_test "print D::C::A::c" "There is no field named c" ++gdb_test "print B::c" "There is no field named c" ++gdb_test "print B::A::c" "There is no field named c" ++gdb_test "print C::A::c" "There is no field named c" ++gdb_test "print D::B::x" "There is no field named x" ++gdb_test "print D::B::A::x" "There is no field named x" ++gdb_test "print B::x" "There is no field named x" ++gdb_test "print B::A::x" "There is no field named x" ++gdb_test "print D::C::x" "There is no field named x" ++gdb_test "print C::x" "There is no field named x" ++gdb_test "print D::C::A::x" "There is no field named x" ++gdb_test "print C::A::x" "There is no field named x" ++ diff --git a/gdb.spec b/gdb.spec index adbeb7c..be5a304 100644 --- a/gdb.spec +++ b/gdb.spec @@ -38,7 +38,7 @@ Version: 7.6.50.%{snap} # 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: 15%{?dist} +Release: 16%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain Group: Development/Debuggers @@ -529,6 +529,9 @@ Patch843: gdb-enable-count-crash.patch # RH BZ 1013453). Patch844: gdb-rhbz1013453-value-struct-elt-memory-leak.patch +# Fix explicit Class:: inside class scope (BZ 874817, Keith Seitz). +Patch845: gdb-implicit-this.patch + %if 0%{!?rhel:1} || 0%{?rhel} > 6 # RL_STATE_FEDORA_GDB would not be found for: # Patch642: gdb-readline62-ask-more-rh.patch @@ -822,6 +825,7 @@ find -name "*.info*"|xargs rm -f %patch832 -p1 %patch843 -p1 %patch844 -p1 +%patch845 -p1 %patch393 -p1 %if 0%{!?el5:1} || 0%{?scl:1} @@ -1340,6 +1344,9 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Sat Nov 9 2013 Jan Kratochvil - 7.6.50.20130731-16.fc20 +- Fix explicit Class:: inside class scope (BZ 874817, Keith Seitz). + * Tue Nov 5 2013 Jan Kratochvil - 7.6.50.20130731-15.fc20 - [aarch64] Backport two fixes (BZ 1026484). From 2bc6944ab312ef525296f6355e5a0be50e43ce97 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Mon, 18 Nov 2013 15:51:05 +0100 Subject: [PATCH 06/10] [rhel7] [--with testsuite] Remove gcc-java&co. BuildRequires. --- gdb.spec | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gdb.spec b/gdb.spec index be5a304..0a88357 100644 --- a/gdb.spec +++ b/gdb.spec @@ -38,7 +38,7 @@ Version: 7.6.50.%{snap} # 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: 16%{?dist} +Release: 17%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain Group: Development/Debuggers @@ -597,7 +597,10 @@ ExclusiveArch: noarch i386 x86_64 ppc ppc64 s390 s390x BuildRequires: sharutils dejagnu # gcc-objc++ is not covered by the GDB testsuite. -BuildRequires: gcc gcc-c++ gcc-gfortran gcc-java gcc-objc +BuildRequires: gcc gcc-c++ gcc-gfortran gcc-objc +%if 0%{!?rhel:1} || 0%{?rhel} < 7 +BuildRequires: gcc-java libgcj%{bits_local} libgcj%{bits_other} +%endif %if 0%{!?rhel:1} || 0%{?rhel} > 6 BuildRequires: gcc-go %endif @@ -628,7 +631,6 @@ BuildRequires: glibc-devel%{bits_local} glibc-devel%{bits_other} BuildRequires: libgcc%{bits_local} libgcc%{bits_other} # libstdc++-devel of matching bits is required only for g++ -static. BuildRequires: libstdc++%{bits_local} libstdc++%{bits_other} -BuildRequires: libgcj%{bits_local} libgcj%{bits_other} %if 0%{!?rhel:1} || 0%{?rhel} > 6 BuildRequires: libgo-devel%{bits_local} libgo-devel%{bits_other} %endif @@ -1344,6 +1346,9 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Mon Nov 18 2013 Jan Kratochvil - 7.6.50.20130731-17.fc20 +- [rhel7] [--with testsuite] Remove gcc-java&co. BuildRequires. + * Sat Nov 9 2013 Jan Kratochvil - 7.6.50.20130731-16.fc20 - Fix explicit Class:: inside class scope (BZ 874817, Keith Seitz). From ab8eb47ebe79054d1213c74da615067a4c644a53 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Wed, 25 Dec 2013 20:52:37 +0100 Subject: [PATCH 07/10] [aarch64] Backport two breakpoint/watchpoint fixes. --- gdb-upstream.patch | 126 +++++++++++++++++++++++++++++++++++++++++++++ gdb.spec | 5 +- 2 files changed, 130 insertions(+), 1 deletion(-) diff --git a/gdb-upstream.patch b/gdb-upstream.patch index 776aa40..da4c127 100644 --- a/gdb-upstream.patch +++ b/gdb-upstream.patch @@ -75,3 +75,129 @@ index 8e66425..bcfcce2 100644 set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_lp64_fetch_link_map_offsets); + + + +pre-req for: +[PATCH, AArch64] Fix bug in hardware watchpoint/breakpoint handling +commit c623a6ef72a8d7dbbb646345f75646710cb9bb68 +Author: Will Newton +Date: Mon Sep 16 14:22:19 2013 +0000 + + gdbserver, aarch64: Zero out regs in aarch64_linux_set_debug_regs. + + Apply the same fix that was applied to aarch64-linux-nat.c. + + 2013-09-16 Will Newton + + * linux-aarch64-low.c (aarch64_linux_set_debug_regs): Zero + out regs. + +diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog +index 73191f4..1082e78 100644 +### a/gdb/gdbserver/ChangeLog +### b/gdb/gdbserver/ChangeLog +## -1,3 +1,8 @@ ++2013-09-16 Will Newton ++ ++ * linux-aarch64-low.c (aarch64_linux_set_debug_regs): Zero ++ out regs. ++ + 2013-09-06 Pedro Alves + + * Makefile.in (gdb_proc_service_h, regdef_h, regcache_h) +diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c +index e37f602..93246b3 100644 +--- a/gdb/gdbserver/linux-aarch64-low.c ++++ b/gdb/gdbserver/linux-aarch64-low.c +@@ -600,6 +600,7 @@ aarch64_linux_set_debug_regs (const struct aarch64_debug_reg_state *state, + const CORE_ADDR *addr; + const unsigned int *ctrl; + ++ memset (®s, 0, sizeof (regs)); + iov.iov_base = ®s; + iov.iov_len = sizeof (regs); + count = watchpoint ? aarch64_num_wp_regs : aarch64_num_bp_regs; + + + +[PATCH, AArch64] Fix bug in hardware watchpoint/breakpoint handling +https://sourceware.org/ml/gdb-patches/2013-12/msg00707.html +commit f45c82da381e0ce5ce51b7fb24d0d28611d266b8 +Author: Yufeng Zhang +Date: Wed Dec 18 16:47:33 2013 +0000 + + gdb/ + + * aarch64-linux-nat.c (aarch64_linux_set_debug_regs): Set + iov.iov_len with the real length in use. + + gdb/gdbserver/ + + * linux-aarch64-low.c (aarch64_linux_set_debug_regs): Set + iov.iov_len with the real length in use. + +diff --git a/gdb/ChangeLog b/gdb/ChangeLog +index 7d9308f..513c593 100644 +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,3 +1,8 @@ ++2013-12-18 Yufeng Zhang ++ ++ * aarch64-linux-nat.c (aarch64_linux_set_debug_regs): Set ++ iov.iov_len with the real length in use. ++ + 2013-12-18 Yao Qi + + * target.h (target_xfer_partial_ftype): New typedef. +diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c +index 256725b..7d76833 100644 +--- a/gdb/aarch64-linux-nat.c ++++ b/gdb/aarch64-linux-nat.c +@@ -314,10 +314,13 @@ aarch64_linux_set_debug_regs (const struct aarch64_debug_reg_state *state, + + memset (®s, 0, sizeof (regs)); + iov.iov_base = ®s; +- iov.iov_len = sizeof (regs); + count = watchpoint ? aarch64_num_wp_regs : aarch64_num_bp_regs; + addr = watchpoint ? state->dr_addr_wp : state->dr_addr_bp; + ctrl = watchpoint ? state->dr_ctrl_wp : state->dr_ctrl_bp; ++ if (count == 0) ++ return; ++ iov.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs[count - 1]) ++ + sizeof (regs.dbg_regs [count - 1])); + + for (i = 0; i < count; i++) + { +diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog +index c73840f..2847796 100644 +### a/gdb/gdbserver/ChangeLog +### b/gdb/gdbserver/ChangeLog +## -1,3 +1,8 @@ ++2013-12-18 Yufeng Zhang ++ ++ * linux-aarch64-low.c (aarch64_linux_set_debug_regs): Set ++ iov.iov_len with the real length in use. ++ + 2013-12-13 Joel Brobecker + + * Makefile.in (safe-ctype.o, lbasename.o): New rules. +diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c +index 93246b3..c2d271a 100644 +--- a/gdb/gdbserver/linux-aarch64-low.c ++++ b/gdb/gdbserver/linux-aarch64-low.c +@@ -602,10 +602,13 @@ aarch64_linux_set_debug_regs (const struct aarch64_debug_reg_state *state, + + memset (®s, 0, sizeof (regs)); + iov.iov_base = ®s; +- iov.iov_len = sizeof (regs); + count = watchpoint ? aarch64_num_wp_regs : aarch64_num_bp_regs; + addr = watchpoint ? state->dr_addr_wp : state->dr_addr_bp; + ctrl = watchpoint ? state->dr_ctrl_wp : state->dr_ctrl_bp; ++ if (count == 0) ++ return; ++ iov.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs[count - 1]) ++ + sizeof (regs.dbg_regs [count - 1])); + + for (i = 0; i < count; i++) + { diff --git a/gdb.spec b/gdb.spec index 0a88357..1067ac8 100644 --- a/gdb.spec +++ b/gdb.spec @@ -38,7 +38,7 @@ Version: 7.6.50.%{snap} # 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: 17%{?dist} +Release: 18%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain Group: Development/Debuggers @@ -1346,6 +1346,9 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Wed Dec 25 2013 Jan Kratochvil - 7.6.50.20130731-18.fc20 +- [aarch64] Backport two breakpoint/watchpoint fixes. + * Mon Nov 18 2013 Jan Kratochvil - 7.6.50.20130731-17.fc20 - [rhel7] [--with testsuite] Remove gcc-java&co. BuildRequires. From b2b7558c354fdbd23534265486560d12958dae88 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sun, 19 Jan 2014 19:36:15 +0100 Subject: [PATCH 08/10] Backport several gdb-7.6.x stable branch fixes (BZ 1055155). --- gdb-6.6-buildid-locate-rpm.patch | 8 +- gdb-6.6-buildid-locate.patch | 12 +- gdb-upstream.patch | 858 +++++++++++++++++++++++++++++++ gdb.spec | 5 +- 4 files changed, 872 insertions(+), 11 deletions(-) diff --git a/gdb-6.6-buildid-locate-rpm.patch b/gdb-6.6-buildid-locate-rpm.patch index 01e560d..3192ee1 100644 --- a/gdb-6.6-buildid-locate-rpm.patch +++ b/gdb-6.6-buildid-locate-rpm.patch @@ -429,17 +429,17 @@ Index: gdb-7.6.50.20130731-cvs/gdb/elfread.c +#ifdef HAVE_LIBRPM + if (missing_exec == MISSING_EXEC_NOT_TRIED) + { -+ char *exec_filename; ++ char *execfilename; - fprintf_unfiltered (gdb_stdlog, - _("Missing separate debuginfo for %s\n"), binary); - if (debug != NULL) - fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"), - debug); -+ exec_filename = get_exec_file (0); -+ if (exec_filename != NULL) ++ execfilename = get_exec_file (0); ++ if (execfilename != NULL) + { -+ if (missing_rpm_enlist (exec_filename) == 0) ++ if (missing_rpm_enlist (execfilename) == 0) + missing_exec = MISSING_EXEC_NOT_FOUND; + else + missing_exec = MISSING_EXEC_ENLISTED; diff --git a/gdb-6.6-buildid-locate.patch b/gdb-6.6-buildid-locate.patch index 2a5517f..0b967fd 100644 --- a/gdb-6.6-buildid-locate.patch +++ b/gdb-6.6-buildid-locate.patch @@ -23,7 +23,7 @@ Index: gdb-7.6.50.20130731-cvs/gdb/corelow.c +{ + CORE_ADDR at_entry; + struct elf_build_id *build_id; -+ char *exec_filename, *debug_filename; ++ char *execfilename, *debug_filename; + char *build_id_filename; + struct cleanup *back_to; + @@ -44,14 +44,14 @@ Index: gdb-7.6.50.20130731-cvs/gdb/corelow.c + file - such .eh_frame would not be found if SYMFILE_OBJFILE would refer + directly to the separate debug info file. */ + -+ exec_filename = build_id_to_filename (build_id, &build_id_filename, 0); ++ execfilename = build_id_to_filename (build_id, &build_id_filename, 0); + make_cleanup (xfree, build_id_filename); + -+ if (exec_filename != NULL) ++ if (execfilename != NULL) + { -+ make_cleanup (xfree, exec_filename); -+ exec_file_attach (exec_filename, from_tty); -+ symbol_file_add_main (exec_filename, from_tty); ++ make_cleanup (xfree, execfilename); ++ exec_file_attach (execfilename, from_tty); ++ symbol_file_add_main (execfilename, from_tty); + if (symfile_objfile != NULL) + symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED; + } diff --git a/gdb-upstream.patch b/gdb-upstream.patch index da4c127..72bcce4 100644 --- a/gdb-upstream.patch +++ b/gdb-upstream.patch @@ -201,3 +201,861 @@ index 93246b3..c2d271a 100644 for (i = 0; i < count; i++) { + + + +commit 9a95e75ee9944cbe6fe3021b92a7c4de87be6fe1 +Author: Yao Qi +Date: Wed Aug 14 11:53:11 2013 +0000 + + gdb/ + + PR gdb/15837: + * frame.h (read_frame_local): Declare. + * mi/mi-cmd-stack.c (list_args_or_locals): Call + read_frame_local. + * stack.c (read_frame_local): New. + +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,3 +1,11 @@ ++2013-08-14 Yao Qi ++ ++ PR gdb/15837: ++ * frame.h (read_frame_local): Declare. ++ * mi/mi-cmd-stack.c (list_args_or_locals): Call ++ read_frame_local. ++ * stack.c (read_frame_local): New. ++ + 2013-06-28 Pedro Alves + + PR tui/14880 +--- a/gdb/frame.h ++++ b/gdb/frame.h +@@ -714,6 +714,8 @@ struct frame_arg + extern void read_frame_arg (struct symbol *sym, struct frame_info *frame, + struct frame_arg *argp, + struct frame_arg *entryargp); ++extern void read_frame_local (struct symbol *sym, struct frame_info *frame, ++ struct frame_arg *argp); + + extern void args_info (char *, int); + +--- a/gdb/mi/mi-cmd-stack.c ++++ b/gdb/mi/mi-cmd-stack.c +@@ -417,7 +417,10 @@ list_args_or_locals (enum what_to_list what, enum print_values values, + && TYPE_CODE (type) != TYPE_CODE_UNION) + { + case PRINT_ALL_VALUES: +- read_frame_arg (sym2, fi, &arg, &entryarg); ++ if (SYMBOL_IS_ARGUMENT (sym)) ++ read_frame_arg (sym2, fi, &arg, &entryarg); ++ else ++ read_frame_local (sym2, fi, &arg); + } + break; + } +--- a/gdb/stack.c ++++ b/gdb/stack.c +@@ -296,6 +296,27 @@ print_frame_arg (const struct frame_arg *arg) + annotate_arg_end (); + } + ++/* Read in inferior function local SYM at FRAME into ARGP. Caller is ++ responsible for xfree of ARGP->ERROR. This function never throws an ++ exception. */ ++ ++void ++read_frame_local (struct symbol *sym, struct frame_info *frame, ++ struct frame_arg *argp) ++{ ++ volatile struct gdb_exception except; ++ struct value *val = NULL; ++ ++ TRY_CATCH (except, RETURN_MASK_ERROR) ++ { ++ val = read_var_value (sym, frame); ++ } ++ ++ argp->error = (val == NULL) ? xstrdup (except.message) : NULL; ++ argp->sym = sym; ++ argp->val = val; ++} ++ + /* Read in inferior function parameter SYM at FRAME into ARGP. Caller is + responsible for xfree of ARGP->ERROR. This function never throws an + exception. */ + + + +commit 4b0f5fbb253fbbe9c2f4578ebd7dd94204a46477 +Author: Jan Kratochvil +Date: Thu Aug 29 14:24:16 2013 +0000 + + PR server/15604 + + gdb/gdbserver/ + 2013-08-29 Jan Kratochvil + + PR server/15604 + * linux-low.c + (linux_create_inferior) : + Close LISTEN_DESC and optionally REMOTE_DESC. + (lynx_create_inferior) : + Close LISTEN_DESC and optionally REMOTE_DESC. + * remote-utils.c (remote_desc, listen_desc): Remove static qualifier. + * server.h (remote_desc, listen_desc): New declaration. + * spu-low.c + (spu_create_inferior) : + Close LISTEN_DESC and optionally REMOTE_DESC. + +### a/gdb/gdbserver/ChangeLog +### b/gdb/gdbserver/ChangeLog +## -1,3 +1,17 @@ ++2013-08-29 Jan Kratochvil ++ ++ PR server/15604 ++ * linux-low.c ++ (linux_create_inferior) : ++ Close LISTEN_DESC and optionally REMOTE_DESC. ++ (lynx_create_inferior) : ++ Close LISTEN_DESC and optionally REMOTE_DESC. ++ * remote-utils.c (remote_desc, listen_desc): Remove static qualifier. ++ * server.h (remote_desc, listen_desc): New declaration. ++ * spu-low.c ++ (spu_create_inferior) : ++ Close LISTEN_DESC and optionally REMOTE_DESC. ++ + 2013-05-31 Doug Evans + + PR server/15594 +--- a/gdb/gdbserver/linux-low.c ++++ b/gdb/gdbserver/linux-low.c +@@ -668,6 +668,12 @@ linux_create_inferior (char *program, char **allargs) + /* Errors ignored. */; + } + } ++ else ++ { ++ close (listen_desc); ++ if (gdb_connected ()) ++ close (remote_desc); ++ } + + execv (program, allargs); + if (errno == ENOENT) +--- a/gdb/gdbserver/lynx-low.c ++++ b/gdb/gdbserver/lynx-low.c +@@ -218,6 +218,12 @@ lynx_create_inferior (char *program, char **allargs) + pgrp = getpid(); + setpgid (0, pgrp); + ioctl (0, TIOCSPGRP, &pgrp); ++ if (!remote_connection_is_stdio ()) ++ { ++ close (listen_desc); ++ if (gdb_connected ()) ++ close (remote_desc); ++ } + lynx_ptrace (PTRACE_TRACEME, null_ptid, 0, 0, 0); + execv (program, allargs); + fprintf (stderr, "Cannot exec %s: %s.\n", program, strerror (errno)); +--- a/gdb/gdbserver/remote-utils.c ++++ b/gdb/gdbserver/remote-utils.c +@@ -108,8 +108,8 @@ struct ui_file *gdb_stdlog; + + static int remote_is_stdio = 0; + +-static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR; +-static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR; ++gdb_fildes_t remote_desc = INVALID_DESCRIPTOR; ++gdb_fildes_t listen_desc = INVALID_DESCRIPTOR; + + /* FIXME headerize? */ + extern int using_threads; +--- a/gdb/gdbserver/server.h ++++ b/gdb/gdbserver/server.h +@@ -274,6 +274,8 @@ extern void hostio_last_error_from_errno (char *own_buf); + /* From remote-utils.c */ + + extern int remote_debug; ++extern gdb_fildes_t remote_desc; ++extern gdb_fildes_t listen_desc; + extern int noack_mode; + extern int transport_is_reliable; + +--- a/gdb/gdbserver/spu-low.c ++++ b/gdb/gdbserver/spu-low.c +@@ -273,6 +273,12 @@ spu_create_inferior (char *program, char **allargs) + + if (pid == 0) + { ++ if (!remote_connection_is_stdio ()) ++ { ++ close (listen_desc); ++ if (gdb_connected ()) ++ close (remote_desc); ++ } + ptrace (PTRACE_TRACEME, 0, 0, 0); + + setpgid (0, 0); + + + +commit 510604eee7892c54d98eefa2893afb823c721406 +Author: Jan Kratochvil +Date: Wed Aug 28 17:55:56 2013 +0000 + + PR gdb/15415 + + gdb/ + 2013-08-27 Jan Kratochvil + + PR gdb/15415 + * corefile.c (get_exec_file): Use exec_filename. + * defs.h (OPF_DISABLE_REALPATH): New definition. Add new comment. + * exec.c (exec_close): Free EXEC_FILENAME. + (exec_file_attach): New variable canonical_pathname. Use + OPF_DISABLE_REALPATH. Call gdb_realpath explicitly. Set + EXEC_FILENAME. + * exec.h (exec_filename): New. + * inferior.c (print_inferior, inferior_command): Use + PSPACE_EXEC_FILENAME. + * mi/mi-main.c (print_one_inferior): Likewise. + * progspace.c (clone_program_space, print_program_space): Likewise. + * progspace.h (struct program_space): New field pspace_exec_filename. + * source.c (openp): Describe OPF_DISABLE_REALPATH. New variable + realpath_fptr, initialize it from OPF_DISABLE_REALPATH, use it. + + gdb/testsuite/ + 2013-08-27 Jan Kratochvil + + PR gdb/15415 + * gdb.base/argv0-symlink.c: New file. + * gdb.base/argv0-symlink.exp: New file. + +diff -dup -ruNp gdb-7.6.50.20130731-cvs-orig/gdb/corefile.c gdb-7.6.50.20130731-cvs/gdb/corefile.c +--- gdb-7.6.50.20130731-cvs-orig/gdb/corefile.c 2013-07-31 21:41:54.000000000 +0200 ++++ gdb-7.6.50.20130731-cvs/gdb/corefile.c 2014-01-19 16:24:46.238323054 +0100 +@@ -182,8 +182,8 @@ validate_files (void) + char * + get_exec_file (int err) + { +- if (exec_bfd) +- return bfd_get_filename (exec_bfd); ++ if (exec_filename) ++ return exec_filename; + if (!err) + return NULL; + +diff -dup -ruNp gdb-7.6.50.20130731-cvs-orig/gdb/defs.h gdb-7.6.50.20130731-cvs/gdb/defs.h +--- gdb-7.6.50.20130731-cvs-orig/gdb/defs.h 2013-07-31 21:41:54.000000000 +0200 ++++ gdb-7.6.50.20130731-cvs/gdb/defs.h 2014-01-19 16:24:46.239323054 +0100 +@@ -346,8 +346,10 @@ extern const char *pc_prefix (CORE_ADDR) + + /* From source.c */ + ++/* See openp function definition for their description. */ + #define OPF_TRY_CWD_FIRST 0x01 + #define OPF_SEARCH_IN_PATH 0x02 ++#define OPF_DISABLE_REALPATH 0x04 + + extern int openp (const char *, int, const char *, int, char **); + +diff -dup -ruNp gdb-7.6.50.20130731-cvs-orig/gdb/exec.c gdb-7.6.50.20130731-cvs/gdb/exec.c +--- gdb-7.6.50.20130731-cvs-orig/gdb/exec.c 2013-07-31 21:41:54.000000000 +0200 ++++ gdb-7.6.50.20130731-cvs/gdb/exec.c 2014-01-19 16:25:18.616315354 +0100 +@@ -102,6 +102,9 @@ exec_close (void) + exec_bfd_mtime = 0; + + remove_target_sections (&exec_bfd); ++ ++ xfree (exec_filename); ++ exec_filename = NULL; + } + } + +@@ -179,12 +182,13 @@ exec_file_attach (char *filename, int fr + else + { + struct cleanup *cleanups; +- char *scratch_pathname; ++ char *scratch_pathname, *canonical_pathname; + int scratch_chan; + struct target_section *sections = NULL, *sections_end = NULL; + char **matching; + +- scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, filename, ++ scratch_chan = openp (getenv ("PATH"), ++ OPF_TRY_CWD_FIRST | OPF_DISABLE_REALPATH, filename, + write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY, + &scratch_pathname); + #if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__) +@@ -193,7 +197,9 @@ exec_file_attach (char *filename, int fr + char *exename = alloca (strlen (filename) + 5); + + strcat (strcpy (exename, filename), ".exe"); +- scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, exename, ++ scratch_chan = openp (getenv ("PATH"), ++ OPF_TRY_CWD_FIRST | OPF_DISABLE_REALPATH, ++ exename, + write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY, + &scratch_pathname); + } +@@ -203,11 +209,16 @@ exec_file_attach (char *filename, int fr + + cleanups = make_cleanup (xfree, scratch_pathname); + ++ /* gdb_bfd_open (and its variants) prefers canonicalized pathname for ++ better BFD caching. */ ++ canonical_pathname = gdb_realpath (scratch_pathname); ++ make_cleanup (xfree, canonical_pathname); ++ + if (write_files) +- exec_bfd = gdb_bfd_fopen (scratch_pathname, gnutarget, ++ exec_bfd = gdb_bfd_fopen (canonical_pathname, gnutarget, + FOPEN_RUB, scratch_chan); + else +- exec_bfd = gdb_bfd_open (scratch_pathname, gnutarget, scratch_chan); ++ exec_bfd = gdb_bfd_open (canonical_pathname, gnutarget, scratch_chan); + + if (!exec_bfd) + { +@@ -215,6 +226,9 @@ exec_file_attach (char *filename, int fr + scratch_pathname, bfd_errmsg (bfd_get_error ())); + } + ++ gdb_assert (exec_filename == NULL); ++ exec_filename = xstrdup (scratch_pathname); ++ + if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching)) + { + /* Make sure to close exec_bfd, or else "run" might try to use +diff -dup -ruNp gdb-7.6.50.20130731-cvs-orig/gdb/exec.h gdb-7.6.50.20130731-cvs/gdb/exec.h +--- gdb-7.6.50.20130731-cvs-orig/gdb/exec.h 2013-07-31 21:41:54.000000000 +0200 ++++ gdb-7.6.50.20130731-cvs/gdb/exec.h 2014-01-19 16:24:46.262323049 +0100 +@@ -32,6 +32,7 @@ extern struct target_ops exec_ops; + + #define exec_bfd current_program_space->ebfd + #define exec_bfd_mtime current_program_space->ebfd_mtime ++#define exec_filename current_program_space->pspace_exec_filename + + /* Builds a section table, given args BFD, SECTABLE_PTR, SECEND_PTR. + Returns 0 if OK, 1 on error. */ +diff -dup -ruNp gdb-7.6.50.20130731-cvs-orig/gdb/inferior.c gdb-7.6.50.20130731-cvs/gdb/inferior.c +--- gdb-7.6.50.20130731-cvs-orig/gdb/inferior.c 2013-07-31 21:41:54.000000000 +0200 ++++ gdb-7.6.50.20130731-cvs/gdb/inferior.c 2014-01-19 16:24:46.264323048 +0100 +@@ -588,9 +588,8 @@ print_inferior (struct ui_out *uiout, ch + ui_out_field_string (uiout, "target-id", + inferior_pid_to_str (inf->pid)); + +- if (inf->pspace->ebfd) +- ui_out_field_string (uiout, "exec", +- bfd_get_filename (inf->pspace->ebfd)); ++ if (inf->pspace->pspace_exec_filename != NULL) ++ ui_out_field_string (uiout, "exec", inf->pspace->pspace_exec_filename); + else + ui_out_field_skip (uiout, "exec"); + +@@ -704,8 +703,8 @@ inferior_command (char *args, int from_t + printf_filtered (_("[Switching to inferior %d [%s] (%s)]\n"), + inf->num, + inferior_pid_to_str (inf->pid), +- (inf->pspace->ebfd +- ? bfd_get_filename (inf->pspace->ebfd) ++ (inf->pspace->pspace_exec_filename != NULL ++ ? inf->pspace->pspace_exec_filename + : _(""))); + + if (inf->pid != 0) +diff -dup -ruNp gdb-7.6.50.20130731-cvs-orig/gdb/mi/mi-main.c gdb-7.6.50.20130731-cvs/gdb/mi/mi-main.c +--- gdb-7.6.50.20130731-cvs-orig/gdb/mi/mi-main.c 2013-07-31 21:41:54.000000000 +0200 ++++ gdb-7.6.50.20130731-cvs/gdb/mi/mi-main.c 2014-01-19 16:24:46.273323046 +0100 +@@ -573,10 +573,10 @@ print_one_inferior (struct inferior *inf + if (inferior->pid != 0) + ui_out_field_int (uiout, "pid", inferior->pid); + +- if (inferior->pspace->ebfd) ++ if (inferior->pspace->pspace_exec_filename != NULL) + { + ui_out_field_string (uiout, "executable", +- bfd_get_filename (inferior->pspace->ebfd)); ++ inferior->pspace->pspace_exec_filename); + } + + data.cores = 0; +diff -dup -ruNp gdb-7.6.50.20130731-cvs-orig/gdb/progspace.c gdb-7.6.50.20130731-cvs/gdb/progspace.c +--- gdb-7.6.50.20130731-cvs-orig/gdb/progspace.c 2013-01-02 02:54:56.000000000 +0100 ++++ gdb-7.6.50.20130731-cvs/gdb/progspace.c 2014-01-19 16:24:46.275323045 +0100 +@@ -196,8 +196,8 @@ clone_program_space (struct program_spac + + set_current_program_space (dest); + +- if (src->ebfd != NULL) +- exec_file_attach (bfd_get_filename (src->ebfd), 0); ++ if (src->pspace_exec_filename != NULL) ++ exec_file_attach (src->pspace_exec_filename, 0); + + if (src->symfile_object_file != NULL) + symbol_file_add_main (src->symfile_object_file->name, 0); +@@ -336,9 +336,8 @@ print_program_space (struct ui_out *uiou + + ui_out_field_int (uiout, "id", pspace->num); + +- if (pspace->ebfd) +- ui_out_field_string (uiout, "exec", +- bfd_get_filename (pspace->ebfd)); ++ if (pspace->pspace_exec_filename) ++ ui_out_field_string (uiout, "exec", pspace->pspace_exec_filename); + else + ui_out_field_skip (uiout, "exec"); + +diff -dup -ruNp gdb-7.6.50.20130731-cvs-orig/gdb/progspace.h gdb-7.6.50.20130731-cvs/gdb/progspace.h +--- gdb-7.6.50.20130731-cvs-orig/gdb/progspace.h 2013-01-02 02:54:56.000000000 +0100 ++++ gdb-7.6.50.20130731-cvs/gdb/progspace.h 2014-01-19 16:24:46.276323045 +0100 +@@ -148,6 +148,10 @@ struct program_space + bfd *ebfd; + /* The last-modified time, from when the exec was brought in. */ + long ebfd_mtime; ++ /* Similar to bfd_get_filename (exec_bfd) but in original form given ++ by user, without symbolic links and pathname resolved. ++ It needs to be freed by xfree. It is not NULL iff EBFD is not NULL. */ ++ char *pspace_exec_filename; + + /* The address space attached to this program space. More than one + program space may be bound to the same address space. In the +diff -dup -ruNp gdb-7.6.50.20130731-cvs-orig/gdb/source.c gdb-7.6.50.20130731-cvs/gdb/source.c +--- gdb-7.6.50.20130731-cvs-orig/gdb/source.c 2013-07-31 21:41:54.000000000 +0200 ++++ gdb-7.6.50.20130731-cvs/gdb/source.c 2014-01-19 16:24:46.278323045 +0100 +@@ -692,6 +692,11 @@ is_regular_file (const char *name) + and the file, sigh! Emacs gets confuzzed by this when we print the + source file name!!! + ++ If OPTS does not have OPF_DISABLE_REALPATH set return FILENAME_OPENED ++ resolved by gdb_realpath. Even with OPF_DISABLE_REALPATH this function ++ still returns filename starting with "/". If FILENAME_OPENED is NULL ++ this option has no effect. ++ + If a file is found, return the descriptor. + Otherwise, return -1, with errno set for the last name we tried to open. */ + +@@ -851,19 +856,27 @@ done: + /* If a file was opened, canonicalize its filename. */ + if (fd < 0) + *filename_opened = NULL; +- else if (IS_ABSOLUTE_PATH (filename)) +- *filename_opened = gdb_realpath (filename); + else + { +- /* Beware the // my son, the Emacs barfs, the botch that catch... */ ++ char *(*realpath_fptr) (const char *); + +- char *f = concat (current_directory, +- IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1]) +- ? "" : SLASH_STRING, +- filename, (char *)NULL); ++ realpath_fptr = ((opts & OPF_DISABLE_REALPATH) != 0 ++ ? xstrdup : gdb_realpath); + +- *filename_opened = gdb_realpath (f); +- xfree (f); ++ if (IS_ABSOLUTE_PATH (filename)) ++ *filename_opened = realpath_fptr (filename); ++ else ++ { ++ /* Beware the // my son, the Emacs barfs, the botch that catch... */ ++ ++ char *f = concat (current_directory, ++ IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1]) ++ ? "" : SLASH_STRING, ++ filename, (char *)NULL); ++ ++ *filename_opened = realpath_fptr (f); ++ xfree (f); ++ } + } + } + +diff -dup -ruNp gdb-7.6.50.20130731-cvs-orig/gdb/testsuite/gdb.base/argv0-symlink.c gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.base/argv0-symlink.c +--- gdb-7.6.50.20130731-cvs-orig/gdb/testsuite/gdb.base/argv0-symlink.c 1970-01-01 01:00:00.000000000 +0100 ++++ gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.base/argv0-symlink.c 2014-01-19 16:24:46.286323043 +0100 +@@ -0,0 +1,22 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2013 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 . */ ++ ++int ++main (int argc, char **argv) ++{ ++ return 0; ++} +diff -dup -ruNp gdb-7.6.50.20130731-cvs-orig/gdb/testsuite/gdb.base/argv0-symlink.exp gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.base/argv0-symlink.exp +--- gdb-7.6.50.20130731-cvs-orig/gdb/testsuite/gdb.base/argv0-symlink.exp 1970-01-01 01:00:00.000000000 +0100 ++++ gdb-7.6.50.20130731-cvs/gdb/testsuite/gdb.base/argv0-symlink.exp 2014-01-19 16:24:46.287323043 +0100 +@@ -0,0 +1,62 @@ ++# Copyright 2013 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 . ++ ++standard_testfile ++ ++if { [build_executable ${testfile}.exp ${testfile} ${srcfile}] == -1 } { ++ return -1 ++} ++ ++set test "kept file symbolic link name" ++set filelink "${testfile}-filelink" ++ ++remote_file host delete [standard_output_file $filelink] ++set status [remote_exec host "ln -sf ${testfile} [standard_output_file $filelink]"] ++if {[lindex $status 0] != 0} { ++ unsupported "$test (host does not support symbolic links)" ++ return 0 ++} ++ ++clean_restart "$filelink" ++ ++if ![runto_main] { ++ untested "could not run to main" ++ return -1 ++} ++ ++gdb_test {print argv[0]} "/$filelink\"" $test ++ ++ ++set test "kept directory symbolic link name" ++set dirlink "${testfile}-dirlink" ++ ++# 'ln -sf' does not overwrite symbol link to a directory. ++# 'remote_file host delete' uses stat (not lstat), therefore it refuses to ++# delete a directory. ++remote_exec host "rm -f [standard_output_file $dirlink]" ++set status [remote_exec host "ln -sf . [standard_output_file $dirlink]"] ++if {[lindex $status 0] != 0} { ++ unsupported "$test (host does not support symbolic links)" ++ return 0 ++} ++ ++clean_restart "$dirlink/$filelink" ++ ++if ![runto_main] { ++ untested "could not run to main" ++ return -1 ++} ++ ++gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test + + + +commit 4856b6bc835e25ab0f48462104152701c864858c +Author: Jan Kratochvil +Date: Sun Oct 13 16:11:08 2013 +0000 + + Improve Executable displayed path (PR 15415 regression kind #2) + + gdb/ + 2013-10-13 Jan Kratochvil + + Canonicalize directories for EXEC_FILENAME. + * exec.c (exec_file_attach): Use gdb_realpath_keepfile for + exec_filename. + * utils.c (gdb_realpath_keepfile): New function. + * utils.h (gdb_realpath_keepfile): New declaration. + + gdb/testsuite/ + 2013-10-13 Jan Kratochvil + + Canonicalize directories for EXEC_FILENAME. + * gdb.base/argv0-symlink.exp + (kept file symbolic link name for info inferiors): New. + (kept directory symbolic link name): Setup kfail. + (kept directory symbolic link name for info inferiors): New. + +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,3 +1,11 @@ ++2013-10-13 Jan Kratochvil ++ ++ Canonicalize directories for EXEC_FILENAME. ++ * exec.c (exec_file_attach): Use gdb_realpath_keepfile for ++ exec_filename. ++ * utils.c (gdb_realpath_keepfile): New function. ++ * utils.h (gdb_realpath_keepfile): New declaration. ++ + 2013-10-11 Doug Evans + + * Makefile.in (GDBFLAGS): New variable. +--- a/gdb/exec.c ++++ b/gdb/exec.c +@@ -224,7 +224,7 @@ exec_file_attach (char *filename, int from_tty) + } + + gdb_assert (exec_filename == NULL); +- exec_filename = xstrdup (scratch_pathname); ++ exec_filename = gdb_realpath_keepfile (scratch_pathname); + + if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching)) + { +### a/gdb/testsuite/ChangeLog +### b/gdb/testsuite/ChangeLog +## -1,3 +1,11 @@ ++2013-10-13 Jan Kratochvil ++ ++ Canonicalize directories for EXEC_FILENAME. ++ * gdb.base/argv0-symlink.exp ++ (kept file symbolic link name for info inferiors): New. ++ (kept directory symbolic link name): Setup kfail. ++ (kept directory symbolic link name for info inferiors): New. ++ + 2013-10-11 Andreas Arnez + + * gdb.arch/s390-multiarch.exp: New file. +--- a/gdb/testsuite/gdb.base/argv0-symlink.exp ++++ b/gdb/testsuite/gdb.base/argv0-symlink.exp +@@ -37,6 +37,7 @@ if ![runto_main] { + } + + gdb_test {print argv[0]} "/$filelink\"" $test ++gdb_test "info inferiors" "/$subdir/$filelink *" "$test for info inferiors" + + + set test "kept directory symbolic link name" +@@ -59,4 +60,9 @@ if ![runto_main] { + return -1 + } + ++# gdbserver does not have this issue. ++if ![is_remote target] { ++ setup_kfail "*-*-*" gdb/15934 ++} + gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test ++gdb_test "info inferiors" "/$subdir/$filelink *" "$test for info inferiors" +--- a/gdb/utils.c ++++ b/gdb/utils.c +@@ -3233,6 +3233,52 @@ gdb_realpath (const char *filename) + return xstrdup (filename); + } + ++/* Return a copy of FILENAME, with its directory prefix canonicalized ++ by gdb_realpath. */ ++ ++char * ++gdb_realpath_keepfile (const char *filename) ++{ ++ const char *base_name = lbasename (filename); ++ char *dir_name; ++ char *real_path; ++ char *result; ++ ++ /* Extract the basename of filename, and return immediately ++ a copy of filename if it does not contain any directory prefix. */ ++ if (base_name == filename) ++ return xstrdup (filename); ++ ++ dir_name = alloca ((size_t) (base_name - filename + 2)); ++ /* Allocate enough space to store the dir_name + plus one extra ++ character sometimes needed under Windows (see below), and ++ then the closing \000 character. */ ++ strncpy (dir_name, filename, base_name - filename); ++ dir_name[base_name - filename] = '\000'; ++ ++#ifdef HAVE_DOS_BASED_FILE_SYSTEM ++ /* We need to be careful when filename is of the form 'd:foo', which ++ is equivalent of d:./foo, which is totally different from d:/foo. */ ++ if (strlen (dir_name) == 2 && isalpha (dir_name[0]) && dir_name[1] == ':') ++ { ++ dir_name[2] = '.'; ++ dir_name[3] = '\000'; ++ } ++#endif ++ ++ /* Canonicalize the directory prefix, and build the resulting ++ filename. If the dirname realpath already contains an ending ++ directory separator, avoid doubling it. */ ++ real_path = gdb_realpath (dir_name); ++ if (IS_DIR_SEPARATOR (real_path[strlen (real_path) - 1])) ++ result = concat (real_path, base_name, (char *) NULL); ++ else ++ result = concat (real_path, SLASH_STRING, base_name, (char *) NULL); ++ ++ xfree (real_path); ++ return result; ++} ++ + ULONGEST + align_up (ULONGEST v, int n) + { +--- a/gdb/utils.h ++++ b/gdb/utils.h +@@ -128,6 +128,8 @@ extern struct cleanup *make_bpstat_clear_actions_cleanup (void); + + extern char *gdb_realpath (const char *); + ++extern char *gdb_realpath_keepfile (const char *); ++ + extern int gdb_filename_fnmatch (const char *pattern, const char *string, + int flags); + + + + +commit 24890efdabbd9d827cdd2088b022f070da04b14f +Author: Tom Tromey +Date: Fri Oct 18 13:12:32 2013 -0600 + + fix argv0-symlink.exp for parallel mode + + argv0-symlink.exp doesn't work properly if standard_output_file puts + files into a per-test subdirectory. That's because it assumes that + files appear in $subdir, which is no longer true. + + This patch fixes the problem by computing the correct directory at + runtime. + + Tested both with and without GDB_PARALLEL on x86-64 Fedora 18. + + 2013-11-04 Tom Tromey + + * gdb.base/argv0-symlink.exp: Compute executable's directory + dynamically. + +### a/gdb/testsuite/ChangeLog +### b/gdb/testsuite/ChangeLog +## -1,5 +1,10 @@ + 2013-11-04 Tom Tromey + ++ * gdb.base/argv0-symlink.exp: Compute executable's directory ++ dynamically. ++ ++2013-11-04 Tom Tromey ++ + * gdb.asm/asm-source.exp: Use standard_output_file. + + 2013-11-04 Tom Tromey +--- a/gdb/testsuite/gdb.base/argv0-symlink.exp ++++ b/gdb/testsuite/gdb.base/argv0-symlink.exp +@@ -37,7 +37,14 @@ if ![runto_main] { + } + + gdb_test {print argv[0]} "/$filelink\"" $test +-gdb_test "info inferiors" "/$subdir/$filelink *" "$test for info inferiors" ++ ++# For a link named /PATH/TO/DIR/LINK, we want to check the output ++# against "/DIR/LINK", but computed in a way that doesn't make ++# assumptions about the test directory layout. ++set full_filelink [standard_output_file $filelink] ++set lastdir [file tail [file dirname $full_filelink]] ++ ++gdb_test "info inferiors" "/$lastdir/$filelink *" "$test for info inferiors" + + + set test "kept directory symbolic link name" +@@ -65,4 +72,4 @@ if ![is_remote target] { + setup_kfail "*-*-*" gdb/15934 + } + gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test +-gdb_test "info inferiors" "/$subdir/$filelink *" "$test for info inferiors" ++gdb_test "info inferiors" "/$lastdir/$filelink *" "$test for info inferiors" + + + +http://sourceware.org/ml/gdb-patches/2014-01/msg00722.html +Subject: [patch] Fix gdb.base/argv0-symlink.exp FAIL in long dirpath + + +--VbJkn9YxBvnuCH5J +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline + +Hi, + +when you build GDB in a very long directory pathname it will: + +(gdb) print argv[0] +$1 = 0x7fffffffdb07 "/home/jkratoch/redhat/", 'x' ... +(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name + +With the fix: + +(gdb) print argv[0] +$1 = 0x7fffffffdb07 "/home/jkratoch/redhat/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/gdb-test/gdb/testsuite/gdb.base/argv0-symlink-filelink" +(gdb) PASS: gdb.base/argv0-symlink.exp: kept file symbolic link name + +The "set print repeats unlimited" part is there to prevent the following +output, it would still PASS (as only its tail is matched) but it is not much +correct. + +(gdb) print argv[0] +$1 = 0x7fffffffdb07 "/home/jkratoch/redhat/", 'x' , "/gdb-test/gdb/testsuite/gdb.base/argv0-symlink-filelink" +(gdb) PASS: gdb.base/argv0-symlink.exp: kept file symbolic link name + +I will check it in. + +Tested on x86_64-fedora20-linux-gnu. + + +Jan + +--VbJkn9YxBvnuCH5J +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline; filename="argv0.patch" + +gdb/testsuite/ +2014-01-19 Jan Kratochvil + + Fix gdb.base/argv0-symlink.exp FAIL in long dirpath. + * gdb.base/argv0-symlink.exp (elements first, repeats first) + (elements second, repeats second): New. + +diff --git a/gdb/testsuite/gdb.base/argv0-symlink.exp b/gdb/testsuite/gdb.base/argv0-symlink.exp +index 0e0202d..7bf5c2f 100644 +--- a/gdb/testsuite/gdb.base/argv0-symlink.exp ++++ b/gdb/testsuite/gdb.base/argv0-symlink.exp +@@ -36,6 +36,10 @@ if ![runto_main] { + return -1 + } + ++# Very long directory paths could be cut below. ++gdb_test_no_output "set print elements unlimited" "elements first" ++gdb_test_no_output "set print repeats unlimited" "repeats first" ++ + gdb_test {print argv[0]} "/$filelink\"" $test + + # For a link named /PATH/TO/DIR/LINK, we want to check the output +@@ -67,6 +71,10 @@ if ![runto_main] { + return -1 + } + ++# Very long directory paths could be cut below. ++gdb_test_no_output "set print elements unlimited" "elements second" ++gdb_test_no_output "set print repeats unlimited" "repeats second" ++ + # gdbserver does not have this issue. + if ![is_remote target] { + setup_kfail "*-*-*" gdb/15934 + +--VbJkn9YxBvnuCH5J-- + diff --git a/gdb.spec b/gdb.spec index 1067ac8..cac3ebb 100644 --- a/gdb.spec +++ b/gdb.spec @@ -38,7 +38,7 @@ Version: 7.6.50.%{snap} # 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: 18%{?dist} +Release: 19%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain Group: Development/Debuggers @@ -1346,6 +1346,9 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Sun Jan 19 2014 Jan Kratochvil - 7.6.50.20140119-19.fc20 +- Backport several gdb-7.6.x stable branch fixes (BZ 1055155). + * Wed Dec 25 2013 Jan Kratochvil - 7.6.50.20130731-18.fc20 - [aarch64] Backport two breakpoint/watchpoint fixes. From ac10ee0d483f17dc7b0eff4c55177a401290ec1e Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Thu, 23 Jan 2014 20:43:11 +0100 Subject: [PATCH 09/10] [s390*,ppc*] Enable secondary targets s390* and ppc* (BZ 1056259). --- gdb.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gdb.spec b/gdb.spec index cac3ebb..4d5a30e 100644 --- a/gdb.spec +++ b/gdb.spec @@ -38,7 +38,7 @@ Version: 7.6.50.%{snap} # 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: 19%{?dist} +Release: 20%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain Group: Development/Debuggers @@ -964,7 +964,7 @@ $(: It breaks RHEL-5 by %{_target_platform} being noarch-redhat-linux-gnu ) \ %ifarch noarch $(:) %else - --enable-targets=arm-linux-gnu,aarch64-linux-gnu \ + --enable-targets=s390-linux-gnu,powerpc-linux-gnu,arm-linux-gnu,aarch64-linux-gnu \ %{_target_platform} %endif %endif @@ -1346,6 +1346,9 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Thu Jan 23 2014 Jan Kratochvil - 7.6.50.20140119-20.fc20 +- [s390*,ppc*] Enable secondary targets s390* and ppc* (BZ 1056259). + * Sun Jan 19 2014 Jan Kratochvil - 7.6.50.20140119-19.fc20 - Backport several gdb-7.6.x stable branch fixes (BZ 1055155). From 1ec4463ac77482c4555de152567156a8c6f3ee5a Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Mon, 24 Feb 2014 22:54:23 +0100 Subject: [PATCH 10/10] Fix crash of -readnow /usr/lib/debug/usr/bin/gnatbind.debug (BZ 1069211). --- gdb-gnat-dwarf-crash-1of3.patch | 451 ++++++++++++++++++++++++++++++++ gdb-gnat-dwarf-crash-2of3.patch | 125 +++++++++ gdb-gnat-dwarf-crash-3of3.patch | 58 ++++ gdb.spec | 13 +- 4 files changed, 646 insertions(+), 1 deletion(-) create mode 100644 gdb-gnat-dwarf-crash-1of3.patch create mode 100644 gdb-gnat-dwarf-crash-2of3.patch create mode 100644 gdb-gnat-dwarf-crash-3of3.patch diff --git a/gdb-gnat-dwarf-crash-1of3.patch b/gdb-gnat-dwarf-crash-1of3.patch new file mode 100644 index 0000000..efad332 --- /dev/null +++ b/gdb-gnat-dwarf-crash-1of3.patch @@ -0,0 +1,451 @@ +commit adde2bff0757e89175ede493f03b86953d0d9352 +Author: Doug Evans +Date: Thu Feb 20 09:13:53 2014 -0800 + + Fix PR symtab/16581 + + * dwarf2read.c (struct die_info): New member in_process. + (reset_die_in_process): New function. + (process_die): Set it at the start, reset when returning. + (inherit_abstract_dies): Only call process_die if origin_child_die + not already being processed. + + testsuite/ + * gdb.dwarf2/dw2-icycle.S: New file. + * gdb.dwarf2/dw2-icycle.c: New file. + * gdb.dwarf2/dw2-icycle.exp: New file. + +### a/gdb/ChangeLog +### b/gdb/ChangeLog +## -1,3 +1,14 @@ ++2014-02-20 lin zuojian ++ Joel Brobecker ++ Doug Evans ++ ++ PR symtab/16581 ++ * dwarf2read.c (struct die_info): New member in_process. ++ (reset_die_in_process): New function. ++ (process_die): Set it at the start, reset when returning. ++ (inherit_abstract_dies): Only call process_die if origin_child_die ++ not already being processed. ++ + 2014-02-20 Joel Brobecker + + * windows-nat.c (handle_unload_dll): Add function documentation. +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -1225,6 +1225,9 @@ struct die_info + type derived from this DIE. */ + unsigned char building_fullname : 1; + ++ /* True if this die is in process. PR 16581. */ ++ unsigned char in_process : 1; ++ + /* Abbrev number */ + unsigned int abbrev; + +@@ -8008,11 +8011,28 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu) + } + } + ++/* Reset the in_process bit of a die. */ ++ ++static void ++reset_die_in_process (void *arg) ++{ ++ struct die_info *die = arg; ++ die->in_process = 0; ++} ++ + /* Process a die and its children. */ + + static void + process_die (struct die_info *die, struct dwarf2_cu *cu) + { ++ struct cleanup *in_process; ++ ++ /* We should only be processing those not already in process. */ ++ gdb_assert (!die->in_process); ++ ++ die->in_process = 1; ++ in_process = make_cleanup (reset_die_in_process,die); ++ + switch (die->tag) + { + case DW_TAG_padding: +@@ -7762,6 +7782,8 @@ process_die (struct die_info *die, struc + new_symbol (die, NULL, cu); + break; + } ++ ++ do_cleanups (in_process); + } + + /* DWARF name computation. */ +@@ -10967,8 +10989,12 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu) + if (offsetp >= offsets_end + || offsetp->sect_off > origin_child_die->offset.sect_off) + { +- /* Found that ORIGIN_CHILD_DIE is really not referenced. */ +- process_die (origin_child_die, origin_cu); ++ /* Found that ORIGIN_CHILD_DIE is really not referenced. ++ Check whether we're already processing ORIGIN_CHILD_DIE. ++ This can happen with mutually referenced abstract_origins. ++ PR 16581. */ ++ if (!origin_child_die->in_process) ++ process_die (origin_child_die, origin_cu); + } + origin_child_die = sibling_die (origin_child_die); + } +### a/gdb/testsuite/ChangeLog +### b/gdb/testsuite/ChangeLog +## -1,3 +1,12 @@ ++2014-02-20 lin zuojian ++ Joel Brobecker ++ Doug Evans ++ ++ PR symtab/16581 ++ * gdb.dwarf2/dw2-icycle.S: New file. ++ * gdb.dwarf2/dw2-icycle.c: New file. ++ * gdb.dwarf2/dw2-icycle.exp: New file. ++ + 2014-02-19 Siva Chandra Reddy + + * gdb.python/py-value-cc.cc: Improve test case to enable testing +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-icycle.S +@@ -0,0 +1,258 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2014 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 . */ ++ ++ .text ++ ++.Ltext0: ++ .type p__top__middle__inside.3062, @function ++p__top__middle__inside.3062: ++.LFB4: ++ .file 1 "p.adb" ++ .4byte 0 ++.LBE6: ++ ++ .globl p__top ++ .type p__top, @function ++p__top: ++.LFB2: ++ .4byte 0 ++.LFE2: ++.Letext0: ++ ++ .section .debug_info,"",@progbits ++.Ldebug_info0: ++ .4byte .Ledebug_info0 - .Lsdebug_info0 /* Length of CU Info */ ++.Lsdebug_info0: ++ .2byte 0x4 /* DWARF version number */ ++ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */ ++ .byte 0x4 /* Pointer Size (in bytes) */ ++ .uleb128 0x1 /* (DIE (0xb) DW_TAG_compile_unit) */ ++ .ascii "GNU Ada 4.9.0 20140126\0" /* DW_AT_producer */ ++ .byte 0xd /* DW_AT_language */ ++ .ascii "p.adb\0" /* DW_AT_name */ ++ .ascii "/tmp\0" /* DW_AT_comp_dir */ ++ .4byte .Ltext0 /* DW_AT_low_pc */ ++ .4byte .Letext0-.Ltext0 /* DW_AT_high_pc */ ++.S0x142: ++ .uleb128 0x8 /* (DIE (0x142) DW_TAG_base_type) */ ++ .byte 0x4 /* DW_AT_byte_size */ ++ .byte 0x5 /* DW_AT_encoding */ ++ .ascii "integer\0" /* DW_AT_name */ ++ ++ .uleb128 0x13 /* (DIE (0x1b4) DW_TAG_subprogram) */ ++ /* DW_AT_external */ ++ .ascii "p__top\0" /* DW_AT_name */ ++ .byte 0x1 /* DW_AT_decl_file (p.adb) */ ++ .byte 0x3 /* DW_AT_decl_line */ ++ .4byte .LFB2 /* DW_AT_low_pc */ ++ .4byte .LFE2-.LFB2 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_AT_frame_base */ ++ .byte 0x9c /* DW_OP_call_frame_cfa */ ++ /* DW_AT_GNU_all_call_sites */ ++ .4byte .S0x4fc - .Ldebug_info0 /* DW_AT_sibling */ ++.S0x1e0: ++ .uleb128 0x15 /* (DIE (0x1e0) DW_TAG_subprogram) */ ++ .ascii "p__top__middle\0" /* DW_AT_name */ ++ .byte 0x1 /* DW_AT_decl_file (p.adb) */ ++ .byte 0x4 /* DW_AT_decl_line */ ++ .byte 0x1 /* DW_AT_inline */ ++ .4byte .S0x374 - .Ldebug_info0 /* DW_AT_sibling */ ++.S0x202: ++ .uleb128 0x15 /* (DIE (0x202) DW_TAG_subprogram) */ ++ .ascii "p__top__middle__inside\0" /* DW_AT_name */ ++ .byte 0x1 /* DW_AT_decl_file (p.adb) */ ++ .byte 0x5 /* DW_AT_decl_line */ ++ .byte 0x1 /* DW_AT_inline */ ++ .4byte .S0x225 - .Ldebug_info0 /* DW_AT_sibling */ ++ .byte 0 /* end of children of DIE 0x202 */ ++.S0x225: ++ .uleb128 0x18 /* (DIE (0x225) DW_TAG_subprogram) */ ++ .4byte .S0x202 - .Ldebug_info0 /* DW_AT_abstract_origin */ ++ .4byte .LFB4 /* DW_AT_low_pc */ ++ .4byte .LBE6-.LFB4 /* DW_AT_high_pc */ ++ .uleb128 0x1 /* DW_AT_frame_base */ ++ .byte 0x9c /* DW_OP_call_frame_cfa */ ++ .uleb128 0x1 /* DW_AT_static_link */ ++ .byte 0x56 /* DW_OP_reg6 */ ++ /* DW_AT_GNU_all_call_sites */ ++ .uleb128 0x1a /* (DIE (0x247) DW_TAG_inlined_subroutine) */ ++ .4byte .S0x1e0 - .Ldebug_info0 /* DW_AT_abstract_origin */ ++ .4byte .LFB4 /* DW_AT_low_pc */ ++ .4byte .LBE6-.LFB4 /* DW_AT_high_pc */ ++ .byte 0x1 /* DW_AT_call_file (p.adb) */ ++ .byte 0x14 /* DW_AT_call_line */ ++ .4byte .S0x374 - .Ldebug_info0 /* DW_AT_sibling */ ++ .byte 0 /* end of children of DIE 0x247 */ ++ .byte 0 /* end of children of DIE 0x225 */ ++ .byte 0 /* end of children of DIE 0x1e0 */ ++.S0x374: ++ .uleb128 0x23 /* (DIE (0x382) DW_TAG_inlined_subroutine) */ ++ .4byte .S0x1e0 - .Ldebug_info0 /* DW_AT_abstract_origin */ ++ .4byte .LFB4 /* DW_AT_low_pc */ ++ .4byte .LBE6-.LFB4 /* DW_AT_high_pc */ ++ .byte 0x1 /* DW_AT_call_file (p.adb) */ ++ .byte 0x1d /* DW_AT_call_line */ ++ .byte 0 /* end of children of DIE 0x382 */ ++ .byte 0 /* end of children of DIE 0x1b4 */ ++.S0x4fc: ++ .uleb128 0x28 /* (DIE (0x52e) DW_TAG_subprogram) */ ++ /* DW_AT_external */ ++ .ascii "__gnat_rcheck_PE_Explicit_Raise\0" /* DW_AT_name */ ++ /* DW_AT_artificial */ ++ /* DW_AT_declaration */ ++ .byte 0 /* end of children of DIE 0x52e */ ++ .byte 0 /* end of children of DIE 0xb */ ++.Ledebug_info0: ++ ++ .section .debug_abbrev,"",@progbits ++.Ldebug_abbrev0: ++ .uleb128 0x1 /* (abbrev code) */ ++ .uleb128 0x11 /* (TAG: DW_TAG_compile_unit) */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x25 /* (DW_AT_producer) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x13 /* (DW_AT_language) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x1b /* (DW_AT_comp_dir) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x11 /* (DW_AT_low_pc) */ ++ .uleb128 0x1 /* (DW_FORM_addr) */ ++ .uleb128 0x12 /* (DW_AT_high_pc) */ ++ .uleb128 0x6 /* (DW_FORM_data4) */ ++ .byte 0 ++ .byte 0 ++ .uleb128 0x8 /* (abbrev code) */ ++ .uleb128 0x24 /* (TAG: DW_TAG_base_type) */ ++ .byte 0 /* DW_children_no */ ++ .uleb128 0xb /* (DW_AT_byte_size) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x3e /* (DW_AT_encoding) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .byte 0 ++ .byte 0 ++ .uleb128 0x13 /* (abbrev code) */ ++ .uleb128 0x2e /* (TAG: DW_TAG_subprogram) */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x3f /* (DW_AT_external) */ ++ .uleb128 0x19 /* (DW_FORM_flag_present) */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x3a /* (DW_AT_decl_file) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x3b /* (DW_AT_decl_line) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x11 /* (DW_AT_low_pc) */ ++ .uleb128 0x1 /* (DW_FORM_addr) */ ++ .uleb128 0x12 /* (DW_AT_high_pc) */ ++ .uleb128 0x6 /* (DW_FORM_data4) */ ++ .uleb128 0x40 /* (DW_AT_frame_base) */ ++ .uleb128 0x18 /* (DW_FORM_exprloc) */ ++ .uleb128 0x2117 /* (DW_AT_GNU_all_call_sites) */ ++ .uleb128 0x19 /* (DW_FORM_flag_present) */ ++ .uleb128 0x1 /* (DW_AT_sibling) */ ++ .uleb128 0x13 /* (DW_FORM_ref4) */ ++ .byte 0 ++ .byte 0 ++ .uleb128 0x15 /* (abbrev code) */ ++ .uleb128 0x2e /* (TAG: DW_TAG_subprogram) */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x3a /* (DW_AT_decl_file) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x3b /* (DW_AT_decl_line) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x20 /* (DW_AT_inline) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x1 /* (DW_AT_sibling) */ ++ .uleb128 0x13 /* (DW_FORM_ref4) */ ++ .byte 0 ++ .byte 0 ++ .uleb128 0x18 /* (abbrev code) */ ++ .uleb128 0x2e /* (TAG: DW_TAG_subprogram) */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x31 /* (DW_AT_abstract_origin) */ ++ .uleb128 0x13 /* (DW_FORM_ref4) */ ++ .uleb128 0x11 /* (DW_AT_low_pc) */ ++ .uleb128 0x1 /* (DW_FORM_addr) */ ++ .uleb128 0x12 /* (DW_AT_high_pc) */ ++ .uleb128 0x6 /* (DW_FORM_data4) */ ++ .uleb128 0x40 /* (DW_AT_frame_base) */ ++ .uleb128 0x18 /* (DW_FORM_exprloc) */ ++ .uleb128 0x48 /* (DW_AT_static_link) */ ++ .uleb128 0x18 /* (DW_FORM_exprloc) */ ++ .uleb128 0x2117 /* (DW_AT_GNU_all_call_sites) */ ++ .uleb128 0x19 /* (DW_FORM_flag_present) */ ++ .byte 0 ++ .byte 0 ++ .uleb128 0x1a /* (abbrev code) */ ++ .uleb128 0x1d /* (TAG: DW_TAG_inlined_subroutine) */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x31 /* (DW_AT_abstract_origin) */ ++ .uleb128 0x13 /* (DW_FORM_ref4) */ ++ .uleb128 0x11 /* (DW_AT_low_pc) */ ++ .uleb128 0x1 /* (DW_FORM_addr) */ ++ .uleb128 0x12 /* (DW_AT_high_pc) */ ++ .uleb128 0x6 /* (DW_FORM_data4) */ ++ .uleb128 0x58 /* (DW_AT_call_file) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x59 /* (DW_AT_call_line) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x1 /* (DW_AT_sibling) */ ++ .uleb128 0x13 /* (DW_FORM_ref4) */ ++ .byte 0 ++ .byte 0 ++ .uleb128 0x23 /* (abbrev code) */ ++ .uleb128 0x1d /* (TAG: DW_TAG_inlined_subroutine) */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x31 /* (DW_AT_abstract_origin) */ ++ .uleb128 0x13 /* (DW_FORM_ref4) */ ++ .uleb128 0x11 /* (DW_AT_low_pc) */ ++ .uleb128 0x1 /* (DW_FORM_addr) */ ++ .uleb128 0x12 /* (DW_AT_high_pc) */ ++ .uleb128 0x6 /* (DW_FORM_data4) */ ++ .uleb128 0x58 /* (DW_AT_call_file) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .uleb128 0x59 /* (DW_AT_call_line) */ ++ .uleb128 0xb /* (DW_FORM_data1) */ ++ .byte 0 ++ .byte 0 ++ .uleb128 0x28 /* (abbrev code) */ ++ .uleb128 0x2e /* (TAG: DW_TAG_subprogram) */ ++ .byte 0x1 /* DW_children_yes */ ++ .uleb128 0x3f /* (DW_AT_external) */ ++ .uleb128 0x19 /* (DW_FORM_flag_present) */ ++ .uleb128 0x3 /* (DW_AT_name) */ ++ .uleb128 0x8 /* (DW_FORM_string) */ ++ .uleb128 0x34 /* (DW_AT_artificial) */ ++ .uleb128 0x19 /* (DW_FORM_flag_present) */ ++ .uleb128 0x3c /* (DW_AT_declaration) */ ++ .uleb128 0x19 /* (DW_FORM_flag_present) */ ++ .byte 0 ++ .byte 0 ++ .byte 0 ++ .byte 0 ++ .byte 0 ++ ++ .section .debug_line ++.Lline1_begin: ++ .byte 0 ++ +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-icycle.c +@@ -0,0 +1,24 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2004-2014 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 . */ ++ ++/* Dummy main function. */ ++ ++int ++main() ++{ ++ return 0; ++} +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-icycle.exp +@@ -0,0 +1,46 @@ ++# Copyright 2014 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 . ++ ++# This test exercises PR 16581. ++ ++load_lib dwarf.exp ++ ++# This test can only be run on targets which support DWARF-2 and use gas. ++if {![dwarf2_support]} { ++ return 0 ++} ++ ++standard_testfile .S .c ++ ++if { [prepare_for_testing ${testfile}.exp ${testfile} \ ++ [list $srcfile $srcfile2] {nodebug}] } { ++ return -1 ++} ++ ++# We are trying to verify that the partial symtab to symtab expansion ++# for the debugging info hand-coded in our assembly file does not cause ++# the debugger to crash (infinite recursion). To facilitate the test, ++# start the debugger with -readnow. This force expansion as soon as ++# the objfile is loaded. ++ ++set saved_gdbflags $GDBFLAGS ++set GDBFLAGS "$GDBFLAGS -readnow" ++clean_restart ${testfile} ++set GDBFLAGS $saved_gdbflags ++ ++# And just to be sure that the debugger did not crash after having ++# expanded our symbols, do a life-check. ++ ++gdb_test "echo life check\\n" "life check" diff --git a/gdb-gnat-dwarf-crash-2of3.patch b/gdb-gnat-dwarf-crash-2of3.patch new file mode 100644 index 0000000..32f0259 --- /dev/null +++ b/gdb-gnat-dwarf-crash-2of3.patch @@ -0,0 +1,125 @@ +http://sourceware.org/ml/gdb-patches/2014-02/msg00729.html +Subject: [patch] [testsuite] Fix dw2-icycle.exp -fsanitize=address GDB crash + + +--WIyZ46R2i8wDzkSu +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline + +Hi Doug, + +in fact obvious, I will check it in. + +binutils readelf -wi: + <4>: Abbrev Number: 26 (DW_TAG_inlined_subroutine) + DW_AT_abstract_origin: <0x5a> + DW_AT_low_pc : 0x400590 + DW_AT_high_pc : 0x4 + DW_AT_call_file : 1 + DW_AT_call_line : 20 + DW_AT_sibling : <0xb8> + <2>: Abbrev Number: 35 (DW_TAG_inlined_subroutine) + DW_AT_abstract_origin: <0x5a> + DW_AT_low_pc : 0x400590 + DW_AT_high_pc : 0x4 + DW_AT_call_file : 1 + DW_AT_call_line : 29 + + DW_AT_sibling points to the next DIE - but that DIE is 2 levels +upwards - definitely not a sibling. This confuses GDB up to a crash: + +==32143== ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6024000198ac at pc 0xb4d104 bp 0x7fff63e96e70 sp 0x7fff63e96e60 +READ of size 1 at 0x6024000198ac thread T0 + #0 0xb4d103 in read_unsigned_leb128 (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb4d103) + #1 0xb15f3c in peek_die_abbrev (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb15f3c) + #2 0xb46185 in load_partial_dies (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb46185) + #3 0xb103fb in process_psymtab_comp_unit_reader (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb103fb) + #4 0xb0d2a9 in init_cutu_and_read_dies (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb0d2a9) + #5 0xb1115f in process_psymtab_comp_unit (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb1115f) + #6 0xb1235f in dwarf2_build_psymtabs_hard (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb1235f) + #7 0xb05536 in dwarf2_build_psymtabs (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb05536) + #8 0x86d5a5 in read_psyms (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x86d5a5) + #9 0x9b1c37 in require_partial_symbols (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x9b1c37) + #10 0x9bf2d0 in read_symbols (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x9bf2d0) + #11 0x9c014c in syms_from_objfile_1 (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x9c014c) + +I have added === Delete all DW_AT_sibling ===: + https://sourceware.org/gdb/wiki/GDBTestcaseCookbook?action=diff&rev2=31&rev1=30 + + +Jan + +--WIyZ46R2i8wDzkSu +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline; filename="sibling.patch" + +gdb/testsuite/ +2014-02-24 Jan Kratochvil + + Fix dw2-icycle.exp -fsanitize=address GDB crash. + * gdb.dwarf2/dw2-icycle.S: Remove all DW_AT_sibling. + +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-icycle.S b/gdb/testsuite/gdb.dwarf2/dw2-icycle.S +index 1f84e4a..938ff20 100644 +--- a/gdb/testsuite/gdb.dwarf2/dw2-icycle.S ++++ b/gdb/testsuite/gdb.dwarf2/dw2-icycle.S +@@ -63,21 +63,18 @@ p__top: + .uleb128 0x1 /* DW_AT_frame_base */ + .byte 0x9c /* DW_OP_call_frame_cfa */ + /* DW_AT_GNU_all_call_sites */ +- .4byte .S0x4fc - .Ldebug_info0 /* DW_AT_sibling */ + .S0x1e0: + .uleb128 0x15 /* (DIE (0x1e0) DW_TAG_subprogram) */ + .ascii "p__top__middle\0" /* DW_AT_name */ + .byte 0x1 /* DW_AT_decl_file (p.adb) */ + .byte 0x4 /* DW_AT_decl_line */ + .byte 0x1 /* DW_AT_inline */ +- .4byte .S0x374 - .Ldebug_info0 /* DW_AT_sibling */ + .S0x202: + .uleb128 0x15 /* (DIE (0x202) DW_TAG_subprogram) */ + .ascii "p__top__middle__inside\0" /* DW_AT_name */ + .byte 0x1 /* DW_AT_decl_file (p.adb) */ + .byte 0x5 /* DW_AT_decl_line */ + .byte 0x1 /* DW_AT_inline */ +- .4byte .S0x225 - .Ldebug_info0 /* DW_AT_sibling */ + .byte 0 /* end of children of DIE 0x202 */ + .S0x225: + .uleb128 0x18 /* (DIE (0x225) DW_TAG_subprogram) */ +@@ -95,7 +92,6 @@ p__top: + .4byte .LBE6-.LFB4 /* DW_AT_high_pc */ + .byte 0x1 /* DW_AT_call_file (p.adb) */ + .byte 0x14 /* DW_AT_call_line */ +- .4byte .S0x374 - .Ldebug_info0 /* DW_AT_sibling */ + .byte 0 /* end of children of DIE 0x247 */ + .byte 0 /* end of children of DIE 0x225 */ + .byte 0 /* end of children of DIE 0x1e0 */ +@@ -167,8 +163,6 @@ p__top: + .uleb128 0x18 /* (DW_FORM_exprloc) */ + .uleb128 0x2117 /* (DW_AT_GNU_all_call_sites) */ + .uleb128 0x19 /* (DW_FORM_flag_present) */ +- .uleb128 0x1 /* (DW_AT_sibling) */ +- .uleb128 0x13 /* (DW_FORM_ref4) */ + .byte 0 + .byte 0 + .uleb128 0x15 /* (abbrev code) */ +@@ -182,8 +176,6 @@ p__top: + .uleb128 0xb /* (DW_FORM_data1) */ + .uleb128 0x20 /* (DW_AT_inline) */ + .uleb128 0xb /* (DW_FORM_data1) */ +- .uleb128 0x1 /* (DW_AT_sibling) */ +- .uleb128 0x13 /* (DW_FORM_ref4) */ + .byte 0 + .byte 0 + .uleb128 0x18 /* (abbrev code) */ +@@ -216,8 +208,6 @@ p__top: + .uleb128 0xb /* (DW_FORM_data1) */ + .uleb128 0x59 /* (DW_AT_call_line) */ + .uleb128 0xb /* (DW_FORM_data1) */ +- .uleb128 0x1 /* (DW_AT_sibling) */ +- .uleb128 0x13 /* (DW_FORM_ref4) */ + .byte 0 + .byte 0 + .uleb128 0x23 /* (abbrev code) */ + +--WIyZ46R2i8wDzkSu-- + diff --git a/gdb-gnat-dwarf-crash-3of3.patch b/gdb-gnat-dwarf-crash-3of3.patch new file mode 100644 index 0000000..3f57fd3 --- /dev/null +++ b/gdb-gnat-dwarf-crash-3of3.patch @@ -0,0 +1,58 @@ +http://sourceware.org/ml/gdb-patches/2014-02/msg00731.html +Subject: [patch] gdb_assert -> complaint for weird DWARF + + +--6TrnltStXW4iwmi0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline + +Hi, + +PR 16581: + GDB crash on inherit_abstract_dies infinite recursion + https://sourceware.org/bugzilla/show_bug.cgi?id=16581 + +fixed crash from an infinite recursion. But in rare cases the new code can +now gdb_assert() due to weird DWARF file. + +I do not yet fully understand why the DWARF is as it is but just GDB should +never crash due to invalid DWARF anyway. The "invalid" DWARF I see only in +Fedora GCC build, not in FSF GCC build, more info at: + https://bugzilla.redhat.com/show_bug.cgi?id=1069382 + http://people.redhat.com/jkratoch/gcc-debuginfo-4.8.2-7.fc20.x86_64-gnatbind.debug + + +Thanks, +Jan + +--6TrnltStXW4iwmi0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline; filename="complaint.patch" + +gdb/ +2014-02-24 Jan Kratochvil + + * dwarf2read.c (process_die): Change gdb_assert to complaint. + +diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c +index 3eaa0b1..71f5d34 100644 +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -8029,7 +8029,13 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) + struct cleanup *in_process; + + /* We should only be processing those not already in process. */ +- gdb_assert (!die->in_process); ++ if (die->in_process) ++ { ++ complaint (&symfile_complaints, ++ _("DIE at 0x%x attempted to be processed twice"), ++ die->offset.sect_off); ++ return; ++ } + + die->in_process = 1; + in_process = make_cleanup (reset_die_in_process,die); + +--6TrnltStXW4iwmi0-- + diff --git a/gdb.spec b/gdb.spec index 4d5a30e..789b62f 100644 --- a/gdb.spec +++ b/gdb.spec @@ -38,7 +38,7 @@ Version: 7.6.50.%{snap} # 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: 20%{?dist} +Release: 21%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain Group: Development/Debuggers @@ -532,6 +532,11 @@ Patch844: gdb-rhbz1013453-value-struct-elt-memory-leak.patch # Fix explicit Class:: inside class scope (BZ 874817, Keith Seitz). Patch845: gdb-implicit-this.patch +# Fix crash of -readnow /usr/lib/debug/usr/bin/gnatbind.debug (BZ 1069211). +Patch850: gdb-gnat-dwarf-crash-1of3.patch +Patch851: gdb-gnat-dwarf-crash-2of3.patch +Patch852: gdb-gnat-dwarf-crash-3of3.patch + %if 0%{!?rhel:1} || 0%{?rhel} > 6 # RL_STATE_FEDORA_GDB would not be found for: # Patch642: gdb-readline62-ask-more-rh.patch @@ -828,6 +833,9 @@ find -name "*.info*"|xargs rm -f %patch843 -p1 %patch844 -p1 %patch845 -p1 +%patch850 -p1 +%patch851 -p1 +%patch852 -p1 %patch393 -p1 %if 0%{!?el5:1} || 0%{?scl:1} @@ -1346,6 +1354,9 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Mon Feb 24 2014 Jan Kratochvil - 7.6.50.20140119-21.fc20 +- Fix crash of -readnow /usr/lib/debug/usr/bin/gnatbind.debug (BZ 1069211). + * Thu Jan 23 2014 Jan Kratochvil - 7.6.50.20140119-20.fc20 - [s390*,ppc*] Enable secondary targets s390* and ppc* (BZ 1056259).