Commit Graph

122 Commits

Author SHA1 Message Date
Andrew Burgess 39e7eccae6 gdb: Convert language la_is_string_type_p field to a method
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-23 13:34:11 +01:00
Andrew Burgess 4ffc13fb0e gdb: Convert language la_print_typedef field to a method
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-23 13:34:11 +01:00
Andrew Burgess d711ee67ac gdb: Convert language la_printstr field to a method
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-23 13:34:11 +01:00
Andrew Burgess 52b50f2c1b gdb: Convert language la_printchar field to a method
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-23 13:34:11 +01:00
Andrew Burgess ec8cec5b96 gdb: Convert language la_emitchar field to a method
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-23 13:34:11 +01:00
Andrew Burgess 1bf9c36374 gdb: Convert language la_post_parser field to a method
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-23 13:34:11 +01:00
Andrew Burgess 87afa6523b gdb: Convert language la_parser field to a method
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-23 13:34:10 +01:00
Andrew Burgess a78a19b152 gdb: Convert language la_lookup_symbol_nonlocal field to a method
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-17 09:25:12 +01:00
Andrew Burgess ebe2334ee6 gdb: Convert language la_value_print_inner field to a method
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-17 09:25:11 +01:00
Andrew Burgess a1d1fa3e41 gdb: Convert language la_value_print field to a method
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-17 09:25:11 +01:00
Andrew Burgess f16a9f57b5 gdb: Convert language la_watch_location_expression field to a method
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-17 09:25:11 +01:00
Andrew Burgess 7e56227dff gdb: Convert language la_collect_symbol_completion_matches field to a method
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-17 09:25:10 +01:00
Andrew Burgess 53fc67f8b2 gdb: Convert language la_word_break_characters field to a method
This commit changes the language_data::la_word_break_characters
function pointer member variable into a member function of
language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_get_gdb_completer_word_break_characters): Delete.
	(ada_language_data): Delete la_word_break_characters initializer.
	(ada_language::word_break_characters): New member function.
	* c-lang.c (c_language_data): Delete la_word_break_characters
	initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* completer.c: Update global comment.
	(advance_to_expression_complete_word_point): Update call to
	word_break_characters.
	(complete_files_symbols): Likewise.
	(complete_line_internal_1): Likewise.
	(default_completer_handle_brkchars): Likewise.
	(skip_quoted_chars): Likewise.
	* d-lang.c (d_language_data): Delete la_word_break_characters
	initializer.
	* f-lang.c (f_word_break_characters): Delete.
	(f_language_data): Delete la_word_break_characters initializer.
	(f_language::word_break_characters): New member function.
	* go-lang.c (go_language_data): Delete la_word_break_characters
	initializer.
	* language.c (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (default_word_break_characters): Move declaration to
	earlier in the file.
	(language_data): Delete la_word_break_characters field.
	(language_defn::word_break_characters): New member function.
	* m2-lang.c (m2_language_data): Delete la_word_break_characters
	initializer.
	* objc-lang.c (objc_language_data): Likewise.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_language_data): Likewise.
2020-06-17 09:25:10 +01:00
Andrew Burgess c9debfb97e gdb: Convert language la_get_symbol_name_matcher field to a method
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-17 09:25:09 +01:00
Andrew Burgess 9a49ad8c52 gdb: Convert language la_compute_program field to a method
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-17 09:25:09 +01:00
Andrew Burgess eff93b4d48 gdb: Convert language la_class_name_from_physname field to a method
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.
2020-06-17 09:25:09 +01:00
Simon Marchi 940da03e32 gdb: remove TYPE_FIELD_TYPE macro
Remove the `TYPE_FIELD_TYPE` macro, changing all the call sites to use
`type::field` and `field::type` directly.

gdb/ChangeLog:

	* gdbtypes.h (TYPE_FIELD_TYPE): Remove.  Change all call sites
	to use type::field and field::type instead.

Change-Id: Ifda6226a25c811cfd334a756a9fbc5c0afdddff3
2020-06-08 15:26:31 -04:00
Simon Marchi 5d14b6e5d6 gdb: add field::type / field::set_type
Add the `type` and `set_type` methods on `struct field`, in order to
remoremove the `FIELD_TYPE` macro.  In this patch, the `FIELD_TYPE`
macro is changed to use `field::type`, so all the call sites that are
useused to set the field's type are changed to use `field::set_type`.
The next patch will remove `FIELD_TYPE` completely.

Note that because of the name clash between the existing field named
`type` and the new method, I renamed the field `m_type`.  It is not
private per-se, because we can't make `struct field` a non-POD yet, but
it should be considered private anyway (not accessed outside `struct
field`).

gdb/ChangeLog:

	* gdbtypes.h (struct field) <type, set_type>: New methods.
	Rename `type` field to...
	<m_type>: ... this.  Change references throughout to use type or
	set_type methods.
	(FIELD_TYPE): Use field::type.  Change call sites that modify
	the field's type to use field::set_type instead.

Change-Id: Ie21f866e3b7f8a51ea49b722d07d272a724459a0
2020-06-08 15:26:04 -04:00
Simon Marchi 3d967001ec gdb: remove TYPE_INDEX_TYPE macro
Remove `TYPE_INDEX_TYPE` macro, changing all the call sites to use
`type::index_type` directly.

gdb/ChangeLog:

	* gdbtypes.h (TYPE_INDEX_TYPE): Remove.  Change all call sites
	to use type::index_type instead.

Change-Id: I56715df0bdec89463cda6bd341dac0e01b2faf84
2020-06-08 15:26:01 -04:00
Andrew Burgess f6eee2d098 gdb: Convert language skip_trampoline field to a method
This commit changes the language_data::skip_trampoline 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 skip_trampoline
	initializer.
	* c-lang.c (c_language_data): Likewise.
	(cplus_language_data): Likewise.
	(cplus_language::skip_trampoline): New member function.
	(asm_language_data): Delete skip_trampoline 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 (unk_lang_trampoline): Delete function.
	(skip_language_trampoline): Update.
	(unknown_language_data): Delete skip_trampoline initializer.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete skip_trampoline field.
	(language_defn::skip_trampoline): New function.
	* m2-lang.c (m2_language_data): Delete skip_trampoline
	initializer.
	* objc-lang.c (objc_skip_trampoline): Delete function, move
	implementation to objc_language::skip_trampoline.
	(objc_language_data): Delete skip_trampoline initializer.
	(objc_language::skip_trampoline): New member function with
	implementation from objc_skip_trampoline.
	* opencl-lang.c (opencl_language_data): Delete skip_trampoline
	initializer.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_language_data): Likewise.
2020-06-02 13:53:11 +01:00
Andrew Burgess 0a50df5dab gdb: Convert language la_demangle field to a method
This commit changes the language_data::la_demangle function pointer
member variable into a member function of language_defn.

