This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Revised DWARF2 macro info patch
- To: gcc-patches at gcc dot gnu dot org
- Subject: [PATCH] Revised DWARF2 macro info patch
- From: Daniel Berlin <dan at cgsoftware dot com>
- Date: Thu, 28 Jun 2001 13:07:18 -0400
Taking advantage of Neil making cpp_macro_definition return the
correct thing, here's a revised patch.
IIRC, Neil said the way i'm passing line numbers is correct, and the
way it used to be is broken.
2001-06-28 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.
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.c,v
retrieving revision 1.475
diff -c -3 -p -w -B -b -r1.475 toplev.c
*** toplev.c 2001/06/26 19:24:08 1.475
--- toplev.c 2001/06/28 17:00:29
*************** static int
*** 4269,4275 ****
decode_g_option (arg)
const char *arg;
{
! unsigned level;
/* 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
--- 4347,4353 ----
decode_g_option (arg)
const char *arg;
{
! 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
*************** decode_g_option (arg)
*** 4313,4319 ****
if (*p)
level = read_integral_parameter (p, 0, max_debug_level + 1);
else
! level = 2;
if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
{
--- 4391,4397 ----
if (*p)
level = read_integral_parameter (p, 0, max_debug_level + 1);
else
! level = (level == 0) ? 2 : level;
if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
{
*************** print_switch_values (file, pos, max, ind
*** 5174,5180 ****
/* Record the beginning of a new source file, named FILENAME. */
void
! debug_start_source_file (filename)
register const char *filename ATTRIBUTE_UNUSED;
{
#ifdef DBX_DEBUGGING_INFO
--- 5253,5260 ----
/* Record the beginning of a new source file, named FILENAME. */
void
! debug_start_source_file (lineno, filename)
! register unsigned int lineno ATTRIBUTE_UNUSED;
register const char *filename ATTRIBUTE_UNUSED;
{
#ifdef DBX_DEBUGGING_INFO
*************** debug_start_source_file (filename)
*** 5188,5194 ****
#endif /* DWARF_DEBUGGING_INFO */
#ifdef DWARF2_DEBUGGING_INFO
if (write_symbols == DWARF2_DEBUG)
! dwarf2out_start_source_file (filename);
#endif /* DWARF2_DEBUGGING_INFO */
#ifdef SDB_DEBUGGING_INFO
if (write_symbols == SDB_DEBUG)
--- 5268,5274 ----
#endif /* DWARF_DEBUGGING_INFO */
#ifdef DWARF2_DEBUGGING_INFO
if (write_symbols == DWARF2_DEBUG)
! dwarf2out_start_source_file (lineno, filename);
#endif /* DWARF2_DEBUGGING_INFO */
#ifdef SDB_DEBUGGING_INFO
if (write_symbols == SDB_DEBUG)
Index: toplev.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.h,v
retrieving revision 1.65
diff -c -3 -p -w -B -b -r1.65 toplev.h
*** toplev.h 2001/06/10 13:47:57 1.65
--- toplev.h 2001/06/28 17:00:30
*************** extern int read_integral_parameter PARAM
*** 37,43 ****
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_end_source_file PARAMS ((unsigned));
extern void debug_define PARAMS ((unsigned, const char *));
extern void debug_undef PARAMS ((unsigned, const char *));
--- 37,43 ----
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 ((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 *));
Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/dwarf2out.c,v
retrieving revision 1.277
diff -c -3 -p -w -B -b -r1.277 dwarf2out.c
*** dwarf2out.c 2001/06/10 13:47:55 1.277
--- dwarf2out.c 2001/06/28 17:00:39
*************** static int file_info_cmp PARAMS ((const
*** 3650,3656 ****
#ifndef DEBUG_LOC_SECTION_LABEL
#define DEBUG_LOC_SECTION_LABEL "Ldebug_loc"
#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.
--- 3651,3659 ----
#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.
*************** static char text_section_label[MAX_ARTIF
*** 3662,3667 ****
--- 3665,3671 ----
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"
*************** dwarf2out_line (filename, line)
*** 11265,11274 ****
}
/* Record the beginning of a new source file, for later output
! of the .debug_macinfo section. At present, unimplemented. */
void
! dwarf2out_start_source_file (filename)
register const char *filename ATTRIBUTE_UNUSED;
{
if (flag_eliminate_dwarf2_dups)
--- 11269,11279 ----
}
/* Record the beginning of a new source file, for later output
! of the .debug_macinfo section.*/
void
! dwarf2out_start_source_file (lineno, filename)
! register unsigned int lineno ATTRIBUTE_UNUSED;
register const char *filename ATTRIBUTE_UNUSED;
{
if (flag_eliminate_dwarf2_dups)
*************** dwarf2out_start_source_file (filename)
*** 11277,11282 ****
--- 11282,11294 ----
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
*************** dwarf2out_end_source_file ()
*** 11290,11295 ****
--- 11302,11312 ----
/* 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
*************** dwarf2out_define (lineno, buffer)
*** 11302,11312 ****
register const char *buffer ATTRIBUTE_UNUSED;
{
static int initialized = 0;
if (!initialized)
{
! dwarf2out_start_source_file (primary_filename);
initialized = 1;
}
}
/* Called from check_newline in c-parse.y. The `buffer' parameter contains
--- 11319,11336 ----
register const char *buffer ATTRIBUTE_UNUSED;
{
static int initialized = 0;
if (!initialized)
{
! 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
*************** dwarf2out_undef (lineno, buffer)
*** 11318,11323 ****
--- 11343,11355 ----
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. */
*************** dwarf2out_init (asm_out_file, main_input
*** 11400,11406 ****
--- 11433,11446 ----
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,
and generate the DWARF-2 debugging info. */
*************** dwarf2out_finish ()
*** 11491,11500 ****
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
/* Output all of the compilation units. We put the main one last so that
the offsets are available to output_pubnames. */
--- 11531,11538 ----
add_AT_lbl_offset (comp_unit_die, DW_AT_stmt_list,
debug_line_section_label);
! 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: c-lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-lex.c,v
retrieving revision 1.141
diff -c -3 -p -w -B -b -r1.141 c-lex.c
*** c-lex.c 2001/05/23 19:05:37 1.141
--- c-lex.c 2001/06/28 17:02:58
*************** cb_file_change (pfile, fc)
*** 249,255 ****
lineno = fc->from.lineno;
push_srcloc (fc->to.filename, 1);
input_file_stack->indent_level = indent_level;
! debug_start_source_file (fc->to.filename);
#ifndef NO_IMPLICIT_EXTERN_C
if (c_header_level)
++c_header_level;
--- 249,255 ----
lineno = fc->from.lineno;
push_srcloc (fc->to.filename, 1);
input_file_stack->indent_level = indent_level;
! debug_start_source_file (fc->from.lineno, fc->to.filename);
#ifndef NO_IMPLICIT_EXTERN_C
if (c_header_level)
++c_header_level;
*************** cb_define (pfile, node)
*** 334,340 ****
cpp_reader *pfile;
cpp_hashnode *node;
{
! debug_define (lineno, (const char *) cpp_macro_definition (pfile, node));
}
/* #undef callback for DWARF and DWARF2 debug info. */
--- 334,340 ----
cpp_reader *pfile;
cpp_hashnode *node;
{
! debug_define (cpp_get_line (parse_in)->line, (const char *) cpp_macro_definition (pfile, node));
}
/* #undef callback for DWARF and DWARF2 debug info. */
*************** cb_undef (pfile, node)
*** 343,349 ****
cpp_reader *pfile ATTRIBUTE_UNUSED;
cpp_hashnode *node;
{
! debug_undef (lineno, (const char *) NODE_NAME (node));
}
#if 0 /* not yet */
--- 343,349 ----
cpp_reader *pfile ATTRIBUTE_UNUSED;
cpp_hashnode *node;
{
! debug_undef (cpp_get_line (parse_in)->line, (const char *) NODE_NAME (node));
}
#if 0 /* not yet */
Index: java/jcf-parse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/jcf-parse.c,v
retrieving revision 1.85
diff -c -3 -p -w -B -b -r1.85 jcf-parse.c
*** jcf-parse.c 2001/05/21 21:37:36 1.85
--- jcf-parse.c 2001/06/28 17:03:30
*************** parse_class_file ()
*** 771,777 ****
input_filename = DECL_SOURCE_FILE (TYPE_NAME (current_class));
lineno = 0;
! debug_start_source_file (input_filename);
init_outgoing_cpool ();
/* Currently we always have to emit calls to _Jv_InitClass when
--- 771,777 ----
input_filename = DECL_SOURCE_FILE (TYPE_NAME (current_class));
lineno = 0;
! debug_start_source_file (lineno, input_filename);
init_outgoing_cpool ();
/* Currently we always have to emit calls to _Jv_InitClass when
--
"In Vegas, I got into a long argument with the man at the
roulette wheel over what I considered to be an odd number.
"-Steven Wright