c-lex.c (cb_file_change): Pass line number to debug_start_source_file.
authorDaniel Berlin <dan@cgsoftware.com>
Wed, 4 Jul 2001 17:55:20 +0000 (17:55 +0000)
committerDaniel Berlin <dberlin@gcc.gnu.org>
Wed, 4 Jul 2001 17:55:20 +0000 (17:55 +0000)
2001-07-04  Daniel Berlin  <dan@cgsoftware.com>

* c-lex.c (cb_file_change): Pass line number to
debug_start_source_file.
(cb_undefine): Pass correct line number to debug_undef.

* toplev.c (debug_start_source_file): Add line number to
parameters. Pass it along to dwarf2out_start_source_file.
(decode_g_option): Stop resetting debug level back to normal when
we change debug formats, unless the current level is
none. (Before, -g3 -gdwarf-2 would use debug level 2, rather than
3).

* toplev.h (debug_start_source_file): Add line number to
parameters.

* dwarf2out.h (dwarf2out_start_source_file): Add line number to parameters.

* dwarf2out.c (dwarf2out_start_source_file): Add line number to
parameters.
Output debug_macinfo data for starting file if requested.
(dwarf2out_end_source_file): Output debug_macinfo data for ending
file if requested.
(dwarf2out_define): Output debug_macinfo data for defining a macro if requested.
(dwarf2out_undef): Output debug_macinfo data for undefining a
macro if requested.
(DEBUG_MACINFO_SECTION): New. DWARF2 macro info section name.
(DEBUG_MACINFO_SECTION_LABEL): New. DWARF2 macro info section label.
(macinfo_section_label): New. DWARF2 macro info section label.
(dwarf2out_init): If we want macro info, output the start label
for the section.
(dwarf2out_finish): If we want macro info, add a DW_AT_macro_info
attribute to the compilation unit die pointing to the macro info.

2001-07-04  Daniel Berlin  <dan@cgsoftware.com>

* dwarf2out.c (new_loc_list): Move to inside #ifdef
DWARF2_DEBUGGING_INFO.
(add_loc_descr_to_loc_list): Ditto.
(output_loc_list): Ditto.
Also, fix thinko in curr not being initialized.
(gen_internal_sym): Ditto.

From-SVN: r43763

gcc/ChangeLog
gcc/c-lex.c
gcc/dwarf2out.c
gcc/dwarf2out.h
gcc/java/ChangeLog
gcc/java/jcf-parse.c
gcc/toplev.c
gcc/toplev.h

index dc2a6fa..9283fa1 100644 (file)
@@ -1,3 +1,46 @@
+2001-07-04  Daniel Berlin  <dan@cgsoftware.com>
+
+       * c-lex.c (cb_file_change): Pass line number to
+       debug_start_source_file. 
+       (cb_undefine): Pass correct line number to debug_undef.
+
+       * toplev.c (debug_start_source_file): Add line number to
+       parameters. Pass it along to dwarf2out_start_source_file.
+       (decode_g_option): Stop resetting debug level back to normal when
+       we change debug formats, unless the current level is
+       none. (Before, -g3 -gdwarf-2 would use debug level 2, rather than
+       3).
+       
+       * toplev.h (debug_start_source_file): Add line number to
+       parameters.
+       
+       * dwarf2out.h (dwarf2out_start_source_file): Add line number to parameters.
+
+       * dwarf2out.c (dwarf2out_start_source_file): Add line number to
+       parameters.
+       Output debug_macinfo data for starting file if requested. 
+       (dwarf2out_end_source_file): Output debug_macinfo data for ending
+       file if requested.
+       (dwarf2out_define): Output debug_macinfo data for defining a macro if requested.
+       (dwarf2out_undef): Output debug_macinfo data for undefining a
+       macro if requested.
+       (DEBUG_MACINFO_SECTION): New. DWARF2 macro info section name.
+       (DEBUG_MACINFO_SECTION_LABEL): New. DWARF2 macro info section label.
+       (macinfo_section_label): New. DWARF2 macro info section label.
+       (dwarf2out_init): If we want macro info, output the start label
+       for the section.
+       (dwarf2out_finish): If we want macro info, add a DW_AT_macro_info
+       attribute to the compilation unit die pointing to the macro info.
+
+2001-07-04  Daniel Berlin  <dan@cgsoftware.com>
+
+       * dwarf2out.c (new_loc_list): Move to inside #ifdef
+       DWARF2_DEBUGGING_INFO.
+       (add_loc_descr_to_loc_list): Ditto.
+       (output_loc_list): Ditto.
+       Also, fix thinko in curr not being initialized.
+       (gen_internal_sym): Ditto.
+     
 Wed Jul  4 13:40:02 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
        * emit-rtl.c (replace_equiv_address): New function.