The only slightly "weird" change in this commit is in f-lang.c, where
I have given the Fortran language a demangle method that is identical
to the default language_defn::demangle.  The only reason for this is
to give me somewhere to copy the comment that was previously embedded
within the f_language_data structure.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data): Delete la_demangle initializer.
	(ada_language::demangle): New member function.
	* c-lang.c (c_language_data): Delete la_demangle initializer.
	(cplus_language_data): Delete la_demangle initializer.
	(cplus_language::demangle): New member function.
	(asm_language_data): Delete la_demangle initializer.
	(minimal_language_data): Delete la_demangle initializer.
	* d-lang.c (d_language_data): Delete la_demangle initializer.
	(d_language::demangle): New member function.
	* f-lang.c (f_language_data): Delete la_demangle initializer.
	(f_language::demangle): New member function.
	* go-lang.c (go_language_data): Delete la_demangle initializer.
	(go_language::demangle): New member function.
	* language.c (language_demangle): Update.
	(unk_lang_demangle): Delete.
	(unknown_language_data): Delete la_demangle initializer.
	(unknown_language::demangle): New member function.
	(auto_language_data): Delete la_demangle initializer.
	(auto_language::demangle): New member function.
	* language.h (language_data): Delete la_demangle field.
	(language_defn::demangle): New function.
	* m2-lang.c (m2_language_data): Delete la_demangle initializer.
	* objc-lang.c (objc_language_data): Delete la_demangle
	initializer.
	(objc_language::demangle): New member function.
	* opencl-lang.c (opencl_language_data): Delete la_demangle
	initializer.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_language_data): Likewise.
	(rust_language::demangle): New member functi
2020-06-02 13:53:11 +01:00
Andrew Burgess fbfb0a463f gdb: Convert language la_print_type field to a method
This commit changes the language_data::la_print_type 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_type
	initializer.
	(ada_language::print_type): New member function.
	* c-lang.c (c_language_data): Delete la_print_type initializer.
	(c_language::print_type): New member function.
	(cplus_language_data): Delete la_print_type initializer.
	(cplus_language::print_type): New member function.
	(asm_language_data): Delete la_print_type initializer.
	(asm_language::print_type): New member function.
	(minimal_language_data): Delete la_print_type initializer.
	(minimal_language::print_type): New member function.
	* d-lang.c (d_language_data): Delete la_print_type initializer.
	(d_language::print_type): New member function.
	* f-lang.c (f_language_data): Delete la_print_type initializer.
	(f_language::print_type): New member function.
	* go-lang.c (go_language_data): Delete la_print_type initializer.
	(go_language::print_type): New member function.
	* language.c (unk_lang_print_type): Delete.
	(unknown_language_data): Delete la_print_type initializer.
	(unknown_language::print_type): New member function.
	(auto_language_data): Delete la_print_type initializer.
	(auto_language::print_type): New member function.
	* language.h (language_data): Delete la_print_type field.
	(language_defn::print_type): New function.
	(LA_PRINT_TYPE): Update.
	* m2-lang.c (m2_language_data): Delete la_print_type initializer.
	(m2_language::print_type): New member function.
	* objc-lang.c (objc_language_data): Delete la_print_type
	initializer.
	(objc_language::print_type): New member function.
	* opencl-lang.c (opencl_print_type): Delete, implementation moved
	to opencl_language::print_type.
	(opencl_language_data): Delete la_print_type initializer.
	(opencl_language::print_type): New member function, implementation
	from opencl_print_type.
	* p-lang.c (pascal_language_data): Delete la_print_type
	initializer.
	(pascal_language::print_type): New member function.
	* rust-lang.c (rust_print_type): Delete, implementation moved to
	rust_language::print_type.
	(rust_language_data): Delete la_print_type initializer.
	(rust_language::print_type): New member function, implementation
	from rust_print_type.
2020-06-02 13:53:11 +01:00
Andrew Burgess 6f8270197a gdb: Convert language la_sniff_from_mangled_name field to a method
This commit changes the language_data::la_sniff_from_mangled_name
function pointer member variable into a member function of
language_defn.

Previously the la_sniff_from_mangled_name pointer was NULL for some
languages, however, all uses of this function pointer were through the
function language_sniff_from_mangled_name which provided a default
implementation.

This default implementation now becomes the implementation in the base
class language_defn, which is then overridden as required in various
language sub-classes.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_sniff_from_mangled_name): Delete function,
	implementation moves to...
	(ada_language::sniff_from_mangled_name): ...here.  Update return
	type.
	(ada_language_data): Delete la_sniff_from_mangled_name
	initializer.
	* c-lang.c (c_language_data): Likewise.
	(cplus_language_data): Likewise.
	(cplus_language::sniff_from_mangled_name): New member function,
	implementation taken from gdb_sniff_from_mangled_name.
	(asm_language_data): Delete la_sniff_from_mangled_name
	initializer.
	(minimal_language_data): Likewise.
	* cp-support.c (gdb_sniff_from_mangled_name): Delete,
	implementation moves to cplus_language::sniff_from_mangled_name.
	* cp-support.h (gdb_sniff_from_mangled_name): Delete declaration.
	* d-lang.c (d_sniff_from_mangled_name): Delete, implementation
	moves to...
	(d_language::sniff_from_mangled_name): ...here.
	(d_language_data): Delete la_sniff_from_mangled_name initializer.
	* f-lang.c (f_language_data): Likewise.
	* go-lang.c (go_sniff_from_mangled_name): Delete, implementation
	moves to...
	(go_language::sniff_from_mangled_name): ...here.
	(go_language_data): Delete la_sniff_from_mangled_name initializer.
	* language.c (language_sniff_from_mangled_name): Delete.
	(unknown_language_data): Delete la_sniff_from_mangled_name
	initializer.
	(auto_language_data): Likewise.
	* language.h (language_data): Delete la_sniff_from_mangled_name
	field.
	(language_defn::sniff_from_mangled_name): New function.
	(language_sniff_from_mangled_name): Delete declaration.
	* m2-lang.c (m2_language_data): Delete la_sniff_from_mangled_name
	field.
	* objc-lang.c (objc_sniff_from_mangled_name): Delete,
	implementation moves to...
	(objc_language::sniff_from_mangled_name): ...here.
	(objc_language_data): Delete la_sniff_from_mangled_name initializer.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_sniff_from_mangled_name): Delete,
	implementation moves to...
	(rust_language::sniff_from_mangled_name): ...here.
	(rust_language_data): Delete la_sniff_from_mangled_name
	initializer.
	* symtab.c (symbol_find_demangled_name): Call
	sniff_from_mangled_name member function.
