Merge remote-tracking branch 'origin/f27' into f26
This commit is contained in:
commit
7780a1c00e
|
@ -0,0 +1,229 @@
|
||||||
|
From: Pedro Alves <palves at redhat dot com>
|
||||||
|
To: gdb-patches at sourceware dot org
|
||||||
|
Subject: [PATCH] Fix GCC PR83906 - [8 Regression] Random FAIL: libstdc++-prettyprinters/80276.cc whatis p4
|
||||||
|
Date: Wed, 24 Jan 2018 17:27:22 +0000
|
||||||
|
Message-Id: <20180124172722.31553-1-palves@redhat.com>
|
||||||
|
|
||||||
|
GCC PR83906 [1] is about a GCC/libstdc++ GDB/Python type printer
|
||||||
|
testcase failing randomly, as shown by running (in libstdc++'s
|
||||||
|
testsuite):
|
||||||
|
|
||||||
|
make check RUNTESTFLAGS=prettyprinters.exp=80276.cc
|
||||||
|
|
||||||
|
in a loop. Sometimes you get this:
|
||||||
|
|
||||||
|
FAIL: libstdc++-prettyprinters/80276.cc whatis p4
|
||||||
|
|
||||||
|
I.e., this:
|
||||||
|
type = std::unique_ptr<std::vector<std::unique_ptr<std::list<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >>[]>>[99]>
|
||||||
|
|
||||||
|
instead of this:
|
||||||
|
type = std::unique_ptr<std::vector<std::unique_ptr<std::list<std::string>[]>>[99]>
|
||||||
|
|
||||||
|
Jonathan Wakely tracked it on the printer side to this bit in
|
||||||
|
libstdc++'s type printer:
|
||||||
|
|
||||||
|
if self.type_obj == type_obj:
|
||||||
|
return strip_inline_namespaces(self.name)
|
||||||
|
|
||||||
|
This assumes the two types resolve to the same gdb.Type but some times
|
||||||
|
the comparison unexpectedly fails.
|
||||||
|
|
||||||
|
Running the testcase manually under Valgrind finds the problem in GDB:
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
==6118== Conditional jump or move depends on uninitialised value(s)
|
||||||
|
==6118== at 0x4C35CB0: bcmp (vg_replace_strmem.c:1100)
|
||||||
|
==6118== by 0x6F773A: check_types_equal(type*, type*, VEC_type_equality_entry_d**) (gdbtypes.c:3515)
|
||||||
|
==6118== by 0x6F7B00: check_types_worklist(VEC_type_equality_entry_d**, bcache*) (gdbtypes.c:3618)
|
||||||
|
==6118== by 0x6F7C03: types_deeply_equal(type*, type*) (gdbtypes.c:3655)
|
||||||
|
==6118== by 0x4D5B06: typy_richcompare(_object*, _object*, int) (py-type.c:1007)
|
||||||
|
==6118== by 0x63D7E6C: PyObject_RichCompare (object.c:961)
|
||||||
|
==6118== by 0x646EAEC: PyEval_EvalFrameEx (ceval.c:4960)
|
||||||
|
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
|
||||||
|
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
|
||||||
|
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
|
||||||
|
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
|
||||||
|
==6118== by 0x646DC08: PyEval_EvalFrameEx (ceval.c:4519)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
That "bcmp" call is really a memcmp call in check_types_equal. The
|
||||||
|
problem is that gdb is memcmp'ing two objects that are equal in value:
|
||||||
|
|
||||||
|
(top-gdb) p *TYPE_RANGE_DATA (type1)
|
||||||
|
$1 = {low = {kind = PROP_CONST, data = {const_val = 0, baton = 0x0}}, high = {kind = PROP_CONST, data = {const_val = 15, baton = 0xf}}, flag_upper_bound_is_count = 0,
|
||||||
|
flag_bound_evaluated = 0}
|
||||||
|
(top-gdb) p *TYPE_RANGE_DATA (type2)
|
||||||
|
$2 = {low = {kind = PROP_CONST, data = {const_val = 0, baton = 0x0}}, high = {kind = PROP_CONST, data = {const_val = 15, baton = 0xf}}, flag_upper_bound_is_count = 0,
|
||||||
|
flag_bound_evaluated = 0}
|
||||||
|
|
||||||
|
but differ in padding. Notice the 4-byte hole:
|
||||||
|
|
||||||
|
(top-gdb) ptype /o range_bounds
|
||||||
|
/* offset | size */ type = struct range_bounds {
|
||||||
|
/* 0 | 16 */ struct dynamic_prop {
|
||||||
|
/* 0 | 4 */ dynamic_prop_kind kind;
|
||||||
|
/* XXX 4-byte hole */
|
||||||
|
/* 8 | 8 */ union dynamic_prop_data {
|
||||||
|
/* 8 */ LONGEST const_val;
|
||||||
|
/* 8 */ void *baton;
|
||||||
|
|
||||||
|
/* total size (bytes): 8 */
|
||||||
|
} data;
|
||||||
|
|
||||||
|
which is filled with garbage:
|
||||||
|
|
||||||
|
(top-gdb) x /40bx TYPE_RANGE_DATA (type1)
|
||||||
|
0x2fa7ea0: 0x01 0x00 0x00 0x00 0x43 0x01 0x00 0x00
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
0x2fa7ea8: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||||
|
0x2fa7eb0: 0x01 0x00 0x00 0x00 0xfe 0x7f 0x00 0x00
|
||||||
|
0x2fa7eb8: 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||||
|
0x2fa7ec0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||||
|
(top-gdb) x /40bx TYPE_RANGE_DATA (type2)
|
||||||
|
0x20379b0: 0x01 0x00 0x00 0x00 0xfe 0x7f 0x00 0x00
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
0x20379b8: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||||
|
0x20379c0: 0x01 0x00 0x00 0x00 0xfe 0x7f 0x00 0x00
|
||||||
|
0x20379c8: 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||||
|
0x20379d0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||||
|
|
||||||
|
(top-gdb) p memcmp (TYPE_RANGE_DATA (type1), TYPE_RANGE_DATA (type2), sizeof (*TYPE_RANGE_DATA (type1)))
|
||||||
|
$3 = -187
|
||||||
|
|
||||||
|
In some cases objects of type range_bounds are memset when allocated,
|
||||||
|
but then their dynamic_prop low/high fields are copied over from some
|
||||||
|
template dynamic_prop object that wasn't memset. E.g.,
|
||||||
|
create_static_range_type's low/high locals are left with garbage in
|
||||||
|
the padding, and then that padding is copied over to the range_bounds
|
||||||
|
object's low/high fields.
|
||||||
|
|
||||||
|
At first, I considered making sure to always memset range_bounds
|
||||||
|
objects, thinking that maybe type objects are being put in some bcache
|
||||||
|
instance somewhere. But then I hacked bcache/bcache_full to poison
|
||||||
|
non-pod types, and made dynamic_prop a non-pod, and GDB still
|
||||||
|
compiled.
|
||||||
|
|
||||||
|
So given that, it seems safest to not assume padding will always be
|
||||||
|
memset, and instead treat them as regular value types, implementing
|
||||||
|
(in)equality operators and using those instead of memcmp.
|
||||||
|
|
||||||
|
This fixes the random FAILs in GCC's testcase.
|
||||||
|
|
||||||
|
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83906
|
||||||
|
|
||||||
|
gdb/ChangeLog:
|
||||||
|
2018-01-24 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
GCC PR libstdc++/83906
|
||||||
|
* gdbtypes.c (operator==(const dynamic_prop &,
|
||||||
|
const dynamic_prop &)): New.
|
||||||
|
(operator==(const range_bounds &, const range_bounds &)): New.
|
||||||
|
(check_types_equal): Use them instead of memcmp.
|
||||||
|
* gdbtypes.h (operator==(const dynamic_prop &,
|
||||||
|
const dynamic_prop &)): Declare.
|
||||||
|
(operator!=(const dynamic_prop &, const dynamic_prop &)): Declare.
|
||||||
|
(operator==(const range_bounds &, const range_bounds &)): Declare.
|
||||||
|
(operator!=(const range_bounds &, const range_bounds &)): Declare.
|
||||||
|
---
|
||||||
|
gdb/gdbtypes.c | 41 +++++++++++++++++++++++++++++++++++++++--
|
||||||
|
gdb/gdbtypes.h | 20 ++++++++++++++++++++
|
||||||
|
2 files changed, 59 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
Index: gdb-8.0.1/gdb/gdbtypes.c
|
||||||
|
===================================================================
|
||||||
|
--- gdb-8.0.1.orig/gdb/gdbtypes.c
|
||||||
|
+++ gdb-8.0.1/gdb/gdbtypes.c
|
||||||
|
@@ -855,6 +855,44 @@ allocate_stub_method (struct type *type)
|
||||||
|
return mtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* See gdbtypes.h. */
|
||||||
|
+
|
||||||
|
+bool
|
||||||
|
+operator== (const dynamic_prop &l, const dynamic_prop &r)
|
||||||
|
+{
|
||||||
|
+ if (l.kind != r.kind)
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
+ switch (l.kind)
|
||||||
|
+ {
|
||||||
|
+ case PROP_UNDEFINED:
|
||||||
|
+ return true;
|
||||||
|
+ case PROP_CONST:
|
||||||
|
+ return l.data.const_val == r.data.const_val;
|
||||||
|
+ case PROP_ADDR_OFFSET:
|
||||||
|
+ case PROP_LOCEXPR:
|
||||||
|
+ case PROP_LOCLIST:
|
||||||
|
+ return l.data.baton == r.data.baton;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ gdb_assert_not_reached ("unhandled dynamic_prop kind");
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/* See gdbtypes.h. */
|
||||||
|
+
|
||||||
|
+bool
|
||||||
|
+operator== (const range_bounds &l, const range_bounds &r)
|
||||||
|
+{
|
||||||
|
+#define FIELD_EQ(FIELD) (l.FIELD == r.FIELD)
|
||||||
|
+
|
||||||
|
+ return (FIELD_EQ (low)
|
||||||
|
+ && FIELD_EQ (high)
|
||||||
|
+ && FIELD_EQ (flag_upper_bound_is_count)
|
||||||
|
+ && FIELD_EQ (flag_bound_evaluated));
|
||||||
|
+
|
||||||
|
+#undef FIELD_EQ
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/* Create a range type with a dynamic range from LOW_BOUND to
|
||||||
|
HIGH_BOUND, inclusive. See create_range_type for further details. */
|
||||||
|
|
||||||
|
@@ -3466,8 +3504,7 @@ check_types_equal (struct type *type1, s
|
||||||
|
|
||||||
|
if (TYPE_CODE (type1) == TYPE_CODE_RANGE)
|
||||||
|
{
|
||||||
|
- if (memcmp (TYPE_RANGE_DATA (type1), TYPE_RANGE_DATA (type2),
|
||||||
|
- sizeof (*TYPE_RANGE_DATA (type1))) != 0)
|
||||||
|
+ if (*TYPE_RANGE_DATA (type1) != *TYPE_RANGE_DATA (type2))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Index: gdb-8.0.1/gdb/gdbtypes.h
|
||||||
|
===================================================================
|
||||||
|
--- gdb-8.0.1.orig/gdb/gdbtypes.h
|
||||||
|
+++ gdb-8.0.1/gdb/gdbtypes.h
|
||||||
|
@@ -408,6 +408,16 @@ struct dynamic_prop
|
||||||
|
union dynamic_prop_data data;
|
||||||
|
};
|
||||||
|
|
||||||
|
+/* Compare two dynamic_prop objects for equality. dynamic_prop
|
||||||
|
+ instances are equal iff they have the same type and storage. */
|
||||||
|
+extern bool operator== (const dynamic_prop &l, const dynamic_prop &r);
|
||||||
|
+
|
||||||
|
+/* Compare two dynamic_prop objects for inequality. */
|
||||||
|
+static inline bool operator!= (const dynamic_prop &l, const dynamic_prop &r)
|
||||||
|
+{
|
||||||
|
+ return !(l == r);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/* * Define a type's dynamic property node kind. */
|
||||||
|
enum dynamic_prop_node_kind
|
||||||
|
{
|
||||||
|
@@ -568,6 +578,16 @@ struct range_bounds
|
||||||
|
int flag_bound_evaluated : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
+/* Compare two range_bounds objects for equality. Simply does
|
||||||
|
+ memberwise comparison. */
|
||||||
|
+extern bool operator== (const range_bounds &l, const range_bounds &r);
|
||||||
|
+
|
||||||
|
+/* Compare two range_bounds objects for inequality. */
|
||||||
|
+static inline bool operator!= (const range_bounds &l, const range_bounds &r)
|
||||||
|
+{
|
||||||
|
+ return !(l == r);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
union type_specific
|
||||||
|
{
|
||||||
|
/* * CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to
|
|
@ -0,0 +1,320 @@
|
||||||
|
commit e379cee61f3890e535e995828e8846b020ef2a32
|
||||||
|
Author: Pedro Alves <palves@redhat.com>
|
||||||
|
Date: Fri Jan 5 18:26:18 2018 +0000
|
||||||
|
|
||||||
|
Fix regression: cannot start with LD_PRELOAD=libSegFault.so (PR gdb/18653#c7)
|
||||||
|
|
||||||
|
At https://sourceware.org/bugzilla/show_bug.cgi?id=18653#c7, Andrew
|
||||||
|
reports that the fix for PR gdb/18653 made GDB useless if you preload
|
||||||
|
libSegFault.so, because GDB internal-errors on startup:
|
||||||
|
|
||||||
|
$ LD_PRELOAD=libSegFault.so gdb
|
||||||
|
src/gdb/common/signals-state-save-restore.c:64: internal-error: unexpected signal handler
|
||||||
|
A problem internal to GDB has been detected,
|
||||||
|
further debugging may prove unreliable.
|
||||||
|
Aborted (core dumped)
|
||||||
|
$
|
||||||
|
|
||||||
|
The internal error comes from the code saving the signal dispositions
|
||||||
|
inherited from gdb's parent:
|
||||||
|
|
||||||
|
(top-gdb) bt
|
||||||
|
#0 0x000000000056b001 in internal_error(char const*, int, char const*, ...) (file=0xaf5f38 "src/gdb/common/signals-state-save-restore.c", line=64, fmt=0xaf5f18 "unexpected signal handler") at src/gdb/common/errors.c:54
|
||||||
|
#1 0x00000000005752c9 in save_original_signals_state() () at src/gdb/common/signals-state-save-restore.c:64
|
||||||
|
#2 0x00000000007425de in captured_main_1(captured_main_args*) (context=0x7fffffffd860)
|
||||||
|
at src/gdb/main.c:509
|
||||||
|
#3 0x0000000000743622 in captured_main(void*) (data=0x7fffffffd860) at src/gdb/main.c:1145
|
||||||
|
During symbol reading, cannot get low and high bounds for subprogram DIE at 24065.
|
||||||
|
#4 0x00000000007436f9 in gdb_main(captured_main_args*) (args=0x7fffffffd860) at src/gdb/main.c:1171
|
||||||
|
#5 0x0000000000413acd in main(int, char**) (argc=1, argv=0x7fffffffd968) at src/gdb/gdb.c:32
|
||||||
|
|
||||||
|
This commit downgrades the internal error to a warning. You'll get
|
||||||
|
instead:
|
||||||
|
|
||||||
|
~~~
|
||||||
|
$ LD_PRELOAD=libSegFault.so gdb
|
||||||
|
warning: Found custom handler for signal 11 (Segmentation fault) preinstalled.
|
||||||
|
Some signal dispositions inherited from the environment (SIG_DFL/SIG_IGN)
|
||||||
|
won't be propagated to spawned programs.
|
||||||
|
GNU gdb (GDB) 8.0.50.20171213-git
|
||||||
|
Copyright (C) 2017 Free Software Foundation, Inc.
|
||||||
|
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
||||||
|
This is free software: you are free to change and redistribute it.
|
||||||
|
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
|
||||||
|
and "show warranty" for details.
|
||||||
|
This GDB was configured as "x86_64-pc-linux-gnu".
|
||||||
|
Type "show configuration" for configuration details.
|
||||||
|
For bug reporting instructions, please see:
|
||||||
|
<http://www.gnu.org/software/gdb/bugs/>.
|
||||||
|
Find the GDB manual and other documentation resources online at:
|
||||||
|
<http://www.gnu.org/software/gdb/documentation/>.
|
||||||
|
For help, type "help".
|
||||||
|
Type "apropos word" to search for commands related to "word"...
|
||||||
|
(gdb)
|
||||||
|
~~~
|
||||||
|
|
||||||
|
This also moves the location where save_original_signals_state is
|
||||||
|
called a bit further below (to after option processing), so that "-q"
|
||||||
|
disables the warning:
|
||||||
|
|
||||||
|
~~~
|
||||||
|
$ LD_PRELOAD=libSegFault.so gdb -q
|
||||||
|
(gdb)
|
||||||
|
~~~
|
||||||
|
|
||||||
|
New testcase included.
|
||||||
|
|
||||||
|
gdb/ChangeLog:
|
||||||
|
2018-01-05 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
PR gdb/18653
|
||||||
|
* common/signals-state-save-restore.c
|
||||||
|
(save_original_signals_state): New parameter 'quiet'. Warn if we
|
||||||
|
find a custom handler preinstalled, instead of internal erroring.
|
||||||
|
But only warn if !quiet.
|
||||||
|
* common/signals-state-save-restore.h
|
||||||
|
(save_original_signals_state): New parameter 'quiet'.
|
||||||
|
* main.c (captured_main_1): Move save_original_signals_state call
|
||||||
|
after option handling, and pass QUIET.
|
||||||
|
|
||||||
|
gdb/gdbserver/ChangeLog:
|
||||||
|
2018-01-05 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
PR gdb/18653
|
||||||
|
* server.c (captured_main): Pass quiet=false to
|
||||||
|
save_original_signals_state.
|
||||||
|
|
||||||
|
gdb/testsuite/ChangeLog:
|
||||||
|
2018-01-05 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
PR gdb/18653
|
||||||
|
* gdb.base/libsegfault.exp: New.
|
||||||
|
|
||||||
|
### a/gdb/ChangeLog
|
||||||
|
### b/gdb/ChangeLog
|
||||||
|
## -1,3 +1,15 @@
|
||||||
|
+2018-01-05 Pedro Alves <palves@redhat.com>
|
||||||
|
+
|
||||||
|
+ PR gdb/18653
|
||||||
|
+ * common/signals-state-save-restore.c
|
||||||
|
+ (save_original_signals_state): New parameter 'quiet'. Warn if we
|
||||||
|
+ find a custom handler preinstalled, instead of internal erroring.
|
||||||
|
+ But only warn if !quiet.
|
||||||
|
+ * common/signals-state-save-restore.h
|
||||||
|
+ (save_original_signals_state): New parameter 'quiet'.
|
||||||
|
+ * main.c (captured_main_1): Move save_original_signals_state call
|
||||||
|
+ after option handling, and pass QUIET.
|
||||||
|
+
|
||||||
|
2018-01-05 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* spu-tdep.c (spu_catch_start): Pass
|
||||||
|
--- a/gdb/common/signals-state-save-restore.c
|
||||||
|
+++ b/gdb/common/signals-state-save-restore.c
|
||||||
|
@@ -35,7 +35,7 @@ static sigset_t original_signal_mask;
|
||||||
|
/* See signals-state-save-restore.h. */
|
||||||
|
|
||||||
|
void
|
||||||
|
-save_original_signals_state (void)
|
||||||
|
+save_original_signals_state (bool quiet)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_SIGACTION
|
||||||
|
int i;
|
||||||
|
@@ -45,6 +45,8 @@ save_original_signals_state (void)
|
||||||
|
if (res == -1)
|
||||||
|
perror_with_name (("sigprocmask"));
|
||||||
|
|
||||||
|
+ bool found_preinstalled = false;
|
||||||
|
+
|
||||||
|
for (i = 1; i < NSIG; i++)
|
||||||
|
{
|
||||||
|
struct sigaction *oldact = &original_signal_actions[i];
|
||||||
|
@@ -59,9 +61,31 @@ save_original_signals_state (void)
|
||||||
|
perror_with_name (("sigaction"));
|
||||||
|
|
||||||
|
/* If we find a custom signal handler already installed, then
|
||||||
|
- this function was called too late. */
|
||||||
|
- if (oldact->sa_handler != SIG_DFL && oldact->sa_handler != SIG_IGN)
|
||||||
|
- internal_error (__FILE__, __LINE__, _("unexpected signal handler"));
|
||||||
|
+ this function was called too late. This is a warning instead
|
||||||
|
+ of an internal error because this can also happen if you
|
||||||
|
+ LD_PRELOAD a library that installs a signal handler early via
|
||||||
|
+ __attribute__((constructor)), like libSegFault.so. */
|
||||||
|
+ if (!quiet
|
||||||
|
+ && oldact->sa_handler != SIG_DFL
|
||||||
|
+ && oldact->sa_handler != SIG_IGN)
|
||||||
|
+ {
|
||||||
|
+ found_preinstalled = true;
|
||||||
|
+
|
||||||
|
+ /* Use raw fprintf here because we're being called in early
|
||||||
|
+ startup, because GDB's filtered streams are are
|
||||||
|
+ created. */
|
||||||
|
+ fprintf (stderr,
|
||||||
|
+ _("warning: Found custom handler for signal "
|
||||||
|
+ "%d (%s) preinstalled.\n"), i,
|
||||||
|
+ strsignal (i));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (found_preinstalled)
|
||||||
|
+ {
|
||||||
|
+ fprintf (stderr, _("\
|
||||||
|
+Some signal dispositions inherited from the environment (SIG_DFL/SIG_IGN)\n\
|
||||||
|
+won't be propagated to spawned programs.\n"));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
--- a/gdb/common/signals-state-save-restore.h
|
||||||
|
+++ b/gdb/common/signals-state-save-restore.h
|
||||||
|
@@ -28,9 +28,10 @@
|
||||||
|
back to what was originally inherited from gdb/gdbserver's parent,
|
||||||
|
just before execing the target program to debug. */
|
||||||
|
|
||||||
|
-/* Save the signal state of all signals. */
|
||||||
|
+/* Save the signal state of all signals. If !QUIET, warn if we detect
|
||||||
|
+ a custom signal handler preinstalled. */
|
||||||
|
|
||||||
|
-extern void save_original_signals_state (void);
|
||||||
|
+extern void save_original_signals_state (bool quiet);
|
||||||
|
|
||||||
|
/* Restore the signal state of all signals. */
|
||||||
|
|
||||||
|
### a/gdb/gdbserver/ChangeLog
|
||||||
|
### b/gdb/gdbserver/ChangeLog
|
||||||
|
## -1,3 +1,9 @@
|
||||||
|
+2018-01-05 Pedro Alves <palves@redhat.com>
|
||||||
|
+
|
||||||
|
+ PR gdb/18653
|
||||||
|
+ * server.c (captured_main): Pass quiet=false to
|
||||||
|
+ save_original_signals_state.
|
||||||
|
+
|
||||||
|
2018-01-01 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
|
* gdbreplay.c (gdbreplay_version): Update copyright year in
|
||||||
|
--- a/gdb/gdbserver/server.c
|
||||||
|
+++ b/gdb/gdbserver/server.c
|
||||||
|
@@ -3712,7 +3712,7 @@ captured_main (int argc, char *argv[])
|
||||||
|
opened by remote_prepare. */
|
||||||
|
notice_open_fds ();
|
||||||
|
|
||||||
|
- save_original_signals_state ();
|
||||||
|
+ save_original_signals_state (false);
|
||||||
|
|
||||||
|
/* We need to know whether the remote connection is stdio before
|
||||||
|
starting the inferior. Inferiors created in this scenario have
|
||||||
|
--- a/gdb/main.c
|
||||||
|
+++ b/gdb/main.c
|
||||||
|
@@ -506,7 +506,6 @@ captured_main_1 (struct captured_main_args *context)
|
||||||
|
|
||||||
|
bfd_init ();
|
||||||
|
notice_open_fds ();
|
||||||
|
- save_original_signals_state ();
|
||||||
|
|
||||||
|
saved_command_line = (char *) xstrdup ("");
|
||||||
|
|
||||||
|
@@ -849,6 +848,8 @@ captured_main_1 (struct captured_main_args *context)
|
||||||
|
quiet = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ save_original_signals_state (quiet);
|
||||||
|
+
|
||||||
|
/* Try to set up an alternate signal stack for SIGSEGV handlers. */
|
||||||
|
setup_alternate_signal_stack ();
|
||||||
|
|
||||||
|
### a/gdb/testsuite/ChangeLog
|
||||||
|
### b/gdb/testsuite/ChangeLog
|
||||||
|
## -1,3 +1,8 @@
|
||||||
|
+2018-01-05 Pedro Alves <palves@redhat.com>
|
||||||
|
+
|
||||||
|
+ PR gdb/18653
|
||||||
|
+ * gdb.base/libsegfault.exp: New.
|
||||||
|
+
|
||||||
|
2018-01-05 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
|
PR gdb/22670
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/gdb/testsuite/gdb.base/libsegfault.exp
|
||||||
|
@@ -0,0 +1,84 @@
|
||||||
|
+# Copyright 2017-2018 Free Software Foundation, Inc.
|
||||||
|
+
|
||||||
|
+# This program is free software; you can redistribute it and/or modify
|
||||||
|
+# it under the terms of the GNU General Public License as published by
|
||||||
|
+# the Free Software Foundation; either version 3 of the License, or
|
||||||
|
+# (at your option) any later version.
|
||||||
|
+#
|
||||||
|
+# This program is distributed in the hope that it will be useful,
|
||||||
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
+# GNU General Public License for more details.
|
||||||
|
+#
|
||||||
|
+# You should have received a copy of the GNU General Public License
|
||||||
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
+
|
||||||
|
+# This file is part of the gdb testsuite.
|
||||||
|
+
|
||||||
|
+# Test that GDB tolerates being started with libSegFault.so preloaded
|
||||||
|
+# with LD_PRELOAD, and that GDB warns about a custom SIGSEGV custom
|
||||||
|
+# handler. See PR gdb/18653
|
||||||
|
+# <https://sourceware.org/bugzilla/show_bug.cgi?id=18653#c7>.
|
||||||
|
+
|
||||||
|
+# We cannot expect remote hosts to see environment variables set on
|
||||||
|
+# the local machine.
|
||||||
|
+if { [is_remote host] } {
|
||||||
|
+ unsupported "can't set environment variables on remote host"
|
||||||
|
+ return -1
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+# Spawn GDB with LIB preloaded with LD_PRELOAD. CMDLINE_OPTS are
|
||||||
|
+# command line options passed to GDB.
|
||||||
|
+
|
||||||
|
+proc gdb_spawn_with_ld_preload {lib cmdline_opts} {
|
||||||
|
+ global env
|
||||||
|
+
|
||||||
|
+ save_vars { env(LD_PRELOAD) } {
|
||||||
|
+ if { ![info exists env(LD_PRELOAD) ]
|
||||||
|
+ || $env(LD_PRELOAD) == "" } {
|
||||||
|
+ set env(LD_PRELOAD) "$lib"
|
||||||
|
+ } else {
|
||||||
|
+ append env(LD_PRELOAD) ":$lib"
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ gdb_spawn_with_cmdline_opts $cmdline_opts
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+proc test_libsegfault {} {
|
||||||
|
+ global gdb_prompt
|
||||||
|
+
|
||||||
|
+ set libsegfault "libSegFault.so"
|
||||||
|
+
|
||||||
|
+ # When started normally, if libSegFault.so is preloaded, GDB
|
||||||
|
+ # should warn about not being able to propagate the signal
|
||||||
|
+ # disposition of SIGSEGV.
|
||||||
|
+ gdb_exit
|
||||||
|
+ gdb_spawn_with_ld_preload $libsegfault ""
|
||||||
|
+
|
||||||
|
+ set test "gdb emits custom handler warning"
|
||||||
|
+ gdb_test_multiple "" $test {
|
||||||
|
+ -re "cannot be preloaded.*\r\n$gdb_prompt $" {
|
||||||
|
+ # Glibc 2.22 outputs:
|
||||||
|
+ # ERROR: ld.so: object 'libSegFault.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
|
||||||
|
+ untested "cannot preload libSegFault.so"
|
||||||
|
+ return
|
||||||
|
+ }
|
||||||
|
+ -re "Found custom handler.*won't be propagated.*\r\n$gdb_prompt $" {
|
||||||
|
+ pass $test
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ # "-q" should disable the warning, though.
|
||||||
|
+ gdb_exit
|
||||||
|
+ gdb_spawn_with_ld_preload $libsegfault "-q"
|
||||||
|
+
|
||||||
|
+ set test "quiet suppresses custom handler warning"
|
||||||
|
+ gdb_test_multiple "" $test {
|
||||||
|
+ -re "^$gdb_prompt $" {
|
||||||
|
+ pass $test
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+test_libsegfault
|
21
gdb.spec
21
gdb.spec
|
@ -26,7 +26,7 @@ Version: 8.0.1
|
||||||
|
|
||||||
# The release always contains a leading reserved number, start it at 1.
|
# The release always contains a leading reserved number, start it at 1.
|
||||||
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
|
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
|
||||||
Release: 33%{?dist}
|
Release: 36%{?dist}
|
||||||
|
|
||||||
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL
|
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL
|
||||||
Group: Development/Debuggers
|
Group: Development/Debuggers
|
||||||
|
@ -737,6 +737,13 @@ Patch1259: gdb-rhbz1498758-5of5.patch
|
||||||
Patch1261: gdb-rhbz1228556-bpt-inlined-func-name-1of2.patch
|
Patch1261: gdb-rhbz1228556-bpt-inlined-func-name-1of2.patch
|
||||||
Patch1262: gdb-rhbz1228556-bpt-inlined-func-name-2of2.patch
|
Patch1262: gdb-rhbz1228556-bpt-inlined-func-name-2of2.patch
|
||||||
|
|
||||||
|
# Fix random 'FAIL: libstdc++-prettyprinters/80276.cc whatis p4' (GCC
|
||||||
|
# PR83906) (Pedro Alves).
|
||||||
|
Patch1263: gdb-random-libstdcpp-prettyprinters-fail.patch
|
||||||
|
|
||||||
|
# Fix signal handlers regression (RH BZ 1542149, Pedro Alves).
|
||||||
|
Patch1270: gdb-rhbz1542149-spawn-default-signal-handlers-regression.patch
|
||||||
|
|
||||||
%if 0%{!?rhel:1} || 0%{?rhel} > 6
|
%if 0%{!?rhel:1} || 0%{?rhel} > 6
|
||||||
# RL_STATE_FEDORA_GDB would not be found for:
|
# RL_STATE_FEDORA_GDB would not be found for:
|
||||||
# Patch642: gdb-readline62-ask-more-rh.patch
|
# Patch642: gdb-readline62-ask-more-rh.patch
|
||||||
|
@ -1149,6 +1156,8 @@ done
|
||||||
%patch1259 -p1
|
%patch1259 -p1
|
||||||
%patch1261 -p1
|
%patch1261 -p1
|
||||||
%patch1262 -p1
|
%patch1262 -p1
|
||||||
|
%patch1263 -p1
|
||||||
|
%patch1270 -p1
|
||||||
|
|
||||||
%patch1075 -p1
|
%patch1075 -p1
|
||||||
%if 0%{?rhel:1} && 0%{?rhel} <= 7
|
%if 0%{?rhel:1} && 0%{?rhel} <= 7
|
||||||
|
@ -1731,6 +1740,16 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Feb 6 2018 Jan Kratochvil <jan.kratochvil@redhat.com> - 8.0.1-36.fc26
|
||||||
|
- Fix signal handlers regression (RH BZ 1542149, Pedro Alves).
|
||||||
|
|
||||||
|
* Thu Jan 25 2018 Sergio Durigan Junior <sergiodj@redhat.com> - 8.0.1-35.fc26
|
||||||
|
- Add %patch directive to the commit below.
|
||||||
|
|
||||||
|
* Wed Jan 24 2018 Sergio Durigan Junior <sergiodj@fedoraproject.org> - 8.0.1-34.fc26
|
||||||
|
- Fix random 'FAIL: libstdc++-prettyprinters/80276.cc whatis p4' (GCC PR83906)
|
||||||
|
(Pedro Alves).
|
||||||
|
|
||||||
* Wed Dec 6 2017 Jan Kratochvil <jan.kratochvil@redhat.com> - 8.0.1-33.fc26
|
* Wed Dec 6 2017 Jan Kratochvil <jan.kratochvil@redhat.com> - 8.0.1-33.fc26
|
||||||
- [rhel7] Fix C++ compiler compatibility.
|
- [rhel7] Fix C++ compiler compatibility.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue