The "record goto" command scans its arguments for "begin", "start", or "end".
[deliverable/binutils-gdb.git] / gdb / machoread.c
index eb56f14629cd1612ab4225ac2546efca23d6d405..9877f07b4d343df6aad6c30bd9b2639be3797108 100644 (file)
@@ -1,5 +1,5 @@
 /* Darwin support for GDB, the GNU debugger.
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    Contributed by AdaCore.
 
 #include "vec.h"
 #include "psympriv.h"
 #include "complaints.h"
+#include "gdb_bfd.h"
 
 #include <string.h>
 
 /* If non-zero displays debugging message.  */
-static int mach_o_debug_level = 0;
+static unsigned int mach_o_debug_level = 0;
 
 /* Dwarf debugging information are never in the final executable.  They stay
    in object files and the executable contains the list of object files read
@@ -78,7 +79,6 @@ static void
 macho_symfile_init (struct objfile *objfile)
 {
   objfile->flags |= OBJF_REORDERED;
-  init_entry_point_info (objfile);
 }
 
 /*  Add a new OSO to the vector of OSO to load.  */
@@ -116,7 +116,8 @@ macho_symtab_add_minsym (struct objfile *objfile, const asymbol *sym)
       CORE_ADDR offset;
       enum minimal_symbol_type ms_type;
 
-      offset = ANOFFSET (objfile->section_offsets, sym->section->index);
+      offset = ANOFFSET (objfile->section_offsets,
+                        gdb_bfd_section_index (objfile->obfd, sym->section));
 
       /* Bfd symbols are section relative.  */
       symaddr = sym->value + sym->section->vma;
@@ -164,8 +165,9 @@ macho_symtab_add_minsym (struct objfile *objfile, const asymbol *sym)
         return;        /* Skip this symbol.  */
 
       prim_record_minimal_symbol_and_info
-        (sym->name, symaddr, ms_type, sym->section->index,
-         sym->section, objfile);
+        (sym->name, symaddr, ms_type,
+        gdb_bfd_section_index (objfile->obfd, sym->section),
+        objfile);
     }
 }
 
@@ -454,6 +456,7 @@ macho_add_oso_symfile (oso_el *oso, bfd *abfd,
   asymbol **symp;
   struct bfd_hash_table table;
   int nbr_sections;
+  struct cleanup *cleanup;
 
   /* Per section flag to mark which section have been rebased.  */
   unsigned char *sections_rebased;
@@ -629,18 +632,15 @@ macho_add_oso_symfile (oso_el *oso, bfd *abfd,
 
   bfd_hash_table_free (&table);
 
-  /* Make sure that the filename was malloc'ed.  The current filename comes
-     either from an OSO symbol name or from an archive name.  Memory for both
-     is not managed by gdb.  */
-  abfd->filename = xstrdup (abfd->filename);
-
   /* We need to clear SYMFILE_MAINLINE to avoid interractive question
      from symfile.c:symbol_file_add_with_addrs_or_offsets.  */
+  cleanup = make_cleanup_bfd_unref (abfd);
   symbol_file_add_from_bfd
     (abfd, symfile_flags & ~(SYMFILE_MAINLINE | SYMFILE_VERBOSE), NULL,
      main_objfile->flags & (OBJF_REORDERED | OBJF_SHARED
                            | OBJF_READNOW | OBJF_USERLOADED),
      main_objfile);
+  do_cleanups (cleanup);
 }
 
 /* Read symbols from the vector of oso files.  */
@@ -651,6 +651,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
   int ix;
   VEC (oso_el) *vec;
   oso_el *oso;
+  struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
 
   vec = oso_vector;
   oso_vector = NULL;
@@ -677,6 +678,8 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
          memcpy (archive_name, oso->name, pfx_len);
          archive_name[pfx_len] = '\0';
 
+         make_cleanup (xfree, archive_name);
+
           /* Compute number of oso for this archive.  */
           for (last_ix = ix;
                VEC_iterate (oso_el, vec, last_ix, oso2); last_ix++)
@@ -686,7 +689,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
             }
 
          /* Open the archive and check the format.  */