index cb15901..714de0c 100644 (file)
@@ -249,7 +249,7 @@ cb_file_change (pfile, fc)
          lineno = fc->from.lineno;
          push_srcloc (fc->to.filename, 1);
          input_file_stack->indent_level = indent_level;
-         debug_start_source_file (fc->to.filename);
+         debug_start_source_file (fc->from.lineno, fc->to.filename);
 #ifndef NO_IMPLICIT_EXTERN_C
          if (c_header_level)
            ++c_header_level;
@@ -334,7 +334,7 @@ cb_define (pfile, node)
      cpp_reader *pfile;
      cpp_hashnode *node;
 {
-  debug_define (lineno, (const char *) cpp_macro_definition (pfile, node));
+  debug_define (cpp_get_line (parse_in)->line,  (const char *) cpp_macro_definition (pfile, node));
 }
 
 /* #undef callback for DWARF and DWARF2 debug info.  */
@@ -343,7 +343,7 @@ cb_undef (pfile, node)
      cpp_reader *pfile ATTRIBUTE_UNUSED;
      cpp_hashnode *node;
 {
-  debug_undef (lineno, (const char *) NODE_NAME (node));
+  debug_undef (cpp_get_line (parse_in)->line, (const char *) NODE_NAME (node));
 }
 
 #if 0 /* not yet */
index 1263e90..5879a8e 100644 (file)
@@ -2223,14 +2223,6 @@ static unsigned long size_of_locs        PARAMS ((dw_loc_descr_ref));
 static void output_loc_operands                PARAMS ((dw_loc_descr_ref));
 static void output_loc_sequence                PARAMS ((dw_loc_descr_ref));
 
-static dw_loc_list_ref new_loc_list     PARAMS ((dw_loc_descr_ref, 
-                                                const char *, const char *,
-                                                const char *, unsigned));
-static void add_loc_descr_to_loc_list   PARAMS ((dw_loc_list_ref *,
-                                                dw_loc_descr_ref,
-                                                const char *, const char *, const char *));
-static void output_loc_list            PARAMS ((dw_loc_list_ref));
-static char *gen_internal_sym          PARAMS ((const char *));
 /* Convert a DWARF stack opcode into its string name.  */
 
 static const char *
@@ -2558,28 +2550,6 @@ new_loc_descr (op, oprnd1, oprnd2)
   return descr;
 }
 
-/* Return a new location list, given the begin and end range, and the
-   expression. gensym tells us whether to generate a new internal
-   symbol for this location list node, which is done for the head of
-   the list only. */ 
-static inline dw_loc_list_ref
-new_loc_list (expr, begin, end, section, gensym)
-     register dw_loc_descr_ref expr;
-     register const char *begin;
-     register const char *end;
-     register const char *section;
-     register unsigned gensym;
-{
-  register dw_loc_list_ref retlist
-    = (dw_loc_list_ref) xcalloc (1, sizeof (dw_loc_list_node));
-  retlist->begin = begin;
-  retlist->end = end;
-  retlist->expr = expr;
-  retlist->section = section;
-  if (gensym) 
-    retlist->ll_symbol = gen_internal_sym ("LLST");
-  return retlist;
-}
 
 /* Add a location description term to a location description expression.  */
 
@@ -2597,24 +2567,6 @@ add_loc_descr (list_head, descr)
   *d = descr;
 }
 
