Rename common to gdbsupport
[deliverable/binutils-gdb.git] / gdb / target.c
index 5f596b6a3c93c0b9fa0dc76a86d271fe9d5fa761..de3706d75dc108d2c69ef769a8e4ce1293de62a3 100644 (file)
 #include "inline-frame.h"
 #include "tracepoint.h"
 #include "gdb/fileio.h"
-#include "common/agent.h"
+#include "gdbsupport/agent.h"
 #include "auxv.h"
 #include "target-debug.h"
 #include "top.h"
 #include "event-top.h"
 #include <algorithm>
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
 #include "terminal.h"
 #include <unordered_map>
 
@@ -704,7 +704,7 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
     {
       ptid_t ptid = inferior_ptid;
 
-      TRY
+      try
        {
          CORE_ADDR lm_addr;
          
@@ -720,7 +720,7 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
        }
       /* If an error occurred, print TLS related messages here.  Otherwise,
          throw the error to some higher catcher.  */
-      CATCH (ex, RETURN_MASK_ALL)
+      catch (const gdb_exception &ex)
        {
          int objfile_is_library = (objfile->flags & OBJF_SHARED);
 
@@ -759,19 +759,18 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
                error (_("Cannot find thread-local storage for %s, "
                         "shared library %s:\n%s"),
                       target_pid_to_str (ptid).c_str (),
-                      objfile_name (objfile), ex.message);
+                      objfile_name (objfile), ex.what ());
              else
                error (_("Cannot find thread-local storage for %s, "
                         "executable file %s:\n%s"),
                       target_pid_to_str (ptid).c_str (),
-                      objfile_name (objfile), ex.message);
+                      objfile_name (objfile), ex.what ());
              break;
            default:
-             throw_exception (ex);
+             throw;
              break;
            }
        }
-      END_CATCH
     }
   else
     error (_("Cannot find thread-local variables on this target"));
@@ -2013,6 +2012,11 @@ target_preopen (int from_tty)
 void
 target_detach (inferior *inf, int from_tty)
 {
+  /* After we have detached, we will clear the register cache for this inferior
+     by calling registers_changed_ptid.  We must save the pid_ptid before
+     detaching, as the target detach method will clear inf->pid.  */
+  ptid_t save_pid_ptid = ptid_t (inf->pid);
+
   /* As long as some to_detach implementations rely on the current_inferior
      (either directly, or indirectly, like through target_gdbarch or by
      reading memory), INF needs to be the current inferior.  When that
@@ -2033,14 +2037,11 @@ target_detach (inferior *inf, int from_tty)
 
   current_top_target ()->detach (inf, from_tty);
 
-  /* After we have detached, clear the register cache for this inferior.  */
-  ptid_t pid_ptid = ptid_t (inf->pid);
-
-  registers_changed_ptid (pid_ptid);
+  registers_changed_ptid (save_pid_ptid);
 
   /* We have to ensure we have no frame cache left.  Normally,
-     registers_changed_ptid (pid_ptid) calls reinit_frame_cache when
-     inferior_ptid matches pid_ptid, but in our case, it does not
+     registers_changed_ptid (save_pid_ptid) calls reinit_frame_cache when
+     inferior_ptid matches save_pid_ptid, but in our case, it does not
      call it, as inferior_ptid has been reset.  */
   reinit_frame_cache ();
 }
@@ -2096,6 +2097,14 @@ target_thread_handle_to_thread_info (const gdb_byte *thread_handle,
                                                     handle_len, inf);
 }
 
+/* See target.h.  */
+
+gdb::byte_vector
+target_thread_info_to_thread_handle (struct thread_info *tip)
+{
+  return current_top_target ()->thread_info_to_thread_handle (tip);
+}
+
 void
 target_resume (ptid_t ptid, int step, enum gdb_signal signal)
 {
@@ -2166,7 +2175,7 @@ target_follow_fork (int follow_child, int detach_fork)
 /* Target wrapper for follow exec hook.  */
 
 void
-target_follow_exec (struct inferior *inf, char *execd_pathname)
+target_follow_exec (struct inferior *inf, const char *execd_pathname)
 {
   current_top_target ()->follow_exec (inf, execd_pathname);
 }
@@ -3097,7 +3106,7 @@ target_fileio_read_stralloc (struct inferior *inf, const char *filename)
     return gdb::unique_xmalloc_ptr<char> (nullptr);
 
   if (transferred == 0)
-    return gdb::unique_xmalloc_ptr<char> (xstrdup (""));
+    return make_unique_xstrdup ("");
 
   bufstr[transferred] = 0;
 
This page took 0.027075 seconds and 4 git commands to generate.