From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12327 invoked by alias); 25 Jul 2002 16:22:53 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 12296 invoked from network); 25 Jul 2002 16:22:49 -0000 Received: from unknown (HELO sunsite.mff.cuni.cz) (195.113.19.66) by sources.redhat.com with SMTP; 25 Jul 2002 16:22:49 -0000 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.11.6/8.11.6) id g6PGMl225078 for binutils@sources.redhat.com; Thu, 25 Jul 2002 18:22:47 +0200 Date: Thu, 25 Jul 2002 09:26:00 -0000 From: Jakub Jelinek To: binutils@sources.redhat.com Subject: [PATCH] Match readelf --debug-dump option with documentation and usage Message-ID: <20020725182247.W20867@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-SW-Source: 2002-07/txt/msg00679.txt.bz2 Hi! The patch to allow more than one option letter to -w broke --debug-dump option as documented in the usage and manual page/info. There it is documented as --debug-dump (for all debug sections) --debug-dump=info (for info only) --debug-dump=str (for debug_str only) etc. while current readelf will handle it completely differently. Here is a patch to fix it, so that -wlia can be used to display .debug_line, .debug_info and .debug_abbrev only while --debug-dump=line,info,abbrev can be used for the same thing. 2002-07-25 Jakub Jelinek * readelf.c (OPTION_DEBUG_DUMP): Define. (options): Use it. (usage): Update help. (parse_args): Handle --debug-dump separately from -w. * doc/binutils.texi (readelf): Update documentation. --- binutils/readelf.c.jj Thu Jul 25 16:07:39 2002 +++ binutils/readelf.c Thu Jul 25 18:22:43 2002 @@ -2251,6 +2251,8 @@ get_section_type_name (sh_type) } } +#define OPTION_DEBUG_DUMP 512 + struct option options [] = { {"all", no_argument, 0, 'a'}, @@ -2270,7 +2272,7 @@ struct option options [] = {"version-info", no_argument, 0, 'V'}, {"use-dynamic", no_argument, 0, 'D'}, {"hex-dump", required_argument, 0, 'x'}, - {"debug-dump", optional_argument, 0, 'w'}, + {"debug-dump", optional_argument, 0, OPTION_DEBUG_DUMP}, {"unwind", no_argument, 0, 'u'}, #ifdef SUPPORT_DISASSEMBLY {"instruction-dump", required_argument, 0, 'i'}, @@ -2305,7 +2307,8 @@ usage () -A --arch-specific Display architecture specific information (if any).\n\ -D --use-dynamic Use the dynamic section info when displaying symbols\n\ -x --hex-dump= Dump the contents of section \n\ - -w --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames,=str,=loc]\n\ + -w[liaprmfFso] or\n\ + --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames,=str,=loc]\n\ Display the contents of DWARF2 debug sections\n")); #ifdef SUPPORT_DISASSEMBLY fprintf (stdout, _("\ @@ -2503,6 +2506,86 @@ parse_args (argc, argv) } } break; + case OPTION_DEBUG_DUMP: + do_dump ++; + if (optarg == 0) + do_debugging = 1; + else + { + const char *debug_dump_opt[] + = { "line", "info", "abbrev", "pubnames", "ranges", + "macro", "frames", "str", "loc", NULL }; + unsigned int index; + const char *p; + + do_debugging = 0; + + p = optarg; + while (*p) + { + for (index = 0; debug_dump_opt[index]; index++) + { + size_t len = strlen (debug_dump_opt[index]); + + if (strncmp (p, debug_dump_opt[index], len) == 0 + && (p[len] == ',' || p[len] == '\0')) + { + switch (p[0]) + { + case 'i': + do_debug_info = 1; + break; + + case 'a': + do_debug_abbrevs = 1; + break; + + case 'l': + if (p[1] == 'i') + do_debug_lines = 1; + else + do_debug_loc = 1; + break; + + case 'p': + do_debug_pubnames = 1; + break; + + case 'r': + do_debug_aranges = 1; + break; + + case 'f': + do_debug_frames = 1; + break; + + case 'm': + do_debug_macinfo = 1; + break; + + case 's': + do_debug_str = 1; + break; + } + + p += len; + break; + } + } + + if (debug_dump_opt[index] == NULL) + { + warn (_("Unrecognized debug option '%s'\n"), p); + p = strchr (p, ','); + if (p == NULL) + break; + } + + if (*p == ',') + p++; + } + } + break; #ifdef SUPPORT_DISASSEMBLY case 'i': do_dump ++; --- binutils/doc/binutils.texi.jj Thu Jul 25 16:07:39 2002 +++ binutils/doc/binutils.texi Thu Jul 25 18:31:09 2002 @@ -2864,7 +2864,7 @@ readelf [@option{-a}|@option{--all}] [@option{-V}|@option{--version-info}] [@option{-D}|@option{--use-dynamic}] [@option{-x} |@option{--hex-dump=}] - [@option{-w[liaprmfs]}|@option{--debug-dump}[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames,=str]] + [@option{-w[liaprmfFso]}|@option{--debug-dump}[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames,=str,=loc]] [@option{-histogram}] [@option{-v}|@option{--version}] [@option{-W}|@option{--wide}] @@ -2966,8 +2966,8 @@ symbols section. @itemx --hex-dump= Displays the contents of the indicated section as a hexadecimal dump. -@item -w[liaprmfs] -@itemx --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames,=str] +@item -w[liaprmfFso] +@itemx --debug-dump[=line,=info,=abbrev,=pubnames,=ranges,=macro,=frames,=str,=loc] Displays the contents of the debug sections in the file, if any are present. If one of the optional letters or words follows the switch then only data found in those specific sections will be dumped. Jakub