2020-06-02 13:53:11 +01:00
Andrew Burgess fb8006fd35 gdb: Convert language la_search_name_hash field to a method
This commit changes the language_data::la_search_name_hash
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_search_name_hash
	initializer.
	* c-lang.c (c_language_data): Likewise.
	(cplus_language_data): Likewise.
	(cplus_language::search_name_hash): New member function.
	(asm_language_data): Delete la_search_name_hash initializer.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* dictionary.c (default_search_name_hash): Rename to...
	(language_defn::search_name_hash): ...this.
	* f-lang.c (f_language_data): Likewise.
	(f_language::search_name_hash): New member function.
	* go-lang.c (go_language_data): Delete la_search_name_hash
	initializer.
	* language.c (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (struct language_data): Delete la_search_name_hash
	field.
	(language_defn::search_name_hash): Declare new member function.
	(default_search_name_hash): Delete declaration.
	* m2-lang.c (m2_language_data): Delete la_search_name_hash
	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 (search_name_hash): Update call.
2020-06-02 13:53:10 +01:00
Andrew Burgess 8e25bafe93 gdb: Convert language la_get_compile_instance field to a method
This commit changes the language_data::la_get_compile_instance
function pointer member variable into a member function of
language_defn.  Unlike previous commits converting fields of
language_data to member function in language_defn, this field is NULL
for some languages.  As a result I had to change the API slightly so
that the base language_defn class provides an implementation.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data): Delete la_get_compile_instance
	initializer.
	* c-lang.c (class compile_instance): Declare.
	(c_language_data): Delete la_get_compile_instance initializer.
	(c_language::get_compile_instance): New member function.
	(cplus_language_data): Delete la_get_compile_instance initializer.
	(cplus_language::get_compile_instance): New member function.
	(asm_language_data): Delete la_get_compile_instance initializer.
	(minimal_language_data): Likewise.
	* c-lang.h (c_get_compile_context): Update comment.
	(cplus_get_compile_context): Update comment.
	* compile/compile.c (compile_to_object): Update calls, don't rely
	on function pointer being NULL.
	* d-lang.c (d_language_data): Delete la_get_compile_instance
	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_get_compile_instance field.
	(language_defn::get_compile_instance): New member function.
	* m2-lang.c (m2_language_data): Delete la_get_compile_instance
	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-02 13:53:10 +01:00
Andrew Burgess 4009ee92c4 gdb: Convert language la_iterate_over_symbols field to a method
This commit changes the language_data::la_iterate_over_symbols
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_add_all_symbols): Update comment.
	(ada_iterate_over_symbols): Delete, move implementation to...
	(ada_language::iterate_over_symbols): ...here, a new member
	function, rewrite to use range based for loop.
	(ada_language_data): Delete la_iterate_over_symbols 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): Delete la_iterate_over_symbols field.
	(language_defn::iterate_over_symbols): New member function.
	(LA_ITERATE_OVER_SYMBOLS): Update.
	* linespec.c (iterate_over_all_matching_symtabs): Update.
	* m2-lang.c (m2_language_data): Delete la_iterate_over_symbols
	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-02 13:53:10 +01:00
Andrew Burgess 54f4ca4610 gdb: Convert language la_lookup_transparent_type field to a method
This commit changes the language_data::la_lookup_transparent_type
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_lookup_transparent_type initializer.
	* c-lang.c (c_language_data): Likewise.
	(cplus_language_data): Likewise.
	(cplus_language::lookup_transparent_type): New member function.
	(asm_language_data): Delete la_lookup_transparent_type
	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 (unknown_language_data): Likewise.
	(auto_language_data): Likewise.
	* language.h (struct language_data): Delete
	la_lookup_transparent_type field.
	(language_defn::lookup_transparent_type): New member function.
	* m2-lang.c (m2_language_data): Delete la_lookup_transparent_type
	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 (symbol_matches_domain): Update call.
2020-06-02 13:53:10 +01:00
Andrew Burgess 1fb314aaa3 gdb: Convert language la_language_arch_info field to a method
This commit changes the language_data::la_language_arch_info 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_arch_info): Delete function, move
	implementation to...
	(ada_language::language_arch_info): ...here, a new member
	function.
	(ada_language_data): Delete la_language_arch_info.
	* c-lang.c (c_language_data): Likewise.
	(c_language::language_arch_info): New member function.
	(cplus_language_arch_info): Delete function, move
	implementation to...
	(cplus_language::language_arch_info): ...here, a new member
	function.
	(cplus_language_data): Delete la_language_arch_info.
	(asm_language_data): Likewise.
	(asm_language::language_arch_info): New member function.
	(minimal_language_data): Delete la_language_arch_info.
	(minimal_language::language_arch_info): New member function.
	* d-lang.c (d_language_arch_info): Delete function, move
	implementation to...
	(d_language::language_arch_info): ...here, a new member
	function.
	(d_language_data): Delete la_language_arch_info.
	* f-lang.c (f_language_arch_info): Delete function, move
	implementation to...
	(f_language::language_arch_info): ...here, a new member
	function.
	(f_language_data): Delete la_language_arch_info.
	* go-lang.c (go_language_arch_info): Delete function, move
	implementation to...
	(go_language::language_arch_info): ...here, a new member
	function.
	(go_language_data): Delete la_language_arch_info.
	* language.c (unknown_language_data): Likewise.
	(unknown_language::language_arch_info): New member function.
	(auto_language_data): Delete la_language_arch_info.
	(auto_language::language_arch_info): New member function.
	(language_gdbarch_post_init): Update call to
	la_language_arch_info.
	* language.h (language_data): Delete la_language_arch_info
	function pointer.
	(language_defn::language_arch_info): New function.
	* m2-lang.c (m2_language_arch_info): Delete function, move
	implementation to...
	(m2_language::language_arch_info): ...here, a new member
	function.
	(m2_language_data): Delete la_language_arch_info.
	* objc-lang.c (objc_language_arch_info): Delete function, move
	implementation to...
	(objc_language::language_arch_info): ...here, a new member
	function.
	(objc_language_data): Delete la_language_arch_info.
	* opencl-lang.c (opencl_language_arch_info): Delete function, move
	implementation to...
	(opencl_language::language_arch_info): ...here, a new member
	function.
	(opencl_language_data): Delete la_language_arch_info.
	* p-lang.c (pascal_language_arch_info): Delete function, move
	implementation to...
	(pascal_language::language_arch_info): ...here, a new member
	function.
	(pascal_language_data): Delete la_language_arch_info.
	* rust-lang.c (rust_language_arch_info): Delete function, move
	implementation to...
	(rust_language::language_arch_info): ...here, a new member
	function.
	(rust_language_data): Delete la_language_arch_info.
2020-06-02 13:53:10 +01:00
Andrew Burgess 48448202d7 gdb: Convert language la_pass_by_reference field to a method
This commit changes the language_data::la_pass_by_reference function
pointer member variable into a member function of language_defn.

