| 1 |
/* |
| 2 |
Copyright 2010-2018 David Anderson. All rights reserved. |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or |
| 5 |
modify it under the terms of version 2 of the GNU General |
| 6 |
Public License as published by the Free Software Foundation. |
| 7 |
|
| 8 |
This program is distributed in the hope that it would be |
| 9 |
useful, but WITHOUT ANY WARRANTY; without even the implied |
| 10 |
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 11 |
PURPOSE. |
| 12 |
|
| 13 |
Further, this software is distributed without any warranty |
| 14 |
that it is free of the rightful claim of any third person |
| 15 |
regarding infringement or the like. Any license provided |
| 16 |
herein, whether implied or otherwise, applies only to this |
| 17 |
software file. Patent licenses, if any, provided herein |
| 18 |
do not apply to combinations of this program with other |
| 19 |
software, or any other product whatsoever. |
| 20 |
|
| 21 |
You should have received a copy of the GNU General Public |
| 22 |
License along with this program; if not, write the Free |
| 23 |
Software Foundation, Inc., 51 Franklin Street - Fifth Floor, |
| 24 |
Boston MA 02110-1301, USA. |
| 25 |
|
| 26 |
*/ |
| 27 |
|
| 28 |
#include <config.h> |
| 29 |
|
| 30 |
#include <stdlib.h> /* atoi() calloc() exit() free() |
| 31 |
malloc() strtol() */ |
| 32 |
#include <string.h> /* strcmp() strdup() strlen() */ |
| 33 |
#include <stdio.h> /* FILE decl for dd_esb.h */ |
| 34 |
|
| 35 |
/* Windows specific header files */ |
| 36 |
#if defined(_WIN32) && defined(HAVE_STDAFX_H) |
| 37 |
#include "stdafx.h" |
| 38 |
#endif /* HAVE_STDAFX_H */ |
| 39 |
|
| 40 |
#include "dwarf.h" |
| 41 |
#include "libdwarf.h" |
| 42 |
#include "dd_defined_types.h" |
| 43 |
#include "dd_checkutil.h" |
| 44 |
#include "dd_glflags.h" |
| 45 |
#include "dd_globals.h" |
| 46 |
#include "dd_dwconf.h" |
| 47 |
#include "dd_getopt.h" |
| 48 |
#include "dd_common.h" |
| 49 |
#include "dd_makename.h" |
| 50 |
#include "dd_uri.h" |
| 51 |
#include "dd_esb.h" /* For flexible string buffer. */ |
| 52 |
#include "dd_sanitized.h" |
| 53 |
#include "dd_tag_common.h" |
| 54 |
#include "dd_command_options.h" |
| 55 |
#include "dd_compiler_info.h" |
| 56 |
#include "dd_regex.h" |
| 57 |
#include "dd_safe_strcpy.h" |
| 58 |
#include "libdwarf_private.h" /* For malloc/calloc debug */ |
| 59 |
|
| 60 |
static const char *remove_quotes_pair(const char *text); |
| 61 |
static char *special_program_name(char *n); |
| 62 |
static void suppress_check_dwarf(void); |
| 63 |
|
| 64 |
/* These configure items are for the |
| 65 |
frame data. We're flexible in |
| 66 |
the path to dwarfdump.conf . |
| 67 |
The HOME strings here are transformed in |
| 68 |
dwconf.c to reference the environment |
| 69 |
variable $HOME . |
| 70 |
|
| 71 |
As of August 2018 CONFPREFIX is always set as it |
| 72 |
comes from autoconf --prefix, aka $prefix |
| 73 |
which defaults to /usr/local |
| 74 |
|
| 75 |
The install puts the .conf file in |
| 76 |
CONFPREFIX/dwarfdump/ |
| 77 |
*/ |
| 78 |
static char *config_file_defaults[] = { |
| 79 |
"dwarfdump.conf", |
| 80 |
"./dwarfdump.conf", |
| 81 |
"HOME/.dwarfdump.conf", |
| 82 |
"HOME/dwarfdump.conf", |
| 83 |
/* See Makefile.am dwarfdump_CFLAGS. This prefix |
| 84 |
is the --prefix option (defaults to /usr/local |
| 85 |
and Makefile.am adds /share/dwarfdump ) |
| 86 |
We need 2 levels of macro to get the name turned into |
| 87 |
the string we want. */ |
| 88 |
#define STR2(s) # s |
| 89 |
#define STR(s) STR2(s) |
| 90 |
STR(CONFPREFIX) "/dwarfdump.conf", |
| 91 |
"/usr/share/dwarfdump/dwarfdump.conf", |
| 92 |
0 |
| 93 |
}; |
| 94 |
static const char *config_file_abi = 0; |
| 95 |
|
| 96 |
/* Do printing of most sections. |
| 97 |
Do not do detailed checking. |
| 98 |
*/ |
| 99 |
static void |
| 100 |
do_all(void) |
| 101 |
{ |
| 102 |
glflags.gf_frame_flag = TRUE; |
| 103 |
glflags.gf_info_flag = TRUE; |
| 104 |
glflags.gf_types_flag = TRUE; /* .debug_types */ |
| 105 |
glflags.gf_line_flag = TRUE; |
| 106 |
glflags.gf_no_follow_debuglink = FALSE; |
| 107 |
glflags.gf_global_debuglink_paths = 0; |
| 108 |
glflags.gf_global_debuglink_count = 0; |
| 109 |
glflags.gf_pubnames_flag = TRUE; |
| 110 |
glflags.gf_macinfo_flag = TRUE; |
| 111 |
glflags.gf_macro_flag = TRUE; |
| 112 |
glflags.gf_aranges_flag = TRUE; |
| 113 |
/* Do not do |
| 114 |
glflags.gf_loc_flag = TRUE |
| 115 |
glflags.gf_abbrev_flag = TRUE; |
| 116 |
glflags.gf_ranges_flag = TRUE; |
| 117 |
because nothing in |
| 118 |
the DWARF spec guarantees the sections are free of |
| 119 |
random bytes in areas not referenced by .debug_info. |
| 120 |
though for DWARF5 .debug_loclists is free |
| 121 |
of random bytes. See --print_raw_loclists */ |
| 122 |
glflags.gf_string_flag = TRUE; |
| 123 |
/* Do not do |
| 124 |
glflags.gf_reloc_flag = TRUE; |
| 125 |
as print_relocs makes no sense for non-elf dwarfdump users.*/ |
| 126 |
glflags.gf_static_func_flag = TRUE; /* SGI only*/ |
| 127 |
glflags.gf_static_var_flag = TRUE; /* SGI only*/ |
| 128 |
glflags.gf_pubtypes_flag = TRUE; /* both SGI typenames |
| 129 |
and dwarf_pubtypes. */ |
| 130 |
glflags.gf_weakname_flag = TRUE; /* SGI only*/ |
| 131 |
glflags.gf_gnu_debuglink_flag = FALSE; |
| 132 |
glflags.gf_debug_addr_flag = FALSE; |
| 133 |
glflags.gf_debug_names_flag = TRUE; |
| 134 |
glflags.gf_debug_sup_flag = TRUE; |
| 135 |
} |
| 136 |
|
| 137 |
static int |
| 138 |
get_number_value(char *v_in,long int *v_out) |
| 139 |
{ |
| 140 |
long int v= 0; |
| 141 |
size_t lenszt = strlen(v_in); |
| 142 |
char *endptr = 0; |
| 143 |
|
| 144 |
if (lenszt < 1) { |
| 145 |
return DW_DLV_ERROR; |
| 146 |
} |
| 147 |
v = strtol(v_in,&endptr,10); |
| 148 |
if (endptr == v_in) { |
| 149 |
return DW_DLV_NO_ENTRY; |
| 150 |
} |
| 151 |
if (*endptr != '\0') { |
| 152 |
return DW_DLV_ERROR; |
| 153 |
} |
| 154 |
*v_out = v; |
| 155 |
return DW_DLV_OK; |
| 156 |
} |
| 157 |
|
| 158 |
static void suppress_print_dwarf(void) |
| 159 |
{ |
| 160 |
glflags.gf_do_print_dwarf = FALSE; |
| 161 |
glflags.gf_do_check_dwarf = TRUE; |
| 162 |
} |
| 163 |
|
| 164 |
/* Remove matching leading/trailing quotes. |
| 165 |
Does not alter the passed in string. |
| 166 |
If quotes removed does a makename on a modified string. */ |
| 167 |
static const char * |
| 168 |
remove_quotes_pair(const char *text) |
| 169 |
{ |
| 170 |
static char single_quote = '\''; |
| 171 |
static char double_quote = '\"'; |
| 172 |
char quote = 0; |
| 173 |
const char *p = text; |
| 174 |
size_t textlenszt = strlen(text); |
| 175 |
|
| 176 |
if (textlenszt < 2) { |
| 177 |
return p; |
| 178 |
} |
| 179 |
|
| 180 |
/* Compare first character with ' or " */ |
| 181 |
if (p[0] == single_quote) { |
| 182 |
quote = single_quote; |
| 183 |
} else { |
| 184 |
if (p[0] == double_quote) { |
| 185 |
quote = double_quote; |
| 186 |
} |
| 187 |
else { |
| 188 |
return p; |
| 189 |
} |
| 190 |
} |
| 191 |
{ |
| 192 |
if (p[textlenszt - 1] == quote) { |
| 193 |
char *altered = calloc(1,textlenszt+1); |
| 194 |
const char *str2 = 0; |
| 195 |
|
| 196 |
/* Here we delete the leading and trailing quote chars. |
| 197 |
Start at p-1. String is to be orig textlenszt - 2 |
| 198 |
bytes long */ |
| 199 |
dd_safe_strcpy(altered,textlenszt+1,p+1,textlenszt-2); |
| 200 |
str2 = makename(altered); |
| 201 |
free(altered); |
| 202 |
return str2; |
| 203 |
} |
| 204 |
} |
| 205 |
return p; |
| 206 |
} |
| 207 |
|
| 208 |
/* By trimming a /dwarfdump.O |
| 209 |
down to /dwarfdump (keeping any prefix |
| 210 |
or suffix) |
| 211 |
we can avoid a sed command in |
| 212 |
regressiontests/DWARFTEST.sh |
| 213 |
and save 12 minutes run time of a regression |
| 214 |
test. |
| 215 |
|
| 216 |
The effect is, when nothing has changed in the |
| 217 |
normal output, that the program_name matches too. |
| 218 |
Because we don't want a different name of dwarfdump |
| 219 |
to cause a mismatch. */ |
| 220 |
static char * |
| 221 |
special_program_name(char *n) |
| 222 |
{ |
| 223 |
char * mp = "/dwarfdump.O"; |
| 224 |
char * revstr = "/dwarfdump"; |
| 225 |
char *cp = n; |
| 226 |
size_t mslenszt = strlen(mp); |
| 227 |
|
| 228 |
for ( ; *cp; ++cp) { |
| 229 |
if (*cp == *mp) { |
| 230 |
if (!strncmp(cp,mp,mslenszt)){ |
| 231 |
esb_append(glflags.newprogname,revstr); |
| 232 |
cp += mslenszt-1; |
| 233 |
} else { |
| 234 |
esb_appendn(glflags.newprogname,cp,1); |
| 235 |
} |
| 236 |
} else { |
| 237 |
esb_appendn(glflags.newprogname,cp,1); |
| 238 |
} |
| 239 |
} |
| 240 |
return esb_get_string(glflags.newprogname); |
| 241 |
} |
| 242 |
|
| 243 |
static void suppress_check_dwarf(void) |
| 244 |
{ |
| 245 |
glflags.gf_do_print_dwarf = TRUE; |
| 246 |
if (glflags.gf_do_check_dwarf) { |
| 247 |
printf("Warning: check flag turned off, " |
| 248 |
"checking and printing are separate.\n"); |
| 249 |
} |
| 250 |
glflags.gf_do_check_dwarf = FALSE; |
| 251 |
set_checks_off(); |
| 252 |
} |
| 253 |
|
| 254 |
static struct esb_s uri_esb_data; |
| 255 |
void |
| 256 |
uri_data_constructor(void) |
| 257 |
{ |
| 258 |
esb_constructor(&uri_esb_data); |
| 259 |
} |
| 260 |
void |
| 261 |
uri_data_destructor(void) |
| 262 |
{ |
| 263 |
esb_destructor(&uri_esb_data); |
| 264 |
} |
| 265 |
/* The strings whose pointers are returned here |
| 266 |
from makename are destructed at dwarf_finish. |
| 267 |
makename() never returns NULL, so |
| 268 |
do_uri_translation() never does so either. |
| 269 |
|
| 270 |
If the user were to type dangerous (for the |
| 271 |
terminal session) characters this prints them |
| 272 |
out as such! So don't put such in the |
| 273 |
dwarfdump command line. |
| 274 |
*/ |
| 275 |
const char * |
| 276 |
do_uri_translation(const char *s,const char *context) |
| 277 |
{ |
| 278 |
struct esb_s str; |
| 279 |
char *finalstr = 0; |
| 280 |
if (!glflags.gf_uri_options_translation) { |
| 281 |
return makename(s); |
| 282 |
} |
| 283 |
esb_constructor(&str); |
| 284 |
translate_from_uri(s,&str); |
| 285 |
if (glflags.gf_do_print_uri_in_input) { |
| 286 |
if (strcmp(s,esb_get_string(&str))) { |
| 287 |
printf("Uri Translation on option %s\n",context); |
| 288 |
printf(" \'%s\'\n",s); |
| 289 |
printf(" \'%s\'\n",esb_get_string(&str)); |
| 290 |
} |
| 291 |
} |
| 292 |
finalstr = makename(esb_get_string(&str)); |
| 293 |
esb_destructor(&str); |
| 294 |
return finalstr; |
| 295 |
} |
| 296 |
|
| 297 |
/* Support for short (-option) and long (--option) names options. |
| 298 |
These functions implement the individual options. |
| 299 |
They are called from |
| 300 |
short names and long names options. |
| 301 |
Implementation code is shared for |
| 302 |
both types of formats. */ |
| 303 |
|
| 304 |
/* Handlers for the short/long names options. */ |
| 305 |
static void arg_check_abbrev(void); |
| 306 |
static void arg_check_all(void); |
| 307 |
static void arg_check_aranges(void); |
| 308 |
static void arg_check_attr_dup(void); |
| 309 |
static void arg_check_attr_encodings(void); |
| 310 |
static void arg_check_attr_names(void); |
| 311 |
static void arg_check_constants(void); |
| 312 |
static void arg_check_files_lines(void); |
| 313 |
static void arg_check_forward_refs(void); |
| 314 |
static void arg_check_frame_basic(void); |
| 315 |
static void arg_check_frame_extended(void); |
| 316 |
static void arg_check_frame_info(void); |
| 317 |
static void arg_check_gaps(void); |
| 318 |
static void arg_check_loc(void); |
| 319 |
static void arg_check_macros(void); |
| 320 |
static void arg_check_pubnames(void); |
| 321 |
static void arg_check_ranges(void); |
| 322 |
static void arg_check_self_refs(void); |
| 323 |
static void arg_check_show(void); |
| 324 |
static void arg_check_silent(void); |
| 325 |
static void arg_check_summary(void); |
| 326 |
static void arg_suppress_debuglink_crc(void); |
| 327 |
static void arg_check_tag_attr(void); |
| 328 |
static void arg_check_tag_tag(void); |
| 329 |
static void arg_check_type(void); |
| 330 |
static void arg_check_unique(void); |
| 331 |
|
| 332 |
static void arg_check_usage(void); |
| 333 |
static void arg_check_usage_extended(void); |
| 334 |
static void arg_check_functions(void); |
| 335 |
|
| 336 |
static void arg_file_abi(void); |
| 337 |
static void arg_file_line5(void); |
| 338 |
static void arg_file_name(void); |
| 339 |
static void arg_file_output(void); |
| 340 |
static void arg_file_tied(void); |
| 341 |
static void arg_file_use_no_libelf(void); |
| 342 |
|
| 343 |
static void arg_format_attr_name(void); |
| 344 |
static void arg_format_dense(void); |
| 345 |
static void arg_format_ellipsis(void); |
| 346 |
static void arg_format_expr_ops_joined(void); |
| 347 |
static void arg_format_extensions(void); |
| 348 |
static void arg_format_global_offsets(void); |
| 349 |
static void arg_format_loc(void); |
| 350 |
static void arg_format_registers(void); |
| 351 |
static void arg_format_suppress_data(void); |
| 352 |
static void arg_format_suppress_group(void); |
| 353 |
static void arg_format_suppress_lookup(void); |
| 354 |
static void arg_format_suppress_offsets(void); |
| 355 |
static void arg_format_suppress_sanitize(void); |
| 356 |
static void arg_format_suppress_uri(void); |
| 357 |
static void arg_format_suppress_uri_msg(void); |
| 358 |
static void arg_format_suppress_utf8(void); |
| 359 |
|
| 360 |
static void arg_format_file(void); |
| 361 |
static void arg_format_gcc(void); |
| 362 |
static void arg_format_groupnumber(void); |
| 363 |
static void arg_format_universalnumber(void); |
| 364 |
static void arg_format_limit(void); |
| 365 |
static void arg_format_producer(void); |
| 366 |
static void arg_format_snc(void); |
| 367 |
|
| 368 |
static void arg_print_all(void); |
| 369 |
static void arg_print_abbrev(void); |
| 370 |
static void arg_print_aranges(void); |
| 371 |
static void arg_print_debug_frame(void); |
| 372 |
static void arg_print_debug_addr(void); |
| 373 |
static void arg_print_debug_names(void); |
| 374 |
static void arg_print_gnu_debuglink(void); |
| 375 |
static void arg_print_debug_gnu(void); |
| 376 |
static void arg_print_debug_sup(void); |
| 377 |
static void arg_print_fission(void); |
| 378 |
static void arg_print_gnu_frame(void); |
| 379 |
static void arg_print_info(void); |
| 380 |
static void arg_print_lines(void); |
| 381 |
static void arg_print_lines_short(void); |
| 382 |
static void arg_print_loc(void); |
| 383 |
static void arg_print_macinfo(void); |
| 384 |
static void arg_print_machine_arch(void); |
| 385 |
static void arg_print_pubnames(void); |
| 386 |
static void arg_print_producers(void); |
| 387 |
static void arg_print_ranges(void); |
| 388 |
static void arg_print_raw_loclists(void); |
| 389 |
static void arg_print_raw_rnglists(void); |
| 390 |
static void arg_print_static(void); |
| 391 |
static void arg_print_static_func(void); |
| 392 |
static void arg_print_static_var(void); |
| 393 |
static void arg_print_str_offsets(void); |
| 394 |
static void arg_print_strings(void); |
| 395 |
static void arg_print_types(void); |
| 396 |
static void arg_print_weaknames(void); |
| 397 |
|
| 398 |
static void arg_no_follow_debuglink(void); |
| 399 |
static void arg_add_debuglink_path(void); |
| 400 |
static void arg_debuglink_path_invalid(void); |
| 401 |
|
| 402 |
static void arg_search_any(void); |
| 403 |
static void arg_search_any_count(void); |
| 404 |
static void arg_search_match(void); |
| 405 |
static void arg_search_match_count(void); |
| 406 |
static void arg_search_regex(void); |
| 407 |
static void arg_search_regex_count(void); |
| 408 |
static void arg_search_count(void); |
| 409 |
static void arg_search_invalid(void); |
| 410 |
|
| 411 |
static void arg_search_print_children(void); |
| 412 |
static void arg_search_print_parent(void); |
| 413 |
static void arg_search_print_tree(void); |
| 414 |
|
| 415 |
static void arg_help(void); |
| 416 |
static void arg_trace(void); |
| 417 |
static void arg_verbose(void); |
| 418 |
static void arg_version(void); |
| 419 |
static void arg_show_dwarfdump_conf(void); |
| 420 |
static void arg_show_args(void); |
| 421 |
|
| 422 |
static void arg_c_multiple_selection(void); |
| 423 |
static void arg_h_multiple_selection(void); |
| 424 |
static void arg_l_multiple_selection(void); |
| 425 |
static void arg_k_multiple_selection(void); |
| 426 |
static void arg_kx_multiple_selection(void); |
| 427 |
static void arg_ku_multiple_selection(void); |
| 428 |
static void arg_O_multiple_selection(void); |
| 429 |
static void arg_S_multiple_selection(void); |
| 430 |
static void arg_t_multiple_selection(void); |
| 431 |
static void arg_W_multiple_selection(void); |
| 432 |
static void arg_x_multiple_selection(void); |
| 433 |
|
| 434 |
static void arg_not_supported(void); |
| 435 |
static void arg_x_invalid(void); |
| 436 |
|
| 437 |
/* Extracted from 'process_args', |
| 438 |
as they are used by option handlers. */ |
| 439 |
static Dwarf_Bool arg_usage_error = FALSE; |
| 440 |
static int arg_option = 0; |
| 441 |
|
| 442 |
static const char *usage_debug_text[] = { |
| 443 |
"Usage: DwarfDump <debug_options>", |
| 444 |
" These only useful with related checking options (-ka suffices)", |
| 445 |
" --trace=0 print this message and stop ", |
| 446 |
" --trace=1 Dump RangesInfo Table requires", |
| 447 |
" add -kl(--check-loc) and -km (--check-ranges)", |
| 448 |
" --trace=2 Dump Linkonce Table (linkonce section)", |
| 449 |
" add -kl(--check-lo) and -km (--check-ranges)", |
| 450 |
" --trace=3 Dump Visited Info, add -kS (--check-self-refs)", |
| 451 |
"" |
| 452 |
}; |
| 453 |
|
| 454 |
static const char *usage_long_text[] = { |
| 455 |
"Usage: DwarfDump <options> <object file>", |
| 456 |
" ", |
| 457 |
"-------------------------------------------------------------------", |
| 458 |
"Print Debug Sections", |
| 459 |
"-------------------------------------------------------------------", |
| 460 |
"-b --print-abbrev Print abbrev section", |
| 461 |
"-a --print-all Print all debug_* sections", |
| 462 |
"-r --print-aranges Print aranges section", |
| 463 |
"-F --print-eh-frame Print gnu .eh_frame section", |
| 464 |
"-f --print-frame Print .debug_frame section", |
| 465 |
"-I --print-fission Print fission sections:", |
| 466 |
" .gdb_index, .debug_cu_index,", |
| 467 |
" .debug_tu_index, .gnu.debuglink,", |
| 468 |
" .note.gnu.build-id", |
| 469 |
" --print-gnu-debuglink Print .gnu_debuglink,", |
| 470 |
" .note.gnu.build-id sections", |
| 471 |
" --print-debug-addr Print .debug_addr section. (If DWARF4", |
| 472 |
" add option -i to make this work)", |
| 473 |
" --print-debug-gnu Print .debug_gnu_pubtypes and", |
| 474 |
" .debug_gnu_pubnames sections", |
| 475 |
" --print-debug-names Print .debug_names section", |
| 476 |
" --print-debug-sup Print .debug_sup section", |
| 477 |
"-i --print-info Print info section", |
| 478 |
"-l --print-lines Print line section", |
| 479 |
"-ls --print-lines-short Print line section, but do not", |
| 480 |
" print <pc> address", |
| 481 |
"-c --print-loc Does nothing, was never very useful", |
| 482 |
"-m --print-macinfo Print DWARF5 style .debug_macro section", |
| 483 |
" and DWARF2,3,4 .debug_macinfo section.", |
| 484 |
" --print-machine-arch Print selected items about objects", |
| 485 |
" and sections", |
| 486 |
"-P --print-producers Print list of compile units per producer", |
| 487 |
"-p --print-pubnames Print pubnames section", |
| 488 |
"-N --print-ranges Print ranges section", |
| 489 |
" --print-raw-rnglists Print entire .debug_rnglists section", |
| 490 |
" --print-raw-loclists Print entire .debug_loclists section", |
| 491 |
"-ta --print-static Print both static sections", |
| 492 |
"-tf --print-static-func Print static func section", |
| 493 |
"-tv --print-static-var Print static var section", |
| 494 |
"-s --print-strings Print raw .debug_str section", |
| 495 |
" --print-str-offsets Print raw .debug_str_offsets section", |
| 496 |
"-y --print-type Print pubtypes section", |
| 497 |
"-w --print-weakname Print weakname section", |
| 498 |
" ", |
| 499 |
"-------------------------------------------------------------------", |
| 500 |
"Print Elf Relocation Data", |
| 501 |
"-------------------------------------------------------------------", |
| 502 |
" libelf not present, use GNU readelf or readelfobj", |
| 503 |
" to see relocations", |
| 504 |
" ", |
| 505 |
"-------------------------------------------------------------------", |
| 506 |
"Print Elf Section Headers", |
| 507 |
"-------------------------------------------------------------------", |
| 508 |
" libelf not present, use GNU readelf or readelfobj", |
| 509 |
" to see elf file details", |
| 510 |
" ", |
| 511 |
"-------------------------------------------------------------------", |
| 512 |
"Check DWARF Integrity", |
| 513 |
"-------------------------------------------------------------------", |
| 514 |
"-kb --check-abbrev Check abbreviations", |
| 515 |
"-ka --check-all Do all checks", |
| 516 |
"-kM --check-aranges Check ranges list (.debug_aranges)", |
| 517 |
"-kD --check-attr-dup Check duplicated attributes", |
| 518 |
"-kE --check-attr-encodings Notice attribute/class/form encodings", |
| 519 |
" and print a report on them", |
| 520 |
"-kn --check-attr-names Examine names in attributes", |
| 521 |
" and report when names contain dot (.)", |
| 522 |
" to find possible naming oddities", |
| 523 |
"-kc --check-constants Examine DWARF constants", |
| 524 |
"-kF --check-files-lines Examine integrity of files-lines", |
| 525 |
" attributes", |
| 526 |
"-kR --check-forward-refs Check forward references to DIEs", |
| 527 |
" (declarations)", |
| 528 |
"-kx --check-frame-basic Basic frames check (.eh_frame,", |
| 529 |
" .debug_frame)", |
| 530 |
"-kxe --check-frame-extended Extensive frames check (.eh_frame,", |
| 531 |
" .debug_frame)", |
| 532 |
"-kf --check-frame-info Examine frame information (use with", |
| 533 |
" -f or -F)", |
| 534 |
"-kg --check-gaps Check debug info gaps", |
| 535 |
"-kl --check-loc Check location list (.debug_loc)", |
| 536 |
"-kw --check-macros Check macros", |
| 537 |
"-ke --check-pubnames Examine attributes of pubnames", |
| 538 |
"-km --check-ranges Check ranges list (.debug_ranges)", |
| 539 |
"-kS --check-self-refs Check self references to DIEs", |
| 540 |
"-kd --check-show Show check results", |
| 541 |
"-ks --check-silent Perform checks in silent mode", |
| 542 |
"-ki --check-summary Display summary for all compilers", |
| 543 |
"-kr --check-tag-attr Examine tag-attr relation, see -kt", |
| 544 |
" Does not print a summary, see -ku", |
| 545 |
"-kt --check-tag-tag Examine tag-tag relations", |
| 546 |
" Unless -C (--format-extensions)", |
| 547 |
" option given certain common", |
| 548 |
" tag-attr and tag-tag extensions are", |
| 549 |
" assumed to be ok (not reported).", |
| 550 |
" Does not print a summary, see -ku", |
| 551 |
"-ky --check-type Examine type info", |
| 552 |
"-kG --check-unique Print only unique errors", |
| 553 |
"-ku --check-usage Print tag-tag, tag-attr, and", |
| 554 |
" attr-form usage summaries", |
| 555 |
"-kuf --check-usage-extended The same as -ku.", |
| 556 |
" --check-functions Adds calls of libdwarf functions not ", |
| 557 |
" otherwise called (for code coverage).", |
| 558 |
" ", |
| 559 |
"-------------------------------------------------------------------", |
| 560 |
"Print Output Qualifiers", |
| 561 |
"-------------------------------------------------------------------", |
| 562 |
"-M --format-attr-name Print the form name for each", |
| 563 |
" attribute", |
| 564 |
"-d --format-dense One line per entry (info section)", |
| 565 |
"-e --format-ellipsis Short names for tags, attrs etc.", |
| 566 |
"-G --format-global-offsets Show global die offsets", |
| 567 |
"-g --format-loc (Was loclist support. Do not use.)", |
| 568 |
" --format-expr-ops-joined Print each group of DWARF DW_OPs", |
| 569 |
" on one line rather than one", |
| 570 |
" per line.", |
| 571 |
"-R --format-registers Print frame register names as", |
| 572 |
" r33 etc and allow up to 1200", |
| 573 |
" registers using a generic", |
| 574 |
" register set.", |
| 575 |
"-Q --format-suppress-data Suppress printing section data", |
| 576 |
"-x noprintsectiongroups", |
| 577 |
" --format-suppress-group Do not print section groups", |
| 578 |
"-n --format-suppress-lookup Suppress frame information function", |
| 579 |
" name lookup(when printing frame", |
| 580 |
" information from multi-gigabyte", |
| 581 |
" object files this", |
| 582 |
" option may save significant time).", |
| 583 |
"-D --format-suppress-offsets Do not show offsets", |
| 584 |
"-x nosanitizestrings", |
| 585 |
" --format-suppress-sanitize Arbitrary string characters", |
| 586 |
" come thru printf. Can be dangerous", |
| 587 |
" to your terminal window.", |
| 588 |
"-U --format-suppress-uri Suppress uri-translate ", |
| 589 |
" meaning do not translate %xx", |
| 590 |
" into the byte it represents in uri", |
| 591 |
"-q --format-suppress-uri-msg Suppress uri-did-translate", |
| 592 |
" notification: by default prints a", |
| 593 |
" note about each detected uri", |
| 594 |
" translation.", |
| 595 |
" --format-suppress-utf8 Suppress printing of utf8 as utf8 by", |
| 596 |
" always using uri-style printing", |
| 597 |
"-C --format-extensions Print (with -ki) warnings", |
| 598 |
" for some common DWARF extensions", |
| 599 |
" (by default extensions accepted", |
| 600 |
" as standard).", |
| 601 |
" ", |
| 602 |
"-------------------------------------------------------------------", |
| 603 |
"Print Output Limiters", |
| 604 |
"-------------------------------------------------------------------", |
| 605 |
"-u<file> --format-file=<file> Print only specified file (CU name)", |
| 606 |
"-x groupnumber=<n> ", |
| 607 |
" --format-group-number=<n> Groupnumber to print", |
| 608 |
"-x universalnumber=<n> ", |
| 609 |
" --format-universalnumber=<n> Binary to print.", |
| 610 |
" Only applies to", |
| 611 |
" Mach-O universal binaries.", |
| 612 |
"-H<num> --format-limit=<num> Limit output to the first <num>", |
| 613 |
" major units.", |
| 614 |
" Stop after <num> compilation units", |
| 615 |
"-c<str> --format-producer=<str> Check only specific compiler", |
| 616 |
" objects <str> is described by", |
| 617 |
" 'DW_AT_producer' -c'350.1' ", |
| 618 |
" check only compiler objects", |
| 619 |
" with 350.1 in the CU name", |
| 620 |
"-cs --format-snc Check only SNC compiler objects", |
| 621 |
"-cg --format-gcc Check only gcc compiler objects", |
| 622 |
" ", |
| 623 |
"-------------------------------------------------------------------", |
| 624 |
"File Specifications", |
| 625 |
"-------------------------------------------------------------------", |
| 626 |
"-x abi=<abi> --file-abi=<abi> Name abi in dwarfdump.conf", |
| 627 |
"-x name=<path> --file-name=<path> Name dwarfdump.conf", |
| 628 |
"-x line5=<val> --file-line5=<val> Table DWARF5 new interfaces", |
| 629 |
" where <val> is: std or s2l", |
| 630 |
"-O file=<path> --file-output=<path> Name the output file", |
| 631 |
"-x tied=<path> --file-tied=<path> Name the Split Dwarf", |
| 632 |
" skeleton object file", |
| 633 |
" --file-use-no-libelf Use non-libelf to", |
| 634 |
" read objects", |
| 635 |
" (as much as possible)", |
| 636 |
" ", |
| 637 |
"-------------------------------------------------------------------", |
| 638 |
"GNU debuglink options", |
| 639 |
"-------------------------------------------------------------------", |
| 640 |
" --no-follow-debuglink Do not follow GNU debuglink, ", |
| 641 |
" just use the file directly so,", |
| 642 |
" debuglink global paths ", |
| 643 |
" and debugid links are ignored.", |
| 644 |
" --add-debuglink_path=<text> Add the path to the list of", |
| 645 |
" global paths debuglink searches", |
| 646 |
" --suppress-debuglink-crc Tell libdwarf to avoid calculating", |
| 647 |
" crc values, saving some runtime at", |
| 648 |
" startup and removing a ", |
| 649 |
" safety check but allowing debuglink", |
| 650 |
" and debugid paths to be used.", |
| 651 |
"-------------------------------------------------------------------", |
| 652 |
"Search text in attributes", |
| 653 |
"-------------------------------------------------------------------", |
| 654 |
"-S any=<text> --search-any=<text> Search any <text>", |
| 655 |
"-Svany=<text> --search-any-count=<text> print number of", |
| 656 |
" occurrences", |
| 657 |
"-S match=<text> --search-match=<text> Search matching <text>", |
| 658 |
"-Svmatch=<text> --search-match-count<text> print number of", |
| 659 |
" occurrences", |
| 660 |
"-S regex=<text> --search-regex=<text> Use Posix Basic regular", |
| 661 |
" expression matching", |
| 662 |
"-Svregex=<text> --search-regex-count<text> print number of", |
| 663 |
" occurrences", |
| 664 |
" only one -S option allowed, any= and", |
| 665 |
" regex= only usable if the functions", |
| 666 |
" required are found at configure time", |
| 667 |
" ", |
| 668 |
"-Wc --search-print-children Print children tree", |
| 669 |
" (wide format) with -S", |
| 670 |
"-Wp --search-print-parent Print parent tree ", |
| 671 |
" (wide format) with -S", |
| 672 |
"-W --search-print-tree Print parent/children tree ", |
| 673 |
" (wide format) with -S", |
| 674 |
" ", |
| 675 |
"-------------------------------------------------------------------", |
| 676 |
"Help & Version", |
| 677 |
"-------------------------------------------------------------------", |
| 678 |
"-h --help Print this dwarfdump help message.", |
| 679 |
"-v --verbose Show more information.", |
| 680 |
"-vv --verbose-more Show even more information.", |
| 681 |
"-V --version Print version information.", |
| 682 |
" --show-dwarfdump-conf Show what dwarfdump.conf is being used", |
| 683 |
" --show-args Show the current date, time, library version,", |
| 684 |
" dwarfdump version, and command arguments", |
| 685 |
" --suppress-de-alloc-tree Turns off the libdwarf-cleanup of", |
| 686 |
" libdwarf-allocated memory on calling", |
| 687 |
" dwarf_finish(). Used to test that", |
| 688 |
" dwarfdump does dealloc everywhere", |
| 689 |
" it should for minimum memory use.", |
| 690 |
"", |
| 691 |
}; |
| 692 |
|
| 693 |
enum longopts_vals { |
| 694 |
OPT_BEGIN = 999, |
| 695 |
|
| 696 |
/* Check DWARF Integrity */ |
| 697 |
OPT_CHECK_ABBREV, /* -kb --check-abbrev */ |
| 698 |
OPT_CHECK_ALL, /* -ka --check-all */ |
| 699 |
OPT_CHECK_ARANGES, /* -kM --check-aranges */ |
| 700 |
OPT_CHECK_ATTR_DUP, /* -kD --check-attr-dup */ |
| 701 |
OPT_CHECK_ATTR_ENCODINGS, /* -kE --check-attr-encodings*/ |
| 702 |
OPT_CHECK_ATTR_NAMES, /* -kn --check-attr-names */ |
| 703 |
OPT_CHECK_CONSTANTS, /* -kc --check-constants */ |
| 704 |
OPT_CHECK_FILES_LINES, /* -kF --check-files-lines */ |
| 705 |
OPT_CHECK_FORWARD_REFS, /* -kR --check-forward-refs */ |
| 706 |
OPT_CHECK_FRAME_BASIC, /* -kx --check-frame-basic */ |
| 707 |
OPT_CHECK_FRAME_EXTENDED, /* -kxe --check-frame-extended*/ |
| 708 |
OPT_CHECK_FRAME_INFO, /* -kf --check-frame-info */ |
| 709 |
OPT_CHECK_GAPS, /* -kg --check-gaps */ |
| 710 |
OPT_CHECK_LOC, /* -kl --check-loc */ |
| 711 |
OPT_CHECK_MACROS, /* -kw --check-macros */ |
| 712 |
OPT_CHECK_PUBNAMES, /* -ke --check-pubnames */ |
| 713 |
OPT_CHECK_RANGES, /* -km --check-ranges */ |
| 714 |
OPT_CHECK_SELF_REFS, /* -kS --check-self-refs */ |
| 715 |
OPT_CHECK_SHOW, /* -kd --check-show */ |
| 716 |
OPT_CHECK_SILENT, /* -ks --check-silent */ |
| 717 |
OPT_CHECK_SUMMARY, /* -ki --check-summary */ |
| 718 |
OPT_CHECK_TAG_ATTR, /* -kr --check-tag-attr */ |
| 719 |
OPT_CHECK_TAG_TAG, /* -kt --check-tag-tag */ |
| 720 |
OPT_CHECK_TYPE, /* -ky --check-type */ |
| 721 |
OPT_CHECK_UNIQUE, /* -kG --check-unique */ |
| 722 |
OPT_CHECK_USAGE, /* -ku --check-usage */ |
| 723 |
OPT_CHECK_USAGE_EXTENDED, /* -kuf --check-usage-extended*/ |
| 724 |
OPT_CHECK_FUNCTIONS, /* --check-functions*/ |
| 725 |
|
| 726 |
/* File Specifications */ |
| 727 |
OPT_FILE_ABI, /* -x abi=<abi> --file-abi=<abi> */ |
| 728 |
OPT_FILE_LINE5, /* -x line5=<val> --file-line5=<val> */ |
| 729 |
OPT_FILE_NAME, /* -x name=<path> --file-name=<path> */ |
| 730 |
OPT_FILE_OUTPUT, /* -O file=<path> --file-output=<path> */ |
| 731 |
OPT_FILE_TIED, /* -x tied=<path> --file-tied=<path> */ |
| 732 |
OPT_FILE_USE_NO_LIBELF,/* --file-use-no-libelf=<path> */ |
| 733 |
|
| 734 |
/* Print Output Qualifiers */ |
| 735 |
OPT_FORMAT_ATTR_NAME, /* -M --format-attr-name */ |
| 736 |
OPT_FORMAT_DENSE, /* -d --format-dense */ |
| 737 |
OPT_FORMAT_ELLIPSIS, /* -e --format-ellipsis */ |
| 738 |
OPT_FORMAT_EXPR_OPS_JOINED, /* --format-expr-ops-joined */ |
| 739 |
OPT_FORMAT_EXTENSIONS, /* -C --format-extensions */ |
| 740 |
OPT_FORMAT_GLOBAL_OFFSETS, /* -G --format-global-offsets */ |
| 741 |
OPT_FORMAT_LOC, /* -g --format-loc */ |
| 742 |
OPT_FORMAT_REGISTERS, /* -R --format-registers */ |
| 743 |
OPT_FORMAT_SUPPRESS_DATA, /* -Q --format-suppress-data */ |
| 744 |
OPT_FORMAT_SUPPRESS_GROUP , /* -x --format-suppress-group */ |
| 745 |
OPT_FORMAT_SUPPRESS_LOOKUP, /* -n --format-suppress-lookup */ |
| 746 |
OPT_FORMAT_SUPPRESS_OFFSETS, /* -D --format-suppress-offsets */ |
| 747 |
OPT_FORMAT_SUPPRESS_SANITIZE, |
| 748 |
/* -x no-sanitize-strings --format-suppress-sanitize */ |
| 749 |
OPT_FORMAT_SUPPRESS_URI, /* -U --format-suppress-uri */ |
| 750 |
OPT_FORMAT_SUPPRESS_URI_MSG, /* -q --format-suppress-uri-msg */ |
| 751 |
|
| 752 |
OPT_FORMAT_SUPPRESS_UTF8, /* --format-suppress-utf8 */ |
| 753 |
OPT_FORMAT_UNIVERSALNUMBER, /* --format-universalnumber */ |
| 754 |
|
| 755 |
/* Print Output Limiters */ |
| 756 |
OPT_FORMAT_FILE, /* -u<file> --format-file=<file> */ |
| 757 |
OPT_FORMAT_GCC, /* -cg --format-gcc */ |
| 758 |
OPT_FORMAT_GROUP_NUMBER, /* -x<n> --format-group-number=<n>*/ |
| 759 |
|
| 760 |
/* -x<n> --format-universalnumber=<n>*/ |
| 761 |
OPT_FORMAT_GROUP_UNIVERSALNUMBER, |
| 762 |
|
| 763 |
OPT_FORMAT_LIMIT, /* -H<num> --format-limit=<num> */ |
| 764 |
OPT_FORMAT_PRODUCER, /* -c<str> --format-producer=<str> */ |
| 765 |
OPT_FORMAT_SNC, /* -cs --format-snc */ |
| 766 |
|
| 767 |
/* Print Debug Sections */ |
| 768 |
OPT_PRINT_ABBREV, /* -b --print-abbrev */ |
| 769 |
OPT_PRINT_ALL, /* -a --print-all */ |
| 770 |
OPT_PRINT_ARANGES, /* -r --print-aranges */ |
| 771 |
OPT_PRINT_DEBUG_NAMES, /* --print-debug-names */ |
| 772 |
OPT_PRINT_DEBUG_ADDR, /* --print-debug-addr */ |
| 773 |
OPT_PRINT_GNU_DEBUGLINK, /* --print-gnu-debuglink */ |
| 774 |
OPT_PRINT_DEBUG_GNU, /* --print-debug-gnu */ |
| 775 |
OPT_PRINT_DEBUG_SUP, /* --print-debug-sup */ |
| 776 |
OPT_PRINT_EH_FRAME, /* -F --print-eh-frame */ |
| 777 |
OPT_PRINT_FISSION, /* -I --print-fission */ |
| 778 |
OPT_PRINT_FRAME, /* -f --print-frame */ |
| 779 |
OPT_PRINT_INFO, /* -i --print-info */ |
| 780 |
OPT_PRINT_LINES, /* -l --print-lines */ |
| 781 |
OPT_PRINT_LINES_SHORT, /* -ls --print-lines-short */ |
| 782 |
OPT_PRINT_LOC, /* -c --print-loc */ |
| 783 |
OPT_PRINT_MACINFO, /* -m --print-macinfo */ |
| 784 |
OPT_PRINT_MACHINE_ARCH, /* --print-machine-arch */ |
| 785 |
OPT_PRINT_PRODUCERS, /* -P --print-producers */ |
| 786 |
OPT_PRINT_PUBNAMES, /* -p --print-pubnames */ |
| 787 |
OPT_PRINT_RANGES, /* -N --print-ranges */ |
| 788 |
OPT_PRINT_RAW_LOCLISTS, /* --print-raw-loclists */ |
| 789 |
OPT_PRINT_RAW_RNGLISTS, /* --print-raw-rnglists */ |
| 790 |
OPT_PRINT_STATIC, /* -ta --print-static */ |
| 791 |
OPT_PRINT_STATIC_FUNC, /* -tf --print-static-func */ |
| 792 |
OPT_PRINT_STATIC_VAR, /* -tv --print-static-var */ |
| 793 |
OPT_PRINT_STRINGS, /* -s --print-strings */ |
| 794 |
OPT_PRINT_STR_OFFSETS, /* --print-str-offsets */ |
| 795 |
OPT_PRINT_TYPE, /* -y --print-type */ |
| 796 |
OPT_PRINT_WEAKNAME, /* -w --print-weakname */ |
| 797 |
|
| 798 |
/* debuglink options */ |
| 799 |
OPT_NO_FOLLOW_DEBUGLINK, /* --no-follow-debuglink */ |
| 800 |
OPT_ADD_DEBUGLINK_PATH, /* --add-debuglink-path=<text> */ |
| 801 |
OPT_SUPPRESS_DEBUGLINK_CRC, /* --suppress-debuglink-crc */ |
| 802 |
|
| 803 |
/* Search text in attributes */ |
| 804 |
OPT_SEARCH_ANY, /* -S any=<text> --search-any=<text> */ |
| 805 |
OPT_SEARCH_ANY_COUNT, /* -Svany=<text> --search-any-count=<text> */ |
| 806 |
OPT_SEARCH_MATCH, /* -S match=<text> --search-match=<text> */ |
| 807 |
OPT_SEARCH_MATCH_COUNT, |
| 808 |
/* -Svmatch=<text> --search-match-count<text>*/ |
| 809 |
OPT_SEARCH_PRINT_CHILDREN, /* -Wc --search-print-children */ |
| 810 |
OPT_SEARCH_PRINT_PARENT, /* -Wp --search-print-parent */ |
| 811 |
OPT_SEARCH_PRINT_TREE, /* -W --search-print-tree */ |
| 812 |
OPT_SEARCH_REGEX, /* -S regex=<text> --search-regex=<text> */ |
| 813 |
OPT_SEARCH_REGEX_COUNT, |
| 814 |
/* -Svregex=<text> --search-regex-count<text>*/ |
| 815 |
|
| 816 |
/* Help & Version */ |
| 817 |
OPT_HELP, /* -h --help */ |
| 818 |
OPT_VERBOSE, /* -v --verbose */ |
| 819 |
OPT_VERBOSE_MORE, /* -vv --verbose-more */ |
| 820 |
OPT_VERSION, /* -V --version */ |
| 821 |
OPT_SHOW_DWARFDUMP_CONF, /* --show-dwarfdump-conf */ |
| 822 |
OPT_SHOW_ARGS, /* --show-args */ |
| 823 |
|
| 824 |
/* Trace */ |
| 825 |
OPT_TRACE, /* -# --trace=<num> */ |
| 826 |
|
| 827 |
OPT_ALLOC_TREE_OFF, /* --suppress-de-alloc-tree */ |
| 828 |
|
| 829 |
OPT_END |
| 830 |
}; |
| 831 |
|
| 832 |
static struct dwoption longopts[] = { |
| 833 |
|
| 834 |
/* Check DWARF Integrity. */ |
| 835 |
{"check-abbrev", dwno_argument, 0, OPT_CHECK_ABBREV }, |
| 836 |
{"check-all", dwno_argument, 0, OPT_CHECK_ALL }, |
| 837 |
{"check-aranges", dwno_argument, 0, OPT_CHECK_ARANGES }, |
| 838 |
{"check-attr-dup", dwno_argument, 0, OPT_CHECK_ATTR_DUP }, |
| 839 |
{"check-attr-encodings", dwno_argument, 0, OPT_CHECK_ATTR_ENCODINGS}, |
| 840 |
{"check-attr-names", dwno_argument, 0, OPT_CHECK_ATTR_NAMES }, |
| 841 |
{"check-constants", dwno_argument, 0, OPT_CHECK_CONSTANTS }, |
| 842 |
{"check-files-lines", dwno_argument, 0, OPT_CHECK_FILES_LINES }, |
| 843 |
{"check-forward-refs", dwno_argument, 0, OPT_CHECK_FORWARD_REFS }, |
| 844 |
{"check-frame-basic", dwno_argument, 0, OPT_CHECK_FRAME_BASIC }, |
| 845 |
{"check-frame-extended", dwno_argument, 0, OPT_CHECK_FRAME_EXTENDED}, |
| 846 |
{"check-frame-info", dwno_argument, 0, OPT_CHECK_FRAME_INFO }, |
| 847 |
{"check-gaps", dwno_argument, 0, OPT_CHECK_GAPS }, |
| 848 |
{"check-loc", dwno_argument, 0, OPT_CHECK_LOC }, |
| 849 |
{"check-macros", dwno_argument, 0, OPT_CHECK_MACROS }, |
| 850 |
{"check-pubnames", dwno_argument, 0, OPT_CHECK_PUBNAMES }, |
| 851 |
{"check-ranges", dwno_argument, 0, OPT_CHECK_RANGES }, |
| 852 |
{"check-self-refs", dwno_argument, 0, OPT_CHECK_SELF_REFS }, |
| 853 |
{"check-show", dwno_argument, 0, OPT_CHECK_SHOW }, |
| 854 |
{"check-silent", dwno_argument, 0, OPT_CHECK_SILENT }, |
| 855 |
{"check-summary", dwno_argument, 0, OPT_CHECK_SUMMARY }, |
| 856 |
{"check-tag-attr", dwno_argument, 0, OPT_CHECK_TAG_ATTR }, |
| 857 |
{"check-tag-tag", dwno_argument, 0, OPT_CHECK_TAG_TAG }, |
| 858 |
{"check-type", dwno_argument, 0, OPT_CHECK_TYPE }, |
| 859 |
{"check-unique", dwno_argument, 0, OPT_CHECK_UNIQUE }, |
| 860 |
{"check-usage", dwno_argument, 0, OPT_CHECK_USAGE }, |
| 861 |
{"check-usage-extended", dwno_argument, 0, OPT_CHECK_USAGE_EXTENDED}, |
| 862 |
{"check-functions", dwno_argument, 0, OPT_CHECK_FUNCTIONS}, |
| 863 |
|
| 864 |
/* File Specifications. */ |
| 865 |
{"file-abi", dwrequired_argument, 0, OPT_FILE_ABI }, |
| 866 |
{"file-line5", dwrequired_argument, 0, OPT_FILE_LINE5 }, |
| 867 |
{"file-name", dwrequired_argument, 0, OPT_FILE_NAME }, |
| 868 |
{"file-output", dwrequired_argument, 0, OPT_FILE_OUTPUT}, |
| 869 |
{"file-tied", dwrequired_argument, 0, OPT_FILE_TIED }, |
| 870 |
{"file-use-no-libelf", dwno_argument, 0, OPT_FILE_USE_NO_LIBELF }, |
| 871 |
|
| 872 |
/* Print Output Qualifiers. */ |
| 873 |
{"format-attr-name", dwno_argument, 0, |
| 874 |
OPT_FORMAT_ATTR_NAME }, |
| 875 |
{"format-dense", dwno_argument, 0, |
| 876 |
OPT_FORMAT_DENSE }, |
| 877 |
{"format-ellipsis", dwno_argument, 0, |
| 878 |
OPT_FORMAT_ELLIPSIS }, |
| 879 |
{"format-expr-ops-joined", dwno_argument, 0, |
| 880 |
OPT_FORMAT_EXPR_OPS_JOINED }, |
| 881 |
{"format-extensions", dwno_argument, 0, |
| 882 |
OPT_FORMAT_EXTENSIONS }, |
| 883 |
{"format-global-offsets", dwno_argument, 0, |
| 884 |
OPT_FORMAT_GLOBAL_OFFSETS }, |
| 885 |
{"format-loc", dwno_argument, 0, |
| 886 |
OPT_FORMAT_LOC }, |
| 887 |
{"format-registers", dwno_argument, 0, |
| 888 |
OPT_FORMAT_REGISTERS }, |
| 889 |
{"format-suppress-data", dwno_argument, 0, |
| 890 |
OPT_FORMAT_SUPPRESS_DATA }, |
| 891 |
{"format-suppress-group", dwno_argument, 0, |
| 892 |
OPT_FORMAT_SUPPRESS_GROUP }, |
| 893 |
{"format-suppress-lookup", dwno_argument, 0, |
| 894 |
OPT_FORMAT_SUPPRESS_LOOKUP }, |
| 895 |
{"format-suppress-offsets", dwno_argument, 0, |
| 896 |
OPT_FORMAT_SUPPRESS_OFFSETS }, |
| 897 |
{"format-suppress-sanitize", dwno_argument, 0, |
| 898 |
OPT_FORMAT_SUPPRESS_SANITIZE}, |
| 899 |
{"format-suppress-uri", dwno_argument, 0, |
| 900 |
OPT_FORMAT_SUPPRESS_URI }, |
| 901 |
{"format-suppress-uri-msg", dwno_argument, 0, |
| 902 |
OPT_FORMAT_SUPPRESS_URI_MSG }, |
| 903 |
{"format-suppress-utf8", dwno_argument, 0, |
| 904 |
OPT_FORMAT_SUPPRESS_UTF8 }, |
| 905 |
|
| 906 |
/* Print Output Limiters. */ |
| 907 |
{"format-file", dwrequired_argument, 0, OPT_FORMAT_FILE }, |
| 908 |
{"format-gcc", dwno_argument, 0, OPT_FORMAT_GCC }, |
| 909 |
{"format-group-number", dwrequired_argument, 0, |
| 910 |
OPT_FORMAT_GROUP_NUMBER}, |
| 911 |
{"format-universalnumber", dwrequired_argument, 0, |
| 912 |
OPT_FORMAT_UNIVERSALNUMBER}, |
| 913 |
{"format-limit", dwrequired_argument, 0, OPT_FORMAT_LIMIT }, |
| 914 |
{"format-producer", dwrequired_argument, 0, OPT_FORMAT_PRODUCER}, |
| 915 |
{"format-snc", dwno_argument, 0, OPT_FORMAT_SNC }, |
| 916 |
|
| 917 |
/* Print Debug Sections. */ |
| 918 |
{"print-abbrev", dwno_argument, 0, OPT_PRINT_ABBREV }, |
| 919 |
{"print-all", dwno_argument, 0, OPT_PRINT_ALL }, |
| 920 |
{"print-aranges", dwno_argument, 0, OPT_PRINT_ARANGES }, |
| 921 |
{"print-debug-addr", dwno_argument, 0, OPT_PRINT_DEBUG_ADDR}, |
| 922 |
{"print-debug-names", dwno_argument, 0, OPT_PRINT_DEBUG_NAMES}, |
| 923 |
{"print-gnu-debuglink", dwno_argument,0,OPT_PRINT_GNU_DEBUGLINK}, |
| 924 |
{"print-debug-gnu", dwno_argument, 0, OPT_PRINT_DEBUG_GNU }, |
| 925 |
{"print-debug-sup", dwno_argument, 0, OPT_PRINT_DEBUG_SUP }, |
| 926 |
{"print-eh-frame", dwno_argument, 0, OPT_PRINT_EH_FRAME }, |
| 927 |
{"print-fission", dwno_argument, 0, OPT_PRINT_FISSION }, |
| 928 |
{"print-frame", dwno_argument, 0, OPT_PRINT_FRAME }, |
| 929 |
{"print-info", dwno_argument, 0, OPT_PRINT_INFO }, |
| 930 |
{"print-lines", dwno_argument, 0, OPT_PRINT_LINES }, |
| 931 |
{"print-lines-short", dwno_argument, 0, OPT_PRINT_LINES_SHORT}, |
| 932 |
{"print-loc", dwno_argument, 0, OPT_PRINT_LOC }, |
| 933 |
{"print-macinfo", dwno_argument, 0, OPT_PRINT_MACINFO }, |
| 934 |
{"print-machine-arch", dwno_argument, 0, OPT_PRINT_MACHINE_ARCH }, |
| 935 |
{"print-producers", dwno_argument, 0, OPT_PRINT_PRODUCERS }, |
| 936 |
{"print-pubnames", dwno_argument, 0, OPT_PRINT_PUBNAMES }, |
| 937 |
{"print-ranges", dwno_argument, 0, OPT_PRINT_RANGES }, |
| 938 |
{"print-raw-loclists",dwno_argument, 0, OPT_PRINT_RAW_LOCLISTS}, |
| 939 |
{"print-raw-rnglists",dwno_argument, 0, OPT_PRINT_RAW_RNGLISTS}, |
| 940 |
{"print-static", dwno_argument, 0, OPT_PRINT_STATIC }, |
| 941 |
{"print-static-func", dwno_argument, 0, OPT_PRINT_STATIC_FUNC}, |
| 942 |
{"print-static-var", dwno_argument, 0, OPT_PRINT_STATIC_VAR }, |
| 943 |
{"print-strings", dwno_argument, 0, OPT_PRINT_STRINGS }, |
| 944 |
{"print-str-offsets", dwno_argument, 0, OPT_PRINT_STR_OFFSETS}, |
| 945 |
{"print-type", dwno_argument, 0, OPT_PRINT_TYPE }, |
| 946 |
{"print-weakname", dwno_argument, 0, OPT_PRINT_WEAKNAME }, |
| 947 |
|
| 948 |
/* GNU debuglink options */ |
| 949 |
{"no-follow-debuglink", dwno_argument, 0,OPT_NO_FOLLOW_DEBUGLINK}, |
| 950 |
{"add-debuglink-path", dwrequired_argument, 0,OPT_ADD_DEBUGLINK_PATH}, |
| 951 |
{"suppress-debuglink-crc", dwno_argument, 0, |
| 952 |
OPT_SUPPRESS_DEBUGLINK_CRC}, |
| 953 |
|
| 954 |
/* Search text in attributes. */ |
| 955 |
{"search-any", dwrequired_argument, 0,OPT_SEARCH_ANY }, |
| 956 |
{"search-any-count", dwrequired_argument, 0, |
| 957 |
OPT_SEARCH_ANY_COUNT }, |
| 958 |
{"search-match", dwrequired_argument, 0, |
| 959 |
OPT_SEARCH_MATCH }, |
| 960 |
{"search-match-count", dwrequired_argument, 0, |
| 961 |
OPT_SEARCH_MATCH_COUNT }, |
| 962 |
{"search-print-children", dwno_argument, 0, |
| 963 |
OPT_SEARCH_PRINT_CHILDREN}, |
| 964 |
{"search-print-parent", dwno_argument, 0, |
| 965 |
OPT_SEARCH_PRINT_PARENT }, |
| 966 |
{"search-print-tree", dwno_argument, 0, |
| 967 |
OPT_SEARCH_PRINT_TREE }, |
| 968 |
{"search-regex", dwrequired_argument, 0, OPT_SEARCH_REGEX }, |
| 969 |
{"search-regex-count", dwrequired_argument, 0, |
| 970 |
OPT_SEARCH_REGEX_COUNT }, |
| 971 |
|
| 972 |
/* Help & Version. */ |
| 973 |
{"help", dwno_argument, 0, OPT_HELP }, |
| 974 |
{"verbose", dwno_argument, 0, OPT_VERBOSE }, |
| 975 |
{"verbose-more", dwno_argument, 0, OPT_VERBOSE_MORE }, |
| 976 |
{"version", dwno_argument, 0, OPT_VERSION }, |
| 977 |
{"show-dwarfdump-conf",dwno_argument, 0, OPT_SHOW_DWARFDUMP_CONF }, |
| 978 |
{"show-args", dwno_argument, 0, OPT_SHOW_ARGS }, |
| 979 |
|
| 980 |
/* Trace. */ |
| 981 |
{"trace", dwrequired_argument, 0, OPT_TRACE}, |
| 982 |
|
| 983 |
{"suppress-de-alloc-tree",dwno_argument,0,OPT_ALLOC_TREE_OFF}, |
| 984 |
{0,0,0,0} |
| 985 |
}; |
| 986 |
|
| 987 |
/* Handlers for the command line options. */ |
| 988 |
/* Option '--print-debug-addr' */ |
| 989 |
void arg_print_debug_addr(void) |
| 990 |
{ |
| 991 |
glflags.gf_debug_addr_flag = TRUE; |
| 992 |
} |
| 993 |
|
| 994 |
/* Option '--print-debug-names' */ |
| 995 |
void arg_print_debug_names(void) |
| 996 |
{ |
| 997 |
glflags.gf_debug_names_flag = TRUE; |
| 998 |
} |
| 999 |
/* Option '--print-gnu-debuglink' */ |
| 1000 |
void arg_print_gnu_debuglink(void) |
| 1001 |
{ |
| 1002 |
glflags.gf_gnu_debuglink_flag = TRUE; |
| 1003 |
} |
| 1004 |
/* Option '--print-debug-gnu' */ |
| 1005 |
void arg_print_debug_gnu(void) |
| 1006 |
{ |
| 1007 |
glflags.gf_debug_gnu_flag = TRUE; |
| 1008 |
} |
| 1009 |
/* Option '--print-debug-sup' */ |
| 1010 |
void arg_print_debug_sup(void) |
| 1011 |
{ |
| 1012 |
glflags.gf_debug_sup_flag = TRUE; |
| 1013 |
} |
| 1014 |
|
| 1015 |
/* Option '--print-str-offsets' */ |
| 1016 |
void arg_print_str_offsets(void) |
| 1017 |
{ |
| 1018 |
glflags.gf_print_str_offsets = TRUE; |
| 1019 |
} |
| 1020 |
|
| 1021 |
void arg_trace(void) |
| 1022 |
{ |
| 1023 |
int nTraceLevel = 0; |
| 1024 |
|
| 1025 |
if (!dwoptarg || !dwoptarg[0]) { |
| 1026 |
/* --trace=0 to dwarfdump gets us here. */ |
| 1027 |
print_usage_message(usage_debug_text); |
| 1028 |
makename_destructor(); |
| 1029 |
global_destructors(); |
| 1030 |
exit(OKAY); |
| 1031 |
} |
| 1032 |
|
| 1033 |
nTraceLevel = atoi(dwoptarg); |
| 1034 |
if (nTraceLevel >= 0 && nTraceLevel <= MAX_TRACE_LEVEL) { |
| 1035 |
glflags.nTrace[nTraceLevel] = 1; |
| 1036 |
} |
| 1037 |
/* Display dwarfdump debug options. */ |
| 1038 |
if (dump_options) { |
| 1039 |
/* --trace=0 to dwarfdump gets us here. */ |
| 1040 |
print_usage_message(usage_debug_text); |
| 1041 |
makename_destructor(); |
| 1042 |
global_destructors(); |
| 1043 |
exit(OKAY); |
| 1044 |
} |
| 1045 |
} |
| 1046 |
|
| 1047 |
/* Option '-a' */ |
| 1048 |
void arg_print_all(void) |
| 1049 |
{ |
| 1050 |
suppress_check_dwarf(); |
| 1051 |
do_all(); |
| 1052 |
} |
| 1053 |
|
| 1054 |
/* Option '-b' */ |
| 1055 |
void arg_print_abbrev(void) |
| 1056 |
{ |
| 1057 |
glflags.gf_abbrev_flag = TRUE; |
| 1058 |
suppress_check_dwarf(); |
| 1059 |
} |
| 1060 |
|
| 1061 |
/* Option '-c[...]' */ |
| 1062 |
void arg_c_multiple_selection(void) |
| 1063 |
{ |
| 1064 |
/* Specify compiler name. */ |
| 1065 |
if (dwoptarg) { |
| 1066 |
switch (dwoptarg[0]) { |
| 1067 |
case 's': arg_format_snc(); break; |
| 1068 |
case 'g': arg_format_gcc(); break; |
| 1069 |
default: arg_format_producer(); break; |
| 1070 |
} |
| 1071 |
} else { |
| 1072 |
arg_print_loc(); |
| 1073 |
} |
| 1074 |
} |
| 1075 |
|
| 1076 |
/* Option '-c' with no other letters. See just above. */ |
| 1077 |
void arg_print_loc(void) |
| 1078 |
{ |
| 1079 |
printf("The -c option to print .debug_loc (unsafely) " |
| 1080 |
"is ignored\n"); |
| 1081 |
/* glflags.gf_loc_flag = TRUE; |
| 1082 |
suppress_check_dwarf(); */ |
| 1083 |
} |
| 1084 |
|
| 1085 |
/* Option '-cs' */ |
| 1086 |
void arg_format_snc(void) |
| 1087 |
{ |
| 1088 |
/* -cs : Check SNC compiler */ |
| 1089 |
glflags.gf_check_snc_compiler = TRUE; |
| 1090 |
glflags.gf_check_all_compilers = FALSE; |
| 1091 |
} |
| 1092 |
|
| 1093 |
/* Option '-cg' --format-gcc */ |
| 1094 |
void arg_format_gcc(void) |
| 1095 |
{ |
| 1096 |
/* -cg : Check GCC compiler */ |
| 1097 |
glflags.gf_check_gcc_compiler = TRUE; |
| 1098 |
glflags.gf_check_all_compilers = FALSE; |
| 1099 |
} |
| 1100 |
|
| 1101 |
/* Option '-c<producer>' */ |
| 1102 |
void arg_format_producer(void) |
| 1103 |
{ |
| 1104 |
/* Assume a compiler version to check, |
| 1105 |
most likely a substring of a compiler name. */ |
| 1106 |
if (!dwoptarg || !dwoptarg[0]) { |
| 1107 |
printf("ERROR: -c<producer> requires " |
| 1108 |
" a producer string\n"); |
| 1109 |
glflags.gf_count_major_errors++; |
| 1110 |
} |
| 1111 |
if (!record_producer(dwoptarg)) { |
| 1112 |
printf("ERROR: Compiler table max %d exceeded, " |
| 1113 |
"limiting the tracked compilers to %d\n", |
| 1114 |
COMPILER_TABLE_MAX,COMPILER_TABLE_MAX); |
| 1115 |
glflags.gf_count_major_errors++; |
| 1116 |
} |
| 1117 |
} |
| 1118 |
|
| 1119 |
/* Option '--format-expr-ops-joined' |
| 1120 |
restoring pre- December 2020 expression block printing */ |
| 1121 |
void arg_format_expr_ops_joined(void) |
| 1122 |
{ |
| 1123 |
glflags.gf_expr_ops_joined = TRUE; |
| 1124 |
} |
| 1125 |
/* Option '-C' -format-extensions */ |
| 1126 |
void arg_format_extensions(void) |
| 1127 |
{ |
| 1128 |
glflags.gf_suppress_check_extensions_tables = TRUE; |
| 1129 |
} |
| 1130 |
|
| 1131 |
/* Option '-d' */ |
| 1132 |
void arg_format_dense(void) |
| 1133 |
{ |
| 1134 |
glflags.gf_do_print_dwarf = TRUE; |
| 1135 |
/* This is sort of useless unless printing, |
| 1136 |
but harmless, so we do not insist we |
| 1137 |
are printing with suppress_check_dwarf(). */ |
| 1138 |
glflags.dense = TRUE; |
| 1139 |
} |
| 1140 |
|
| 1141 |
/* Option '-D' */ |
| 1142 |
void arg_format_suppress_offsets(void) |
| 1143 |
{ |
| 1144 |
/* Do not emit offset in output */ |
| 1145 |
glflags.gf_display_offsets = FALSE; |
| 1146 |
} |
| 1147 |
|
| 1148 |
/* Option '-e' */ |
| 1149 |
void arg_format_ellipsis(void) |
| 1150 |
{ |
| 1151 |
suppress_check_dwarf(); |
| 1152 |
glflags.ellipsis = TRUE; |
| 1153 |
} |
| 1154 |
|
| 1155 |
/* Option '-f' */ |
| 1156 |
void arg_print_debug_frame(void) |
| 1157 |
{ |
| 1158 |
glflags.gf_frame_flag = TRUE; |
| 1159 |
suppress_check_dwarf(); |
| 1160 |
} |
| 1161 |
|
| 1162 |
/* Option '-F' */ |
| 1163 |
void arg_print_gnu_frame(void) |
| 1164 |
{ |
| 1165 |
glflags.gf_eh_frame_flag = TRUE; |
| 1166 |
suppress_check_dwarf(); |
| 1167 |
} |
| 1168 |
|
| 1169 |
/* Option '-g' */ |
| 1170 |
void arg_format_loc(void) |
| 1171 |
{ |
| 1172 |
/* info_flag = TRUE; removed from -g. Nov 2015 |
| 1173 |
Entirely removed the effect of the -g 2021 */ |
| 1174 |
glflags.gf_use_old_dwarf_loclist = FALSE; |
| 1175 |
suppress_check_dwarf(); |
| 1176 |
} |
| 1177 |
|
| 1178 |
/* Option '-G' */ |
| 1179 |
void arg_format_global_offsets(void) |
| 1180 |
{ |
| 1181 |
glflags.gf_show_global_offsets = TRUE; |
| 1182 |
} |
| 1183 |
|
| 1184 |
/* Option '-h' */ |
| 1185 |
void arg_h_multiple_selection(void) |
| 1186 |
{ |
| 1187 |
if (dwoptarg) { |
| 1188 |
arg_usage_error = TRUE; |
| 1189 |
} else { |
| 1190 |
arg_help(); |
| 1191 |
} |
| 1192 |
} |
| 1193 |
|
| 1194 |
/* Option '-h' */ |
| 1195 |
void arg_help(void) |
| 1196 |
{ |
| 1197 |
print_usage_message(usage_long_text); |
| 1198 |
makename_destructor(); |
| 1199 |
global_destructors(); |
| 1200 |
exit(OKAY); |
| 1201 |
} |
| 1202 |
|
| 1203 |
/* Option '-H' */ |
| 1204 |
void arg_format_limit(void) |
| 1205 |
{ |
| 1206 |
int break_val = 0; |
| 1207 |
|
| 1208 |
if (!dwoptarg || !dwoptarg[0]) { |
| 1209 |
printf("\nERROR The -H option requires a limit value\n"); |
| 1210 |
glflags.gf_count_major_errors++; |
| 1211 |
return; |
| 1212 |
} |
| 1213 |
break_val = atoi(dwoptarg); |
| 1214 |
if (break_val > 0) { |
| 1215 |
glflags.break_after_n_units = break_val; |
| 1216 |
} |
| 1217 |
} |
| 1218 |
|
| 1219 |
/* Option '-i' */ |
| 1220 |
void arg_print_info(void) |
| 1221 |
{ |
| 1222 |
glflags.gf_info_flag = TRUE; |
| 1223 |
glflags.gf_types_flag = TRUE; |
| 1224 |
suppress_check_dwarf(); |
| 1225 |
} |
| 1226 |
|
| 1227 |
/* Option '-I' */ |
| 1228 |
void arg_print_fission(void) |
| 1229 |
{ |
| 1230 |
glflags.gf_gdbindex_flag = TRUE; |
| 1231 |
glflags.gf_gnu_debuglink_flag = TRUE; |
| 1232 |
suppress_check_dwarf(); |
| 1233 |
} |
| 1234 |
|
| 1235 |
/* Option '-k[...]' */ |
| 1236 |
void arg_k_multiple_selection(void) |
| 1237 |
{ |
| 1238 |
if (!dwoptarg || !dwoptarg[0]) { |
| 1239 |
printf("ERROR: The -k option requires at least" |
| 1240 |
" one selection\n"); |
| 1241 |
glflags.gf_count_major_errors++; |
| 1242 |
return; |
| 1243 |
} |
| 1244 |
switch (dwoptarg[0]) { |
| 1245 |
case 'a': arg_check_all(); break; |
| 1246 |
case 'b': arg_check_abbrev(); break; |
| 1247 |
case 'c': arg_check_constants(); break; |
| 1248 |
case 'd': arg_check_show(); break; |
| 1249 |
case 'D': arg_check_attr_dup(); break; |
| 1250 |
case 'e': arg_check_pubnames(); break; |
| 1251 |
case 'E': arg_check_attr_encodings(); break; |
| 1252 |
case 'f': arg_check_frame_info(); break; |
| 1253 |
case 'F': arg_check_files_lines(); break; |
| 1254 |
case 'g': arg_check_gaps(); break; |
| 1255 |
case 'G': arg_check_unique(); break; |
| 1256 |
case 'i': arg_check_summary(); break; |
| 1257 |
case 'l': arg_check_loc(); break; |
| 1258 |
case 'm': arg_check_ranges(); break; |
| 1259 |
case 'M': arg_check_aranges(); break; |
| 1260 |
case 'n': arg_check_attr_names(); break; |
| 1261 |
case 'r': arg_check_tag_attr(); break; |
| 1262 |
case 'R': arg_check_forward_refs(); break; |
| 1263 |
case 's': arg_check_silent(); break; |
| 1264 |
case 'S': arg_check_self_refs(); break; |
| 1265 |
case 't': arg_check_tag_tag(); break; |
| 1266 |
case 'u': arg_ku_multiple_selection(); break; |
| 1267 |
case 'w': arg_check_macros(); break; |
| 1268 |
case 'x': arg_kx_multiple_selection(); break; |
| 1269 |
case 'y': arg_check_type(); break; |
| 1270 |
default: arg_usage_error = TRUE; break; |
| 1271 |
} |
| 1272 |
} |
| 1273 |
|
| 1274 |
/* Option '-ka' */ |
| 1275 |
void arg_check_all(void) |
| 1276 |
{ |
| 1277 |
suppress_print_dwarf(); |
| 1278 |
glflags.gf_check_pubname_attr = TRUE; |
| 1279 |
glflags.gf_check_tag_attr = TRUE; |
| 1280 |
glflags.gf_check_tag_tree = TRUE; |
| 1281 |
glflags.gf_check_type_offset = TRUE; |
| 1282 |
glflags.gf_gnu_debuglink_flag = FALSE; |
| 1283 |
glflags.gf_check_names = TRUE; |
| 1284 |
glflags.gf_pubnames_flag = TRUE; |
| 1285 |
glflags.gf_info_flag = TRUE; |
| 1286 |
glflags.gf_types_flag = TRUE; |
| 1287 |
glflags.gf_gdbindex_flag = TRUE; |
| 1288 |
glflags.gf_check_decl_file = TRUE; |
| 1289 |
glflags.gf_check_macros = TRUE; |
| 1290 |
glflags.gf_check_frames = TRUE; |
| 1291 |
glflags.gf_check_frames_extended = FALSE; |
| 1292 |
glflags.gf_check_locations = TRUE; |
| 1293 |
glflags.gf_frame_flag = TRUE; |
| 1294 |
glflags.gf_eh_frame_flag = TRUE; |
| 1295 |
glflags.gf_check_ranges = TRUE; |
| 1296 |
glflags.gf_check_lines = TRUE; |
| 1297 |
glflags.gf_check_fdes = TRUE; |
| 1298 |
glflags.gf_check_harmless = TRUE; |
| 1299 |
glflags.gf_check_aranges = TRUE; |
| 1300 |
glflags.gf_aranges_flag = TRUE; /* Aranges section */ |
| 1301 |
glflags.gf_check_abbreviations = TRUE; |
| 1302 |
glflags.gf_check_dwarf_constants = TRUE; |
| 1303 |
glflags.gf_check_di_gaps = TRUE; |
| 1304 |
glflags.gf_check_forward_decl = TRUE; |
| 1305 |
glflags.gf_check_self_references = TRUE; |
| 1306 |
glflags.gf_check_attr_encoding = TRUE; |
| 1307 |
glflags.gf_print_usage_tag_attr = TRUE; |
| 1308 |
glflags.gf_check_duplicated_attributes = TRUE; |
| 1309 |
glflags.gf_check_functions = TRUE; |
| 1310 |
} |
| 1311 |
|
| 1312 |
/* Option '-kb' --check-abbrev */ |
| 1313 |
void arg_check_abbrev(void) |
| 1314 |
{ |
| 1315 |
/* Abbreviations */ |
| 1316 |
suppress_print_dwarf(); |
| 1317 |
glflags.gf_check_abbreviations = TRUE; |
| 1318 |
glflags.gf_info_flag = TRUE; |
| 1319 |
glflags.gf_types_flag = TRUE; |
| 1320 |
/* For some checks is worth trying the plain |
| 1321 |
.debug_abbrev section on its own. */ |
| 1322 |
glflags.gf_abbrev_flag = TRUE; |
| 1323 |
} |
| 1324 |
|
| 1325 |
/* Option '-kc' --check-constants */ |
| 1326 |
void arg_check_constants(void) |
| 1327 |
{ |
| 1328 |
/* DWARF constants */ |
| 1329 |
suppress_print_dwarf(); |
| 1330 |
glflags.gf_check_dwarf_constants = TRUE; |
| 1331 |
glflags.gf_info_flag = TRUE; |
| 1332 |
glflags.gf_types_flag = TRUE; |
| 1333 |
} |
| 1334 |
|
| 1335 |
/* Option '-kd' --check-show */ |
| 1336 |
void arg_check_show(void) |
| 1337 |
{ |
| 1338 |
/* Display check results */ |
| 1339 |
suppress_print_dwarf(); |
| 1340 |
glflags.gf_check_show_results = TRUE; |
| 1341 |
} |
| 1342 |
|
| 1343 |
/* Option '-kD' --check-attr-dup */ |
| 1344 |
void arg_check_attr_dup(void) |
| 1345 |
{ |
| 1346 |
/* Check duplicated attributes */ |
| 1347 |
suppress_print_dwarf(); |
| 1348 |
glflags.gf_check_duplicated_attributes = TRUE; |
| 1349 |
glflags.gf_info_flag = TRUE; |
| 1350 |
glflags.gf_types_flag = TRUE; |
| 1351 |
/* For some checks is worth trying the plain |
| 1352 |
.debug_abbrev section on its own. */ |
| 1353 |
glflags.gf_abbrev_flag = TRUE; |
| 1354 |
} |
| 1355 |
|
| 1356 |
/* Option '-ke' --check-pubnames */ |
| 1357 |
void arg_check_pubnames(void) |
| 1358 |
{ |
| 1359 |
suppress_print_dwarf(); |
| 1360 |
glflags.gf_check_pubname_attr = TRUE; |
| 1361 |
glflags.gf_pubnames_flag = TRUE; |
| 1362 |
glflags.gf_check_harmless = TRUE; |
| 1363 |
glflags.gf_check_fdes = TRUE; |
| 1364 |
} |
| 1365 |
|
| 1366 |
/* Option '-kE' --check-attr-encodings */ |
| 1367 |
void arg_check_attr_encodings(void) |
| 1368 |
{ |
| 1369 |
/* Attributes encoding usage */ |
| 1370 |
suppress_print_dwarf(); |
| 1371 |
glflags.gf_check_attr_encoding = TRUE; |
| 1372 |
glflags.gf_info_flag = TRUE; |
| 1373 |
glflags.gf_types_flag = TRUE; |
| 1374 |
} |
| 1375 |
|
| 1376 |
/* Option '-kf' --check-frame-info */ |
| 1377 |
void arg_check_frame_info(void) |
| 1378 |
{ |
| 1379 |
suppress_print_dwarf(); |
| 1380 |
glflags.gf_check_harmless = TRUE; |
| 1381 |
glflags.gf_check_fdes = TRUE; |
| 1382 |
} |
| 1383 |
|
| 1384 |
/* Option '-kF' --check-files-lines */ |
| 1385 |
void arg_check_files_lines(void) |
| 1386 |
{ |
| 1387 |
/* files-lines */ |
| 1388 |
suppress_print_dwarf(); |
| 1389 |
glflags.gf_check_decl_file = TRUE; |
| 1390 |
glflags.gf_check_lines = TRUE; |
| 1391 |
glflags.gf_info_flag = TRUE; |
| 1392 |
glflags.gf_types_flag = TRUE; |
| 1393 |
} |
| 1394 |
|
| 1395 |
/* Option '-kg' */ |
| 1396 |
void arg_check_gaps(void) |
| 1397 |
{ |
| 1398 |
/* Check debug info gaps */ |
| 1399 |
suppress_print_dwarf(); |
| 1400 |
glflags.gf_check_di_gaps = TRUE; |
| 1401 |
glflags.gf_info_flag = TRUE; |
| 1402 |
glflags.gf_types_flag = TRUE; |
| 1403 |
} |
| 1404 |
|
| 1405 |
/* Option '-kG' */ |
| 1406 |
void arg_check_unique(void) |
| 1407 |
{ |
| 1408 |
/* Print just global (unique) errors */ |
| 1409 |
suppress_print_dwarf(); |
| 1410 |
glflags.gf_print_unique_errors = TRUE; |
| 1411 |
} |
| 1412 |
|
| 1413 |
/* Option '-ki' */ |
| 1414 |
void arg_check_summary(void) |
| 1415 |
{ |
| 1416 |
/* Summary for each compiler */ |
| 1417 |
suppress_print_dwarf(); |
| 1418 |
glflags.gf_print_summary_all = TRUE; |
| 1419 |
} |
| 1420 |
|
| 1421 |
/* Option '-kl' --check-loc */ |
| 1422 |
void arg_check_loc(void) |
| 1423 |
{ |
| 1424 |
/* Locations list */ |
| 1425 |
suppress_print_dwarf(); |
| 1426 |
glflags.gf_check_locations = TRUE; |
| 1427 |
glflags.gf_info_flag = TRUE; |
| 1428 |
glflags.gf_types_flag = TRUE; |
| 1429 |
glflags.gf_loc_flag = TRUE; |
| 1430 |
} |
| 1431 |
|
| 1432 |
/* Option '-km' */ |
| 1433 |
void arg_check_ranges(void) |
| 1434 |
{ |
| 1435 |
/* Ranges */ |
| 1436 |
suppress_print_dwarf(); |
| 1437 |
glflags.gf_check_ranges = TRUE; |
| 1438 |
glflags.gf_info_flag = TRUE; |
| 1439 |
glflags.gf_types_flag = TRUE; |
| 1440 |
} |
| 1441 |
|
| 1442 |
/* Option '-kM' */ |
| 1443 |
void arg_check_aranges(void) |
| 1444 |
{ |
| 1445 |
/* Aranges */ |
| 1446 |
suppress_print_dwarf(); |
| 1447 |
glflags.gf_check_aranges = TRUE; |
| 1448 |
glflags.gf_aranges_flag = TRUE; |
| 1449 |
} |
| 1450 |
|
| 1451 |
/* Option '-kn' |
| 1452 |
Force examination of .debug_info and .debug_types |
| 1453 |
and record attribute name (DW_AT_name). Will report any names |
| 1454 |
with dot (.) except in compile-unit DIEs |
| 1455 |
as those have source names like t.c so dot is |
| 1456 |
to be expected. */ |
| 1457 |
void arg_check_attr_names(void) |
| 1458 |
{ |
| 1459 |
/* invalid names */ |
| 1460 |
suppress_print_dwarf(); |
| 1461 |
glflags.gf_check_names = TRUE; |
| 1462 |
glflags.gf_info_flag = TRUE; |
| 1463 |
glflags.gf_types_flag = TRUE; |
| 1464 |
} |
| 1465 |
|
| 1466 |
/* Option '-kr --check-tag-attr' |
| 1467 |
Force examination of .debug_info and .debug_types |
| 1468 |
and record tag/attr uses. */ |
| 1469 |
void arg_check_tag_attr(void) |
| 1470 |
{ |
| 1471 |
suppress_print_dwarf(); |
| 1472 |
glflags.gf_check_tag_attr = TRUE; |
| 1473 |
glflags.gf_info_flag = TRUE; |
| 1474 |
glflags.gf_types_flag = TRUE; |
| 1475 |
glflags.gf_check_harmless = TRUE; |
| 1476 |
} |
| 1477 |
|
| 1478 |
/* Option '-kR' |
| 1479 |
Force examination of .debug_info and .debug_types |
| 1480 |
and record tag/attr uses. */ |
| 1481 |
void arg_check_forward_refs(void) |
| 1482 |
{ |
| 1483 |
/* forward declarations in DW_AT_specification */ |
| 1484 |
suppress_print_dwarf(); |
| 1485 |
glflags.gf_check_forward_decl = TRUE; |
| 1486 |
glflags.gf_info_flag = TRUE; |
| 1487 |
glflags.gf_types_flag = TRUE; |
| 1488 |
} |
| 1489 |
|
| 1490 |
/* Option '-ks' */ |
| 1491 |
void arg_check_silent(void) |
| 1492 |
{ |
| 1493 |
/* Check verbose mode */ |
| 1494 |
suppress_print_dwarf(); |
| 1495 |
glflags.gf_check_verbose_mode = FALSE; |
| 1496 |
} |
| 1497 |
|
| 1498 |
/* Option '-kS' --check-self-refs */ |
| 1499 |
void arg_check_self_refs(void) |
| 1500 |
{ |
| 1501 |
/* self references in: |
| 1502 |
DW_AT_specification, DW_AT_type, DW_AT_abstract_origin */ |
| 1503 |
suppress_print_dwarf(); |
| 1504 |
glflags.gf_check_self_references = TRUE; |
| 1505 |
glflags.gf_info_flag = TRUE; |
| 1506 |
glflags.gf_types_flag = TRUE; |
| 1507 |
} |
| 1508 |
|
| 1509 |
/* Option '-kt'--check-tag-tag |
| 1510 |
Force examination of .debug_info and .debug_types |
| 1511 |
and record tag and attr uses. */ |
| 1512 |
void arg_check_tag_tag(void) |
| 1513 |
{ |
| 1514 |
suppress_print_dwarf(); |
| 1515 |
glflags.gf_check_tag_tree = TRUE; |
| 1516 |
glflags.gf_check_harmless = TRUE; |
| 1517 |
glflags.gf_info_flag = TRUE; |
| 1518 |
glflags.gf_types_flag = TRUE; |
| 1519 |
} |
| 1520 |
|
| 1521 |
/* Option '-ku[...]' */ |
| 1522 |
void arg_ku_multiple_selection(void) |
| 1523 |
{ |
| 1524 |
/* Tag-Tree and Tag-Attr usage */ |
| 1525 |
if (!dwoptarg || !dwoptarg[0]) { |
| 1526 |
printf("ERROR: The -ku option requires at least" |
| 1527 |
" one selection\n"); |
| 1528 |
glflags.gf_count_major_errors++; |
| 1529 |
return; |
| 1530 |
} |
| 1531 |
if (dwoptarg[1]) { |
| 1532 |
switch (dwoptarg[1]) { |
| 1533 |
case 'f': arg_check_usage_extended(); break; |
| 1534 |
default: arg_usage_error = TRUE; break; |
| 1535 |
} |
| 1536 |
} else { |
| 1537 |
arg_check_usage(); |
| 1538 |
} |
| 1539 |
} |
| 1540 |
|
| 1541 |
/* Option '-ku' --check-usage */ |
| 1542 |
void arg_check_usage(void) |
| 1543 |
{ |
| 1544 |
suppress_print_dwarf(); |
| 1545 |
glflags.gf_print_usage_tag_attr = TRUE; |
| 1546 |
glflags.gf_info_flag = TRUE; |
| 1547 |
glflags.gf_types_flag = TRUE; |
| 1548 |
} |
| 1549 |
|
| 1550 |
/* Option '-kuf' --check-usage-extended, |
| 1551 |
Now obsolete as all such reports |
| 1552 |
are full reports, but accepted and means |
| 1553 |
the same as -ku. */ |
| 1554 |
void arg_check_usage_extended(void) |
| 1555 |
{ |
| 1556 |
arg_check_usage(); |
| 1557 |
} |
| 1558 |
|
| 1559 |
/* Option '-kw' --check-macros */ |
| 1560 |
void arg_check_macros(void) |
| 1561 |
{ |
| 1562 |
suppress_print_dwarf(); |
| 1563 |
glflags.gf_check_macros = TRUE; |
| 1564 |
glflags.gf_macro_flag = TRUE; |
| 1565 |
glflags.gf_macinfo_flag = TRUE; |
| 1566 |
} |
| 1567 |
|
| 1568 |
/* Option '-kx[...]' */ |
| 1569 |
void arg_kx_multiple_selection(void) |
| 1570 |
{ |
| 1571 |
/* Frames check */ |
| 1572 |
if (dwoptarg[1]) { |
| 1573 |
switch (dwoptarg[1]) { |
| 1574 |
case 'e': arg_check_frame_extended(); break; |
| 1575 |
default: arg_usage_error = TRUE; break; |
| 1576 |
} |
| 1577 |
} else { |
| 1578 |
arg_check_frame_basic(); |
| 1579 |
} |
| 1580 |
} |
| 1581 |
|
| 1582 |
/* Option '-kx' --check-frame-basic */ |
| 1583 |
void arg_check_frame_basic(void) |
| 1584 |
{ |
| 1585 |
suppress_print_dwarf(); |
| 1586 |
glflags.gf_check_frames = TRUE; |
| 1587 |
glflags.gf_frame_flag = TRUE; |
| 1588 |
glflags.gf_eh_frame_flag = TRUE; |
| 1589 |
} |
| 1590 |
|
| 1591 |
/* Option '-kxe' --check-frame-extended */ |
| 1592 |
void arg_check_frame_extended(void) |
| 1593 |
{ |
| 1594 |
arg_check_frame_basic(); |
| 1595 |
|
| 1596 |
/* -xe : Extended frames check */ |
| 1597 |
glflags.gf_check_frames = FALSE; |
| 1598 |
glflags.gf_check_frames_extended = TRUE; |
| 1599 |
} |
| 1600 |
|
| 1601 |
/* Option '-ky' */ |
| 1602 |
void arg_check_type(void) |
| 1603 |
{ |
| 1604 |
suppress_print_dwarf(); |
| 1605 |
glflags.gf_check_type_offset = TRUE; |
| 1606 |
glflags.gf_check_harmless = TRUE; |
| 1607 |
glflags.gf_check_decl_file = TRUE; |
| 1608 |
glflags.gf_info_flag = TRUE; |
| 1609 |
glflags.gf_pubtypes_flag = TRUE; |
| 1610 |
glflags.gf_check_ranges = TRUE; |
| 1611 |
glflags.gf_check_aranges = TRUE; |
| 1612 |
} |
| 1613 |
|
| 1614 |
/* Option '--check-functions' */ |
| 1615 |
void arg_check_functions(void) |
| 1616 |
{ |
| 1617 |
suppress_print_dwarf(); |
| 1618 |
glflags.gf_check_functions = TRUE; |
| 1619 |
} |
| 1620 |
|
| 1621 |
/* Option '-l[...]' */ |
| 1622 |
void arg_l_multiple_selection(void) |
| 1623 |
{ |
| 1624 |
if (dwoptarg) { |
| 1625 |
switch (dwoptarg[0]) { |
| 1626 |
case 's': arg_print_lines_short(); break; |
| 1627 |
default: arg_usage_error = TRUE; break; |
| 1628 |
} |
| 1629 |
} else { |
| 1630 |
arg_print_lines(); |
| 1631 |
} |
| 1632 |
} |
| 1633 |
|
| 1634 |
/* Option '-l' */ |
| 1635 |
void arg_print_lines(void) |
| 1636 |
{ |
| 1637 |
/* Enable to suppress offsets printing */ |
| 1638 |
glflags.gf_line_flag = TRUE; |
| 1639 |
suppress_check_dwarf(); |
| 1640 |
} |
| 1641 |
|
| 1642 |
/* Option '-ls' */ |
| 1643 |
void arg_print_lines_short(void) |
| 1644 |
{ |
| 1645 |
/* -ls : suppress <pc> addresses */ |
| 1646 |
glflags.gf_line_print_pc = FALSE; |
| 1647 |
arg_print_lines(); |
| 1648 |
} |
| 1649 |
|
| 1650 |
/* Option '-m' */ |
| 1651 |
void arg_print_macinfo(void) |
| 1652 |
{ |
| 1653 |
glflags.gf_macinfo_flag = TRUE; /* DWARF2,3,4 */ |
| 1654 |
glflags.gf_macro_flag = TRUE; /* DWARF5 */ |
| 1655 |
suppress_check_dwarf(); |
| 1656 |
} |
| 1657 |
/* Option '--print-machine-arch' */ |
| 1658 |
void arg_print_machine_arch(void) |
| 1659 |
{ |
| 1660 |
glflags.gf_machine_arch_flag = TRUE; |
| 1661 |
suppress_check_dwarf(); |
| 1662 |
} |
| 1663 |
|
| 1664 |
/* Option '-M' */ |
| 1665 |
void arg_format_attr_name(void) |
| 1666 |
{ |
| 1667 |
glflags.show_form_used = TRUE; |
| 1668 |
} |
| 1669 |
|
| 1670 |
/* Option '-n' */ |
| 1671 |
void arg_format_suppress_lookup(void) |
| 1672 |
{ |
| 1673 |
glflags.gf_suppress_nested_name_search = TRUE; |
| 1674 |
} |
| 1675 |
|
| 1676 |
/* Option '-N' */ |
| 1677 |
void arg_print_ranges(void) |
| 1678 |
{ |
| 1679 |
glflags.gf_ranges_flag = TRUE; |
| 1680 |
suppress_check_dwarf(); |
| 1681 |
} |
| 1682 |
/* Option '--print-raw-rnglists' */ |
| 1683 |
void arg_print_raw_rnglists(void) |
| 1684 |
{ |
| 1685 |
glflags.gf_print_raw_rnglists = TRUE; |
| 1686 |
suppress_check_dwarf(); |
| 1687 |
} |
| 1688 |
/* Option '--print-raw-loclists' */ |
| 1689 |
void arg_print_raw_loclists(void) |
| 1690 |
{ |
| 1691 |
glflags.gf_print_raw_loclists = TRUE; |
| 1692 |
suppress_check_dwarf(); |
| 1693 |
} |
| 1694 |
|
| 1695 |
/* Option '-O' */ |
| 1696 |
void arg_O_multiple_selection(void) |
| 1697 |
{ |
| 1698 |
/* Output filename */ |
| 1699 |
/* -O file=<filename> */ |
| 1700 |
if (!dwoptarg || !dwoptarg[0]) { |
| 1701 |
arg_usage_error = TRUE; |
| 1702 |
return; |
| 1703 |
} |
| 1704 |
if (strncmp(dwoptarg,"file=",5) == 0) { |
| 1705 |
dwoptarg = &dwoptarg[5]; |
| 1706 |
arg_file_output(); |
| 1707 |
} else { |
| 1708 |
arg_usage_error = TRUE; |
| 1709 |
} |
| 1710 |
} |
| 1711 |
|
| 1712 |
/* Option '-O file=' */ |
| 1713 |
void arg_file_output(void) |
| 1714 |
{ |
| 1715 |
const char *ctx = arg_option > OPT_BEGIN ? |
| 1716 |
"--file-output=" : "-O file="; |
| 1717 |
const char *path = 0; |
| 1718 |
|
| 1719 |
if (!dwoptarg || !dwoptarg[0]) { |
| 1720 |
arg_usage_error = TRUE; |
| 1721 |
return; |
| 1722 |
} |
| 1723 |
path = do_uri_translation(dwoptarg,ctx); |
| 1724 |
if (strlen(path) > 0) { |
| 1725 |
glflags.output_file = path; |
| 1726 |
} else { |
| 1727 |
arg_usage_error = TRUE; |
| 1728 |
} |
| 1729 |
} |
| 1730 |
|
| 1731 |
/* Option '-p' */ |
| 1732 |
void arg_print_pubnames(void) |
| 1733 |
{ |
| 1734 |
glflags.gf_pubnames_flag = TRUE; |
| 1735 |
suppress_check_dwarf(); |
| 1736 |
} |
| 1737 |
|
| 1738 |
/* Option '-P' */ |
| 1739 |
void arg_print_producers(void) |
| 1740 |
{ |
| 1741 |
/* List of CUs per compiler */ |
| 1742 |
glflags.gf_producer_children_flag = TRUE; |
| 1743 |
} |
| 1744 |
|
| 1745 |
/* Option '-q' */ |
| 1746 |
void arg_format_suppress_uri_msg(void) |
| 1747 |
{ |
| 1748 |
/* Suppress uri-did-translate notification */ |
| 1749 |
glflags.gf_do_print_uri_in_input = FALSE; |
| 1750 |
} |
| 1751 |
/* Option '--format-suppress-utf8' */ |
| 1752 |
void arg_format_suppress_utf8(void) |
| 1753 |
{ |
| 1754 |
/* Suppress uri-did-translate notification */ |
| 1755 |
glflags.gf_print_utf8_flag = FALSE; |
| 1756 |
} |
| 1757 |
|
| 1758 |
/* Option '-Q' */ |
| 1759 |
void arg_format_suppress_data(void) |
| 1760 |
{ |
| 1761 |
/* Q suppresses section data printing. */ |
| 1762 |
glflags.gf_do_print_dwarf = FALSE; |
| 1763 |
} |
| 1764 |
|
| 1765 |
/* Option '-r' */ |
| 1766 |
void arg_print_aranges(void) |
| 1767 |
{ |
| 1768 |
glflags.gf_aranges_flag = TRUE; |
| 1769 |
suppress_check_dwarf(); |
| 1770 |
} |
| 1771 |
|
| 1772 |
/* Option '-R' */ |
| 1773 |
void arg_format_registers(void) |
| 1774 |
{ |
| 1775 |
glflags.gf_generic_1200_regs = TRUE; |
| 1776 |
} |
| 1777 |
|
| 1778 |
/* Option '-s' */ |
| 1779 |
void arg_print_strings(void) |
| 1780 |
{ |
| 1781 |
glflags.gf_string_flag = TRUE; |
| 1782 |
suppress_check_dwarf(); |
| 1783 |
} |
| 1784 |
|
| 1785 |
/* Option '-S' */ |
| 1786 |
void arg_S_multiple_selection(void) |
| 1787 |
{ |
| 1788 |
/* 'v' option, to print number of occurrences */ |
| 1789 |
/* -S[v]match|any|regex=text*/ |
| 1790 |
if (!dwoptarg || !dwoptarg[0]) { |
| 1791 |
arg_usage_error = TRUE; |
| 1792 |
return; |
| 1793 |
} |
| 1794 |
if (dwoptarg[0] == 'v') { |
| 1795 |
++dwoptarg; |
| 1796 |
arg_search_count(); |
| 1797 |
} |
| 1798 |
|
| 1799 |
if (strncmp(dwoptarg,"match=",6) == 0) { |
| 1800 |
dwoptarg = &dwoptarg[6]; |
| 1801 |
arg_search_match(); |
| 1802 |
} else if (strncmp(dwoptarg,"any=",4) == 0) { |
| 1803 |
dwoptarg = &dwoptarg[4]; |
| 1804 |
arg_search_any(); |
| 1805 |
} |
| 1806 |
else if (strncmp(dwoptarg,"regex=",6) == 0) { |
| 1807 |
dwoptarg = &dwoptarg[6]; |
| 1808 |
arg_search_regex(); |
| 1809 |
} |
| 1810 |
else { |
| 1811 |
arg_search_invalid(); |
| 1812 |
} |
| 1813 |
} |
| 1814 |
|
| 1815 |
/* Option --no-follow-debuglink */ |
| 1816 |
void arg_no_follow_debuglink(void) |
| 1817 |
{ |
| 1818 |
glflags.gf_no_follow_debuglink = TRUE; |
| 1819 |
} |
| 1820 |
|
| 1821 |
/* Option --suppress-debuglink-crc */ |
| 1822 |
void arg_suppress_debuglink_crc(void) |
| 1823 |
{ |
| 1824 |
dwarf_suppress_debuglink_crc(1); |
| 1825 |
} |
| 1826 |
|
| 1827 |
static int |
| 1828 |
insert_debuglink_path(char *p) |
| 1829 |
{ |
| 1830 |
char ** newarray = 0; |
| 1831 |
unsigned int curcount = glflags.gf_global_debuglink_count; |
| 1832 |
unsigned newcount = curcount+1; |
| 1833 |
unsigned u = 0; |
| 1834 |
char * pstr = 0; |
| 1835 |
|
| 1836 |
newarray = (char **)malloc(newcount * sizeof(char *)); |
| 1837 |
if (!newarray) { |
| 1838 |
printf("ERROR Unable to malloc space for" |
| 1839 |
" debuglink paths. " |
| 1840 |
" malloc %u pointers failed.\n",newcount); |
| 1841 |
printf("Global debuglink path ignored: %s\n", |
| 1842 |
sanitized(p)); |
| 1843 |
glflags.gf_count_major_errors++; |
| 1844 |
return DW_DLV_ERROR; |
| 1845 |
} |
| 1846 |
pstr = strdup(p); |
| 1847 |
if (!pstr) { |
| 1848 |
printf("ERROR Unable to malloc space" |
| 1849 |
" for debuglink path: " |
| 1850 |
"count stays at %u\n",curcount); |
| 1851 |
printf("Global debuglink path ignored: %s\n", |
| 1852 |
sanitized(p)); |
| 1853 |
glflags.gf_count_major_errors++; |
| 1854 |
free(newarray); |
| 1855 |
return DW_DLV_ERROR; |
| 1856 |
} |
| 1857 |
for ( u = 0; u < curcount; ++u) { |
| 1858 |
newarray[u] = glflags.gf_global_debuglink_paths[u]; |
| 1859 |
} |
| 1860 |
newarray[curcount] = pstr; |
| 1861 |
free(glflags.gf_global_debuglink_paths); |
| 1862 |
glflags.gf_global_debuglink_paths = newarray; |
| 1863 |
glflags.gf_global_debuglink_count = newcount; |
| 1864 |
return DW_DLV_OK; |
| 1865 |
} |
| 1866 |
|
| 1867 |
/* Option --add-debuglink-path=<text> */ |
| 1868 |
void arg_add_debuglink_path(void) |
| 1869 |
{ |
| 1870 |
if (!dwoptarg || !dwoptarg[0]) { |
| 1871 |
arg_usage_error = TRUE; |
| 1872 |
return; |
| 1873 |
} |
| 1874 |
if (strncmp(dwoptarg,"add-debuglink-path=",21) == 0) { |
| 1875 |
dwoptarg = &dwoptarg[21]; |
| 1876 |
if (strlen(dwoptarg)) { |
| 1877 |
int res = 0; |
| 1878 |
|
| 1879 |
res = insert_debuglink_path(dwoptarg); |
| 1880 |
if (res == DW_DLV_OK) { |
| 1881 |
return; |
| 1882 |
} |
| 1883 |
} |
| 1884 |
} |
| 1885 |
arg_debuglink_path_invalid(); |
| 1886 |
} |
| 1887 |
|
| 1888 |
/* Option '-S any=' */ |
| 1889 |
void arg_search_any(void) |
| 1890 |
{ |
| 1891 |
const char *tempstr = 0; |
| 1892 |
const char *ctx = arg_option > OPT_BEGIN ? |
| 1893 |
"--search-any=" : "-S any="; |
| 1894 |
|
| 1895 |
/* -S any=<text> */ |
| 1896 |
if (!dwoptarg || !dwoptarg[0]) { |
| 1897 |
arg_usage_error = TRUE; |
| 1898 |
return; |
| 1899 |
} |
| 1900 |
glflags.gf_search_is_on = TRUE; |
| 1901 |
glflags.search_any_text = makename(dwoptarg); |
| 1902 |
tempstr = remove_quotes_pair(glflags.search_any_text); |
| 1903 |
if (!tempstr){ |
| 1904 |
printf("ERROR regcomp: unable to compile " |
| 1905 |
" search expression %s, out of memory\n", |
| 1906 |
glflags.search_any_text); |
| 1907 |
glflags.gf_count_major_errors++; |
| 1908 |
return; |
| 1909 |
} |
| 1910 |
glflags.search_any_text = do_uri_translation(tempstr,ctx); |
| 1911 |
if (strlen(glflags.search_any_text) <= 0) { |
| 1912 |
arg_search_invalid(); |
| 1913 |
} |
| 1914 |
} |
| 1915 |
|
| 1916 |
/* Option '-Sv any=' */ |
| 1917 |
void arg_search_any_count(void) |
| 1918 |
{ |
| 1919 |
arg_search_count(); |
| 1920 |
arg_search_any(); |
| 1921 |
} |
| 1922 |
|
| 1923 |
/* Option '-S match=' */ |
| 1924 |
void arg_search_match(void) |
| 1925 |
{ |
| 1926 |
const char *tempstr = 0; |
| 1927 |
const char *ctx = arg_option > OPT_BEGIN ? |
| 1928 |
"--search-match=" : "-S match="; |
| 1929 |
|
| 1930 |
if (!dwoptarg || !dwoptarg[0]) { |
| 1931 |
arg_usage_error = TRUE; |
| 1932 |
return; |
| 1933 |
} |
| 1934 |
/* -S match=<text> */ |
| 1935 |
glflags.gf_search_is_on = TRUE; |
| 1936 |
glflags.search_match_text = makename(dwoptarg); |
| 1937 |
tempstr = remove_quotes_pair(glflags.search_match_text); |
| 1938 |
if (!tempstr){ |
| 1939 |
printf("ERROR: regcomp unable to compile " |
| 1940 |
" search expression match=%s, out of memory\n", |
| 1941 |
glflags.search_match_text); |
| 1942 |
glflags.gf_count_major_errors++; |
| 1943 |
return; |
| 1944 |
} |
| 1945 |
glflags.search_match_text = do_uri_translation(tempstr,ctx); |
| 1946 |
if (strlen(glflags.search_match_text) <= 0) { |
| 1947 |
arg_search_invalid(); |
| 1948 |
} |
| 1949 |
} |
| 1950 |
|
| 1951 |
/* Option '-Sv match=' */ |
| 1952 |
void arg_search_match_count(void) |
| 1953 |
{ |
| 1954 |
arg_search_count(); |
| 1955 |
arg_search_match(); |
| 1956 |
} |
| 1957 |
|
| 1958 |
/* Option '-S regex=' */ |
| 1959 |
void arg_search_regex(void) |
| 1960 |
{ |
| 1961 |
const char *tempstr = 0; |
| 1962 |
const char *ctx = arg_option > OPT_BEGIN ? |
| 1963 |
"--search-regex=" : "-S regex="; |
| 1964 |
int res = 0; |
| 1965 |
|
| 1966 |
if (!dwoptarg || !dwoptarg[0]) { |
| 1967 |
arg_usage_error = TRUE; |
| 1968 |
return; |
| 1969 |
} |
| 1970 |
/* The compiled regex occupies a static area */ |
| 1971 |
/* -S regex=<regular expression> */ |
| 1972 |
glflags.gf_search_is_on = TRUE; |
| 1973 |
glflags.search_regex_text = makename(dwoptarg); |
| 1974 |
tempstr = remove_quotes_pair(glflags.search_regex_text); |
| 1975 |
if (!tempstr){ |
| 1976 |
printf("regcomp: unable to compile " |
| 1977 |
" search regular expression %s, out of memory\n", |
| 1978 |
glflags.search_regex_text); |
| 1979 |
glflags.gf_count_major_errors++; |
| 1980 |
return; |
| 1981 |
} |
| 1982 |
glflags.search_regex_text = do_uri_translation(tempstr,ctx); |
| 1983 |
if (glflags.search_regex_text && |
| 1984 |
strlen(glflags.search_regex_text) > 0) { |
| 1985 |
res = dd_re_comp(glflags.search_regex_text); |
| 1986 |
|
| 1987 |
if (res != DW_DLV_OK) { |
| 1988 |
printf("ERROR: regcomp: unable to compile " |
| 1989 |
" search regular expression %s " |
| 1990 |
"so regex= ignored.\n", |
| 1991 |
glflags.search_regex_text); |
| 1992 |
glflags.search_regex_text = 0; |
| 1993 |
glflags.gf_search_is_on = FALSE; |
| 1994 |
glflags.gf_count_major_errors++; |
| 1995 |
} |
| 1996 |
} else { |
| 1997 |
arg_search_invalid(); |
| 1998 |
} |
| 1999 |
} |
| 2000 |
|
| 2001 |
/* Option '-Sv regex=' */ |
| 2002 |
void arg_search_regex_count(void) |
| 2003 |
{ |
| 2004 |
arg_search_count(); |
| 2005 |
arg_search_regex(); |
| 2006 |
} |
| 2007 |
|
| 2008 |
/* Option '-Sv' */ |
| 2009 |
void arg_search_count(void) |
| 2010 |
{ |
| 2011 |
glflags.gf_search_print_results = TRUE; |
| 2012 |
} |
| 2013 |
|
| 2014 |
/* Option '-t' */ |
| 2015 |
void arg_t_multiple_selection(void) |
| 2016 |
{ |
| 2017 |
if (!dwoptarg || !dwoptarg[0]) { |
| 2018 |
arg_usage_error = TRUE; |
| 2019 |
return; |
| 2020 |
} |
| 2021 |
switch (dwoptarg[0]) { |
| 2022 |
case 'a': arg_print_static(); break; |
| 2023 |
case 'f': arg_print_static_func(); break; |
| 2024 |
case 'v': arg_print_static_var(); break; |
| 2025 |
default: arg_usage_error = TRUE; break; |
| 2026 |
} |
| 2027 |
} |
| 2028 |
|
| 2029 |
/* Option '-ta' */ |
| 2030 |
void arg_print_static(void) |
| 2031 |
{ |
| 2032 |
/* all */ |
| 2033 |
glflags.gf_static_func_flag = TRUE; |
| 2034 |
glflags.gf_static_var_flag = TRUE; |
| 2035 |
suppress_check_dwarf(); |
| 2036 |
} |
| 2037 |
|
| 2038 |
/* Option '-tf' */ |
| 2039 |
void arg_print_static_func(void) |
| 2040 |
{ |
| 2041 |
/* .debug_static_func */ |
| 2042 |
glflags.gf_static_func_flag = TRUE; |
| 2043 |
suppress_check_dwarf(); |
| 2044 |
} |
| 2045 |
|
| 2046 |
/* Option '-tv' */ |
| 2047 |
void arg_print_static_var(void) |
| 2048 |
{ |
| 2049 |
/* .debug_static_var */ |
| 2050 |
glflags.gf_static_var_flag = TRUE; |
| 2051 |
suppress_check_dwarf(); |
| 2052 |
} |
| 2053 |
|
| 2054 |
/* Option '-u' */ |
| 2055 |
void arg_format_file(void) |
| 2056 |
{ |
| 2057 |
const char *ctx = arg_option > OPT_BEGIN ? |
| 2058 |
"--format-file=" : "-u<cu name>"; |
| 2059 |
const char *tstr = 0; |
| 2060 |
|
| 2061 |
if (!dwoptarg || !dwoptarg[0]) { |
| 2062 |
arg_usage_error = TRUE; |
| 2063 |
return; |
| 2064 |
} |
| 2065 |
/* compile unit */ |
| 2066 |
glflags.gf_cu_name_flag = TRUE; |
| 2067 |
tstr = do_uri_translation(dwoptarg,ctx); |
| 2068 |
if (!tstr) { |
| 2069 |
} |
| 2070 |
esb_append(glflags.cu_name,tstr); |
| 2071 |
} |
| 2072 |
|
| 2073 |
/* Option '-U' */ |
| 2074 |
void arg_format_suppress_uri(void) |
| 2075 |
{ |
| 2076 |
glflags.gf_uri_options_translation = FALSE; |
| 2077 |
} |
| 2078 |
|
| 2079 |
/* Option '-v' --verbose */ |
| 2080 |
void arg_verbose(void) |
| 2081 |
{ |
| 2082 |
glflags.verbose++; |
| 2083 |
} |
| 2084 |
/* Option '--show-dwarfdump-conf' */ |
| 2085 |
void arg_show_dwarfdump_conf(void) |
| 2086 |
{ |
| 2087 |
glflags.gf_show_dwarfdump_conf++; |
| 2088 |
} |
| 2089 |
/* Option '--show-args' |
| 2090 |
which causes dwarfdump to print the current |
| 2091 |
version of the program, date, and time of the run, |
| 2092 |
and to show the command line arguments. */ |
| 2093 |
void arg_show_args(void) |
| 2094 |
{ |
| 2095 |
glflags.gf_show_args_flag = TRUE; |
| 2096 |
print_version_details(glflags.program_fullname); |
| 2097 |
} |
| 2098 |
|
| 2099 |
/* Option '-V' */ |
| 2100 |
void arg_version(void) |
| 2101 |
{ |
| 2102 |
/* Display dwarfdump compilation date and time */ |
| 2103 |
print_version_details(glflags.program_fullname); |
| 2104 |
arg_show_args(); |
| 2105 |
makename_destructor(); |
| 2106 |
global_destructors(); |
| 2107 |
exit(OKAY); |
| 2108 |
} |
| 2109 |
|
| 2110 |
/* Option '-w' */ |
| 2111 |
void arg_print_weaknames(void) |
| 2112 |
{ |
| 2113 |
/* .debug_weaknames */ |
| 2114 |
glflags.gf_weakname_flag = TRUE; |
| 2115 |
suppress_check_dwarf(); |
| 2116 |
} |
| 2117 |
|
| 2118 |
/* Option '-W[...]' */ |
| 2119 |
void arg_W_multiple_selection(void) |
| 2120 |
{ |
| 2121 |
if (dwoptarg) { |
| 2122 |
if (!dwoptarg[0]) { |
| 2123 |
arg_usage_error = TRUE; |
| 2124 |
return; |
| 2125 |
} |
| 2126 |
switch (dwoptarg[0]) { |
| 2127 |
case 'c': arg_search_print_children(); break; |
| 2128 |
case 'p': arg_search_print_parent(); break; |
| 2129 |
default: arg_usage_error = TRUE; break; |
| 2130 |
} |
| 2131 |
} else { |
| 2132 |
arg_search_print_tree(); |
| 2133 |
} |
| 2134 |
} |
| 2135 |
|
| 2136 |
/* Option '-W' */ |
| 2137 |
void arg_search_print_tree(void) |
| 2138 |
{ |
| 2139 |
/* Search results in wide format */ |
| 2140 |
glflags.gf_search_wide_format = TRUE; |
| 2141 |
|
| 2142 |
/* -W : Display parent and children tree */ |
| 2143 |
glflags.gf_display_children_tree = TRUE; |
| 2144 |
glflags.gf_display_parent_tree = TRUE; |
| 2145 |
} |
| 2146 |
|
| 2147 |
/* Option '-Wc' */ |
| 2148 |
void arg_search_print_children(void) |
| 2149 |
{ |
| 2150 |
/* -Wc : Display children tree */ |
| 2151 |
arg_search_print_tree(); |
| 2152 |
glflags.gf_display_children_tree = TRUE; |
| 2153 |
glflags.gf_display_parent_tree = FALSE; |
| 2154 |
} |
| 2155 |
|
| 2156 |
/* Option '-Wp' */ |
| 2157 |
void arg_search_print_parent(void) |
| 2158 |
{ |
| 2159 |
/* -Wp : Display parent tree */ |
| 2160 |
arg_search_print_tree(); |
| 2161 |
glflags.gf_display_children_tree = FALSE; |
| 2162 |
glflags.gf_display_parent_tree = TRUE; |
| 2163 |
} |
| 2164 |
|
| 2165 |
/* Option '-x[...]' */ |
| 2166 |
void arg_x_multiple_selection(void) |
| 2167 |
{ |
| 2168 |
if (!dwoptarg || !dwoptarg[0]) { |
| 2169 |
arg_usage_error = TRUE; |
| 2170 |
return; |
| 2171 |
} |
| 2172 |
if (strncmp(dwoptarg,"name=",5) == 0) { |
| 2173 |
dwoptarg = &dwoptarg[5]; |
| 2174 |
arg_file_name(); |
| 2175 |
} else if (strncmp(dwoptarg,"abi=",4) == 0) { |
| 2176 |
dwoptarg = &dwoptarg[4]; |
| 2177 |
arg_file_abi(); |
| 2178 |
} else if (strncmp(dwoptarg,"groupnumber=",12) == 0) { |
| 2179 |
dwoptarg = &dwoptarg[12]; |
| 2180 |
arg_format_groupnumber(); |
| 2181 |
} else if (strncmp(dwoptarg,"universalnumber=",16) == 0) { |
| 2182 |
dwoptarg = &dwoptarg[12]; |
| 2183 |
arg_format_universalnumber(); |
| 2184 |
} else if (strncmp(dwoptarg,"tied=",5) == 0) { |
| 2185 |
dwoptarg = &dwoptarg[5]; |
| 2186 |
arg_file_tied(); |
| 2187 |
} else if (strncmp(dwoptarg,"line5=",6) == 0) { |
| 2188 |
dwoptarg = &dwoptarg[6]; |
| 2189 |
arg_file_line5(); |
| 2190 |
} else if (strcmp(dwoptarg,"nosanitizestrings") == 0) { |
| 2191 |
arg_format_suppress_sanitize(); |
| 2192 |
} else if (strcmp(dwoptarg,"noprintsectiongroups") == 0) { |
| 2193 |
arg_format_suppress_group(); |
| 2194 |
} else { |
| 2195 |
arg_x_invalid(); |
| 2196 |
} |
| 2197 |
} |
| 2198 |
|
| 2199 |
/* Option '-x abi=' */ |
| 2200 |
static void |
| 2201 |
arg_file_abi(void) |
| 2202 |
{ |
| 2203 |
const char *ctx = arg_option > OPT_BEGIN ? |
| 2204 |
"--file-abi=" : "-x abi="; |
| 2205 |
const char *abi = 0; |
| 2206 |
|
| 2207 |
if (!dwoptarg || !dwoptarg[0]) { |
| 2208 |
printf("ERROR *abi= does not allow an empty text\n"); |
| 2209 |
glflags.gf_count_major_errors++; |
| 2210 |
arg_usage_error = TRUE; |
| 2211 |
return; |
| 2212 |
} |
| 2213 |
/* -x abi=<abi> meaning select abi from dwarfdump.conf |
| 2214 |
file. Must always select abi to use dwarfdump.conf */ |
| 2215 |
abi = do_uri_translation(dwoptarg,ctx); |
| 2216 |
if (strlen(abi) > 0) { |
| 2217 |
config_file_abi = abi; |
| 2218 |
} else { |
| 2219 |
arg_x_invalid(); |
| 2220 |
} |
| 2221 |
} |
| 2222 |
|
| 2223 |
/* Option '-x universalnumber=' |
| 2224 |
greater than zero only applies to Mach-O universal |
| 2225 |
object files*/ |
| 2226 |
static void |
| 2227 |
arg_format_universalnumber(void) |
| 2228 |
{ |
| 2229 |
/* By default prints the lowest universal number in the object. |
| 2230 |
Default is -x universalnumber=0 */ |
| 2231 |
|
| 2232 |
long int gnum = 0; |
| 2233 |
int res = 0; |
| 2234 |
|
| 2235 |
if (!dwoptarg || !dwoptarg[0]) { |
| 2236 |
printf("ERROR *groupnumber= does not allow an empty text\n"); |
| 2237 |
glflags.gf_count_major_errors++; |
| 2238 |
arg_usage_error = TRUE; |
| 2239 |
return; |
| 2240 |
} |
| 2241 |
res = get_number_value(dwoptarg,&gnum); |
| 2242 |
if (res == DW_DLV_OK && gnum >= 0) { |
| 2243 |
glflags.gf_universalnumber = gnum; |
| 2244 |
} else { |
| 2245 |
arg_x_invalid(); |
| 2246 |
} |
| 2247 |
} |
| 2248 |
|
| 2249 |
/* Option '-x groupnumber=' */ |
| 2250 |
static void |
| 2251 |
arg_format_groupnumber(void) |
| 2252 |
{ |
| 2253 |
/* By default prints the lowest groupnumber in the object. |
| 2254 |
Default is -x groupnumber=0 |
| 2255 |
For group 1 (standard base dwarfdata) |
| 2256 |
-x groupnumber=1 |
| 2257 |
For group 1 (DWARF5 .dwo sections and dwp data) |
| 2258 |
-x groupnumber=2 */ |
| 2259 |
long int gnum = 0; |
| 2260 |
int res = 0; |
| 2261 |
|
| 2262 |
if (!dwoptarg || !dwoptarg[0]) { |
| 2263 |
printf("ERROR *groupnumber= does not allow an empty text\n"); |
| 2264 |
glflags.gf_count_major_errors++; |
| 2265 |
arg_usage_error = TRUE; |
| 2266 |
return; |
| 2267 |
} |
| 2268 |
res = get_number_value(dwoptarg,&gnum); |
| 2269 |
if (res == DW_DLV_OK) { |
| 2270 |
glflags.group_number = gnum; |
| 2271 |
} else { |
| 2272 |
arg_x_invalid(); |
| 2273 |
} |
| 2274 |
} |
| 2275 |
|
| 2276 |
/* Option '-x line5=' --file-line5=<v> */ |
| 2277 |
static void |
| 2278 |
arg_file_line5(void) |
| 2279 |
{ |
| 2280 |
if (!dwoptarg || !dwoptarg[0]) { |
| 2281 |
printf("ERROR *line5= does not allow an empty text\n"); |
| 2282 |
glflags.gf_count_major_errors++; |
| 2283 |
arg_usage_error = TRUE; |
| 2284 |
return; |
| 2285 |
} |
| 2286 |
if (!strcmp(dwoptarg,"std")) { |
| 2287 |
glflags.gf_line_flag_selection = singledw5; |
| 2288 |
} else if (!strcmp(dwoptarg,"s2l")) { |
| 2289 |
glflags.gf_line_flag_selection= s2l; |
| 2290 |
} else if (!strcmp(dwoptarg,"orig")) { |
| 2291 |
/* drop orig */ |
| 2292 |
glflags.gf_line_flag_selection= singledw5; |
| 2293 |
} else if (!strcmp(dwoptarg,"orig2l")) { |
| 2294 |
/* drop orig2l */ |
| 2295 |
glflags.gf_line_flag_selection= s2l; |
| 2296 |
} else { |
| 2297 |
arg_x_invalid(); |
| 2298 |
} |
| 2299 |
} |
| 2300 |
|
| 2301 |
/* Option '-x name=' */ |
| 2302 |
static void arg_file_name(void) |
| 2303 |
{ |
| 2304 |
const char *ctx = arg_option > OPT_BEGIN ? |
| 2305 |
"--file-name=" : "-x name="; |
| 2306 |
const char *path = 0; |
| 2307 |
|
| 2308 |
if (!dwoptarg || !dwoptarg[0]) { |
| 2309 |
printf("ERROR *name= does not allow an empty text\n"); |
| 2310 |
glflags.gf_count_major_errors++; |
| 2311 |
arg_usage_error = TRUE; |
| 2312 |
return; |
| 2313 |
} |
| 2314 |
/* -x name=<path> meaning name dwarfdump.conf file. */ |
| 2315 |
path = do_uri_translation(dwoptarg,ctx); |
| 2316 |
if (strlen(path) > 0) { |
| 2317 |
esb_empty_string(glflags.config_file_path); |
| 2318 |
esb_append(glflags.config_file_path,path); |
| 2319 |
} else { |
| 2320 |
arg_x_invalid(); |
| 2321 |
} |
| 2322 |
} |
| 2323 |
|
| 2324 |
/* Option '-x noprintsectiongroups' */ |
| 2325 |
static void arg_format_suppress_group(void) |
| 2326 |
{ |
| 2327 |
glflags.gf_section_groups_flag = FALSE; |
| 2328 |
} |
| 2329 |
|
| 2330 |
/* Option '-x nosanitizestrings' '--format-suppress-sanitize' */ |
| 2331 |
static void arg_format_suppress_sanitize(void) |
| 2332 |
{ |
| 2333 |
glflags.gf_no_sanitize_strings = TRUE; |
| 2334 |
} |
| 2335 |
|
| 2336 |
/* Option '-x tied=' */ |
| 2337 |
static void arg_file_tied(void) |
| 2338 |
{ |
| 2339 |
const char *ctx = arg_option > OPT_BEGIN ? |
| 2340 |
"--file-tied=" : "-x tied="; |
| 2341 |
const char *tiedpath = 0; |
| 2342 |
|
| 2343 |
if (!dwoptarg || !dwoptarg[0]) { |
| 2344 |
printf("ERROR *tied= does not allow an empty text\n"); |
| 2345 |
glflags.gf_count_major_errors++; |
| 2346 |
arg_usage_error = TRUE; |
| 2347 |
return; |
| 2348 |
} |
| 2349 |
tiedpath = do_uri_translation(dwoptarg,ctx); |
| 2350 |
if (strlen(tiedpath) > 0) { |
| 2351 |
esb_empty_string(glflags.config_file_tiedpath); |
| 2352 |
esb_append(glflags.config_file_tiedpath,tiedpath); |
| 2353 |
} else { |
| 2354 |
arg_x_invalid(); |
| 2355 |
} |
| 2356 |
} |
| 2357 |
|
| 2358 |
/* Option '--file-use-no-libelf' */ |
| 2359 |
static void arg_file_use_no_libelf(void) |
| 2360 |
{ |
| 2361 |
glflags.gf_file_use_no_libelf = TRUE; |
| 2362 |
} |
| 2363 |
|
| 2364 |
/* -y */ |
| 2365 |
static void arg_print_types(void) |
| 2366 |
{ |
| 2367 |
/* .debug_pubtypes */ |
| 2368 |
/* Also for SGI-only, and obsolete, .debug_typenames */ |
| 2369 |
suppress_check_dwarf(); |
| 2370 |
glflags.gf_pubtypes_flag = TRUE; |
| 2371 |
} |
| 2372 |
|
| 2373 |
/* Option not supported */ |
| 2374 |
static void arg_not_supported(void) |
| 2375 |
{ |
| 2376 |
printf("ERROR Option -%c is no longer supported:ignored\n", |
| 2377 |
arg_option); |
| 2378 |
glflags.gf_count_major_errors++; |
| 2379 |
} |
| 2380 |
|
| 2381 |
/* Error message for --add-debuglink-path=path */ |
| 2382 |
static void arg_debuglink_path_invalid(void) |
| 2383 |
{ |
| 2384 |
printf("--add-debuglink-path=<text>\n"); |
| 2385 |
/* Add quotes around string so any invisible chars |
| 2386 |
kind of show up */ |
| 2387 |
if (!dwoptarg || !dwoptarg[0]) { |
| 2388 |
printf("is allowed, not an empty <text>\n"); |
| 2389 |
} else { |
| 2390 |
printf("is allowed, not \"%s\"\n",dwoptarg); |
| 2391 |
} |
| 2392 |
glflags.gf_count_major_errors++; |
| 2393 |
arg_usage_error = TRUE; |
| 2394 |
|
| 2395 |
} |
| 2396 |
/* Error message for invalid '-S' option. */ |
| 2397 |
static void arg_search_invalid(void) |
| 2398 |
{ |
| 2399 |
printf("-S any=<text> or -S match=<text> or" |
| 2400 |
" -S regex=<text>\n"); |
| 2401 |
if (!dwoptarg || !dwoptarg[0]) { |
| 2402 |
printf("is allowed, not an empty <text>\n"); |
| 2403 |
} else { |
| 2404 |
printf("is allowed, not -S %s\n",dwoptarg); |
| 2405 |
} |
| 2406 |
arg_usage_error = TRUE; |
| 2407 |
glflags.gf_count_major_errors++; |
| 2408 |
} |
| 2409 |
|
| 2410 |
/* Error message for invalid '-x' option. */ |
| 2411 |
static void arg_x_invalid(void) |
| 2412 |
{ |
| 2413 |
printf("-x name=<path-to-conf> \n"); |
| 2414 |
printf(" and \n"); |
| 2415 |
printf("-x abi=<abi-in-conf> \n"); |
| 2416 |
printf(" and \n"); |
| 2417 |
printf("-x tied=<tied-file-path> \n"); |
| 2418 |
printf(" and \n"); |
| 2419 |
printf("-x line5={std,s2l,orig,orig2l} \n"); |
| 2420 |
printf(" and \n"); |
| 2421 |
printf("-x nosanitizestrings \n"); |
| 2422 |
if (!dwoptarg || !dwoptarg[0]) { |
| 2423 |
printf("is allowed, not an empty text after the =\n"); |
| 2424 |
} else { |
| 2425 |
printf("are legal, not -x %s\n", dwoptarg); |
| 2426 |
} |
| 2427 |
arg_usage_error = TRUE; |
| 2428 |
glflags.gf_count_major_errors++; |
| 2429 |
} |
| 2430 |
|
| 2431 |
/* Process the command line arguments and set the |
| 2432 |
appropriate options. All |
| 2433 |
the options are within the global flags structure. */ |
| 2434 |
static void |
| 2435 |
set_command_options(int argc, char *argv[]) |
| 2436 |
{ |
| 2437 |
int longindex = 0; |
| 2438 |
|
| 2439 |
/* j unused */ |
| 2440 |
while ((arg_option = dwgetopt_long(argc, argv, |
| 2441 |
"#:abc::CdDeE::fFgGhH:iIk:l::mMnNo::O:pPqQrRsS:t:" |
| 2442 |
"u:UvVwW::x:yz", |
| 2443 |
longopts,&longindex)) != EOF) { |
| 2444 |
|
| 2445 |
switch (arg_option) { |
| 2446 |
case '#': arg_trace(); break; |
| 2447 |
case 'a': arg_print_all(); break; |
| 2448 |
case 'b': arg_print_abbrev(); break; |
| 2449 |
case 'c': arg_c_multiple_selection(); break; |
| 2450 |
case 'C': arg_format_extensions(); break; |
| 2451 |
case 'd': arg_format_dense(); break; |
| 2452 |
case 'D': arg_format_suppress_offsets(); break; |
| 2453 |
case 'e': arg_format_ellipsis(); break; |
| 2454 |
case 'f': arg_print_debug_frame(); break; |
| 2455 |
case 'F': arg_print_gnu_frame(); break; |
| 2456 |
case 'g': arg_format_loc(); break; |
| 2457 |
case 'G': arg_format_global_offsets(); break; |
| 2458 |
case 'h': arg_h_multiple_selection(); break; |
| 2459 |
case 'H': arg_format_limit(); break; |
| 2460 |
case 'i': arg_print_info(); break; |
| 2461 |
case 'I': arg_print_fission(); break; |
| 2462 |
case 'k': arg_k_multiple_selection(); break; |
| 2463 |
case 'l': arg_l_multiple_selection(); break; |
| 2464 |
case 'm': arg_print_macinfo(); break; |
| 2465 |
case 'M': arg_format_attr_name(); break; |
| 2466 |
case 'n': arg_format_suppress_lookup(); break; |
| 2467 |
case 'N': arg_print_ranges(); break; |
| 2468 |
case 'O': arg_O_multiple_selection(); break; |
| 2469 |
case 'p': arg_print_pubnames(); break; |
| 2470 |
case 'P': arg_print_producers(); break; |
| 2471 |
case 'q': arg_format_suppress_uri_msg(); break; |
| 2472 |
case 'Q': arg_format_suppress_data(); break; |
| 2473 |
case 'r': arg_print_aranges(); break; |
| 2474 |
case 'R': arg_format_registers(); break; |
| 2475 |
case 's': arg_print_strings(); break; |
| 2476 |
case 'S': arg_S_multiple_selection(); break; |
| 2477 |
case 't': arg_t_multiple_selection(); break; |
| 2478 |
case 'u': arg_format_file(); break; |
| 2479 |
case 'U': arg_format_suppress_uri(); break; |
| 2480 |
case 'v': arg_verbose(); break; |
| 2481 |
case 'V': arg_version(); break; |
| 2482 |
case 'w': arg_print_weaknames(); break; |
| 2483 |
case 'W': arg_W_multiple_selection(); break; |
| 2484 |
case 'x': arg_x_multiple_selection(); break; |
| 2485 |
case 'y': arg_print_types(); break; |
| 2486 |
case 'z': arg_not_supported(); break; |
| 2487 |
|
| 2488 |
/* Check DWARF Integrity. */ |
| 2489 |
case OPT_CHECK_ABBREV: arg_check_abbrev(); break; |
| 2490 |
case OPT_CHECK_ALL: arg_check_all(); break; |
| 2491 |
case OPT_CHECK_ARANGES: arg_check_aranges(); break; |
| 2492 |
case OPT_CHECK_ATTR_DUP: arg_check_attr_dup(); break; |
| 2493 |
case OPT_CHECK_ATTR_ENCODINGS: arg_check_attr_encodings(); |
| 2494 |
break; |
| 2495 |
case OPT_CHECK_ATTR_NAMES: arg_check_attr_names();break; |
| 2496 |
case OPT_CHECK_CONSTANTS: arg_check_constants(); break; |
| 2497 |
case OPT_CHECK_FILES_LINES: arg_check_files_lines(); |
| 2498 |
break; |
| 2499 |
case OPT_CHECK_FORWARD_REFS: arg_check_forward_refs(); |
| 2500 |
break; |
| 2501 |
case OPT_CHECK_FRAME_BASIC: arg_check_frame_basic(); |
| 2502 |
break; |
| 2503 |
case OPT_CHECK_FRAME_EXTENDED: arg_check_frame_extended(); |
| 2504 |
break; |
| 2505 |
case OPT_CHECK_FRAME_INFO: arg_check_frame_info();break; |
| 2506 |
case OPT_CHECK_GAPS: arg_check_gaps(); break; |
| 2507 |
case OPT_CHECK_LOC: arg_check_loc(); break; |
| 2508 |
case OPT_CHECK_MACROS: arg_check_macros(); break; |
| 2509 |
case OPT_CHECK_PUBNAMES: arg_check_pubnames(); break; |
| 2510 |
case OPT_CHECK_RANGES: arg_check_ranges(); break; |
| 2511 |
case OPT_CHECK_SELF_REFS: arg_check_self_refs();break; |
| 2512 |
case OPT_CHECK_SHOW: arg_check_show(); break; |
| 2513 |
case OPT_CHECK_SILENT: arg_check_silent(); break; |
| 2514 |
case OPT_CHECK_SUMMARY: arg_check_summary(); break; |
| 2515 |
case OPT_CHECK_TAG_ATTR: arg_check_tag_attr(); break; |
| 2516 |
case OPT_CHECK_TAG_TAG: arg_check_tag_tag(); break; |
| 2517 |
case OPT_CHECK_TYPE: arg_check_type(); break; |
| 2518 |
case OPT_CHECK_UNIQUE: arg_check_unique(); break; |
| 2519 |
case OPT_CHECK_USAGE: arg_check_usage();break; |
| 2520 |
case OPT_CHECK_USAGE_EXTENDED: arg_check_usage_extended(); |
| 2521 |
break; |
| 2522 |
case OPT_CHECK_FUNCTIONS: arg_check_functions(); break; |
| 2523 |
|
| 2524 |
/* File Specifications. */ |
| 2525 |
case OPT_FILE_ABI: arg_file_abi(); break; |
| 2526 |
case OPT_FILE_LINE5: arg_file_line5(); break; |
| 2527 |
case OPT_FILE_NAME: arg_file_name(); break; |
| 2528 |
case OPT_FILE_OUTPUT: arg_file_output(); break; |
| 2529 |
case OPT_FILE_TIED: arg_file_tied(); break; |
| 2530 |
case OPT_FILE_USE_NO_LIBELF: arg_file_use_no_libelf(); break; |
| 2531 |
|
| 2532 |
/* Print Output Qualifiers. */ |
| 2533 |
case OPT_FORMAT_ATTR_NAME: |
| 2534 |
arg_format_attr_name(); break; |
| 2535 |
case OPT_FORMAT_DENSE: |
| 2536 |
arg_format_dense(); break; |
| 2537 |
case OPT_FORMAT_ELLIPSIS: |
| 2538 |
arg_format_ellipsis(); break; |
| 2539 |
case OPT_FORMAT_EXPR_OPS_JOINED: |
| 2540 |
arg_format_expr_ops_joined(); break; |
| 2541 |
case OPT_FORMAT_EXTENSIONS: |
| 2542 |
arg_format_extensions(); break; |
| 2543 |
case OPT_FORMAT_GLOBAL_OFFSETS: |
| 2544 |
arg_format_global_offsets(); break; |
| 2545 |
case OPT_FORMAT_LOC: |
| 2546 |
arg_format_loc(); break; |
| 2547 |
case OPT_FORMAT_REGISTERS: |
| 2548 |
arg_format_registers(); break; |
| 2549 |
case OPT_FORMAT_SUPPRESS_DATA: |
| 2550 |
arg_format_suppress_data(); break; |
| 2551 |
case OPT_FORMAT_SUPPRESS_GROUP: |
| 2552 |
arg_format_suppress_group(); break; |
| 2553 |
case OPT_FORMAT_SUPPRESS_OFFSETS: |
| 2554 |
arg_format_suppress_offsets(); break; |
| 2555 |
case OPT_FORMAT_SUPPRESS_LOOKUP: |
| 2556 |
arg_format_suppress_lookup(); break; |
| 2557 |
case OPT_FORMAT_SUPPRESS_SANITIZE: |
| 2558 |
arg_format_suppress_sanitize();break; |
| 2559 |
case OPT_FORMAT_SUPPRESS_URI: |
| 2560 |
arg_format_suppress_uri(); break; |
| 2561 |
case OPT_FORMAT_SUPPRESS_URI_MSG: |
| 2562 |
arg_format_suppress_uri_msg(); break; |
| 2563 |
case OPT_FORMAT_SUPPRESS_UTF8: |
| 2564 |
arg_format_suppress_utf8(); break; |
| 2565 |
|
| 2566 |
/* Print Output Limiters. */ |
| 2567 |
case OPT_FORMAT_FILE: arg_format_file(); break; |
| 2568 |
case OPT_FORMAT_GCC: arg_format_gcc(); break; |
| 2569 |
case OPT_FORMAT_GROUP_NUMBER: arg_format_groupnumber(); break; |
| 2570 |
case OPT_FORMAT_UNIVERSALNUMBER: arg_format_universalnumber(); |
| 2571 |
break; |
| 2572 |
case OPT_FORMAT_LIMIT: arg_format_limit(); break; |
| 2573 |
case OPT_FORMAT_PRODUCER: arg_format_producer(); break; |
| 2574 |
case OPT_FORMAT_SNC: arg_format_snc(); break; |
| 2575 |
|
| 2576 |
/* Print Debug Sections. */ |
| 2577 |
case OPT_PRINT_ABBREV: arg_print_abbrev(); break; |
| 2578 |
case OPT_PRINT_ALL: arg_print_all(); break; |
| 2579 |
case OPT_PRINT_ARANGES: arg_print_aranges(); break; |
| 2580 |
case OPT_PRINT_DEBUG_NAMES: arg_print_debug_names(); break; |
| 2581 |
case OPT_PRINT_DEBUG_ADDR: arg_print_debug_addr(); break; |
| 2582 |
case OPT_PRINT_GNU_DEBUGLINK: arg_print_gnu_debuglink(); |
| 2583 |
break; |
| 2584 |
case OPT_PRINT_DEBUG_GNU: arg_print_debug_gnu(); break; |
| 2585 |
case OPT_PRINT_DEBUG_SUP: arg_print_debug_sup(); break; |
| 2586 |
case OPT_PRINT_EH_FRAME: arg_print_gnu_frame(); break; |
| 2587 |
case OPT_PRINT_FISSION: arg_print_fission(); break; |
| 2588 |
case OPT_PRINT_FRAME: arg_print_debug_frame(); break; |
| 2589 |
case OPT_PRINT_INFO: arg_print_info(); break; |
| 2590 |
case OPT_PRINT_LINES: arg_print_lines(); break; |
| 2591 |
case OPT_PRINT_LINES_SHORT: arg_print_lines_short(); break; |
| 2592 |
case OPT_PRINT_LOC: arg_print_loc(); break; |
| 2593 |
case OPT_PRINT_MACINFO: arg_print_macinfo(); break; |
| 2594 |
case OPT_PRINT_MACHINE_ARCH: arg_print_machine_arch(); break; |
| 2595 |
case OPT_PRINT_PRODUCERS: arg_print_producers(); break; |
| 2596 |
case OPT_PRINT_PUBNAMES: arg_print_pubnames(); break; |
| 2597 |
case OPT_PRINT_RANGES: arg_print_ranges(); break; |
| 2598 |
case OPT_PRINT_RAW_LOCLISTS:arg_print_raw_loclists();break; |
| 2599 |
case OPT_PRINT_RAW_RNGLISTS:arg_print_raw_rnglists();break; |
| 2600 |
case OPT_PRINT_STATIC: arg_print_static(); break; |
| 2601 |
case OPT_PRINT_STATIC_FUNC: arg_print_static_func(); break; |
| 2602 |
case OPT_PRINT_STATIC_VAR: arg_print_static_var(); break; |
| 2603 |
case OPT_PRINT_STRINGS: arg_print_strings(); break; |
| 2604 |
case OPT_PRINT_STR_OFFSETS: arg_print_str_offsets(); break; |
| 2605 |
case OPT_PRINT_TYPE: arg_print_types(); break; |
| 2606 |
case OPT_PRINT_WEAKNAME: arg_print_weaknames(); break; |
| 2607 |
|
| 2608 |
/* debuglink attributes */ |
| 2609 |
case OPT_NO_FOLLOW_DEBUGLINK: arg_no_follow_debuglink();break; |
| 2610 |
case OPT_ADD_DEBUGLINK_PATH: arg_add_debuglink_path(); break; |
| 2611 |
case OPT_SUPPRESS_DEBUGLINK_CRC: |
| 2612 |
arg_suppress_debuglink_crc(); break; |
| 2613 |
|
| 2614 |
/* Search text in attributes. */ |
| 2615 |
case OPT_SEARCH_ANY: arg_search_any(); |
| 2616 |
break; |
| 2617 |
case OPT_SEARCH_ANY_COUNT: arg_search_any_count(); |
| 2618 |
break; |
| 2619 |
case OPT_SEARCH_MATCH: arg_search_match(); |
| 2620 |
break; |
| 2621 |
case OPT_SEARCH_MATCH_COUNT: arg_search_match_count(); |
| 2622 |
break; |
| 2623 |
case OPT_SEARCH_PRINT_CHILDREN: arg_search_print_children(); |
| 2624 |
break; |
| 2625 |
case OPT_SEARCH_PRINT_PARENT: arg_search_print_parent(); |
| 2626 |
break; |
| 2627 |
case OPT_SEARCH_PRINT_TREE: arg_search_print_tree();break; |
| 2628 |
case OPT_SEARCH_REGEX: arg_search_regex();break; |
| 2629 |
case OPT_SEARCH_REGEX_COUNT: arg_search_regex_count(); |
| 2630 |
break; |
| 2631 |
|
| 2632 |
/* Help & Version. */ |
| 2633 |
case OPT_HELP: arg_help(); break; |
| 2634 |
case OPT_VERBOSE: arg_verbose(); break; |
| 2635 |
case OPT_VERBOSE_MORE: arg_verbose(); break; |
| 2636 |
case OPT_VERSION: arg_version(); break; |
| 2637 |
case OPT_SHOW_DWARFDUMP_CONF: |
| 2638 |
arg_show_dwarfdump_conf();break; |
| 2639 |
case OPT_SHOW_ARGS: |
| 2640 |
arg_show_args();break; |
| 2641 |
/* Trace. */ |
| 2642 |
case OPT_TRACE: arg_trace(); break; |
| 2643 |
|
| 2644 |
case OPT_ALLOC_TREE_OFF: |
| 2645 |
/* Suppress nearly all libdwarf de_alloc_tree |
| 2646 |
record keeping. */ |
| 2647 |
dwarf_set_de_alloc_flag(FALSE); |
| 2648 |
break; |
| 2649 |
|
| 2650 |
default: arg_usage_error = TRUE; break; |
| 2651 |
} |
| 2652 |
} |
| 2653 |
} |
| 2654 |
|
| 2655 |
/* This is a hack allowing us to pretend that |
| 2656 |
dwarfdump --suppress-de-alloc-tree foo.o |
| 2657 |
has no arguments. Because the args here really |
| 2658 |
are special for use by dwarfdump developers and |
| 2659 |
even with these special args we want do_all() to be |
| 2660 |
called by process_args() below if there are no |
| 2661 |
'normal' - or -- args. |
| 2662 |
And of course -v --verbose are special too. |
| 2663 |
So regression testing can behave identically |
| 2664 |
with or without the specials. |
| 2665 |
Function new March 6, 2020 */ |
| 2666 |
static const char *simplestdargs[] ={ |
| 2667 |
"-v", |
| 2668 |
"-vv", |
| 2669 |
"-vvv", |
| 2670 |
"-vvvv", |
| 2671 |
"-vvvvv", |
| 2672 |
"-vvvvvv", |
| 2673 |
"--verbose", |
| 2674 |
"--show-dwarfdump-conf", |
| 2675 |
"--show-args", |
| 2676 |
"--verbose-more", |
| 2677 |
"--suppress-de-alloc-tree", |
| 2678 |
"--suppress-debuglink-crc", |
| 2679 |
"--no-follow-debuglink", |
| 2680 |
0 |
| 2681 |
}; |
| 2682 |
|
| 2683 |
static int |
| 2684 |
lacking_normal_args (int argct,char **args) |
| 2685 |
{ |
| 2686 |
char * curarg = 0; |
| 2687 |
int i = 0; |
| 2688 |
|
| 2689 |
for ( i = 0; i < argct ; ++i) { |
| 2690 |
int k = 0; |
| 2691 |
int simple = FALSE; |
| 2692 |
curarg = args[i]; |
| 2693 |
if (curarg[0] != '-') { |
| 2694 |
/* Standard case. */ |
| 2695 |
return TRUE; |
| 2696 |
} |
| 2697 |
for (k = 0; simplestdargs[k]; ++k) { |
| 2698 |
if (!strcmp(curarg,simplestdargs[k])) { |
| 2699 |
simple = TRUE; |
| 2700 |
break; |
| 2701 |
} |
| 2702 |
} |
| 2703 |
if (simple) { |
| 2704 |
continue; |
| 2705 |
} |
| 2706 |
/* Not one of the specials, a normal argument, |
| 2707 |
so we have some 'real' args. */ |
| 2708 |
return FALSE; |
| 2709 |
} |
| 2710 |
/* Never found any non-simple argument, let regular |
| 2711 |
arg processing deal with it. */ |
| 2712 |
return TRUE; |
| 2713 |
} |
| 2714 |
|
| 2715 |
/* process arguments and return object filename */ |
| 2716 |
const char * |
| 2717 |
process_args(int argc, char *argv[]) |
| 2718 |
{ |
| 2719 |
/* the call sets up glflags.newprogname, returns its string */ |
| 2720 |
glflags.program_name = special_program_name(argv[0]); |
| 2721 |
glflags.program_fullname = argv[0]; |
| 2722 |
|
| 2723 |
suppress_check_dwarf(); |
| 2724 |
if (argv[1] && lacking_normal_args(argc-1,argv+1)) { |
| 2725 |
/* The default setting of what to print or do */ |
| 2726 |
do_all(); |
| 2727 |
} |
| 2728 |
glflags.gf_section_groups_flag = TRUE; |
| 2729 |
|
| 2730 |
/* Process the arguments and set the appropriate options. */ |
| 2731 |
set_command_options(argc, argv); |
| 2732 |
if (config_file_abi && glflags.gf_generic_1200_regs) { |
| 2733 |
printf("Specifying both -R and -x abi= is not " |
| 2734 |
"allowed. Use one " |
| 2735 |
"or the other. -x abi= ignored.\n"); |
| 2736 |
config_file_abi = 0; |
| 2737 |
} |
| 2738 |
{ |
| 2739 |
/* even with no abi we look as there may be |
| 2740 |
a dwarfdump option there we know about. */ |
| 2741 |
int res = 0; |
| 2742 |
res = find_conf_file_and_read_config( |
| 2743 |
esb_get_string(glflags.config_file_path), |
| 2744 |
config_file_abi, |
| 2745 |
config_file_defaults, |
| 2746 |
glflags.config_file_data); |
| 2747 |
if (res == FOUND_ERROR) { |
| 2748 |
if (!glflags.gf_do_print_dwarf && |
| 2749 |
!glflags.gf_do_check_dwarf) { |
| 2750 |
printf("Frame not configured due to " |
| 2751 |
"configure error(s).\n"); |
| 2752 |
printf("(Since no print or check options provided " |
| 2753 |
"dwarfdump may now silently exit)\n"); |
| 2754 |
} else { |
| 2755 |
printf("Frame not configured due to " |
| 2756 |
"configure error(s), " |
| 2757 |
"using generic 100 registers.\n" |
| 2758 |
"Frame section access suppressed.\n"); |
| 2759 |
glflags.gf_eh_frame_flag = FALSE; |
| 2760 |
glflags.gf_frame_flag = FALSE; |
| 2761 |
} |
| 2762 |
} else if (res == FOUND_DONE || res == FOUND_OPTION) { |
| 2763 |
if (glflags.gf_generic_1200_regs) { |
| 2764 |
init_generic_config_1200_regs( |
| 2765 |
glflags.config_file_data); |
| 2766 |
} |
| 2767 |
} else { |
| 2768 |
/* FOUND_ABI_START nothing to do. */ |
| 2769 |
} |
| 2770 |
} |
| 2771 |
if (arg_usage_error ) { |
| 2772 |
printf("%s option error.\n",glflags.program_name); |
| 2773 |
printf("To see the options list: %s -h\n", |
| 2774 |
glflags.program_name); |
| 2775 |
makename_destructor(); |
| 2776 |
global_destructors(); |
| 2777 |
exit(EXIT_FAILURE); |
| 2778 |
} |
| 2779 |
if (dwoptind < (argc - 1)) { |
| 2780 |
printf("Multiple apparent object file names " |
| 2781 |
"provided to %s\n",glflags.program_name); |
| 2782 |
printf("Only a single object name is allowed\n"); |
| 2783 |
printf("To see the options list: %s -h\n", |
| 2784 |
glflags.program_name); |
| 2785 |
makename_destructor(); |
| 2786 |
global_destructors(); |
| 2787 |
exit(EXIT_FAILURE); |
| 2788 |
} |
| 2789 |
if (dwoptind > (argc - 1)) { |
| 2790 |
printf("No object file name provided to %s\n", |
| 2791 |
glflags.program_name); |
| 2792 |
printf("To see the options list: %s -h\n", |
| 2793 |
glflags.program_name); |
| 2794 |
makename_destructor(); |
| 2795 |
global_destructors(); |
| 2796 |
exit(EXIT_FAILURE); |
| 2797 |
} |
| 2798 |
/* FIXME: it seems silly to be printing section names |
| 2799 |
where the section does not exist in the object file. |
| 2800 |
However we continue the long-standard practice |
| 2801 |
of printing such by default in most cases. For now. */ |
| 2802 |
if (glflags.group_number == DW_GROUPNUMBER_DWO) { |
| 2803 |
/* For split-dwarf/DWO some sections make no sense. |
| 2804 |
This prevents printing of meaningless headers where no |
| 2805 |
data can exist. */ |
| 2806 |
glflags.gf_pubnames_flag = FALSE; |
| 2807 |
glflags.gf_eh_frame_flag = FALSE; |
| 2808 |
glflags.gf_frame_flag = FALSE; |
| 2809 |
glflags.gf_macinfo_flag = FALSE; |
| 2810 |
glflags.gf_aranges_flag = FALSE; |
| 2811 |
glflags.gf_ranges_flag = FALSE; |
| 2812 |
glflags.gf_static_func_flag = FALSE; |
| 2813 |
glflags.gf_static_var_flag = FALSE; |
| 2814 |
glflags.gf_weakname_flag = FALSE; |
| 2815 |
} |
| 2816 |
if (glflags.group_number > DW_GROUPNUMBER_BASE) { |
| 2817 |
/* These no longer apply, no one uses. */ |
| 2818 |
glflags.gf_static_func_flag = FALSE; |
| 2819 |
glflags.gf_static_var_flag = FALSE; |
| 2820 |
glflags.gf_weakname_flag = FALSE; |
| 2821 |
glflags.gf_pubnames_flag = FALSE; |
| 2822 |
} |
| 2823 |
|
| 2824 |
if (glflags.gf_do_check_dwarf) { |
| 2825 |
/* Reduce verbosity when checking |
| 2826 |
(checking means checking-only). */ |
| 2827 |
glflags.verbose = 1; |
| 2828 |
} |
| 2829 |
return do_uri_translation(argv[dwoptind],"file-to-process"); |
| 2830 |
} |