/* libthread_db assisted debugging support, generic parts.
- Copyright (C) 1999-2020 Free Software Foundation, Inc.
+ Copyright (C) 1999-2021 Free Software Foundation, Inc.
This file is part of GDB.
/* 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
{
/* List of known processes using thread_db, and the required
bookkeeping. */
-struct thread_db_info *thread_db_list;
+static thread_db_info *thread_db_list;
static void thread_db_find_new_threads_1 (thread_info *stopped);
static void thread_db_find_new_threads_2 (thread_info *stopped,
fprintf_unfiltered (gdb_stdlog, _("td_ta_new failed: %s\n"),
thread_db_err_str (err));
else
- switch (err)
- {
- case TD_NOLIBTHREAD:
+ switch (err)
+ {
+ case TD_NOLIBTHREAD:
#ifdef THREAD_DB_HAS_TD_VERSION
- case TD_VERSION:
+ case TD_VERSION:
#endif
- /* The errors above are not unexpected and silently ignored:
- they just mean we haven't found correct version of
- libthread_db yet. */
- break;
- default:
- warning (_("td_ta_new failed: %s"), thread_db_err_str (err));
- }
+ /* The errors above are not unexpected and silently ignored:
+ they just mean we haven't found correct version of
+ libthread_db yet. */
+ break;
+ default:
+ warning (_("td_ta_new failed: %s"), thread_db_err_str (err));
+ }
return false;
}
else if (thread_db_find_new_threads_silently (inferior_thread ()) != 0)
{
/* Even if libthread_db initializes, if the thread list is
- corrupted, we'd not manage to list any threads. Better reject this
- thread_db, and fall back to at least listing LWPs. */
+ corrupted, we'd not manage to list any threads. Better reject this
+ thread_db, and fall back to at least listing LWPs. */
return false;
}
return false;
}
- if (!file_is_auto_load_safe (library, _("auto-load: Loading libthread-db "
- "library \"%s\" from explicit "
- "directory.\n"),
- library))
+ auto_load_debug_printf
+ ("Loading libthread-db library \"%s\" from explicit directory.",
+ library);
+
+ if (!file_is_auto_load_safe (library))
return false;
}
td_init = dlsym (handle, "td_init");
if (td_init != NULL)
- {
- const char *const libpath = dladdr_to_soname (td_init);
+ {
+ const char *const libpath = dladdr_to_soname (td_init);
- if (libpath != NULL)
- fprintf_unfiltered (gdb_stdlog, _("Host %s resolved to: %s.\n"),
- library, libpath);
- }
+ if (libpath != NULL)
+ fprintf_unfiltered (gdb_stdlog, _("Host %s resolved to: %s.\n"),
+ library, libpath);
+ }
}
info = add_thread_db_info (handle);
{
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;
}
}
}
}
static void
-check_pid_namespace_match (void)
+check_pid_namespace_match (inferior *inf)
{
/* Check is only relevant for local targets targets. */
if (target_can_run ())
child's thread list, we'll mistakenly think it has no threads
since the thread PID fields won't match the PID we give to
libthread_db. */
- if (!linux_ns_same (inferior_ptid.pid (), LINUX_NS_PID))
+ if (!linux_ns_same (inf->pid, LINUX_NS_PID))
{
warning (_ ("Target and debugger are in different PID "
"namespaces; thread lists and other data are "
This handles the case of debugging statically linked executables. */
static void
-thread_db_inferior_created (struct target_ops *target, int from_tty)
+thread_db_inferior_created (inferior *inf)
{
- check_pid_namespace_match ();
+ check_pid_namespace_match (inf);
check_for_thread_db ();
}
thread_db_thread_info *priv = get_thread_db_thread_info (tp);
if (priv != NULL && handle_tid == priv->tid)
- return tp;
+ return tp;
}
return NULL;
/* Now, if libthread_db provided the initialization image's
address, we *could* try to build a non-lvalue value from
the initialization image. */
- throw_error (TLS_NOT_ALLOCATED_YET_ERROR,
- _("TLS not allocated yet"));
+ throw_error (TLS_NOT_ALLOCATED_YET_ERROR,
+ _("TLS not allocated yet"));
#endif
/* Something else went wrong. */
if (err != TD_OK)
- throw_error (TLS_GENERIC_ERROR,
- (("%s")), thread_db_err_str (err));
+ throw_error (TLS_GENERIC_ERROR,
+ (("%s")), thread_db_err_str (err));
/* Cast assuming host == target. Joy. */
/* Do proper sign extension for the target. */
- gdb_assert (exec_bfd);
- return (bfd_get_sign_extend_vma (exec_bfd) > 0
+ gdb_assert (current_program_space->exec_bfd ());
+ return (bfd_get_sign_extend_vma (current_program_space->exec_bfd ()) > 0
? (CORE_ADDR) (intptr_t) address
: (CORE_ADDR) (uintptr_t) address);
}