The interesting thing in this commit is that I have removed the
default_pass_by_reference function entirely.  This function only ever
returned a language_pass_by_ref_info struct in its default state, so
all uses of this function can be replaced by just default
initialisation of a language_pass_by_ref_info variable.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_data): Delete la_pass_by_reference
	initializer.
	* c-lang.c (c_language_data): Likewise.
	(cplus_language_data): Likewise.
	(cplus_language::pass_by_reference_info): New method.
	(asm_language_data): Delete la_pass_by_reference initializer.
	(minimal_language_data): Likewise.
	* cp-abi.c (cp_pass_by_reference): Remove use of
	default_pass_by_reference.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_language_data): Likewise.
	* gnu-v3-abi.c (gnuv3_pass_by_reference): Remove use of
	default_pass_by_reference.
	* go-lang.c (go_language_data): Likewise.
	* language.c (language_pass_by_reference): Update.
	(default_pass_by_reference): Delete.
	(unknown_language_data): Delete la_pass_by_reference
	initializer.
	(auto_language_data): Likewise.
	* language.h (struct language_data): Delete la_pass_by_reference
	field.
	(language_defn::pass_by_reference_info): New member function.
	(default_pass_by_reference): Delete declaration.
	* m2-lang.c (m2_language_data): Delete la_pass_by_reference
	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-02 13:53:10 +01:00
Andrew Burgess 15e5fd3556 gdb: Convert language la_read_var_value field to a method
This commit changes the language_data::la_read_var_value function
pointer member variable into a member function of language_defn.

An interesting aspect of this change is that the implementation of
language_defn::read_var_value is actually in findvar.c.  This is
partly historical, the new language_defn::read_var_value is a rename
of default_read_var_value, which was already in that file, but also,
that is the file that contains the helper functions needed by the
read_var_value method, so it makes sens that the method implementation
should continue to live there (I think).

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_read_var_value): Delete function, move
	implementation to...
	(ada_language::read_var_value): ...here.
	(ada_language_data): Delete la_read_var_value initializer.
	* c-lang.c (c_language_data): Likewise.
	(cplus_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_language_data): Likewise.
	* findvar.c (default_read_var_value): Rename to...
	(language_defn::read_var_value): ...this.
	* findvar.c (read_var_value): Update header comment, and change to
	call member function instead of function pointer.
	* go-lang.c (go_language_data): Likewise.
	* language.c (unknown_language_data): Delete la_read_var_value
	initializer.
	(auto_language_data): Likewise.
	* language.h (struct language_data): Delete la_read_var_value
	field.
	(language_defn::read_var_value): New member function.
	(default_read_var_value): Delete declaration.
	* m2-lang.c (m2_language_data): Delete la_read_var_value
	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.
	* value.h (default_read_var_value): Delete declaration.
2020-06-02 13:53:10 +01:00
Andrew Burgess 5bd40f2a3f gdb: Convert language la_print_array_index field to a method
This commit changes the language_data::la_print_array_index function
pointer member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_print_array_index): Delete function, move
	implementation to...
	(ada_language::print_array_index): ...here.
	(ada_language_data): Delete la_print_array_index initializer.
	* c-lang.c (c_language_data): Likewise.
	(cplus_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_language_data): Likewise.
	* go-lang.c (go_language_data): Likewise.
	* language.c (default_print_array_index): Delete function, move
	implementation to...
	(language_defn::print_array_index): ...here.
	(unknown_language_data): Delete la_print_array_index initializer.
	(auto_language_data): Likewise.
	* language.h (struct language_data): Delete la_print_array_index
	field.
	(language_defn::print_array_index): New member function.
	(LA_PRINT_ARRAY_INDEX): Update.
	(default_print_array_index): Delete declaration.
	* m2-lang.c (m2_language_data): Delete la_print_array_index
	initializer.
	* objc-lang.c (objc_language_data): Likewise.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Likewise.
	* rust-lang.c (rust_language_data): Likewise.
2020-06-02 13:53:10 +01:00
Andrew Burgess 0874fd075b gdb: Represent all languages as sub-classes of language_defn
This commit converts all languages to sub-classes of a language_defn
base class.

The motivation for this change is to make it easier to add new methods
onto languages without having to update all of the individual language
structures.  In the future it might be possible to move more things,
like expression parsing, into the language class(es) for better
encapsulation, however I have no plans to tackle this in the short
term.

This commit sets up a strategy for transitioning from the current
language system, where each language is an instance of the
language_defn structure, to the class hierarchy system.

The plan is to rename the existing language_defn into language_data,
and make this a base class for the new language_defn class, something
like this:

  struct language_data
  {
    ... old language_defn fields here ...
  };

  struct language_defn : public language_data
  {
    language_defn (const language_data d)
      : language_data (d)
    { .... }
  };

Then each existing language, for example ada_language_defn can be
converted into an instance of language_data, and passed into the
constructor of a new language class, something like this:

  language_data ada_language_data =
  {
    ... old ada_language_defn values here ...
  };

  struct ada_language : public language_defn
  {
    ada_language (ada_language_data)
    { .... }
  };

What this means is that immediately after the conversion nothing much
changes.  Every language is now its own class, but all the old
language fields still exist and can be accessed in the same way.

In later commits I will convert function pointers from the old
language_defn structure into real class methods on language_defn, with
overrides on sub-classes where needed.

At this point I imagine that those fields of the old language_defn
structure that contained only data will probably remain as data fields
within the new language_data base structure, it is only the methods
that I plan to change initially.

I tweaked how we manage the list of languages a bit, each language is
now registered as it is created, and this resulted in a small number
of changes in language.c.

