PR gdb/24364: Don't call dtrace_process_dof with NULL dof.
[deliverable/binutils-gdb.git] / gdb / fbsd-tdep.c
index f06836216d9ed865668834c753579fd6d1961f1e..e81c6c99bff254bf63cb0f4e6ccba9dec3947f54 100644 (file)
@@ -445,53 +445,37 @@ get_fbsd_gdbarch_data (struct gdbarch *gdbarch)
          gdbarch_data (gdbarch, fbsd_gdbarch_data_handle));
 }
 
-/* Per-program-space data for FreeBSD architectures.  */
-static const struct program_space_data *fbsd_pspace_data_handle;
-
 struct fbsd_pspace_data
 {
   /* Offsets in the runtime linker's 'Obj_Entry' structure.  */
-  LONGEST off_linkmap;
-  LONGEST off_tlsindex;
-  bool rtld_offsets_valid;
+  LONGEST off_linkmap = 0;
+  LONGEST off_tlsindex = 0;
+  bool rtld_offsets_valid = false;
 };
 
+/* Per-program-space data for FreeBSD architectures.  */
+static const struct program_space_key<fbsd_pspace_data>
+  fbsd_pspace_data_handle;
+
 static struct fbsd_pspace_data *
 get_fbsd_pspace_data (struct program_space *pspace)
 {
   struct fbsd_pspace_data *data;
 
-  data = ((struct fbsd_pspace_data *)
-         program_space_data (pspace, fbsd_pspace_data_handle));
+  data = fbsd_pspace_data_handle.get (pspace);
   if (data == NULL)
-    {
-      data = XCNEW (struct fbsd_pspace_data);
-      set_program_space_data (pspace, fbsd_pspace_data_handle, data);
-    }
+    data = fbsd_pspace_data_handle.emplace (pspace);
 
   return data;
 }
 
-/* The cleanup callback for FreeBSD architecture per-program-space data.  */
-
-static void
-fbsd_pspace_data_cleanup (struct program_space *pspace, void *data)
-{
-  xfree (data);
-}
-
 /* This is how we want PTIDs from core files to be printed.  */
 
-static const char *
+static std::string
 fbsd_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
 {
-  static char buf[80];
-
   if (ptid.lwp () != 0)
-    {
-      xsnprintf (buf, sizeof buf, "LWP %ld", ptid.lwp ());
-      return buf;
-    }
+    return string_printf ("LWP %ld", ptid.lwp ());
 
   return normal_pid_to_str (ptid);
 }
@@ -751,15 +735,14 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
     }
 
   /* Thread register information.  */
-  TRY
+  try
     {
       update_thread_list ();
     }
-  CATCH (e, RETURN_MASK_ERROR)
+  catch (const gdb_exception_error &e)
     {
       exception_print (gdb_stderr, e);
     }
-  END_CATCH
 
   /* Like the kernel, prefer dumping the signalled thread first.
      "First thread" is what tools use to infer the signalled thread.
@@ -1283,7 +1266,7 @@ fbsd_core_vnode_path (struct gdbarch *gdbarch, int fd)
          && bfd_get_signed_32 (core_bfd, descdata + KF_FD) == fd)
        {
          char *path = (char *) descdata + KF_PATH;
-         return gdb::unique_xmalloc_ptr<char> (xstrdup (path));
+         return make_unique_xstrdup (path);
        }
 
       descdata += structsize;
@@ -1990,7 +1973,7 @@ fbsd_read_integer_by_name (struct gdbarch *gdbarch, const char *name)
 static void
 fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data)
 {
-  TRY
+  try
     {
       /* Fetch offsets from debug symbols in rtld.  */
       struct symbol *obj_entry_sym
@@ -2005,13 +1988,12 @@ fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data)
       data->rtld_offsets_valid = true;
       return;
     }
-  CATCH (e, RETURN_MASK_ERROR)
+  catch (const gdb_exception_error &e)
     {
       data->off_linkmap = -1;
     }
-  END_CATCH
 
-  TRY
+  try
     {
       /* Fetch offsets from global variables in libthr.  Note that
         this does not work for single-threaded processes that are not
@@ -2023,11 +2005,10 @@ fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data)
       data->rtld_offsets_valid = true;
       return;
     }
-  CATCH (e, RETURN_MASK_ERROR)
+  catch (const gdb_exception_error &e)
     {
       data->off_linkmap = -1;
     }
-  END_CATCH
 }
 
 /* Helper function to read the TLS index of an object file associated
@@ -2108,6 +2089,4 @@ _initialize_fbsd_tdep (void)
 {
   fbsd_gdbarch_data_handle =
     gdbarch_data_register_post_init (init_fbsd_gdbarch_data);
-  fbsd_pspace_data_handle
-    = register_program_space_data_with_cleanup (NULL, fbsd_pspace_data_cleanup);
 }
This page took 0.025448 seconds and 4 git commands to generate.