Accepting request 872638 from home:tomdevries:branches:devel:gcc-gdb-license-fix

- Replace tentative fix with upstreamed fix [swo#26881]:
  Remove:
  * gdb-fix-assert-in-process-event-stop-test.patch
  Add:
  * gdb-fix-internal-error-in-process_event_stop_test.patch
  * gdb-breakpoints-handle-glibc-with-debuginfo-in-create_exception_master_breakpoint.patch
- Fix license [bsc#1180786].

OBS-URL: https://build.opensuse.org/request/show/872638
OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=269
This commit is contained in:
Richard Biener 2021-02-16 07:12:59 +00:00 committed by Git OBS Bridge
parent 8da52f9fa5
commit 0d5f9882f6
5 changed files with 349 additions and 36 deletions

View File

@ -0,0 +1,53 @@
[gdb/breakpoints] Handle glibc with debuginfo in create_exception_master_breakpoint
The test-case nextoverthrow.exp is failing on targets with unstripped libc.
This is a regression since commit 1940319c0ef "[gdb] Fix internal-error in
process_event_stop_test".
The problem is that this code in create_exception_master_breakpoint:
...
for (objfile *sepdebug = obj->separate_debug_objfile;
sepdebug != nullptr; sepdebug = sepdebug->separate_debug_objfile)
if (create_exception_master_breakpoint_hook (sepdebug))
...
iterates over all the separate debug object files, but fails to handle the
case that obj itself has the debug info we're looking for.
Fix this by using the separate_debug_objfiles () range instead, which does
iterate both over obj and the obj->separate_debug_objfile chain.
Tested on x86_64-linux.
gdb/ChangeLog:
2021-02-05 Tom de Vries <tdevries@suse.de>
PR breakpoints/27330
* breakpoint.c (create_exception_master_breakpoint): Handle case that
glibc object file has debug info.
---
gdb/breakpoint.c | 9 ++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 7ead1529ad1..a94bb2e3540 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3474,11 +3474,10 @@ create_exception_master_breakpoint (void)
if (create_exception_master_breakpoint_probe (obj))
continue;
- /* Iterate over separate debug objects and try an _Unwind_DebugHook
- kind breakpoint. */
- for (objfile *sepdebug = obj->separate_debug_objfile;
- sepdebug != nullptr; sepdebug = sepdebug->separate_debug_objfile)
- if (create_exception_master_breakpoint_hook (sepdebug))
+ /* Iterate over main and separate debug objects and try an
+ _Unwind_DebugHook kind breakpoint. */
+ for (objfile *debug_objfile : obj->separate_debug_objfiles ())
+ if (create_exception_master_breakpoint_hook (debug_objfile))
break;
}
}

View File