Most of the changes in the *-lang.c files are identical.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* gdb/ada-lang.c (ada_language_defn): Convert to...
	(ada_language_data): ...this.
	(class ada_language): New class.
	(ada_language_defn): New static global.
	* gdb/c-lang.c (c_language_defn): Convert to...
	(c_language_data): ...this.
	(class c_language): New class.
	(c_language_defn): New static global.
	(cplus_language_defn): Convert to...
	(cplus_language_data): ...this.
	(class cplus_language): New class.
	(cplus_language_defn): New static global.
	(asm_language_defn): Convert to...
	(asm_language_data): ...this.
	(class asm_language): New class.
	(asm_language_defn): New static global.
	(minimal_language_defn): Convert to...
	(minimal_language_data): ...this.
	(class minimal_language): New class.
	(minimal_language_defn): New static global.
	* gdb/d-lang.c (d_language_defn): Convert to...
	(d_language_data): ...this.
	(class d_language): New class.
	(d_language_defn): New static global.
	* gdb/f-lang.c (f_language_defn): Convert to...
	(f_language_data): ...this.
	(class f_language): New class.
	(f_language_defn): New static global.
	* gdb/go-lang.c (go_language_defn): Convert to...
	(go_language_data): ...this.
	(class go_language): New class.
	(go_language_defn): New static global.
	* gdb/language.c (unknown_language_defn): Remove declaration.
	(current_language): Initialize to nullptr, real initialization is
	moved to _initialize_language.
	(languages): Delete global.
	(language_defn::languages): Define.
	(set_language_command): Use language_defn::languages.
	(set_language): Likewise.
	(range_error): Likewise.
	(language_enum): Likewise.
	(language_def): Likewise.
	(add_set_language_command): Use language_def::languages for the
	language list, and language_def to lookup language pointers.
	(skip_language_trampoline): Use language_defn::languages.
	(unknown_language_defn): Convert to...
	(unknown_language_data): ...this.
	(class unknown_language): New class.
	(unknown_language_defn): New static global.
	(auto_language_defn): Convert to...
	(auto_language_data): ...this.
	(class auto_language): New class.
	(auto_language_defn): New static global.
	(language_gdbarch_post_init): Use language_defn::languages.
	(_initialize_language): Initialize current_language.
	* gdb/language.h (struct language_defn): Rename to...
	(struct language_data): ...this.
	(struct language_defn): New.
	(auto_language_defn): Delete.
	(unknown_language_defn): Delete.
	(minimal_language_defn): Delete.
	(ada_language_defn): Delete.
	(asm_language_defn): Delete.
	(c_language_defn): Delete.
	(cplus_language_defn): Delete.
	(d_language_defn): Delete.
	(f_language_defn): Delete.
	(go_language_defn): Delete.
	(m2_language_defn): Delete.
	(objc_language_defn): Delete.
	(opencl_language_defn): Delete.
	(pascal_language_defn): Delete.
	(rust_language_defn): Delete.
	* gdb/m2-lang.c (m2_language_defn): Convert to...
	(m2_language_data): ...this.
	(class m2_language): New class.
	(m2_language_defn): New static global.
	* gdb/objc-lang.c (objc_language_defn): Convert to...
	(objc_language_data): ...this.
	(class objc_language): New class.
	(objc_language_defn): New static global.
	* gdb/opencl-lang.c (opencl_language_defn): Convert to...
	(opencl_language_data): ...this.
	(class opencl_language): New class.
	(opencl_language_defn): New static global.
	* gdb/p-lang.c (pascal_language_defn): Convert to...
	(pascal_language_data): ...this.
	(class pascal_language): New class.
	(pascal_language_defn): New static global.
	* gdb/rust-exp.y (rust_lex_tests): Use language_def to find
	language pointer, update comment format.
	* gdb/rust-lang.c (rust_language_defn): Convert to...
	(rust_language_data): ...this.
	(class rust_language): New class.
	(rust_language_defn): New static global.
2020-06-02 13:53:10 +01:00
Simon Marchi ceacbf6edf gdb: remove TYPE_FIELD macro
Replace all uses of it by type::field.

Note that since type::field returns a reference to the field, some spots
are used to assign the whole field structure.  See ctfread.c, function
attach_fields_to_type, for example.  This is the same as was happening
with the macro, so I don't think it's a problem, but if anybody sees a
really nicer way to do this, now could be a good time to implement it.

gdb/ChangeLog:

	* gdbtypes.h (TYPE_FIELD): Remove.  Replace all uses with
	type::field.
2020-05-23 17:39:54 -04:00
Simon Marchi 3cabb6b069 gdb: add type::fields / type::set_fields
Add the `fields` and `set_fields` methods on `struct type`, in order to
remove the `TYPE_FIELDS` macro.  In this patch, the `TYPE_FIELDS` macro
is changed to the `type::fields`, so all the call sites that use it to
set the fields array are changed to use `type::set_fields`.  The next
patch will remove `TYPE_FIELDS` entirely.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <fields, set_fields>: New methods.
	(TYPE_FIELDS): Use type::fields.  Change all call sites that
	modify the propery to use type::set_fields instead.

Change-Id: I05174ce68f2ce3fccdf5d8b469ff141f14886b33
2020-05-22 16:55:16 -04:00
Simon Marchi 1f704f761b gdb: remove TYPE_NFIELDS macro
Remove `TYPE_NFIELDS`, changing all the call sites to use
`type::num_fields` directly.  This is quite a big diff, but this was
mostly done using sed and coccinelle.  A few call sites were done by
hand.

gdb/ChangeLog:

	* gdbtypes.h (TYPE_NFIELDS): Remove.  Change all cal sites to use
	type::num_fields instead.

Change-Id: Ib73be4c36f9e770e0f729bac3b5257d7cb2f9591
2020-05-22 16:55:15 -04:00
Simon Marchi 5e33d5f4e1 gdb: add type::num_fields / type::set_num_fields
Add the `num_fields` and `set_num_fields` methods on `struct type`, in
order to remove the `TYPE_NFIELDS` macro.  In this patch, the
`TYPE_NFIELDS` macro is changed to use `type::num_fields`, so all the
call sites that are used to set the number of fields are changed to use
`type::set_num_fields`.  The next patch will remove `TYPE_NFIELDS`
completely.

I think that in the future, we should consider making the interface of
`struct type` better.  For example, right now it's possible for the
number of fields property and the actual number of fields set to be out
of sync.  However, I want to keep the existing behavior in this patch,
just translate from macros to methods.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <num_fields, set_num_fields>: New
	methods.
	(TYPE_NFIELDS): Use type::num_fields.  Change all call sites
	that modify the number of fields to use type::set_num_fields
	instead.

Change-Id: I5ad9de5be4097feaf942d111077434bf91d13dc5
2020-05-22 16:55:14 -04:00
Simon Marchi 7d93a1e0b6 gdb: remove TYPE_NAME macro
Remove `TYPE_NAME`, changing all the call sites to use `type::name`
directly.  This is quite a big diff, but this was mostly done using sed
and coccinelle.  A few call sites were done by hand.

gdb/ChangeLog:

	* gdbtypes.h (TYPE_NAME): Remove.  Change all cal sites to use
	type::name instead.
2020-05-16 12:36:05 -04:00
Simon Marchi d0e39ea27c gdb: add type::name / type::set_name
Add the `name` and `set_name` methods on `struct type`, in order to
remove the `TYPE_NAME` macro.  In this patch, the `TYPE_NAME` macro is
changed to use `type::name`, so all the call sites that are used to set
the type name are changed to use `type::set_name`.  The next patch will
remove `TYPE_NAME` completely.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <name, set_name>: New methods.
	(TYPE_CODE): Use type::name.  Change all call sites used to set
	the name to use type::set_name instead.
2020-05-16 12:36:05 -04:00
Simon Marchi 7813437494 gdb: remove TYPE_CODE macro
Remove TYPE_CODE, changing all the call sites to use type::code
directly.  This is quite a big diff, but this was mostly done using sed
and coccinelle.  A few call sites were done by hand.

gdb/ChangeLog:

	* gdbtypes.h (TYPE_CODE): Remove.  Change all call sites to use
	type::code instead.
