addr2line.c (78828) | addr2line.c (89857) |
---|---|
1/* addr2line.c -- convert addresses to line number and function name | 1/* addr2line.c -- convert addresses to line number and function name |
2 Copyright 1997, 1998, 1999, 2000 Free Software Foundation, Inc. | 2 Copyright 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
3 Contributed by Ulrich Lauther <Ulrich.Lauther@mchp.siemens.de> 4 5 This file is part of GNU Binutils. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2, or (at your option) 10 any later version. --- 12 unchanged lines hidden (view full) --- 23 Usage: 24 addr2line [options] addr addr ... 25 or 26 addr2line [options] 27 28 both forms write results to stdout, the second form reads addresses 29 to be converted from stdin. */ 30 | 3 Contributed by Ulrich Lauther <Ulrich.Lauther@mchp.siemens.de> 4 5 This file is part of GNU Binutils. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2, or (at your option) 10 any later version. --- 12 unchanged lines hidden (view full) --- 23 Usage: 24 addr2line [options] addr addr ... 25 or 26 addr2line [options] 27 28 both forms write results to stdout, the second form reads addresses 29 to be converted from stdin. */ 30 |
31#include <ctype.h> | |
32#include <string.h> 33 34#include "bfd.h" 35#include "getopt.h" 36#include "libiberty.h" 37#include "demangle.h" 38#include "bucomm.h" 39 | 31#include <string.h> 32 33#include "bfd.h" 34#include "getopt.h" 35#include "libiberty.h" 36#include "demangle.h" 37#include "bucomm.h" 38 |
40extern char *program_version; 41 | |
42static boolean with_functions; /* -f, show function names. */ 43static boolean do_demangle; /* -C, demangle names. */ 44static boolean base_names; /* -s, strip directory names. */ 45 46static int naddr; /* Number of addresses to process. */ 47static char **addr; /* Hex addresses to process. */ 48 49static asymbol **syms; /* Symbol table. */ --- 18 unchanged lines hidden (view full) --- 68 69/* Print a usage message to STREAM and exit with STATUS. */ 70 71static void 72usage (stream, status) 73 FILE *stream; 74 int status; 75{ | 39static boolean with_functions; /* -f, show function names. */ 40static boolean do_demangle; /* -C, demangle names. */ 41static boolean base_names; /* -s, strip directory names. */ 42 43static int naddr; /* Number of addresses to process. */ 44static char **addr; /* Hex addresses to process. */ 45 46static asymbol **syms; /* Symbol table. */ --- 18 unchanged lines hidden (view full) --- 65 66/* Print a usage message to STREAM and exit with STATUS. */ 67 68static void 69usage (stream, status) 70 FILE *stream; 71 int status; 72{ |
76 fprintf (stream, _("\ 77Usage: %s [-CfsHV] [-b bfdname] [--target=bfdname]\n\ 78 [-e executable] [--exe=executable] [--demangle[=style]]\n\ 79 [--basenames] [--functions] [addr addr ...]\n"), 80 program_name); | 73 fprintf (stream, _("Usage: %s [option(s)] [addr(s)]\n"), program_name); 74 fprintf (stream, _(" Convert addresses into line number/file name pairs.\n")); 75 fprintf (stream, _(" If no addresses are specified on the command line, they will be read from stdin\n")); 76 fprintf (stream, _(" The options are:\n\ 77 -b --target=<bfdname> Set the binary file format\n\ 78 -e --exe=<executable> Set the input file name (default is a.out)\n\ 79 -s --basenames Strip directory names\n\ 80 -f --functions Show function names\n\ 81 -C --demangle[=style] Demangle function names\n\ 82 -h --help Display this information\n\ 83 -v --version Display the program's version\n\ 84\n")); 85 |
81 list_supported_targets (program_name, stream); 82 if (status == 0) 83 fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO); 84 exit (status); 85} 86 87/* Read in the symbol table. */ 88 --- 172 unchanged lines hidden (view full) --- 261 { 262 free (syms); 263 syms = NULL; 264 } 265 266 bfd_close (abfd); 267} 268 | 86 list_supported_targets (program_name, stream); 87 if (status == 0) 88 fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO); 89 exit (status); 90} 91 92/* Read in the symbol table. */ 93 --- 172 unchanged lines hidden (view full) --- 266 { 267 free (syms); 268 syms = NULL; 269 } 270 271 bfd_close (abfd); 272} 273 |
274int main PARAMS ((int, char **)); 275 |
|
269int 270main (argc, argv) 271 int argc; 272 char **argv; 273{ 274 const char *filename; 275 char *target; 276 int c; 277 278#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) 279 setlocale (LC_MESSAGES, ""); 280#endif | 276int 277main (argc, argv) 278 int argc; 279 char **argv; 280{ 281 const char *filename; 282 char *target; 283 int c; 284 285#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) 286 setlocale (LC_MESSAGES, ""); 287#endif |
288#if defined (HAVE_SETLOCALE) 289 setlocale (LC_CTYPE, ""); 290#endif |
|
281 bindtextdomain (PACKAGE, LOCALEDIR); 282 textdomain (PACKAGE); 283 284 program_name = *argv; 285 xmalloc_set_program_name (program_name); 286 287 bfd_init (); 288 set_default_bfd_target (); 289 290 filename = NULL; 291 target = NULL; | 291 bindtextdomain (PACKAGE, LOCALEDIR); 292 textdomain (PACKAGE); 293 294 program_name = *argv; 295 xmalloc_set_program_name (program_name); 296 297 bfd_init (); 298 set_default_bfd_target (); 299 300 filename = NULL; 301 target = NULL; |
292 while ((c = getopt_long (argc, argv, "b:Ce:sfHV", long_options, (int *) 0)) | 302 while ((c = getopt_long (argc, argv, "b:Ce:sfHhVv", long_options, (int *) 0)) |
293 != EOF) 294 { 295 switch (c) 296 { 297 case 0: | 303 != EOF) 304 { 305 switch (c) 306 { 307 case 0: |
298 break; /* we've been given a long option */ | 308 break; /* We've been given a long option. */ |
299 case 'b': 300 target = optarg; 301 break; 302 case 'C': 303 do_demangle = true; 304 if (optarg != NULL) 305 { 306 enum demangling_styles style; --- 10 unchanged lines hidden (view full) --- 317 filename = optarg; 318 break; 319 case 's': 320 base_names = true; 321 break; 322 case 'f': 323 with_functions = true; 324 break; | 309 case 'b': 310 target = optarg; 311 break; 312 case 'C': 313 do_demangle = true; 314 if (optarg != NULL) 315 { 316 enum demangling_styles style; --- 10 unchanged lines hidden (view full) --- 327 filename = optarg; 328 break; 329 case 's': 330 base_names = true; 331 break; 332 case 'f': 333 with_functions = true; 334 break; |
335 case 'v': |
|
325 case 'V': 326 print_version ("addr2line"); 327 break; | 336 case 'V': 337 print_version ("addr2line"); 338 break; |
339 case 'h': |
|
328 case 'H': 329 usage (stdout, 0); 330 break; 331 default: 332 usage (stderr, 1); 333 break; 334 } 335 } 336 337 if (filename == NULL) 338 filename = "a.out"; 339 340 addr = argv + optind; 341 naddr = argc - optind; 342 343 process_file (filename, target); 344 345 return 0; 346} | 340 case 'H': 341 usage (stdout, 0); 342 break; 343 default: 344 usage (stderr, 1); 345 break; 346 } 347 } 348 349 if (filename == NULL) 350 filename = "a.out"; 351 352 addr = argv + optind; 353 naddr = argc - optind; 354 355 process_file (filename, target); 356 357 return 0; 358} |