OSDN Git Service

* config/s390/s390.c (s390_fixup_clobbered_return_reg):
[pf3gnuchains/gcc-fork.git] / gcc / dwarf2out.c
index 5a515e3..3c6dec7 100644 (file)
@@ -257,6 +257,18 @@ dw_fde_node;
 #define DWARF_OFFSET_SIZE 4
 #endif
 
+/* According to the (draft) DWARF 3 specification, the initial length
+   should either be 4 or 12 bytes.  When it's 12 bytes, the first 4
+   bytes are 0xffffffff, followed by the length stored in the next 8
+   bytes.
+
+   However, the SGI/MIPS ABI uses an initial length which is equal to
+   DWARF_OFFSET_SIZE.  It is defined (elsewhere) accordingly.  */
+
+#ifndef DWARF_INITIAL_LENGTH_SIZE
+#define DWARF_INITIAL_LENGTH_SIZE (DWARF_OFFSET_SIZE == 4 ? 4 : 12)
+#endif
+
 #define DWARF_VERSION 2
 
 /* Round SIZE up to the nearest BOUNDARY.  */
@@ -3397,7 +3409,8 @@ limbo_die_node;
    language, and compiler version.  */
 
 /* Fixed size portion of the DWARF compilation unit header.  */
-#define DWARF_COMPILE_UNIT_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 3)
+#define DWARF_COMPILE_UNIT_HEADER_SIZE \
+  (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE + 3)
 
 /* Fixed size portion of public names info.  */
 #define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
@@ -6349,7 +6362,10 @@ size_of_die (die)
          size += 1;
          break;
        case dw_val_class_die_ref:
-         size += DWARF_OFFSET_SIZE;
+         if (AT_ref_external (a))
+           size += DWARF2_ADDR_SIZE;
+         else
+           size += DWARF_OFFSET_SIZE;
          break;
        case dw_val_class_fde_ref:
          size += DWARF_OFFSET_SIZE;
@@ -6909,7 +6925,11 @@ output_die (die)
 static void
 output_compilation_unit_header ()
 {
-  dw2_asm_output_data (DWARF_OFFSET_SIZE, next_die_offset - DWARF_OFFSET_SIZE,
+  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+    dw2_asm_output_data (4, 0xffffffff,
+      "Initial length escape value indicating 64-bit DWARF extension");
+  dw2_asm_output_data (DWARF_OFFSET_SIZE,
+                       next_die_offset - DWARF_INITIAL_LENGTH_SIZE,
                       "Length of Compilation Unit Info");
   dw2_asm_output_data (2, DWARF_VERSION, "DWARF version number");
   dw2_asm_output_offset (DWARF_OFFSET_SIZE, abbrev_section_label,
@@ -7020,6 +7040,9 @@ output_pubnames ()
   unsigned i;
   unsigned long pubnames_length = size_of_pubnames ();
 
+  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+    dw2_asm_output_data (4, 0xffffffff,
+      "Initial length escape value indicating 64-bit DWARF extension");
   dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length,
                       "Length of Public Names Info");
   dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
@@ -7078,6 +7101,9 @@ output_aranges ()
   unsigned i;
   unsigned long aranges_length = size_of_aranges ();
 
+  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+    dw2_asm_output_data (4, 0xffffffff,
+      "Initial length escape value indicating 64-bit DWARF extension");
   dw2_asm_output_data (DWARF_OFFSET_SIZE, aranges_length,
                       "Length of Address Ranges Info");
   dw2_asm_output_data (2, DWARF_VERSION, "DWARF Version");
@@ -7484,7 +7510,7 @@ output_file_names ()
       int dir_idx = dirs[files[file_idx].dir_idx].dir_idx;
 
       dw2_asm_output_nstring (files[file_idx].path + dirs[dir_idx].length, -1,
-                             "File Entry: 0x%x", i);
+                             "File Entry: 0x%lx", (unsigned long) i);
 
       /* Include directory index.  */
       dw2_asm_output_data_uleb128 (dirs[dir_idx].used, NULL);
@@ -7523,6 +7549,9 @@ output_line_info ()
   ASM_GENERATE_INTERNAL_LABEL (p1, LN_PROLOG_AS_LABEL, 0);
   ASM_GENERATE_INTERNAL_LABEL (p2, LN_PROLOG_END_LABEL, 0);
 
+  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+    dw2_asm_output_data (4, 0xffffffff,
+      "Initial length escape value indicating 64-bit DWARF extension");
   dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
                        "Length of Source Line Info");
   ASM_OUTPUT_LABEL (asm_out_file, l1);
