int do_debug_info;
int do_debug_abbrevs;
int do_debug_lines;
-int do_debug_lines_decoded;
int do_debug_pubnames;
int do_debug_aranges;
int do_debug_ranges;
int do_debug_loc;
int do_wide;
+/* Values for do_debug_lines. */
+#define FLAG_DEBUG_LINES_RAW 1
+#define FLAG_DEBUG_LINES_DECODED 2
+
dwarf_vma (*byte_get) (unsigned char *, int);
dwarf_vma
{
unsigned char *data = section->start;
unsigned char *end = data + section->size;
- int retValRaw = 0;
- int retValDecoded = 0;
+ int retValRaw = 1;
+ int retValDecoded = 1;
if (load_debug_info (file) == 0)
{
return 0;
}
- if (do_debug_lines)
+ if (do_debug_lines & FLAG_DEBUG_LINES_RAW)
retValRaw = display_debug_lines_raw (section, data, end);
- if (do_debug_lines_decoded)
+ if (do_debug_lines & FLAG_DEBUG_LINES_DECODED)
retValDecoded = display_debug_lines_decoded (section, data, end);
- if ((do_debug_lines && !retValRaw)
- || (do_debug_lines_decoded && !retValDecoded))
+ if (!retValRaw || !retValDecoded)
return 0;
return 1;
}
}
+void
+dwarf_select_sections_by_names (const char *names)
+{
+ typedef struct
+ {
+ const char * option;
+ int * variable;
+ int val;
+ }
+ debug_dump_long_opts;
+
+ static const debug_dump_long_opts opts_table [] =
+ {
+ /* Please keep this table alpha- sorted. */
+ { "Ranges", & do_debug_ranges, 1 },
+ { "abbrev", & do_debug_abbrevs, 1 },
+ { "aranges", & do_debug_aranges, 1 },
+ { "frames", & do_debug_frames, 1 },
+ { "frames-interp", & do_debug_frames_interp, 1 },
+ { "info", & do_debug_info, 1 },
+ { "line", & do_debug_lines, FLAG_DEBUG_LINES_RAW }, /* For backwards compatibility. */
+ { "rawline", & do_debug_lines, FLAG_DEBUG_LINES_RAW },
+ { "decodedline", & do_debug_lines, FLAG_DEBUG_LINES_DECODED },
+ { "loc", & do_debug_loc, 1 },
+ { "macro", & do_debug_macinfo, 1 },
+ { "pubnames", & do_debug_pubnames, 1 },
+ /* This entry is for compatability
+ with earlier versions of readelf. */
+ { "ranges", & do_debug_aranges, 1 },
+ { "str", & do_debug_str, 1 },
+ { NULL, NULL, 0 }
+ };
+
+ const char *p;
+
+ p = names;
+ while (*p)
+ {
+ const debug_dump_long_opts * entry;
+
+ for (entry = opts_table; entry->option; entry++)
+ {
+ size_t len = strlen (entry->option);
+
+ if (strncmp (p, entry->option, len) == 0
+ && (p[len] == ',' || p[len] == '\0'))
+ {
+ * entry->variable |= entry->val;
+
+ /* The --debug-dump=frames-interp option also
+ enables the --debug-dump=frames option. */
+ if (do_debug_frames_interp)
+ do_debug_frames = 1;
+
+ p += len;
+ break;
+ }
+ }
+
+ if (entry->option == NULL)
+ {
+ warn (_("Unrecognized debug option '%s'\n"), p);
+ p = strchr (p, ',');
+ if (p == NULL)
+ break;
+ }
+
+ if (*p == ',')
+ p++;
+ }
+}
+
+void
+dwarf_select_sections_by_letters (const char *letters)
+{
+ unsigned int index = 0;
+
+ while (letters[index])
+ switch (letters[index++])
+ {
+ case 'i':
+ do_debug_info = 1;
+ break;
+
+ case 'a':
+ do_debug_abbrevs = 1;
+ break;
+
+ case 'l':
+ do_debug_lines |= FLAG_DEBUG_LINES_RAW;
+ break;
+
+ case 'L':
+ do_debug_lines |= FLAG_DEBUG_LINES_DECODED;
+ break;
+
+ case 'p':
+ do_debug_pubnames = 1;
+ break;
+
+ case 'r':
+ do_debug_aranges = 1;
+ break;
+
+ case 'R':
+ do_debug_ranges = 1;
+ break;
+
+ case 'F':
+ do_debug_frames_interp = 1;
+ case 'f':
+ do_debug_frames = 1;
+ break;
+
+ case 'm':
+ do_debug_macinfo = 1;
+ break;
+
+ case 's':
+ do_debug_str = 1;
+ break;
+
+ case 'o':
+ do_debug_loc = 1;
+ break;
+
+ default:
+ warn (_("Unrecognized debug option '%s'\n"), optarg);
+ break;
+ }
+}
+
+void
+dwarf_select_sections_all (void)
+{
+ do_debug_info = 1;
+ do_debug_abbrevs = 1;
+ do_debug_lines = FLAG_DEBUG_LINES_RAW;
+ do_debug_pubnames = 1;
+ do_debug_aranges = 1;
+ do_debug_ranges = 1;
+ do_debug_frames = 1;
+ do_debug_macinfo = 1;
+ do_debug_str = 1;
+ do_debug_loc = 1;
+}
+
struct dwarf_section_display debug_displays[] =
{
{ { ".debug_abbrev", ".zdebug_abbrev", NULL, NULL, 0, 0 },
- display_debug_abbrev, 0, 0 },
+ display_debug_abbrev, &do_debug_abbrevs, 0, 0 },
{ { ".debug_aranges", ".zdebug_aranges", NULL, NULL, 0, 0 },
- display_debug_aranges, 0, 0 },
+ display_debug_aranges, &do_debug_aranges, 0, 0 },
{ { ".debug_frame", ".zdebug_frame", NULL, NULL, 0, 0 },
- display_debug_frames, 1, 0 },
+ display_debug_frames, &do_debug_frames, 1, 0 },
{ { ".debug_info", ".zdebug_info", NULL, NULL, 0, 0 },
- display_debug_info, 1, 0 },
+ display_debug_info, &do_debug_info, 1, 0 },
{ { ".debug_line", ".zdebug_line", NULL, NULL, 0, 0 },
- display_debug_lines, 0, 0 },
+ display_debug_lines, &do_debug_lines, 0, 0 },
{ { ".debug_pubnames", ".zdebug_pubnames", NULL, NULL, 0, 0 },
- display_debug_pubnames, 0, 0 },
+ display_debug_pubnames, &do_debug_pubnames, 0, 0 },
{ { ".eh_frame", "", NULL, NULL, 0, 0 },
- display_debug_frames, 1, 1 },
+ display_debug_frames, &do_debug_frames, 1, 1 },
{ { ".debug_macinfo", ".zdebug_macinfo", NULL, NULL, 0, 0 },
- display_debug_macinfo, 0, 0 },
+ display_debug_macinfo, &do_debug_macinfo, 0, 0 },
{ { ".debug_str", ".zdebug_str", NULL, NULL, 0, 0 },
- display_debug_str, 0, 0 },
+ display_debug_str, &do_debug_str, 0, 0 },
{ { ".debug_loc", ".zdebug_loc", NULL, NULL, 0, 0 },
- display_debug_loc, 0, 0 },
+ display_debug_loc, &do_debug_loc, 0, 0 },
{ { ".debug_pubtypes", ".zdebug_pubtypes", NULL, NULL, 0, 0 },
- display_debug_pubnames, 0, 0 },
+ display_debug_pubnames, &do_debug_pubnames, 0, 0 },
{ { ".debug_ranges", ".zdebug_ranges", NULL, NULL, 0, 0 },
- display_debug_ranges, 0, 0 },
+ display_debug_ranges, &do_debug_ranges, 0, 0 },
{ { ".debug_static_func", ".zdebug_static_func", NULL, NULL, 0, 0 },
- display_debug_not_supported, 0, 0 },
+ display_debug_not_supported, NULL, 0, 0 },
{ { ".debug_static_vars", ".zdebug_static_vars", NULL, NULL, 0, 0 },
- display_debug_not_supported, 0, 0 },
- { { ".debug_types", ".zdebug_types", NULL, NULL, 0, 0 },
- display_debug_not_supported, 0, 0 },
+ display_debug_not_supported, NULL, 0, 0 },
+ { { ".debug_types", ".zdebug_types", NULL, NULL, 0, 0 },
+ display_debug_not_supported, NULL, 0, 0 },
{ { ".debug_weaknames", ".zdebug_weaknames", NULL, NULL, 0, 0 },
- display_debug_not_supported, 0, 0 }
+ display_debug_not_supported, NULL, 0, 0 }
};
-g, --debugging Display debug information in object file\n\
-e, --debugging-tags Display debug information using ctags style\n\
-G, --stabs Display (in raw form) any STABS info in the file\n\
- -W, --dwarf Display DWARF info in the file\n\
+ -W[lLiaprmfFsoR] or\n\
+ --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=str,=loc,=Ranges]\n\
+ Display DWARF info in the file\n\
-t, --syms Display the contents of the symbol table(s)\n\
-T, --dynamic-syms Display the contents of the dynamic symbol table\n\
-r, --reloc Display the relocation entries in the file\n\
OPTION_ENDIAN=150,
OPTION_START_ADDRESS,
OPTION_STOP_ADDRESS,
+ OPTION_DWARF,
OPTION_PREFIX,
OPTION_PREFIX_STRIP,
OPTION_ADJUST_VMA
{"source", no_argument, NULL, 'S'},
{"special-syms", no_argument, &dump_special_syms, 1},
{"include", required_argument, NULL, 'I'},
- {"dwarf", no_argument, NULL, 'W'},
+ {"dwarf", optional_argument, NULL, OPTION_DWARF},
{"stabs", no_argument, NULL, 'G'},
{"start-address", required_argument, NULL, OPTION_START_ADDRESS},
{"stop-address", required_argument, NULL, OPTION_STOP_ADDRESS},
match = name;
for (i = 0; i < max; i++)
- if (strcmp (debug_displays [i].section.uncompressed_name, match) == 0
- || strcmp (debug_displays [i].section.compressed_name, match) == 0)
+ if ((strcmp (debug_displays [i].section.uncompressed_name, match) == 0
+ || strcmp (debug_displays [i].section.compressed_name, match) == 0)
+ && debug_displays [i].enabled != NULL
+ && *debug_displays [i].enabled)
{
if (!debug_displays [i].eh_frame)
{
bfd_init ();
set_default_bfd_target ();
- while ((c = getopt_long (argc, argv, "pib:m:M:VvCdDlfFaHhrRtTxsSI:j:wE:zgeGW",
+ while ((c = getopt_long (argc, argv,
+ "pib:m:M:VvCdDlfFaHhrRtTxsSI:j:wE:zgeGW::",
long_options, (int *) 0))
!= EOF)
{
case 'W':
dump_dwarf_section_info = TRUE;
seenflag = TRUE;
- do_debug_info = 1;
- do_debug_abbrevs = 1;
- do_debug_lines = 1;
- do_debug_pubnames = 1;
- do_debug_aranges = 1;
- do_debug_ranges = 1;
- do_debug_frames = 1;
- do_debug_macinfo = 1;
- do_debug_str = 1;
- do_debug_loc = 1;
+ if (optarg)
+ dwarf_select_sections_by_letters (optarg);
+ else
+ dwarf_select_sections_all ();
+ break;
+ case OPTION_DWARF:
+ dump_dwarf_section_info = TRUE;
+ seenflag = TRUE;
+ if (optarg)
+ dwarf_select_sections_by_names (optarg);
+ else
+ dwarf_select_sections_all ();
break;
case 'G':
dump_stab_section_info = TRUE;
do_debugging = 1;
else
{
- unsigned int index = 0;
-
do_debugging = 0;
-
- while (optarg[index])
- switch (optarg[index++])
- {
- case 'i':
- do_debug_info = 1;
- break;
-
- case 'a':
- do_debug_abbrevs = 1;
- break;
-
- case 'l':
- do_debug_lines = 1;
- break;
-
- case 'L':
- do_debug_lines_decoded = 1;
- break;
-
- case 'p':
- do_debug_pubnames = 1;
- break;
-
- case 'r':
- do_debug_aranges = 1;
- break;
-
- case 'R':
- do_debug_ranges = 1;
- break;
-
- case 'F':
- do_debug_frames_interp = 1;
- case 'f':
- do_debug_frames = 1;
- break;
-
- case 'm':
- do_debug_macinfo = 1;
- break;
-
- case 's':
- do_debug_str = 1;
- break;
-
- case 'o':
- do_debug_loc = 1;
- break;
-
- default:
- warn (_("Unrecognized debug option '%s'\n"), optarg);
- break;
- }
+ dwarf_select_sections_by_letters (optarg);
}
break;
case OPTION_DEBUG_DUMP:
do_debugging = 1;
else
{
- typedef struct
- {
- const char * option;
- int * variable;
- }
- debug_dump_long_opts;
-
- debug_dump_long_opts opts_table [] =
- {
- /* Please keep this table alpha- sorted. */
- { "Ranges", & do_debug_ranges },
- { "abbrev", & do_debug_abbrevs },
- { "aranges", & do_debug_aranges },
- { "frames", & do_debug_frames },
- { "frames-interp", & do_debug_frames_interp },
- { "info", & do_debug_info },
- { "line", & do_debug_lines }, /* For backwards compatibility. */
- { "rawline", & do_debug_lines },
- { "decodedline", & do_debug_lines_decoded },
- { "loc", & do_debug_loc },
- { "macro", & do_debug_macinfo },
- { "pubnames", & do_debug_pubnames },
- /* This entry is for compatability
- with earlier versions of readelf. */
- { "ranges", & do_debug_aranges },
- { "str", & do_debug_str },
- { NULL, NULL }
- };
-
- const char *p;
-
do_debugging = 0;
-
- p = optarg;
- while (*p)
- {
- debug_dump_long_opts * entry;
-
- for (entry = opts_table; entry->option; entry++)
- {
- size_t len = strlen (entry->option);
-
- if (strneq (p, entry->option, len)
- && (p[len] == ',' || p[len] == '\0'))
- {
- * entry->variable = 1;
-
- /* The --debug-dump=frames-interp option also
- enables the --debug-dump=frames option. */
- if (do_debug_frames_interp)
- do_debug_frames = 1;
-
- p += len;
- break;
- }
- }
-
- if (entry->option == NULL)
- {
- warn (_("Unrecognized debug option '%s'\n"), p);
- p = strchr (p, ',');
- if (p == NULL)
- break;
- }
-
- if (*p == ',')
- p++;
- }
+ dwarf_select_sections_by_names (optarg);
}
break;
#ifdef SUPPORT_DISASSEMBLY
else if (section->sh_type == SHT_RELA)
CHECK_ENTSIZE (section, i, Rela);
else if ((do_debugging || do_debug_info || do_debug_abbrevs
- || do_debug_lines || do_debug_lines_decoded || do_debug_pubnames
+ || do_debug_lines || do_debug_pubnames
|| do_debug_aranges || do_debug_frames || do_debug_macinfo
|| do_debug_str || do_debug_loc || do_debug_ranges)
&& (const_strneq (name, ".debug_")
if (do_debugging
|| (do_debug_info && streq (name, "info"))
|| (do_debug_abbrevs && streq (name, "abbrev"))
- || ((do_debug_lines || do_debug_lines_decoded)
- && streq (name, "line"))
+ || (do_debug_lines && streq (name, "line"))
|| (do_debug_pubnames && streq (name, "pubnames"))
|| (do_debug_aranges && streq (name, "aranges"))
|| (do_debug_ranges && streq (name, "ranges"))