From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/9] gdb: Convert language la_print_array_index field to a method
Date: Mon, 11 May 2020 23:35:47 +0100 [thread overview]
Message-ID: <9c0f059475ab9a33bcb2c8172e71218e58dce473.1589235908.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1589235908.git.andrew.burgess@embecosm.com>
This commit changes the language_data::la_print_array_index 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_print_array_index): Delete function, move
implementation to...
(ada_language::print_array_index): ...here.
(ada_language_data): Delete la_print_array_index initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (default_print_array_index): Delete function, move
implementation to...
(language_defn::print_array_index): ...here.
(unknown_language_data): Delete la_print_array_index initializer.
(auto_language_data): Likewise.
* language.h (struct language_data): Delete la_print_array_index
field.
(language_defn::print_array_index): New member function.
(LA_PRINT_ARRAY_INDEX): Update.
(default_print_array_index): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_print_array_index
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.
---
gdb/ChangeLog | 29 +++++++++++++++++++++++++++++
gdb/ada-lang.c | 21 ++++++++++-----------
gdb/c-lang.c | 4 ----
gdb/d-lang.c | 1 -
gdb/f-lang.c | 1 -
gdb/go-lang.c | 1 -
gdb/language.c | 9 ++++-----
gdb/language.h | 19 ++++++++-----------
gdb/m2-lang.c | 1 -
gdb/objc-lang.c | 1 -
gdb/opencl-lang.c | 1 -
gdb/p-lang.c | 1 -
gdb/rust-lang.c | 1 -
13 files changed, 51 insertions(+), 39 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 4489c284776..47007e52119 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -498,16 +498,6 @@ ada_get_gdb_completer_word_break_characters (void)
return ada_completer_word_break_characters;
}
-/* Print an array element index using the Ada syntax. */
-
-static void
-ada_print_array_index (struct value *index_value, struct ui_file *stream,
- const struct value_print_options *options)
-{
- LA_VALUE_PRINT (index_value, stream, options);
- fprintf_filtered (stream, " => ");
-}
-
/* la_watch_location_expression for Ada. */
static gdb::unique_xmalloc_ptr<char>
@@ -14108,7 +14098,6 @@ extern const struct language_data ada_language_data =
ada_get_gdb_completer_word_break_characters,
ada_collect_symbol_completion_matches,
ada_language_arch_info,
- ada_print_array_index,
default_pass_by_reference,
ada_watch_location_expression,
ada_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
@@ -14129,6 +14118,16 @@ class ada_language : public language_defn
ada_language ()
: language_defn (language_ada, ada_language_data)
{ /* Nothing. */ }
+
+ /* Print an array element index using the Ada syntax. */
+
+ void print_array_index (struct value *index_value,
+ struct ui_file *stream,
+ const value_print_options *options) const override
+ {
+ LA_VALUE_PRINT (index_value, stream, options);
+ fprintf_filtered (stream, " => ");
+ }
};
/* Single instance of the Ada language class. */
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 2774010a2ed..af4b4d3cf02 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -923,7 +923,6 @@ extern const struct language_data c_language_data =
default_word_break_characters,
default_collect_symbol_completion_matches,
c_language_arch_info,
- default_print_array_index,
default_pass_by_reference,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
@@ -1084,7 +1083,6 @@ extern const struct language_data cplus_language_data =
default_word_break_characters,
default_collect_symbol_completion_matches,
cplus_language_arch_info,
- default_print_array_index,
cp_pass_by_reference,
c_watch_location_expression,
cp_get_symbol_name_matcher,
@@ -1154,7 +1152,6 @@ extern const struct language_data asm_language_data =
default_word_break_characters,
default_collect_symbol_completion_matches,
c_language_arch_info, /* FIXME: la_language_arch_info. */
- default_print_array_index,
default_pass_by_reference,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
@@ -1221,7 +1218,6 @@ extern const struct language_data minimal_language_data =
default_word_break_characters,
default_collect_symbol_completion_matches,
c_language_arch_info,
- default_print_array_index,
default_pass_by_reference,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index c572ad7890e..af8143b9b13 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -244,7 +244,6 @@ extern const struct language_data d_language_data =
default_word_break_characters,
default_collect_symbol_completion_matches,
d_language_arch_info,
- default_print_array_index,
default_pass_by_reference,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 888d78b720a..1b79485f61d 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -672,7 +672,6 @@ extern const struct language_data f_language_data =
f_word_break_characters,
f_collect_symbol_completion_matches,
f_language_arch_info,
- default_print_array_index,
default_pass_by_reference,
c_watch_location_expression,
cp_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 61e2a1d549f..a69091bb631 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -615,7 +615,6 @@ extern const struct language_data go_language_data =
default_word_break_characters,
default_collect_symbol_completion_matches,
go_language_arch_info,
- default_print_array_index,
default_pass_by_reference,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
diff --git a/gdb/language.c b/gdb/language.c
index 7622ddca0a3..4b2a405c725 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -650,11 +650,12 @@ default_word_break_characters (void)
return " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,-";
}
-/* Print the index of array elements using the C99 syntax. */
+/* See language.h. */
void
-default_print_array_index (struct value *index_value, struct ui_file *stream,
- const struct value_print_options *options)
+language_defn::print_array_index (struct value *index_value,
+ struct ui_file *stream,
+ const value_print_options *options) const
{
fprintf_filtered (stream, "[");
LA_VALUE_PRINT (index_value, stream, options);
@@ -846,7 +847,6 @@ extern const struct language_data unknown_language_data =
default_word_break_characters,
default_collect_symbol_completion_matches,
unknown_language_arch_info, /* la_language_arch_info. */
- default_print_array_index,
default_pass_by_reference,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
@@ -911,7 +911,6 @@ extern const struct language_data auto_language_data =
default_word_break_characters,
default_collect_symbol_completion_matches,
unknown_language_arch_info, /* la_language_arch_info. */
- default_print_array_index,
default_pass_by_reference,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
diff --git a/gdb/language.h b/gdb/language.h
index a07ed0637a6..307a08c13cd 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -387,11 +387,6 @@ struct language_data
void (*la_language_arch_info) (struct gdbarch *,
struct language_arch_info *);
- /* Print the index of an element of an array. */
- void (*la_print_array_index) (struct value *index_value,
- struct ui_file *stream,
- const struct value_print_options *options);
-
/* Return information about whether TYPE should be passed
(and returned) by reference at the language level. */
struct language_pass_by_ref_info (*la_pass_by_reference)
@@ -494,6 +489,13 @@ struct language_defn : language_data
languages[lang] = this;
}
+ /* Print the index of an element of an array. This default
+ implementation prints using C99 syntax. */
+
+ virtual void print_array_index (struct value *index_value,
+ struct ui_file *stream,
+ const value_print_options *options) const;
+
/* List of all known languages. */
static const struct language_defn *languages[nr_languages];
};
@@ -599,7 +601,7 @@ extern enum language set_language (enum language);
(current_language->la_emitchar(ch, type, stream, quoter))
#define LA_PRINT_ARRAY_INDEX(index_value, stream, options) \
- (current_language->la_print_array_index(index_value, stream, options))
+ (current_language->print_array_index(index_value, stream, options))
#define LA_ITERATE_OVER_SYMBOLS(BLOCK, NAME, DOMAIN, CALLBACK) \
(current_language->la_iterate_over_symbols (BLOCK, NAME, DOMAIN, CALLBACK))
@@ -661,11 +663,6 @@ extern char *language_class_name_from_physname (const struct language_defn *,
/* Splitting strings into words. */
extern const char *default_word_break_characters (void);
-/* Print the index of an array element using the C99 syntax. */
-extern void default_print_array_index (struct value *index_value,
- struct ui_file *stream,
- const struct value_print_options *options);
-
/* Return information about whether TYPE should be passed
(and returned) by reference at the language level. */
struct language_pass_by_ref_info language_pass_by_reference (struct type *type);
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 161be09001f..4d4f5493938 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -413,7 +413,6 @@ extern const struct language_data m2_language_data =
default_word_break_characters,
default_collect_symbol_completion_matches,
m2_language_arch_info,
- default_print_array_index,
default_pass_by_reference,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 7fe495f6892..47d75620dcb 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -402,7 +402,6 @@ extern const struct language_data objc_language_data =
default_word_break_characters,
default_collect_symbol_completion_matches,
c_language_arch_info,
- default_print_array_index,
default_pass_by_reference,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index b7ea773e75f..ebd13d68381 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1079,7 +1079,6 @@ extern const struct language_data opencl_language_data =
default_word_break_characters,
default_collect_symbol_completion_matches,
opencl_language_arch_info,
- default_print_array_index,
default_pass_by_reference,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index d5c83d70eff..34063232da6 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -466,7 +466,6 @@ extern const struct language_data pascal_language_data =
default_word_break_characters,
default_collect_symbol_completion_matches,
pascal_language_arch_info,
- default_print_array_index,
default_pass_by_reference,
c_watch_location_expression,
NULL, /* la_compare_symbol_for_completion */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index d7caf3531e5..41bb47189eb 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -2139,7 +2139,6 @@ extern const struct language_data rust_language_data =
default_word_break_characters,
default_collect_symbol_completion_matches,
rust_language_arch_info,
- default_print_array_index,
default_pass_by_reference,
rust_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
--
2.25.3
next prev parent reply other threads:[~2020-05-11 22:36 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 22:35 [PATCH 0/9] Starting to convert languages to separate classes Andrew Burgess
2020-05-11 22:35 ` [PATCH 1/9] gdb: Represent all languages as sub-classes of language_defn Andrew Burgess
2020-05-11 22:35 ` Andrew Burgess [this message]
2020-05-11 22:35 ` [PATCH 3/9] gdb: Convert language la_read_var_value field to a method Andrew Burgess
2020-05-14 19:43 ` Tom Tromey
2020-05-11 22:35 ` [PATCH 4/9] gdb: Convert language la_pass_by_reference " Andrew Burgess
2020-05-14 11:00 ` Aktemur, Tankut Baris
2020-05-14 19:49 ` Tom Tromey
2020-05-14 19:48 ` Tom Tromey
2020-05-11 22:35 ` [PATCH 5/9] gdb: Convert language la_language_arch_info " Andrew Burgess
2020-05-11 22:35 ` [PATCH 6/9] gdb: Convert language la_lookup_transparent_type " Andrew Burgess
2020-05-11 22:35 ` [PATCH 7/9] gdb: Convert language la_iterate_over_symbols " Andrew Burgess
2020-05-12 23:21 ` Christian Biesinger
2020-05-11 22:35 ` [PATCH 8/9] gdb: Convert language la_get_compile_instance " Andrew Burgess
2020-05-12 21:11 ` Christian Biesinger
2020-05-11 22:35 ` [PATCH 9/9] gdb: Convert language la_search_name_hash " Andrew Burgess
2020-05-12 21:10 ` Christian Biesinger
2020-05-12 23:17 ` [PATCH 0/9] Starting to convert languages to separate classes Christian Biesinger
2020-05-13 1:33 ` Simon Marchi
2020-05-14 19:57 ` Tom Tromey
2020-05-15 15:06 ` [PATCHv2 00/13] " Andrew Burgess
2020-05-15 15:06 ` [PATCHv2 01/13] gdb: Represent all languages as sub-classes of language_defn Andrew Burgess
2020-05-15 15:06 ` [PATCHv2 02/13] gdb: Convert language la_print_array_index field to a method Andrew Burgess
2020-05-15 15:06 ` [PATCHv2 03/13] gdb: Convert language la_read_var_value " Andrew Burgess
2020-05-15 15:06 ` [PATCHv2 04/13] gdb: Convert language la_pass_by_reference " Andrew Burgess
2020-05-15 15:06 ` [PATCHv2 05/13] gdb: Convert language la_language_arch_info " Andrew Burgess
2020-05-15 15:06 ` [PATCHv2 06/13] gdb: Convert language la_lookup_transparent_type " Andrew Burgess
2020-05-15 15:06 ` [PATCHv2 07/13] gdb: Convert language la_iterate_over_symbols " Andrew Burgess
2020-05-15 15:06 ` [PATCHv2 08/13] gdb: Convert language la_get_compile_instance " Andrew Burgess
2020-05-15 15:06 ` [PATCHv2 09/13] gdb: Convert language la_search_name_hash " Andrew Burgess
2020-05-15 17:47 ` Christian Biesinger
2020-05-15 15:06 ` [PATCHv2 10/13] gdb: Convert language la_sniff_from_mangled_name " Andrew Burgess
2020-05-15 15:06 ` [PATCHv2 11/13] gdb: Convert language la_print_type " Andrew Burgess
2020-05-15 15:06 ` [PATCHv2 12/13] gdb: Convert language la_demangle " Andrew Burgess
2020-05-15 15:06 ` [PATCHv2 13/13] gdb: Convert language skip_trampoline " Andrew Burgess
2020-05-15 17:06 ` [PATCHv2 00/13] Starting to convert languages to separate classes Tom Tromey
2020-06-01 16:02 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9c0f059475ab9a33bcb2c8172e71218e58dce473.1589235908.git.andrew.burgess@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).