From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 6/7] gdb: Convert language la_print_typedef field to a method
Date: Thu, 18 Jun 2020 23:31:53 +0100 [thread overview]
Message-ID: <8450ff191dc0de63ba68e21186ed8cb24b7ce000.1592519094.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1592519094.git.andrew.burgess@embecosm.com>
This commit changes the language_data::la_print_typedef 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_language_data): Delete la_print_typedef
initializer.
(ada_language::print_typedef): New member function.
* c-lang.c (c_language_data): Delete la_print_typedef initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
(f_language::print_typedef): New member function.
* go-lang.c (go_language_data): Delete la_print_typedef
initializer.
* language.c (language_defn::print_typedef): Define member
function.
(unknown_language_data): Delete la_print_typedef initializer.
(unknown_language::print_typedef): New member function.
(auto_language_data): Delete la_print_typedef initializer.
(auto_language::print_typedef): New member function.
* language.h (language_data): Delete la_print_typedef field.
(language_defn::print_typedef): Declare new member function.
(LA_PRINT_TYPEDEF): Update call to print_typedef.
(default_print_typedef): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_print_typedef
initializer.
(m2_language::print_typedef): New member function.
* objc-lang.c (objc_language_data): Delete la_print_typedef
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::print_typedef): New member function.
* rust-lang.c (rust_print_typedef): Delete function,
implementation moved to rust_language::print_typedef.
(rust_language): Delete la_print_typedef initializer.
(rust_language::print_typedef): New member function,
implementation from rust_print_typedef.
* typeprint.c (default_print_typedef): Delete.
---
gdb/ChangeLog | 39 +++++++++++++++++++++++++++++++++++++++
gdb/ada-lang.c | 9 ++++++++-
gdb/c-lang.c | 4 ----
gdb/d-lang.c | 2 --
gdb/f-lang.c | 9 ++++++++-
gdb/go-lang.c | 2 --
gdb/language.c | 27 +++++++++++++++++++++++++--
gdb/language.h | 21 +++++++++------------
gdb/m2-lang.c | 10 +++++++++-
gdb/objc-lang.c | 1 -
gdb/opencl-lang.c | 1 -
gdb/p-lang.c | 10 +++++++++-
gdb/rust-lang.c | 25 +++++++++++--------------
gdb/typeprint.c | 9 ---------
14 files changed, 118 insertions(+), 51 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 62ea21a3857..752bf44cef0 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13681,7 +13681,6 @@ extern const struct language_data ada_language_data =
macro_expansion_no,
ada_extensions,
&ada_exp_descriptor,
- ada_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
true, /* la_store_sym_names_in_linkage_form_p */
ada_op_print_tab, /* expression operators for printing */
@@ -14132,6 +14131,14 @@ class ada_language : public language_defn
force_ellipses, options);
}
+ /* See language.h. */
+
+ void print_typedef (struct type *type, struct symbol *new_symbol,
+ struct ui_file *stream) const override
+ {
+ ada_print_typedef (type, new_symbol, stream);
+ }
+
protected:
/* See language.h. */
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index d6bbc025bc7..aca0d7a6bc9 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -889,7 +889,6 @@ extern const struct language_data c_language_data =
macro_expansion_c,
c_extensions,
&exp_descriptor_c,
- c_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
@@ -992,7 +991,6 @@ extern const struct language_data cplus_language_data =
macro_expansion_c,
cplus_extensions,
&exp_descriptor_c,
- c_print_typedef, /* Print a typedef using appropriate syntax */
"this", /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
@@ -1192,7 +1190,6 @@ extern const struct language_data asm_language_data =
macro_expansion_c,
asm_extensions,
&exp_descriptor_c,
- c_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
@@ -1250,7 +1247,6 @@ extern const struct language_data minimal_language_data =
macro_expansion_c,
NULL,
&exp_descriptor_c,
- c_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 17ab38ee511..b907dd750e0 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -142,8 +142,6 @@ extern const struct language_data d_language_data =
macro_expansion_no,
d_extensions,
&exp_descriptor_c,
- c_print_typedef, /* Print a typedef using appropriate
- syntax. */
"this",
false, /* la_store_sym_names_in_linkage_form_p */
d_op_print_tab, /* Expression operators for printing. */
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 67c2ea34b64..946d5bc25af 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -513,7 +513,6 @@ extern const struct language_data f_language_data =
macro_expansion_no,
f_extensions,
&exp_descriptor_f,
- f_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
f_op_print_tab, /* expression operators for printing */
@@ -702,6 +701,14 @@ class f_language : public language_defn
force_ellipses, '\'', 0, options);
}
+ /* See language.h. */
+
+ void print_typedef (struct type *type, struct symbol *new_symbol,
+ struct ui_file *stream) const override
+ {
+ f_print_typedef (type, new_symbol, stream);
+ }
+
protected:
/* See language.h. */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 69f14b8c56c..fa263997b12 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -527,8 +527,6 @@ extern const struct language_data go_language_data =
macro_expansion_no,
NULL,
&exp_descriptor_c,
- c_print_typedef, /* Print a typedef using appropriate
- syntax. */
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
go_op_print_tab, /* Expression operators for printing. */
diff --git a/gdb/language.c b/gdb/language.c
index 9867ac4b4b5..5ae8c46879c 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -681,6 +681,15 @@ language_defn::printstr (struct ui_file *stream, struct type *elttype,
options);
}
+/* See language.h. */
+
+void
+language_defn::print_typedef (struct type *type, struct symbol *new_symbol,
+ struct ui_file *stream) const
+{
+ c_print_typedef (type, new_symbol, stream);
+}
+
/* The default implementation of the get_symbol_name_matcher_inner method
from the language_defn class. Matches with strncmp_iw. */
@@ -774,7 +783,6 @@ extern const struct language_data unknown_language_data =
macro_expansion_no,
NULL,
&exp_descriptor_standard,
- default_print_typedef, /* Print a typedef using appropriate syntax */
"this", /* name_of_this */
true, /* store_sym_names_in_linkage_form_p */
unk_op_print_tab, /* expression operators for printing */
@@ -868,6 +876,14 @@ class unknown_language : public language_defn
{
error (_("unimplemented unknown_language::printstr called"));
}
+
+ /* See language.h. */
+
+ void print_typedef (struct type *type, struct symbol *new_symbol,
+ struct ui_file *stream) const override
+ {
+ error (_("unimplemented unknown_language::print_typedef called"));
+ }
};
/* Single instance of the unknown language class. */
@@ -887,7 +903,6 @@ extern const struct language_data auto_language_data =
macro_expansion_no,
NULL,
&exp_descriptor_standard,
- default_print_typedef, /* Print a typedef using appropriate syntax */
"this", /* name_of_this */
false, /* store_sym_names_in_linkage_form_p */
unk_op_print_tab, /* expression operators for printing */
@@ -981,6 +996,14 @@ class auto_language : public language_defn
{
error (_("unimplemented auto_language::printstr called"));
}
+
+ /* See language.h. */
+
+ void print_typedef (struct type *type, struct symbol *new_symbol,
+ struct ui_file *stream) const override
+ {
+ error (_("unimplemented auto_language::print_typedef called"));
+ }
};
/* Single instance of the fake "auto" language. */
diff --git a/gdb/language.h b/gdb/language.h
index a68b6dfdcae..19cd8205718 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -225,13 +225,6 @@ struct language_data
const struct exp_descriptor *la_exp_desc;
- /* Print a typedef using syntax appropriate for this language.
- TYPE is the underlying type. NEW_SYMBOL is the symbol naming
- the type. STREAM is the output stream on which to print. */
-
- void (*la_print_typedef) (struct type *type, struct symbol *new_symbol,
- struct ui_file *stream);
-
/* Now come some hooks for lookup_symbol. */
/* If this is non-NULL, specifies the name that of the implicit
@@ -552,6 +545,14 @@ struct language_defn : language_data
const char *encoding, int force_ellipses,
const struct value_print_options *options) const;
+
+ /* Print a typedef using syntax appropriate for this language.
+ TYPE is the underlying type. NEW_SYMBOL is the symbol naming
+ the type. STREAM is the output stream on which to print. */
+
+ virtual void print_typedef (struct type *type, struct symbol *new_symbol,
+ struct ui_file *stream) const;
+
protected:
/* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
@@ -648,7 +649,7 @@ extern enum language set_language (enum language);
(current_language->print_type(type,varstring,stream,show,level,flags))
#define LA_PRINT_TYPEDEF(type,new_symbol,stream) \
- (current_language->la_print_typedef(type,new_symbol,stream))
+ (current_language->print_typedef (type,new_symbol,stream))
#define LA_VALUE_PRINT(val,stream,options) \
(current_language->value_print (val,stream,options))
@@ -715,10 +716,6 @@ extern char *language_demangle (const struct language_defn *current_language,
(and returned) by reference at the language level. */
struct language_pass_by_ref_info language_pass_by_reference (struct type *type);
-/* The default implementation of la_print_typedef. */
-void default_print_typedef (struct type *type, struct symbol *new_symbol,
- struct ui_file *stream);
-
void c_get_string (struct value *value,
gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
int *length, struct type **char_type,
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index b84a9a49f84..f0f7c22fb5d 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -229,7 +229,6 @@ extern const struct language_data m2_language_data =
macro_expansion_no,
NULL,
&exp_descriptor_modula2,
- m2_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
m2_op_print_tab, /* expression operators for printing */
@@ -427,6 +426,15 @@ class m2_language : public language_defn
if (force_ellipses || i < length)
fputs_filtered ("...", stream);
}
+
+ /* See language.h. */
+
+ void print_typedef (struct type *type, struct symbol *new_symbol,
+ struct ui_file *stream) const override
+ {
+ m2_print_typedef (type, new_symbol, stream);
+ }
+
};
/* Single instance of the M2 language. */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 95c6c0a1fc5..0c952730a96 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -337,7 +337,6 @@ extern const struct language_data objc_language_data =
macro_expansion_c,
objc_extensions,
&exp_descriptor_standard,
- c_print_typedef, /* Print a typedef using appropriate syntax */
"self", /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
objc_op_print_tab, /* Expression operators for printing */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 765202aac0a..2431faed00e 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1016,7 +1016,6 @@ extern const struct language_data opencl_language_data =
macro_expansion_c,
NULL,
&exp_descriptor_opencl,
- c_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 1c6aea90b6c..9fd823185b1 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -276,7 +276,6 @@ extern const struct language_data pascal_language_data =
macro_expansion_no,
p_extensions,
&exp_descriptor_standard,
- pascal_print_typedef, /* Print a typedef using appropriate syntax */
"this", /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
pascal_op_print_tab, /* expression operators for printing */
@@ -494,6 +493,15 @@ class pascal_language : public language_defn
if (force_ellipses || i < length)
fputs_filtered ("...", stream);
}
+
+ /* See language.h. */
+
+ void print_typedef (struct type *type, struct symbol *new_symbol,
+ struct ui_file *stream) const override
+ {
+ pascal_print_typedef (type, new_symbol, stream);
+ }
+
};
/* Single instance of the Pascal language class. */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index b13623fe619..083b3f73277 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -765,19 +765,6 @@ rust_print_struct_def (struct type *type, const char *varstring,
fputs_filtered (is_tuple_struct ? ")" : "}", stream);
}
-/* la_print_typedef implementation for Rust. */
-
-static void
-rust_print_typedef (struct type *type,
- struct symbol *new_symbol,
- struct ui_file *stream)
-{
- type = check_typedef (type);
- fprintf_filtered (stream, "type %s = ", new_symbol->print_name ());
- type_print (type, "", stream, 0);
- fprintf_filtered (stream, ";");
-}
-
/* la_print_type implementation for Rust. */
static void
@@ -1953,7 +1940,6 @@ extern const struct language_data rust_language_data =
macro_expansion_no,
rust_extensions,
&exp_descriptor_rust,
- rust_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
@@ -2155,6 +2141,17 @@ class rust_language : public language_defn
rust_printstr (stream, elttype, string, length, encoding,
force_ellipses, options);
}
+
+ /* See language.h. */
+
+ void print_typedef (struct type *type, struct symbol *new_symbol,
+ struct ui_file *stream) const override
+ {
+ type = check_typedef (type);
+ fprintf_filtered (stream, "type %s = ", new_symbol->print_name ());
+ type_print (type, "", stream, 0);
+ fprintf_filtered (stream, ";");
+ }
};
/* Single instance of the Rust language class. */
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 37409d9a210..08b9a426eac 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -368,15 +368,6 @@ typedef_print (struct type *type, struct symbol *newobj, struct ui_file *stream)
LA_PRINT_TYPEDEF (type, newobj, stream);
}
-/* The default way to print a typedef. */
-
-void
-default_print_typedef (struct type *type, struct symbol *new_symbol,
- struct ui_file *stream)
-{
- error (_("Language not supported."));
-}
-
/* Print a description of a type TYPE in the form of a declaration of a
variable named VARSTRING. (VARSTRING is demangled if necessary.)
Output goes to STREAM (via stdio).
--
2.25.4
next prev parent reply other threads:[~2020-06-18 22:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-18 22:31 [PATCH 0/7] Language Class Hierarchy Conversion (Prt 3) Andrew Burgess
2020-06-18 22:31 ` [PATCH 1/7] gdb: Convert language la_parser field to a method Andrew Burgess
2020-06-18 22:31 ` [PATCH 2/7] gdb: Convert language la_post_parser " Andrew Burgess
2020-06-18 22:31 ` [PATCH 3/7] gdb: Convert language la_emitchar " Andrew Burgess
2020-06-18 22:31 ` [PATCH 4/7] gdb: Convert language la_printchar " Andrew Burgess
2020-06-18 22:31 ` [PATCH 5/7] gdb: Convert language la_printstr " Andrew Burgess
2020-06-18 22:31 ` Andrew Burgess [this message]
2020-06-18 22:31 ` [PATCH 7/7] gdb: Convert language la_is_string_type_p " Andrew Burgess
2020-06-19 14:25 ` [PATCH 0/7] Language Class Hierarchy Conversion (Prt 3) Tom Tromey
2020-06-19 16:18 ` 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=8450ff191dc0de63ba68e21186ed8cb24b7ce000.1592519094.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).