-/* Add a location description expression to a location list */
-static inline void
-add_loc_descr_to_loc_list (list_head, descr, begin, end, section)
-     register dw_loc_list_ref *list_head;
-     register dw_loc_descr_ref descr;
-     register const char *begin;
-     register const char *end;
-     register const char *section;
-{
-  register dw_loc_list_ref *d;
-  
-  /* Find the end of the chain. */
-  for (d = list_head; (*d) != NULL; d = &(*d)->dw_loc_next)
-    ;
-  /* Add a new location list node to the list */
-  *d = new_loc_list (descr, begin, end, section, 0);
-}
-
 /* Return the size of a location descriptor.  */
 
 static unsigned long
@@ -3592,6 +3544,14 @@ static void gen_type_die_for_member      PARAMS ((tree, tree, dw_die_ref));
 static rtx save_rtx                    PARAMS ((rtx));
 static void splice_child_die           PARAMS ((dw_die_ref, dw_die_ref));
 static int file_info_cmp               PARAMS ((const void *, const void *));
+static dw_loc_list_ref new_loc_list     PARAMS ((dw_loc_descr_ref, 
+                                                const char *, const char *,
+                                                const char *, unsigned));
+static void add_loc_descr_to_loc_list   PARAMS ((dw_loc_list_ref *,
+                                                dw_loc_descr_ref,
+                                                const char *, const char *, const char *));
+static void output_loc_list            PARAMS ((dw_loc_list_ref));
+static char *gen_internal_sym          PARAMS ((const char *));
 
 /* Section names used to hold DWARF debugging information.  */
 #ifndef DEBUG_INFO_SECTION
@@ -3648,7 +3608,9 @@ static int file_info_cmp          PARAMS ((const void *, const void *));
 #ifndef DEBUG_LOC_SECTION_LABEL
 #define DEBUG_LOC_SECTION_LABEL                "Ldebug_loc"
 #endif
-
+#ifndef DEBUG_MACINFO_SECTION_LABEL
+#define DEBUG_MACINFO_SECTION_LABEL     "Ldebug_macinfo"
+#endif
 /* Definitions of defaults for formats and names of various special
    (artificial) labels which may be generated within this file (when the -g
    options is used and DWARF_DEBUGGING_INFO is in effect.
@@ -3660,6 +3622,7 @@ static char text_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
 static char abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
 static char debug_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
 static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char macinfo_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
 static char loc_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
 #ifndef TEXT_END_LABEL
 #define TEXT_END_LABEL         "Letext"
@@ -5931,21 +5894,64 @@ output_die_symbol (die)
   ASM_OUTPUT_LABEL (asm_out_file, sym);
 }
 
+/* Return a new location list, given the begin and end range, and the
+   expression. gensym tells us whether to generate a new internal
+   symbol for this location list node, which is done for the head of
+   the list only. */ 
+static inline dw_loc_list_ref
+new_loc_list (expr, begin, end, section, gensym)
+     register dw_loc_descr_ref expr;
+     register const char *begin;
+     register const char *end;
+     register const char *section;
+     register unsigned gensym;
+{
+  register dw_loc_list_ref retlist
+    = (dw_loc_list_ref) xcalloc (1, sizeof (dw_loc_list_node));
+  retlist->begin = begin;
+  retlist->end = end;
+  retlist->expr = expr;
+  retlist->section = section;
+  if (gensym) 
+    retlist->ll_symbol = gen_internal_sym ("LLST");
+  return retlist;
+}
+
+/* Add a location description expression to a location list */
+static inline void
+add_loc_descr_to_loc_list (list_head, descr, begin, end, section)
+     register dw_loc_list_ref *list_head;
+     register dw_loc_descr_ref descr;
+     register const char *begin;
+     register const char *end;
+     register const char *section;
+{
+  register dw_loc_list_ref *d;
+  
+  /* Find the end of the chain. */
+  for (d = list_head; (*d) != NULL; d = &(*d)->dw_loc_next)
+    ;
+  /* Add a new location list node to the list */
+  *d = new_loc_list (descr, begin, end, section, 0);
+}
+
+
+
 /* Output the location list given to us */
 static void
 output_loc_list (list_head)
      register dw_loc_list_ref list_head;
 {
-  register dw_loc_list_ref curr;
+  register dw_loc_list_ref curr=list_head;
   ASM_OUTPUT_LABEL (asm_out_file, list_head->ll_symbol);
   if (strcmp (curr->section, ".text") == 0)
     {
       if (DWARF2_ADDR_SIZE == 4)
-        dw2_asm_output_data (DWARF2_ADDR_SIZE, 0xffffffff, "Location list base address specifier fake entry");
+       dw2_asm_output_data (DWARF2_ADDR_SIZE, 0xffffffff, "Location list base address specifier fake entry");
       else if (DWARF2_ADDR_SIZE == 8)
        dw2_asm_output_data (DWARF2_ADDR_SIZE, 0xffffffffffffffffLL, "Location list base address specifier fake entry");
       else
-        abort();
+       abort();
       dw2_asm_output_offset (DWARF2_ADDR_SIZE, curr->section, "Location list base address specifier base");
     }
   for (curr = list_head; curr != NULL; curr=curr->dw_loc_next)
@@ -11263,10 +11269,11 @@ dwarf2out_line (filename, line)
 }
 
 /* Record the beginning of a new source file, for later output
-   of the .debug_macinfo section.  At present, unimplemented.  */
+   of the .debug_macinfo section.*/
 
 void
