- Fix various testsuite fails on Factory using backports:

* gdb-testsuite-fix-gdb.arch-amd64-stap-three-arg-disp.s.patch
  * gdb-testsuite-fix-xfail-handling-in-gdb.threads-gcore-thread.exp.patch
  * gdb-threads-fix-lin_thread_get_thread_signals-for-glibc-2.28.patch
- Fix libthread_db problem on Factory [swo#27526, boo#1184214]:
  * gdb-try-to-load-libthread_db-only-after-reading-all-shared-libraries-when-attaching.patch
- Workaround libncurses pulling in libpcre2_posix:
  * gdb-build-workaround-pcre2_posix-linking-problem.patch

OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=271
This commit is contained in:
Tom de Vries 2021-04-06 22:25:35 +00:00 committed by Git OBS Bridge
parent 0d5f9882f6
commit 476969a0b2
7 changed files with 534 additions and 0 deletions

View File

@ -0,0 +1,117 @@
[gdb/build] Workaround pcre2_posix linking problem
On openSUSE Tumbleweed, the ncurses package got the --with-pcre2 configure
switch enabled, and solved the resulting dependencies using:
...
$ cat /usr/lib64/libncursesw.so
/* GNU ld script */
-INPUT(/lib64/libncursesw.so.6 AS_NEEDED(-ltinfo -ldl))
+INPUT(/lib64/libncursesw.so.6 AS_NEEDED(-ltinfo -ldl -lpcre2-posix -lpcre2-8))
...
GDB uses the regexp functions regcomp, regerror, regfree, regexec and re_search, see
gdb_regex.c. The latter is a GNU extension.
Due to the changes mentioned above, the first four functions got bound to
lpcre2-posix, while re_search still got bound to lc, resulting in all sorts of
trouble, like hangs or:
...
$ gdb -q -batch -ex "apropos apropos"
Aborted (core dumped)
...
There is a debate whether it's legal to use re_search in combination with regcomp.
Either way, the immediate problem can be fixed/worked-around by adding -lc
before @LIBS@ in the CLIBS def in Makefile.in.
This is something that works with clang++, though not with g++, which drops
-lc, see PR gcc/99896. For g++, we can work around this by using -Wl,-lc
instead.
Add -lc before @LIBS@ in CLIBS def.
Tested on x86_64-linux.
gdb/ChangeLog:
2021-04-06 Tom de Vries <tdevries@suse.de>
PR build/27681
* Makefile.in (CDEFS): Add @LIBC@ before @LIBS@.
* configure.ac: Define LIBC.
* configure: Regenerate.
---
gdb/Makefile.in | 5 +++--
gdb/configure | 11 +++++++++++
gdb/configure.ac | 8 ++++++++
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 4808357e651..31a1009dd6d 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -620,11 +620,12 @@ INTERNAL_LDFLAGS = \
# Libraries and corresponding dependencies for compiling gdb.
# XM_CLIBS, defined in *config files, have host-dependent libs.
-# LIBIBERTY appears twice on purpose.
+# LIBIBERTY appears twice on purpose. LIBC is added before
+# LIBS to ensure that all functions in gdb_regex.c bind to libc.
CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) \
$(LIBSUPPORT) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
$(XM_CLIBS) $(GDBTKLIBS) \
- @LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
+ @LIBC@ @LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \
$(WIN32LIBS) $(LIBGNU) $(LIBICONV) \
$(LIBMPFR) $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \
diff --git a/gdb/configure b/gdb/configure
index e7811e807a6..4a8bf5cc78e 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -728,6 +728,7 @@ HAVE_PYTHON_TRUE
PYTHON_LIBS
PYTHON_CPPFLAGS
PYTHON_CFLAGS
+LIBC
python_prog_path
LTLIBMPFR
LIBMPFR
@@ -10983,6 +10984,16 @@ _ACEOF
fi
fi
+if test "${GCC}" = yes; then
+ # G++ drops -lc, so wrap it using -Wl. See PR gcc/99896.
+ GCC_LIBC="-Wl,-lc"
+ LIBC=$GCC_LIBC
+
+else
+ LIBC=-lc
+
+fi
+
# Check whether --with-python-libdir was given.
if test "${with_python_libdir+set}" = set; then :
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 620ae23e343..5bf44beb63a 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -891,6 +891,14 @@ else
fi
fi
+if test "${GCC}" = yes; then
+ # G++ drops -lc, so wrap it using -Wl. See PR gcc/99896.
+ GCC_LIBC="-Wl,-lc"
+ AC_SUBST(LIBC, $GCC_LIBC)
+else
+ AC_SUBST(LIBC, -lc)
+fi
+
dnl Use --with-python-libdir to control where GDB looks for the Python
dnl libraries.
dnl

