gdb: Convert language la_word_break_characters field to a method

This commit changes the language_data::la_word_break_characters
function pointer member variable into a member function of
language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_get_gdb_completer_word_break_characters): Delete.
	(ada_language_data): Delete la_word_break_characters initializer.
	(ada_language::word_break_characters): New member function.
	* c-lang.c (c_language_data): Delete la_word_break_characters
	initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* completer.c: Update global comment.
	(advance_to_expression_complete_word_point): Update call to
	word_break_characters.
	(complete_files_symbols): Likewise.
	(complete_line_internal_1): Likewise.
	(default_completer_handle_brkchars): Likewise.
	(skip_quoted_chars): Likewise.
	* d-lang.c (d_language_data): Delete la_word_break_characters
	initializer.
	* f-lang.c (f_word_break_characters): Delete.
	(f_language_data): Delete la_word_break_characters initializer.
	(f_language::word_break_characters): New member function.
	* go-lang.c (go_language_data): Delete la_word_break_characters
	initializer.
	* language.c (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (default_word_break_characters): Move declaration to
	earlier in the file.
	(language_data): Delete la_word_break_characters field.
	(language_defn::word_break_characters): New member function.
	* m2-lang.c (m2_language_data): Delete la_word_break_characters
	initializer.
	* objc-lang.c (objc_language_data): Likewise.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_language_data): Likewise.
This commit is contained in:
Andrew Burgess
2020-06-01 14:40:22 +01:00
parent c9debfb97e
commit 53fc67f8b2
14 changed files with 83 additions and 57 deletions

View File

@@ -1,3 +1,40 @@
2020-06-17 Andrew Burgess <andrew.burgess@embecosm.com>
* ada-lang.c (ada_get_gdb_completer_word_break_characters): Delete.
(ada_language_data): Delete la_word_break_characters initializer.
(ada_language::word_break_characters): New member function.
* c-lang.c (c_language_data): Delete la_word_break_characters
initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* completer.c: Update global comment.
(advance_to_expression_complete_word_point): Update call to
word_break_characters.
(complete_files_symbols): Likewise.
(complete_line_internal_1): Likewise.
(default_completer_handle_brkchars): Likewise.
(skip_quoted_chars): Likewise.
* d-lang.c (d_language_data): Delete la_word_break_characters
initializer.
* f-lang.c (f_word_break_characters): Delete.
(f_language_data): Delete la_word_break_characters initializer.
(f_language::word_break_characters): New member function.
* go-lang.c (go_language_data): Delete la_word_break_characters
initializer.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (default_word_break_characters): Move declaration to
earlier in the file.
(language_data): Delete la_word_break_characters field.
(language_defn::word_break_characters): New member function.
* m2-lang.c (m2_language_data): Delete la_word_break_characters
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
2020-06-17 Andrew Burgess <andrew.burgess@embecosm.com> 2020-06-17 Andrew Burgess <andrew.burgess@embecosm.com>
* ada-lang.c (ada_get_symbol_name_matcher): Update header comment. * ada-lang.c (ada_get_symbol_name_matcher): Update header comment.

View File

@@ -488,12 +488,6 @@ add_angle_brackets (const char *str)
return string_printf ("<%s>", str); return string_printf ("<%s>", str);
} }
static const char *
ada_get_gdb_completer_word_break_characters (void)
{
return ada_completer_word_break_characters;
}
/* la_watch_location_expression for Ada. */ /* la_watch_location_expression for Ada. */
static gdb::unique_xmalloc_ptr<char> static gdb::unique_xmalloc_ptr<char>
@@ -13917,7 +13911,6 @@ extern const struct language_data ada_language_data =
ada_op_print_tab, /* expression operators for printing */ ada_op_print_tab, /* expression operators for printing */
0, /* c-style arrays */ 0, /* c-style arrays */
1, /* String lower bound */ 1, /* String lower bound */
ada_get_gdb_completer_word_break_characters,
ada_collect_symbol_completion_matches, ada_collect_symbol_completion_matches,
ada_watch_location_expression, ada_watch_location_expression,
&ada_varobj_ops, &ada_varobj_ops,
@@ -14105,6 +14098,13 @@ public:
ada_print_type (type, varstring, stream, show, level, flags); ada_print_type (type, varstring, stream, show, level, flags);
} }
/* See language.h. */
const char *word_break_characters (void) const override
{
return ada_completer_word_break_characters;
}
protected: protected:
/* See language.h. */ /* See language.h. */

