Commit Graph

192 Commits

Author SHA1 Message Date
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
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 80fc5e77f0 gdb: remove TYPE_FIELDS macro
Remove all uses of the `TYPE_FIELDS` macro.  Replace them with either:

1) type::fields, to obtain a pointer to the fields array (same as
   TYPE_FIELDS yields)
2) type::field, a new convenience method that obtains a reference to one
   of the type's field by index.  It is meant to replace

     TYPE_FIELDS (type)[idx]

   with

     type->field (idx)

gdb/ChangeLog:

	* gdbtypes.h (struct type) <field>: New method.
	(TYPE_FIELDS): Remove, replace all uses with either type::fields
	or type::field.

Change-Id: I49fba10114417deb502060c6156aa5f7fc62462f
2020-05-22 16:55:17 -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 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 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
Tom Tromey 596dc4adff Speed up psymbol reading by removing a copy
I noticed that cp_canonicalize_string and friends copy a
unique_xmalloc_ptr to a std::string.  However, this copy isn't
genuinely needed anywhere, and it serves to slow down DWARF psymbol
reading.

This patch removes the copy and updates the callers to adapt.

This speeds up the reader from 1.906 seconds (mean of 10 runs, of gdb
on a copy of itself) to 1.888 seconds (mean of 10 runs, on the same
copy as the first trial).

gdb/ChangeLog
2020-05-08  Tom Tromey  <tom@tromey.com>

	* symtab.h (class demangle_result_storage) <set_malloc_ptr>: New
	overload.
	<swap_string, m_string>: Remove.
	* symtab.c (demangle_for_lookup, completion_list_add_symbol):
	Update.
	* stabsread.c (define_symbol, read_type): Update.
	* linespec.c (find_linespec_symbols): Update.
	* gnu-v3-abi.c (gnuv3_get_typeid): Update.
	* dwarf2/read.c (dwarf2_canonicalize_name): Update.
	* dbxread.c (read_dbx_symtab): Update.
	* cp-support.h (cp_canonicalize_string_full)
	(cp_canonicalize_string, cp_canonicalize_string_no_typedefs):
	Return unique_xmalloc_ptr.
	* cp-support.c (inspect_type): Update.
	(cp_canonicalize_string_full): Return unique_xmalloc_ptr.
	(cp_canonicalize_string_no_typedefs, cp_canonicalize_string):
	Likewise.
	* c-typeprint.c (print_name_maybe_canonical): Update.
	* break-catch-throw.c (check_status_exception_catchpoint):
	Update.
2020-05-08 14:14:06 -06:00
Tom Tromey 3293bbaffa Add C parser support for "restrict" and "_Atomic"
A user noticed that "watch -location" would fail with a "restrict"
pointer.  The issue here is that if the DWARF mentions "restrict", gdb
will put this into the type name -- but then the C parser will not be
able to parse this type.

This patch adds support for "restrict" and "_Atomic" to the C parser.
C++ doesn't have "restrict", but does have some GCC extensions.  The
type printer is changed to handle this difference as well, so that
watch expressions will work properly.

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

	* c-typeprint.c (cp_type_print_method_args): Print "__restrict__"
	for C++.
	(c_type_print_modifier): Likewise.  Add "language" parameter.
	(c_type_print_varspec_prefix, c_type_print_base_struct_union)
	(c_type_print_base_1): Update.
	* type-stack.h (enum type_pieces) <tp_atomic, tp_restrict>: New
	constants.
	* type-stack.c (type_stack::insert): Handle tp_atomic and
	tp_restrict.
	(type_stack::follow_type_instance_flags): Likewise.
	(type_stack::follow_types): Likewise.  Merge type-following code.
	* c-exp.y (RESTRICT, ATOMIC): New tokens.
	(space_identifier, cv_with_space_id)
	(const_or_volatile_or_space_identifier_noopt)
	(const_or_volatile_or_space_identifier): Remove.
	(single_qualifier, qualifier_seq_noopt, qualifier_seq): New
	rules.
	(ptr_operator, typebase): Update.
	(enum token_flag) <FLAG_C>: New constant.
	(ident_tokens): Add "restrict", "__restrict__", "__restrict", and
	"_Atomic".
	(lex_one_token): Handle FLAG_C.

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

	* gdb.base/cvexpr.exp: Add test for _Atomic and restrict.
2020-03-14 12:32:10 -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
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
Andrew Burgess e170989694 gdb: Don't print a newline in language la_print_typedef methods
When calling the language la_print_typedef method, don't include a
newline at the end, instead print the newline from the users of
la_print_typedef.

This change will be useful in a later commit when the output from
la_print_typedef will be placed into an MI output field, in which case
the trailing newline is not required.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-typeprint.c (ada_print_typedef): Don't print newline at the
	end.
	* c-typeprint.c (c_print_typedef): Likewise.
	* f-typeprint.c (f_print_typedef): Likewise.
	* m2-typeprint.c (m2_print_typedef): Likewise.
	* p-typeprint.c (pascal_print_typedef): Likewise.
	* rust-lang.c (rust_print_typedef): Likewise.
	* symtab.c (print_symbol_info): Print a newline after calling
	typedef_print.

Change-Id: I6e697ea1ec0eadaa31aefaea959b2055188d680d
2019-10-31 23:02:59 +00:00
Tom Tromey 7f6aba03b9 Introduce metadata style
This introduces a new "metadata" style and changes many places in gdb
to use it.  The idea here is to let the user distinguish gdb output
from output that (conceptually at least) comes directly from the
inferior.  The newly-styled category includes text that gdb
traditionally surrounds in "<...>", like "<unavailable>".

I only added a single test for this.  In many cases this output is
difficult to test.  Also, while developing this errors in the
implementation of the new printf formats showed up as regressions.

gdb/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

	* p-lang.c (pascal_printstr): Use metadata style.
	* value.c (show_convenience): Use metadata style.
	* valprint.c (valprint_check_validity, val_print_optimized_out)
	(val_print_not_saved, val_print_unavailable)
	(val_print_invalid_address, generic_val_print, val_print)
	(value_check_printable, val_print_array_elements): Use metadata
	style.
	* ui-out.h (class ui_out) <field_fmt>: New overload.
	<do_field_fmt>: Add style parameter.
	* ui-out.c (ui_out::field_fmt): New overload.
	* typeprint.c (type_print_unknown_return_type)
	(val_print_not_allocated, val_print_not_associated): Use metadata
	style.
	* tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style
	parameter.
	* tui/tui-out.c (tui_ui_out::do_field_fmt): Update.
	* tracepoint.c (tvariables_info_1): Use metadata style.
	* stack.c (print_frame_arg, print_frame_info, print_frame)
	(info_frame_command_core): Use metadata style.
	* skip.c (info_skip_command): Use metadata style.
	* rust-lang.c (rust_print_enum): Use metadata style.
	* python/py-prettyprint.c (print_stack_unless_memory_error): Use
	metadata style.
	* python/py-framefilter.c (py_print_single_arg): Use metadata
	style.
	* printcmd.c (do_one_display, print_variable_and_value): Use
	metadata style.
	* p-valprint.c (pascal_val_print)
	(pascal_object_print_value_fields): Use metadata style.
	* p-typeprint.c (pascal_type_print_base): Use metadata style.
	* mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style
	parameter.
	* mi/mi-out.c (mi_ui_out::do_field_fmt): Update.
	* m2-valprint.c (m2_print_long_set): Use metadata style.
	* m2-typeprint.c (m2_print_type): Use metadata style.
	* infcmd.c (print_return_value_1): Use metadata style.
	* gnu-v3-abi.c (print_one_vtable): Use metadata style.
	* f-valprint.c (info_common_command_for_block): Use metadata
	style.
	* f-typeprint.c (f_type_print_base): Use metadata style.
	* expprint.c (print_subexp_standard): Use metadata style.
	* cp-valprint.c (cp_print_value_fields): Use metadata style.
	* cli/cli-style.h (class cli_style_option): Add constructor.
	(metadata_style): Declare.
	* cli/cli-style.c (metadata_style): New global.
	(_initialize_cli_style): Register metadata style.
	* cli-out.h (class cli_ui_out) <do_field_fmt>: Add style
	parameter.
	* cli-out.c (cli_ui_out::do_field_fmt): Update.
	* c-typeprint.c (c_type_print_base_struct_union)
	(c_type_print_base_1): Use metadata style.
	* breakpoint.c (watchpoint_value_print)
	(print_one_breakpoint_location): Use metadata style.
	* break-catch-syscall.c (print_one_catch_syscall): Use metadata
	style.
	* break-catch-sig.c (signal_catchpoint_print_one): Use metadata
	style.
	* ada-valprint.c (val_print_packed_array_elements, printstr)
	(print_field_values, ada_val_print_ref, ada_val_print): Use
	metadata style.
	* ada-typeprint.c (print_array_type, ada_print_type): Use metadata
	style.
	* ada-tasks.c (print_ada_task_info, info_task): Use metadata
	style.
	* ada-lang.c (user_select_syms): Use metadata style.

gdb/testsuite/ChangeLog
2019-10-01  Tom Tromey  <tom@tromey.com>

	* lib/gdb-utils.exp (style): Handle "metadata" argument.
	* gdb.base/style.exp: Add metadata style test.
2019-10-01 15:12:40 -06:00
Andrew Burgess a8e9d24718 gdb: Show type summary for anonymous structures from c_print_typedef
Currently each language has a la_print_typedef method, this is only
used for the "info types" command.

The documentation for "info types" says:

   Print a brief description of all types whose names match the regular
   expression @var{regexp} (or all types in your program, if you supply
   no argument).

However, if we consider this C code:

   typedef struct {
     int a;
   } my_type;

Then currently with "info types" this will be printed like this:

   3:      typedef struct {
       int a;
   } my_type;

I see two problems with this, first the indentation is clearly broken,
second, if the struct contained more fields then it feels like the
actual type names could easily get lost in the noise.

Given that "info types" is about discovering type names, I think there
is an argument to be made that we should focus on giving _only_ the
briefest summary for "info types", and if the user wants to know more
they can take the type name and plug it into "ptype".  As such, I
propose that a better output would be:

   3:      typedef struct {...} my_type;

The user understands that there is a type called `my_type`, and that
it's an alias for an anonymous structure type.

The change to achieve this turns out to be pretty simple, but only
effects languages that make use of c_print_typedef, which are C, C++,
asm, minimal, d, go, objc, and opencl.  Other languages will for now
do whatever they used to do.

The patch to change how anonymous structs are displayed also changes
the display of anonymous enums, consider this code sample:

   typedef enum {
     AA, BB, CC
   } anon_enum_t;

This used to be displayed like this:

   3:      typedef enum {AA, BB, CC} anon_enum_t;

Which will quickly become cluttered for enums with a large number of
values.  The modified output looks like this:

   3:      typedef enum {...} anon_enum_t;

Again, the user can always make use of ptype if they want to see the
details of the anon_enum_t type.

It is worth pointing out that this change (to use {...}) only effects
anonymous structs and enums, named types don't change with this patch,
consider this code:

   struct struct_t {
     int i;
   };
   enum enum_t {
    AA, BB, CC
   };

The output from 'info types' remains unchanged, like this:

   4:      enum enum_t;
   1:      struct struct_t;

An additional area of interest is how C++ handles anonymous types used
within a typedef; enums are handled basically inline with how C
handles them, but structs (and classes) are slightly different.  The
behaviour before the patch is different, and is unchanged by this
patch.  Consider this code compiled for C++:

   typedef struct {
     int i;
   } struct_t;

Both before and after this patch, this is show by 'info types' as:

   3:      typedef struct_t struct_t;

Unions are displayed similarly to structs in both C and C++, the
handling of anonymous unions changes for C in the same way that
it changes for anonymous structs.

I did look at ada, as this is the only language to actually have some
tests for "info types", however, as I understand it ada doesn't really
support typedefs, however, by forcing the language we can see what ada
would print.  So, if we 'set language ada', then originally we printed
this:

   3:      record
       a: int;
   end record

Again the indentation is clearly broken, but we also have no mention
of the type name at all, which is odd, but understandable given the
lack of typedefs.  If I make a similar change as I'm proposing for C,
then we now get this output:

   3:      record ... end record

Which is even less informative I think.  However, the original output
_is_ tested for in gdb.ada/info_auto_lang.exp, and its not clear to me
if the change is a good one or not, so for now I have left this out.

gdb/ChangeLog:

	* c-typeprint.c (c_print_typedef): Pass -1 instead of 0 to
	type_print.

gdb/testsuite/ChangeLog:

	* gdb.ada/info_auto_lang.exp: Update expected results.
	* gdb.base/info-types.c: Add additional types to check.
	* gdb.base/info-types.exp: Update expected results.
2019-07-22 10:43:03 +01:00
Tom Tromey 4de283e4b5 Revert the header-sorting patch
Andreas Schwab and John Baldwin pointed out some bugs in the header
sorting patch; and I noticed that the output was not correct when
limited to a subset of files (a bug in my script).