-dwarf2out_start_source_file (filename)
+dwarf2out_start_source_file (lineno, filename)
+     register unsigned int lineno ATTRIBUTE_UNUSED;
      register const char *filename ATTRIBUTE_UNUSED;
 {
   if (flag_eliminate_dwarf2_dups)
@@ -11275,6 +11282,13 @@ dwarf2out_start_source_file (filename)
       dw_die_ref bincl_die = new_die (DW_TAG_GNU_BINCL, comp_unit_die);
       add_AT_string (bincl_die, DW_AT_name, filename);
     }
+  if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+    {
+      ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
+      dw2_asm_output_data (1, DW_MACINFO_start_file, "Start new file");
+      dw2_asm_output_data_uleb128 (lineno, "Included from line number %d", lineno);
+      dw2_asm_output_data_uleb128 (lookup_filename (filename), "Filename we just started");
+    }
 }
 
 /* Record the end of a source file, for later output
@@ -11288,6 +11302,11 @@ dwarf2out_end_source_file ()
       /* Record the end of the file for break_out_includes.  */
       new_die (DW_TAG_GNU_EINCL, comp_unit_die);
     }
+  if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+    {
+      ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
+      dw2_asm_output_data (1, DW_MACINFO_end_file, "End file");
+    }
 }
 
 /* Called from check_newline in c-parse.y.  The `buffer' parameter contains
@@ -11302,9 +11321,16 @@ dwarf2out_define (lineno, buffer)
   static int initialized = 0;
   if (!initialized)
     {
-      dwarf2out_start_source_file (primary_filename);
+      dwarf2out_start_source_file (0, primary_filename);
       initialized = 1;
     }
+  if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+    {
+      ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
+      dw2_asm_output_data (1, DW_MACINFO_define, "Define macro");
+      dw2_asm_output_data_uleb128 (lineno, "At line number %d", lineno);
+      dw2_asm_output_nstring (buffer, -1, "The macro");
+    }
 }
 
 /* Called from check_newline in c-parse.y.  The `buffer' parameter contains
@@ -11316,6 +11342,13 @@ dwarf2out_undef (lineno, buffer)
      register unsigned lineno ATTRIBUTE_UNUSED;
      register const char *buffer ATTRIBUTE_UNUSED;
 {
+  if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+    {
+      ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
+      dw2_asm_output_data (1, DW_MACINFO_undef, "Undefine macro");
+      dw2_asm_output_data_uleb128 (lineno, "At line number %d", lineno);
+      dw2_asm_output_nstring (buffer, -1, "The macro");
+    }
 }
 
 /* Set up for Dwarf output at the start of compilation.  */
@@ -11398,6 +11431,13 @@ dwarf2out_init (asm_out_file, main_input_filename)
   ASM_OUTPUT_LABEL (asm_out_file, debug_info_section_label);
   ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LINE_SECTION);
   ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label);
