gas: Update commit 4780e5e4933
[binutils-gdb.git] / gdbserver / inferiors.cc
index 0a09de79071d20c97352970c78ac85c844984c8b..a636266c798fd4a1d5a16c883544c77fa1a73dcc 100644 (file)
@@ -28,25 +28,21 @@ std::list<thread_info *> all_threads;
 
 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;
 }
 
@@ -91,8 +87,7 @@ find_any_thread_of_pid (int pid)
 static void
 free_one_thread (thread_info *thread)
 {
-  free_register_cache (thread_regcache_data (thread));
-  free (thread);
+  delete thread;
 }
 
 void
@@ -235,7 +230,7 @@ switch_to_process (process_info *proc)
 
 /* See gdbsupport/common-inferior.h.  */
 
-const char *
+const std::string &
 get_inferior_cwd ()
 {
   return current_inferior_cwd;
@@ -244,11 +239,7 @@ get_inferior_cwd ()
 /* 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);
 }