@@ -8216,10 +8245,10 @@ multiple_reg_loc_descriptor (rtl, regs)
        {
          dw_loc_descr_ref t;
 
-         ++reg;
          t = one_reg_loc_descriptor (reg);
          add_loc_descr (&loc_result, t);
          add_loc_descr (&loc_result, new_loc_descr (DW_OP_piece, size, 0));
+         ++reg;
        }
       return loc_result;
     }
@@ -8394,6 +8423,11 @@ mem_loc_descriptor (rtl, mode)
        add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
       break;
 
+    case LO_SUM:
+        rtl = XEXP (rtl, 1);
+
+      /* ... fall through ...  */
+
     case LABEL_REF:
       /* Some ports can transform a symbol ref into a label ref, because
         the symbol ref is too far away and has to be dumped into a constant
@@ -12015,6 +12049,10 @@ decls_for_scope (stmt, context_die, depth)
        gen_decl_die (decl, context_die);
     }
 
+  /* If we're at -g1, we're not interested in subblocks.  */
+  if (debug_info_level <= DINFO_LEVEL_TERSE)
+    return;
+
   /* Output the DIEs to represent all sub-blocks (and the items declared
      therein) of this block.  */
   for (subblocks = BLOCK_SUBBLOCKS (stmt);
@@ -12187,6 +12225,9 @@ gen_decl_die (decl, context_die)
       break;
 
     default:
+      if ((int)TREE_CODE (decl) > NUM_TREE_CODES)
+       /* Probably some frontend-internal decl.  Assume we don't care.  */
+       break;
       abort ();
     }
 }
@@ -12283,7 +12324,9 @@ dwarf2out_decl (decl)
       /* If we're a nested function, initially use a parent of NULL; if we're
         a plain function, this will be fixed up in decls_for_scope.  If
         we're a method, it will be ignored, since we already have a DIE.  */
-      if (decl_function_context (decl))
+      if (decl_function_context (decl)
+         /* But if we're in terse mode, we don't care about scope.  */
+         && debug_info_level > DINFO_LEVEL_TERSE)
        context_die = NULL;
       break;
 
@@ -12752,7 +12795,7 @@ output_indirect_string (h, v)
 
 
 /* Clear the marks for a die and its children.
-   Be cool if the mark isn't set. */
+   Be cool if the mark isn't set.  */
 
 static void
 prune_unmark_dies (die)
@@ -12826,7 +12869,7 @@ prune_unused_types_mark (die, dokids)
       for (c = die->die_child; c; c = c->die_sib)
        {
          /* If this is an array type, we need to make sure our
-            kids get marked, even if they're types. */
+            kids get marked, even if they're types.  */
          if (die->die_tag == DW_TAG_array_type)
            prune_unused_types_mark (c, 1);
          else
@@ -12938,14 +12981,10 @@ prune_unused_types ()
 
   /* Also set the mark on nodes referenced from the
      pubname_table or arange_table.  */
-  for (i=0; i < pubname_table_in_use; i++)
-    {
-      prune_unused_types_mark (pubname_table[i].die, 1);
-    }
-  for (i=0; i < arange_table_in_use; i++)
-    {
-      prune_unused_types_mark (arange_table[i], 1);
-    }
+  for (i = 0; i < pubname_table_in_use; i++)
+    prune_unused_types_mark (pubname_table[i].die, 1);
+  for (i = 0; i < arange_table_in_use; i++)
+    prune_unused_types_mark (arange_table[i], 1);
 
   /* Get rid of nodes that aren't marked.  */
   prune_unused_types_prune (comp_unit_die);