View File

@@ -914,7 +914,6 @@ extern const struct language_data c_language_data =
c_op_print_tab, /* expression operators for printing */ c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */ 1, /* c-style arrays */
0, /* String lower bound */ 0, /* String lower bound */
default_word_break_characters,
default_collect_symbol_completion_matches, default_collect_symbol_completion_matches,
c_watch_location_expression, c_watch_location_expression,
&c_varobj_ops, &c_varobj_ops,
@@ -1028,7 +1027,6 @@ extern const struct language_data cplus_language_data =
c_op_print_tab, /* expression operators for printing */ c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */ 1, /* c-style arrays */
0, /* String lower bound */ 0, /* String lower bound */
default_word_break_characters,
default_collect_symbol_completion_matches, default_collect_symbol_completion_matches,
c_watch_location_expression, c_watch_location_expression,
&cplus_varobj_ops, &cplus_varobj_ops,
@@ -1230,7 +1228,6 @@ extern const struct language_data asm_language_data =
c_op_print_tab, /* expression operators for printing */ c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */ 1, /* c-style arrays */
0, /* String lower bound */ 0, /* String lower bound */
default_word_break_characters,
default_collect_symbol_completion_matches, default_collect_symbol_completion_matches,
c_watch_location_expression, c_watch_location_expression,
&default_varobj_ops, &default_varobj_ops,
@@ -1299,7 +1296,6 @@ extern const struct language_data minimal_language_data =
c_op_print_tab, /* expression operators for printing */ c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */ 1, /* c-style arrays */
0, /* String lower bound */ 0, /* String lower bound */
default_word_break_characters,
default_collect_symbol_completion_matches, default_collect_symbol_completion_matches,
c_watch_location_expression, c_watch_location_expression,
&default_varobj_ops, &default_varobj_ops,

View File