+  if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+    {
+      ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
+      ASM_GENERATE_INTERNAL_LABEL (macinfo_section_label,
+                                  DEBUG_MACINFO_SECTION_LABEL, 0);
+      ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label);
+    }
 }
 
 /* Output stuff that dwarf requires at the end of every file,
@@ -11489,10 +11529,8 @@ dwarf2out_finish ()
     add_AT_lbl_offset (comp_unit_die, DW_AT_stmt_list,
                       debug_line_section_label);
 
-#if 0 /* unimplemented */
-  if (debug_info_level >= DINFO_LEVEL_VERBOSE && primary)
-    add_AT_unsigned (die, DW_AT_macro_info, 0);
-#endif
+  if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+    add_AT_lbl_offset (comp_unit_die, DW_AT_macro_info, macinfo_section_label);
 
   /* Output all of the compilation units.  We put the main one last so that
      the offsets are available to output_pubnames.  */
index 1f42626..6c657cb 100644 (file)
@@ -23,7 +23,7 @@ extern void dwarf2out_finish          PARAMS ((void));
 
 extern void dwarf2out_define           PARAMS ((unsigned, const char *));
 extern void dwarf2out_undef            PARAMS ((unsigned, const char *));
-extern void dwarf2out_start_source_file        PARAMS ((const char *));
+extern void dwarf2out_start_source_file        PARAMS ((unsigned, const char *));
 extern void dwarf2out_end_source_file  PARAMS ((void));
 
 extern void dwarf2out_begin_block      PARAMS ((unsigned));
index 8d4709f..6a73085 100644 (file)
@@ -1,3 +1,8 @@
+2001-07-04  Daniel Berlin  <dan@cgsoftware.com>
+
+       * jcf-parse.c (parse_class_file): Add lineno parameter to
+       debug_start_source_file call.
+
 2001-07-04  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * gcj.texi: Use gpl.texi.
index 82583e0..b4d5ba0 100644 (file)
@@ -773,7 +773,7 @@ parse_class_file ()
 
   input_filename = DECL_SOURCE_FILE (TYPE_NAME (current_class));
   lineno = 0;
-  debug_start_source_file (input_filename);
+  debug_start_source_file (lineno, input_filename);
   init_outgoing_cpool ();
 
   /* Currently we always have to emit calls to _Jv_InitClass when
index 762b7f1..94b830e 100644 (file)
@@ -4272,7 +4272,7 @@ static int
 decode_g_option (arg)
      const char *arg;
 {
-  unsigned level;
+  static unsigned level=0;
   /* A lot of code assumes write_symbols == NO_DEBUG if the
      debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
      of what debugging type has been selected).  This records the
@@ -4316,7 +4316,7 @@ decode_g_option (arg)
          if (*p)
            level = read_integral_parameter (p, 0, max_debug_level + 1);
          else
-           level = 2;
+           level = (level == 0) ? 2 : level;
 
          if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
            {
@@ -5177,7 +5177,8 @@ print_switch_values (file, pos, max, indent, sep, term)
 /* Record the beginning of a new source file, named FILENAME.  */
 
 void
-debug_start_source_file (filename)
+debug_start_source_file (lineno, filename)
+     register unsigned int lineno ATTRIBUTE_UNUSED;
      register const char *filename ATTRIBUTE_UNUSED;
 {
 #ifdef DBX_DEBUGGING_INFO
@@ -5191,7 +5192,7 @@ debug_start_source_file (filename)
 #endif /* DWARF_DEBUGGING_INFO  */
 #ifdef DWARF2_DEBUGGING_INFO
   if (write_symbols == DWARF2_DEBUG)
-    dwarf2out_start_source_file (filename);
+    dwarf2out_start_source_file (lineno, filename);
 #endif /* DWARF2_DEBUGGING_INFO  */
 #ifdef SDB_DEBUGGING_INFO
   if (write_symbols == SDB_DEBUG)
index 2a6dad1..a9ea125 100644 (file)
@@ -37,7 +37,7 @@ extern int read_integral_parameter    PARAMS ((const char *, const char *,
 extern int count_error                 PARAMS ((int));
 extern void strip_off_ending           PARAMS ((char *, int));
 extern void print_time                 PARAMS ((const char *, long));
-extern void debug_start_source_file    PARAMS ((const char *));
+extern void debug_start_source_file    PARAMS ((unsigned, const char *));
 extern void debug_end_source_file      PARAMS ((unsigned));
 extern void debug_define               PARAMS ((unsigned, const char *));
 extern void debug_undef                        PARAMS ((unsigned, const char *));