proc-events.c: fix compilation on Solaris
[deliverable/binutils-gdb.git] / gdb / solib-darwin.c
index 0b975569e25c81f03ec1fc1f216d0aeeab534e67..d66938fb90561ad90583fa58cc79722b24463e18 100644 (file)
@@ -1,6 +1,6 @@
 /* Handle Darwin shared libraries for GDB, the GNU Debugger.
 
-   Copyright (C) 2009-2017 Free Software Foundation, Inc.
+   Copyright (C) 2009-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -67,7 +67,7 @@ struct gdb_dyld_all_image_infos
 
 /* Current all_image_infos version.  */
 #define DYLD_VERSION_MIN 1
-#define DYLD_VERSION_MAX 14
+#define DYLD_VERSION_MAX 15
 
 /* Per PSPACE specific data.  */
 struct darwin_info
@@ -153,18 +153,10 @@ darwin_load_image_infos (struct darwin_info *info)
 
 /* Link map info to include in an allocated so_list entry.  */
 
-struct lm_info
+struct lm_info_darwin : public lm_info_base
 {
   /* The target location of lm.  */
-  CORE_ADDR lm_addr;
-};
-
-struct darwin_so_list
-{
-  /* Common field.  */
-  struct so_list sl;
-  /* Darwin specific data.  */
-  struct lm_info li;
+  CORE_ADDR lm_addr = 0;
 };
 
 /* Lookup the value for a specific symbol.  */
@@ -230,7 +222,7 @@ find_program_interpreter (void)
     Note that darwin-nat.c implements pid_to_exec_file.  */
 
 static int
-open_symbol_file_object (void *from_ttyp)
+open_symbol_file_object (int from_tty)
 {
   return 0;
 }
@@ -269,9 +261,8 @@ darwin_current_sos (void)
       CORE_ADDR path_addr;
       struct mach_o_header_external hdr;
       unsigned long hdr_val;
-      char *file_path;
+      gdb::unique_xmalloc_ptr<char> file_path;
       int errcode;
-      struct darwin_so_list *dnew;
       struct so_list *newobj;
       struct cleanup *old_chain;
 
@@ -302,17 +293,16 @@ darwin_current_sos (void)
        break;
 
       /* Create and fill the new so_list element.  */
-      dnew = XCNEW (struct darwin_so_list);
-      newobj = &dnew->sl;
-      old_chain = make_cleanup (xfree, dnew);
+      newobj = XCNEW (struct so_list);
+      old_chain = make_cleanup (xfree, newobj);
 
-      newobj->lm_info = &dnew->li;
+      lm_info_darwin *li = new lm_info_darwin;
+      newobj->lm_info = li;
 
-      strncpy (newobj->so_name, file_path, SO_NAME_MAX_PATH_SIZE - 1);
+      strncpy (newobj->so_name, file_path.get (), SO_NAME_MAX_PATH_SIZE - 1);
       newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
       strcpy (newobj->so_original_name, newobj->so_name);
-      xfree (file_path);
-      newobj->lm_info->lm_addr = load_addr;
+      li->lm_addr = load_addr;
 
       if (head == NULL)
        head = newobj;
@@ -587,6 +577,9 @@ darwin_clear_solib (void)
 static void
 darwin_free_so (struct so_list *so)
 {
+  lm_info_darwin *li = (lm_info_darwin *) so->lm_info;
+
+  delete li;
 }
 
 /* The section table is built from bfd sections using bfd VMAs.
@@ -596,8 +589,10 @@ static void
 darwin_relocate_section_addresses (struct so_list *so,
                                   struct target_section *sec)
 {
-  sec->addr += so->lm_info->lm_addr;
-  sec->endaddr += so->lm_info->lm_addr;
+  lm_info_darwin *li = (lm_info_darwin *) so->lm_info;
+
+  sec->addr += li->lm_addr;
+  sec->endaddr += li->lm_addr;
 
   /* Best effort to set addr_high/addr_low.  This is used only by
      'info sharedlibary'.  */
@@ -621,18 +616,18 @@ darwin_lookup_lib_symbol (struct objfile *objfile,
 }
 
 static gdb_bfd_ref_ptr
-darwin_bfd_open (char *pathname)
+darwin_bfd_open (const char *pathname)
 {
-  char *found_pathname;
   int found_file;
 
   /* Search for shared library file.  */
-  found_pathname = solib_find (pathname, &found_file);
+  gdb::unique_xmalloc_ptr<char> found_pathname
+    = solib_find (pathname, &found_file);
   if (found_pathname == NULL)
     perror_with_name (pathname);
 
   /* Open bfd for shared library.  */
-  gdb_bfd_ref_ptr abfd (solib_bfd_fopen (found_pathname, found_file));
+  gdb_bfd_ref_ptr abfd (solib_bfd_fopen (found_pathname.get (), found_file));
 
   gdb_bfd_ref_ptr res
     (gdb_bfd_mach_o_fat_extract (abfd.get (), bfd_object,
@@ -652,9 +647,6 @@ darwin_bfd_open (char *pathname)
 
 struct target_so_ops darwin_so_ops;
 
-/* -Wmissing-prototypes */
-extern initialize_file_ftype _initialize_darwin_solib;
-
 void
 _initialize_darwin_solib (void)
 {
This page took 0.025975 seconds and 4 git commands to generate.