View File

@ -0,0 +1,71 @@
[gdb/testsuite] Fix gdb.arch/amd64-stap-three-arg-disp.S
On SLE-11 I ran into:
...
(gdb) print $_probe_arg0^M
Cannot access memory at address 0x8000003fe05c^M
(gdb) FAIL: gdb.arch/amd64-stap-special-operands.exp: probe: three_arg: \
print $_probe_arg0
...
The memory cannot be accessed because the address used to evaluate
$_probe_arg0 at the probe point is incorrect.
The address is calculated using this expression:
...
.asciz "-4@-4(%rbp,%ebx,0)"
...
which uses $ebx, but $ebx is uninitialized at the probe point.
The test-case does contain a "movl $0, %ebx" insn to set $ebx to 0, but that
insn is placed after the probe point. We could fix this by moving the insn
to before the probe point. But, $ebx is also a callee-save register, so
normally, if we modify it, we also need to save and restore it, which is
currently not done. This is currently not harmful, because we don't run the
test-case further than the probe point, but it's bound to cause confusion.
So, fix this instead by using $eax instead in the expression, and moving the
insn setting $eax to 0 to before the probe point.
gdb/testsuite/ChangeLog:
2021-01-11 Tom de Vries <tdevries@suse.de>
PR testsuite/26968
* gdb.arch/amd64-stap-three-arg-disp.S: Remove insn modifying $ebx.
Move insn setting $eax to before probe point.
---
gdb/testsuite/gdb.arch/amd64-stap-three-arg-disp.S | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/gdb/testsuite/gdb.arch/amd64-stap-three-arg-disp.S b/gdb/testsuite/gdb.arch/amd64-stap-three-arg-disp.S
index cf3856f41e9..17b64048082 100644
--- a/gdb/testsuite/gdb.arch/amd64-stap-three-arg-disp.S
+++ b/gdb/testsuite/gdb.arch/amd64-stap-three-arg-disp.S
@@ -15,6 +15,7 @@ main:
movl %edi, -20(%rbp)
movq %rsi, -32(%rbp)
movl $10, -4(%rbp)
+ movl $0, %eax
#APP
# 8 "amd64-stap-three-arg-disp.c" 1
990: nop
@@ -28,7 +29,7 @@ main:
.8byte 0
.asciz "test"
.asciz "three_arg"
-.asciz "-4@-4(%rbp,%ebx,0)"
+.asciz "-4@-4(%rbp,%eax,0)"
994: .balign 4
.popsection
@@ -45,8 +46,6 @@ _.stapsdt.base: .space 1
# 0 "" 2
#NO_APP
- movl $0, %eax
- movl $0, %ebx
popq %rbp
.cfi_def_cfa 7, 8
# SUCC: EXIT [100.0%]

View File