So, I'm reverting the patch.  I may try again after fixing the issues
pointed out.

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

	Revert the header-sorting patch.
	* ft32-tdep.c: Revert.
	* frv-tdep.c: Revert.
	* frv-linux-tdep.c: Revert.
	* frame.c: Revert.
	* frame-unwind.c: Revert.
	* frame-base.c: Revert.
	* fork-child.c: Revert.
	* findvar.c: Revert.
	* findcmd.c: Revert.
	* filesystem.c: Revert.
	* filename-seen-cache.h: Revert.
	* filename-seen-cache.c: Revert.
	* fbsd-tdep.c: Revert.
	* fbsd-nat.h: Revert.
	* fbsd-nat.c: Revert.
	* f-valprint.c: Revert.
	* f-typeprint.c: Revert.
	* f-lang.c: Revert.
	* extension.h: Revert.
	* extension.c: Revert.
	* extension-priv.h: Revert.
	* expprint.c: Revert.
	* exec.h: Revert.
	* exec.c: Revert.
	* exceptions.c: Revert.
	* event-top.c: Revert.
	* event-loop.c: Revert.
	* eval.c: Revert.
	* elfread.c: Revert.
	* dwarf2read.h: Revert.
	* dwarf2read.c: Revert.
	* dwarf2loc.c: Revert.
	* dwarf2expr.h: Revert.
	* dwarf2expr.c: Revert.
	* dwarf2-frame.c: Revert.
	* dwarf2-frame-tailcall.c: Revert.
	* dwarf-index-write.h: Revert.
	* dwarf-index-write.c: Revert.
	* dwarf-index-common.c: Revert.
	* dwarf-index-cache.h: Revert.
	* dwarf-index-cache.c: Revert.
	* dummy-frame.c: Revert.
	* dtrace-probe.c: Revert.
	* disasm.h: Revert.
	* disasm.c: Revert.
	* disasm-selftests.c: Revert.
	* dictionary.c: Revert.
	* dicos-tdep.c: Revert.
	* demangle.c: Revert.
	* dcache.h: Revert.
	* dcache.c: Revert.
	* darwin-nat.h: Revert.
	* darwin-nat.c: Revert.
	* darwin-nat-info.c: Revert.
	* d-valprint.c: Revert.
	* d-namespace.c: Revert.
	* d-lang.c: Revert.
	* ctf.c: Revert.
	* csky-tdep.c: Revert.
	* csky-linux-tdep.c: Revert.
	* cris-tdep.c: Revert.
	* cris-linux-tdep.c: Revert.
	* cp-valprint.c: Revert.
	* cp-support.c: Revert.
	* cp-namespace.c: Revert.
	* cp-abi.c: Revert.
	* corelow.c: Revert.
	* corefile.c: Revert.
	* continuations.c: Revert.
	* completer.h: Revert.
	* completer.c: Revert.
	* complaints.c: Revert.
	* coffread.c: Revert.
	* coff-pe-read.c: Revert.
	* cli-out.h: Revert.
	* cli-out.c: Revert.
	* charset.c: Revert.
	* c-varobj.c: Revert.
	* c-valprint.c: Revert.
	* c-typeprint.c: Revert.
	* c-lang.c: Revert.
	* buildsym.c: Revert.
	* buildsym-legacy.c: Revert.
	* build-id.h: Revert.
	* build-id.c: Revert.
	* btrace.c: Revert.
	* bsd-uthread.c: Revert.
	* breakpoint.h: Revert.
	* breakpoint.c: Revert.
	* break-catch-throw.c: Revert.
	* break-catch-syscall.c: Revert.
	* break-catch-sig.c: Revert.
	* blockframe.c: Revert.
	* block.c: Revert.
	* bfin-tdep.c: Revert.
	* bfin-linux-tdep.c: Revert.
	* bfd-target.c: Revert.
	* bcache.c: Revert.
	* ax-general.c: Revert.
	* ax-gdb.h: Revert.
	* ax-gdb.c: Revert.
	* avr-tdep.c: Revert.
	* auxv.c: Revert.
	* auto-load.c: Revert.
	* arm-wince-tdep.c: Revert.
	* arm-tdep.c: Revert.
	* arm-symbian-tdep.c: Revert.
	* arm-pikeos-tdep.c: Revert.
	* arm-obsd-tdep.c: Revert.
	* arm-nbsd-tdep.c: Revert.
	* arm-nbsd-nat.c: Revert.
	* arm-linux-tdep.c: Revert.
	* arm-linux-nat.c: Revert.
	* arm-fbsd-tdep.c: Revert.
	* arm-fbsd-nat.c: Revert.
	* arm-bsd-tdep.c: Revert.
	* arch-utils.c: Revert.
	* arc-tdep.c: Revert.
	* arc-newlib-tdep.c: Revert.
	* annotate.h: Revert.
	* annotate.c: Revert.
	* amd64-windows-tdep.c: Revert.
	* amd64-windows-nat.c: Revert.
	* amd64-tdep.c: Revert.
	* amd64-sol2-tdep.c: Revert.
	* amd64-obsd-tdep.c: Revert.
	* amd64-obsd-nat.c: Revert.
	* amd64-nbsd-tdep.c: Revert.
	* amd64-nbsd-nat.c: Revert.
	* amd64-nat.c: Revert.
	* amd64-linux-tdep.c: Revert.
	* amd64-linux-nat.c: Revert.
	* amd64-fbsd-tdep.c: Revert.
	* amd64-fbsd-nat.c: Revert.
	* amd64-dicos-tdep.c: Revert.
	* amd64-darwin-tdep.c: Revert.
	* amd64-bsd-nat.c: Revert.
	* alpha-tdep.c: Revert.
	* alpha-obsd-tdep.c: Revert.
	* alpha-nbsd-tdep.c: Revert.
	* alpha-mdebug-tdep.c: Revert.
	* alpha-linux-tdep.c: Revert.
	* alpha-linux-nat.c: Revert.
	* alpha-bsd-tdep.c: Revert.
	* alpha-bsd-nat.c: Revert.
	* aix-thread.c: Revert.
	* agent.c: Revert.
	* addrmap.c: Revert.
	* ada-varobj.c: Revert.
	* ada-valprint.c: Revert.
	* ada-typeprint.c: Revert.
	* ada-tasks.c: Revert.
	* ada-lang.c: Revert.
	* aarch64-tdep.c: Revert.
	* aarch64-ravenscar-thread.c: Revert.
	* aarch64-newlib-tdep.c: Revert.
	* aarch64-linux-tdep.c: Revert.
	* aarch64-linux-nat.c: Revert.
	* aarch64-fbsd-tdep.c: Revert.
	* aarch64-fbsd-nat.c: Revert.
	* aarch32-linux-nat.c: Revert.
2019-04-06 13:47:34 -06:00
Tom Tromey d55e5aa6b2 Sort includes for files gdb/[a-f]*.[chyl].
This patch sorts the include files for the files [a-f]*.[chyl].
The patch was written by a script.

Tested by the buildbot.

I will follow up with patches to sort the remaining files, by sorting
a subset, testing them, and then checking them in.

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

	* ft32-tdep.c: Sort headers.
	* frv-tdep.c: Sort headers.
	* frv-linux-tdep.c: Sort headers.
	* frame.c: Sort headers.
	* frame-unwind.c: Sort headers.
	* frame-base.c: Sort headers.
	* fork-child.c: Sort headers.
	* findvar.c: Sort headers.
	* findcmd.c: Sort headers.
	* filesystem.c: Sort headers.
	* filename-seen-cache.h: Sort headers.
	* filename-seen-cache.c: Sort headers.
	* fbsd-tdep.c: Sort headers.
	* fbsd-nat.h: Sort headers.
	* fbsd-nat.c: Sort headers.
	* f-valprint.c: Sort headers.
	* f-typeprint.c: Sort headers.
	* f-lang.c: Sort headers.
	* extension.h: Sort headers.
	* extension.c: Sort headers.
	* extension-priv.h: Sort headers.
	* expprint.c: Sort headers.
	* exec.h: Sort headers.
	* exec.c: Sort headers.
	* exceptions.c: Sort headers.
	* event-top.c: Sort headers.
	* event-loop.c: Sort headers.
	* eval.c: Sort headers.
	* elfread.c: Sort headers.
	* dwarf2read.h: Sort headers.
	* dwarf2read.c: Sort headers.
	* dwarf2loc.c: Sort headers.
	* dwarf2expr.h: Sort headers.
	* dwarf2expr.c: Sort headers.
	* dwarf2-frame.c: Sort headers.
	* dwarf2-frame-tailcall.c: Sort headers.
	* dwarf-index-write.h: Sort headers.
	* dwarf-index-write.c: Sort headers.
	* dwarf-index-common.c: Sort headers.
	* dwarf-index-cache.h: Sort headers.
	* dwarf-index-cache.c: Sort headers.
	* dummy-frame.c: Sort headers.
	* dtrace-probe.c: Sort headers.
	* disasm.h: Sort headers.
	* disasm.c: Sort headers.
	* disasm-selftests.c: Sort headers.
	* dictionary.c: Sort headers.
	* dicos-tdep.c: Sort headers.
	* demangle.c: Sort headers.
	* dcache.h: Sort headers.
	* dcache.c: Sort headers.
	* darwin-nat.h: Sort headers.
	* darwin-nat.c: Sort headers.
	* darwin-nat-info.c: Sort headers.
	* d-valprint.c: Sort headers.
	* d-namespace.c: Sort headers.
	* d-lang.c: Sort headers.
	* ctf.c: Sort headers.
	* csky-tdep.c: Sort headers.
	* csky-linux-tdep.c: Sort headers.
	* cris-tdep.c: Sort headers.
	* cris-linux-tdep.c: Sort headers.
	* cp-valprint.c: Sort headers.
	* cp-support.c: Sort headers.
	* cp-namespace.c: Sort headers.
	* cp-abi.c: Sort headers.
	* corelow.c: Sort headers.
	* corefile.c: Sort headers.
	* continuations.c: Sort headers.
	* completer.h: Sort headers.
	* completer.c: Sort headers.
	* complaints.c: Sort headers.
	* coffread.c: Sort headers.
	* coff-pe-read.c: Sort headers.
	* cli-out.h: Sort headers.
	* cli-out.c: Sort headers.
	* charset.c: Sort headers.
	* c-varobj.c: Sort headers.
	* c-valprint.c: Sort headers.
	* c-typeprint.c: Sort headers.
	* c-lang.c: Sort headers.
	* buildsym.c: Sort headers.
	* buildsym-legacy.c: Sort headers.
	* build-id.h: Sort headers.
	* build-id.c: Sort headers.
	* btrace.c: Sort headers.
	* bsd-uthread.c: Sort headers.
	* breakpoint.h: Sort headers.
	* breakpoint.c: Sort headers.
	* break-catch-throw.c: Sort headers.
	* break-catch-syscall.c: Sort headers.
	* break-catch-sig.c: Sort headers.
	* blockframe.c: Sort headers.
	* block.c: Sort headers.
	* bfin-tdep.c: Sort headers.
	* bfin-linux-tdep.c: Sort headers.
	* bfd-target.c: Sort headers.
	* bcache.c: Sort headers.
	* ax-general.c: Sort headers.
	* ax-gdb.h: Sort headers.
	* ax-gdb.c: Sort headers.
	* avr-tdep.c: Sort headers.
	* auxv.c: Sort headers.
	* auto-load.c: Sort headers.
	* arm-wince-tdep.c: Sort headers.
	* arm-tdep.c: Sort headers.
	* arm-symbian-tdep.c: Sort headers.
	* arm-pikeos-tdep.c: Sort headers.
	* arm-obsd-tdep.c: Sort headers.
	* arm-nbsd-tdep.c: Sort headers.
	* arm-nbsd-nat.c: Sort headers.
	* arm-linux-tdep.c: Sort headers.
	* arm-linux-nat.c: Sort headers.
	* arm-fbsd-tdep.c: Sort headers.
	* arm-fbsd-nat.c: Sort headers.
	* arm-bsd-tdep.c: Sort headers.
	* arch-utils.c: Sort headers.
	* arc-tdep.c: Sort headers.
	* arc-newlib-tdep.c: Sort headers.
	* annotate.h: Sort headers.
	* annotate.c: Sort headers.
	* amd64-windows-tdep.c: Sort headers.
	* amd64-windows-nat.c: Sort headers.
	* amd64-tdep.c: Sort headers.
	* amd64-sol2-tdep.c: Sort headers.
	* amd64-obsd-tdep.c: Sort headers.
	* amd64-obsd-nat.c: Sort headers.
	* amd64-nbsd-tdep.c: Sort headers.
	* amd64-nbsd-nat.c: Sort headers.
	* amd64-nat.c: Sort headers.
	* amd64-linux-tdep.c: Sort headers.
	* amd64-linux-nat.c: Sort headers.
	* amd64-fbsd-tdep.c: Sort headers.
	* amd64-fbsd-nat.c: Sort headers.
	* amd64-dicos-tdep.c: Sort headers.
	* amd64-darwin-tdep.c: Sort headers.
	* amd64-bsd-nat.c: Sort headers.
	* alpha-tdep.c: Sort headers.
	* alpha-obsd-tdep.c: Sort headers.
	* alpha-nbsd-tdep.c: Sort headers.
	* alpha-mdebug-tdep.c: Sort headers.
	* alpha-linux-tdep.c: Sort headers.
	* alpha-linux-nat.c: Sort headers.
	* alpha-bsd-tdep.c: Sort headers.
	* alpha-bsd-nat.c: Sort headers.
	* aix-thread.c: Sort headers.
	* agent.c: Sort headers.
	* addrmap.c: Sort headers.
	* ada-varobj.c: Sort headers.
	* ada-valprint.c: Sort headers.
	* ada-typeprint.c: Sort headers.
	* ada-tasks.c: Sort headers.
	* ada-lang.c: Sort headers.
	* aarch64-tdep.c: Sort headers.
	* aarch64-ravenscar-thread.c: Sort headers.
	* aarch64-newlib-tdep.c: Sort headers.
	* aarch64-linux-tdep.c: Sort headers.
	* aarch64-linux-nat.c: Sort headers.
	* aarch64-fbsd-tdep.c: Sort headers.
	* aarch64-fbsd-nat.c: Sort headers.
	* aarch32-linux-nat.c: Sort headers.
2019-04-05 19:09:35 -06:00
Philippe Waroquiers ac8c53cc67 Use function_name_style to print Ada and C function names
Note that ada-typeprint.c print_func_type is called with
types representing functions and is also called to print
a function NAME together with its type.  In such a case, the function
name will be printed using function name style.

Similarly, c_print_type_1 is called to print a type, optionally
with the name of an object of this type in the VARSTRING arg.
So, c_print_type_1 uses function name style to print varstring
when the type code indicates that c_print_type_1 TYPE is some
'real code'.

gdb/ChangeLog
2019-02-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* ada-typeprint.c (print_func_type): Print function name
	style to print function name.
	* c-typeprint.c (c_print_type_1): Likewise.
2019-02-12 19:59:39 +01:00
Joel Brobecker 42a4f53d2b Update copyright year range in all GDB files.
This commit applies all changes made after running the gdb/copyright.py
script.

Note that one file was flagged by the script, due to an invalid
copyright header
(gdb/unittests/basic_string_view/element_access/char/empty.cc).
As the file was copied from GCC's libstdc++-v3 testsuite, this commit
leaves this file untouched for the time being; a patch to fix the header
was sent to gcc-patches first.

gdb/ChangeLog:

	Update copyright year range in all GDB files.
