]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* dwarf2read.c (signatured_type): Make "per_cu" member first.
authorDoug Evans <dje@google.com>
Sun, 1 Jul 2012 02:05:13 +0000 (02:05 +0000)
committerDoug Evans <dje@google.com>
Sun, 1 Jul 2012 02:05:13 +0000 (02:05 +0000)
(init_cutu_and_read_dies): Handle rereading a DWO CU while it's
currently being read.  Propagate DW_AT_comp_dir to DWO DIE.

testsuite/
* gdb.dwarf2/fission-reread.S: New file.
* gdb.dwarf2/fission-reread.exp: New file.

gdb/ChangeLog
gdb/dwarf2read.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/fission-reread.S [new file with mode: 0644]
gdb/testsuite/gdb.dwarf2/fission-reread.exp [new file with mode: 0644]

index 4ab87071ca23403afab141fc9d2af9de11543779..fbe1ae417189f04b68d52a9825604ef4b97461e7 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-30  Doug Evans  <dje@google.com>
+
+       * dwarf2read.c (signatured_type): Make "per_cu" member first.
+       (init_cutu_and_read_dies): Handle rereading a DWO CU while it's
+       currently being read.  Propagate DW_AT_comp_dir to DWO DIE.
+
 2012-06-29  Doug Evans  <dje@google.com>
 
        * linespec.c: #include "stack.h".
index 69798f6be48ac2e0610bf7b40b0c59d4aec77d12..dc3f625e28e2c656fd7da393270e2ee17aa69cb4 100644 (file)
@@ -544,6 +544,11 @@ struct dwarf2_per_cu_data
 
 struct signatured_type
 {
+  /* The "per_cu" object of this type.
+     N.B.: This is the first member so that it's easy to convert pointers
+     between them.  */
+  struct dwarf2_per_cu_data per_cu;
+
   /* The type's signature.  */
   ULONGEST signature;
 
@@ -557,9 +562,6 @@ struct signatured_type
      The value is zero until the actual value is known.
      Zero is otherwise not a valid section offset.  */
   sect_offset type_offset_in_section;
-
-  /* The CU(/TU) of this type.  */
-  struct dwarf2_per_cu_data per_cu;
 };
 
 /* These sections are what may appear in a "dwo" file.  */
@@ -3851,6 +3853,8 @@ lookup_signatured_type (ULONGEST sig)
   entry = htab_find (dwarf2_per_objfile->signatured_types, &find_entry);
   return entry;
 }
+\f
+/* Low level DIE reading support.  */
 
 /* Initialize a die_reader_specs struct from a dwarf2_cu struct.  */
 
@@ -3899,6 +3903,10 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
   struct cleanup *cleanups, *free_cu_cleanup = NULL;
   struct signatured_type *sig_type = NULL;
   struct dwarf2_section_info *abbrev_section;
+  /* Non-zero if CU currently points to a DWO file and we need to
+     reread it.  When this happens we need to reread the skeleton die
+     before we can reread the DWO file.  */
+  int rereading_dwo_cu = 0;
 
   if (use_existing_cu)
     gdb_assert (keep);
@@ -3914,7 +3922,15 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
   if (use_existing_cu && this_cu->cu != NULL)
     {
       cu = this_cu->cu;
-      info_ptr += cu->header.first_die_offset.cu_off;
+
+      /* If this CU is from a DWO file we need to start over, we need to
+        refetch the attributes from the skeleton CU.
+        This could be optimized by retrieving those attributes from when we
+        were here the first time: the previous comp_unit_die was stored in
+        comp_unit_obstack.  But there's no data yet that we need this
+        optimization.  */
+      if (cu->dwo_unit != NULL)
+       rereading_dwo_cu = 1;
     }
   else
     {
@@ -3926,26 +3942,35 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
 
       /* If an error occurs while loading, release our storage.  */
       free_cu_cleanup = make_cleanup (free_heap_comp_unit, cu);
+    }
 
