/* Thread management interface, for the remote server for GDB.
- Copyright (C) 2002-2017 Free Software Foundation, Inc.
+ Copyright (C) 2002-2020 Free Software Foundation, Inc.
Contributed by MontaVista Software.
#include "linux-low.h"
-extern int debug_threads;
-
+#include "debug.h"
#include "gdb_proc_service.h"
#include "nat/gdb_thread_db.h"
-#include "gdb_vecs.h"
+#include "gdbsupport/gdb_vecs.h"
#include "nat/linux-procfs.h"
-#include "common/scoped_restore.h"
+#include "gdbsupport/scoped_restore.h"
#ifndef USE_LIBTHREAD_DB_DIRECTLY
#include <dlfcn.h>
td_thrhandle_t th;
td_thrinfo_t ti;
td_err_e err;
- struct thread_info *inferior;
struct lwp_info *lwp;
struct thread_db *thread_db = current_process ()->priv->thread_db;
- int lwpid = ptid_get_lwp (ptid);
+ int lwpid = ptid.lwp ();
- inferior = (struct thread_info *) find_inferior_id (&all_threads, ptid);
- lwp = get_thread_lwp (inferior);
+ thread_info *thread = find_thread_ptid (ptid);
+ lwp = get_thread_lwp (thread);
if (lwp->thread_known)
return 1;
{
struct process_info *proc = current_process ();
int pid = pid_of (proc);
- ptid_t ptid = ptid_build (pid, ti_p->ti_lid, 0);
+ ptid_t ptid = ptid_t (pid, ti_p->ti_lid, 0);
struct lwp_info *lwp;
int err;
err = linux_attach_lwp (ptid);
if (err != 0)
{
- warning ("Could not attach to thread %ld (LWP %d): %s\n",
- (unsigned long) ti_p->ti_tid, ti_p->ti_lid,
- linux_ptrace_attach_fail_reason_string (ptid, err));
+ std::string reason = linux_ptrace_attach_fail_reason_string (ptid, err);
+
+ warning ("Could not attach to thread %ld (LWP %d): %s",
+ (unsigned long) ti_p->ti_tid, ti_p->ti_lid, reason.c_str ());
+
return 0;
}
{
struct lwp_info *lwp;
- lwp = find_lwp_pid (pid_to_ptid (ti_p->ti_lid));
+ lwp = find_lwp_pid (ptid_t (ti_p->ti_lid));
if (lwp != NULL)
return 1;
{
struct thread_db *thread_db;
struct lwp_info *lwp;
- struct thread_info *thread
- = (struct thread_info *) find_inferior_id (&all_threads, ptid);
+ thread_info *thread = find_thread_ptid (ptid);
if (thread == NULL)
return false;
static int
thread_db_load_search (void)
{
- VEC (char_ptr) *dir_vec;
- char *this_dir;
- int i, rc = 0;
+ int rc = 0;
if (libthread_db_search_path == NULL)
libthread_db_search_path = xstrdup (LIBTHREAD_DB_SEARCH_PATH);
- dir_vec = dirnames_to_char_ptr_vec (libthread_db_search_path);
+ std::vector<gdb::unique_xmalloc_ptr<char>> dir_vec
+ = dirnames_to_char_ptr_vec (libthread_db_search_path);
- for (i = 0; VEC_iterate (char_ptr, dir_vec, i, this_dir); ++i)
+ for (const gdb::unique_xmalloc_ptr<char> &this_dir_up : dir_vec)
{
+ char *this_dir = this_dir_up.get ();
const int pdir_len = sizeof ("$pdir") - 1;
size_t this_dir_len;
}
}
- free_char_ptr_vec (dir_vec);
if (debug_threads)
debug_printf ("thread_db_load_search returning %d\n", rc);
return rc;
= make_scoped_restore (¤t_thread, parent_thr);
if (!find_one_thread (child_ptid))
- warning ("Cannot find thread after clone.\n");
+ warning ("Cannot find thread after clone.");
}