@ -0,0 +1,80 @@
[gdb/testsuite] Fix xfail handling in gdb.threads/gcore-thread.exp
When running test-case gdb.threads/gcore-thread.exp on openSUSE Tumbleweed,
I run into these XFAILs:
...
XFAIL: gdb.threads/gcore-thread.exp: clear __stack_user.next
XFAIL: gdb.threads/gcore-thread.exp: clear stack_used.next
...
Apart from the xfail, the test-case also sets core0file to "":
...
-re "No symbol \"${symbol}\" in current context\\.\r\n$gdb_prompt $" {
xfail $test
# Do not do the verification.
set core0file ""
}
...
After which we run into this FAIL, because gdb_core_cmd fails to load a
core file called "":
...
(gdb) core ^M
No core file now.^M
(gdb) FAIL: gdb.threads/gcore-thread.exp: core0file: \
re-load generated corefile
...
Fix this FAIL by skipping gdb_core_cmd if the core file is "".
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-04-06 Tom de Vries <tdevries@suse.de>
PR testsuite/27691
* gdb.threads/gcore-thread.exp: Don't call gdb_core_cmd with core
file "".
---
gdb/testsuite/gdb.threads/gcore-thread.exp | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/gdb/testsuite/gdb.threads/gcore-thread.exp b/gdb/testsuite/gdb.threads/gcore-thread.exp
index 942bfb127b8..1bdeff1d460 100644
--- a/gdb/testsuite/gdb.threads/gcore-thread.exp
+++ b/gdb/testsuite/gdb.threads/gcore-thread.exp
@@ -114,11 +114,13 @@ if {"$core0file" != ""} {
# Now restart gdb and load the corefile.
clean_restart ${testfile}
-foreach name { corefile core0file } { with_test_prefix $name {
- set core_loaded [gdb_core_cmd [subst $$name] "re-load generated corefile"]
+proc load_core { filename } {
+ global horiz nl
+
+ set core_loaded [gdb_core_cmd $filename "re-load generated corefile"]
if { $core_loaded == -1 } {
# No use proceeding from here.
- continue
+ return
}
# FIXME: now what can we test about the thread state?
@@ -139,4 +141,14 @@ foreach name { corefile core0file } { with_test_prefix $name {
gdb_test "info threads" "\\* ${horiz} thread2 .*${nl}" \
"thread2 is current thread in corefile"
-}}
+}
+
+foreach name { corefile core0file } {
+ set filename [subst $$name]
+ if { $filename == "" } {
+ continue
+ }
+ with_test_prefix $name {
+ load_core $filename
+ }
+}

View File

@ -0,0 +1,167 @@
[gdb/threads] Fix lin_thread_get_thread_signals for glibc 2.28
When running test-case gdb.threads/create-fail.exp on openSUSE Factory
(with glibc version 2.32) I run into:
...
(gdb) continue
Continuing.
[New Thread 0x7ffff7c83700 (LWP 626354)]
[New Thread 0x7ffff7482700 (LWP 626355)]
[Thread 0x7ffff7c83700 (LWP 626354) exited]
[New Thread 0x7ffff6c81700 (LWP 626356)]
[Thread 0x7ffff7482700 (LWP 626355) exited]
[New Thread 0x7ffff6480700 (LWP 626357)]
[Thread 0x7ffff6c81700 (LWP 626356) exited]
[New Thread 0x7ffff5c7f700 (LWP 626358)]
[Thread 0x7ffff6480700 (LWP 626357) exited]
pthread_create: 22: Invalid argument
Thread 6 "create-fail" received signal SIG32, Real-time event 32.
[Switching to Thread 0x7ffff5c7f700 (LWP 626358)]
0x00007ffff7d87695 in clone () from /lib64/libc.so.6
(gdb) FAIL: gdb.threads/create-fail.exp: iteration 1: run till end
...
The problem is that glibc-internal signal SIGCANCEL is not recognized by gdb.
There's code in check_thread_signals that is supposed to take care of that,
but it's not working because this code in lin_thread_get_thread_signals has
stopped working:
...
/* NPTL reserves the first two RT signals, but does not provide any
way for the debugger to query the signal numbers - fortunately
they don't change. */
sigaddset (set, __SIGRTMIN);
sigaddset (set, __SIGRTMIN + 1);
...
Since glibc commit d2dc5467c6 "Filter out NPTL internal signals (BZ #22391)"
(first released as part of glibc 2.28), a sigaddset with a glibc-internal
signal has no other effect than setting errno to EINVALID.
Fix this by eliminating the usage of sigset_t in check_thread_signals and
lin_thread_get_thread_signals.
The same problem was observed on Ubuntu 20.04.
Tested on x86_64-linux, openSUSE Factory.
Tested on aarch64-linux, Ubuntu 20.04 and Ubuntu 18.04.
gdb/ChangeLog:
2021-02-12 Tom de Vries <tdevries@suse.de>
PR threads/26228
* linux-nat.c (lin_thread_get_thread_signals): Remove.
(lin_thread_signals): New static var.
(lin_thread_get_thread_signal_num, lin_thread_get_thread_signal):
New function.
* linux-nat.h (lin_thread_get_thread_signals): Remove.
(lin_thread_get_thread_signal_num, lin_thread_get_thread_signal):
Declare.
* linux-thread-db.c (check_thread_signals): Use
lin_thread_get_thread_signal_num and lin_thread_get_thread_signal.
---
gdb/linux-nat.c | 26 +++++++++++++++++---------
gdb/linux-nat.h | 7 +++++--
gdb/linux-thread-db.c | 21 +++++----------------
3 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index b81014024c7..36f769c285a 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4418,16 +4418,24 @@ Enables printf debugging output."),
the GNU/Linux Threads library and therefore doesn't really belong
here. */
-/* Return the set of signals used by the threads library in *SET. */
+/* NPTL reserves the first two RT signals, but does not provide any
+ way for the debugger to query the signal numbers - fortunately
+ they don't change. */
+static int lin_thread_signals[] = { __SIGRTMIN, __SIGRTMIN + 1 };
-void
-lin_thread_get_thread_signals (sigset_t *set)
+/* See linux-nat.h. */
+
+unsigned int
+lin_thread_get_thread_signal_num (void)
{
- sigemptyset (set);
+ return sizeof (lin_thread_signals) / sizeof (lin_thread_signals[0]);
+}
- /* NPTL reserves the first two RT signals, but does not provide any
- way for the debugger to query the signal numbers - fortunately
- they don't change. */
- sigaddset (set, __SIGRTMIN);
- sigaddset (set, __SIGRTMIN + 1);
+/* See linux-nat.h. */
+
+int
+lin_thread_get_thread_signal (unsigned int i)
+{
+ gdb_assert (i < lin_thread_get_thread_signal_num ());
+ return lin_thread_signals[i];
}
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index 1af9e830c83..6efc28f41ae 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -304,8 +304,11 @@ void check_for_thread_db (void);
true on success, false if the process isn't using libpthread. */
extern int thread_db_notice_clone (ptid_t parent, ptid_t child);
-/* Return the set of signals used by the threads library. */
-extern void lin_thread_get_thread_signals (sigset_t *mask);
+/* Return the number of signals used by the threads library. */
+extern unsigned int lin_thread_get_thread_signal_num (void);
+
+/* Return the i-th signal used by the threads library. */
+extern int lin_thread_get_thread_signal (unsigned int i);
/* Find process PID's pending signal set from /proc/pid/status. */
void linux_proc_pending_signals (int pid, sigset_t *pending,
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index b3cda05cd6e..5498308cf37 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -161,8 +161,6 @@ static thread_db_target the_thread_db_target;
/* Non-zero if we have determined the signals used by the threads
library. */
static int thread_signals;
-static sigset_t thread_stop_set;
-static sigset_t thread_print_set;
struct thread_db_info
{
@@ -1224,23 +1222,14 @@ check_thread_signals (void)
{
if (!thread_signals)
{
- sigset_t mask;
int i;
- lin_thread_get_thread_signals (&mask);
- sigemptyset (&thread_stop_set);
- sigemptyset (&thread_print_set);
-
- for (i = 1; i < NSIG; i++)
+ for (i = 0; i < lin_thread_get_thread_signal_num (); i++)
{
- if (sigismember (&mask, i))
- {
- if (signal_stop_update (gdb_signal_from_host (i), 0))
- sigaddset (&thread_stop_set, i);
- if (signal_print_update (gdb_signal_from_host (i), 0))
- sigaddset (&thread_print_set, i);
- thread_signals = 1;
- }
+ int sig = lin_thread_get_thread_signal (i);
+ signal_stop_update (gdb_signal_from_host (sig), 0);
+ signal_print_update (gdb_signal_from_host (sig), 0);
+ thread_signals = 1;
}
}
}

View File

@ -0,0 +1,77 @@
gdb: try to load libthread_db only after reading all shared libraries when attaching
https://sourceware.org/pipermail/gdb-patches/2021-March/177369.html
---
gdb/infcmd.c | 7 ++-----
gdb/linux-thread-db.c | 24 +++++++++++++++++++-----
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index cfc31699925..345cdc23b0d 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -347,6 +347,8 @@ post_create_inferior (struct target_ops *target, int from_tty)
if the now pushed target supports hardware watchpoints. */
breakpoint_re_set ();
+ current_inferior ()->needs_setup = 0;
+
gdb::observers::inferior_created.notify (target, from_tty);
}
@@ -2414,11 +2416,6 @@ proceed_after_attach (inferior *inf)
void
setup_inferior (int from_tty)
{
- struct inferior *inferior;
-
- inferior = current_inferior ();
- inferior->needs_setup = 0;
-
/* If no exec file is yet known, try to determine it from the
process itself. */
if (get_exec_file (0) == NULL)
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 5498308cf37..61c0237b0e3 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1010,8 +1010,19 @@ try_thread_db_load (const char *library, bool check_auto_load_safe)
if (strchr (library, '/') != NULL)
info->filename = gdb_realpath (library).release ();
- if (try_thread_db_load_1 (info))
- return true;
+ try
+ {
+ if (try_thread_db_load_1 (info))
+ return true;
+ }
+ catch (const gdb_exception &except)
+ {
+ if (libthread_db_debug)
+ {
+ exception_fprintf (gdb_stdlog, except,
+ "Warning: try_thread_db_load: ");
+ }
+ }
/* This library "refused" to work on current inferior. */
delete_thread_db_info (current_inferior ()->process_target (),
@@ -1182,10 +1193,13 @@ has_libpthread (void)
static bool
thread_db_load (void)
{
- struct thread_db_info *info;
+ inferior *inf = current_inferior ();
- info = get_thread_db_info (current_inferior ()->process_target (),
- inferior_ptid.pid ());
+ if (inf->needs_setup)
+ return false;
+
+ thread_db_info *info = get_thread_db_info (inf->process_target (),
+ inferior_ptid.pid ());
if (info != NULL)
return true;

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Tue Apr 6 15:15:10 UTC 2021 - Tom de Vries <tdevries@suse.com>
- Fix various testsuite fails on Factory using backports:
* gdb-testsuite-fix-gdb.arch-amd64-stap-three-arg-disp.s.patch
* gdb-testsuite-fix-xfail-handling-in-gdb.threads-gcore-thread.exp.patch
* gdb-threads-fix-lin_thread_get_thread_signals-for-glibc-2.28.patch
- Fix libthread_db problem on Factory [swo#27526, boo#1184214]:
* gdb-try-to-load-libthread_db-only-after-reading-all-shared-libraries-when-attaching.patch
- Workaround libncurses pulling in libpcre2_posix:
* gdb-build-workaround-pcre2_posix-linking-problem.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Feb 11 16:13:14 UTC 2021 - Tom de Vries <tdevries@suse.com> Thu Feb 11 16:13:14 UTC 2021 - Tom de Vries <tdevries@suse.com>

View File

@ -294,6 +294,8 @@ Patch1511: gdb-testsuite-gdb-tui-new-layout-exp-partly-require-tcl86.patch
Patch1512: gdb-tui-enable-work-around-libncurses-segfault.patch Patch1512: gdb-tui-enable-work-around-libncurses-segfault.patch
Patch1513: gdb-testsuite-fix-control-flow-in-gdb-reverse-insn-reverse-exp.patch Patch1513: gdb-testsuite-fix-control-flow-in-gdb-reverse-insn-reverse-exp.patch
Patch1514: gdb-fix-use-of-invalid-pointer-in-remote-async-inferior-event-handler.patch Patch1514: gdb-fix-use-of-invalid-pointer-in-remote-async-inferior-event-handler.patch
Patch1515: gdb-try-to-load-libthread_db-only-after-reading-all-shared-libraries-when-attaching.patch
Patch1516: gdb-build-workaround-pcre2_posix-linking-problem.patch
# Backports from master # Backports from master
@ -309,6 +311,9 @@ Patch2009: gdb-testsuite-fix-failure-in-gdb-base-step-over-no-symbols-exp.p
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 Patch2011: gdb-fix-internal-error-in-process_event_stop_test.patch
Patch2012: gdb-breakpoints-handle-glibc-with-debuginfo-in-create_exception_master_breakpoint.patch Patch2012: gdb-breakpoints-handle-glibc-with-debuginfo-in-create_exception_master_breakpoint.patch
Patch2013: gdb-testsuite-fix-gdb.arch-amd64-stap-three-arg-disp.s.patch
Patch2014: gdb-testsuite-fix-xfail-handling-in-gdb.threads-gcore-thread.exp.patch
Patch2015: gdb-threads-fix-lin_thread_get_thread_signals-for-glibc-2.28.patch
# Testsuite patches # Testsuite patches
@ -705,6 +710,8 @@ find -name "*.info*"|xargs rm -f
%patch1512 -p1 %patch1512 -p1
%patch1513 -p1 %patch1513 -p1
%patch1514 -p1 %patch1514 -p1
%patch1515 -p1
%patch1516 -p1
%patch2000 -p1 %patch2000 -p1
%patch2002 -p1 %patch2002 -p1
@ -718,6 +725,9 @@ find -name "*.info*"|xargs rm -f
%patch2010 -p1 %patch2010 -p1
%patch2011 -p1 %patch2011 -p1
%patch2012 -p1 %patch2012 -p1
%patch2013 -p1
%patch2014 -p1
%patch2015 -p1
%patch2500 -p1 %patch2500 -p1
%if 0%{?suse_version} > 1500 %if 0%{?suse_version} > 1500