@ -1,24 +0,0 @@
Fix assert in process_event_stop_test
Fixes PR26881 - "infrun.c:6384: internal-error: void
process_event_stop_test(execution_control_state*): Assertion
`ecs->event_thread->control.exception_resume_breakpoint != NULL' failed".
https://sourceware.org/bugzilla/show_bug.cgi?id=26881
---
gdb/infrun.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 4c2e1f56d24..6000c58c142 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -6431,6 +6431,7 @@ process_event_stop_test (struct execution_control_state *ecs)
else
{
/* Case 3. */
+ ecs->event_thread->stepping_over_breakpoint = 1;
keep_going (ecs);
return;
}

View File

@ -0,0 +1,267 @@
[gdb] Fix internal-error in process_event_stop_test
The function create_exception_master_breakpoint in gdb/breakpoint.c attempts
to set a master exception breakpoint in each objfile. It tries this using
a libgcc/unwind probe, and if that fails then using the
_Unwind_DebugHook symbol:
...
for (objfile *objfile : current_program_space->objfiles ())
{
/* Try using probes. */
if (/* successful */)
continue;
/* Try using _Unwind_DebugHook */
}
...
The preference scheme works ok both if the objfile has debug info, and if it's
stripped.
But it doesn't work when the objfile has a .gnu_debuglink to a .debug file
(and the .debug file is present). What happens is that:
- we first encounter objfile libgcc.debug
- we try using probes, and this fails
- so we try _Unwind_DebugHook, which succeeds
- next we encounter objfile libgcc
- we try using probes, and this succeeds.
So, we end up with a master exception breakpoint in both libgcc (using probes)
and libgcc.debug (using _Unwind_DebugHook).
This eventually causes:
...
(gdb) PASS: gdb.cp/nextoverthrow.exp: post-check - next over a throw 3
next^M
src/gdb/infrun.c:6384: internal-error: \
void process_event_stop_test(execution_control_state*): \
Assertion `ecs->event_thread->control.exception_resume_breakpoint != NULL' \
failed.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
Quit this debugging session? (y or n) FAIL: gdb.cp/nextoverthrow.exp: next
past catch (GDB internal error)
...
To trigger this internal-error, we need to use gcc-10 or later to compile the
test-case, such that it contains the fix for gcc PR97774 - "Incorrect line
info for try/catch".
Fix this by only trying to install the master exception breakpoint in
libgcc.debug using the _Unwind_DebugHook method, if the install using probes
in libgcc failed.
Tested on x86_64-linux.
gdb/ChangeLog:
2021-01-08 Tom de Vries <tdevries@suse.de>
PR gdb/26881
* breakpoint.c (create_exception_master_breakpoint_probe)
(create_exception_master_breakpoint_hook): Factor out
of ...
(create_exception_master_breakpoint): ... here. Only try to install
the master exception breakpoint in objfile.debug using the
_Unwind_DebugHook method, if the install using probes in objfile
failed.
---
gdb/breakpoint.c | 164 +++++++++++++++++++++++++++++++++----------------------
2 files changed, 110 insertions(+), 65 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index f304c0c3559..7ead1529ad1 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3360,92 +3360,126 @@ create_std_terminate_master_breakpoint (void)
}
}
-/* Install a master breakpoint on the unwinder's debug hook. */
+/* Install a master breakpoint on the unwinder's debug hook for OBJFILE using a
+ probe. Return true if a breakpoint was installed. */
-static void
-create_exception_master_breakpoint (void)
+static bool
+create_exception_master_breakpoint_probe (objfile *objfile)
{
- const char *const func_name = "_Unwind_DebugHook";
+ struct breakpoint *b;
+ struct gdbarch *gdbarch;
+ struct breakpoint_objfile_data *bp_objfile_data;
- for (objfile *objfile : current_program_space->objfiles ())
- {
- struct breakpoint *b;
- struct gdbarch *gdbarch;
- struct breakpoint_objfile_data *bp_objfile_data;
- CORE_ADDR addr;
- struct explicit_location explicit_loc;
+ bp_objfile_data = get_breakpoint_objfile_data (objfile);
- bp_objfile_data = get_breakpoint_objfile_data (objfile);
+ /* We prefer the SystemTap probe point if it exists. */
+ if (!bp_objfile_data->exception_searched)
+ {
+ std::vector<probe *> ret
+ = find_probes_in_objfile (objfile, "libgcc", "unwind");
- /* We prefer the SystemTap probe point if it exists. */
- if (!bp_objfile_data->exception_searched)
+ if (!ret.empty ())
{
- std::vector<probe *> ret
- = find_probes_in_objfile (objfile, "libgcc", "unwind");
+ /* We are only interested in checking one element. */
+ probe *p = ret[0];
- if (!ret.empty ())
+ if (!p->can_evaluate_arguments ())
{
- /* We are only interested in checking one element. */
- probe *p = ret[0];
-
- if (!p->can_evaluate_arguments ())
- {
- /* We cannot use the probe interface here, because it does
- not know how to evaluate arguments. */
- ret.clear ();
- }
+ /* We cannot use the probe interface here, because it does
+ not know how to evaluate arguments. */
+ ret.clear ();
}
- bp_objfile_data->exception_probes = ret;
- bp_objfile_data->exception_searched = 1;
}
+ bp_objfile_data->exception_probes = ret;
+ bp_objfile_data->exception_searched = 1;
+ }
- if (!bp_objfile_data->exception_probes.empty ())
- {
- gdbarch = objfile->arch ();
+ if (bp_objfile_data->exception_probes.empty ())
+ return false;
- for (probe *p : bp_objfile_data->exception_probes)
- {
- b = create_internal_breakpoint (gdbarch,
- p->get_relocated_address (objfile),
- bp_exception_master,
- &internal_breakpoint_ops);
- b->location = new_probe_location ("-probe-stap libgcc:unwind");
- b->enable_state = bp_disabled;
- }
+ gdbarch = objfile->arch ();
- continue;
- }
+ for (probe *p : bp_objfile_data->exception_probes)
+ {
+ b = create_internal_breakpoint (gdbarch,
+ p->get_relocated_address (objfile),
+ bp_exception_master,
+ &internal_breakpoint_ops);
+ b->location = new_probe_location ("-probe-stap libgcc:unwind");
+ b->enable_state = bp_disabled;
+ }
- /* Otherwise, try the hook function. */
+ return true;
+}
- if (msym_not_found_p (bp_objfile_data->exception_msym.minsym))
- continue;
+/* Install a master breakpoint on the unwinder's debug hook for OBJFILE using
+ _Unwind_DebugHook. Return true if a breakpoint was installed. */
- gdbarch = objfile->arch ();
+static bool
+create_exception_master_breakpoint_hook (objfile *objfile)
+{
+ const char *const func_name = "_Unwind_DebugHook";
+ struct breakpoint *b;
+ struct gdbarch *gdbarch;
+ struct breakpoint_objfile_data *bp_objfile_data;
+ CORE_ADDR addr;
+ struct explicit_location explicit_loc;
- if (bp_objfile_data->exception_msym.minsym == NULL)
- {
- struct bound_minimal_symbol debug_hook;
+ bp_objfile_data = get_breakpoint_objfile_data (objfile);
- debug_hook = lookup_minimal_symbol (func_name, NULL, objfile);
- if (debug_hook.minsym == NULL)
- {
- bp_objfile_data->exception_msym.minsym = &msym_not_found;
- continue;
- }
+ if (msym_not_found_p (bp_objfile_data->exception_msym.minsym))
+ return false;
- bp_objfile_data->exception_msym = debug_hook;
+ gdbarch = objfile->arch ();
+
+ if (bp_objfile_data->exception_msym.minsym == NULL)
+ {
+ struct bound_minimal_symbol debug_hook;
+
+ debug_hook = lookup_minimal_symbol (func_name, NULL, objfile);
+ if (debug_hook.minsym == NULL)
+ {
+ bp_objfile_data->exception_msym.minsym = &msym_not_found;
+ return false;
}
- addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->exception_msym);
- addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr,
- current_top_target ());
- b = create_internal_breakpoint (gdbarch, addr, bp_exception_master,
- &internal_breakpoint_ops);
- initialize_explicit_location (&explicit_loc);
- explicit_loc.function_name = ASTRDUP (func_name);
- b->location = new_explicit_location (&explicit_loc);
- b->enable_state = bp_disabled;
+ bp_objfile_data->exception_msym = debug_hook;
+ }
+
+ addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->exception_msym);
+ addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr,
+ current_top_target ());
+ b = create_internal_breakpoint (gdbarch, addr, bp_exception_master,
+ &internal_breakpoint_ops);
+ initialize_explicit_location (&explicit_loc);
+ explicit_loc.function_name = ASTRDUP (func_name);
+ b->location = new_explicit_location (&explicit_loc);
+ b->enable_state = bp_disabled;
+
+ return true;
+}
+
+/* Install a master breakpoint on the unwinder's debug hook. */
+
+static void
+create_exception_master_breakpoint (void)
+{
+ for (objfile *obj : current_program_space->objfiles ())
+ {
+ /* Skip separate debug object. */
+ if (obj->separate_debug_objfile_backlink)
+ continue;
+
+ /* Try a probe kind breakpoint. */
+ if (create_exception_master_breakpoint_probe (obj))
+ continue;
+
+ /* Iterate over separate debug objects and try an _Unwind_DebugHook
+ kind breakpoint. */
+ for (objfile *sepdebug = obj->separate_debug_objfile;
+ sepdebug != nullptr; sepdebug = sepdebug->separate_debug_objfile)
+ if (create_exception_master_breakpoint_hook (sepdebug))
+ break;
}
}

