/* Inferior process information for the remote server for GDB.
- Copyright (C) 2002-2020 Free Software Foundation, Inc.
+ Copyright (C) 2002-2021 Free Software Foundation, Inc.
Contributed by MontaVista Software.
struct thread_info *current_thread;
-/* The current working directory used to start the inferior. */
-static const char *current_inferior_cwd = NULL;
+/* The current working directory used to start the inferior.
+
+ Empty if not specified. */
+static std::string current_inferior_cwd;
struct thread_info *
add_thread (ptid_t thread_id, void *target_data)
{
- struct thread_info *new_thread = XCNEW (struct thread_info);
-
- new_thread->id = thread_id;
- new_thread->last_resume_kind = resume_continue;
- new_thread->last_status.kind = TARGET_WAITKIND_IGNORE;
+ thread_info *new_thread = new thread_info (thread_id, target_data);
all_threads.push_back (new_thread);
if (current_thread == NULL)
current_thread = new_thread;
- new_thread->target_data = target_data;
-
return new_thread;
}
static void
free_one_thread (thread_info *thread)
{
- free_register_cache (thread_regcache_data (thread));
- free (thread);
+ delete thread;
}
void
discard_queued_stop_replies (ptid_of (thread));
all_threads.remove (thread);
- free_one_thread (thread);
if (current_thread == thread)
current_thread = NULL;
+ free_one_thread (thread);
}
void *
current_thread = find_thread_ptid (ptid);
}
+/* See inferiors.h. */
+
+void
+switch_to_process (process_info *proc)
+{
+ int pid = pid_of (proc);
+
+ current_thread = find_any_thread_of_pid (pid);
+}
+
/* See gdbsupport/common-inferior.h. */
-const char *
+const std::string &
get_inferior_cwd ()
{
return current_inferior_cwd;
}
-/* See gdbsupport/common-inferior.h. */
+/* See inferiors.h. */
void
-set_inferior_cwd (const char *cwd)
+set_inferior_cwd (std::string cwd)
{
- xfree ((void *) current_inferior_cwd);
- if (cwd != NULL)
- current_inferior_cwd = xstrdup (cwd);
- else
- current_inferior_cwd = NULL;
+ current_inferior_cwd = std::move (cwd);
}