2020-05-14 13:46:38 -04:00
Simon Marchi 67607e24d0 gdb: add type::code / type::set_code
Add the code and set_code methods on code, in order to remove the
TYPE_CODE macro.  In this patch, the TYPE_CODE macro is changed to use
type::code, so all the call sites that are used to set the type code are
changed to use type::set_code.  The next patch will remove TYPE_CODE
completely.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <code, set_code>: New methods.
	(TYPE_CODE): Use type::code.  Change all call sites used to set
	the code to use type::set_code instead.
2020-05-14 13:45:40 -04:00
Simon Marchi 24e99c6c3c gdb: make get_dyn_prop a method of struct type
Move get_dyn_prop, currently a free function, to be a method on struct
type.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <get_dyn_prop>: New method.
	(get_dyn_prop): Remove.  Update all users to use
	type::dyn_prop.
	* gdbtypes.c (get_dyn_prop): Rename to...
	(type::dyn_prop): ... this.
2020-05-07 11:32:25 -04:00
Tom Tromey 9c6a1327ad Rewrite the existing variant part code
This rewrites the existing variant part code to follow the new model
implemented in the previous patch.  The old variant part code is
removed.

This only affects Rust for the moment.  I tested this using various
version of the Rust compiler, including one that emits old-style enum
debuginfo, exercising the quirks code.

gdb/ChangeLog
2020-04-24  Tom Tromey  <tromey@adacore.com>

	* dwarf2/read.c (struct variant_field): Rewrite.
	(struct variant_part_builder): New.
	(struct nextfield): Remove "variant" field.  Add "offset".
	(struct field_info): Add "current_variant_part" and
	"variant_parts".
	(alloc_discriminant_info): Remove.
	(alloc_rust_variant): New function.
	(quirk_rust_enum): Update.
	(dwarf2_add_field): Set "offset" member.  Don't handle
	DW_TAG_variant_part.
	(offset_map_type): New typedef.
	(convert_variant_range, create_one_variant)
	(create_one_variant_part, create_variant_parts)
	(add_variant_property): New functions.
	(dwarf2_attach_fields_to_type): Call add_variant_property.
	(read_structure_type): Don't handle DW_TAG_variant_part.
	(handle_variant_part, handle_variant): New functions.
	(handle_struct_member_die): Use them.
	(process_structure_scope): Don't handle variant parts.
	* gdbtypes.h (TYPE_FLAG_DISCRIMINATED_UNION): Remove.
	(struct discriminant_info): Remove.
	(enum dynamic_prop_node_kind) <DYN_PROP_DISCRIMINATED>: Remove.
	(struct main_type) <flag_discriminated_union>: Remove.
	* rust-lang.c (rust_enum_p, rust_empty_enum_p): Rewrite.
	(rust_enum_variant): Return int.  Remove "contents".  Rewrite.
	(rust_print_enum, rust_print_struct_def, rust_evaluate_subexp):
	Update.
	* valops.c (value_union_variant): Remove.
	* value.h (value_union_variant): Don't declare.
2020-04-24 13:40:32 -06:00
Tom Tromey 426a9c18dd Remove val_print
We can finally remove val_print and various helper functions that are
no longer needed.

gdb/ChangeLog
2020-03-13  Tom Tromey  <tom@tromey.com>

	* value.h (val_print): Don't declare.
	* valprint.h (val_print_array_elements)
	(val_print_scalar_formatted, generic_val_print): Don't declare.
	* valprint.c (generic_val_print_array): Take a struct value.
	(generic_val_print_ptr, generic_val_print_memberptr)
	(generic_val_print_bool, generic_val_print_int)
	(generic_val_print_char, generic_val_print_complex)
	(generic_val_print): Remove.
	(generic_value_print): Update.
	(do_val_print): Remove unused parameters.  Don't call
	la_val_print.
	(val_print): Remove.
	(common_val_print): Update.  Don't call value_check_printable.
	(val_print_scalar_formatted, val_print_array_elements): Remove.
	* rust-lang.c (rust_val_print): Remove.
	(rust_language_defn): Update.
	* p-valprint.c (pascal_val_print): Remove.
	(pascal_value_print_inner): Update.
	(pascal_object_print_val_fields, pascal_object_print_val):
	Remove.
	(pascal_object_print_static_field): Update.
	* p-lang.h (pascal_val_print): Don't declare.
	* p-lang.c (pascal_language_defn): Update.
	* opencl-lang.c (opencl_language_defn): Update.
	* objc-lang.c (objc_language_defn): Update.
	* m2-valprint.c (m2_print_unbounded_array, m2_val_print): Remove.
	* m2-lang.h (m2_val_print): Don't declare.
	* m2-lang.c (m2_language_defn): Update.
	* language.h (struct language_defn) <la_val_print>: Remove.
	* language.c (unk_lang_value_print_inner): Rename.  Change
	argument types.
	(unknown_language_defn, auto_language_defn): Update.
	* go-valprint.c (go_val_print): Remove.
	* go-lang.h (go_val_print): Don't declare.
	* go-lang.c (go_language_defn): Update.
	* f-valprint.c (f_val_print): Remove.
	* f-lang.h (f_value_print): Don't declare.
	* f-lang.c (f_language_defn): Update.
	* d-valprint.c (d_val_print): Remove.
	* d-lang.h (d_value_print): Don't declare.
	* d-lang.c (d_language_defn): Update.
	* cp-valprint.c (cp_print_value_fields)
	(cp_print_value_fields_rtti, cp_print_value): Remove.
	(cp_print_static_field): Update.
	* c-valprint.c (c_val_print_array, c_val_print_ptr)
	(c_val_print_struct, c_val_print_union, c_val_print_int)
	(c_val_print_memberptr, c_val_print): Remove.
	* c-lang.h (c_val_print_array, cp_print_value_fields)
	(cp_print_value_fields_rtti): Don't declare.
	* c-lang.c (c_language_defn, cplus_language_defn)
	(asm_language_defn, minimal_language_defn): Update.
	* ada-valprint.c (ada_val_print_ptr, ada_val_print_num): Remove.
	(ada_val_print_enum): Take a struct value.
	(ada_val_print_flt, ada_val_print_array, ada_val_print_1)
	(ada_val_print): Remove.
	(ada_value_print_1): Update.
	(printable_val_type): Remove.
	* ada-lang.h (ada_val_print): Don't declare.
	* ada-lang.c (ada_language_defn): Update.
2020-03-13 18:03:42 -06:00
Tom Tromey 5f56f7cbd2 Convert Rust printing to value-based API
For Rust, it was simple to convert the printing code to the
value-based API all at once.

gdb/ChangeLog
2020-03-13  Tom Tromey  <tom@tromey.com>

	* rust-lang.c (val_print_struct, rust_print_enum): Use the value
	API.
	(rust_val_print): Rewrite.
	(rust_value_print_inner): New function, from rust_val_print.
	(rust_language_defn): Use rust_value_print_inner.