View File

@ -1,3 +1,18 @@
-------------------------------------------------------------------
Thu Feb 11 16:13:14 UTC 2021 - Tom de Vries <tdevries@suse.com>
- Replace tentative fix with upstreamed fix [swo#26881]:
Remove:
* gdb-fix-assert-in-process-event-stop-test.patch
Add:
* gdb-fix-internal-error-in-process_event_stop_test.patch
* gdb-breakpoints-handle-glibc-with-debuginfo-in-create_exception_master_breakpoint.patch
-------------------------------------------------------------------
Thu Feb 11 15:07:12 UTC 2021 - Tom de Vries <tdevries@suse.com>
- Fix license [bsc#1180786].
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Dec 9 07:56:36 UTC 2020 - Tom de Vries <tdevries@suse.com> Wed Dec 9 07:56:36 UTC 2020 - Tom de Vries <tdevries@suse.com>

View File

@ -1,7 +1,7 @@
# #
# spec file for package gdb # spec file for package gdb-testresults
# #
# Copyright (c) 2020 SUSE LLC # Copyright (c) 2021 SUSE LLC
# Copyright (c) 2012 RedHat # Copyright (c) 2012 RedHat
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
@ -54,7 +54,7 @@ ExclusiveArch: do_not_build
%if %{build_main} %if %{build_main}
Summary: A GNU source-level debugger for C, C++, Fortran and other languages Summary: A GNU source-level debugger for C, C++, Fortran and other languages
License: SUSE-Public-Domain License: GPL-3.0-only WITH GCC-exception-3.1 AND GPL-3.0-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later
Group: Development/Languages/C and C++ Group: Development/Languages/C and C++
%endif %endif
%if %{build_testsuite} %if %{build_testsuite}
@ -283,7 +283,6 @@ Patch1003: gdb-testsuite-ada-pie.patch
Patch1500: gdb-fix-selftest-fails-with-gdb-build-with-O2-flto.patch Patch1500: gdb-fix-selftest-fails-with-gdb-build-with-O2-flto.patch
Patch1501: gdb-fortran-fix-print-dynamic-array.patch Patch1501: gdb-fortran-fix-print-dynamic-array.patch
Patch1502: gdb-don-t-return-non-existing-path-in-debuginfod-source-query.patch Patch1502: gdb-don-t-return-non-existing-path-in-debuginfod-source-query.patch
Patch1503: gdb-fix-assert-in-process-event-stop-test.patch
Patch1504: gdb-fix-filename-in-not-in-executable-format-error.patch Patch1504: gdb-fix-filename-in-not-in-executable-format-error.patch
Patch1505: gdb-handle-no-upper-bound-in-value-subscript.patch Patch1505: gdb-handle-no-upper-bound-in-value-subscript.patch
Patch1506: gdb-fortran-handle-dw-at-string-length-with-loclistptr.patch Patch1506: gdb-fortran-handle-dw-at-string-length-with-loclistptr.patch
@ -308,11 +307,13 @@ Patch2007: gdb-fix-section-matching-in-find_pc_sect_compunit.patch
Patch2008: gdb-symtab-fix-language-of-frame-without-debug-info.patch Patch2008: gdb-symtab-fix-language-of-frame-without-debug-info.patch
Patch2009: gdb-testsuite-fix-failure-in-gdb-base-step-over-no-symbols-exp.patch Patch2009: gdb-testsuite-fix-failure-in-gdb-base-step-over-no-symbols-exp.patch
Patch2010: gdb-powerpc-remove-512-bytes-region-limit-if-2nd-dawr-is-avaliable.patch Patch2010: gdb-powerpc-remove-512-bytes-region-limit-if-2nd-dawr-is-avaliable.patch
Patch2011: gdb-fix-internal-error-in-process_event_stop_test.patch
Patch2012: gdb-breakpoints-handle-glibc-with-debuginfo-in-create_exception_master_breakpoint.patch
# Testsuite patches # Testsuite patches
Patch2500: gdb-testsuite-fix-gdb-server-ext-run-exp-for-obs.patch Patch2500: gdb-testsuite-fix-gdb-server-ext-run-exp-for-obs.patch
%if 0%{?suse_version} > 1500 %if 0%{?suse_version} > 1500
Patch2501: gdb-testsuite-disable-selftests-for-factory.patch Patch2501: gdb-testsuite-disable-selftests-for-factory.patch
%endif %endif
@ -360,7 +361,7 @@ Requires: %{python}-base
BuildRequires: %{python}-devel BuildRequires: %{python}-devel
%endif # 0%{!?_without_python:1} %endif # 0%{!?_without_python:1}
%global have_libdebuginfod 0 %global have_libdebuginfod 0
%if 0%{?suse_version} > 1500 %if 0%{?suse_version} > 1500
%ifarch %{ix86} x86_64 aarch64 armv7l ppc64 ppc64le s390x %ifarch %{ix86} x86_64 aarch64 armv7l ppc64 ppc64le s390x
%global have_libdebuginfod 1 %global have_libdebuginfod 1
%endif %endif
@ -527,7 +528,7 @@ and printing their data.
%package -n gdbserver %package -n gdbserver
Summary: A standalone server for GDB (the GNU source-level debugger) Summary: A standalone server for GDB (the GNU source-level debugger)
License: GPL-3.0-or-later AND GPL-3.0-with-GCC-exception AND LGPL-2.1-or-later AND LGPL-3.0-or-later License: GPL-3.0-only WITH GCC-exception-3.1 AND GPL-3.0-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later
Group: Development/Tools/Debuggers Group: Development/Tools/Debuggers
%description -n gdbserver %description -n gdbserver
@ -558,7 +559,7 @@ This package provides INFO, HTML and PDF user manual for GDB.
%if %{build_testsuite} %if %{build_testsuite}
%description %description
Results from running the GDB testsuite. Results from running the GDB testsuite.
%endif %endif
%prep %prep
@ -693,7 +694,6 @@ find -name "*.info*"|xargs rm -f
%patch1500 -p1 %patch1500 -p1
%patch1501 -p1 %patch1501 -p1
%patch1502 -p1 %patch1502 -p1
%patch1503 -p1
%patch1504 -p1 %patch1504 -p1
%patch1505 -p1 %patch1505 -p1
%patch1506 -p1 %patch1506 -p1
@ -716,9 +716,11 @@ find -name "*.info*"|xargs rm -f
%patch2008 -p1 %patch2008 -p1
%patch2009 -p1 %patch2009 -p1
%patch2010 -p1 %patch2010 -p1
%patch2011 -p1
%patch2012 -p1
%patch2500 -p1 %patch2500 -p1
%if 0%{?suse_version} > 1500 %if 0%{?suse_version} > 1500
%patch2501 -p1 %patch2501 -p1
%endif %endif
@ -768,7 +770,7 @@ export CFLAGS="$RPM_OPT_FLAGS"
# Add your -Wno-x/-Wno-error=y options here: # Add your -Wno-x/-Wno-error=y options here:
for opt in -Wno-error=odr; do for opt in -Wno-error=odr; do
# checking for acceptance of -Wno-foo is a bit wieldy: GCC doesn't # checking for acceptance of -Wno-foo is a bit wieldy: GCC doesn't
# warn about unknown -Wno- flags, _except_ if there are other # warn about unknown -Wno- flags, _except_ if there are other
# diagnostics as well, so let's force an uninitialized use warning # diagnostics as well, so let's force an uninitialized use warning
# and grep for the diagnostic about the -Wno flag: # and grep for the diagnostic about the -Wno flag:
@ -1249,7 +1251,7 @@ cp -p %{SOURCE3} $RPM_BUILD_ROOT%{_mandir}/man1/gstack.1
%if 0%{?el5:1} %if 0%{?el5:1}
rm -f $RPM_BUILD_ROOT%{_infodir}/annotate.info* rm -f $RPM_BUILD_ROOT%{_infodir}/annotate.info*
rm -f $RPM_BUILD_ROOT%{_infodir}/gdb.info* rm -f $RPM_BUILD_ROOT%{_infodir}/gdb.info*
%endif # 0%{?el5:1} %endif # 0%{?el5:1}
# -j1: There is some race resulting in: # -j1: There is some race resulting in:
# /usr/bin/texi2dvi: texinfo.tex appears to be broken, quitting. # /usr/bin/texi2dvi: texinfo.tex appears to be broken, quitting.
make -j1 -C gdb/doc install DESTDIR=$RPM_BUILD_ROOT make -j1 -C gdb/doc install DESTDIR=$RPM_BUILD_ROOT