gdb/gdb-try-to-load-libthread_db-only-after-reading-all-shared-libraries-when-attaching.patch
Tom de Vries 476969a0b2 - 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
2021-04-06 22:25:35 +00:00

78 lines
2.2 KiB
Diff

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;