2020-03-13 18:03:40 -06:00
Tom Tromey 2b4e573d62 Introduce la_value_print_inner
The plan for removing val_print is, essentially, to first duplicate
printing code as needed to use the value API; and then remove the
val_print code.  This makes it possible to do the changes
incrementally while keeping everything working.

This adds a new la_value_print_inner function pointer to struct
language_defn.  Eventually this will replace la_val_print.  This patch
also changes printing to prefer this API, when available -- but no
language defines it yet.

gdb/ChangeLog
2020-03-13  Tom Tromey  <tom@tromey.com>

	* valprint.c (do_val_print): Call la_value_print_inner, if
	available.
	* rust-lang.c (rust_language_defn): Update.
	* p-lang.c (pascal_language_defn): Update.
	* opencl-lang.c (opencl_language_defn): Update.
	* objc-lang.c (objc_language_defn): Update.
	* m2-lang.c (m2_language_defn): Update.
	* language.h (struct language_defn) <la_value_print_inner>: New
	member.
	* language.c (unknown_language_defn, auto_language_defn): Update.
	* go-lang.c (go_language_defn): Update.
	* f-lang.c (f_language_defn): Update.
	* d-lang.c (d_language_defn): Update.
	* c-lang.c (c_language_defn, cplus_language_defn)
	(asm_language_defn, minimal_language_defn): Update.
	* ada-lang.c (ada_language_defn): Update.
2020-03-13 18:03:39 -06:00
Tom Tromey 3f0cbb04d0 Style field names in "print"
This changes gdb to use the "variable" style when printing field
names.  I've added new tests for C and Rust, but not other languages.

I chose "variable" because that seemed most straightforward.  However,
another option would be to introduce a new "field" style.  Similarly,
this patch uses the variable style for enumerator constants -- but
again, a new style could be used if that's preferred.

gdb/ChangeLog
2020-02-22  Tom Tromey  <tom@tromey.com>

	* valprint.c (generic_val_print_enum_1)
	(val_print_type_code_flags): Style member names.
	* rust-lang.c (val_print_struct, rust_print_enum)
	(rust_print_struct_def, rust_internal_print_type): Style member
	names.
	* p-valprint.c (pascal_object_print_value_fields): Style member
	names.  Only call fprintf_symbol_filtered for static members.
	* m2-typeprint.c (m2_record_fields, m2_enum): Style member names.
	* f-valprint.c (f_val_print): Style member names.
	* f-typeprint.c (f_type_print_base): Style member names.
	* cp-valprint.c (cp_print_value_fields): Style member names.  Only
	call fprintf_symbol_filtered for static members.
	(cp_print_class_member): Style member names.
	* c-typeprint.c (c_print_type_1, c_type_print_base_1): Style
	member names.
	* ada-valprint.c (ada_print_scalar): Style enum names.
	(ada_val_print_enum): Likewise.
	* ada-typeprint.c (print_enum_type): Style enum names.

gdb/testsuite/ChangeLog
2020-02-22  Tom Tromey  <tom@tromey.com>

	* gdb.rust/rust-style.rs: New file.
	* gdb.rust/rust-style.exp: New file.
	* gdb.base/style.exp: Test structure printing.
	* gdb.base/style.c (struct some_struct): New type.
	(enum etype): New type.
	(struct_value): New global.

