This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Support display of debug_macinfo in readelf.
- To: binutils at sources dot redhat dot com, Nick Clifton <nickc at redhat dot com>
- Subject: [PATCH] Support display of debug_macinfo in readelf.
- From: Daniel Berlin <dan at cgsoftware dot com>
- Date: Wed, 04 Jul 2001 15:18:57 -0400
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/binutils/ChangeLog,v
retrieving revision 1.303
diff -c -3 -p -w -B -b -r1.303 ChangeLog
*** ChangeLog 2001/07/01 08:53:14 1.303
--- ChangeLog 2001/07/04 19:15:18
***************
*** 1,3 ****
--- 1,13 ----
+ 2001-07-04 Daniel Berlin <dan@cgsoftware.com>
+
+ * readelf.c (display_debug_macinfo): New function, display
+ .debug_macinfo section.
+ (do_debug_macinfo): New variable.
+ (parse_args): Handle "-w[mM]" to mean display macro info.
+ (process_section_headers): Handle debug_macinfo.
+ (debug_displays): Replace unsupported function with macinfo
+ function for .debug_macinfo display.
+
2001-07-01 Daniel Berlin <dan@cgsoftware.com>
* readelf.c: Support DWARF 2.1 tags, encodings, languages.
Index: readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.108
diff -c -3 -p -w -B -b -r1.108 readelf.c
*** readelf.c 2001/07/01 08:53:15 1.108
--- readelf.c 2001/07/04 19:15:43
*************** int do_debug_pubname
*** 119,124 ****
--- 119,125 ----
int do_debug_aranges;
int do_debug_frames;
int do_debug_frames_interp;
+ int do_debug_macinfo;
int do_arch;
int do_notes;
int is_32bit_elf;
*************** static int display_debug_
*** 210,215 ****
--- 211,217 ----
static int display_debug_abbrev PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *));
static int display_debug_aranges PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *));
static int display_debug_frames PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *));
+ static int display_debug_macinfo PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *));
static unsigned char * process_abbrev_section PARAMS ((unsigned char *, unsigned char *));
static unsigned long read_leb128 PARAMS ((unsigned char *, int *, int));
static int process_extended_line_op PARAMS ((unsigned char *, int, int));
*************** usage ()
*** 2019,2025 ****
fprintf (stdout, _(" -D or --use-dynamic Use the dynamic section info when displaying symbols\n"));
fprintf (stdout, _(" -x <number> or --hex-dump=<number>\n"));
fprintf (stdout, _(" Dump the contents of section <number>\n"));
! fprintf (stdout, _(" -w[liaprf] or --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=frames]\n"));
fprintf (stdout, _(" Display the contents of DWARF2 debug sections\n"));
#ifdef SUPPORT_DISASSEMBLY
fprintf (stdout, _(" -i <number> or --instruction-dump=<number>\n"));
--- 2021,2027 ----
fprintf (stdout, _(" -D or --use-dynamic Use the dynamic section info when displaying symbols\n"));
fprintf (stdout, _(" -x <number> or --hex-dump=<number>\n"));
fprintf (stdout, _(" Dump the contents of section <number>\n"));
! fprintf (stdout, _(" -w[liaprmf] or --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=frames,=macro]\n"));
fprintf (stdout, _(" Display the contents of DWARF2 debug sections\n"));
#ifdef SUPPORT_DISASSEMBLY
fprintf (stdout, _(" -i <number> or --instruction-dump=<number>\n"));
*************** parse_args (argc, argv)
*** 2189,2194 ****
--- 2191,2201 ----
do_debug_frames = 1;
break;
+ case 'm':
+ case 'M':
+ do_debug_macinfo = 1;
+ break;
+
default:
warn (_("Unrecognised debug option '%s'\n"), optarg);
break;
*************** process_section_headers (file)
*** 2935,2941 ****
}
else if ((do_debugging || do_debug_info || do_debug_abbrevs
|| do_debug_lines || do_debug_pubnames || do_debug_aranges
! || do_debug_frames)
&& strncmp (name, ".debug_", 7) == 0)
{
name += 7;
--- 2942,2948 ----
}
else if ((do_debugging || do_debug_info || do_debug_abbrevs
|| do_debug_lines || do_debug_pubnames || do_debug_aranges
! || do_debug_frames || do_debug_macinfo)
&& strncmp (name, ".debug_", 7) == 0)
{
name += 7;
*************** process_section_headers (file)
*** 2947,2952 ****
--- 2954,2960 ----
|| (do_debug_pubnames && (strcmp (name, "pubnames") == 0))
|| (do_debug_aranges && (strcmp (name, "aranges") == 0))
|| (do_debug_frames && (strcmp (name, "frame") == 0))
+ || (do_debug_macinfo && (strcmp (name, "macinfo") == 0))
)
request_dump (i, DEBUG_DUMP);
}
*************** process_abbrev_section (start, end)
*** 6263,6268 ****
--- 6271,6348 ----
return NULL;
}
+ static int
+ display_debug_macinfo (section, start, file)
+ Elf32_Internal_Shdr * section;
+ unsigned char * start;
+ FILE * file ATTRIBUTE_UNUSED;
+ {
+ unsigned char * end = start + section->sh_size;
+ unsigned char * curr = start;
+ unsigned int bytes_read;
+ enum dwarf_macinfo_record_type op;
+ printf (_("Contents of the %s section:\n\n"), SECTION_NAME (section));
+
+ while (curr < end)
+ {
+ op = *curr;
+ curr++;
+ switch (op)
+ {
+ case DW_MACINFO_start_file:
+ {
+ unsigned int filenum;
+ unsigned int lineno;
+ lineno = read_leb128 (curr, & bytes_read, 0);
+ curr += bytes_read;
+ filenum = read_leb128 (curr, & bytes_read, 0);
+ curr += bytes_read;
+ printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"), lineno, filenum);
+ }
+ break;
+ case DW_MACINFO_end_file:
+ {
+ printf (_(" DW_MACINFO_end_file\n"));
+ }
+ break;
+ case DW_MACINFO_define:
+ {
+ unsigned int lineno;
+ const char *string;
+ lineno = read_leb128 (curr, & bytes_read, 0);
+ curr += bytes_read;
+ string = curr;
+ curr += strlen (string) + 1;
+ printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"), lineno, string);
+ }
+ break;
+ case DW_MACINFO_undef:
+ {
+ unsigned int lineno;
+ const char *string;
+ lineno = read_leb128 (curr, & bytes_read, 0);
+ curr += bytes_read;
+ string = curr;
+ curr += strlen (string) + 1;
+ printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"), lineno, string);
+ }
+ break;
+ case DW_MACINFO_vendor_ext:
+ {
+ unsigned int constant;
+ const char * string;
+ constant = read_leb128 (curr, & bytes_read, 0);
+ curr += bytes_read;
+ string = curr;
+ curr += strlen (string) + 1;
+ printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"), constant, string);
+ }
+ break;
+ }
+ }
+ return 1;
+ }
+
static int
display_debug_abbrev (section, start, file)
*************** debug_displays[] =
*** 7846,7852 ****
{ ".debug_pubnames", display_debug_pubnames, NULL },
{ ".debug_frame", display_debug_frames, NULL },
{ ".eh_frame", display_debug_frames, NULL },
! { ".debug_macinfo", display_debug_not_supported, NULL },
{ ".debug_str", display_debug_not_supported, NULL },
{ ".debug_static_func", display_debug_not_supported, NULL },
{ ".debug_static_vars", display_debug_not_supported, NULL },
--- 7926,7932 ----
{ ".debug_pubnames", display_debug_pubnames, NULL },
{ ".debug_frame", display_debug_frames, NULL },
{ ".eh_frame", display_debug_frames, NULL },
! { ".debug_macinfo", display_debug_macinfo, NULL },
{ ".debug_str", display_debug_not_supported, NULL },
{ ".debug_static_func", display_debug_not_supported, NULL },
{ ".debug_static_vars", display_debug_not_supported, NULL },
--
"I was once walking through the forest alone. A tree fell right
in front of me -- and I didn't hear it.
"-Steven Wright