@@ -155,7 +155,7 @@ enum explicit_location_match_type
but it does affect how much stuff M-? lists. but it does affect how much stuff M-? lists.
(2) If one of the matches contains a word break character, readline (2) If one of the matches contains a word break character, readline
will quote it. That's why we switch between will quote it. That's why we switch between
current_language->la_word_break_characters() and current_language->word_break_characters () and
gdb_completer_command_word_break_characters. I'm not sure when gdb_completer_command_word_break_characters. I'm not sure when
we need this behavior (perhaps for funky characters in C++ we need this behavior (perhaps for funky characters in C++
symbols?). */ symbols?). */
@@ -448,7 +448,7 @@ const char *
advance_to_expression_complete_word_point (completion_tracker &tracker, advance_to_expression_complete_word_point (completion_tracker &tracker,
const char *text) const char *text)
{ {
const char *brk_chars = current_language->la_word_break_characters (); const char *brk_chars = current_language->word_break_characters ();
return advance_to_completion_word (tracker, brk_chars, text); return advance_to_completion_word (tracker, brk_chars, text);
} }
@@ -573,7 +573,7 @@ complete_files_symbols (completion_tracker &tracker,
colon = p; colon = p;
symbol_start = p + 1; symbol_start = p + 1;
} }
else if (strchr (current_language->la_word_break_characters(), *p)) else if (strchr (current_language->word_break_characters (), *p))
symbol_start = p + 1; symbol_start = p + 1;
} }
@@ -1348,7 +1348,7 @@ complete_line_internal_1 (completion_tracker &tracker,
strings, which leaves out the '-' and '.' character used in some strings, which leaves out the '-' and '.' character used in some
commands. */ commands. */
set_rl_completer_word_break_characters set_rl_completer_word_break_characters
(current_language->la_word_break_characters()); (current_language->word_break_characters ());
/* Decide whether to complete on a list of gdb commands or on /* Decide whether to complete on a list of gdb commands or on
symbols. */ symbols. */
@@ -1964,7 +1964,7 @@ default_completer_handle_brkchars (struct cmd_list_element *ignore,
const char *text, const char *word) const char *text, const char *word)
{ {
set_rl_completer_word_break_characters set_rl_completer_word_break_characters
(current_language->la_word_break_characters ()); (current_language->word_break_characters ());
} }
/* See definition in completer.h. */ /* See definition in completer.h. */
@@ -2473,7 +2473,7 @@ skip_quoted_chars (const char *str, const char *quotechars,
quotechars = gdb_completer_quote_characters; quotechars = gdb_completer_quote_characters;
if (breakchars == NULL) if (breakchars == NULL)
breakchars = current_language->la_word_break_characters(); breakchars = current_language->word_break_characters ();
for (scan = str; *scan != '\0'; scan++) for (scan = str; *scan != '\0'; scan++)
{ {

View File

@@ -157,7 +157,6 @@ extern const struct language_data d_language_data =
d_op_print_tab, /* Expression operators for printing. */ d_op_print_tab, /* Expression operators for printing. */
1, /* C-style arrays. */ 1, /* C-style arrays. */
0, /* String lower bound. */ 0, /* String lower bound. */
default_word_break_characters,
default_collect_symbol_completion_matches, default_collect_symbol_completion_matches,
c_watch_location_expression, c_watch_location_expression,
&default_varobj_ops, &default_varobj_ops,

View File

@@ -165,30 +165,6 @@ enum f_primitive_types {
nr_f_primitive_types nr_f_primitive_types
}; };
/* Remove the modules separator :: from the default break list. */
static const char *
f_word_break_characters (void)
{
static char *retval;
if (!retval)
{
char *s;
retval = xstrdup (default_word_break_characters ());
s = strchr (retval, ':');
if (s)
{
char *last_char = &s[strlen (s) - 1];
*s = *last_char;
*last_char = 0;
}
}
return retval;
}
/* Consider the modules separator :: as a valid symbol name character /* Consider the modules separator :: as a valid symbol name character
class. */ class. */
@@ -617,7 +593,6 @@ extern const struct language_data f_language_data =
f_op_print_tab, /* expression operators for printing */ f_op_print_tab, /* expression operators for printing */
0, /* arrays are first-class (not c-style) */ 0, /* arrays are first-class (not c-style) */
1, /* String lower bound */ 1, /* String lower bound */
f_word_break_characters,
f_collect_symbol_completion_matches, f_collect_symbol_completion_matches,
c_watch_location_expression, c_watch_location_expression,
&default_varobj_ops, &default_varobj_ops,
@@ -699,6 +674,30 @@ public:
f_print_type (type, varstring, stream, show, level, flags); f_print_type (type, varstring, stream, show, level, flags);
} }
/* See language.h. This just returns default set of word break
characters but with the modules separator `::' removed. */
const char *word_break_characters (void) const override
{
static char *retval;
if (!retval)
{
char *s;
retval = xstrdup (language_defn::word_break_characters ());
s = strchr (retval, ':');
if (s)
{
char *last_char = &s[strlen (s) - 1];
*s = *last_char;
*last_char = 0;
}
}
return retval;
}
protected: protected:
/* See language.h. */ /* See language.h. */

View File

@@ -542,7 +542,6 @@ extern const struct language_data go_language_data =
go_op_print_tab, /* Expression operators for printing. */ go_op_print_tab, /* Expression operators for printing. */
1, /* C-style arrays. */ 1, /* C-style arrays. */
0, /* String lower bound. */ 0, /* String lower bound. */
default_word_break_characters,
default_collect_symbol_completion_matches, default_collect_symbol_completion_matches,
c_watch_location_expression, c_watch_location_expression,
&default_varobj_ops, &default_varobj_ops,

View File

@@ -779,7 +779,6 @@ extern const struct language_data unknown_language_data =
unk_op_print_tab, /* expression operators for printing */ unk_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */ 1, /* c-style arrays */
0, /* String lower bound */ 0, /* String lower bound */
default_word_break_characters,
default_collect_symbol_completion_matches, default_collect_symbol_completion_matches,
c_watch_location_expression, c_watch_location_expression,
&default_varobj_ops, &default_varobj_ops,
@@ -852,7 +851,6 @@ extern const struct language_data auto_language_data =
unk_op_print_tab, /* expression operators for printing */ unk_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */ 1, /* c-style arrays */
0, /* String lower bound */ 0, /* String lower bound */
default_word_break_characters,
default_collect_symbol_completion_matches, default_collect_symbol_completion_matches,
c_watch_location_expression, c_watch_location_expression,
&default_varobj_ops, &default_varobj_ops,

View File

