From b7c6e27dbbbbe678b2e2f0bf617605e055e1b378 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Tue, 4 Aug 2020 17:07:59 +0100 Subject: [PATCH] gdb: Convert language_data::la_op_print_tab to a method Convert language_data::la_op_print_tab member variable to a virtual method language_defn::opcode_print_table. I changed the name in order to make it clearer (I hope) what the method does. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_op_print_tab initializer. (ada_language::opcode_print_table): New member function. * c-lang.c (c_language_data): Remove la_op_print_tab initializer. (c_language::opcode_print_table): New member function. (cplus_language_data): Remove la_op_print_tab initializer. (cplus_language::opcode_print_table): New member function. (asm_language_data): Remove la_op_print_tab initializer. (asm_language::opcode_print_table): New member function. (minimal_language_data): Remove la_op_print_tab initializer. (minimal_language::opcode_print_table): New member function. * d-lang.c (d_language_data): Remove la_op_print_tab initializer. (d_language::opcode_print_table): New member function. * expprint.c (print_subexp_standard): Update call to opcode_print_table. (op_string): Likewise. * f-lang.c (f_language_data): Remove la_op_print_tab initializer. (f_language::opcode_print_table): New member function. * go-lang.c (go_language_data): Remove la_op_print_tab initializer. (go_language::opcode_print_table): New member function. * language.c (unknown_language_data): Remove la_op_print_tab initializer. (unknown_language::opcode_print_table): New member function. (auto_language_data): Remove la_op_print_tab initializer. (auto_language::opcode_print_table): New member function. * language.h (language_data): Remove la_op_print_tab field. (language_defn::opcode_print_table): Declare new member function. * m2-lang.c (m2_language_data): Remove la_op_print_tab initializer. (m2_language::opcode_print_table): New member function. * objc-lang.c (objc_language_data): Remove la_op_print_tab initializer. (objc_language::opcode_print_table): New member function. * opencl-lang.c (opencl_language_data): Remove la_op_print_tab initializer. (opencl_language::opcode_print_table): New member function. * p-lang.c (pascal_language_data): Remove la_op_print_tab initializer. (pascal_language::opcode_print_table): New member function. * rust-lang.c (rust_language_data): Remove la_op_print_tab initializer. (rust_language::opcode_print_table): New member function. --- gdb/ChangeLog | 46 ++++++++++++++++++++++++++++++++++++++++++++++ gdb/ada-lang.c | 6 +++++- gdb/c-lang.c | 24 ++++++++++++++++++++---- gdb/d-lang.c | 6 +++++- gdb/expprint.c | 4 ++-- gdb/f-lang.c | 6 +++++- gdb/go-lang.c | 6 +++++- gdb/language.c | 12 ++++++++++-- gdb/language.h | 7 ++++--- gdb/m2-lang.c | 6 +++++- gdb/objc-lang.c | 6 +++++- gdb/opencl-lang.c | 6 +++++- gdb/p-lang.c | 6 +++++- gdb/rust-lang.c | 6 +++++- 14 files changed, 127 insertions(+), 20 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d646595e73..f1fcbcfa82 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,49 @@ +2020-09-16 Andrew Burgess + + * ada-lang.c (ada_language_data): Remove la_op_print_tab + initializer. + (ada_language::opcode_print_table): New member function. + * c-lang.c (c_language_data): Remove la_op_print_tab initializer. + (c_language::opcode_print_table): New member function. + (cplus_language_data): Remove la_op_print_tab initializer. + (cplus_language::opcode_print_table): New member function. + (asm_language_data): Remove la_op_print_tab initializer. + (asm_language::opcode_print_table): New member function. + (minimal_language_data): Remove la_op_print_tab initializer. + (minimal_language::opcode_print_table): New member function. + * d-lang.c (d_language_data): Remove la_op_print_tab initializer. + (d_language::opcode_print_table): New member function. + * expprint.c (print_subexp_standard): Update call to + opcode_print_table. + (op_string): Likewise. + * f-lang.c (f_language_data): Remove la_op_print_tab initializer. + (f_language::opcode_print_table): New member function. + * go-lang.c (go_language_data): Remove la_op_print_tab + initializer. + (go_language::opcode_print_table): New member function. + * language.c (unknown_language_data): Remove la_op_print_tab + initializer. + (unknown_language::opcode_print_table): New member function. + (auto_language_data): Remove la_op_print_tab initializer. + (auto_language::opcode_print_table): New member function. + * language.h (language_data): Remove la_op_print_tab field. + (language_defn::opcode_print_table): Declare new member function. + * m2-lang.c (m2_language_data): Remove la_op_print_tab + initializer. + (m2_language::opcode_print_table): New member function. + * objc-lang.c (objc_language_data): Remove la_op_print_tab + initializer. + (objc_language::opcode_print_table): New member function. + * opencl-lang.c (opencl_language_data): Remove la_op_print_tab + initializer. + (opencl_language::opcode_print_table): New member function. + * p-lang.c (pascal_language_data): Remove la_op_print_tab + initializer. + (pascal_language::opcode_print_table): New member function. + * rust-lang.c (rust_language_data): Remove la_op_print_tab + initializer. + (rust_language::opcode_print_table): New member function. + 2020-09-16 Andrew Burgess * ada-lang.c (ada_language_data): Remove la_exp_desc initializer. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 876125c4f1..edf0d6b135 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13708,7 +13708,6 @@ ada_get_symbol_name_matcher (const lookup_name_info &lookup_name) extern const struct language_data ada_language_data = { - ada_op_print_tab, /* expression operators for printing */ }; /* Class representing the Ada language. */ @@ -14210,6 +14209,11 @@ public: const struct exp_descriptor *expression_ops () const override { return &ada_exp_descriptor; } + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return ada_op_print_tab; } + protected: /* See language.h. */ diff --git a/gdb/c-lang.c b/gdb/c-lang.c index f29f3407e1..73968ed20f 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -875,7 +875,6 @@ const struct exp_descriptor exp_descriptor_c = extern const struct language_data c_language_data = { - c_op_print_tab, /* expression operators for printing */ }; /* Class representing the C language. */ @@ -951,6 +950,11 @@ public: const struct exp_descriptor *expression_ops () const override { return &exp_descriptor_c; } + + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return c_op_print_tab; } }; /* Single instance of the C language class. */ @@ -989,7 +993,6 @@ enum cplus_primitive_types { extern const struct language_data cplus_language_data = { - c_op_print_tab, /* expression operators for printing */ }; /* A class for the C++ language. */ @@ -1187,6 +1190,11 @@ public: const struct exp_descriptor *expression_ops () const override { return &exp_descriptor_c; } + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return c_op_print_tab; } + protected: /* See language.h. */ @@ -1206,7 +1214,6 @@ static cplus_language cplus_language_defn; extern const struct language_data asm_language_data = { - c_op_print_tab, /* expression operators for printing */ }; /* A class for the ASM language. */ @@ -1269,6 +1276,11 @@ public: const struct exp_descriptor *expression_ops () const override { return &exp_descriptor_c; } + + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return c_op_print_tab; } }; /* The single instance of the ASM language class. */ @@ -1281,7 +1293,6 @@ static asm_language asm_language_defn; extern const struct language_data minimal_language_data = { - c_op_print_tab, /* expression operators for printing */ }; /* A class for the minimal language. */ @@ -1333,6 +1344,11 @@ public: const struct exp_descriptor *expression_ops () const override { return &exp_descriptor_c; } + + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return c_op_print_tab; } }; /* The single instance of the minimal language class. */ diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 4b8020e2ec..f9967868e1 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -128,7 +128,6 @@ enum d_primitive_types { extern const struct language_data d_language_data = { - d_op_print_tab, /* Expression operators for printing. */ }; /* Class representing the D language. */ @@ -280,6 +279,11 @@ public: const struct exp_descriptor *expression_ops () const override { return &exp_descriptor_c; } + + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return d_op_print_tab; } }; /* Single instance of the D language class. */ diff --git a/gdb/expprint.c b/gdb/expprint.c index 8cca5b4f92..5bd9553a41 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -73,7 +73,7 @@ print_subexp_standard (struct expression *exp, int *pos, struct value *val; char *tempstr = NULL; - op_print_tab = exp->language_defn->la_op_print_tab; + op_print_tab = exp->language_defn->opcode_print_table (); pc = (*pos)++; opcode = exp->elts[pc].opcode; switch (opcode) @@ -669,7 +669,7 @@ op_string (enum exp_opcode op) int tem; const struct op_print *op_print_tab; - op_print_tab = current_language->la_op_print_tab; + op_print_tab = current_language->opcode_print_table (); for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++) if (op_print_tab[tem].opcode == op) return op_print_tab[tem].string; diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 2bf046d64f..510d06737e 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -486,7 +486,6 @@ static const struct exp_descriptor exp_descriptor_f = extern const struct language_data f_language_data = { - f_op_print_tab, /* expression operators for printing */ }; /* Class representing the Fortran language. */ @@ -736,6 +735,11 @@ public: const struct exp_descriptor *expression_ops () const override { return &exp_descriptor_f; } + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return f_op_print_tab; } + protected: /* See language.h. */ diff --git a/gdb/go-lang.c b/gdb/go-lang.c index eacc4debf4..2b9be93b2e 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -508,7 +508,6 @@ enum go_primitive_types { extern const struct language_data go_language_data = { - go_op_print_tab, /* Expression operators for printing. */ }; /* Class representing the Go language. */ @@ -641,6 +640,11 @@ public: const struct exp_descriptor *expression_ops () const override { return &exp_descriptor_c; } + + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return go_op_print_tab; } }; /* Single instance of the Go language class. */ diff --git a/gdb/language.c b/gdb/language.c index b467512e80..37aef2cd73 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -816,7 +816,6 @@ unknown_language_arch_info (struct gdbarch *gdbarch, extern const struct language_data unknown_language_data = { - unk_op_print_tab, /* expression operators for printing */ }; /* Class representing the unknown language. */ @@ -937,6 +936,11 @@ public: bool store_sym_names_in_linkage_form_p () const override { return true; } + + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return unk_op_print_tab; } }; /* Single instance of the unknown language class. */ @@ -947,7 +951,6 @@ static unknown_language unknown_language_defn; extern const struct language_data auto_language_data = { - unk_op_print_tab, /* expression operators for printing */ }; /* Class representing the fake "auto" language. */ @@ -1063,6 +1066,11 @@ public: const char *name_of_this () const override { return "this"; } + + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return unk_op_print_tab; } }; /* Single instance of the fake "auto" language. */ diff --git a/gdb/language.h b/gdb/language.h index cfb3461a8c..2d13cfa9db 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -168,9 +168,6 @@ extern const char *default_word_break_characters (void); struct language_data { - /* Table for printing expressions. */ - - const struct op_print *la_op_print_tab; }; /* Base class from which all other language classes derive. */ @@ -567,6 +564,10 @@ struct language_defn : language_data virtual const struct exp_descriptor *expression_ops () const; + /* Table for printing expressions. */ + + virtual const struct op_print *opcode_print_table () const = 0; + protected: /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method. diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index b41d0b48d6..1f9c8a878e 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -199,7 +199,6 @@ const struct exp_descriptor exp_descriptor_modula2 = extern const struct language_data m2_language_data = { - m2_op_print_tab, /* expression operators for printing */ }; /* Class representing the M2 language. */ @@ -448,6 +447,11 @@ public: const struct exp_descriptor *expression_ops () const override { return &exp_descriptor_modula2; } + + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return m2_op_print_tab; } }; /* Single instance of the M2 language. */ diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index e78e0871aa..b59a45b49b 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -323,7 +323,6 @@ static const struct op_print objc_op_print_tab[] = extern const struct language_data objc_language_data = { - objc_op_print_tab, /* Expression operators for printing */ }; /* Class representing the Objective-C language. */ @@ -427,6 +426,11 @@ public: enum macro_expansion macro_expansion () const override { return macro_expansion_c; } + + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return c_op_print_tab; } }; /* Single instance of the class representing the Objective-C language. */ diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index e7186ebbf3..df99fdc2f4 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -1006,7 +1006,6 @@ const struct exp_descriptor exp_descriptor_opencl = /* Constant data representing the OpenCL language. */ extern const struct language_data opencl_language_data = { - c_op_print_tab, /* expression operators for printing */ }; /* Class representing the OpenCL language. */ @@ -1074,6 +1073,11 @@ public: const struct exp_descriptor *expression_ops () const override { return &exp_descriptor_opencl; } + + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return c_op_print_tab; } }; /* Single instance of the OpenCL language class. */ diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 1acd591d41..6a9811d869 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -252,7 +252,6 @@ enum pascal_primitive_types { extern const struct language_data pascal_language_data = { - pascal_op_print_tab, /* expression operators for printing */ }; /* Class representing the Pascal language. */ @@ -507,6 +506,11 @@ public: bool range_checking_on_by_default () const override { return true; } + + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return pascal_op_print_tab; } }; /* Single instance of the Pascal language class. */ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 8c952e394f..1971a8d3a3 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1901,7 +1901,6 @@ static const struct exp_descriptor exp_descriptor_rust = extern const struct language_data rust_language_data = { - c_op_print_tab, /* expression operators for printing */ }; /* Class representing the Rust language. */ @@ -2153,6 +2152,11 @@ public: const struct exp_descriptor *expression_ops () const override { return &exp_descriptor_rust; } + + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return c_op_print_tab; } }; /* Single instance of the Rust language class. */ -- 2.34.1