Change-Id: I070e1293c6cc830c9ea916af8243410aa384e944
2020-02-22 10:12:52 -07:00
Doug Evans 084104828c rust/25535 Apply embedded offset to enum variant calculation
Hopefully straightforward (and I didn't miss anything ...).

gdb/ChangeLog
2020-02-19  Doug Evans  <dje@google.com>

	PR rust/25535
	* rust-lang.c (rust_print_enum): Apply embedded_offset to
	rust_enum_variant calculation.

gdb/testsuite/ChangeLog
2020-02-19  Doug Evans  <dje@google.com>

	PR rust/25535
	* gdb.rust/simple.exp: Add test.
	* gdb.rust/simple.rs: Add test.
2020-02-19 13:59:31 -07:00
Joel Brobecker b811d2c292 Update copyright year range in all GDB files.
gdb/ChangeLog:

        Update copyright year range in all GDB files.
2020-01-01 10:20:53 +04:00
Christian Biesinger 987012b89b Replace SYMBOL_*_NAME accessors with member functions
Similar to the MSYMBOL version of this patch, improves readability
and will eventually allow making name private.

gdb/ChangeLog:

2019-11-22  Christian Biesinger  <cbiesinger@google.com>

	* ada-exp.y: Update.
	* ada-lang.c (sort_choices): Update.
	(ada_print_symbol_signature): Update.
	(resolve_subexp): Update.
	(ada_parse_renaming): Update.
	(ada_read_renaming_var_value): Update.
	(lesseq_defined_than): Update.
	(remove_extra_symbols): Update.
	(remove_irrelevant_renamings): Update.
	(ada_add_block_symbols): Update.
	(ada_collect_symbol_completion_matches): Update.
	(ada_is_renaming_symbol): Update.
	(aggregate_assign_from_choices): Update.
	(ada_evaluate_subexp): Update.
	(ada_has_this_exception_support): Update.
	(ada_is_non_standard_exception_sym): Update.
	(ada_add_exceptions_from_frame): Update.
	(ada_add_global_exceptions): Update.
	(ada_print_subexp): Update.
	* ax-gdb.c (gen_var_ref): Update.
	(gen_maybe_namespace_elt): Update.
	(gen_expr_for_cast): Update.
	(gen_expr): Update.
	* block.h: Update.
	* blockframe.c (find_pc_partial_function): Update.
	* breakpoint.c (print_breakpoint_location): Update.
	(update_static_tracepoint): Update.
	* btrace.c (ftrace_print_function_name): Update.
	(ftrace_function_switched): Update.
	* buildsym.c (find_symbol_in_list): Update.
	* c-exp.y: Update.
	* c-typeprint.c (c_print_typedef): Update.
	(c_type_print_template_args): Update.
	* cli/cli-cmds.c (edit_command): Update.
	(list_command): Update.
	(print_sal_location): Update.
	* coffread.c (patch_opaque_types): Update.
	(process_coff_symbol): Update.
	(coff_read_enum_type): Update.
	* compile/compile-c-symbols.c (c_symbol_substitution_name): Update.
	(convert_one_symbol): Update.
	(hash_symname): Update.
	(eq_symname): Update.
	* compile/compile-cplus-symbols.c (convert_one_symbol): Update.
	* compile/compile-cplus-types.c (debug_print_scope): Update.
	* compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update.
	* compile/compile-object-load.c (get_out_value_type): Update.
	* cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
	(search_symbol_list): Update.
	(cp_lookup_symbol_imports_or_template): Update.
	* cp-support.c (overload_list_add_symbol): Update.
	* ctfread.c (psymtab_to_symtab): Update.
	* dbxread.c (cp_set_block_scope): Update.
	* dictionary.c (iter_match_first_hashed): Update.
	(iter_match_next_hashed): Update.
	(insert_symbol_hashed): Update.
	(iter_match_next_linear): Update.
	* dictionary.h: Update.
	* dwarf2loc.c (func_get_frame_base_dwarf_block): Update.
	(locexpr_describe_location_piece): Update.
	(locexpr_describe_location_1): Update.
	(locexpr_generate_c_location): Update.
	(loclist_describe_location): Update.
	(loclist_generate_c_location): Update.
	* dwarf2read.c (dw2_debug_names_lookup_symbol): Update.
	(read_func_scope): Update.
	(process_enumeration_scope): Update.
	(new_symbol): Update.
	(dwarf2_const_value): Update.
	(dwarf2_symbol_mark_computed): Update.
	* eval.c (evaluate_funcall): Update.
	(evaluate_subexp_standard): Update.
	* expprint.c (print_subexp_standard): Update.
	(dump_subexp_body_standard): Update.
	* f-valprint.c (info_common_command_for_block): Update.
	* findvar.c (get_hosting_frame): Update.
	(default_read_var_value): Update.
	* go-lang.c (go_symbol_package_name): Update.
	* guile/scm-block.c (bkscm_print_block_smob): Update.
	* guile/scm-symbol.c (syscm_print_symbol_smob): Update.
	(gdbscm_symbol_name): Update.
	(gdbscm_symbol_linkage_name): Update.
	(gdbscm_symbol_print_name): Update.
	* infcall.c (get_function_name): Update.
	* infcmd.c (jump_command): Update.
	(finish_command): Update.
	* infrun.c (insert_exception_resume_breakpoint): Update.
	* linespec.c (canonicalize_linespec): Update.
	(create_sals_line_offset): Update.
	(convert_linespec_to_sals): Update.
	(complete_label): Update.
	(find_label_symbols_in_block): Update.
	* m2-typeprint.c (m2_print_typedef): Update.
	* mdebugread.c (mdebug_reg_to_regnum): Update.
	(parse_symbol): Update.
	(mylookup_symbol): Update.
	* mi/mi-cmd-stack.c (list_arg_or_local): Update.
	(list_args_or_locals): Update.
	* objc-lang.c (compare_selectors): Update.
	(info_selectors_command): Update.
	(compare_classes): Update.
	(info_classes_command): Update.
	(find_imps): Update.
	* p-typeprint.c (pascal_print_typedef): Update.
	* printcmd.c (build_address_symbolic): Update.
	(info_address_command): Update.
	(print_variable_and_value): Update.
	* python/py-framefilter.c (extract_sym): Update.
	(py_print_single_arg): Update.
	* python/py-symbol.c (sympy_str): Update.
	(sympy_get_name): Update.
	(sympy_get_linkage_name): Update.
	* python/python.c (gdbpy_rbreak): Update.
	* record-btrace.c (btrace_get_bfun_name): Update.
	(btrace_call_history): Update.
	* rust-lang.c (rust_print_typedef): Update.
	* solib-frv.c (frv_fdpic_find_canonical_descriptor): Update.
	* stabsread.c (stab_reg_to_regnum): Update.
	(define_symbol): Update.
	(read_enum_type): Update.
	(common_block_end): Update.
	(cleanup_undefined_types_1): Update.
	(scan_file_globals): Update.
	* stack.c (print_frame_arg): Update.
	(print_frame_args): Update.
	(find_frame_funname): Update.
	(info_frame_command_core): Update.
	(iterate_over_block_locals): Update.
	(print_block_frame_labels): Update.
	(do_print_variable_and_value): Update.
	(iterate_over_block_arg_vars): Update.
	(return_command): Update.
	* symmisc.c (dump_symtab_1): Update.
	(print_symbol): Update.
	* symtab.c (eq_symbol_entry): Update.
	(symbol_cache_dump): Update.
	(lookup_language_this): Update.
	(find_pc_sect_line): Update.
	(skip_prologue_sal): Update.
	(symbol_search::compare_search_syms): Update.
	(treg_matches_sym_type_name): Update.
	(search_symbols): Update.
	(print_symbol_info): Update.
	(rbreak_command): Update.
	(completion_list_add_symbol): Update.
	(find_gnu_ifunc): Update.
	(get_symbol_address): Update.
	(search_module_symbols): Update.
	(info_module_subcommand): Update.
	* symtab.h (SYMBOL_NATURAL_NAME): Remove.
	(SYMBOL_LINKAGE_NAME): Remove.
	(SYMBOL_DEMANGLED_NAME): Remove.
	(SYMBOL_PRINT_NAME): Remove.
	(SYMBOL_SEARCH_NAME): Remove.
	* tracepoint.c (set_traceframe_context): Update.
	(validate_actionline): Update.
	(collection_list::collect_symbol): Update.
	(encode_actions_1): Update.
	(info_scope_command): Update.
	(print_one_static_tracepoint_marker): Update.
	* typeprint.c (typedef_hash_table::add_template_parameters): Update.
	* valops.c (address_of_variable): Update.
	(find_overload_match): Update.
	(find_oload_champ): Update.

Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 12:05:14 -06:00
Tom Tromey 91ae903f89 Remove la_get_string member
The la_get_string member of struct language_defn was intended to
provide a way to fetch string data from a "string" object in a
language-dependent way.  However, it turned out that this was never
needed, and was only ever implemented for C.  This patch removes the
language hook entirely.

gdb/ChangeLog
2019-11-05  Tom Tromey  <tom@tromey.com>

	* rust-lang.c (rust_language_defn): Update.
	* python/py-value.c (valpy_string): Call c_get_string.
	* p-lang.c (pascal_language_defn): Update.
	* opencl-lang.c (opencl_language_defn): Update.
	* objc-lang.c (objc_language_defn): Update.
	* m2-lang.c (m2_language_defn): Update.
	* language.c (unknown_language_defn, auto_language_defn): Update.
	(default_get_string): Remove.
	* guile/scm-value.c (gdbscm_value_to_string): Use c_get_string.
	* go-lang.c (go_language_defn): Update.
	* f-lang.c (f_language_defn): Update.
	* d-lang.c (d_language_defn): Update.
	* c-lang.c (c_language_defn, cplus_language_defn)
	(asm_language_defn, minimal_language_defn): Update.
	* ada-lang.c (ada_language_defn): Update.
	* language.h (struct language_defn) <la_get_string>: Remove.
	(LA_GET_STRING): Remove.
	(default_get_string): Don't declare.

Change-Id: Ia97763dfe34dc8ecb46587f7a651f8af9be8fdbd
2019-11-05 15:36:28 -07:00