Introduce assign_operation
[deliverable/binutils-gdb.git] / gdb / minidebug.c
index a56a822628e3e297262794d4be9c030e3e9c653c..68a54d9fc6c2af469b2de178136930aea69fac0c 100644 (file)
@@ -1,6 +1,6 @@
 /* Read MiniDebugInfo data from an objfile.
 
-   Copyright (C) 2012-2020 Free Software Foundation, Inc.
+   Copyright (C) 2012-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 
 #ifdef HAVE_LIBLZMA
 
+/* We stash a reference to the .gnu_debugdata BFD on the enclosing
+   BFD.  */
+static const bfd_key<gdb_bfd_ref_ptr> gnu_debug_key;
+
 #include <lzma.h>
 
 /* Allocator function for LZMA.  */
@@ -92,7 +96,7 @@ lzma_open (struct bfd *nbfd, void *open_closure)
   if (size < LZMA_STREAM_HEADER_SIZE
       || bfd_seek (section->owner, offset, SEEK_SET) != 0
       || bfd_bread (footer, LZMA_STREAM_HEADER_SIZE, section->owner)
-         != LZMA_STREAM_HEADER_SIZE
+        != LZMA_STREAM_HEADER_SIZE
       || lzma_stream_footer_decode (&options, footer) != LZMA_OK
       || offset < options.backward_size)
     {
@@ -106,10 +110,10 @@ lzma_open (struct bfd *nbfd, void *open_closure)
   pos = 0;
   if (bfd_seek (section->owner, offset, SEEK_SET) != 0
       || bfd_bread (indexdata, options.backward_size, section->owner)
-         != options.backward_size
+        != options.backward_size
       || lzma_index_buffer_decode (&index, &memlimit, &gdb_lzma_allocator,
                                   indexdata, &pos, options.backward_size)
-         != LZMA_OK
+        != LZMA_OK
       || lzma_index_size (index) != options.backward_size)
     {
       xfree (indexdata);
@@ -269,6 +273,10 @@ find_separate_debug_file_in_section (struct objfile *objfile)
     return NULL;
 
 #ifdef HAVE_LIBLZMA
+  gdb_bfd_ref_ptr *shared = gnu_debug_key.get (objfile->obfd);
+  if (shared != nullptr)
+    return *shared;
+
   std::string filename = string_printf (_(".gnu_debugdata for %s"),
                                        objfile_name (objfile));
 
@@ -282,6 +290,9 @@ find_separate_debug_file_in_section (struct objfile *objfile)
       warning (_("Cannot parse .gnu_debugdata section; not a BFD object"));
       return NULL;
     }
+
+  gnu_debug_key.emplace (objfile->obfd, abfd);
+
 #else
   warning (_("Cannot parse .gnu_debugdata section; LZMA support was "
             "disabled at compile time"));
This page took 0.024205 seconds and 4 git commands to generate.