PR29262, memory leak in pr_function_type
[binutils-gdb.git] / gdb / target.c
index 5a416d5ee3a24415991b5c331fe76fafb1f62b67..18e53aa5d2768638513173243d62ec1ac459a5c8 100644 (file)
@@ -423,7 +423,7 @@ target_extra_thread_info (thread_info *tp)
 
 /* See target.h.  */
 
-char *
+const char *
 target_pid_to_exec_file (int pid)
 {
   return current_inferior ()->top_target ()->pid_to_exec_file (pid);
@@ -1394,25 +1394,6 @@ target_xfer_status_to_string (enum target_xfer_status status)
 };
 
 
-/* See target.h.  */
-
-gdb::unique_xmalloc_ptr<char>
-target_read_string (CORE_ADDR memaddr, int len, int *bytes_read)
-{
-  gdb::unique_xmalloc_ptr<gdb_byte> buffer;
-
-  int ignore;
-  if (bytes_read == nullptr)
-    bytes_read = &ignore;
-
-  /* Note that the endian-ness does not matter here.  */
-  int errcode = target_read_string (memaddr, -1, 1, len, &buffer, bytes_read);
-  if (errcode != 0)
-    return {};
-
-  return gdb::unique_xmalloc_ptr<char> ((char *) buffer.release ());
-}
-
 const target_section_table *
 target_get_section_table (struct target_ops *target)
 {
@@ -2674,21 +2655,24 @@ target_thread_info_to_thread_handle (struct thread_info *tip)
 }
 
 void
-target_resume (ptid_t ptid, int step, enum gdb_signal signal)
+target_resume (ptid_t scope_ptid, int step, enum gdb_signal signal)
 {
   process_stratum_target *curr_target = current_inferior ()->process_target ();
   gdb_assert (!curr_target->commit_resumed_state);
 
+  gdb_assert (inferior_ptid != null_ptid);
+  gdb_assert (inferior_ptid.matches (scope_ptid));
+
   target_dcache_invalidate ();
 
-  current_inferior ()->top_target ()->resume (ptid, step, signal);
+  current_inferior ()->top_target ()->resume (scope_ptid, step, signal);
 
-  registers_changed_ptid (curr_target, ptid);
+  registers_changed_ptid (curr_target, scope_ptid);
   /* We only set the internal executing state here.  The user/frontend
      running state is set at a higher level.  This also clears the
      thread's stop_pc as side effect.  */
-  set_executing (curr_target, ptid, true);
-  clear_inline_frame_state (curr_target, ptid);
+  set_executing (curr_target, scope_ptid, true);
+  clear_inline_frame_state (curr_target, scope_ptid);
 
   if (target_can_async_p ())
     target_async (1);