forked from Imagelibrary/binutils-gdb
gdb: remove language_auto
I think that the language_auto enumerator and the auto_language class can be removed. There isn't really an "auto" language, it's only a construct of the "set language" command to say "pick the appropriate language automatically". But "auto" is never the current language. The `current_language` points to the current effective language, and the fact that we're in "auto language" mode is noted by the language_mode global. - Change set_language to handle the "auto" (and "local", which is a synonym) early, instead of in the for loop. I think it makes the two cases (auto vs explicit language) more clearly separated anyway. - Adjust add_set_language_command to hard-code the "auto" string, instead of using the "auto" language definition. - Remove auto_language, rename auto_or_unknown_language to unknown_language and move the bits of the existing unknown_language in there. - Remove the set_language at the end of _initialize_language. I think it's not needed, because we call set_language in gdb_init, after all _initialize functions are called. There is some chance that an _initialize function that runs after _initialize_language implicitly depends on current_language being set, but my testsuite runs haven't found anything like that. - Use language_unknown instead of language_auto when creating a minimal symbol (minimal_symbol_reader::record_full). I think that this value is used to indicate that we don't know the symbol of the minimal symbol (yet), so language_unknown makes sense to me. Update a condition accordingly in ada-lang.c. symbol_find_demangled_name also appears to "normalize" this value from "unknown" to "auto", remove that part and update the condition to just check for language_unknown. Change-Id: I47bcd6c15f607d9818f2e6e413053c2dc8ec5034 Reviewed-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
@@ -13700,7 +13700,7 @@ public:
|
|||||||
C++ symbols (using an old mangling scheme), such as "name__2Xn"
|
C++ symbols (using an old mangling scheme), such as "name__2Xn"
|
||||||
-> "Xn::name(void)" and thus some Ada minimal symbols end up
|
-> "Xn::name(void)" and thus some Ada minimal symbols end up
|
||||||
with the wrong language set. Paper over that issue here. */
|
with the wrong language set. Paper over that issue here. */
|
||||||
if (symbol_language == language_auto
|
if (symbol_language == language_unknown
|
||||||
|| symbol_language == language_cplus)
|
|| symbol_language == language_cplus)
|
||||||
symbol_language = language_ada;
|
symbol_language = language_ada;
|
||||||
|
|
||||||
|
|||||||
@@ -210,7 +210,6 @@ extern void quit_serial_event_clear (void);
|
|||||||
enum language
|
enum language
|
||||||
{
|
{
|
||||||
language_unknown, /* Language not known */
|
language_unknown, /* Language not known */
|
||||||
language_auto, /* Placeholder for automatic setting */
|
|
||||||
language_c, /* C */
|
language_c, /* C */
|
||||||
language_objc, /* Objective-C */
|
language_objc, /* Objective-C */
|
||||||
language_rust, /* Rust */
|
language_rust, /* Rust */
|
||||||
|
|||||||
@@ -142,16 +142,8 @@ set_language (const char *language)
|
|||||||
enum language flang = language_unknown;
|
enum language flang = language_unknown;
|
||||||
|
|
||||||
/* "local" is a synonym of "auto". */
|
/* "local" is a synonym of "auto". */
|
||||||
if (strcmp (language, "local") == 0)
|
if (strcmp (language, "auto") == 0
|
||||||
language = "auto";
|
|| strcmp (language, "local") == 0)
|
||||||
|
|
||||||
/* Search the list of languages for a match. */
|
|
||||||
for (const auto &lang : language_defn::languages)
|
|
||||||
{
|
|
||||||
if (strcmp (lang->name (), language) == 0)
|
|
||||||
{
|
|
||||||
/* Found it! Go into manual mode, and use this language. */
|
|
||||||
if (lang->la_language == language_auto)
|
|
||||||
{
|
{
|
||||||
/* Enter auto mode. Set to the current frame's language, if
|
/* Enter auto mode. Set to the current frame's language, if
|
||||||
known, or fallback to the initial language. */
|
known, or fallback to the initial language. */
|
||||||
@@ -172,20 +164,24 @@ set_language (const char *language)
|
|||||||
set_language (flang);
|
set_language (flang);
|
||||||
else
|
else
|
||||||
set_initial_language ();
|
set_initial_language ();
|
||||||
|
|
||||||
expected_language = current_language;
|
expected_language = current_language;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
/* Search the list of languages for a match. */
|
||||||
|
for (const auto &lang : language_defn::languages)
|
||||||
{
|
{
|
||||||
/* Enter manual mode. Set the specified language. */
|
if (strcmp (lang->name (), language) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Found it! Go into manual mode, and use this language. */
|
||||||
language_mode = language_mode_manual;
|
language_mode = language_mode_manual;
|
||||||
current_language = lang;
|
current_language = lang;
|
||||||
set_range_case ();
|
set_range_case ();
|
||||||
expected_language = current_language;
|
expected_language = current_language;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal_error ("Couldn't find language `%s' in known languages list.",
|
internal_error ("Couldn't find language `%s' in known languages list.",
|
||||||
language);
|
language);
|
||||||
@@ -434,9 +430,6 @@ language_enum (const char *str)
|
|||||||
if (strcmp (lang->name (), str) == 0)
|
if (strcmp (lang->name (), str) == 0)
|
||||||
return lang->la_language;
|
return lang->la_language;
|
||||||
|
|
||||||
if (strcmp (str, "local") == 0)
|
|
||||||
return language_auto;
|
|
||||||
|
|
||||||
return language_unknown;
|
return language_unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,22 +461,21 @@ add_set_language_command ()
|
|||||||
static const char **language_names;
|
static const char **language_names;
|
||||||
|
|
||||||
/* Build the language names array, to be used as enumeration in the
|
/* Build the language names array, to be used as enumeration in the
|
||||||
"set language" enum command. +1 for "local" and +1 for NULL
|
"set language" enum command. +3 for "auto", "local" and NULL
|
||||||
termination. */
|
termination. */
|
||||||
language_names = new const char *[ARRAY_SIZE (language_defn::languages) + 2];
|
language_names = new const char *[ARRAY_SIZE (language_defn::languages) + 3];
|
||||||
|
|
||||||
/* Display "auto", "local" and "unknown" first, and then the rest,
|
/* Display "auto", "local" and "unknown" first, and then the rest,
|
||||||
alpha sorted. */
|
alpha sorted. */
|
||||||
const char **language_names_p = language_names;
|
const char **language_names_p = language_names;
|
||||||
*language_names_p++ = language_def (language_auto)->name ();;
|
*language_names_p++ = "auto";
|
||||||
*language_names_p++ = "local";
|
*language_names_p++ = "local";
|
||||||
*language_names_p++ = language_def (language_unknown)->name ();
|
*language_names_p++ = language_def (language_unknown)->name ();
|
||||||
const char **sort_begin = language_names_p;
|
const char **sort_begin = language_names_p;
|
||||||
for (const auto &lang : language_defn::languages)
|
for (const auto &lang : language_defn::languages)
|
||||||
{
|
{
|
||||||
/* Already handled above. */
|
/* Already handled above. */
|
||||||
if (lang->la_language == language_auto
|
if (lang->la_language == language_unknown)
|
||||||
|| lang->la_language == language_unknown)
|
|
||||||
continue;
|
continue;
|
||||||
*language_names_p++ = lang->name ();
|
*language_names_p++ = lang->name ();
|
||||||
}
|
}
|
||||||
@@ -505,8 +497,7 @@ add_set_language_command ()
|
|||||||
for (const auto &lang : language_defn::languages)
|
for (const auto &lang : language_defn::languages)
|
||||||
{
|
{
|
||||||
/* Already dealt with these above. */
|
/* Already dealt with these above. */
|
||||||
if (lang->la_language == language_unknown
|
if (lang->la_language == language_unknown)
|
||||||
|| lang->la_language == language_auto)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Note that we add the newline at the front, so we don't wind
|
/* Note that we add the newline at the front, so we don't wind
|
||||||
@@ -703,15 +694,12 @@ language_defn::varobj_ops () const
|
|||||||
return &c_varobj_ops;
|
return &c_varobj_ops;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parent class for both the "auto" and "unknown" languages. These two
|
/* Class representing the "unknown" language. */
|
||||||
pseudo-languages are very similar so merging their implementations like
|
|
||||||
this makes sense. */
|
|
||||||
|
|
||||||
class auto_or_unknown_language : public language_defn
|
class unknown_language : public language_defn
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
auto_or_unknown_language (enum language lang)
|
unknown_language () : language_defn (language_unknown)
|
||||||
: language_defn (lang)
|
|
||||||
{ /* Nothing. */ }
|
{ /* Nothing. */ }
|
||||||
|
|
||||||
/* See language.h. */
|
/* See language.h. */
|
||||||
@@ -823,40 +811,6 @@ public:
|
|||||||
|
|
||||||
const char *name_of_this () const override
|
const char *name_of_this () const override
|
||||||
{ return "this"; }
|
{ return "this"; }
|
||||||
};
|
|
||||||
|
|
||||||
/* Class representing the fake "auto" language. */
|
|
||||||
|
|
||||||
class auto_language : public auto_or_unknown_language
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
auto_language ()
|
|
||||||
: auto_or_unknown_language (language_auto)
|
|
||||||
{ /* Nothing. */ }
|
|
||||||
|
|
||||||
/* See language.h. */
|
|
||||||
|
|
||||||
const char *name () const override
|
|
||||||
{ return "auto"; }
|
|
||||||
|
|
||||||
/* See language.h. */
|
|
||||||
|
|
||||||
const char *natural_name () const override
|
|
||||||
{ return "Auto"; }
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Single instance of the fake "auto" language. */
|
|
||||||
|
|
||||||
static auto_language auto_language_defn;
|
|
||||||
|
|
||||||
/* Class representing the unknown language. */
|
|
||||||
|
|
||||||
class unknown_language : public auto_or_unknown_language
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
unknown_language ()
|
|
||||||
: auto_or_unknown_language (language_unknown)
|
|
||||||
{ /* Nothing. */ }
|
|
||||||
|
|
||||||
/* See language.h. */
|
/* See language.h. */
|
||||||
|
|
||||||
@@ -1131,7 +1085,4 @@ For Fortran the default is off; for other languages the default is on."),
|
|||||||
&setlist, &showlist);
|
&setlist, &showlist);
|
||||||
|
|
||||||
add_set_language_command ();
|
add_set_language_command ();
|
||||||
|
|
||||||
/* Have the above take effect. */
|
|
||||||
set_language (language_auto);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -351,8 +351,7 @@ mi_parse (const char *cmd, char **token)
|
|||||||
std::string lang_name = extract_arg (&chp);
|
std::string lang_name = extract_arg (&chp);
|
||||||
|
|
||||||
parse->language = language_enum (lang_name.c_str ());
|
parse->language = language_enum (lang_name.c_str ());
|
||||||
if (parse->language == language_unknown
|
if (parse->language == language_unknown)
|
||||||
|| parse->language == language_auto)
|
|
||||||
error (_("Invalid --language argument: %s"), lang_name.c_str ());
|
error (_("Invalid --language argument: %s"), lang_name.c_str ());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1189,7 +1189,7 @@ minimal_symbol_reader::record_full (gdb::string_view name,
|
|||||||
m_msym_bunch = newobj;
|
m_msym_bunch = newobj;
|
||||||
}
|
}
|
||||||
msymbol = &m_msym_bunch->contents[m_msym_bunch_index];
|
msymbol = &m_msym_bunch->contents[m_msym_bunch_index];
|
||||||
msymbol->set_language (language_auto,
|
msymbol->set_language (language_unknown,
|
||||||
&m_objfile->per_bfd->storage_obstack);
|
&m_objfile->per_bfd->storage_obstack);
|
||||||
|
|
||||||
if (copy_name)
|
if (copy_name)
|
||||||
|
|||||||
@@ -365,8 +365,7 @@ dump_symtab (struct symtab *symtab, struct ui_file *outfile)
|
|||||||
because certain routines used during dump_symtab() use the current
|
because certain routines used during dump_symtab() use the current
|
||||||
language to print an image of the symbol. We'll restore it later.
|
language to print an image of the symbol. We'll restore it later.
|
||||||
But use only real languages, not placeholders. */
|
But use only real languages, not placeholders. */
|
||||||
if (symtab->language () != language_unknown
|
if (symtab->language () != language_unknown)
|
||||||
&& symtab->language () != language_auto)
|
|
||||||
{
|
{
|
||||||
scoped_restore_current_language save_lang;
|
scoped_restore_current_language save_lang;
|
||||||
set_language (symtab->language ());
|
set_language (symtab->language ());
|
||||||
|
|||||||
@@ -887,10 +887,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
|
|||||||
gdb::unique_xmalloc_ptr<char> demangled;
|
gdb::unique_xmalloc_ptr<char> demangled;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (gsymbol->language () == language_unknown)
|
if (gsymbol->language () != language_unknown)
|
||||||
gsymbol->m_language = language_auto;
|
|
||||||
|
|
||||||
if (gsymbol->language () != language_auto)
|
|
||||||
{
|
{
|
||||||
const struct language_defn *lang = language_def (gsymbol->language ());
|
const struct language_defn *lang = language_def (gsymbol->language ());
|
||||||
|
|
||||||
@@ -1028,7 +1025,7 @@ general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
|
|||||||
(*slot)->demangled = std::move (demangled_name);
|
(*slot)->demangled = std::move (demangled_name);
|
||||||
(*slot)->language = language ();
|
(*slot)->language = language ();
|
||||||
}
|
}
|
||||||
else if (language () == language_unknown || language () == language_auto)
|
else if (language () == language_unknown)
|
||||||
m_language = (*slot)->language;
|
m_language = (*slot)->language;
|
||||||
|
|
||||||
m_name = (*slot)->mangled.data ();
|
m_name = (*slot)->mangled.data ();
|
||||||
|
|||||||
Reference in New Issue
Block a user