2019-01-01 10:01:51 +04:00
Sergio Durigan Junior 16ff70ddd4 Fix PR c++/23373: GDB hangs when printing a struct with a static member of itself
This patch fixes a failure that happens when a structure has a static
member whose type is the same as itself.  From the bug report:

  Example code:
  struct A
  {
      static A Empty;
      int a;
  };

  int main(void) {
      A a;
      return 0;
  }

  Output:
  (gdb) ptype/o A
  /* offset    |  size */  type = struct A {
			     static struct A {
				 static struct A {
				     static struct A {
					 static struct A {
					     static struct A {
						 static struct A {
						     ... # infinite loop

The problem here is that GDB is not taking into account the fact that
static members inside a class/struct are not stored in the
class/struct, and therefore they should not be accounted for during
the display of the offsets/sizes.  The fix is simple: we just check if
the field we're dealing with (on
c-typeprint.c:c_type_print_base_struct_union) is static, and if it is
then we don't iterate over it.

This patch also adds a new test for this case, and doesn't introduce
any regressions.  I believe it is important enough to be included in
the 8.2 branch.

OK?

gdb/ChangeLog:
2018-07-11  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR c++/23373
	* c-typeprint.c (c_type_print_base_struct_union): Don't print
	offsets/sizes for static members of a class/struct.

gdb/testsuite/ChangeLog:
2018-07-11  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR c++/23373
	* gdb.base/ptype-offsets.cc (struct static_member): New
	struct.
	(main) <stmember>: New variable.
	* gdb.base/ptype-offsets.exp: Add test for printing a struct
	with a static member in it.
2018-07-11 14:53:44 -04:00
Tom Tromey e0c547d14a Move ptype/o printing code to typeprint.c
This moves the hole-printing support code for ptype/o from
c-typeprint.c to be methods on print_offset_data.  This allows the
code to be used from non-C languages.

gdb/ChangeLog
2018-06-26  Tom Tromey  <tom@tromey.com>

	* typeprint.h (struct print_offset_data) <update, finish,
	maybe_print_hole>: New methods.
	<indentation>: New constant.
	* typeprint.c (print_offset_data::indentation): Define.
	(print_offset_data::maybe_print_hole, print_offset_data::update)
	(print_offset_data::finish): Move from c-typeprint.c and rename.
	* c-typeprint.c (OFFSET_SPC_LEN): Remove.
	(print_spaces_filtered_with_print_options): Update.
	(c_print_type_union_field_offset, maybe_print_hole)
	(c_print_type_struct_field_offset): Move to typeprint.c and
	rename.
	(c_type_print_base_struct_union): Update.
2018-06-26 14:53:17 -06:00
Tom Tromey a737d952e0 Remove type_name_no_tag and rename type_name_no_tag_or_error
type_name_no_tag is just a plain wrapper for TYPE_NAME now, so this
patch removes it.  And, because tag names no longer exist, this
renames type_name_no_tag_or_error to type_name_or_error.

gdb/ChangeLog
2018-06-01  Tom Tromey  <tom@tromey.com>

	* valops.c (value_cast_structs, destructor_name_p): Update.
	* symtab.c (gdb_mangle_name): Update.
	* stabsread.c (define_symbol, read_cpp_abbrev, read_baseclasses):
	Update.
	* p-valprint.c (pascal_object_is_vtbl_ptr_type)
	(pascal_object_print_value_fields, pascal_object_print_value):
	Update.
	* p-typeprint.c (pascal_type_print_derivation_info): Update.
	* linespec.c (find_methods): Update.
	* gdbtypes.h (type_name_no_tag): Remove.
	(type_name_or_error): Rename from type_name_no_tag_or_error.
	* gdbtypes.c (type_name_no_tag): Remove.
	(type_name_or_error): Rename from type_name_no_tag_or_error.
	(lookup_struct_elt_type, check_typedef): Update.
	* expprint.c (print_subexp_standard): Update.
	* dwarf2read.c (dwarf2_add_field, load_partial_dies): Update.
	* d-namespace.c (d_lookup_nested_symbol): Update.
	* cp-valprint.c (cp_is_vtbl_ptr_type, cp_print_value_fields)
	(cp_print_class_member): Update.
	* cp-namespace.c (cp_lookup_nested_symbol): Update.
	* completer.c (add_struct_fields): Update.
	* c-typeprint.c (cp_type_print_derivation_info)
	(c_type_print_varspec_prefix, c_type_print_base_struct_union):
	Update.
	* ada-lang.c (parse_old_style_renaming, xget_renaming_scope)
	(ada_prefer_type, ada_is_exception_sym): Update.
2018-06-01 10:19:55 -06:00
Tom Tromey e86ca25fd6 Remove TYPE_TAG_NAME
TYPE_TAG_NAME has been an occasional source of confusion and bugs.  It
seems to me that it is only useful for C and C++ -- but even there,
not so much, because at least with DWARF there doesn't seem to be any
way to wind up with a type where the name and the tag name are both
non-NULL and different.

So, this patch removes TYPE_TAG_NAME entirely.  This should save a
little memory, but more importantly, it simplifies this part of gdb.

A few minor test suite adjustments were needed.  In some situations
the new code does not yield identical output to the old code.

gdb/ChangeLog
2018-06-01  Tom Tromey  <tom@tromey.com>

	* valops.c (enum_constant_from_type, value_namespace_elt)
	(value_maybe_namespace_elt): Update.
	* valarith.c (find_size_for_pointer_math): Update.
	* target-descriptions.c (make_gdb_type): Update.
	* symmisc.c (print_symbol): Update.
	* stabsread.c (define_symbol, read_type)
	(complain_about_struct_wipeout, add_undefined_type)
	(cleanup_undefined_types_1): Update.
	* rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
	(rust_range_type_p, val_print_struct, rust_print_struct_def)
	(rust_internal_print_type, rust_composite_type)
	(rust_evaluate_funcall, rust_evaluate_subexp)
	(rust_inclusive_range_type_p): Update.
	* python/py-type.c (typy_get_tag): Update.
	* p-typeprint.c (pascal_type_print_base): Update.
	* mdebugread.c (parse_symbol, parse_type): Update.
	* m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
	Update.
	* guile/scm-type.c (gdbscm_type_tag): Update.
	* go-lang.c (sixg_string_p): Update.
	* gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
	Update.
	* gdbtypes.h (struct main_type) <tag_name>: Remove.
	(TYPE_TAG_NAME): Remove.
	* gdbtypes.c (type_name_no_tag): Simplify.
	(check_typedef, check_types_equal, recursive_dump_type)
	(copy_type_recursive, arch_composite_type): Update.
	* f-typeprint.c (f_type_print_base): Update.  Print "Type" prefix
	in summary mode when needed.
	* eval.c (evaluate_funcall): Update.
	* dwarf2read.c (fixup_go_packaging, read_structure_type)
	(process_structure_scope, read_enumeration_type)
	(read_namespace_type, read_module_type, determine_prefix): Update.
	* cp-support.c (inspect_type): Update.
	* coffread.c (process_coff_symbol, decode_base_type): Update.
	* c-varobj.c (c_is_path_expr_parent): Update.
	* c-typeprint.c (c_type_print_base_struct_union): Update.
	(c_type_print_base_1): Update.  Print struct/class/union/enum in
	summary when using C language.
	* ax-gdb.c (gen_struct_ref, gen_namespace_elt)
	(gen_maybe_namespace_elt): Update.
	* ada-lang.c (ada_type_name): Simplify.
	(empty_record, ada_template_to_fixed_record_type_1)
	(template_to_static_fixed_type)
	(to_record_with_fixed_variant_part, ada_check_typedef): Update.

gdb/testsuite/ChangeLog
2018-06-01  Tom Tromey  <tom@tromey.com>

	* gdb.xml/tdesc-regs.exp (load_description): Update expected
	results.
	* gdb.dwarf2/method-ptr.exp: Set language to C++.
	* gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
	* gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
	* gdb.base/maint.exp (maint_pass_if): Update.
2018-06-01 10:19:55 -06:00
Tom Tromey c1ec8cea7f Thread language through c_type_print_args
Currently dwarf2read.c will pass the CU's language to
c_type_print_args -- but this doesn't affect all aspects of type
printing, because some code in c-typeprint.c refers to
current_language.

This patch threads the language through more of the type printing
code, adding an overload to c_type_print.  Some uses of
current_language remain, but now they are only in top-level functions.

gdb/ChangeLog
2018-06-01  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (dwarf2_compute_name): Pass CU's language to
	c_print_type.
	* c-typeprint.c (c_print_type_1): Add "language" parameter.
	(c_print_type): Update.
	(c_print_type): New overload.
	(c_type_print_varspec_prefix, c_type_print_args)
	(c_type_print_varspec_suffix, c_print_type_no_offsets)
	(c_type_print_base_struct_union, c_type_print_base_1)
	(cp_type_print_method_args): Add "language" parameter.
	(c_type_print_base): Update.
	* c-lang.h (c_print_type): Add new overload.
2018-06-01 10:19:55 -06:00
Tom Tromey bc8453a7bb Make c_type_print_varspec_suffix static
I noticed that c_type_print_varspec_suffix is only called from
c-typeprint.c, so this patch makes it "static".

gdb/ChangeLog
2018-06-01  Tom Tromey  <tom@tromey.com>

	* typeprint.h (c_type_print_varspec_suffix): Don't declare.
	* c-typeprint.c (c_type_print_varspec_suffix): Now static.
2018-06-01 10:19:55 -06:00
Tom Tromey ce1e8424c6 Show padding in ptype/o output
I was recently using ptype/o to look at the layout of some objects in
gdb.  I noticed that trailing padding was not shown -- but I wanted to
be able to look at that, too.

This patch changes ptype/o to also print trailing holes.

Tested on x86-64 Fedora 26.

gdb/ChangeLog
2018-05-18  Tom Tromey  <tom@tromey.com>

	* c-typeprint.c (maybe_print_hole): New function.
	(c_print_type_struct_field_offset): Update.
	(c_type_print_base_struct_union): Call maybe_print_hole.

gdb/testsuite/ChangeLog
2018-05-18  Tom Tromey  <tom@tromey.com>

	* gdb.base/ptype-offsets.exp: Update.
2018-05-18 13:20:39 -06:00
Tom Tromey c819b2c0b2 C++-ify typedef hash
This changes the typedef_hash_table structure to be a C++ class.  It
adds constructors and destructors and changes some functions to be
methods of the class.  Then it changes the various users of this class
to adapt.  This allows for the removal of some cleanups.

Regression tested by the buildbot.

gdb/ChangeLog
2018-03-27  Tom Tromey  <tom@tromey.com>

	* typeprint.h (struct type_print_options) <local_typedefs,
	global_typedefs>: Remove "struct" keyword.
	(class typedef_hash_table): New class.
	(recursively_update_typedef_hash, add_template_parameters)
	(create_typedef_hash, free_typedef_hash, copy_typedef_hash)
	(find_typedef_in_hash): Don't declare.
	* typeprint.c (struct typedef_hash_table): Move to typeprint.h.
	(typedef_hash_table::recursively_update): Rename from
	recursively_update_typedef_hash.  Now a member.
	(typedef_hash_table::add_template_parameters): Rename from
	add_template_parameters.  Now a member.
	(typedef_hash_table::typedef_hash_table): Now a constructor;
	rename from create_typedef_hash.
	(typedef_hash_table::~typedef_hash_table): Now a destructor;
	rename from free_typedef_hash.
	(do_free_typedef_hash, make_cleanup_free_typedef_hash)
	(do_free_global_table): Remove.
	(typedef_hash_table::typedef_hash_table): New constructor; renamed
	from copy_type_recursive.
	(create_global_typedef_table): Remove.
	(typedef_hash_table::find_global_typedef): Now a member of
	typedef_hash_table.
	(typedef_hash_table::find_typedef): Rename from
	find_typedef_in_hash; now a member.
	(whatis_exp): Update.
	* extension.h (struct ext_lang_type_printers): Add constructor and
	destructor.
	(start_ext_lang_type_printers, free_ext_lang_type_printers): Don't
	declare.
	* extension.c (ext_lang_type_printers::ext_lang_type_printers):
	Now a constructor; rename from start_ext_lang_type_printers.
	(ext_lang_type_printers): Now a destructor; rename from
	free_ext_lang_type_printers.
	* c-typeprint.c (find_typedef_for_canonicalize, c_print_type_1):
	Update.
	(c_type_print_base_struct_union): Update.  Remove cleanups.
2018-03-27 10:09:25 -06:00
Joel Brobecker e2882c8578 Update copyright year range in all GDB files
gdb/ChangeLog:

        Update copyright year range in all GDB files
2018-01-02 07:38:06 +04:00
Sergio Durigan Junior 7c1618381f Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.

The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality.  Here's an example:

  /* offset    |  size */  type = struct wer : public tuv {
			   public:
  /*   32      |    24 */    struct tyu {
  /*   32:31   |     4 */        int a1 : 1;
  /*   32:28   |     4 */        int a2 : 3;
  /*   32: 5   |     4 */        int a3 : 23;
  /*   35: 3   |     1 */        char a4 : 2;
  /* XXX  3-bit hole   */
  /* XXX  4-byte hole  */
  /*   40      |     8 */        int64_t a5;
  /*   48:27   |     4 */        int a6 : 5;
  /*   48:56   |     8 */        int64_t a7 : 3;

				 /* total size (bytes):   24 */
			     } a1;

			     /* total size (bytes):   56 */
			   }

A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy.  The code to handle bitfield offsets, however,
took some time to craft.  My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).

After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes.  Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt.  This should be implemented in a future
patch.

This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB.  In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:

  <https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>

This has been regression-tested on the BuildBot.  There's a new
testcase for it, along with an update to the documentation.  I also
thought it was worth mentioning this feature in the NEWS file.

gdb/ChangeLog:
2017-12-15  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	PR cli/16224
	* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
	* c-typeprint.c (OFFSET_SPC_LEN): New define.
	(c_type_print_varspec_prefix): New argument 'struct
	print_offset_data *'.
	(c_type_print_base_1): New function and prototype.
	(c_print_type_1): New function, with code from 'c_print_type'.
	(c_print_type): Use 'c_print_type_1'.
	(c_type_print_varspec_prefix): New argument 'struct
	print_offset_data *'.  Use it.  Call 'c_type_print_base_1'
	instead of 'c_print_type_base'.
	(print_spaces_filtered_with_print_options): New function.
	(output_access_specifier): Take new argument FLAGS.  Modify
	function to call 'print_spaces_filtered_with_print_options'.
	(c_print_type_vtable_offset_marker): New function.
	(c_print_type_union_field_offset): New function.
	(c_print_type_struct_field_offset): New function.
	(c_print_type_no_offsets): New function.
	(c_type_print_base_struct_union): New argument 'struct
	print_offset_data *'.  Print offsets and sizes for
	struct/union/class fields.
	* typeprint.c (const struct type_print_options
	type_print_raw_options): Initialize 'print_offsets'.
	(static struct type_print_options default_ptype_flags):
	Likewise.
	(struct print_offset_data print_offset_default_data): New
	variable.
	(whatis_exp): Handle '/o' option.
	(_initialize_typeprint): Add '/o' flag to ptype's help.
	* typeprint.h (struct print_offset_data): New struct.
	(struct type_print_options) <print_offsets>: New field.

gdb/testsuite/ChangeLog:
2017-12-15  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR cli/16224
	* gdb.base/ptype-offsets.cc: New file.
	* gdb.base/ptype-offsets.exp: New file.

gdb/doc/ChangeLog:
2017-12-15  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR cli/16224
	* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-12-15 15:07:42 -05:00
Sergio Durigan Junior a27ed7d613 Reorganize code to handle TYPE_CODE_{STRUCT,UNION} on 'c_type_print_base'
While doing the 'ptype /o' work, I noticed that 'c_type_print_base'
was very long, with a big amount of code just to handle the case of
TYPE_CODE_{STRUCT,UNION}.  This made working with the function a bit
difficult, specially because of the level of indentation.

This commit moves this part of the code to their own functions.  Now
we have a 'c_type_print_base_struct_union' with most of the code, and
also 'need_access_label_p', which is a subset of the code that was
also a good candidate for having its own function.

gdb/ChangeLog:
2017-12-15  Sergio Durigan Junior  <sergiodj@redhat.com>

	* c-typeprint.c (need_access_label_p): New function.
	(c_type_print_base_struct_union): New function.
	(c_type_print_base): Move code to handle
	TYPE_CODE_{STRUCT,UNION} to the functions mentioned above.
2017-12-15 15:06:26 -05:00
Keith Seitz 883fd55ab1 Record nested types
GDB currently does not track types defined in classes.  Consider:

class A
{
  public:

  class B
  {
    public:
      class C { };
  };
};

(gdb) ptype A
type = class A {
   <no data fields>
}

This patch changes this behavior so that GDB records these nested types
and displays them to the user when he has set the (new) "print type"
option "nested-type-limit."

Example:

(gdb) set print type nested-type-limit 1
(gdb) ptype A
type = class A {
    <no data fields>
    class A::B {
        <no data fields>
    };
}
(gdb) set print type nested-type-limit 2
type = class A {
    <no data fields>
    class A::B {
        <no data fields>
        class A::B::C {
            <no data fields>
        };
    };
}

By default, the code maintains the status quo, that is, it will not print
any nested type definitions at all.

Testing is carried out via cp_ptype_class which required quite a bit of
modification to permit recursive calling (for the nested types).  This
was most easily facilitated by turning the ptype command output into a
queue.  Upshot: the test suite now has stack and queue data structures that
may be used by test writers.

gdb/ChangeLog

	* NEWS (New commands): Mention set/show print type nested-type-limit.
	* c-typeprint.c (c_type_print_base): Print out nested types.
	* dwarf2read.c (struct typedef_field_list): Rename to ...
	(struct decl_field_list): ... this.  Change all uses.
	(struct field_info) <nested_types_list, nested_types_list_count>:
	New fields.
	(add_partial_symbol): Look for nested type definitions in C++, too.
	(dwarf2_add_typedef): Rename to ...
	(dwarf2_add_type_defn): ... this.
	(type_can_define_types): New function.
	Update assertion to use type_can_define_types.
	Permit NULL for a field's name.
	(process_structure_scope): Handle child DIEs of types that can
	define types.
	Copy the list of nested types into the type struct.
	* gdbtypes.h (struct typedef_field): Rename to ...
	(struct decl_field): ... this.  Change all uses.
	[is_protected, is_private]: New fields.
	(struct cplus_struct_type) <nested_types, nested_types_count>: New
	fields.
	(TYPE_NESTED_TYPES_ARRAY, TYPE_NESTED_TYPES_FIELD)
	(TYPE_NESTED_TYPES_FIELD_NAME, TYPE_NESTED_TYPES_FIELD_TYPE)
	(TYPE_NESTED_TYPES_COUNT, TYPE_NESTED_TYPES_FIELD_PROTECTED)
	(TYPE_NESTED_TYPES_FIELD_PRIVATE): New macros.
	* typeprint.c (type_print_raw_options, default_ptype_flags): Add
	default value for print_nested_type_limit.
	(print_nested_type_limit): New static variable.
	(set_print_type_nested_types, show_print_type_nested_types): New
	functions.
	(_initialize_typeprint): Register new commands for set/show
	`print-nested-type-limit'.
	* typeprint.h (struct type_print_options) [print_nested_type_limit]:
	New field.

gdb/testsuite/ChangeLog

	* gdb.cp/nested-types.cc: New file.
	* gdb.cp/nested-types.exp: New file.
	* lib/cp-support.exp: Load data-structures.exp library.
	(debug_cp_test_ptype_class): New global.
	(cp_ptype_class_verbose, next_line): New procedures.
	(cp_test_ptype_class): Add and document new parameter `recursive_qid'.
	Add and document new return value.
	Switch the list of lines to a queue.
	Add support for new `type' key for nested type definitions.
	Add debugging/troubleshooting messages.
	* lib/data-structures.exp: New file.

gdb/doc/ChangeLog

	* gdb.texinfo (Symbols): Document "set print type nested-type-limit"
	and "show print type nested-type-limit".
2017-12-07 15:01:30 -08:00
Tom Tromey 331b71e5ee Use unique_xmalloc_ptr in c_type_print_base
This changes c_type_print_base to use unique_xmalloc_ptr, removing a
cleanup.

gdb/ChangeLog
2017-11-04  Tom Tromey  <tom@tromey.com>

	* c-typeprint.c (c_type_print_base): Use gdb::unique_xmalloc_ptr.
2017-11-04 10:27:19 -06:00
Keith Seitz c191a6875b Record and output access specifiers for nested typedefs
We currently do not record access information for typedefs defined inside
classes.  Consider:

struct foo
{
   typedef int PUBLIC;
 private:
   typedef int PRIVATE;
   PRIVATE b;
};

(gdb) ptype foo
type = struct foo {
  private:
    PRIVATE b;

    typedef int PRIVATE;
    typedef int PUBLIC;
}

This patch fixes this:

(gdb) ptype foo
type = struct foo {
  private:
    PRIVATE b;

    typedef int PRIVATE;
  public:
    typedef int PUBLIC;
}

gdb/ChangeLog:

	* c-typeprint.c (enum access_specifier): Moved here from
	c_type_print_base.
	(output_access_specifier): New function.
	(c_type_print_base): Consider typedefs when assessing
	whether access labels are needed.
	Use output_access_specifier as needed.
	Output access specifier for typedefs, if needed.
	* dwarf2read.c (dwarf2_add_typedef): Record DW_AT_accessibility.
	* gdbtypes.h (struct typedef_field) <is_protected, is_private>: New
	fields.
	(TYPE_TYPEDEF_FIELD_PROTECTED, TYPE_TYPEDEF_FIELD_PRIVATE): New
	accessor macros.

gdb/testsuite/ChangeLog:

	* gdb.cp/classes.cc (class_with_typedefs, class_with_public_typedef)
	(class_with_protected_typedef, class_with_private_typedef)
	(struct_with_public_typedef, struct_with_protected_typedef)
	(struct_with_private_typedef): New classes/structs.
	* gdb.cp/classes.exp (test_ptype_class_objects): Add tests for
	typedefs and access specifiers.
2017-10-16 17:19:29 -07:00
Pedro Alves 7022349d5c Stop assuming no-debug-info functions return int
The fact that GDB defaults to assuming that functions return int, when
it has no debug info for the function has been a recurring source of
user confusion.  Recently this came up on the errno pretty printer
discussions.  Shortly after, it came up again on IRC, with someone
wondering why does getenv() in GDB return a negative int:

  (gdb) p getenv("PATH")
  $1 = -6185

This question (with s/getenv/random-other-C-runtime-function) is a FAQ
on IRC.

The reason for the above is:

 (gdb) p getenv
 $2 = {<text variable, no debug info>} 0x7ffff7751d80 <getenv>
 (gdb) ptype getenv
 type = int ()

... which means that GDB truncated the 64-bit pointer that is actually
returned from getent to 32-bit, and then sign-extended it:

 (gdb) p /x -6185
 $6 = 0xffffe7d7

The workaround is to cast the function to the right type, like:

 (gdb) p ((char *(*) (const char *)) getenv) ("PATH")
 $3 = 0x7fffffffe7d7 "/usr/local/bin:/"...

IMO, we should do better than this.

I see the "assume-int" issue the same way I see printing bogus values
for optimized-out variables instead of "<optimized out>" -- I'd much
rather that the debugger tells me "I don't know" and tells me how to
fix it than showing me bogus misleading results, making me go around
tilting at windmills.

If GDB prints a signed integer when you're expecting a pointer or
aggregate, you at least have some sense that something is off, but
consider the case of the function actually returning a 64-bit integer.
For example, compile this without debug info:

 unsigned long long
 function ()
 {
   return 0x7fffffffffffffff;
 }

Currently, with pristine GDB, you get:

 (gdb) p function ()
 $1 = -1                      # incorrect
 (gdb) p /x function ()
 $2 = 0xffffffff              # incorrect

maybe after spending a few hours debugging you suspect something is
wrong with that -1, and do:

 (gdb) ptype function
 type = int ()

and maybe, just maybe, you realize that the function actually returns
unsigned long long.  And you try to fix it with:

(gdb) p /x (unsigned long long) function ()
 $3 = 0xffffffffffffffff      # incorrect

... which still produces the wrong result, because GDB simply applied
int to unsigned long long conversion.  Meaning, it sign-extended the
integer that it extracted from the return of the function, to 64-bits.

and then maybe, after asking around on IRC, you realize you have to
cast the function to a pointer of the right type, and call that.  It
won't be easy, but after a few missteps, you'll get to it:

.....  (gdb) p /x ((unsigned long long(*) ()) function) ()
 $666 = 0x7fffffffffffffff             # finally! :-)


So to improve on the user experience, this patch does the following
(interrelated) things:

 - makes no-debug-info functions no longer default to "int" as return
   type.  Instead, they're left with NULL/"<unknown return type>"
   return type.

    (gdb) ptype getenv
    type = <unknown return type> ()

 - makes calling a function with unknown return type an error.

    (gdb) p getenv ("PATH")
    'getenv' has unknown return type; cast the call to its declared return type

 - and then to make it easier to call the function, makes it possible
   to _only_ cast the return of the function to the right type,
   instead of having to cast the function to a function pointer:

    (gdb) p (char *) getenv ("PATH")                      # now Just Works
    $3 = 0x7fffffffe7d7 "/usr/local/bin:/"...

    (gdb) p ((char *(*) (const char *)) getenv) ("PATH")  # continues working
    $4 = 0x7fffffffe7d7 "/usr/local/bin:/"...

   I.e., it makes GDB default the function's return type to the type
   of the cast, and the function's parameters to the type of the
   arguments passed down.

After this patch, here's what you'll get for the "unsigned long long"
example above:

 (gdb) p function ()
 'function' has unknown return type; cast the call to its declared return type
 (gdb) p /x (unsigned long long) function ()
 $4 = 0x7fffffffffffffff     # correct!

Note that while with "print" GDB shows the name of the function that
has the problem:

  (gdb) p getenv ("PATH")
  'getenv' has unknown return type; cast the call to its declared return type

which can by handy in more complicated expressions, "ptype" does not:

  (gdb) ptype getenv ("PATH")
  function has unknown return type; cast the call to its declared return type

This will be fixed in the next patch.

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_evaluate_subexp) <TYPE_CODE_FUNC>: Don't handle
	TYPE_GNU_IFUNC specially here.  Throw error if return type is
	unknown.
	* ada-typeprint.c (print_func_type): Handle functions with unknown
	return type.
	* c-typeprint.c (c_type_print_base): Handle functions and methods
	with unknown return type.
	* compile/compile-c-symbols.c (convert_symbol_bmsym)
	<mst_text_gnu_ifunc>: Use nodebug_text_gnu_ifunc_symbol.
	* compile/compile-c-types.c: Include "objfiles.h".
	(convert_func): For functions with unknown return type, warn and
	default to int.
	* compile/compile-object-run.c (compile_object_run): Adjust call
	to call_function_by_hand_dummy.
	* elfread.c (elf_gnu_ifunc_resolve_addr): Adjust call to
	call_function_by_hand.
	* eval.c (evaluate_subexp_standard): Adjust calls to
	call_function_by_hand.  Handle functions and methods with unknown
	return type.  Pass expect_type to call_function_by_hand.
	* f-typeprint.c (f_type_print_base): Handle functions with unknown
	return type.
	* gcore.c (call_target_sbrk): Adjust call to
	call_function_by_hand.
	* gdbtypes.c (objfile_type): Leave nodebug text symbol with NULL
	return type instead of int.  Make nodebug_text_gnu_ifunc_symbol be
	an integer address type instead of nodebug.
	* guile/scm-value.c (gdbscm_value_call): Adjust call to
	call_function_by_hand.
	* infcall.c (error_call_unknown_return_type): New function.
	(call_function_by_hand): New "default_return_type" parameter.
	Pass it down.
	(call_function_by_hand_dummy): New "default_return_type"
	parameter.  Use it instead of defaulting to int.  If there's no
	default and the return type is unknown, throw an error.  If
	there's a default return type, and the called function has no
	debug info, then assume the function is prototyped.
	* infcall.h (call_function_by_hand, call_function_by_hand_dummy):
	New "default_return_type" parameter.
	(error_call_unknown_return_type): New declaration.
	* linux-fork.c (call_lseek): Cast return type of lseek.
	(inferior_call_waitpid, checkpoint_command): Adjust calls to
	call_function_by_hand.
	* linux-tdep.c (linux_infcall_mmap, linux_infcall_munmap): Adjust
	calls to call_function_by_hand.
	* m2-typeprint.c (m2_procedure): Handle functions with unknown
	return type.
	* objc-lang.c (lookup_objc_class, lookup_child_selector)
	(value_nsstring, print_object_command): Adjust calls to
	call_function_by_hand.
	* p-typeprint.c (pascal_type_print_varspec_prefix): Handle
	functions with unknown return type.
	(pascal_type_print_func_varspec_suffix): New function.
	(pascal_type_print_varspec_suffix) <TYPE_CODE_FUNC,
	TYPE_CODE_METHOD>: Use it.
	* python/py-value.c (valpy_call): Adjust call to
	call_function_by_hand.
	* rust-lang.c (rust_evaluate_funcall): Adjust call to
	call_function_by_hand.
	* valarith.c (value_x_binop, value_x_unop): Adjust calls to
	call_function_by_hand.
	* valops.c (value_allocate_space_in_inferior): Adjust call to
	call_function_by_hand.
	* typeprint.c (type_print_unknown_return_type): New function.
	* typeprint.h (type_print_unknown_return_type): New declaration.

gdb/testsuite/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* gdb.base/break-main-file-remove-fail.exp (test_remove_bp): Cast
	return type of munmap in infcall.
	* gdb.base/break-probes.exp: Cast return type of foo in infcall.
	* gdb.base/checkpoint.exp: Simplify using for loop.  Cast return
	type of ftell in infcall.
	* gdb.base/dprintf-detach.exp (dprintf_detach_test): Cast return
	type of getpid in infcall.
	* gdb.base/infcall-exec.exp: Cast return type of execlp in
	infcall.
	* gdb.base/info-os.exp: Cast return type of getpid in infcall.
	Bail on failure to extract the pid.
	* gdb.base/nodebug.c: #include <stdint.h>.
	(multf, multf_noproto, mult, mult_noproto, add8, add8_noproto):
	New functions.
	* gdb.base/nodebug.exp (test_call_promotion): New procedure.
	Change expected output of print/whatis/ptype with functions with
	no debug info.  Test all supported languages.  Call
	test_call_promotion.
	* gdb.compile/compile.exp: Adjust expected output to expect
	warning.
	* gdb.threads/siginfo-threads.exp: Likewise.
2017-09-04 20:21:13 +01:00
Pedro Alves 8090b426b5 Introduce CP_OPERATOR_STR/CP_OPERATOR_LEN and use throughout
Move LENGTH_OF_OPERATOR from cp-support.c to cp-support.h so we can
use it elsewhere.  Since there's already
CP_ANONYMOUS_NAMESPACE_STR/CP_ANONYMOUS_NAMESPACE_LEN there, follow
the same naming pattern for the new symbols.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

	* c-exp.y (operator_stoken): Use CP_OPERATOR_LEN and
	CP_OPERATOR_STR.
	* c-typeprint.c (is_type_conversion_operator): Use
	CP_OPERATOR_STR.
	* cp-support.c (LENGTH_OF_OPERATOR): Delete.
	(cp_find_first_component_aux): Use CP_OPERATOR_STR and
	CP_OPERATOR_LEN.
	* cp-support.h (CP_OPERATOR_STR, CP_OPERATOR_LEN): New.
	* gnu-v2-abi.c (gnuv2_is_operator_name): Use CP_OPERATOR_STR.
	* gnu-v3-abi.c (gnuv3_is_operator_name): Use CP_OPERATOR_STR.
	* linespec.c (linespec_lexer_lex_string): Use CP_OPERATOR_LEN and
	CP_OPERATOR_STR.
	* location.c: Include "cp-support.h".
	(explicit_location_lex_one): Use CP_OPERATOR_LEN and
	CP_OPERATOR_STR.
	* symtab.c (operator_chars): Use CP_OPERATOR_STR and
	CP_OPERATOR_LEN.
2017-07-17 15:51:55 +01:00
Artemiy Volkov e1cb321347 Implement printing of rvalue reference types and values
This patch provides the ability to print out names of rvalue reference types
and values of those types. This is done in full similarity to regular
references, and as with them, we don't print out "const" suffix because all
rvalue references are const.

gdb/ChangeLog

	PR gdb/14441
	* c-typeprint.c (c_print_type, c_type_print_varspec_prefix)
	(c_type_print_modifier, c_type_print_varspec_suffix)
	(c_type_print_base): Support printing rvalue reference types.
	* c-valprint.c (c_val_print, c_value_print): Support printing
	rvalue reference values.
2017-03-20 13:47:48 -07:00
Keith Seitz 5f4d108508 c++/8218: Destructors w/arguments.
For a long time now, c++/8218 has noted that GDB is printing argument types
for destructors:

(gdb) ptype A
type = class A {
  public:
    ~A(int);
}

This happens because cp_type_print_method_args doesn't ignore artificial
arguments.  [It ignores the first `this' pointer because it simply skips
the first argument for any non-static function.]

This patch fixes this:

(gdb) ptype  A
type = class A {
  public:
    ~A();
}

I've adjusted gdb.cp/templates.exp to account for this and added a new
passing regexp.

gdb/ChangeLog

	PR c++/8218
	* c-typeprint.c (cp_type_print_method_args): Skip artificial arguments.

gdb/testsuite/ChangeLog

	PR c++/8128
	* gdb.cp/templates.exp (test_ptype_of_templates): Remove argument
	type from destructor regexps.
	Add a branch which actually passes the test.
	Adjust "ptype t5i" test names.
2017-03-10 10:32:09 -08:00
Joel Brobecker 61baf725ec update copyright year range in GDB files
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.

gdb/ChangeLog:

        Update copyright year range in all GDB files.
2017-01-01 10:52:34 +04:00
Pedro Alves 2f408ecb92 Use ui_file_as_string throughout more
This replaces most of the remaining ui_file_xstrdup calls with
ui_file_as_string calls.  Whenever a call was replaced, that led to a
cascade of other necessary adjustments throughout, to make the code
use std::string instead of raw pointers.  And then whenever I added a
std::string as member of a struct, I needed to adjust
allocation/destruction of said struct to use new/delete instead of
xmalloc/xfree.

The stopping point was once gdb built again.  These doesn't seem to be
a way to reasonably split this out further.

Maybe-not-obvious changes:

 - demangle_for_lookup returns a cleanup today.  To get rid of that,
   and avoid unnecessary string dupping/copying, this introduces a
   demangle_result_storage type that the caller instantiates and
   passes to demangle_for_lookup.

 - Many methods returned a "char *" to indicate that the caller owns
   the memory and must free it.  Those are switched to return a
   std::string instead.  Methods that return a "view" into some
   internal string return a "const char *" instead.  I.e., we only
   copy/allocate when necessary.

gdb/ChangeLog:
2016-11-08  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_name_for_lookup, type_as_string): Use and return
	std::string.
	(type_as_string_and_cleanup): Delete.
	(ada_lookup_struct_elt_type): Use type_as_string.
	* ada-lang.h (ada_name_for_lookup): Now returns std::string.
	* ada-varobj.c (ada_varobj_scalar_image): Return a std::string.
	(ada_varobj_describe_child): Make 'child_name' and
	'child_path_expr' parameters std::string pointers.
	(ada_varobj_describe_struct_child, ada_varobj_describe_ptr_child):
	Likewise, and use string_printf.
	(ada_varobj_describe_simple_array_child)
	(ada_varobj_describe_child): Likewise.
	(ada_varobj_get_name_of_child, ada_varobj_get_path_expr_of_child)
	(ada_varobj_get_value_image)
	(ada_varobj_get_value_of_array_variable)
	(ada_varobj_get_value_of_variable, ada_name_of_variable)
	(ada_name_of_child, ada_path_expr_of_child)
	(ada_value_of_variable): Now returns std::string.  Use
	string_printf.
	(ada_value_of_child): Adjust.
	* break-catch-throw.c (check_status_exception_catchpoint): Adjust
	to use std::string.
	* breakpoint.c (watch_command_1): Adjust to use std::string.
	* c-lang.c (c_get_string): Adjust to use std::string.
	* c-typeprint.c (print_name_maybe_canonical): Use std::string.
	* c-varobj.c (varobj_is_anonymous_child): Use ==/!= std::string
	operators.
	(c_name_of_variable): Now returns a std::string.
	(c_describe_child): The 'cname' and 'cfull_expression' output
	parameters are now std::string pointers.  Adjust.
	(c_name_of_child, c_path_expr_of_child, c_value_of_variable)
	(cplus_number_of_children): Adjust to use std::string and
	string_printf.
	(cplus_name_of_variable): Now returns a std::string.
	(cplus_describe_child): The 'cname' and 'cfull_expression' output
	parameters are now std::string pointers.  Adjust.
	(cplus_name_of_child, cplus_path_expr_of_child)
	(cplus_value_of_variable): Now returns a std::string.
	* cp-abi.c (cplus_typename_from_type_info): Return std::string.
	* cp-abi.h (cplus_typename_from_type_info): Return std::string.
	(struct cp_abi_ops) <get_typename_from_type_info>: Return
	std::string.
	* cp-support.c (inspect_type): Use std::string.
	(cp_canonicalize_string_full, cp_canonicalize_string_no_typedefs)
	(cp_canonicalize_string): Return std::string and adjust.
	* cp-support.h (cp_canonicalize_string)
	(cp_canonicalize_string_no_typedefs, cp_canonicalize_string_full):
	Return std::string.
	* dbxread.c (read_dbx_symtab): Use std::string.
	* dwarf2read.c (dwarf2_canonicalize_name): Adjust to use std::string.
	* gdbcmd.h (lookup_struct_elt_type): Adjust to use std::string.
	* gnu-v3-abi.c (gnuv3_get_typeid): Use std::string.
	(gnuv3_get_typename_from_type_info): Return a std::string and
	adjust.
	(gnuv3_get_type_from_type_info): Adjust to use std::string.
	* guile/guile.c (gdbscm_execute_gdb_command): Adjust to use
	std::string.
	* infcmd.c (print_return_value_1): Adjust to use std::string.
	* linespec.c (find_linespec_symbols): Adjust to
	demangle_for_lookup API change.  Use std::string.
	* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_set_format)
	(mi_cmd_var_info_type, mi_cmd_var_info_path_expression)
	(mi_cmd_var_info_expression, mi_cmd_var_evaluate_expression)
	(mi_cmd_var_assign, varobj_update_one): Adjust to use std::string.
	* minsyms.c (lookup_minimal_symbol): Use std::string.
	* python/py-varobj.c (py_varobj_iter_next): Use new instead of
	XNEW.  vitem->name is a std::string now, adjust.
	* rust-exp.y (convert_ast_to_type, convert_name): Adjust to use
	std::string.
	* stabsread.c (define_symbol): Adjust to use std::string.
	* symtab.c (demangle_for_lookup): Now returns 'const char *'.  Add
	a demangle_result_storage parameter.  Use it for storage.
	(lookup_symbol_in_language)
	(lookup_symbol_in_objfile_from_linkage_name): Adjust to new
	demangle_for_lookup API.
	* symtab.h (struct demangle_result_storage): New type.
	(demangle_for_lookup): Now returns 'const char *'.  Add a
	demangle_result_storage parameter.
	* typeprint.c (type_to_string): Return std::string and use
	ui_file_as_string.
	* value.h (type_to_string): Change return type to std::string.
	* varobj-iter.h (struct varobj_item) <name>: Now a std::string.
	(varobj_iter_delete): Use delete instead of xfree.
	* varobj.c (create_child): Return std::string instead of char * in
	output parameter.
	(name_of_variable, name_of_child, my_value_of_variable): Return
	std::string instead of char *.
	(varobj_create, varobj_get_handle): Constify 'objname' parameter.
	Adjust to std::string fields.
	(varobj_get_objname): Return a const char * instead of a char *.
	(varobj_get_expression): Return a std::string.
	(varobj_list_children): Adjust to use std::string.
	(varobj_get_type): Return a std::string.
	(varobj_get_path_expr): Return a const char * instead of a char *.
	Adjust to std::string fields.
	(varobj_get_formatted_value, varobj_get_value): Return a
	std::string.
	(varobj_set_value): Change type of 'expression' parameter to
	std::string.  Use std::string.
	(install_new_value): Use std::string.
	(delete_variable_1): Adjust to use std::string.
	(create_child): Change the 'name' parameter to a std::string
	reference.  Swap it into the new item's name.
	(create_child_with_value): Swap item's name into the new child's
	name.  Use string_printf.
	(new_variable): Use new instead of XNEW.
	(free_variable): Don't xfree fields that are now std::string.
	(name_of_variable, name_of_child): Now returns std::string.
	(value_of_root): Adjust to use std::string.
	(my_value_of_variable, varobj_value_get_print_value): Return
	and use std::string.
	(varobj_value_get_print_value): Adjust to use ui_file_as_string
	and std::string.
	* varobj.h (struct varobj) <name, path_expr, obj_name,
	print_value>: Now std::string's.
	<name_of_variable, name_of_child, path_expr_of_child,
	value_of_variable>: Return std::string.
	(varobj_create, varobj_get_handle): Constify 'objname' parameter.
	(varobj_get_objname): Return a const char * instead of a char *.
	(varobj_get_expression, varobj_get_type): Return a std::string.
	(varobj_get_path_expr): Return a const char * instead of a char *.
	(varobj_get_formatted_value, varobj_get_value): Return a
	std::string.
	(varobj_set_value): Constify 'expression' parameter.
	(varobj_value_get_print_value): Return a std::string.
2016-11-08 15:26:47 +00:00
Tom Tromey 9c37b5aed9 Remove Java support
This patch removes the Java support from gdb.  gcj has not seen much
development or use for years now, and was recently removed from GCC.
This patch changes gdb to follow; in the unlikely event that there are
still users using gcj, they can continue to use an older gdb to debug.
Or, they can debug in C++ mode.

Built and regtested on x86-64 Fedora 24.

2016-10-06  Tom Tromey  <tom@tromey.com>

	* MAINTAINERS: Remove Java test maintainer.
	* varobj.h (java_varobj_ops): Don't declare.
	* valprint.h (struct value_print_options)
	<pascal_static_field_print>: Update comment.
	* utils.c (producer_is_gcc): Remove java reference.
	* symtab.h (struct general_symbol_info): Remove java references.
	(SYMBOL_SEARCH_NAME): Likewise.
	* objfiles.c (allocate_objfile): Update comment.
	* linespec.c (find_linespec_symbols): Remove java references.
	* gnu-v3-abi.c (gnuv3_rtti_type, gnuv3_baseclass_offset): Remove
	java references.
	* gdbtypes.h (struct cplus_struct_type) <is_java>: Remove.
	(TYPE_CPLUS_REALLY_JAVA): Remove.
	* c-varobj.c (enum vsections): Update comment.
	* symtab.c (symbol_set_language, symbol_set_names)
	(symbol_natural_name, symbol_demangled_name)
	(demangle_for_lookup, symbol_matches_domain)
	(default_make_symbol_completion_list_break_on_1): Remove java
	references.
	(JAVA_PREFIX, JAVA_PREFIX_LEN): Remove.
	* psymtab.c (match_partial_symbol, psymtab_search_name)
	(lookup_partial_symbol): Remove java references.
	* dwarf2read.c (find_slot_in_mapped_hash): Remove java references.
	(add_partial_symbol, dwarf2_compute_name, dwarf2_physname)
	(dwarf2_add_member_fn, is_vtable_name, read_structure_type)
	(process_structure_scope, read_subroutine_type)
	(read_subrange_type, load_partial_dies)
	(new_symbol_full, determine_prefix, typename_concat)
	(dwarf2_name): Remove java references.
	(set_cu_language): Treat Java as C++.
	* c-typeprint.c (c_type_print_args): Remove java reference.
	* defs.h (enum language) <language_java>: Remove.
	* Makefile.in (SFILES, HFILES_NO_SRCDIR, COMMON_OBS, YYFILES)
	(YYOBJ, local-maintainer-clean): Don't mention java files.
	* jv-exp.y, jv-lang.c, jv-lang.h, jv-typeprint.c, jv-valprint.c,
	jv-varobj.c: Remove.

2016-10-06  Tom Tromey  <tom@tromey.com>

	* guile.texi (Types In Guile): Remove Java mentions.
	* python.texi (Types In Python): Remove Java mentions.
	* gdb.texinfo (Address Locations, Supported Languages)
	(Index Section Format): Remove Java mentions.

2016-10-06  Tom Tromey  <tom@tromey.com>

	* gdb.compile/compile.exp: Change java tests to rust.
	* gdb.base/setshow.exp: Change java tests to rust.
	* gdb.base/default.exp: Remove java from language list.
	* README (Examples): Update language example.
	* gdb.python/py-lookup-type.exp (test_lookup_type): Remove java
	test.
	* lib/gdb.exp (skip_java_tests): Remove.
	* lib/java.exp: Remove.
	* gdb.java: Remove.
2016-10-06 10:10:40 -06:00
David Taylor 6b8505468e Support structure offsets that are 512K or larger.
GDB computes structure byte offsets using a 32 bit integer.  And,
first it computes the offset in bits and then converts to bytes.  The
result is that any offset that if 512K bytes or larger overflows.
This patch changes GDB to use LONGEST for such calculations.

	PR gdb/17520 Structure offset wrong when 1/4 GB or greater.
	* c-lang.h: Change all parameters, variables, and struct or union
	members used as struct or union fie3ld offsets from int to
	LONGEST.
	* c-valprint.c: Likewise.
	* cp-abi.c: Likewise.
	* cp-abi.h: Likewise.
	* cp-valprint.c: Likewise.
	* d-valprint.c: Likewise.
	* dwarf2loc.c: Likewise.
	* eval.c: Likewise.
	* extension-priv.h: Likewise.
	* extension.c: Likewise.
	* extension.h: Likewise.
	* findvar.c: Likewise.
	* gdbtypes.h: Likewise.
	* gnu-v2-abi.c: Likewise.
	* gnu-v3-abi.c: Likewise.
	* go-valprint.c: Likewise.
	* guile/guile-internal.h: Likewise.
	* guile/scm-pretty-print.c: Likewise.
	* jv-valprint.c Likewise.
	* opencl-lang.c: Likewise.
	* p-lang.h: Likewise.
	* python/py-prettyprint.c: Likewise.
	* python/python-internal.h: Likewise.
	* spu-tdep.c: Likewise.
	* typeprint.c: Likewise.
	* valarith.c: Likewise.
	* valops.c: Likewise.
	* valprint.c: Likewise.
	* valprint.h: Likewise.
	* value.c: Likewise.
	* value.h: Likewise.
	* p-valprint.c: Likewise.
	* c-typeprint.c (c_type_print_base): When printing offset, use
	plongest, not %d.
	* gdbtypes.c (recursive_dump_type): Ditto.
2016-06-24 21:02:36 -04:00
Doug Evans 8151645076 Extend flags to support multibit and enum bitfields.
gdb/ChangeLog:

	Extend flags to support multibit and enum bitfields.
	NEWS: Document new features.
	* c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS.
	(c_type_print_varspec_suffix, c_type_print_base): Ditto.
	* gdbtypes.c (arch_flags_type): Don't assume all fields are one bit.
	(append_flags_type_field): New function.
	(append_flags_type_flag): Call it.
	* gdbtypes.h (append_flags_type_field): Declare.
	* target-descriptions.c (struct tdesc_type_flag): Delete.
	(enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value.
	(enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto.
	(struct tdesc_type) <u.f>: Delete.
	(tdesc_predefined_types): Add "bool".
	(tdesc_predefined_type): New function.
	(tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM.
	Update TDESC_TYPE_FLAGS support.
	(tdesc_free_type): Handle TDESC_TYPE_ENUM.  Update TDESC_TYPE_FLAGS.
	(tdesc_create_flags): Update.
	(tdesc_create_enum): New function.
	(tdesc_add_field): Initialize start,end to -1.
	(tdesc_add_typed_bitfield): New function.
	(tdesc_add_bitfield): Call it.
	(tdesc_add_flag): Allow TDESC_TYPE_STRUCT.  Update.
	(tdesc_add_enum_value): New function.
	(maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into
	TDESC_TYPE_STRUCT.  Handle TDESC_TYPE_ENUM.
	* target-descriptions.h (tdesc_create_enum): Declare.
	(tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare.
	* valprint.c (generic_val_print_enum_1): New function.
	(generic_val_print_enum): Call it.
	(val_print_type_code_flags): Make static.  Handle multibit bitfields
	and enum bitfields.
	* valprint.h (val_print_type_code_flags): Delete.
	* xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>:
	Delete.  All uses removed.
	(tdesc_start_enum): New function.
	(tdesc_start_field): Handle multibit and enum bitfields.
	(tdesc_start_enum_value): New function.
	(enum_value_attributes, enum_children, enum_attributes): New static
	globals.
	(feature_children): Add "enum".
	* features/gdb-target.dtd (enum, evalue): New elements.

gdb/doc/ChangeLog:

	* gdb.texinfo (Target Descriptions): New menu item "Enum Target Types".
	(Target Description Format): Mention enum types.  Update docs on
	flags types.
	(Predefined Target Types): Add "bool".
	(Enum Target Types): New node.

gdb/testsuite/ChangeLog:

	* gdb.xml/extra-regs.xml: Add enum, mixed_flags values.
	* gdb.xml/tdesc-regs.exp (load_description): New arg xml_file.
	All callers updated.  Add tests for enums, mixed flags register.
2016-03-15 14:37:29 -07:00
Mark Wielaard a579cd9aa8 Fix GCC6 -Wmisleading-indentation issues.
GCC6 will warn about misleading indentation issues like:

gdb/ada-lang.c: In function ‘ada_evaluate_subexp’:
ada-lang.c:11423:9: error: statement is indented as if it were guarded by...
         arg1 = unwrap_value (arg1);
         ^~~~

gdb/ada-lang.c:11421:7: note: ...this ‘else’ clause, but it is not
       else
       ^~~~

In this case it would be a bug except for the fact the if clause already
returned early. So this misindented statement really only got executed
for the else case. But it could easily mislead a reader, so adding a
proper else block is the correct solution.

In case of c-typeprint.c (c_type_print_base) the if statement is indeed
misleadingly indented, but not a bug. Just indent correctly. The inflow.c
(terminal_ours_1) misindented block comes from the removal of an if clause
in commit d9d2d8b which looks correct. Just introduce an else to fixup the
indentation of the block. The linux-record.c misleadingly indented return
statements are just that. Misleading to the reader, but not actual bugs.
Just unindent them so they don't look like they fall under the wrong if
clause.
2016-01-26 00:04:55 +01:00
Joel Brobecker 618f726fcb GDB copyright headers update after running GDB's copyright.py script.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2016-01-01 08:43:22 +04:00
Simon Marchi 9a3c826307 Add some more casts (1/2)
Note: I needed to split this patch in two, otherwise it's too big for
the mailing list.

This patch adds explicit casts to situations where a void pointer is
assigned to a pointer to the "real" type.  Building in C++ mode requires
those assignments to use an explicit cast.  This includes, for example:

 - callback arguments (cleanups, comparison functions, ...)
 - data attached to some object (objfile, program space, etc) in the form
   of a void pointer
 - "user data" passed to some function

This patch comes from the commit "(mostly) auto-generated patch to insert
casts needed for C++", taken from Pedro's C++ branch.

Only files built on x86 with --enable-targets=all are modified, so the
native files for other arches will need to be dealt with separately.

I built-tested this with --enable-targets=all and reg-tested.  To my
surprise, a test case (selftest.exp) had to be adjusted.

Here's the ChangeLog entry.  Again, this was relatively quick to make
despite the length, thanks to David Malcom's script, although I don't
believe it's very useful information in that particular case...

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_make_prologue_cache): Add cast(s).
	(aarch64_make_stub_cache): Likewise.
	(value_of_aarch64_user_reg): Likewise.
	* ada-lang.c (ada_inferior_data_cleanup): Likewise.
	(get_ada_inferior_data): Likewise.
	(get_ada_pspace_data): Likewise.
	(ada_pspace_data_cleanup): Likewise.
	(ada_complete_symbol_matcher): Likewise.
	(ada_exc_search_name_matches): Likewise.
	* ada-tasks.c (get_ada_tasks_pspace_data): Likewise.
	(get_ada_tasks_inferior_data): Likewise.
	* addrmap.c (addrmap_mutable_foreach_worker): Likewise.
	(splay_obstack_alloc): Likewise.
	(splay_obstack_free): Likewise.
	* alpha-linux-tdep.c (alpha_linux_supply_gregset): Likewise.
	(alpha_linux_collect_gregset): Likewise.
	(alpha_linux_supply_fpregset): Likewise.
	(alpha_linux_collect_fpregset): Likewise.
	* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Likewise.
	* alpha-tdep.c (alpha_lds): Likewise.
	(alpha_sts): Likewise.
	(alpha_sigtramp_frame_unwind_cache): Likewise.
	(alpha_heuristic_frame_unwind_cache): Likewise.
	(alpha_supply_int_regs): Likewise.
	(alpha_fill_int_regs): Likewise.
	(alpha_supply_fp_regs): Likewise.
	(alpha_fill_fp_regs): Likewise.
	* alphanbsd-tdep.c (alphanbsd_supply_fpregset): Likewise.
	(alphanbsd_aout_supply_gregset): Likewise.
	(alphanbsd_supply_gregset): Likewise.
	* amd64-linux-tdep.c (amd64_linux_init_abi): Likewise.
	(amd64_x32_linux_init_abi): Likewise.
	* amd64-nat.c (amd64_supply_native_gregset): Likewise.
	(amd64_collect_native_gregset): Likewise.
	* amd64-tdep.c (amd64_frame_cache): Likewise.
	(amd64_sigtramp_frame_cache): Likewise.
	(amd64_epilogue_frame_cache): Likewise.
	(amd64_supply_fxsave): Likewise.
	(amd64_supply_xsave): Likewise.
	(amd64_collect_fxsave): Likewise.
	(amd64_collect_xsave): Likewise.
	* amd64-windows-tdep.c (amd64_windows_frame_cache): Likewise.
	* amd64obsd-tdep.c (amd64obsd_trapframe_cache): Likewise.
	* arm-linux-tdep.c (arm_linux_supply_gregset): Likewise.
	(arm_linux_collect_gregset): Likewise.
	(arm_linux_supply_nwfpe): Likewise.
	(arm_linux_collect_nwfpe): Likewise.
	(arm_linux_supply_vfp): Likewise.
	(arm_linux_collect_vfp): Likewise.
	* arm-tdep.c (arm_find_mapping_symbol): Likewise.
	(arm_prologue_unwind_stop_reason): Likewise.
	(arm_prologue_this_id): Likewise.
	(arm_prologue_prev_register): Likewise.
	(arm_exidx_data_free): Likewise.
	(arm_find_exidx_entry): Likewise.
	(arm_stub_this_id): Likewise.
	(arm_m_exception_this_id): Likewise.
	(arm_m_exception_prev_register): Likewise.
	(arm_normal_frame_base): Likewise.
	(gdb_print_insn_arm): Likewise.
	(arm_objfile_data_free): Likewise.
	(arm_record_special_symbol): Likewise.
	(value_of_arm_user_reg): Likewise.
	* armbsd-tdep.c (armbsd_supply_fpregset): Likewise.
	(armbsd_supply_gregset): Likewise.
	* auto-load.c (auto_load_pspace_data_cleanup): Likewise.
	(get_auto_load_pspace_data): Likewise.
	(hash_loaded_script_entry): Likewise.
	(eq_loaded_script_entry): Likewise.
	(clear_section_scripts): Likewise.
	(collect_matching_scripts): Likewise.
	* auxv.c (auxv_inferior_data_cleanup): Likewise.
	(get_auxv_inferior_data): Likewise.
	* avr-tdep.c (avr_frame_unwind_cache): Likewise.
	* ax-general.c (do_free_agent_expr_cleanup): Likewise.
	* bfd-target.c (target_bfd_xfer_partial): Likewise.
	(target_bfd_xclose): Likewise.
	(target_bfd_get_section_table): Likewise.
	* bfin-tdep.c (bfin_frame_cache): Likewise.
	* block.c (find_block_in_blockvector): Likewise.
	(call_site_for_pc): Likewise.
	(block_find_non_opaque_type_preferred): Likewise.
	* break-catch-sig.c (signal_catchpoint_insert_location): Likewise.
	(signal_catchpoint_remove_location): Likewise.
	(signal_catchpoint_breakpoint_hit): Likewise.
	(signal_catchpoint_print_one): Likewise.
	(signal_catchpoint_print_mention): Likewise.
	(signal_catchpoint_print_recreate): Likewise.
	* break-catch-syscall.c (get_catch_syscall_inferior_data): Likewise.
	* breakpoint.c (do_cleanup_counted_command_line): Likewise.
	(bp_location_compare_addrs): Likewise.
	(get_first_locp_gte_addr): Likewise.
	(check_tracepoint_command): Likewise.
	(do_map_commands_command): Likewise.
	(get_breakpoint_objfile_data): Likewise.
	(free_breakpoint_probes): Likewise.
	(do_captured_breakpoint_query): Likewise.
	(compare_breakpoints): Likewise.
	(bp_location_compare): Likewise.
	(bpstat_remove_breakpoint_callback): Likewise.
	(do_delete_breakpoint_cleanup): Likewise.
	* bsd-uthread.c (bsd_uthread_set_supply_uthread): Likewise.
	(bsd_uthread_set_collect_uthread): Likewise.
	(bsd_uthread_activate): Likewise.
	(bsd_uthread_fetch_registers): Likewise.
	(bsd_uthread_store_registers): Likewise.
	* btrace.c (check_xml_btrace_version): Likewise.
	(parse_xml_btrace_block): Likewise.
	(parse_xml_btrace_pt_config_cpu): Likewise.
	(parse_xml_btrace_pt_raw): Likewise.
	(parse_xml_btrace_pt): Likewise.
	(parse_xml_btrace_conf_bts): Likewise.
	(parse_xml_btrace_conf_pt): Likewise.
	(do_btrace_data_cleanup): Likewise.
	* c-typeprint.c (find_typedef_for_canonicalize): Likewise.
	* charset.c (cleanup_iconv): Likewise.
	(do_cleanup_iterator): Likewise.
	* cli-out.c (cli_uiout_dtor): Likewise.
	(cli_table_begin): Likewise.
	(cli_table_body): Likewise.
	(cli_table_end): Likewise.
	(cli_table_header): Likewise.
	(cli_begin): Likewise.
	(cli_end): Likewise.
	(cli_field_int): Likewise.
	(cli_field_skip): Likewise.
	(cli_field_string): Likewise.
	(cli_field_fmt): Likewise.
	(cli_spaces): Likewise.
	(cli_text): Likewise.
	(cli_message): Likewise.
	(cli_wrap_hint): Likewise.
	(cli_flush): Likewise.
	(cli_redirect): Likewise.
	(out_field_fmt): Likewise.
	(field_separator): Likewise.
	(cli_out_set_stream): Likewise.
	* cli/cli-cmds.c (compare_symtabs): Likewise.
	* cli/cli-dump.c (call_dump_func): Likewise.
	(restore_section_callback): Likewise.
	* cli/cli-script.c (clear_hook_in_cleanup): Likewise.
	(do_restore_user_call_depth): Likewise.
	(do_free_command_lines_cleanup): Likewise.
	* coff-pe-read.c (get_section_vmas): Likewise.
	(pe_as16): Likewise.
	(pe_as32): Likewise.
	* coffread.c (coff_symfile_read): Likewise.
	* common/agent.c (agent_look_up_symbols): Likewise.
	* common/filestuff.c (do_close_cleanup): Likewise.
	* common/format.c (free_format_pieces_cleanup): Likewise.
	* common/vec.c (vec_o_reserve): Likewise.
	* compile/compile-c-support.c (print_one_macro): Likewise.
	* compile/compile-c-symbols.c (hash_symbol_error): Likewise.
	(eq_symbol_error): Likewise.
	(del_symbol_error): Likewise.
	(error_symbol_once): Likewise.
	(gcc_convert_symbol): Likewise.
	(gcc_symbol_address): Likewise.
	(hash_symname): Likewise.
	(eq_symname): Likewise.
	* compile/compile-c-types.c (hash_type_map_instance): Likewise.
	(eq_type_map_instance): Likewise.
	(insert_type): Likewise.
	(convert_type): Likewise.
	* compile/compile-object-load.c (munmap_listp_free_cleanup): Likewise.
	(setup_sections): Likewise.
	(link_hash_table_free): Likewise.
	(copy_sections): Likewise.
	* compile/compile-object-run.c (do_module_cleanup): Likewise.
	* compile/compile.c (compile_print_value): Likewise.
	(do_rmdir): Likewise.
	(cleanup_compile_instance): Likewise.
	(cleanup_unlink_file): Likewise.
	* completer.c (free_completion_tracker): Likewise.
	* corelow.c (add_to_spuid_list): Likewise.
	* cp-namespace.c (reset_directive_searched): Likewise.
	* cp-support.c (reset_directive_searched): Likewise.
	* cris-tdep.c (cris_sigtramp_frame_unwind_cache): Likewise.
	(cris_frame_unwind_cache): Likewise.
	* d-lang.c (builtin_d_type): Likewise.
	* d-namespace.c (reset_directive_searched): Likewise.
	* dbxread.c (dbx_free_symfile_info): Likewise.
	(do_free_bincl_list_cleanup): Likewise.
	* disasm.c (hash_dis_line_entry): Likewise.
	(eq_dis_line_entry): Likewise.
	(dis_asm_print_address): Likewise.
	(fprintf_disasm): Likewise.
	(do_ui_file_delete): Likewise.
	* doublest.c (convert_floatformat_to_doublest): Likewise.
	* dummy-frame.c (pop_dummy_frame_bpt): Likewise.
	(dummy_frame_prev_register): Likewise.
	(dummy_frame_this_id): Likewise.
	* dwarf2-frame-tailcall.c (cache_hash): Likewise.
	(cache_eq): Likewise.
	(cache_find): Likewise.
	(tailcall_frame_this_id): Likewise.
	(dwarf2_tailcall_prev_register_first): Likewise.
	(tailcall_frame_prev_register): Likewise.
	(tailcall_frame_dealloc_cache): Likewise.
	(tailcall_frame_prev_arch): Likewise.
	* dwarf2-frame.c (dwarf2_frame_state_free): Likewise.
	(dwarf2_frame_set_init_reg): Likewise.
	(dwarf2_frame_init_reg): Likewise.
	(dwarf2_frame_set_signal_frame_p): Likewise.
	(dwarf2_frame_signal_frame_p): Likewise.
	(dwarf2_frame_set_adjust_regnum): Likewise.
	(dwarf2_frame_adjust_regnum): Likewise.
	(clear_pointer_cleanup): Likewise.
	(dwarf2_frame_cache): Likewise.
	(find_cie): Likewise.
	(dwarf2_frame_find_fde): Likewise.
	* dwarf2expr.c (dwarf_expr_address_type): Likewise.
	(free_dwarf_expr_context_cleanup): Likewise.
	* dwarf2loc.c (locexpr_find_frame_base_location): Likewise.
	(locexpr_get_frame_base): Likewise.
	(loclist_find_frame_base_location): Likewise.
	(loclist_get_frame_base): Likewise.
	(dwarf_expr_dwarf_call): Likewise.
	(dwarf_expr_get_base_type): Likewise.
	(dwarf_expr_push_dwarf_reg_entry_value): Likewise.
	(dwarf_expr_get_obj_addr): Likewise.
	(entry_data_value_coerce_ref): Likewise.
	(entry_data_value_copy_closure): Likewise.
	(entry_data_value_free_closure): Likewise.
	(get_frame_address_in_block_wrapper): Likewise.
	(dwarf2_evaluate_property): Likewise.
	(dwarf2_compile_property_to_c): Likewise.
	(needs_frame_read_addr_from_reg): Likewise.
	(needs_frame_get_reg_value): Likewise.
	(needs_frame_frame_base): Likewise.
	(needs_frame_frame_cfa): Likewise.
	(needs_frame_tls_address): Likewise.
	(needs_frame_dwarf_call): Likewise.
	(needs_dwarf_reg_entry_value): Likewise.
	(get_ax_pc): Likewise.
	(locexpr_read_variable): Likewise.
	(locexpr_read_variable_at_entry): Likewise.
	(locexpr_read_needs_frame): Likewise.
	(locexpr_describe_location): Likewise.
	(locexpr_tracepoint_var_ref): Likewise.
	(locexpr_generate_c_location): Likewise.
	(loclist_read_variable): Likewise.
	(loclist_read_variable_at_entry): Likewise.
	(loclist_describe_location): Likewise.
	(loclist_tracepoint_var_ref): Likewise.
	(loclist_generate_c_location): Likewise.
	* dwarf2read.c (line_header_hash_voidp): Likewise.
	(line_header_eq_voidp): Likewise.
	(dwarf2_has_info): Likewise.
	(dwarf2_get_section_info): Likewise.
	(locate_dwz_sections): Likewise.
	(hash_file_name_entry): Likewise.
	(eq_file_name_entry): Likewise.
	(delete_file_name_entry): Likewise.
	(dw2_setup): Likewise.
	(dw2_get_file_names_reader): Likewise.
	(dw2_find_pc_sect_compunit_symtab): Likewise.
	(hash_signatured_type): Likewise.
	(eq_signatured_type): Likewise.
	(add_signatured_type_cu_to_table): Likewise.
	(create_debug_types_hash_table): Likewise.
	(lookup_dwo_signatured_type): Likewise.
	(lookup_dwp_signatured_type): Likewise.
	(lookup_signatured_type): Likewise.
	(hash_type_unit_group): Likewise.
	(eq_type_unit_group): Likewise.
	(get_type_unit_group): Likewise.
	(process_psymtab_comp_unit_reader): Likewise.
	(sort_tu_by_abbrev_offset): Likewise.
	(process_skeletonless_type_unit): Likewise.
	(psymtabs_addrmap_cleanup): Likewise.
	(dwarf2_read_symtab): Likewise.
	(psymtab_to_symtab_1): Likewise.
	(die_hash): Likewise.
	(die_eq): Likewise.
	(load_full_comp_unit_reader): Likewise.
	(reset_die_in_process): Likewise.
	(free_cu_line_header): Likewise.
	(handle_DW_AT_stmt_list): Likewise.
	(hash_dwo_file): Likewise.
	(eq_dwo_file): Likewise.
	(hash_dwo_unit): Likewise.
	(eq_dwo_unit): Likewise.
	(create_dwo_cu_reader): Likewise.
	(create_dwo_unit_in_dwp_v1): Likewise.
	(create_dwo_unit_in_dwp_v2): Likewise.
	(lookup_dwo_unit_in_dwp): Likewise.
	(dwarf2_locate_dwo_sections): Likewise.
	(dwarf2_locate_common_dwp_sections): Likewise.
	(dwarf2_locate_v2_dwp_sections): Likewise.
	(hash_dwp_loaded_cutus): Likewise.
	(eq_dwp_loaded_cutus): Likewise.
	(lookup_dwo_cutu): Likewise.
	(abbrev_table_free_cleanup): Likewise.
	(dwarf2_free_abbrev_table): Likewise.
	(find_partial_die_in_comp_unit): Likewise.
	(free_line_header_voidp): Likewise.
	(follow_die_offset): Likewise.
	(follow_die_sig_1): Likewise.
	(free_heap_comp_unit): Likewise.
	(free_stack_comp_unit): Likewise.
	(dwarf2_free_objfile): Likewise.
	(per_cu_offset_and_type_hash): Likewise.
	(per_cu_offset_and_type_eq): Likewise.
	(get_die_type_at_offset): Likewise.
	(partial_die_hash): Likewise.
	(partial_die_eq): Likewise.
	(dwarf2_per_objfile_free): Likewise.
	(hash_strtab_entry): Likewise.
	(eq_strtab_entry): Likewise.
	(add_string): Likewise.
	(hash_symtab_entry): Likewise.
	(eq_symtab_entry): Likewise.
	(delete_symtab_entry): Likewise.
	(cleanup_mapped_symtab): Likewise.
	(add_indices_to_cpool): Likewise.
	(hash_psymtab_cu_index): Likewise.
	(eq_psymtab_cu_index): Likewise.
	(add_address_entry_worker): Likewise.
	(unlink_if_set): Likewise.
	(write_one_signatured_type): Likewise.
	(save_gdb_index_command): Likewise.
	* elfread.c (elf_symtab_read): Likewise.
	(elf_gnu_ifunc_cache_hash): Likewise.
	(elf_gnu_ifunc_cache_eq): Likewise.
	(elf_gnu_ifunc_record_cache): Likewise.
	(elf_gnu_ifunc_resolve_by_cache): Likewise.
	(elf_get_probes): Likewise.
	(probe_key_free): Likewise.
	* f-lang.c (builtin_f_type): Likewise.
	* frame-base.c (frame_base_append_sniffer): Likewise.
	(frame_base_set_default): Likewise.
	(frame_base_find_by_frame): Likewise.
	* frame-unwind.c (frame_unwind_prepend_unwinder): Likewise.
	(frame_unwind_append_unwinder): Likewise.
	(frame_unwind_find_by_frame): Likewise.
	* frame.c (frame_addr_hash): Likewise.
	(frame_addr_hash_eq): Likewise.
	(frame_stash_find): Likewise.
	(do_frame_register_read): Likewise.
	(unwind_to_current_frame): Likewise.
	(frame_cleanup_after_sniffer): Likewise.
	* frv-linux-tdep.c (frv_linux_sigtramp_frame_cache): Likewise.
	* frv-tdep.c (frv_frame_unwind_cache): Likewise.
	* ft32-tdep.c (ft32_frame_cache): Likewise.
	* gcore.c (do_bfd_delete_cleanup): Likewise.
	(gcore_create_callback): Likewise.
	* gdb_bfd.c (hash_bfd): Likewise.
	(eq_bfd): Likewise.
	(gdb_bfd_open): Likewise.
	(free_one_bfd_section): Likewise.
	(gdb_bfd_ref): Likewise.
	(gdb_bfd_unref): Likewise.
	(get_section_descriptor): Likewise.
	(gdb_bfd_map_section): Likewise.
	(gdb_bfd_crc): Likewise.
	(gdb_bfd_mark_parent): Likewise.
	(gdb_bfd_record_inclusion): Likewise.
	(gdb_bfd_requires_relocations): Likewise.
	(print_one_bfd): Likewise.
	* gdbtypes.c (type_pair_hash): Likewise.
	(type_pair_eq): Likewise.
	(builtin_type): Likewise.
	(objfile_type): Likewise.
	* gnu-v3-abi.c (vtable_ptrdiff_type): Likewise.
	(vtable_address_point_offset): Likewise.
	(gnuv3_get_vtable): Likewise.
	(hash_value_and_voffset): Likewise.
	(eq_value_and_voffset): Likewise.
	(compare_value_and_voffset): Likewise.
	(compute_vtable_size): Likewise.
	(gnuv3_get_typeid_type): Likewise.
	* go-lang.c (builtin_go_type): Likewise.
	* guile/scm-block.c (bkscm_hash_block_smob): Likewise.
	(bkscm_eq_block_smob): Likewise.
	(bkscm_objfile_block_map): Likewise.
	(bkscm_del_objfile_blocks): Likewise.
	* guile/scm-breakpoint.c (bpscm_build_bp_list): Likewise.
	* guile/scm-disasm.c (gdbscm_disasm_read_memory_worker): Likewise.
	(gdbscm_disasm_print_address): Likewise.
	* guile/scm-frame.c (frscm_hash_frame_smob): Likewise.
	(frscm_eq_frame_smob): Likewise.
	(frscm_inferior_frame_map): Likewise.
	(frscm_del_inferior_frames): Likewise.
	* guile/scm-gsmob.c (gdbscm_add_objfile_ref): Likewise.
	* guile/scm-objfile.c (ofscm_handle_objfile_deleted): Likewise.
	(ofscm_objfile_smob_from_objfile): Likewise.
	* guile/scm-ports.c (ioscm_write): Likewise.
	(ioscm_file_port_delete): Likewise.
	(ioscm_file_port_rewind): Likewise.
	(ioscm_file_port_put): Likewise.
	(ioscm_file_port_write): Likewise.
	* guile/scm-progspace.c (psscm_handle_pspace_deleted): Likewise.
	(psscm_pspace_smob_from_pspace): Likewise.
	* guile/scm-safe-call.c (scscm_recording_pre_unwind_handler): Likewise.
	(scscm_recording_unwind_handler): Likewise.
	(gdbscm_with_catch): Likewise.
	(scscm_call_0_body): Likewise.
	(scscm_call_1_body): Likewise.
	(scscm_call_2_body): Likewise.
	(scscm_call_3_body): Likewise.
	(scscm_call_4_body): Likewise.
	(scscm_apply_1_body): Likewise.
	(scscm_eval_scheme_string): Likewise.
	(gdbscm_safe_eval_string): Likewise.
	(scscm_source_scheme_script): Likewise.
	(gdbscm_safe_source_script): Likewise.
	* guile/scm-string.c (gdbscm_call_scm_to_stringn): Likewise.
	(gdbscm_call_scm_from_stringn): Likewise.
	* guile/scm-symbol.c (syscm_hash_symbol_smob): Likewise.
	(syscm_eq_symbol_smob): Likewise.
	(syscm_get_symbol_map): Likewise.
	(syscm_del_objfile_symbols): Likewise.
	* guile/scm-symtab.c (stscm_hash_symtab_smob): Likewise.
	(stscm_eq_symtab_smob): Likewise.
	(stscm_objfile_symtab_map): Likewise.
	(stscm_del_objfile_symtabs): Likewise.
	* guile/scm-type.c (tyscm_hash_type_smob): Likewise.
	(tyscm_eq_type_smob): Likewise.
	(tyscm_type_map): Likewise.
	(tyscm_copy_type_recursive): Likewise.
	(save_objfile_types): Likewise.
	* guile/scm-utils.c (extract_arg): Likewise.
	* h8300-tdep.c (h8300_frame_cache): Likewise.
	* hppa-linux-tdep.c (hppa_linux_sigtramp_frame_unwind_cache): Likewise.
	* hppa-tdep.c (compare_unwind_entries): Likewise.
	(find_unwind_entry): Likewise.
	(hppa_frame_cache): Likewise.
	(hppa_stub_frame_unwind_cache): Likewise.
	* hppanbsd-tdep.c (hppanbsd_supply_gregset): Likewise.
	* hppaobsd-tdep.c (hppaobsd_supply_gregset): Likewise.
	(hppaobsd_supply_fpregset): Likewise.
	* i386-cygwin-tdep.c (core_process_module_section): Likewise.
	* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
	* i386-tdep.c (i386_frame_cache): Likewise.
	(i386_epilogue_frame_cache): Likewise.
	(i386_sigtramp_frame_cache): Likewise.
	(i386_supply_gregset): Likewise.
	(i386_collect_gregset): Likewise.
	(i386_gdbarch_init): Likewise.
	* i386obsd-tdep.c (i386obsd_aout_supply_regset): Likewise.
	(i386obsd_trapframe_cache): Likewise.
	* i387-tdep.c (i387_supply_fsave): Likewise.
	(i387_collect_fsave): Likewise.
	(i387_supply_fxsave): Likewise.
	(i387_collect_fxsave): Likewise.
	(i387_supply_xsave): Likewise.
	(i387_collect_xsave): Likewise.
	* ia64-tdep.c (ia64_frame_cache): Likewise.
	(ia64_sigtramp_frame_cache): Likewise.
	* infcmd.c (attach_command_continuation): Likewise.
	(attach_command_continuation_free_args): Likewise.
	* inferior.c (restore_inferior): Likewise.
	(delete_thread_of_inferior): Likewise.
	* inflow.c (inflow_inferior_data_cleanup): Likewise.
	(get_inflow_inferior_data): Likewise.
	(inflow_inferior_exit): Likewise.
	* infrun.c (displaced_step_clear_cleanup): Likewise.
	(restore_current_uiout_cleanup): Likewise.
	(release_stop_context_cleanup): Likewise.
	(do_restore_infcall_suspend_state_cleanup): Likewise.
	(do_restore_infcall_control_state_cleanup): Likewise.
	(restore_inferior_ptid): Likewise.
	* inline-frame.c (block_starting_point_at): Likewise.
	* iq2000-tdep.c (iq2000_frame_cache): Likewise.
	* jit.c (get_jit_objfile_data): Likewise.
	(get_jit_program_space_data): Likewise.
	(jit_object_close_impl): Likewise.
	(jit_find_objf_with_entry_addr): Likewise.
	(jit_breakpoint_deleted): Likewise.
	(jit_unwind_reg_set_impl): Likewise.
	(jit_unwind_reg_get_impl): Likewise.
	(jit_dealloc_cache): Likewise.
	(jit_frame_sniffer): Likewise.
	(jit_frame_prev_register): Likewise.
	(jit_prepend_unwinder): Likewise.
	(jit_inferior_exit_hook): Likewise.
	(free_objfile_data): Likewise.
	* jv-lang.c (jv_per_objfile_free): Likewise.
	(get_dynamics_objfile): Likewise.
	(get_java_class_symtab): Likewise.
	(builtin_java_type): Likewise.
	* language.c (language_string_char_type): Likewise.
	(language_bool_type): Likewise.
	(language_lookup_primitive_type): Likewise.
	(language_lookup_primitive_type_as_symbol): Likewise.
	* linespec.c (hash_address_entry): Likewise.
	(eq_address_entry): Likewise.
	(iterate_inline_only): Likewise.
	(iterate_name_matcher): Likewise.
	(decode_line_2_compare_items): Likewise.
	(collect_one_symbol): Likewise.
	(compare_symbols): Likewise.
	(compare_msymbols): Likewise.
	(add_symtabs_to_list): Likewise.
	(collect_symbols): Likewise.
	(compare_msyms): Likewise.
	(add_minsym): Likewise.
	(cleanup_linespec_result): Likewise.
	* linux-fork.c (inferior_call_waitpid_cleanup): Likewise.
	* linux-nat.c (delete_lwp_cleanup): Likewise.
	(count_events_callback): Likewise.
	(select_event_lwp_callback): Likewise.
	(resume_stopped_resumed_lwps): Likewise.
	* linux-tdep.c (get_linux_gdbarch_data): Likewise.
	(invalidate_linux_cache_inf): Likewise.
	(get_linux_inferior_data): Likewise.
	(linux_find_memory_regions_thunk): Likewise.
	(linux_make_mappings_callback): Likewise.
	(linux_corefile_thread_callback): Likewise.
	(find_mapping_size): Likewise.
	* linux-thread-db.c (find_new_threads_callback): Likewise.
	* lm32-tdep.c (lm32_frame_cache): Likewise.
	* m2-lang.c (builtin_m2_type): Likewise.
	* m32c-tdep.c (m32c_analyze_frame_prologue): Likewise.
	* m32r-linux-tdep.c (m32r_linux_sigtramp_frame_cache): Likewise.
	(m32r_linux_supply_gregset): Likewise.
	(m32r_linux_collect_gregset): Likewise.
	* m32r-tdep.c (m32r_frame_unwind_cache): Likewise.
	* m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
	* m68k-tdep.c (m68k_frame_cache): Likewise.
	* m68kbsd-tdep.c (m68kbsd_supply_fpregset): Likewise.
	(m68kbsd_supply_gregset): Likewise.
	* m68klinux-tdep.c (m68k_linux_sigtramp_frame_cache): Likewise.
	* m88k-tdep.c (m88k_frame_cache): Likewise.
	(m88k_supply_gregset): Likewise.

gdb/gdbserver/ChangeLog:

	* dll.c (match_dll): Add cast(s).
	(unloaded_dll): Likewise.
	* linux-low.c (second_thread_of_pid_p): Likewise.
	(delete_lwp_callback): Likewise.
	(count_events_callback): Likewise.
	(select_event_lwp_callback): Likewise.
	(linux_set_resume_request): Likewise.
	* server.c (accumulate_file_name_length): Likewise.
	(emit_dll_description): Likewise.
	(handle_qxfer_threads_worker): Likewise.
	(visit_actioned_threads): Likewise.
	* thread-db.c (any_thread_of): Likewise.
	* tracepoint.c (same_process_p): Likewise.
	(match_blocktype): Likewise.
	(build_traceframe_info_xml): Likewise.

gdb/testsuite/ChangeLog:

	* gdb.gdb/selftest.exp (do_steps_and_nexts): Adjust expected
	source line.
2015-09-25 14:08:07 -04:00
Simon Marchi f168693bc9 Remove CHECK_TYPEDEF, use check_typedef instead
I think that the CHECK_TYPEDEF macro is not necessary, and even a bit
annoying.  It makes unclear the fact that the "type" variables gets
overwritten.  It has actually bitten me a few times.  I think the
following, explicit form, is better.

  type = check_typedef (type);

This patches changes all instances of CHECK_TYPEDEF for an equivalent
call to check_typedef.  The bulk of the change was done with this sed:

  sed -i 's/CHECK_TYPEDEF (\([^)]*\));/\1 = check_typedef (\1);/' <file>.c

The ChangeLog was generated using David Malcom's generate_changelog.py.
I manually fixed those places where it gets the wrong function name,
hopefully all of them.

The patch was built-tested, and I ran a few smoke tests.

gdb/ChangeLog:
	* gdbtypes.h (CHECK_TYPEDEF): Remove.
	* aarch64-tdep.c (aarch64_return_in_memory): Replace CHECK_TYPEDEF
        with check_typedef.
	* ada-lang.c (decode_constrained_packed_array_type): Likewise.
	(ada_array_length): Likewise.
	(find_parallel_type_by_descriptive_type): Likewise.
	(ada_check_typedef): Likewise.
	* arm-tdep.c (arm_return_in_memory): Likewise.
	* ax-gdb.c (gen_trace_static_fields): Likewise.
	(gen_struct_ref_recursive): Likewise.
	* c-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise.
	(variable: block COLONCOLON name): Likewise.
	(qualified_name: TYPENAME COLONCOLON name): Likewise.
	* c-lang.c (classify_type): Likewise.
	* c-typeprint.c (c_print_type): Likewise.
	(c_print_typedef): Likewise.
	(c_type_print_base): Likewise.
	* c-valprint.c (c_val_print): Likewise.
	* compile/compile-c-types.c (convert_type): Likewise.
	* compile/compile-object-load.c (get_out_value_type): Likewise.
	* completer.c (add_struct_fields): Likewise.
	(expression_completer): Likewise.
	* cp-namespace.c (cp_find_type_baseclass_by_name): Likewise.
	(cp_lookup_nested_symbol_1): Likewise.
	(cp_lookup_nested_symbol): Likewise.
	* cp-valprint.c (cp_print_value_fields): Likewise.
	(cp_print_static_field): Likewise.
	* d-valprint.c (d_val_print): Likewise.
	* eval.c (evaluate_subexp_standard): Likewise.
	(evaluate_subexp_for_sizeof): Likewise.
	* f-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise.
	* f-typeprint.c (f_type_print_base): Likewise.
	* f-valprint.c (f_val_print): Likewise.
	* gdbtypes.c (get_discrete_bounds): Likewise.
	(create_array_type_with_stride): Likewise.
	(type_name_no_tag_or_error): Likewise.
	(lookup_struct_elt_type): Likewise.
	(get_unsigned_type_max): Likewise.
	(internal_type_vptr_fieldno): Likewise.
	(set_type_vptr_fieldno): Likewise.
	(internal_type_vptr_basetype): Likewise.
	(set_type_vptr_basetype): Likewise.
        (get_vptr_fieldno): Likewise.
	(is_integral_type): Likewise.
	(is_scalar_type): Likewise.
        (is_scalar_type_recursive): Likewise.
	(distance_to_ancestor): Likewise.
	(is_unique_ancestor_worker): Likewise.
	(check_types_equal): Likewise.
	* gnu-v2-abi.c (gnuv2_value_rtti_type): Likewise.
	* gnu-v3-abi.c (gnuv3_dynamic_class): Likewise.
	(gnuv3_get_vtable): Likewise.
	(gnuv3_pass_by_reference): Likewise.
	* go-exp.y (exp : SIZEOF_KEYWORD '(' type ')' %prec UNARY): Likewise.
	* go-lang.c (gccgo_string_p): Likewise.
	(go_classify_struct_type): Likewise.
	* go-typeprint.c (go_print_type): Likewise.
	* go-valprint.c (go_val_print): Likewise.
	* guile/scm-math.c (vlscm_binop): Likewise.
	* guile/scm-value.c (gdbscm_value_dynamic_type): Likewise.
	(gdbscm_value_to_bytevector): Likewise.
	(gdbscm_value_to_bool): Likewise.
	(gdbscm_value_to_integer): Likewise.
	(gdbscm_value_to_real): Likewise.
	* infcall.c (call_function_by_hand_dummy): Likewise.
	* infcmd.c (get_return_value): Likewise.
	* jv-lang.c (is_object_type): Likewise.
	* jv-typeprint.c (java_type_print_base): Likewise.
	* jv-valprint.c (java_print_value_fields): Likewise.
	(java_val_print): Likewise.
	* linespec.c (find_methods): Likewise.
	(collect_one_symbol): Likewise.
	* m2-typeprint.c (m2_print_type): Likewise.
	(m2_print_typedef): Likewise.
	(m2_get_discrete_bounds): Likewise.
	* m2-valprint.c (m2_print_long_set): Likewise.
	(m2_print_unbounded_array): Likewise.
	(m2_print_array_contents): Likewise.
	(m2_val_print): Likewise.
	* opencl-lang.c (opencl_print_type): Likewise.
	* p-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise.
	* p-typeprint.c (pascal_print_type): Likewise.
	(pascal_print_typedef): Likewise.
	(pascal_type_print_base): Likewise.
	* p-valprint.c (pascal_val_print): Likewise.
	(pascal_object_print_value_fields): Likewise.
	(pascal_object_print_static_field): Likewise.
	* python/py-type.c (typy_fields_items): Likewise.
	(typy_get_composite): Likewise.
	* python/py-value.c (valpy_get_dynamic_type): Likewise.
	(valpy_binop): Likewise.
	(valpy_long): Likewise.
	(valpy_float): Likewise.
	* stack.c (return_command): Likewise.
	* symtab.c (check_field): Likewise.
	(lookup_symbol_aux): Likewise.
	* tic6x-tdep.c (tic6x_return_value): Likewise.
	* typeprint.c (print_type_scalar): Likewise.
	* valarith.c (value_vector_widen): Likewise.
	* valops.c (value_cast): Likewise.
	(value_assign): Likewise.
	(do_search_struct_field): Likewise.
	(search_struct_method): Likewise.
	(find_method_list): Likewise.
	* valprint.c (val_print_scalar_type_p): Likewise.
	(valprint_check_validity): Likewise.
	(generic_val_print): Likewise.
	* value.c (unpack_double): Likewise.
	(value_primitive_field): Likewise.
	(unpack_bits_as_long): Likewise.
2015-07-14 16:42:16 -04:00
Gary Benson 61012eef84 New common function "startswith"
This commit introduces a new inline common function "startswith"
which takes two string arguments and returns nonzero if the first
string starts with the second.  It also updates the 295 places
where this logic was written out longhand to use the new function.

gdb/ChangeLog:

	* common/common-utils.h (startswith): New inline function.
	All places where this logic was used updated to use the above.
2015-03-06 09:42:06 +00:00
Mark Wielaard a2c2acaf15 GCC5/DWARFv5 Handle DW_TAG_atomic_type for C11 _Atomic type qualifier.
gdb/ChangeLog

	* c-typeprint.c (cp_type_print_method_args): Handle '_Atomic'.
	(c_type_print_modifier): Likewise.
	* dwarf2read.c (read_tag_atomic_type): New function.
	(read_type_die_1): Handle DW_TAG_atomic_type.
	* gdbtypes.c (make_atomic_type): New function.
	(recursive_dump_type): Handle TYPE_ATOMIC.
	* gdbtypes.h (enum type_flag_values): Renumber.
	(enum type_instance_flag_value): Add TYPE_INSTANCE_FLAG_ATOMIC.
	(TYPE_ATOMIC): New macro.
	(make_atomic_type): Declare.

gdb/testsuite/ChangeLog

	* gdb.dwarf2/atomic.c: New file.
	* gdb.dwarf2/atomic-type.exp: Likewise.

include/ChangeLog

	* dwarf2.def: Add DW_TAG_atomic_type.
2015-02-09 15:09:22 +01:00
Doug Evans 4bfb94b864 gdbtypes.h (TYPE_SELF_TYPE): Renamed from TYPE_DOMAIN_TYPE.
gdb/ChangeLog:

	* gdbtypes.h (TYPE_SELF_TYPE): Renamed from TYPE_DOMAIN_TYPE.
	All uses updated.
2015-01-31 21:17:05 -08:00