+  if (cu->header.first_die_offset.cu_off != 0 && ! rereading_dwo_cu)
+    {
+      /* We already have the header, there's no need to read it in again.  */
+      info_ptr += cu->header.first_die_offset.cu_off;
+    }
+  else
+    {
       if (this_cu->is_debug_types)
        {
          ULONGEST signature;
+         cu_offset type_offset_in_tu;
 
          info_ptr = read_and_check_type_unit_head (&cu->header, section,
                                                    abbrev_section, info_ptr,
-                                                   &signature, NULL);
+                                                   &signature,
+                                                   &type_offset_in_tu);
 
-         /* There's no way to get from PER_CU to its containing
-            struct signatured_type.
-            But we have the signature so we can use that.  */
-         sig_type = lookup_signatured_type (signature);
-         /* We've already scanned all the signatured types,
-            this must succeed.  */
-         gdb_assert (sig_type != NULL);
-         gdb_assert (&sig_type->per_cu == this_cu);
+         /* Since per_cu is the first member of struct signatured_type,
+            we can go from a pointer to one to a pointer to the other.  */
+         sig_type = (struct signatured_type *) this_cu;
+         gdb_assert (sig_type->signature == signature);
+         gdb_assert (sig_type->type_offset_in_tu.cu_off
+                     == type_offset_in_tu.cu_off);
          gdb_assert (this_cu->offset.sect_off == cu->header.offset.sect_off);
 
-         /* LENGTH has not been set yet for type units.  */
+         /* LENGTH has not been set yet for type units if we're
+            using .gdb_index.  */
          this_cu->length = get_cu_length (&cu->header);
 
          /* Establish the type offset that can be used to lookup the type.  */
@@ -3973,12 +3998,19 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
 
   /* If we don't have them yet, read the abbrevs for this compilation unit.
      And if we need to read them now, make sure they're freed when we're
-     done.  */
+     done.  Note that it's important that if the CU had an abbrev table
+     on entry we don't free it when we're done: Somewhere up the call stack
+     it may be in use.  */
   if (cu->abbrev_table == NULL)
     {
       dwarf2_read_abbrevs (cu, abbrev_section);
       make_cleanup (dwarf2_free_abbrev_table, cu);
     }
+  else if (rereading_dwo_cu)
+    {
+      dwarf2_free_abbrev_table (cu);
+      dwarf2_read_abbrevs (cu, abbrev_section);
+    }
 
   /* Read the top level CU/TU die.  */
   init_cu_die_reader (&reader, cu, section, NULL);
@@ -3991,10 +4023,10 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
   if (attr)
     {
       char *dwo_name = DW_STRING (attr);
-      const char *comp_dir;
+      const char *comp_dir_string;
       struct dwo_unit *dwo_unit;
       ULONGEST signature; /* Or dwo_id.  */
-      struct attribute *stmt_list, *low_pc, *high_pc, *ranges;
+      struct attribute *comp_dir, *stmt_list, *low_pc, *high_pc, *ranges;
       int i,num_extra_attrs;
       struct dwarf2_section_info *dwo_abbrev_section;
 
@@ -4008,15 +4040,16 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
         However, the attribute is found in the stub which we won't have later.
         In order to not impose this complication on the rest of the code,
         we read them here and copy them to the DWO CU/TU die.  */
-      stmt_list = low_pc = high_pc = ranges = NULL;
 
       /* For TUs in DWO files, the DW_AT_stmt_list attribute lives in the
         DWO file.  */
+      stmt_list = NULL;
       if (! this_cu->is_debug_types)
        stmt_list = dwarf2_attr (comp_unit_die, DW_AT_stmt_list, cu);
       low_pc = dwarf2_attr (comp_unit_die, DW_AT_low_pc, cu);
       high_pc = dwarf2_attr (comp_unit_die, DW_AT_high_pc, cu);
       ranges = dwarf2_attr (comp_unit_die, DW_AT_ranges, cu);
+      comp_dir = dwarf2_attr (comp_unit_die, DW_AT_comp_dir, cu);
 
       /* There should be a DW_AT_addr_base attribute here (if needed).
         We need the value before we can process DW_FORM_GNU_addr_index.  */
@@ -4047,15 +4080,14 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
        }
 
       /* We may need the comp_dir in order to find the DWO file.  */
-      comp_dir = NULL;
-      attr = dwarf2_attr (comp_unit_die, DW_AT_comp_dir, cu);
-      if (attr)
-       comp_dir = DW_STRING (attr);
+      comp_dir_string = NULL;
+      if (comp_dir)
+       comp_dir_string = DW_STRING (comp_dir);
 
       if (this_cu->is_debug_types)
-       dwo_unit = lookup_dwo_type_unit (sig_type, dwo_name, comp_dir);
+       dwo_unit = lookup_dwo_type_unit (sig_type, dwo_name, comp_dir_string);
       else
-       dwo_unit = lookup_dwo_comp_unit (this_cu, dwo_name, comp_dir,
+       dwo_unit = lookup_dwo_comp_unit (this_cu, dwo_name, comp_dir_string,
                                         signature);
 
       if (dwo_unit == NULL)
@@ -4110,7 +4142,8 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
       num_extra_attrs = ((stmt_list != NULL)
                         + (low_pc != NULL)
                         + (high_pc != NULL)
-                        + (ranges != NULL));
+                        + (ranges != NULL)
+                        + (comp_dir != NULL));
       info_ptr = read_full_die_1 (&reader, &comp_unit_die, info_ptr,
                                  &has_children, num_extra_attrs);
 
@@ -4124,6 +4157,8 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
        comp_unit_die->attrs[i++] = *high_pc;
       if (ranges != NULL)
        comp_unit_die->attrs[i++] = *ranges;
+      if (comp_dir != NULL)
+       comp_unit_die->attrs[i++] = *comp_dir;
       comp_unit_die->num_attrs += num_extra_attrs;
 
       /* Skip dummy compilation units.  */
index 44c72d8c77e58e7e26703576290a790f3bd24d38..2f4d131005a528284aa2632cdca4ef3b7583fee0 100644 (file)
@@ -1,3 +1,8 @@
+2012-06-30  Doug Evans  <dje@google.com>
+
+       * gdb.dwarf2/fission-reread.S: New file.
+       * gdb.dwarf2/fission-reread.exp: New file.
+
 2012-06-28  Stan Shebs  <stan@codesourcery.com>
 
        * gdb.mi/mi-logging.exp: New file.
diff --git a/gdb/testsuite/gdb.dwarf2/fission-reread.S b/gdb/testsuite/gdb.dwarf2/fission-reread.S
new file mode 100644 (file)
index 0000000..1db363f
--- /dev/null
@@ -0,0 +1,459 @@
+/* Copyright 2012 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Testcase to exercise the code path in bug 13961 for Fission.
+   http://gcc.gnu.org/wiki/DebugFission
+
+   Compiled from:
+
+   class foo
+   {
+    public:
+     int bar;
+   };
+
+   foo baz;
+
+   int
+   main ()
+   {
+     return 0;
+   }
+
+   And then manually edited to insert the necessary DW_AT_specification
+   entries to trigger the desired code path.
+   There's no real need to make this architecture-specific, so it has been
+   further hand-edited to support that.
+*/
+
+       .file   "fission-reread.cc"
+
+       .globl  baz
+       .bss
+       .align 4
+       .type   baz, @object
+       .size   baz, 4
+baz:
+       .zero   4
+
+       .text
+.Ltext0:
+       .globl  main
+       .type   main, @function
+main:
+.LFB0:
+       .file 1 "fission-reread.cc"
+       .loc 1 11 0
+       .4byte 0
+.LFE0:
+       .size   main, .-main
+.Letext0:
+
+       .section        .debug_types.dwo,"G",@progbits,wt.198b7eaccef12290,comdat
+.Ltu_start_dwo:
+       .4byte  .Ltu_end_dwo - .Ltu_start_dwo - 4       # Length of Compilation Unit Info
+       .2byte  0x4     # DWARF version number
+       .4byte  .Ldebug_abbrev0 # Offset Into Abbrev. Section
+       .byte   0x8     # Pointer Size (in bytes)
+       .byte   0x19    # Type Signature
+       .byte   0x8b
+       .byte   0x7e
+       .byte   0xac
+       .byte   0xce
+       .byte   0xf1
+       .byte   0x22
+       .byte   0x90
+       .4byte  .Ltu_class_type - .Ltu_start_dwo        # Offset to Type DIE
+       .uleb128 0x1    # (DIE (0x17) DW_TAG_type_unit)
+       .byte   0x4     # DW_AT_language
+       .byte   0x73    # DW_AT_GNU_odr_signature
+       .byte   0xea
+       .byte   0x85
+       .byte   0x23
+       .byte   0x75
+       .byte   0x8a
+       .byte   0x7e
+       .byte   0x87
+       .4byte  .Lskeleton_debug_line0  # DW_AT_stmt_list
+
+       /* Manually inserted to have a DW_AT_specification refering to
+          something and appearing ahead of it.  */
+       .uleb128 0x8    /* DW_TAG_class_type */
+       .4byte .Ltu_class_type - .Ltu_start_dwo
+       /* End of manual insertion */
+
+.Ltu_class_type:
+       .uleb128 0x2    # (DIE (0x25) DW_TAG_class_type)
+       .ascii "foo\0"  # DW_AT_name
+       .byte   0x4     # DW_AT_byte_size
+       .byte   0x1     # DW_AT_decl_file (fission-reread.cc)
+       .byte   0x1     # DW_AT_decl_line
+       .4byte  .Ltu_int        # DW_AT_sibling
+       .uleb128 0x3    # (DIE (0x31) DW_TAG_member)
+       .ascii "bar\0"  # DW_AT_name
+       .byte   0x1     # DW_AT_decl_file (fission-reread.cc)
+       .byte   0x4     # DW_AT_decl_line
+       .4byte  .Ltu_int        # DW_AT_type
+       .byte   0       # DW_AT_data_member_location
+       .byte   0x1     # DW_AT_accessibility
+       .byte   0       # end of children of DIE 0x25
+.Ltu_int:
+       .uleb128 0x4    # (DIE (0x3f) DW_TAG_base_type)
+       .byte   0x4     # DW_AT_byte_size
+       .byte   0x5     # DW_AT_encoding
+       .ascii "int\0"  # DW_AT_name
+       .byte   0       # end of children of DIE 0x17
+.Ltu_end_dwo:
+
+       .section        .debug_types,"G",@progbits,wt.198b7eaccef12290,comdat
+.Ltu_start:
+       .4byte  .Ltu_end - .Ltu_start - 4       # Length of Type Unit Info
+       .2byte  0x4     # DWARF version number
+       .4byte  .Lskeleton_debug_abbrev0        # Offset Into Abbrev. Section
+       .byte   0x8     # Pointer Size (in bytes)
+       .byte   0x19    # Type Signature
+       .byte   0x8b
+       .byte   0x7e
+       .byte   0xac
+       .byte   0xce
+       .byte   0xf1
+       .byte   0x22
+       .byte   0x90
+       .4byte  0       # Offset to Type DIE
+       .uleb128 0x2    # (DIE (0) DW_TAG_type_unit)
+       .ascii "/tmp/src/gdb/testsuite/gdb.dwarf2\0"    # DW_AT_comp_dir
+       # Normally dwo_name would be "fission-reread.dwo".
+       # Simplification: Leave the DWO contents in the executable.
+       .ascii "fission-reread\0"       # DW_AT_GNU_dwo_name
+       .4byte  .Ldebug_pubnames0       # DW_AT_GNU_pubnames
+       .4byte  .Ldebug_pubtypes0       # DW_AT_GNU_pubtypes
+       .4byte  .Ldebug_addr0   # DW_AT_GNU_addr_base
+.Ltu_end:
+
+       .section        .debug_info.dwo,"",@progbits
+.Lcu_start_dwo:
+       .4byte  .Lcu_end_dwo - .Lcu_start_dwo - 4       # Length of Compilation Unit Info
+       .2byte  0x4     # DWARF version number
+       .4byte  .Ldebug_abbrev0 # Offset Into Abbrev. Section
+       .byte   0x8     # Pointer Size (in bytes)
+       .uleb128 0x5    # (DIE (0xb) DW_TAG_compile_unit)
+       .ascii "GNU C++ 4.6.x-fission\0"        # DW_AT_producer
+       .byte   0x4     # DW_AT_language
+       .ascii "fission-reread.cc\0"    # DW_AT_name
+       .ascii "/tmp/src/gdb/testsuite/gdb.dwarf2\0"    # DW_AT_comp_dir
+       .byte   0       # DW_AT_GNU_dwo_id
+       .byte   0
+       .byte   0
+       .byte   0
+       .byte   0
+       .byte   0
+       .byte   0
+       .byte   0
+.Lcu_int:
+       .uleb128 0x4    # (DIE (0x7f) DW_TAG_base_type)
+       .byte   0x4     # DW_AT_byte_size
+       .byte   0x5     # DW_AT_encoding
+       .ascii "int\0"  # DW_AT_name
+       .uleb128 0x6    # (DIE (0x86) DW_TAG_subprogram)
+                       # DW_AT_external
+       .ascii "main\0" # DW_AT_name
+       .byte   0x1     # DW_AT_decl_file (fission-reread.cc)
+       .byte   0xa     # DW_AT_decl_line
+       .4byte  .Lcu_int        # DW_AT_type
+       .uleb128 0      # DW_AT_low_pc
+       .8byte  .LFE0-.LFB0     # DW_AT_high_pc
+       .uleb128 0x1    # DW_AT_frame_base
+       .byte   0x9c    # DW_OP_call_frame_cfa
+       .uleb128 0x7    # (DIE (0x9d) DW_TAG_variable)
+       .ascii "baz\0"  # DW_AT_name
+       .byte   0x1     # DW_AT_decl_file (fission-reread.cc)
+       .byte   0x7     # DW_AT_decl_line
+       .byte   0x19    # DW_AT_type
+       .byte   0x8b
+       .byte   0x7e
+       .byte   0xac
+       .byte   0xce
+       .byte   0xf1
+       .byte   0x22
+       .byte   0x90
+                       # DW_AT_external
+       .uleb128 0x2    # DW_AT_location
+       .byte   0xfb    # DW_OP_GNU_addr_index
+       .uleb128 0x1    # (index into .debug_addr)
+       .byte   0       # end of children of DIE 0xb
+.Lcu_end_dwo:
+
+       .section        .debug_info,"",@progbits
+.Lskeleton_debug_info0:
+.Lcu_start:
+       .4byte  .Lcu_end - .Lcu_start - 4       # Length of Compilation Unit Info
+       .2byte  0x4     # DWARF version number
+       .4byte  .Lskeleton_debug_abbrev0        # Offset Into Abbrev. Section
+       .byte   0x8     # Pointer Size (in bytes)
+       .uleb128 0x1    # (DIE (0) DW_TAG_compile_unit)
+       .8byte  .Ltext0 # DW_AT_low_pc
+       .8byte  .Letext0-.Ltext0        # DW_AT_high_pc
+       .4byte  .Ldebug_line0   # DW_AT_stmt_list
+       .ascii "/tmp/src/gdb/testsuite/gdb.dwarf2\0"    # DW_AT_comp_dir
+       # Normally dwo_name would be "fission-reread.dwo".
+       # Simplification: Leave the DWO contents in the executable.
+       .ascii "fission-reread\0"       # DW_AT_GNU_dwo_name
+       .4byte  .Ldebug_pubnames0       # DW_AT_GNU_pubnames
+       .4byte  .Ldebug_pubtypes0       # DW_AT_GNU_pubtypes
+       .4byte  .Ldebug_addr0   # DW_AT_GNU_addr_base
+       .byte   0       # DW_AT_GNU_dwo_id
+       .byte   0
+       .byte   0
+       .byte   0
+       .byte   0
+       .byte   0
+       .byte   0
+       .byte   0
+.Lcu_end:
+
+       .section        .debug_abbrev,"",@progbits
+.Lskeleton_debug_abbrev0:
+       .uleb128 0x1    # (abbrev code)
+       .uleb128 0x11   # (TAG: DW_TAG_compile_unit)
+       .byte   0       # DW_children_no
+       .uleb128 0x11   # (DW_AT_low_pc)
+       .uleb128 0x1    # (DW_FORM_addr)
+       .uleb128 0x12   # (DW_AT_high_pc)
+       .uleb128 0x7    # (DW_FORM_data8)
+       .uleb128 0x10   # (DW_AT_stmt_list)
+       .uleb128 0x17   # (DW_FORM_sec_offset)
+       .uleb128 0x1b   # (DW_AT_comp_dir)
+       .uleb128 0x8    # (DW_FORM_string)
+       .uleb128 0x2130 # (DW_AT_GNU_dwo_name)
+       .uleb128 0x8    # (DW_FORM_string)
+       .uleb128 0x2134 # (DW_AT_GNU_pubnames)
+       .uleb128 0x17   # (DW_FORM_sec_offset)
+       .uleb128 0x2135 # (DW_AT_GNU_pubtypes)
+       .uleb128 0x17   # (DW_FORM_sec_offset)
+       .uleb128 0x2133 # (DW_AT_GNU_addr_base)
+       .uleb128 0x17   # (DW_FORM_sec_offset)
+       .uleb128 0x2131 # (DW_AT_GNU_dwo_id)
+       .uleb128 0x7    # (DW_FORM_data8)
+       .byte   0
+       .byte   0
+       .uleb128 0x2    # (abbrev code)
+       .uleb128 0x41   # (TAG: DW_TAG_type_unit)
+       .byte   0       # DW_children_no
+       .uleb128 0x1b   # (DW_AT_comp_dir)
+       .uleb128 0x8    # (DW_FORM_string)
+       .uleb128 0x2130 # (DW_AT_GNU_dwo_name)
+       .uleb128 0x8    # (DW_FORM_string)
+       .uleb128 0x2134 # (DW_AT_GNU_pubnames)
+       .uleb128 0x17   # (DW_FORM_sec_offset)
+       .uleb128 0x2135 # (DW_AT_GNU_pubtypes)
+       .uleb128 0x17   # (DW_FORM_sec_offset)
+       .uleb128 0x2133 # (DW_AT_GNU_addr_base)
+       .uleb128 0x17   # (DW_FORM_sec_offset)
+       .byte   0
+       .byte   0
+       .byte   0       # end of skeleton .debug_abbrev
+       .section        .debug_abbrev.dwo,"",@progbits
+.Ldebug_abbrev0:
+       .uleb128 0x1    # (abbrev code)
+       .uleb128 0x41   # (TAG: DW_TAG_type_unit)
+       .byte   0x1     # DW_children_yes
+       .uleb128 0x13   # (DW_AT_language)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x210f # (DW_AT_GNU_odr_signature)
+       .uleb128 0x7    # (DW_FORM_data8)
+       .uleb128 0x10   # (DW_AT_stmt_list)
+       .uleb128 0x17   # (DW_FORM_sec_offset)
+       .byte   0
+       .byte   0
+       .uleb128 0x2    # (abbrev code)
+       .uleb128 0x2    # (TAG: DW_TAG_class_type)
+       .byte   0x1     # DW_children_yes
+       .uleb128 0x3    # (DW_AT_name)
+       .uleb128 0x8    # (DW_FORM_string)
+       .uleb128 0xb    # (DW_AT_byte_size)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x3a   # (DW_AT_decl_file)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x3b   # (DW_AT_decl_line)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x1    # (DW_AT_sibling)
+       .uleb128 0x13   # (DW_FORM_ref4)
+       .byte   0
+       .byte   0
+       .uleb128 0x3    # (abbrev code)
+       .uleb128 0xd    # (TAG: DW_TAG_member)
+       .byte   0       # DW_children_no
+       .uleb128 0x3    # (DW_AT_name)
+       .uleb128 0x8    # (DW_FORM_string)
+       .uleb128 0x3a   # (DW_AT_decl_file)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x3b   # (DW_AT_decl_line)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x49   # (DW_AT_type)
+       .uleb128 0x13   # (DW_FORM_ref4)
+       .uleb128 0x38   # (DW_AT_data_member_location)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x32   # (DW_AT_accessibility)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .byte   0
+       .byte   0
+       .uleb128 0x4    # (abbrev code)
+       .uleb128 0x24   # (TAG: DW_TAG_base_type)
+       .byte   0       # DW_children_no
+       .uleb128 0xb    # (DW_AT_byte_size)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x3e   # (DW_AT_encoding)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x3    # (DW_AT_name)
+       .uleb128 0x8    # (DW_FORM_string)
+       .byte   0
+       .byte   0
+       .uleb128 0x5    # (abbrev code)
+       .uleb128 0x11   # (TAG: DW_TAG_compile_unit)
+       .byte   0x1     # DW_children_yes
+       .uleb128 0x25   # (DW_AT_producer)
+       .uleb128 0x8    # (DW_FORM_string)
+       .uleb128 0x13   # (DW_AT_language)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x3    # (DW_AT_name)
+       .uleb128 0x8    # (DW_FORM_string)
+       .uleb128 0x1b   # (DW_AT_comp_dir)
+       .uleb128 0x8    # (DW_FORM_string)
+       .uleb128 0x2131 # (DW_AT_GNU_dwo_id)
+       .uleb128 0x7    # (DW_FORM_data8)
+       .byte   0
+       .byte   0
+       .uleb128 0x6    # (abbrev code)
+       .uleb128 0x2e   # (TAG: DW_TAG_subprogram)
+       .byte   0       # DW_children_no
+       .uleb128 0x3f   # (DW_AT_external)
+       .uleb128 0x19   # (DW_FORM_flag_present)
+       .uleb128 0x3    # (DW_AT_name)
+       .uleb128 0x8    # (DW_FORM_string)
+       .uleb128 0x3a   # (DW_AT_decl_file)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x3b   # (DW_AT_decl_line)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x49   # (DW_AT_type)
+       .uleb128 0x13   # (DW_FORM_ref4)
+       .uleb128 0x11   # (DW_AT_low_pc)
+       .uleb128 0x1f01 # (DW_FORM_GNU_addr_index)
+       .uleb128 0x12   # (DW_AT_high_pc)
+       .uleb128 0x7    # (DW_FORM_data8)
+       .uleb128 0x40   # (DW_AT_frame_base)
+       .uleb128 0x18   # (DW_FORM_exprloc)
+       .byte   0
+       .byte   0
+       .uleb128 0x7    # (abbrev code)
+       .uleb128 0x34   # (TAG: DW_TAG_variable)
+       .byte   0       # DW_children_no
+       .uleb128 0x3    # (DW_AT_name)
+       .uleb128 0x8    # (DW_FORM_string)
+       .uleb128 0x3a   # (DW_AT_decl_file)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x3b   # (DW_AT_decl_line)
+       .uleb128 0xb    # (DW_FORM_data1)
+       .uleb128 0x49   # (DW_AT_type)
+       .uleb128 0x20   # (DW_FORM_ref_sig8)
+       .uleb128 0x3f   # (DW_AT_external)
+       .uleb128 0x19   # (DW_FORM_flag_present)
+       .uleb128 0x2    # (DW_AT_location)
+       .uleb128 0x18   # (DW_FORM_exprloc)
+       .byte   0
+       .byte   0
+
+       /* Manually inserted.  */
+       .uleb128 0x8            /* abbrev code */
+       .uleb128 0x2            /* DW_TAG_class_type */
+       .byte   0x0             /* DW_has_children_no */
+       .uleb128 0x47           /* DW_AT_specification */
+       .uleb128 0x13           /* DW_FORM_ref4 */
+       .byte   0x0             /* Terminator */
+       .byte   0x0             /* Terminator */
+       /* End of manual insertion.  */
+
+       .byte   0
+       .section        .debug_pubnames,"",@progbits
+.Ldebug_pubnames0:
+       .4byte  0x1f    # Length of Public Names Info
+       .2byte  0x2     # DWARF Version
+       .4byte  .Lskeleton_debug_info0  # Offset of Compilation Unit Info
+       .4byte  0xb0    # Compilation Unit Length
+       .4byte  0x86    # DIE offset
+       .ascii "main\0" # external name
+       .4byte  0x9d    # DIE offset
+       .ascii "baz\0"  # external name
+       .4byte  0
+       .section        .debug_pubtypes,"",@progbits
+.Ldebug_pubtypes0:
+       .4byte  0x1e    # Length of Public Type Names Info
+       .2byte  0x2     # DWARF Version
+       .4byte  .Lskeleton_debug_info0  # Offset of Compilation Unit Info
+       .4byte  0xb0    # Compilation Unit Length
+       .4byte  0x7f    # DIE offset
+       .ascii "int\0"  # external name
+       .4byte  0x25    # DIE offset
+       .ascii "foo\0"  # external name
+       .4byte  0
+       .section        .debug_aranges,"",@progbits
+       .4byte  0x2c    # Length of Address Ranges Info
+       .2byte  0x2     # DWARF Version
+       .4byte  .Lskeleton_debug_info0  # Offset of Compilation Unit Info
+       .byte   0x8     # Size of Address
+       .byte   0       # Size of Segment Descriptor
+       .2byte  0       # Pad to 16 byte boundary
+       .2byte  0
+       .8byte  .Ltext0 # Address
+       .8byte  .Letext0-.Ltext0        # Length
+       .8byte  0
+       .8byte  0
+       .section        .debug_line,"",@progbits
+.Ldebug_line0:
+       .section        .debug_line.dwo,"",@progbits
+.Lskeleton_debug_line0:
+       .4byte  .LELT0-.LSLT0   # Length of Source Line Info
+.LSLT0:
+       .2byte  0x4     # DWARF Version
+       .4byte  .LELTP0-.LASLTP0        # Prolog Length
+.LASLTP0:
+       .byte   0x1     # Minimum Instruction Length
+       .byte   0x1     # Maximum Operations Per Instruction
+       .byte   0x1     # Default is_stmt_start flag
+       .byte   0xf6    # Line Base Value (Special Opcodes)
+       .byte   0xf5    # Line Range Value (Special Opcodes)
+       .byte   0xa     # Special Opcode Base
+       .byte   0       # opcode: 0x1 has 0 args
+       .byte   0x1     # opcode: 0x2 has 1 args
+       .byte   0x1     # opcode: 0x3 has 1 args
+       .byte   0x1     # opcode: 0x4 has 1 args
+       .byte   0x1     # opcode: 0x5 has 1 args
+       .byte   0       # opcode: 0x6 has 0 args
+       .byte   0       # opcode: 0x7 has 0 args
+       .byte   0       # opcode: 0x8 has 0 args
+       .byte   0x1     # opcode: 0x9 has 1 args
+       .byte   0       # End directory table
+       .ascii "fission-reread.cc\0"    # File Entry: 0x1
+       .uleb128 0
+       .uleb128 0
+       .uleb128 0
+       .byte   0       # End file name table
+.LELTP0:
+.LELT0:
+       .section        .debug_addr,"",@progbits
+.Ldebug_addr0:
+       .8byte  .LFB0   # DW_AT_low_pc
+       .8byte  baz     # DW_AT_location
+
+       .section        .note.GNU-stack,"",@progbits
diff --git a/gdb/testsuite/gdb.dwarf2/fission-reread.exp b/gdb/testsuite/gdb.dwarf2/fission-reread.exp
new file mode 100644 (file)
index 0000000..9efc530
--- /dev/null
@@ -0,0 +1,44 @@
+# Copyright 2012 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+if ![dwarf2_support] {
+    return 0  
+}
+
+set basename "fission-reread"
+
+standard_testfile .S
+
+# IWBN to use prepare_for_testing here, but we need to set debug-file-directory
+# before we load the binary.
+
+if { [build_executable "$testfile.exp" "$testfile" "$srcfile" {nodebug}] } {
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+# Set debug-file-directory so we find the dwo file.
+gdb_test_no_output "set debug-file-directory $subdir"
+gdb_load [standard_output_file $testfile]
+
+gdb_test "break main" "Breakpoint.*at.*"
+
+# If we get this far gdb didn't crash, nor did an error occur.
+pass $testfile