aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
AgeCommit message (Collapse)AuthorFilesLines
2020-10-09ada-lang.c::advance_wild_match improve doc and parameter+temporaries typesJoel Brobecker1-6/+6
This commit fixes the type of one of the parameters as well as a couple of temporaries. While at it, the function's description is slightly rewritten to make it a little clearer what the function does. gdb/ChangeLog: * ada-lang.c (advance_wild_match): Rewrite the function's description. Change the type of target0, t0 and t1 to char.
2020-10-09Return std::string from ada_encodeTom Tromey1-35/+15
This changes ada_encode to return a std::string. This simplifies it somewhat, removes a use of GROW_VECT, and is also simpler for callers to use. gdb/ChangeLog 2020-10-09 Tom Tromey <tromey@adacore.com> * ada-lang.h (ada_encode): Return std::string. * ada-lang.c (ada_encode_1): Return std::string. (ada_encode): Likewise. (type_from_tag, ada_lookup_name_info::ada_lookup_name_info): Update. * ada-exp.y (block_lookup, write_var_or_type): Update.
2020-09-16gdb: Remove language_data structAndrew Burgess1-7/+1
The language_data type, from which language_defn inherits, is now empty, and this commit removes it. Each language is updated to no longer create and use a language_data struct. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Delete. (ada_language): Remove references to ada_language_data. * c-lang.c (c_language_data): Delete. (c_language): Remove references to c_language_data. (cplus_language_data): Delete. (cplus_language): Remove references to cplus_language_data. (asm_language_data): Delete. (asm_language): Remove references to asm_language_data. (minimal_language_data): Delete. (minimal_language): Remove references to minimal_language_data. * d-lang.c (d_language_data): Delete. (d_language): Remove references to d_language_data. * f-lang.c (f_language_data): Delete. (f_language): Remove references to f_language_data. * go-lang.c (go_language_data): Delete. (go_language): Remove references to go_language_data. * language.c (unknown_language_data): Delete. (unknown_language): Remove references to unknown_language_data. (auto_language_data): Delete. (auto_language): Remove references to auto_language_data. * language.h (language_data): Delete struct. (language_defn): No longer inherit from language_data. * m2-lang.c (m2_language_data): Delete. (m2_language): Remove references to m2_language_data. * objc-lang.c (objc_language_data): Delete. (objc_language): Remove references to objc_language_data. * opencl-lang.c (opencl_language_data): Delete. (opencl_language): Remove references to opencl_language_data. * p-lang.c (pascal_language_data): Delete. (pascal_language): Remove references to pascal_language_data. * rust-lang.c (rust_language_data): Delete. (rust_language): Remove references to rust_language_data.
2020-09-16gdb: Convert language_data::la_op_print_tab to a methodAndrew Burgess1-1/+5
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.
2020-09-16gdb: Convert language_data::la_exp_desc to a methodAndrew Burgess1-1/+5
Convert language_data::la_exp_desc member variable to a virtual method language_defn::expression_ops. The change of names brings this method more into line with the existing varobj_ops method, that also returns a table of function pointers. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_exp_desc initializer. (ada_language::expression_ops): New member function. * c-lang.c (c_language_data): Remove la_exp_desc initializer. (c_language::expression_ops): New member function. (cplus_language_data): Remove la_exp_desc initializer. (cplus_language::expression_ops): New member function. (asm_language_data): Remove la_exp_desc initializer. (asm_language::expression_ops): New member function. (minimal_language_data): Remove la_exp_desc initializer. (minimal_language::expression_ops): New member function. * d-lang.c (d_language_data): Remove la_exp_desc initializer. (d_language::expression_ops): New member function. * eval.c (evaluate_subexp): Update call to expression_ops. * expprint.c (print_subexp): Likewise. (op_name): Likewise. (dump_subexp_body): Likewise. * f-lang.c (f_language_data): Remove la_exp_desc initializer. (f_language::expression_ops): New member function. * go-lang.c (go_language_data): Remove la_exp_desc initializer. (go_language::expression_ops): New member function. * language.c (language_defn::expression_ops): New function. (unknown_language_data): Remove la_exp_desc initializer. (auto_language_data): Likewise. * language.h (language_data): Remove la_exp_desc field. (language_defn::expression_ops): Declare new member function. * m2-lang.c (m2_language_data): Remove la_exp_desc initializer. (m2_language::expression_ops): New member function. * objc-lang.c (objc_language_data): Remove la_exp_desc initializer. * opencl-lang.c (opencl_language_data): Remove la_exp_desc initializer. (opencl_language::expression_ops): New member function. * p-lang.c (pascal_language_data): Remove la_exp_desc initializer. * parse.c (operator_length): Update call to expression_ops. (exp_iterate): Likewise. * rust-lang.c (rust_language_data): Remove la_exp_desc initializer. (ruse_language::expression_ops): New member function.
2020-09-16gdb: Convert language_data::la_varobj_ops to a methodAndrew Burgess1-1/+5
Convert language_data::la_varobj_ops member variable to a virtual method language_defn::varobj_ops. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_varobj_ops initializer. (ada_language::varobj_ops): New member function. * c-lang.c (c_language_data): Remove la_varobj_ops initializer. (cplus_language_data): Likewise. (cplus_language::varobj_ops): New member function. (asm_language_data): Remove la_varobj_ops initializer. (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 (language_defn::varobj_ops): New function. (unknown_language_data): Remove la_varobj_ops initializer. (auto_language_data): Likewise. * language.h (language_data): Remove la_varobj_ops field. (language_defn::varobj_ops): Declare new member function. * m2-lang.c (m2_language_data): Remove la_varobj_ops 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. * varobj.c (varobj_create): Update call to varobj_ops. * varobj.h (default_varobj_ops): Delete define.
2020-09-16gdb: Convert language_data::la_macro_expansion to a methodAndrew Burgess1-1/+0
Convert language_data::la_macro_expansion member variable to a virtual method language_defn::macro_expansion. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_macro_expansion initializer. * c-lang.c (c_language_data): Likewise. (c_language::macro_expansion): New member function. (cplus_language_data): Likewise. (cplus_language::macro_expansion): New member function. (asm_language_data): Likewise. (asm_language::macro_expansion): New member function. (minimal_language_data): Likewise. (minimal_language::macro_expansion): New member function. * d-lang.c (d_language_data): Remove la_macro_expansion initializer. * f-lang.c (f_language_data): Likewise. * go-lang.c (go_language_data): Likewise. * language.c (unknown_language_data): Likewise. (auto_language_data): Likewise. * language.h (language_data): Remove la_macro_expansion field. (language_defn::macro_expansion): New member function. * m2-lang.c (m2_language_data): Remove la_macro_expansion initializer. * objc-lang.c (objc_language_data): Likewise. (objc_language::macro_expansion): New member function. * opencl-lang.c (opencl_language_data): Likewise. (opencl_language::macro_expansion): New member function. * p-lang.c (pascal_language_data): Remove la_macro_expansion initializer. * rust-lang.c (rust_language_data): Likewise. * symtab.c (default_collect_symbol_completion_matches_break_on): Update call to macro_expansion.
2020-09-16gdb: Convert language_data::la_array_ordering to a methodAndrew Burgess1-1/+0
Convert language_data::la_array_ordering member variable to a virtual method language_defn::array_ordering. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_array_ordering initializer. * c-lang.c (c_language_data): Likewise. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * dwarf2/read.c (read_array_order): Update for call to array_ordering. * f-lang.c (f_language_data): Remove la_array_ordering initializer. (f_language::array_ordering): New member function. * go-lang.c (go_language_data): Remove la_array_ordering initializer. * language.c (unknown_language_data): Likewise. (auto_language_data): Likewise. * language.h (language_data): Delete la_array_ordering field. (language_defn::array_ordering): New member function. * m2-lang.c (m2_language_data): Remove la_array_ordering 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-09-16gdb: Convert language_data::la_case_sensitivity to a methodAndrew Burgess1-2/+0
Convert language_data::la_case_sensitivity member variable to a virtual method language_defn::case_sensitivity. This is mostly straight forward. The only slight problem is that I ended up deleting this comment from ada-lang.c: /* Yes, Ada is case-insensitive, but that's not quite what this means. */ However, as the comment (which has existed since Ada support was first added to GDB) doesn't explain _why_ Ada sets case sensitivity to on despite being a generally case insensitive language, this doesn't really help me much. If I understood _why_ the setting doesn't quite mean what it seems to mean (at least as far as Ada is concerned) then I would extend the comment on language_defn::case_sensitivity (in language.h) to include the detail, and note how this impacts Ada. But as it stands I've just deleted the comment for now. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_case_sensitivity initializer. * c-lang.c (c_language_data): Likewise. (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::case_sensitivity): New member function. * go-lang.c (go_language_data): Remove la_case_sensitivity initializer. * language.c (enum case_mode): Moved here from language.h. (case_mode): Make static. (show_case_command): Update for case_sensitivity being a method. (set_case_command): Likewise. (set_range_case): Likewise. (unknown_language_data): Remove la_case_sensitivity initializer. (auto_language_data): Likewise. * language.h (case_mode): Delete, move enum declaration to language.c. (language_data): Delete la_case_sensitivity field. (language_defn::case_sensitivity): New member function. * m2-lang.c (m2_language_data): Remove la_case_sensitivity 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-09-16gdb: Convert language_data::la_range_check to a methodAndrew Burgess1-1/+0
Convert language_data::la_range_check member variable to a virtual method language_defn::range_checking_on_by_default. Where the previous member variable was of type 'enum range_check', the new member function returns a boolean that selects between range checking being on or off. This removes the possibility of a language having its default be the third enum state, range_check_warn, which no language currently used. This all makes sense I think, the language's true/false provides the default when the global 'set check range' is set to 'auto'. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_range_check initializer. * c-lang.c (c_language_data): Likewise. (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::range_checking_on_by_default): New member function. * go-lang.c (go_language_data): Remove la_range_check initializer. * language.c (enum range_mode): Moved here from language.h. (range_mode): Made static. (show_range_command): Update to use range_checking_on_by_default. (set_range_command): Likewise. (set_range_case): Likewise. (unknown_language_data): Remove la_range_check initializer. (auto_language_data): Likewise. * language.h (range_mode): Delete. Enum definition moved to language.c. (language_data): Remove la_range_check field. (language_defn::range_checking_on_by_default): New member function. * m2-lang.c (m2_language_data): Remove la_range_check initializer. (m2_language::range_checking_on_by_default): New member function. * objc-lang.c (objc_language_data): Remove la_range_check initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. (pascal_language::range_checking_on_by_default): New member function. * rust-lang.c (rust_language_data): Remove la_range_check initializer. (rust_language::range_checking_on_by_default): New member function.
2020-09-16gdb: Convert la_store_sym_names_in_linkage_form_p to a methodAndrew Burgess1-1/+5
Convert language_data::la_store_sym_names_in_linkage_form_p member variable to language_defn::store_sym_names_in_linkage_form_p virtual function. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_store_sym_names_in_linkage_form_p initializer. (ada_language::store_sym_names_in_linkage_form_p): New member function. * c-lang.c (c_language_data): Remove la_store_sym_names_in_linkage_form_p initializer. (c_language::store_sym_names_in_linkage_form_p): New member function. (cplus_language_data): Remove la_store_sym_names_in_linkage_form_p initializer. (asm_language_data): Likewise. (asm_language::store_sym_names_in_linkage_form_p): New member function. (minimal_language_data): Remove la_store_sym_names_in_linkage_form_p initializer. (minimal_language::store_sym_names_in_linkage_form_p): New member function. * d-lang.c (d_language_data): Remove la_store_sym_names_in_linkage_form_p initializer. * dwarf2/read.c (dwarf2_physname): Update call to store_sym_names_in_linkage_form_p. * f-lang.c (f_language_data): Remove la_store_sym_names_in_linkage_form_p initializer. * go-lang.c (go_language_data): Remove la_store_sym_names_in_linkage_form_p initializer. * language.c (unknown_language_data): Remove la_store_sym_names_in_linkage_form_p initializer. (unknown_language::store_sym_names_in_linkage_form_p): New member function. (auto_language_data): Remove la_store_sym_names_in_linkage_form_p initializer. (auto_language::store_sym_names_in_linkage_form_p): New member function. * language.h (language_data): Remove la_store_sym_names_in_linkage_form_p member variable. (language_defn::store_sym_names_in_linkage_form_p): New member function. * m2-lang.c (m2_language_data): Remove la_store_sym_names_in_linkage_form_p 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-09-16gdb: Convert language_data::string_lower_bound to a methodAndrew Burgess1-1/+0
Convert language_data::string_lower_bound member variable to a virtual method language_defn::string_lower_bound. Over all of the languages we currently support there are currently only two values for the lower bound, 0 or 1. I noticed that in all cases, if a language has C style arrays then the lower bound is 0, otherwise the lower bound is 1. So the default for the virtual method in language.h makes use of this, which means languages don't have to worry about providing a string_lower_bound method at all. Except for Modula2. This language is defined to not have C style arrays, but has a string_lower_bound index of 0, this behaviour is maintained after this commit by having Modula2 be the only language that overrides the string_lower_bound method. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove string_lower_bound initializer. * c-lang.c (c_language_data): Likewise. (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. * go-lang.c (go_language_data): Likewise. * language.c (unknown_language_data): Likewise. (auto_language_data): Likewise. * language.h (language_data): Remove string_lower_bound field. (language_defn::string_lower_bound): New member function. * m2-lang.c (m2_language_data): Remove string_lower_bound initializer. (m2_language::string_lower_bound): New member function. * objc-lang.c (objc_language_data): Remove string_lower_bound initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. * rust-lang.c (rust_language_data): Likewise. * valops.c (value_cstring): Update call to string_lower_bound. (value_string): Likewise. * value.c (allocate_repeated_value): Likewise.
2020-09-16gdb: Convert language_data::c_style_arrays to a methodAndrew Burgess1-1/+5
Convert language_data::c_style_arrays member variable to a virtual method language_defn::c_style_arrays_p. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove c_style_arrays initializer. (ada_language::c_style_arrays_p): New member fuction. * c-lang.c (c_language_data): Remove c_style_arrays initializer. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * eval.c (ptrmath_type_p): Update call to c_style_arrays_p. * f-lang.c (f_language_data): Remove c_style_arrays initializer. (f_language::c_style_arrays_p): New member function. * go-lang.c (go_language_data): Remove c_style_arrays initializer. * infcall.c (value_arg_coerce): Update call to c_style_arrays_p. * language.c (unknown_language_data): Remove c_style_arrays initializer. (auto_language_data): Likewise. * language.h (language_data): Remove c_style_arrays field. (language_defn::c_style_arrays_p): New member function. * m2-lang.c (m2_language_data): Remove c_style_arrays initializer. (m2_language::c_style_arrays_p): New member function. * objc-lang.c (objc_language_data): Remove c_style_arrays initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. * rust-lang.c (rust_language_data): Likewise. * valarith.c (value_subscript): Update call to c_style_arrays_p, and update local variable to a bool. * valops.c (value_cast): Update call to c_style_arrays_p. (value_array): Likewise. * value.c (coerce_array): Likewise.
2020-09-16gdb: Move la_language into the language_defn classAndrew Burgess1-1/+0
Move the language_data::la_language member variable into the langage_defn class. I have not made the la_language member variable a method of langage_defn simply because of the large number of places that la_language is referenced throughout GDB. I have made the new member variable constant though, so this should prevent accidental assignment. In the future we might consider converting la_language to a method, but right now my goal is to remove the langage_data class, so I'm happy to leave la_language as a constant member variable. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_language initializer. * c-lang.c (c_language_data): Likewise. (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. * go-lang.c (go_language_data): Likewise. * language.c (unknown_language_data): Likewise. (auto_language_data): Likewise. * language.h (language_data): Remove la_language field. (language_defn::language_defn): Initialise la_language field. (language_defn::la_language): New member variable. * m2-lang.c (m2_language_data): Remove la_language field. * 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-09-16gdb: Convert la_filename_extensions to a methodAndrew Burgess1-6/+9
Convert language_data::la_filename_extensions member variable to a virtual method language_defn::filename_extensions. The new method returns a vector of filename extensions, which means that where previously we needed a NULL marker on the end of the list, we can now discard this. All of the old arrays that contained the extensions now become static data within each languages filename_extensions method. I've updated the single use of the filename_extensions method to make use of this method returning a vector. And, just in case anyone accidentally adds a NULL marked into a languages extensions list, I've added a new assert in add_filename_language (symtab.c) to catch this. gdb/ChangeLog: * ada-lang.c (ada_extensions): Delete, moved into ada_language::filename_extensions. (ada_language_data): Remove la_filename_extensions initializer. (ada_language::filename_extensions): New member function. * c-lang.c (c_extensions): Delete, moved into c_language::filename_extensions. (c_language_data): Remove la_filename_extensions initializer. (c_language::filename_extensions): New member function. (cplus_extensions): Delete, moved into cplus_language::filename_extensions. (cplus_language_data): Remove la_filename_extensions initializer. (cplus_language::filename_extensions): New member function. (asm_extensions): Delete, moved into asm_language::filename_extensions. (asm_language_data): Remove la_filename_extensions initializer. (asm_language::filename_extensions): New member function. (minimal_language_data): Remove la_filename_extensions initializer. * d-lang.c (d_extensions): Delete, moved into d_language::filename_extensions. (d_language_data): Remove la_filename_extensions initializer. (d_language::filename_extensions): New member function. * f-lang.c (f_extensions): Delete, moved into f_language::filename_extensions. (f_language_data): Remove la_filename_extensions initializer. (f_language::filename_extensions): New member function. * go-lang.c (go_language_data): Remove la_filename_extensions initializer. * language.c (add_set_language_command): Update now that filename_extensions returns a vector. (unknown_language_data): Remove la_filename_extensions initializer. (auto_language_data): Likewise. * language.h (language_data): Remove la_filename_extensions field. (language_defn::filename_extensions): New member function. * m2-lang.c (m2_language_data): Remove la_filename_extensions initializer. * objc-lang.c (objc_extensions): Delete, moved into objc_language::filename_extensions. (objc_language_data): Remove la_filename_extensions initializer. (objc_language::filename_extensions): New member function. * opencl-lang.c (opencl_language_data): Remove la_filename_extensions initializer. * p-lang.c (pascal_extensions): Delete, moved into pascal_language::filename_extensions. (pascal_language_data): Remove la_filename_extensions initializer. (pascal_language::filename_extensions): New member function. * rust-lang.c (rust_extensions): Delete, moved into rust_language::filename_extensions. (rust_language_data): Remove la_filename_extensions initializer. (rust_language::filename_extensions): New member function. * symfile.c (add_filename_language): Add new assert.
2020-09-16gdb: Convert la_name and la_natural_name to methodsAndrew Burgess1-2/+10
Convert the two language_data member variables la_name and la_natural_name to virtual methods in language_defn struct called name and natural_name respectively. The virtual methods in the language_defn base class are pure virtual, as every language must implement these, and as every language has a unique name there's no sensible default here. Given that every language must implement these methods I did wonder about making this data passed into the base class constructor, but in the end I went with the virtual method approach. I'm open to changing this approach if people prefer the constructor approach. During updating the calls to language_defn::name I found in add_set_language_command a place where we took la_name and then capitalised the first letter to create a language name that could be used in the documentation string. I replaced this with a use of natural_name instead as this seemed a better choice, in most cases this will make no difference, as for most languages the natural_name is just the name with the first character in upper case, but for some languages, for example 'Open-CL' and 'Objective-C' this is not the case. In the case of asm_language the name is 'asm', while the natural_name was previously 'assembly'. I changed the natural name to 'Assembly', this makes the documentation string case above cleaner, however, this will change the MI output for -var-info-expression, where the 'lang' field will change from 'assembly' to 'Assembly'. It is possible this could be a breaking change if a front-end is relying on the existing name. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_name and la_natural_name initializers. (ada_language::name): New member function. (ada_language::natural_name): New member function. * c-lang.c (c_language_data): Remove la_name and la_natural_name initializers. (c_language::name): New member function. (c_language::natural_name): New member function. (cplus_language_data): Remove la_name and la_natural_name initializers. (cplus_language::name): New member function. (cplus_language::natural_name): New member function. (asm_language_data): Remove la_name and la_natural_name initializers. (asm_language::name): New member function. (asm_language::natural_name): New member function. (minimal_language_data): Remove la_name and la_natural_name initializers. (minimal_language::name): New member function. (minimal_language::natural_name): New member function. * compile/compile.c (compile_to_object): Update call to lanugage_defn::name. * d-lang.c (d_language_data): Remove la_name and la_natural_name initializers. (d_language::name): New member function. (d_language::natural_name): New member function. * expprint.c (print_subexp_standard): Update call to language_defn::name. (dump_raw_expression): Likewise (dump_prefix_expression): Likewise. * f-lang.c (f_language_data): Remove la_name and la_natural_name initializers. (f_language::name): New member function. (f_language::natural_name): New member function. * go-lang.c (go_language_data): Remove la_name and la_natural_name initializers. (go_language::name): New member function. (go_language::natural_name): New member function. * language.c (show_language_command): Update call to language_defn::name. (set_language_command): Likewise. (language_enum): Likewise. (language_str): Likewise. (add_set_language_command): Likewise, use language_defn::natural_name in the doc string. (unknown_language_data): Remove la_name and la_natural_name initializers. (unknown_language::name): New member function. (unknown_language::natural_name): New member function. (auto_language_data): Remove la_name and la_natural_name initializers. (auto_language::name): New member function. (auto_language::natural_name): New member function. (language_lookup_primitive_type_as_symbol): Update call to language_defn::name. * language.h (language_data): Remove la_name and la_natural_name member variables. (language_defn::name): New member function. (language_defn::natural_name): New member function. * m2-lang.c (m2_language_data): Remove la_name and la_natural_name initializers. (m2_language::name): New member function. (m2_language::natural_name): New member function. * mi/mi-cmd-var.c (mi_cmd_var_info_expression): Update call to language_defn::natural_name. * objc-lang.c (objc_language_data): Remove la_name and la_natural_name initializers. (objc_language::name): New member function. (objc_language::natural_name): New member function. * opencl-lang.c (opencl_language_data): Remove la_name and la_natural_name initializers. (opencl_language::name): New member function. (opencl_language::natural_name): New member function. * p-lang.c (pascal_language_data): Remove la_name and la_natural_name initializers. (pascal_language::name): New member function. (pascal_language::natural_name): New member function. * rust-lang.c (rust_language_data): Remove la_name and la_natural_name initializers. (rust_language::name): New member function. (rust_language::natural_name): New member function. * symtab.c (lookup_language_this): Update call to language_defn::name.
2020-09-16gdb: Convert la_name_of_this to a methodAndrew Burgess1-1/+0
Convert language_data::la_name_of_this member variable to a virtual method language_defn::name_of_this. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_name_of_this initializer. * ax-gdb.c (gen_expr): Update call to name_of_this. * c-exp.y (classify_name): Likewise. * c-lang.c (c_language_data): Remove la_name_of_this initializer. (cplus_language_data): Likewise. (cplus_language::name_of_this): New member function. (asm_language_data): Remove la_name_of_this initializer. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. (d_language::name_of_this): New member function. * expprint.c (print_subexp_standard): Update call to name_of_this. * f-lang.c (f_language_data): Remove la_name_of_this initializer. * go-lang.c (go_language_data): Likewise. * language.c (unknown_language_data): Likewise. (unknown_language::name_of_this): New member function. (auto_language_data): Remove la_name_of_this initializer. (auto_language::name_of_this): New member function. * language.h (language_data): Delete la_name_of_this member variable. (language_defn::name_of_this): New member function. * m2-lang.c (m2_language_data): Remove la_name_of_this initializer. * objc-lang.c (objc_language_data): Likewise. (objc_language::name_of_this): New member function. * opencl-lang.c (opencl_language_data): Remove la_name_of_this initializer. * p-lang.c (pascal_language_data): Likewise. (pascal_language::name_of_this): New member function. * rust-lang.c (rust_language_data): Remove la_name_of_this initializer. * symtab.c (lookup_language_this): Update call to name_of_this. (lookup_symbol_aux): Likewise. * valops.c (value_of_this): Likewise.
2020-09-16gdb: Convert la_struct_too_deep_ellipsis to a methodAndrew Burgess1-1/+4
Convert language_data::la_struct_too_deep_ellipsis member variable to a method in language_defn. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove la_struct_too_deep_ellipsis initializer. (ada_language::struct_too_deep_ellipsis): New member function. * c-lang.c (c_language_data): Remove la_struct_too_deep_ellipsis initializer. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * cp-valprint.c (cp_print_value): Update call to struct_too_deep_ellipsis. * d-lang.c (d_language_data): Remove la_struct_too_deep_ellipsis initializer. * f-lang.c (f_language_data): Likewise. (f_language::struct_too_deep_ellipsis): New member function. * go-lang.c (go_language_data): Remove la_struct_too_deep_ellipsis initializer. * language.c (unknown_language_data): Likewise. (auto_language_data): Likewise. * language.h (language_data): Delete la_struct_too_deep_ellipsis member variable. (language_defn::struct_too_deep_ellipsis): New member function. * m2-lang.c (m2_language_data): Remove la_struct_too_deep_ellipsis initializer.Q * 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. * valprint.c (val_print_check_max_depth): Update call to struct_too_deep_ellipsis.
2020-09-14Apply 'const' in more placesTom Tromey1-5/+5
Many global arrays in gdb could be marked "const" but are not. This patch changes some of them. (There may be other arrays that could benefit from this treatment. I only examined arrays of strings.) This lets the linker move some symbols to the readonly data section. For example, previously: 0000000000000000 d _ZL18can_use_agent_enum is now: 0000000000000030 r _ZL18can_use_agent_enum 2020-09-14 Tom Tromey <tromey@adacore.com> * x86-tdep.h (x86_in_indirect_branch_thunk): Update. * x86-tdep.c (x86_is_thunk_register_name) (x86_in_indirect_branch_thunk): Update. * sparc64-tdep.c (sparc64_fpu_register_names) (sparc64_cp0_register_names, sparc64_register_names) (sparc64_pseudo_register_names): Now const. * sparc-tdep.h (struct gdbarch_tdep) <fpu_register_names, cp0_registers_num>: Now const. * sparc-tdep.c (sparc_core_register_names) (sparc32_fpu_register_names, sparc32_cp0_register_names) (sparc32_pseudo_register_names): Now const. (validate_tdesc_registers): Update. * rust-lang.c (rust_extensions): Now const. * p-lang.c (p_extensions): Now const. * objc-lang.c (objc_extensions): Now const. * nto-tdep.c (nto_thread_state_str): Now const. * moxie-tdep.c (moxie_register_names): Now const. * mips-tdep.h (struct gdbarch_tdep) <mips_processor_reg_names>: Now const. * mips-tdep.c (mips_generic_reg_names, mips_tx39_reg_names) (mips_linux_reg_names): Now const. (mips_gdbarch_init): Update. * microblaze-tdep.c (microblaze_register_names): Now const. * m68k-tdep.c (m68k_register_names): Now const. * m32r-tdep.c (m32r_register_names): Now const. * ia64-tdep.c (ia64_register_names): Now const. * i386-tdep.h (struct gdbarch_tdep) <register_names, ymmh_register_names, ymm16h_regnum, mpx_register_names, k_register_names, zmmh_register_names, xmm_avx512_register_names, ymm_avx512_register_names, pkeys_register_names>: Now const. * i386-tdep.c (i386_register_names, i386_zmm_names) (i386_zmmh_names, i386_k_names, i386_ymm_names, i386_ymmh_names) (i386_mpx_names, i386_pkeys_names, i386_bnd_names) (i386_mmx_names, i386_byte_names, i386_word_names): Now const. * f-lang.c (f_extensions): Now const. * d-lang.c (d_extensions): Now const. * csky-tdep.c (csky_register_names): Now const. * charset.c (default_charset_names, charset_enum): Now const. (_initialize_charset): Update. * c-lang.c (c_extensions, cplus_extensions, asm_extensions): Now const. * bsd-uthread.c (bsd_uthread_solib_names): Now const. (bsd_uthread_solib_loaded): Update. (bsd_uthread_state): Now const. * amd64-tdep.c (amd64_register_names, amd64_ymm_names) (amd64_ymm_avx512_names, amd64_ymmh_names) (amd64_ymmh_avx512_names, amd64_mpx_names, amd64_k_names) (amd64_zmmh_names, amd64_zmm_names, amd64_xmm_avx512_names) (amd64_pkeys_names, amd64_byte_names, amd64_word_names) (amd64_dword_names): Now const. * agent.c (can_use_agent_enum): Now const. * ada-tasks.c (task_states, long_task_states): Now const. * ada-lang.c (known_runtime_file_name_patterns) (known_auxiliary_function_name_patterns, attribute_names) (standard_exc, ada_extensions): Now const. gdbserver/ChangeLog 2020-09-14 Tom Tromey <tromey@adacore.com> * tracepoint.cc (eval_result_names): Now const. * ax.cc (gdb_agent_op_names): Now const.
2020-09-14gdb: remove TYPE_FIXED_INSTANCESimon Marchi1-5/+5
gdb/ChangeLog: * gdbtypes.h (TYPE_FIXED_INSTANCE): Remove, replace all uses with type::is_fixed_instance. Change-Id: I57731b5ab44aac7d8896a32b9c7481891baea51a
2020-09-14gdb: add type::is_fixed_instance / type::set_is_fixed_instanceSimon Marchi1-6/+6
Add the `is_fixed_instance` and `set_is_fixed_instance` methods on `struct type`, in order to remove the `TYPE_FIXED_INSTANCE` macro. In this patch, the macro is changed to use the getter, so all the call sites of the macro that are used as a setter are changed to use the setter method directly. The next patch will remove the macro completely. gdb/ChangeLog: * gdbtypes.h (struct type) <is_fixed_instance, set_is_fixed_instance>: New methods. (TYPE_FIXED_INSTANCE): Use type::is_fixed_instance, change all write call sites to use type::set_is_fixed_instance. Change-Id: I4401d81512fab9eab4232bbea48ce6c7d586b94c
2020-09-14gdb: remove TYPE_STUBSimon Marchi1-4/+4
gdb/ChangeLog: * gdbtypes.h (TYPE_STUB): Remove, replace all uses with type::is_stub. Change-Id: Iec25b50449a0d10a38f815209e478c343e98632c
2020-09-14gdb: add type::is_stub / type::set_is_stubSimon Marchi1-1/+1
Add the `is_stub` and `set_is_stub` methods on `struct type`, in order to remove the `TYPE_STUB` macro. In this patch, the macro is changed to use the getter, so all the call sites of the macro that are used as a setter are changed to use the setter method directly. The next patch will remove the macro completely. gdb/ChangeLog: * gdbtypes.h (struct type) <is_stub, set_is_stub>: New methods. (TYPE_STUB): Use type::is_stub, change all write call sites to use type::set_is_stub. Change-Id: Ie935e8fe72c908afd8718411e83f4ff00c386bf3
2020-09-14gdb: remove TYPE_UNSIGNEDSimon Marchi1-5/+5
gdb/ChangeLog: * gdbtypes.h (TYPE_UNSIGNED): Remove, replace all uses with type::is_unsigned. Change-Id: I84f76f5cd44ff7294e421d317376a9e476bc8666
2020-09-09Fix latent bug in ada-lang.c:remove_extra_symbolsTom Tromey1-2/+2
I believe ada-lang.c:remove_extra_symbols has a latent bug. This function loops over a vector of symbols, removing duplicates according to some criteria. At the end of the loop it does: if (remove_p) syms->erase (syms->begin () + i); i += 1; However, this seems wrong to me -- when removing the i'th element, this code still increments "i", thus skipping an element. At first I thought this was a regression from the patches to remove cleanups from ada-lang.c (this was when std::vector was introduced); but I found that instead the bug seems to be older: if (remove_p) { for (j = i + 1; j < nsyms; j += 1) syms[j - 1] = syms[j]; nsyms -= 1; } i += 1; No test, as I don't know how to write one. As this is Ada-specific, and was already reviewed internally by Joel, I am checking it in. gdb/ChangeLog 2020-09-09 Tom Tromey <tromey@adacore.com> * ada-lang.c (remove_extra_symbols): Do not increment when removing an element
2020-08-31gdb: remove NULL_TYPESimon Marchi1-48/+48
The NULL_TYPE macro is not very useful... remove it and just use nullptr. gdb/ChangeLog: * gdbtypes.h (NULL_TYPE): Remove, change all uses to nullptr. Change-Id: Ic6215921413dad5649192b012f1a41d0a650a644
2020-07-30gdb: handle non-const property types in ada_modulus (PR ada/26318)Simon Marchi1-1/+8
PR 26318 shows that running `maint print symbols` on an Ada binary, compiled with an Ada distribution that includes debug info for the standard library, triggers this assertion: /home/simark/src/binutils-gdb/gdb/gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed. The problem is in particular when printing type `system__object_reader__decoded_ada_name__TTdecodedSP1___XDL_0`, which has a dynamic high bound (PROP_LOCLIST kind). When printing a concrete value of this type, this type gets resolved to a type with a constant high bound, so ada_modulus can return this constant value. However, when printing the dynamic range type on its own, such as with `maint print symbols`, the high bound is still of kind PROP_LOCLIST. When ada_modulus tries to access the property as a const value, the assert triggers. There's no sensible numerical value to return in this case. Ideally, ada_modulus would return something to the caller indicating that the value is dynamic and therefore can't be returned as an integer. The callers would handle it, for example `maint print symbols` would say that the high bound of the type is dynamic. However, this patch implements the simpler fix of returning 0 in that case. It kind of restores the previous behavior of before we validated the dynamic property kind in the getters, where we would just return whatever random integer value was in `const_val`. Except now it's consistently 0. This is what we had before we added dynamic property getters: $ ./gdb -q ~/foo -ex "maint expand-symtabs" -ex "maint print symbols" -batch | grep 'typedef <system__object_reader__decoded_ada_name__TTdecodedSP1' typedef <system__object_reader__decoded_ada_name__TTdecodedSP1: mod 107820865988257; and this is what we have now: $ ./gdb -q ~/foo -ex "maint expand-symtabs" -ex "maint print symbols" -batch | grep 'typedef <system__object_reader__decoded_ada_name__TTdecodedSP1' typedef <system__object_reader__decoded_ada_name__TTdecodedSP1: mod 0; The value 107820865988257 is the `baton` field of the property's union interpreted as an integer, so a bogus value. gdb/ChangeLog: PR ada/26318 * ada-lang.c (ada_modulus): Return 0 if property is not of const kind. Change-Id: I3f6d343a9c3cd7cd62a4fc591943a43541223d50
2020-07-21gdb: handle undefined properties in ada_discrete_type_{low,high}_boundSimon Marchi1-2/+30
This patch fixes a failure in test `gdb.ada/access_to_packed_array.exp`. The failure was introduced by 8c2e4e0689ea24 ("gdb: add accessors to struct dynamic_prop"), but I think it in fact exposed a latent buglet. Note that to reproduce it, I had to use AdaCore's Ada "distribution" [1]. The one that comes with my distro doesn't have debug info for the standard library stuff, so the bug wouldn't trigger. The bug is that while executing the `maint print symbols` command, we are accessing the value of a range type's high bound dynamic prop as a "const" value (PROP_CONST), when it is actually undefined (PROP_UNDEFINED). It results in this failed assertion: /home/simark/src/binutils-gdb/gdb/gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed. `ada_discrete_type_high_bound` calls `resolve_dynamic_type`, which eventually calls `resolve_dynamic_range`. This one is responsible for evaluating a range type's dynamic bounds in the current context and returning static values. It returns a new range type with these static bounds. The resulting bounds are typically properties of the PROP_CONST kind. But when it's not possible to evaluate the properties, the properties are PROP_UNDEFINED. In the case we are looking at, it's not possible to evaluate the dynamic high bound, which is of type PROP_LOCLIST. It would require a target with registers and a frame, but we run `maint print symbols` without a live process. `ada_discrete_type_high_bound` then accesses the high bound unconditionally as a const value, which triggers the assert. Note that the previous code in resolve_dynamic_range (before commit 8c2e4e0689ea24) did this: prop = &TYPE_RANGE_DATA (dyn_range_type)->high; if (dwarf2_evaluate_property (prop, NULL, addr_stack, &value)) { high_bound.kind = PROP_CONST; high_bound.data.const_val = value; if (TYPE_RANGE_DATA (dyn_range_type)->flag_upper_bound_is_count) high_bound.data.const_val = low_bound.data.const_val + high_bound.data.const_val - 1; } else { high_bound.kind = PROP_UNDEFINED; high_bound.data.const_val = 0; } That did not really made sense, setting the kind to `PROP_UNDEFINED` but also setting the `const_val` field. The `const_val` field is only meaningful if the kind if `PROP_CONST`. The new code (post-8c2e4e0689ea24) simply calls `set_undefined ()`. Fix this by making the caller, `ada_discrete_type_high_bound`, consider that a range high bound could be of kind `PROP_UNDEFINED`, and return 0 in this case. I made the same change in ada_discrete_type_low_bound. I didn't encounter a problem with this function, but the same could in theory happen there. Returning 0 here is kind of a lie, but the goal here is just to restore the behavior of pre-8c2e4e0689ea24. The output of `maint print symbols` is: typedef <ada__exceptions__exception_data__append_info_basic_exception_information__TTnameSP1: range 1 .. 0; record ada__exceptions__exception_data__append_info_basic_exception_information__TTnameSP1: range 1 .. 0; end record; Instead of `1 .. 0`, which does not make sense, we could say something like `1 .. <dynamic>`. But that would require more changes than I'm willing to do at the moment. [1] https://www.adacore.com/download gdb/ChangeLog: PR ada/26235 * gdbtypes.c (ada_discrete_type_low_bound, ada_discrete_type_high_bound): Handle undefined bounds. Change-Id: Ia12167e61ef030941c0790f83294f3418e6a7c12
2020-07-12gdb: make type::bounds work for array and string typesSimon Marchi1-2/+2
Getting the bounds of an array (or string) type is a common operation, and is currently done through its index type: my_array_type->index_type ()->bounds () I think it would make sense to let the `type::bounds` methods work for arrays and strings, as a shorthand for this. It's natural that when asking for the bounds of an array, we get the bounds of the range type used as its index type. In a way, it's equivalent as the now-removed TYPE_ARRAY_{LOWER,UPPER}_BOUND_IS_UNDEFINED and TYPE_ARRAY_{LOWER,UPPER}_BOUND_VALUE, except it returns the `range_bounds` object. The caller is then responsible for getting the property it needs in it. I updated all the spots I could find that could take advantage of this. Note that this also makes `type::bit_stride` work on array types, since `type::bit_stride` uses `type::bounds`. `my_array_type->bit_stride ()` now returns the bit stride of the array's index type. So some spots are also changed to take advantage of this. gdb/ChangeLog: * gdbtypes.h (struct type) <bounds>: Handle array and string types. * ada-lang.c (assign_aggregate): Use type::bounds on array/string type. * c-typeprint.c (c_type_print_varspec_suffix): Likewise. * c-varobj.c (c_number_of_children): Likewise. (c_describe_child): Likewise. * eval.c (evaluate_subexp_for_sizeof): Likewise. * f-typeprint.c (f_type_print_varspec_suffix): Likewise. (f_type_print_base): Likewise. * f-valprint.c (f77_array_offset_tbl): Likewise. (f77_get_upperbound): Likewise. (f77_print_array_1): Likewise. * guile/scm-type.c (gdbscm_type_range): Likewise. * m2-typeprint.c (m2_array): Likewise. (m2_is_long_set_of_type): Likewise. * m2-valprint.c (get_long_set_bounds): Likewise. * p-typeprint.c (pascal_type_print_varspec_prefix): Likewise. * python/py-type.c (typy_range): Likewise. * rust-lang.c (rust_internal_print_type): Likewise. * type-stack.c (type_stack::follow_types): Likewise. * valarith.c (value_subscripted_rvalue): Likewise. * valops.c (value_cast): Likewise. Change-Id: I5c0c08930bffe42fd69cb4bfcece28944dd88d1f
2020-07-12gdb: remove TYPE_ARRAY_{LOWER,UPPER}_BOUND_VALUESimon Marchi1-2/+2
Remove the macros, use the various equivalent getters instead. gdb/ChangeLog: * gdbtypes.h (TYPE_ARRAY_LOWER_BOUND_VALUE, TYPE_ARRAY_UPPER_BOUND_VALUE): Remove. Update all callers to use the equivalent accessor methods instead. Change-Id: I7f96d988f872170e7a2f58095832710e62b85cfd
2020-07-12gdb: remove TYPE_HIGH_BOUND and TYPE_LOW_BOUNDSimon Marchi1-8/+10
Remove the macros, use the getters of `struct dynamic_prop` instead. gdb/ChangeLog: * gdbtypes.h (TYPE_LOW_BOUND, TYPE_HIGH_BOUND): Remove. Update all callers to use type::range_bounds followed by dynamic_prop::{low,high}. Change-Id: I31beeed65d94d81ac4f999244a8b859e2ee961d1
2020-07-12gdb: remove TYPE_RANGE_DATA macroSimon Marchi1-1/+1
Remove it in favor of using type::bounds directly. gdb/ChangeLog: * gdbtypes.h (TYPE_RANGE_DATA): Remove. Update callers to use the type::bounds method directly. Change-Id: Id4fab22af0a94cbf505f78b01b3ee5b3d682fba2
2020-07-08Use read_memory in ada_exception_message_1Tom Tromey1-1/+6
Testing using the internal AdaCore test suite showed a regression from the target string reading changes. In particular, now ada_exception_message_1 can get the wrong answer in some cases. In particular, when an Ada exception catchpoint is hit, sometimes the exception name will be incorrect. The case I was seeing changed from the correct: Catchpoint 2, CONSTRAINT_ERROR (catch C_E) at [...] to: Catchpoint 2, CONSTRAINT_ERROR (catch C_EE) at [...] I was not able to reproduce this failure with the Fedora gnat. Perhaps it is related to some local change to gnat; I do not know. Meanwhile, because ada_exception_message_1 knows the length of the string to read, we can use read_memory here. This fixes the bug. I've updated the test suite to at least exercise this code path. However, as mentioned above, the new test does not actually provoke the failure. gdb/ChangeLog 2020-07-08 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_exception_message_1): Use read_memory. gdb/testsuite/ChangeLog 2020-07-08 Tom Tromey <tromey@adacore.com> * gdb.ada/catch_ex/foo.adb: Pass string to raise. * gdb.ada/catch_ex.exp: Examine catchpoint text.
2020-06-30Do not define basic_string_view::to_stringTom Tromey1-4/+4
gdb's copy of basic_string_view includes a to_string method. However, according to cppreference, this is not a method on the real std::basic_string_view: https://en.cppreference.com/w/cpp/string/basic_string_view This difference matters because gdb_string_view.h will use the standard implementation when built with a C++17 or later. This caused PR build/26183. This patch fixes the problem by changing the method to be a standalone helper function, and then rewriting the uses. Tested by rebuilding with a version of GCC that defaults to C++17. (Note that the build still is not clean; and also I noticed that the libstdc++ string_view forbids the use of nullptr ... I wonder if gdb violates that.) gdb/ChangeLog 2020-06-30 Tom Tromey <tromey@adacore.com> PR build/26183: * ada-lang.c (ada_lookup_name_info::ada_lookup_name_info): Use gdb::to_string. gdbsupport/ChangeLog 2020-06-30 Tom Tromey <tromey@adacore.com> PR build/26183: * gdb_string_view.h (basic_string_view::to_string): Remove. (gdb::to_string): New function.
2020-06-23gdb: Convert language la_is_string_type_p field to a methodAndrew Burgess1-1/+8
This commit changes the language_data::la_is_string_type_p 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_is_string_type_p initializer. (ada_language::is_string_type_p): New member function. * c-lang.c (c_language_data): Delete la_is_string_type_p initializer. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_is_string_type_p): Delete function, implementation moved to f_language::is_string_type_p. (f_language_data): Delete la_is_string_type_p initializer. (f_language::is_string_type_p): New member function, implementation from f_is_string_type_p. * go-lang.c (go_is_string_type_p): Delete function, implementation moved to go_language::is_string_type_p. (go_language_data): Delete la_is_string_type_p initializer. (go_language::is_string_type_p): New member function, implementation from go_is_string_type_p. * language.c (language_defn::is_string_type_p): Define new member function. (default_is_string_type_p): Make static, add comment copied from header file. (unknown_language_data): Delete la_is_string_type_p initializer. (unknown_language::is_string_type_p): New member function. (auto_language_data): Delete la_is_string_type_p initializer. (auto_language::is_string_type_p): New member function. * language.h (language_data): Delete la_is_string_type_p field. (language_defn::is_string_type_p): Declare new function. (default_is_string_type_p): Delete desclaration, move comment to definition. * m2-lang.c (m2_is_string_type_p): Delete function, implementation moved to m2_language::is_string_type_p. (m2_language_data): Delete la_is_string_type_p initializer. (m2_language::is_string_type_p): New member function, implementation from m2_is_string_type_p. * objc-lang.c (objc_language_data): Delete la_is_string_type_p initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_is_string_type_p): Delete function, implementation moved to pascal_language::is_string_type_p. (pascal_language_data): Delete la_is_string_type_p initializer. (pascal_language::is_string_type_p): New member function, implementation from pascal_is_string_type_p. * rust-lang.c (rust_is_string_type_p): Delete function, implementation moved to rust_language::is_string_type_p. (rust_language_data): Delete la_is_string_type_p initializer. (rust_language::is_string_type_p): New member function, implementation from rust_is_string_type_p. * valprint.c (val_print_scalar_or_string_type_p): Update call to is_string_type_p.
2020-06-23gdb: Convert language la_print_typedef field to a methodAndrew Burgess1-1/+8
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.
2020-06-23gdb: Convert language la_printstr field to a methodAndrew Burgess1-1/+11
This commit changes the language_data::la_printstr 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_printstr initializer. (ada_language::printstr): New member function. * c-lang.c (c_language_data): Delete la_printstr initializer. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_printstr): Rename to f_language::printstr. (f_language_data): Delete la_printstr initializer. (f_language::printstr): New member function, implementation from f_printstr. * go-lang.c (go_language_data): Delete la_printstr initializer. * language.c (language_defn::printstr): Define new member function. (unk_lang_printstr): Delete. (unknown_language_data): Delete la_printstr initializer. (unknown_language::printstr): New member function. (auto_language_data): Delete la_printstr initializer. (auto_language::printstr): New member function. * language.h (language_data): Delete la_printstr field. (language_defn::printstr): Declare new member function. (LA_PRINT_STRING): Update call to printstr. * m2-lang.c (m2_printstr): Rename to m2_language::printstr. (m2_language_data): Delete la_printstr initializer. (m2_language::printstr): New member function, implementation from m2_printstr. * objc-lang.c (objc_language_data): Delete la_printstr initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_printstr): Rename to pascal_language::printstr. (pascal_language_data): Delete la_printstr initializer. (pascal_language::printstr): New member function, implementation from pascal_printstr. * p-lang.h (pascal_printstr): Delete declaration. * rust-lang.c (rust_printstr): Update header comment. (rust_language_data): Delete la_printstr initializer. (rust_language::printstr): New member function.
2020-06-23gdb: Convert language la_printchar field to a methodAndrew Burgess1-1/+8
This commit changes the language_data::la_printchar 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_printchar initializer. (ada_language::printchar): New member function. * c-lang.c (c_language_data): Delete la_printchar initializer. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_printchar): Rename to f_language::printchar. (f_language_data): Delete la_printchar initializer. (f_language::printchar): New member function, implementation from f_printchar. * go-lang.c (go_language_data): Delete la_printchar initializer. * language.c (unk_lang_printchar): Delete. (language_defn::printchar): Define new member function. (unknown_language_data): Delete la_printchar initializer. (unknown_language::printchar): New member function. (auto_language_data): Delete la_printchar initializer. (auto_language::printchar): New member function. * language.h (language_data): Delete la_printchar field. (language_defn::printchar): Declare new member function. (LA_PRINT_CHAR): Update call to printchar. * m2-lang.c (m2_language_data): Delete la_printchar initializer. (m2_language::printchar): New member function. * objc-lang.c (objc_language_data): Delete la_printchar initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Delete la_printchar initializer. (pascal_language::printchar): New member function. * rust-lang.c (rust_printchar): Rename to rust_language::printchar. (rust_language_data): Delete la_printchar initializer. (rust_language::printchar): New member function, implementation from rust_printchar.
2020-06-23gdb: Convert language la_emitchar field to a methodAndrew Burgess1-9/+8
This commit changes the language_data::la_emitchar 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 (emit_char): Renamed to ada_language::emitchar. (ada_language_data): Delete la_emitchar initializer. (ada_language::emitchar): New member function, implementation from emit_char. * c-lang.c (c_language_data): Delete la_emitchar initializer. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_emit_char): Rename to f_language::emitchar. (f_language_data): Delete la_emitchar initializer. (f_language::emitchar): New member function, implementation from f_emit_char. * go-lang.c (go_language_data): Delete la_emitchar initializer. * language.c (unk_lang_emit_char): Delete. (language_defn::emitchar): New member function definition. (unknown_language_data): Delete la_emitchar initializer. (unknown_language::emitchar): New member function. (auto_language_data): Delete la_emitchar initializer. (auto_language::emitchar): New member function. * language.h (language_data): Delete la_emitchar field. (language_defn::emitchar): New member field declaration. (LA_EMIT_CHAR): Update call to emitchar. * m2-lang.c (m2_emit_char): Rename to m2_language::emitchar. (m2_language_data): Delete la_emitchar initializer. (m2_language::emitchar): New member function, implementation from m2_emit_char. * objc-lang.c (objc_language_data): Delete la_emitchar initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_emit_char): Rename to pascal_language::emitchar. (pascal_language_data): Delete la_emitchar initializer. (pascal_language::emitchar): New member function, implementation from pascal_emit_char. * rust-lang.c (rust_emitchar): Rename to rust_language::emitchar. (rust_language_data): Delete la_emitchar initializer. (rust_language::emitchar): New member function, implementation from rust_emitchar.
2020-06-23gdb: Convert language la_post_parser field to a methodAndrew Burgess1-23/+23
This commit changes the language_data::la_post_parser 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 (resolve): Rename to ada_language::post_parser. (ada_language_data): Delete la_post_parser initializer. (ada_language::post_parser): New member function. * c-lang.c (c_language_data): Delete la_post_parser 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. * go-lang.c (go_language_data): Likewise. * language.c (unknown_language_data): Likewise. (auto_language_data): Likewise. * language.h (language_data): Delete la_post_parser field. (language_defn::post_parser): New member function. * m2-lang.c (m2_language_data): Delete la_post_parser initializer. * objc-lang.c (objc_language_data): Likewise. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. * parse.c (parse_exp_in_context): Update call to post_parser. (null_post_parser): Delete definition. * parser-defs.h (null_post_parser): Delete declaration. * rust-lang.c (rust_language_data): Delete la_post_parser initializer.
2020-06-23gdb: Convert language la_parser field to a methodAndrew Burgess1-8/+8
This commit changes the language_data::la_parser 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 (parse): Rename to ada_language::parser. (ada_language_data): Delete la_parser initializer. (ada_language::parser): New member function, implementation from parse. * c-lang.c (c_language_data): Delete la_parser initializer. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. (d_language::parser): New member function. * f-lang.c (f_language_data): Delete la_parser initializer. (f_language::parser): New member function. * go-lang.c (go_language_data): Delete la_parser initializer. (go_language::parser): New member function. * language.c (unk_lang_parser): Delete. (language_defn::parser): Define new member function. (unknown_language_data): Delete la_parser initializer. (unknown_language::parser): New member function. (auto_language_data): Delete la_parser initializer. (auto_language::parser): New member function. * language.h (language_data): Delete la_parser field. (language_defn::parser): Declare new member function. * m2-lang.c (m2_language_data): Delete la_parser initializer. (m2_language::parser): New member function. * objc-lang.c (objc_language_data): Delete la_parser initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. (pascal_language::parser): New member function. * parse.c (parse_exp_in_context): Update call to parser. * rust-lang.c (rust_language_data): Delete la_parser initializer. (rust_language::parser): New member function.
2020-06-17gdb: Convert language la_lookup_symbol_nonlocal field to a methodAndrew Burgess1-41/+41
This commit changes the language_data::la_lookup_symbol_nonlocal 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_lookup_symbol_nonlocal): Rename to ada_language::lookup_symbol_nonlocal. (ada_language_data): Delete la_lookup_symbol_nonlocal initializer. (ada_language::lookup_symbol_nonlocal): New member function, implementation from ada_lookup_symbol_nonlocal. * c-lang.c (c_language_data): Delete la_lookup_symbol_nonlocal initializer. (cplus_language_data): Delete la_lookup_symbol_nonlocal initializer. (cplus_language::lookup_symbol_nonlocal): New member function. (asm_language_data): Delete la_lookup_symbol_nonlocal initializer. (minimal_language_data) Likewise. * cp-namespace.c (cp_lookup_nested_symbol): Update comment. * d-lang.c (d_language_data): Delete la_lookup_symbol_nonlocal initializer. (d_language::lookup_symbol_nonlocal): New member function. * f-lang.c (f_language_data): Delete la_lookup_symbol_nonlocal initializer. (f_language::lookup_symbol_nonlocal): New member function. * go-lang.c (go_language_data): Delete la_lookup_symbol_nonlocal initializer. * language.c (unknown_language_data): Likewise. (auto_language_data): Likewise. * language.h (language_data): Delete la_lookup_symbol_nonlocal field. (language_defn::lookup_symbol_nonlocal): New member function. * m2-lang.c (m2_language_data): Delete la_lookup_symbol_nonlocal 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_lookup_symbol_nonlocal): Rename to rust_language::lookup_symbol_nonlocal. (rust_language_data): Delete la_lookup_symbol_nonlocal initializer. (rust_language::lookup_symbol_nonlocal): New member function, implementation from rust_lookup_symbol_nonlocal. * symtab.c (lookup_symbol_aux): Update call to lookup_symbol_nonlocal. (basic_lookup_symbol_nonlocal): Rename to... (language_defn::lookup_symbol_nonlocal): ...this, and update header comment. Remove language_defn parameter, and replace with uses of `this'. * symtab.h (basic_lookup_symbol_nonlocal): Delete declaration.
2020-06-17gdb: Convert language la_value_print_inner field to a methodAndrew Burgess1-1/+9
This commit changes the language_data::la_value_print_inner 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_value_print_inner initializer. (ada_language::value_print_inner): New member function. * c-lang.c (c_language_data): Delete la_value_print_inner initializer. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. (d_language::value_print_inner): New member function. * f-lang.c (f_language_data): Delete la_value_print_inner initializer. (f_language::value_print_inner): New member function. * f-lang.h (f_value_print_innner): Rename to... (f_value_print_inner): ...this (note spelling of 'inner'). * f-valprint.c (f_value_print_innner): Rename to... (f_value_print_inner): ...this (note spelling of 'inner'). * go-lang.c (go_language_data): Delete la_value_print_inner initializer. (go_language::value_print_inner): New member function. * language.c (language_defn::value_print_inner): Define new member function. (unk_lang_value_print_inner): Delete. (unknown_language_data): Delete la_value_print_inner initializer. (unknown_language::value_print_inner): New member function. (auto_language_data): Delete la_value_print_inner initializer. (auto_language::value_print_inner): New member function. * language.h (language_data): Delete la_value_print_inner field. (language_defn::value_print_inner): Delcare new member function. * m2-lang.c (m2_language_data): Delete la_value_print_inner initializer. (m2_language::value_print_inner): New member function. * objc-lang.c (objc_language_data): Delete la_value_print_inner initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. (pascal_language::value_print_inner): New member function. * rust-lang.c (rust_language_data): Delete la_value_print_inner initializer. (rust_language::value_print_inner): New member function. * valprint.c (do_val_print): Update call to value_print_inner.
2020-06-17gdb: Convert language la_value_print field to a methodAndrew Burgess1-1/+8
This commit changes the language_data::la_value_print 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_value_print initializer. (ada_language::value_print): New member function. * c-lang.c (c_language_data): Delete la_value_print 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. * go-lang.c (go_language_data): Likewise. * language.c (unk_lang_value_print): Delete. (language_defn::value_print): Define new member function. (unknown_language_data): Delete la_value_print initializer. (unknown_language::value_print): New member function. (auto_language_data): Delete la_value_print initializer. (auto_language::value_print): New member function. * language.h (language_data): Delete la_value_print field. (language_defn::value_print): Declare new member function. (LA_VALUE_PRINT): Update call to value_print. * m2-lang.c (m2_language_data): Delete la_value_print initializer. * objc-lang.c (objc_language_data): Likewise. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. (pascal_language::value_print): New member function. * rust-lang.c (rust_language_data): Delete la_value_print initializer.
2020-06-17gdb: Convert language la_watch_location_expression field to a methodAndrew Burgess1-12/+11
This commit changes the language_data::la_watch_location_expression 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_watch_location_expression): Rename to ada_language::watch_location_expression. (ada_language_data): Delete la_watch_location_expression initializer. (ada_language::watch_location_expression): New member function, implementation from ada_watch_location_expression. * breakpoint.c (watch_command_1): Update call to watch_location_expression. * c-lang.c (c_watch_location_expression): Rename to language_defn::watch_location_expression. (c_language_data): Delete la_watch_location_expression initializer. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * c-lang.h (c_watch_location_expression): Delete declaration. * d-lang.c (d_language_data): Delete la_watch_location_expression initializer. * f-lang.c (f_language_data): Likewise. * go-lang.c (go_language_data): Likewise. * language.c (language_defn::watch_location_expression): Member function implementation from c_watch_location_expression. (unknown_language_data): Delete la_watch_location_expression initializer. (auto_language_data): Likewise. * language.h (language_data): Delete la_watch_location_expression field. (language_defn::watch_location_expression): Declare new member function. * m2-lang.c (m2_language_data): Delete la_watch_location_expression 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_watch_location_expression): Rename to rust_language::watch_location_expression. (rust_language_data): Delete la_watch_location_expression initializer. (rust_language::watch_location_expression): New member function, implementation from rust_watch_location_expression.
2020-06-17gdb: Convert language la_collect_symbol_completion_matches field to a methodAndrew Burgess1-129/+126
This commit changes the language_data::la_collect_symbol_completion_matches 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_collect_symbol_completion_matches): Rename to ada_language::collect_symbol_completion_matches. (ada_language_data): Delete la_collect_symbol_completion_matches initializer. (ada_language::collect_symbol_completion_matches): New member function, implementation from ada_collect_symbol_completion_matches. * c-lang.c (c_language_data): Delete la_collect_symbol_completion_matches initializer. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_collect_symbol_completion_matches): Rename to f_language::collect_symbol_completion_matches. (f_language_data): Delete la_collect_symbol_completion_matches initializer. (f_language::collect_symbol_completion_matches) New member function, implementation from f_collect_symbol_completion_matches. * go-lang.c (go_language_data): Delete la_collect_symbol_completion_matches initializer. * language.c (unknown_language_data): Likewise. (auto_language_data): Likewise. * language.h (language_data): Delete la_collect_symbol_completion_matches field. (language_defn::collect_symbol_completion_matches): New member function. * m2-lang.c (m2_language_data): Delete la_collect_symbol_completion_matches 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. * symtab.c (default_collect_symbol_completion_matches): Delete. (collect_symbol_completion_matches): Update call to collect_symbol_completion_matches. (collect_symbol_completion_matches_type): Likewise. * symtab.h (default_collect_symbol_completion_matches): Delete declaration.
2020-06-17gdb: Convert language la_word_break_characters field to a methodAndrew Burgess1-7/+7
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.
2020-06-17gdb: Convert language la_get_symbol_name_matcher field to a methodAndrew Burgess1-2/+10
This commit changes the language_data::la_get_symbol_name_matcher function pointer member variable into a member function of language_defn. There should be no user visible changes after this commit. Before this commit access to the la_get_symbol_name_matcher function pointer was through the get_symbol_name_matcher function, which looked something like this (is pseudo-code): <return-type> get_symbol_name_matcher (language_defn *lang, <other args>) { if (current_language == ada) current_language->la_get_symbol_name_matcher (<other args>); else lang->la_get_symbol_name_matcher (<other args>); } In this commit I moved the get_symbol_name_matcher as a non-virtual function in the language_defn base class, I then add a new virtual method that is only used from within get_symbol_name_matcher, this can then be overridden by specific languages as needed. So we now have: class language_defn { <return-type> get_symbol_name_matcher (<args>) { if (current_language == ada) return current_language->get_symbol_name_matcher_inner (<args>); else return this->get_symbol_name_matcher_inner (<args>); } virtual <return-type> get_symbol_name_matcher_inner (<args>) { .... } } gdb/ChangeLog: * ada-lang.c (ada_get_symbol_name_matcher): Update header comment. (ada_language_data): Delete la_get_symbol_name_matcher initializer. (language_defn::get_symbol_name_matcher_inner): New member function. * c-lang.c (c_language_data): Delete la_get_symbol_name_matcher initializer. (cplus_language_data): Likewise. (cplus_language::get_symbol_name_matcher_inner): New member function. (asm_language_data): Delete la_get_symbol_name_matcher initializer. (minimal_language_data): Likewise. * cp-support.h (cp_get_symbol_name_matcher): Update header comment. * d-lang.c (d_language_data): Delete la_get_symbol_name_matcher initializer. * dictionary.c (iter_match_first_hashed): Update call to get_symbol_name_matcher. (iter_match_next_hashed): Likewise. (iter_match_next_linear): Likewise. * dwarf2/read.c (dw2_expand_symtabs_matching_symbol): Likewise. * f-lang.c (f_language_data): Delete la_get_symbol_name_matcher initializer. (f_language::get_symbol_name_matcher_inner): New member function. * go-lang.c (go_language_data): Delete la_get_symbol_name_matcher initializer. * language.c (default_symbol_name_matcher): Update header comment, make static. (language_defn::get_symbol_name_matcher): New definition. (language_defn::get_symbol_name_matcher_inner): Likewise. (get_symbol_name_matcher): Delete. (unknown_language_data): Delete la_get_symbol_name_matcher initializer. (auto_language_data): Likewise. * language.h (language_data): Delete la_get_symbol_name_matcher field. (language_defn::get_symbol_name_matcher): New member function. (language_defn::get_symbol_name_matcher_inner): Likewise. (default_symbol_name_matcher): Delete declaration. * linespec.c (find_methods): Update call to get_symbol_name_matcher. * m2-lang.c (m2_language_data): Delete la_get_symbol_name_matcher initializer. * minsyms.c (lookup_minimal_symbol): Update call to get_symbol_name_matcher. (iterate_over_minimal_symbols): Likewise. * objc-lang.c (objc_language_data): Delete la_get_symbol_name_matcher initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. * psymtab.c (psymbol_name_matches): Update call to get_symbol_name_matcher. * rust-lang.c (rust_language_data): Delete la_get_symbol_name_matcher initializer. * symtab.c (symbol_matches_search_name): Update call to get_symbol_name_matcher. (compare_symbol_name): Likewise.
2020-06-17gdb: Convert language la_compute_program field to a methodAndrew Burgess1-1/+0
This commit changes the language_data::la_compute_program 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_compute_program initializer. * c-lang.c (c_language_data): Likewise. (c_language::compute_program): New member function. (cplus_language_data): Delete la_compute_program initializer. (cplus_language::compute_program): New member function. (asm_language_data): Delete la_compute_program initializer. (minimal_language_data): Likewise. * c-lang.h (c_compute_program): Update comment. (cplus_compute_program): Likewise. * compile/compile-c-support.c (c_compute_program): Likewise. (cplus_compute_program): Likewise. * compile/compile.c (compile_to_object): Update call to la_compute_program. * d-lang.c (d_language_data): Delete la_compute_program initializer. * f-lang.c (f_language_data): Likewise. * go-lang.c (go_language_data): Likewise. * language.c (unknown_language_data): Likewise. (auto_language_data): Likewise. * language.h (language_data): Delete la_compute_program field. (language_defn::compute_program): New member function. * m2-lang.c (m2_language_data): Delete la_compute_program 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-17gdb: Convert language la_class_name_from_physname field to a methodAndrew Burgess1-2/+0
This commit changes the language_data::la_class_name_from_physname 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_class_name_from_physname initializer. * c-lang.c (c_language_data): Likewise. (cplus_language_data): Likewise. (cplus_language::class_name_from_physname): New member function. (asm_language_data): Delete la_class_name_from_physname initializer. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * dwarf2/read.c (guess_partial_die_structure_name): Update to call method on language_defn class. (guess_full_die_structure_name): Likewise. * f-lang.c (f_language_data): Delete la_class_name_from_physname initializer. * go-lang.c (go_language_data): Likewise. * language.c (language_class_name_from_physname): Delete. (unk_lang_class_name): Delete. (unknown_language_data): Delete la_class_name_from_physname initializer. (auto_language_data): Likewise. * language.h (language_data): Delete la_class_name_from_physname field. (language_defn::class_name_from_physname): New function. (language_class_name_from_physname): Delete declaration. * m2-lang.c (m2_language_data): Delete la_class_name_from_physname 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.