public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  tromey/pr-15028-dwz-m-fix: change gdb to use BFD's "dwz" functions
@ 2013-06-17 19:05 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2013-06-17 19:05 UTC (permalink / raw)
  To: archer-commits

The branch, tromey/pr-15028-dwz-m-fix has been updated
       via  b197273a722bc640c16cccee5522b5685efda6dd (commit)
      from  aa1d0a15ceb48404b437e9ed68e27157f51fd369 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit b197273a722bc640c16cccee5522b5685efda6dd
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu May 30 12:09:24 2013 -0600

    change gdb to use BFD's "dwz" functions
    
    BFD recently got a few functions related to "dwz" files.  This patch
    changes gdb to use them, just to share a bit more code.
    
    This changes dwarf2_get_dwz_file to possibly return NULL.  This
    simplified a bit of code elsewhere.
    
    Built and regtested on x86-64 Fedora 18.  I specifically regtested it
    using my pending dwz test case.
    
    	* dwarf2read.c (dwarf2_get_dwz_file): Return NULL if
    	.gnu_debugaltlink not found.  Use bfd_get_alt_debug_link_info.
    	(dwarf2_read_index, create_all_comp_units): Update.

-----------------------------------------------------------------------

Summary of changes:
 gdb/dwarf2read.c |   47 +++++++++++++++++++++++++----------------------
 1 files changed, 25 insertions(+), 22 deletions(-)

First 500 lines of diff:
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 09d5b11..a0ae91d 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2099,29 +2099,33 @@ locate_dwz_sections (bfd *abfd, asection *sectp, void *arg)
     }
 }
 
-/* Open the separate '.dwz' debug file, if needed.  Error if the file
-   cannot be found.  */
+/* Open the separate '.dwz' debug file, if needed.  Return NULL if
+   there is no .gnu_debugaltlink section in the file.  Error if there
+   is such a section but the file cannot be found.  */
 
 static struct dwz_file *
 dwarf2_get_dwz_file (void)
 {
-  bfd *abfd, *dwz_bfd;
-  asection *section;
-  gdb_byte *data;
+  bfd *dwz_bfd;
+  char *data;
   struct cleanup *cleanup;
   const char *filename;
   struct dwz_file *result;
+  unsigned long buildid;
 
   if (dwarf2_per_objfile->dwz_file != NULL)
     return dwarf2_per_objfile->dwz_file;
 
-  abfd = dwarf2_per_objfile->objfile->obfd;
-  section = bfd_get_section_by_name (abfd, ".gnu_debugaltlink");
-  if (section == NULL)
-    error (_("could not find '.gnu_debugaltlink' section"));
-  if (!bfd_malloc_and_get_section (abfd, section, &data))
-    error (_("could not read '.gnu_debugaltlink' section: %s"),
-	   bfd_errmsg (bfd_get_error ()));
+  bfd_set_error (bfd_error_no_error);
+  data = bfd_get_alt_debug_link_info (dwarf2_per_objfile->objfile->obfd,
+				      &buildid);
+  if (data == NULL)
+    {
+      if (bfd_get_error () == bfd_error_no_error)
+	return NULL;
+      error (_("could not read '.gnu_debugaltlink' section: %s"),
+	     bfd_errmsg (bfd_get_error ()));
+    }
   cleanup = make_cleanup (xfree, data);
 
   filename = (const char *) data;
@@ -2799,6 +2803,7 @@ dwarf2_read_index (struct objfile *objfile)
   struct mapped_index local_map, *map;
   const gdb_byte *cu_list, *types_list, *dwz_list = NULL;
   offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0;
+  struct dwz_file *dwz;
 
   if (!read_index_from_section (objfile, objfile->name,
 				use_deprecated_index_sections,
@@ -2813,9 +2818,9 @@ dwarf2_read_index (struct objfile *objfile)
 
   /* If there is a .dwz file, read it so we can get its CU list as
      well.  */
-  if (bfd_get_section_by_name (objfile->obfd, ".gnu_debugaltlink") != NULL)
+  dwz = dwarf2_get_dwz_file ();
+  if (dwz != NULL)
     {
-      struct dwz_file *dwz = dwarf2_get_dwz_file ();
       struct mapped_index dwz_map;
       const gdb_byte *dwz_types_ignore;
       offset_type dwz_types_elements_ignore;
@@ -6038,6 +6043,7 @@ create_all_comp_units (struct objfile *objfile)
   int n_allocated;
   int n_comp_units;
   struct dwarf2_per_cu_data **all_comp_units;
+  struct dwz_file *dwz;
 
   n_comp_units = 0;
   n_allocated = 10;
@@ -6047,14 +6053,11 @@ create_all_comp_units (struct objfile *objfile)
   read_comp_units_from_section (objfile, &dwarf2_per_objfile->info, 0,
 				&n_allocated, &n_comp_units, &all_comp_units);
 
-  if (bfd_get_section_by_name (objfile->obfd, ".gnu_debugaltlink") != NULL)
-    {
-      struct dwz_file *dwz = dwarf2_get_dwz_file ();
-
-      read_comp_units_from_section (objfile, &dwz->info, 1,
-				    &n_allocated, &n_comp_units,
-				    &all_comp_units);
-    }
+  dwz = dwarf2_get_dwz_file ();
+  if (dwz != NULL)
+    read_comp_units_from_section (objfile, &dwz->info, 1,
+				  &n_allocated, &n_comp_units,
+				  &all_comp_units);
 
   dwarf2_per_objfile->all_comp_units
     = obstack_alloc (&objfile->objfile_obstack,


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-06-17 19:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-17 19:05 [SCM] tromey/pr-15028-dwz-m-fix: change gdb to use BFD's "dwz" functions tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).