diff options
author | Ian Lance Taylor <ian@airs.com> | 2008-03-24 03:48:29 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2008-03-24 03:48:29 +0000 |
commit | 086a18414ad6c07d0ee79990a971fdc7387af7c1 (patch) | |
tree | ec8a34804f770463ee55114f4981658beb878413 /gold/options.cc | |
parent | b5615ead1bf14f1ac87c310f20f63ed74adc46e8 (diff) | |
download | gdb-086a18414ad6c07d0ee79990a971fdc7387af7c1.zip gdb-086a18414ad6c07d0ee79990a971fdc7387af7c1.tar.gz gdb-086a18414ad6c07d0ee79990a971fdc7387af7c1.tar.bz2 |
* options.cc: Include "demangle.h".
(parse_optional_string): New function.
(parse_long_option): Handle takes_optional_argument.
(parse_short_option): Update dash_z initializer. Handle
takes_optional_argument.
(General_options::General_options): Initialize do_demangle_.
(General_options::finalize): Set do_demangle_. Handle demangling
style.
* options.h (parse_optional_string): Declare.
(struct One_option): Add optional_arg field. Update constructor.
Update call constructor calls. Add takes_optional_argument
function.
(DEFINE_var): Add optional_arg__ parameter. Change all callers.
(DEFINE_optional_string): Define.
(General_options::demangle): Change from DEFINE_bool to
DEFINE_optional_string.
(General_options::no_demangle): New function.
(General_options::do_demangle): New function.
(General_options::set_do_demangle): New function.
(General_options::execstack_status_): Move definition to end of
class definition.
(General_options::static_): Likewise.
(General_options::do_demangle_): New field.
* object.cc (big_endian>::get_symbol_location_info): Call
Options::do_demangle, not Options::demangle.
* symtab.cc (demangle): Likewise.
Diffstat (limited to 'gold/options.cc')
-rw-r--r-- | gold/options.cc | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/gold/options.cc b/gold/options.cc index 916ccf4..46d84cf 100644 --- a/gold/options.cc +++ b/gold/options.cc @@ -28,6 +28,7 @@ #include <sys/stat.h> #include "filenames.h" #include "libiberty.h" +#include "demangle.h" #include "debug.h" #include "script.h" @@ -191,6 +192,12 @@ parse_string(const char* option_name, const char* arg, const char** retval) } void +parse_optional_string(const char*, const char* arg, const char** retval) +{ + *retval = arg; +} + +void parse_dirlist(const char*, const char* arg, Dir_list* retval) { retval->push_back(Search_directory(arg, false)); @@ -466,6 +473,8 @@ parse_long_option(int argc, const char** argv, bool equals_only, { if (equals) *arg = equals + 1; + else if (retval->takes_optional_argument()) + *arg = retval->default_value; else if (*i < argc && !equals_only) *arg = argv[(*i)++]; else @@ -496,7 +505,8 @@ parse_short_option(int argc, const char** argv, int pos_in_argv_i, // We handle -z as a special case. static gold::options::One_option dash_z("", gold::options::DASH_Z, - 'z', "", "-z", "Z-OPTION", NULL); + 'z', "", "-z", "Z-OPTION", false, + NULL); gold::options::One_option* retval = NULL; if (this_argv[pos_in_argv_i] == 'z') retval = &dash_z; @@ -524,6 +534,8 @@ parse_short_option(int argc, const char** argv, int pos_in_argv_i, ++(*i); if (this_argv[pos_in_argv_i + 1] != '\0') *arg = this_argv + pos_in_argv_i + 1; + else if (retval->takes_optional_argument()) + *arg = retval->default_value; else if (*i < argc) *arg = argv[(*i)++]; else @@ -550,7 +562,8 @@ namespace gold { General_options::General_options() - : execstack_status_(General_options::EXECSTACK_FROM_INPUT), static_(false) + : execstack_status_(General_options::EXECSTACK_FROM_INPUT), static_(false), + do_demangle_(false) { } @@ -629,6 +642,30 @@ General_options::finalize() else if (this->noexecstack()) this->set_execstack_status(EXECSTACK_NO); + // Handle the optional argument for --demangle. + if (this->user_set_demangle()) + { + this->set_do_demangle(true); + const char* style = this->demangle(); + if (*style != '\0') + { + enum demangling_styles style_code; + + style_code = cplus_demangle_name_to_style(style); + if (style_code == unknown_demangling) + gold_fatal("unknown demangling style '%s'", style); + cplus_demangle_set_style(style_code); + } + } + else if (this->user_set_no_demangle()) + this->set_do_demangle(false); + else + { + // Testing COLLECT_NO_DEMANGLE makes our default demangling + // behaviour identical to that of gcc's linker wrapper. + this->set_do_demangle(getenv("COLLECT_NO_DEMANGLE") == NULL); + } + // If --thread_count is specified, it applies to // --thread-count-{initial,middle,final}, though it doesn't override // them. |