Make ada_decode not use a static buffer

This makes it safer to use in general, and also allows using it on a
background thread in the future.

Inspired by tromey's patch at:
1226cbdfa4
(however, implemented in a different way)

gdb/ChangeLog:

2019-09-23  Christian Biesinger  <cbiesinger@google.com>

	* ada-exp.y (write_object_remaining): Update.
	* ada-lang.c (ada_decode): Return a std::string instead of a char*
	and eliminate the static buffer.
	(ada_decode_symbol): Update.
	(ada_la_decode): Update.
	(ada_sniff_from_mangled_name): Update.
	(is_valid_name_for_wild_match): Update.
	(ada_lookup_name_info::matches): Update and simplify.
	(name_matches_regex): Update.
	(ada_add_global_exceptions): Update.
	* ada-lang.h (ada_decode): Update signature.
	* ada-varobj.c (ada_varobj_describe_simple_array_child): Update.
	* dwarf-index-write.c (debug_names::insert): Update.
This commit is contained in:
Christian Biesinger 2019-08-28 15:40:31 -05:00
parent 4a41f3face
commit f945dedfd3
6 changed files with 52 additions and 46 deletions

View file

@ -714,13 +714,14 @@ public:
name (of the form "<MumBle>") must be entered without the
angle brackets. Note that the current index is unusual,
see PR symtab/24820 for details. */
const char *decoded = ada_decode (name);
std::string decoded = ada_decode (name);
if (decoded[0] == '<')
name = (char *) obstack_copy0 (&m_string_obstack,
decoded + 1,
strlen (decoded + 1) - 1);
decoded.c_str () + 1,
decoded.length () - 2);
else
name = obstack_strdup (&m_string_obstack, ada_encode (decoded));
name = obstack_strdup (&m_string_obstack,
ada_encode (decoded.c_str ()));
}
const auto insertpair