summaryrefslogtreecommitdiff
path: root/binutils/coffdump.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2002-01-23 16:12:56 +0000
committerNick Clifton <nickc@redhat.com>2002-01-23 16:12:56 +0000
commitd8964b34b8ad04936bb5fa2d012132cbb017fbb6 (patch)
tree479dfc35f75e59998529ad9a60005c6fbbefd95d /binutils/coffdump.c
parent075ecf47c6119966275f1318ffced74da1c9ece6 (diff)
downloadbinutils-redhat-d8964b34b8ad04936bb5fa2d012132cbb017fbb6.tar.gz
Tidy up formatting of --help output.
Diffstat (limited to 'binutils/coffdump.c')
-rw-r--r--binutils/coffdump.c184
1 files changed, 98 insertions, 86 deletions
diff --git a/binutils/coffdump.c b/binutils/coffdump.c
index 598d29d00d..db5034e009 100644
--- a/binutils/coffdump.c
+++ b/binutils/coffdump.c
@@ -1,27 +1,27 @@
/* Coff file dumper.
- Copyright 1994, 1995, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright 1994, 1995, 1998, 1999, 2000, 2001, 2002
+ Free Software Foundation, Inc.
-This file is part of GNU Binutils.
+ This file is part of GNU Binutils.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at
+ your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Steve Chamberlain <sac@cygnus.com>
This module reads a type tree generated by coffgrok and prints
- it out so we can test the grokker.
-*/
+ it out so we can test the grokker. */
#include <bfd.h>
#include <getopt.h>
@@ -44,12 +44,11 @@ static void dump_coff_sfile PARAMS ((struct coff_sfile *));
static void dump_coff_section PARAMS ((struct coff_section *));
extern void coff_dump PARAMS ((struct coff_ofile *));
static void show_usage PARAMS ((FILE *, int));
-static void show_help PARAMS ((void));
extern int main PARAMS ((int, char **));
static void
tab (x)
-int x;
+ int x;
{
static int indent;
int i;
@@ -91,7 +90,8 @@ int x;
}
}
-static void nl ()
+static void
+nl ()
{
atnl = 1;
}
@@ -102,21 +102,25 @@ dump_coff_lines (p)
{
int i;
int online = 0;
- tab(1);
- printf(_("#lines %d "),p->nlines);
+
+ tab (1);
+ printf (_("#lines %d "),p->nlines);
+
for (i = 0; i < p->nlines; i++)
{
- printf("(%d 0x%x)", p->lines[i], p->addresses[i]);
+ printf ("(%d 0x%x)", p->lines[i], p->addresses[i]);
+
online++;
+
if (online > 6)
{
- nl();
- tab(0);
+ nl ();
+ tab (0);
online = 0;
}
}
- nl();
- tab(-1);
+ nl ();
+ tab (-1);
}
static void
@@ -125,13 +129,14 @@ dump_coff_type (p)
{
tab (1);
printf ("size %d ", p->size);
+
switch (p->type)
{
case coff_secdef_type:
printf ("section definition at %x size %x\n",
p->u.asecdef.address,
p->u.asecdef.size);
- nl();
+ nl ();
break;
case coff_pointer_type:
printf ("pointer to");
@@ -325,7 +330,6 @@ dump_coff_visible (p)
tab (-1);
}
-
void
dump_coff_symbol (p)
struct coff_symbol *p;
@@ -333,6 +337,7 @@ dump_coff_symbol (p)
tab (1);
printf ("List of symbols");
nl ();
+
while (p)
{
tab (1);
@@ -363,35 +368,37 @@ static void
dump_coff_scope (p)
struct coff_scope *p;
{
-if (p) {
- tab (1);
- printf ("List of blocks %lx ",(unsigned long) p);
-
- if (p->sec) {
- printf( " %s %x..%x", p->sec->name,p->offset, p->offset + p->size -1);
- }
- nl ();
- tab (0);
- printf ("*****************");
- nl ();
- while (p)
+ if (p)
{
- tab (0);
- printf ("vars %d", p->nvars);
+ tab (1);
+ printf ("List of blocks %lx ",(unsigned long) p);
+
+ if (p->sec)
+ printf( " %s %x..%x", p->sec->name,p->offset, p->offset + p->size -1);
+
nl ();
- dump_coff_symbol (p->vars_head);
- printf ("blocks");
+ tab (0);
+ printf ("*****************");
nl ();
- dump_coff_scope (p->list_head);
+
+ while (p)
+ {
+ tab (0);
+ printf ("vars %d", p->nvars);
+ nl ();
+ dump_coff_symbol (p->vars_head);
+ printf ("blocks");
+ nl ();
+ dump_coff_scope (p->list_head);
+ nl ();
+ p = p->next;
+ }
+
+ tab (0);
+ printf ("*****************");
nl ();
- p = p->next;
+ tab (-1);
}
-
- tab (0);
- printf ("*****************");
- nl ();
- tab (-1);
-}
}
static void
@@ -401,6 +408,7 @@ dump_coff_sfile (p)
tab (1);
printf ("List of source files");
nl ();
+
while (p)
{
tab (0);
@@ -414,25 +422,27 @@ dump_coff_sfile (p)
static void
dump_coff_section(ptr)
-struct coff_section *ptr;
+ struct coff_section *ptr;
{
int i;
- tab(1);
- printf("section %s %d %d address %x size %x number %d nrelocs %d",
- ptr->name, ptr->code, ptr->data, ptr->address,ptr->size, ptr->number, ptr->nrelocs);
- nl();
+
+ tab (1);
+ printf ("section %s %d %d address %x size %x number %d nrelocs %d",
+ ptr->name, ptr->code, ptr->data, ptr->address,ptr->size,
+ ptr->number, ptr->nrelocs);
+ nl ();
for (i = 0; i < ptr->nrelocs; i++)
{
- tab(0);
- printf("(%x %s %x)",
- ptr->relocs[i].offset,
- ptr->relocs[i].symbol->name,
- ptr->relocs[i].addend);
- nl();
+ tab (0);
+ printf ("(%x %s %x)",
+ ptr->relocs[i].offset,
+ ptr->relocs[i].symbol->name,
+ ptr->relocs[i].addend);
+ nl ();
}
- tab(-1);
+ tab (-1);
}
void
@@ -440,17 +450,17 @@ coff_dump (ptr)
struct coff_ofile *ptr;
{
int i;
+
printf ("Coff dump");
nl ();
printf ("#souces %d", ptr->nsources);
nl ();
dump_coff_sfile (ptr->source_head);
+
for (i = 0; i < ptr->nsections; i++)
- dump_coff_section(ptr->sections + i);
+ dump_coff_section (ptr->sections + i);
}
-
-
char * program_name;
static void
@@ -458,18 +468,18 @@ show_usage (file, status)
FILE *file;
int status;
{
- fprintf (file, "Usage: %s [-hV] in-file\n", program_name);
- exit (status);
-}
+ fprintf (file, _("Usage: %s [option(s)] in-file\n"), program_name);
+ fprintf (file, _(" Print a human readable interpretation of a SYSROFF object file\n"));
+ fprintf (file, _(" The options are:\n\
+ -h --help Display this information\n\
+ -v --version Display the program's version\n\
+\n"));
-static void
-show_help ()
-{
- printf (_("%s: Print a human readable interpretation of a SYSROFF object file\n"),
- program_name);
- show_usage (stdout, 0);
-}
+ if (status == 0)
+ fprintf (file, _("Report bugs to %s\n"), REPORT_BUGS_TO);
+ exit (status);
+}
int
main (ac, av)
@@ -500,24 +510,25 @@ main (ac, av)
program_name = av[0];
xmalloc_set_program_name (program_name);
- while ((opt = getopt_long (ac, av, "hV", long_options,
+ while ((opt = getopt_long (ac, av, "HhVv", long_options,
(int *) NULL))
!= EOF)
{
switch (opt)
{
+ case 'H':
case 'h':
- show_help ();
- /*NOTREACHED*/
+ show_usage (stdout, 0);
+ break;
+ case 'v':
case 'V':
print_version ("coffdump");
exit (0);
- /*NOTREACHED*/
case 0:
break;
default:
show_usage (stderr, 1);
- /*NOTREACHED*/
+ break;
}
}
@@ -527,9 +538,8 @@ main (ac, av)
}
if (!input_file)
- {
- fatal (_("no input file specified"));
- }
+ fatal (_("no input file specified"));
+
abfd = bfd_openr (input_file, 0);
if (!abfd)
@@ -538,6 +548,7 @@ main (ac, av)
if (! bfd_check_format_matches (abfd, bfd_object, &matching))
{
bfd_nonfatal (input_file);
+
if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
{
list_matching_formats (matching);
@@ -548,7 +559,8 @@ main (ac, av)
tree = coff_grok (abfd);
- coff_dump(tree);
- printf("\n");
+ coff_dump (tree);
+ printf ("\n");
+
return 0;
}