@@ -169,6 +169,9 @@ struct language_pass_by_ref_info
bool destructible = true; bool destructible = true;
}; };
/* Splitting strings into words. */
extern const char *default_word_break_characters (void);
/* Structure tying together assorted information about a language. /* Structure tying together assorted information about a language.
As we move over from the old structure based languages to a class As we move over from the old structure based languages to a class
@@ -316,9 +319,6 @@ struct language_data
/* Index to use for extracting the first element of a string. */ /* Index to use for extracting the first element of a string. */
char string_lower_bound; char string_lower_bound;
/* The list of characters forming word boundaries. */
const char *(*la_word_break_characters) (void);
/* Add to the completion tracker all symbols which are possible /* Add to the completion tracker all symbols which are possible
completions for TEXT. WORD is the entire command on which the completions for TEXT. WORD is the entire command on which the
completion is being made. If CODE is TYPE_CODE_UNDEF, then all completion is being made. If CODE is TYPE_CODE_UNDEF, then all
@@ -529,6 +529,12 @@ struct language_defn : language_data
return nullptr; return nullptr;
} }
/* The list of characters forming word boundaries. */
virtual const char *word_break_characters (void) const
{
return default_word_break_characters ();
}
/* List of all known languages. */ /* List of all known languages. */
static const struct language_defn *languages[nr_languages]; static const struct language_defn *languages[nr_languages];
@@ -691,9 +697,6 @@ extern CORE_ADDR skip_language_trampoline (struct frame_info *, CORE_ADDR pc);
extern char *language_demangle (const struct language_defn *current_language, extern char *language_demangle (const struct language_defn *current_language,
const char *mangled, int options); const char *mangled, int options);
/* Splitting strings into words. */
extern const char *default_word_break_characters (void);
/* Return information about whether TYPE should be passed /* Return information about whether TYPE should be passed
(and returned) by reference at the language level. */ (and returned) by reference at the language level. */
struct language_pass_by_ref_info language_pass_by_reference (struct type *type); struct language_pass_by_ref_info language_pass_by_reference (struct type *type);

View File

@@ -376,7 +376,6 @@ extern const struct language_data m2_language_data =
m2_op_print_tab, /* expression operators for printing */ m2_op_print_tab, /* expression operators for printing */
0, /* arrays are first-class (not c-style) */ 0, /* arrays are first-class (not c-style) */
0, /* String lower bound */ 0, /* String lower bound */
default_word_break_characters,
default_collect_symbol_completion_matches, default_collect_symbol_completion_matches,
c_watch_location_expression, c_watch_location_expression,
&default_varobj_ops, &default_varobj_ops,

View File

@@ -351,7 +351,6 @@ extern const struct language_data objc_language_data =
objc_op_print_tab, /* Expression operators for printing */ objc_op_print_tab, /* Expression operators for printing */
1, /* C-style arrays */ 1, /* C-style arrays */
0, /* String lower bound */ 0, /* String lower bound */
default_word_break_characters,
default_collect_symbol_completion_matches, default_collect_symbol_completion_matches,
c_watch_location_expression, c_watch_location_expression,
&default_varobj_ops, &default_varobj_ops,

View File

@@ -1030,7 +1030,6 @@ extern const struct language_data opencl_language_data =
c_op_print_tab, /* expression operators for printing */ c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */ 1, /* c-style arrays */
0, /* String lower bound */ 0, /* String lower bound */
default_word_break_characters,
default_collect_symbol_completion_matches, default_collect_symbol_completion_matches,
c_watch_location_expression, c_watch_location_expression,
&default_varobj_ops, &default_varobj_ops,

View File

@@ -407,7 +407,6 @@ extern const struct language_data pascal_language_data =
pascal_op_print_tab, /* expression operators for printing */ pascal_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */ 1, /* c-style arrays */
0, /* String lower bound */ 0, /* String lower bound */
default_word_break_characters,
default_collect_symbol_completion_matches, default_collect_symbol_completion_matches,
c_watch_location_expression, c_watch_location_expression,
&default_varobj_ops, &default_varobj_ops,

View File

@@ -2062,7 +2062,6 @@ extern const struct language_data rust_language_data =
c_op_print_tab, /* expression operators for printing */ c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */ 1, /* c-style arrays */
0, /* String lower bound */ 0, /* String lower bound */
default_word_break_characters,
default_collect_symbol_completion_matches, default_collect_symbol_completion_matches,
rust_watch_location_expression, rust_watch_location_expression,
&default_varobj_ops, &default_varobj_ops,