-         archive_bfd = gdb_bfd_ref (bfd_openr (archive_name, gnutarget));
+         archive_bfd = gdb_bfd_open (archive_name, gnutarget, -1);
          if (archive_bfd == NULL)
            {
              warning (_("Could not open OSO archive file \"%s\""),
@@ -702,8 +705,8 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
               ix = last_ix;
              continue;
            }
-         member_bfd = gdb_bfd_ref (bfd_openr_next_archived_file (archive_bfd,
-                                                                 NULL));
+
+         member_bfd = gdb_bfd_openr_next_archived_file (archive_bfd, NULL);
 
          if (member_bfd == NULL)
            {
@@ -739,9 +742,8 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
                 }
 
               prev = member_bfd;
-             member_bfd
-               = gdb_bfd_ref (bfd_openr_next_archived_file (archive_bfd,
-                                                            member_bfd));
+             member_bfd = gdb_bfd_openr_next_archived_file (archive_bfd,
+                                                            member_bfd);
 
               /* Free previous member if not referenced by an oso.  */
               if (ix2 >= last_ix)
@@ -761,7 +763,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
        {
           bfd *abfd;
 
-         abfd = gdb_bfd_ref (bfd_openr (oso->name, gnutarget));
+         abfd = gdb_bfd_open (oso->name, gnutarget, -1);
          if (!abfd)
             warning (_("`%s': can't open to read symbols: %s."), oso->name,
                      bfd_errmsg (bfd_get_error ()));
@@ -773,6 +775,7 @@ macho_symfile_read_all_oso (struct objfile *main_objfile, int symfile_flags)
     }
 
   VEC_free (oso_el, vec);
+  do_cleanups (cleanup);
 }
 
 /* DSYM (debug symbols) files contain the debug info of an executable.
@@ -810,12 +813,10 @@ macho_check_dsym (struct objfile *objfile)
       warning (_("can't find UUID in %s"), objfile->name);
       return NULL;
     }
-  dsym_filename = xstrdup (dsym_filename);
-  dsym_bfd = gdb_bfd_ref (bfd_openr (dsym_filename, gnutarget));
+  dsym_bfd = gdb_bfd_openr (dsym_filename, gnutarget);
   if (dsym_bfd == NULL)
     {
       warning (_("can't open dsym file %s"), dsym_filename);
-      xfree (dsym_filename);
       return NULL;
     }
 
@@ -823,7 +824,6 @@ macho_check_dsym (struct objfile *objfile)
     {
       gdb_bfd_unref (dsym_bfd);
       warning (_("bad dsym file format: %s"), bfd_errmsg (bfd_get_error ()));
-      xfree (dsym_filename);
       return NULL;
     }
 
@@ -832,7 +832,6 @@ macho_check_dsym (struct objfile *objfile)
     {
       warning (_("can't find UUID in %s"), dsym_filename);
       gdb_bfd_unref (dsym_bfd);
-      xfree (dsym_filename);
       return NULL;
     }
   if (memcmp (dsym_uuid->command.uuid.uuid, main_uuid->command.uuid.uuid,
@@ -840,7 +839,6 @@ macho_check_dsym (struct objfile *objfile)
     {
       warning (_("dsym file UUID doesn't match the one in %s"), objfile->name);
       gdb_bfd_unref (dsym_bfd);
-      xfree (dsym_filename);
       return NULL;
     }
   return dsym_bfd;
@@ -904,6 +902,7 @@ macho_symfile_read (struct objfile *objfile, int symfile_flags)
          int ix;
          oso_el *oso;
           struct bfd_section *asect, *dsect;
+         struct cleanup *cleanup;
 
          if (mach_o_debug_level > 0)
            printf_unfiltered (_("dsym file found\n"));
@@ -924,7 +923,9 @@ macho_symfile_read (struct objfile *objfile, int symfile_flags)
             }
 
          /* Add the dsym file as a separate file.  */
+         cleanup = make_cleanup_bfd_unref (dsym_bfd);
           symbol_file_add_separate (dsym_bfd, symfile_flags, objfile);
+         do_cleanups (cleanup);
 
          /* Don't try to read dwarf2 from main file or shared libraries.  */
           return;
@@ -967,7 +968,7 @@ macho_symfile_finish (struct objfile *objfile)
 
 static void
 macho_symfile_offsets (struct objfile *objfile,
-                       struct section_addr_info *addrs)
+                       const struct section_addr_info *addrs)
 {
   unsigned int i;
   unsigned int num_sections;
@@ -992,9 +993,6 @@ macho_symfile_offsets (struct objfile *objfile,
 
   for (i = 0; i < addrs->num_sections; i++)
     {
-      if (addrs->other[i].name == NULL)
-       continue;
-
       ALL_OBJFILE_OSECTIONS (objfile, osect)
        {
          const char *bfd_sect_name = osect->the_bfd_section->name;
@@ -1012,7 +1010,7 @@ macho_symfile_offsets (struct objfile *objfile,
   ALL_OBJFILE_OSECTIONS (objfile, osect)
     {
       const char *bfd_sect_name = osect->the_bfd_section->name;
-      int sect_index = osect->the_bfd_section->index;
+      int sect_index = osect - objfile->sections;;
 
       if (strncmp (bfd_sect_name, "LC_SEGMENT.", 11) == 0)
        bfd_sect_name += 11;
@@ -1046,10 +1044,10 @@ _initialize_machoread ()
 {
   add_symtab_fns (&macho_sym_fns);
 
-  add_setshow_zinteger_cmd ("mach-o", class_obscure,
-                           &mach_o_debug_level,
-                           _("Set if printing Mach-O symbols processing."),
-                           _("Show if printing Mach-O symbols processing."),
-                           NULL, NULL, NULL,
-                           &setdebuglist, &showdebuglist);
+  add_setshow_zuinteger_cmd ("mach-o", class_obscure,
+                            &mach_o_debug_level,
+                            _("Set if printing Mach-O symbols processing."),
+                            _("Show if printing Mach-O symbols processing."),
+                            NULL, NULL, NULL,
+                            &setdebuglist, &showdebuglist);
 }
This page took 0.026596 seconds and 4 git commands to generate.