summaryrefslogtreecommitdiff
path: root/gdb/gdbtypes.h
Commit message (Collapse)AuthorAgeFilesLines
* gdb: remove TYPE_NAME macroSimon Marchi2020-05-161-3/+2
| | | | | | | | | | | 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.
* gdb: add type::name / type::set_nameSimon Marchi2020-05-161-1/+13
| | | | | | | | | | | | | | Add the `name` and `set_name` methods on `struct type`, in order to remove the `TYPE_NAME` macro. In this patch, the `TYPE_NAME` macro is changed to use `type::name`, so all the call sites that are used to set the type name are changed to use `type::set_name`. The next patch will remove `TYPE_NAME` completely. gdb/ChangeLog: * gdbtypes.h (struct type) <name, set_name>: New methods. (TYPE_CODE): Use type::name. Change all call sites used to set the name to use type::set_name instead.
* gdb: remove TYPE_CODE macroSimon Marchi2020-05-141-4/+3
| | | | | | | | | | | 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.
* gdb: add type::code / type::set_codeSimon Marchi2020-05-141-3/+16
| | | | | | | | | | | | | | Add the code and set_code methods on code, in order to remove the TYPE_CODE macro. In this patch, the TYPE_CODE macro is changed to use type::code, so all the call sites that are used to set the type code are changed to use type::set_code. The next patch will remove TYPE_CODE completely. gdb/ChangeLog: * gdbtypes.h (struct type) <code, set_code>: New methods. (TYPE_CODE): Use type::code. Change all call sites used to set the code to use type::set_code instead.
* gdb: remove TYPE_DYN_PROP_LIST macroSimon Marchi2020-05-071-2/+0
| | | | | | | | | | | | | Remove this macro, which abstracts how to obtain the dyn_prop_list of a given type. We could replace it with a method on `struct type`, but I don't think it's needed, as the only code that accesses the dynamic prop list directly is internal gdbtypes.c code (that can be seen as code internal to `struct type`). So it can just refer to the field directly. gdb/ChangeLog: * gdbtypes.h (TYPE_DYN_PROP_LIST): Remove. Update all users access thistype->main_type->dyn_prop_list directly.
* gdb: make remove_dyn_prop a method of struct typeSimon Marchi2020-05-071-3/+3
| | | | | | | | | | | | | Move remove_dyn_prop, currently a free function, to be a method of struct type. gdb/ChangeLog: * gdbtypes.h (struct type) <remove_dyn_prop>: New method. (remove_dyn_prop): Remove. Update all users to use type::remove_dyn_prop. * gdbtypes.c (remove_dyn_prop): Rename to... (type::remove_dyn_prop): ... this.
* gdb: make add_dyn_prop a method of struct typeSimon Marchi2020-05-071-8/+6
| | | | | | | | | | | | | Move add_dyn_prop, currently a free function, to be a method of struct type. gdb/ChangeLog: * gdbtypes.h (struct type) <add_dyn_prop>: New method. (add_dyn_prop): Remove. Update all users to use type::add_dyn_prop. * gdbtypes.c (add_dyn_prop): Rename to... (type::add_dyn_prop): ... this.
* gdb: make get_dyn_prop a method of struct typeSimon Marchi2020-05-071-12/+11
| | | | | | | | | | | | | Move get_dyn_prop, currently a free function, to be a method on struct type. gdb/ChangeLog: * gdbtypes.h (struct type) <get_dyn_prop>: New method. (get_dyn_prop): Remove. Update all users to use type::dyn_prop. * gdbtypes.c (get_dyn_prop): Rename to... (type::dyn_prop): ... this.
* gdb: remove main_type::flag_staticSimon Marchi2020-05-061-1/+0
| | | | | | | | It is not used. gdb/ChangeLog: * gdbtypes.h (struct main_type) <flag_static>: Remove.
* gdb: remove main_type::flag_incompleteSimon Marchi2020-05-051-1/+0
| | | | | | | | | It is unused. The corresponding macro was removed in c3236f84c17 ("gdb: remove TYPE_INCOMPLETE"). gdb/ChangeLog: * gdbtypes.h (struct main_type) <flag_incomplete>: Remove.
* gdb: remove TYPE_INCOMPLETESimon Marchi2020-05-041-10/+0
| | | | | | | | | | | The "HP platforms" comment prompted me to check if this was still used somewhere. Apparently it's not, so remove it. gdb/ChangeLog: * gdbtypes.h (TYPE_INCOMPLETE): Remove. * gdbtypes.c (recursive_dump_type): Remove use of TYPE_INCOMPLETE.
* Fix typo in comment of DYN_PROP_ASSOCIATEDHannes Domani2020-05-021-1/+1
| | | | | | | | gdb/ChangeLog: 2020-05-02 Hannes Domani <ssbssa@yahoo.de> * gdbtypes.h (enum dynamic_prop_node_kind): Fix typo.
* Add support for dynamic type lengthsTom Tromey2020-04-241-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | In Ada, a type with variant parts can have a variable length. This patch adds support for this to gdb, by integrating the length computation into the dynamic type resolution code. gdb/ChangeLog 2020-04-24 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (read_structure_type): Handle dynamic length. * gdbtypes.c (is_dynamic_type_internal): Check TYPE_HAS_DYNAMIC_LENGTH. (resolve_dynamic_type_internal): Use TYPE_DYNAMIC_LENGTH. * gdbtypes.h (TYPE_HAS_DYNAMIC_LENGTH, TYPE_DYNAMIC_LENGTH): New macros. (enum dynamic_prop_node_kind) <DYN_PROP_BYTE_SIZE>: New constant. gdb/testsuite/ChangeLog 2020-04-24 Tom Tromey <tromey@adacore.com> * gdb.ada/variant.exp: New file * gdb.ada/variant/pkg.adb: New file * gdb.ada/variant/pck.adb: New file
* Rewrite the existing variant part codeTom Tromey2020-04-241-51/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This rewrites the existing variant part code to follow the new model implemented in the previous patch. The old variant part code is removed. This only affects Rust for the moment. I tested this using various version of the Rust compiler, including one that emits old-style enum debuginfo, exercising the quirks code. gdb/ChangeLog 2020-04-24 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (struct variant_field): Rewrite. (struct variant_part_builder): New. (struct nextfield): Remove "variant" field. Add "offset". (struct field_info): Add "current_variant_part" and "variant_parts". (alloc_discriminant_info): Remove. (alloc_rust_variant): New function. (quirk_rust_enum): Update. (dwarf2_add_field): Set "offset" member. Don't handle DW_TAG_variant_part. (offset_map_type): New typedef. (convert_variant_range, create_one_variant) (create_one_variant_part, create_variant_parts) (add_variant_property): New functions. (dwarf2_attach_fields_to_type): Call add_variant_property. (read_structure_type): Don't handle DW_TAG_variant_part. (handle_variant_part, handle_variant): New functions. (handle_struct_member_die): Use them. (process_structure_scope): Don't handle variant parts. * gdbtypes.h (TYPE_FLAG_DISCRIMINATED_UNION): Remove. (struct discriminant_info): Remove. (enum dynamic_prop_node_kind) <DYN_PROP_DISCRIMINATED>: Remove. (struct main_type) <flag_discriminated_union>: Remove. * rust-lang.c (rust_enum_p, rust_empty_enum_p): Rewrite. (rust_enum_variant): Return int. Remove "contents". Rewrite. (rust_print_enum, rust_print_struct_def, rust_evaluate_subexp): Update. * valops.c (value_union_variant): Remove. * value.h (value_union_variant): Don't declare.
* Prefer existing data when evaluating DWARF expressionTom Tromey2020-04-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When evaluating a DWARF expression, the dynamic type resolution code will pass in a buffer of bytes via the property_addr_info. However, the DWARF expression evaluator will then proceed to read memory from the inferior, even when the request could be filled from this buffer. This, in turn, is a problem in some cases; and specifically when trying to handle the Ada scenario of extracting a variable-length value from a packed array. Here, the ordinary DWARF expression cannot be directly evaluated, because the data may appear at some arbitrary bit offset. So, it is unpacked into a staging area and then the expression is evaluated -- using an address of 0. This patch fixes the problem by arranging for the DWARF evaluator, in this case, to prefer passed-in memory when possible. The type of the buffer in the property_addr_info is changed to an array_view so that bounds checking can be done. gdb/ChangeLog 2020-04-24 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_discrete_type_high_bound, ada_discrete_type_low) (ada_value_primitive_packed_val): Update. * ada-valprint.c (ada_value_print_1): Update. * dwarf2/loc.c (evaluate_for_locexpr_baton): New struct. (dwarf2_locexpr_baton_eval): Take a property_addr_info rather than just an address. Use evaluate_for_locexpr_baton. (dwarf2_evaluate_property): Update. * dwarf2/loc.h (struct property_addr_info) <valaddr>: Now an array_view. * findvar.c (default_read_var_value): Update. * gdbtypes.c (compute_variant_fields_inner) (resolve_dynamic_type_internal): Update. (resolve_dynamic_type): Change type of valaddr parameter. * gdbtypes.h (resolve_dynamic_type): Update. * valarith.c (value_subscripted_rvalue): Update. * value.c (value_from_contents_and_address): Update.
* Add new variant part codeTom Tromey2020-04-241-1/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the infrastructure for the new variant part code. At this point, nothing uses this code. This is done in a separate patch to make it simpler to review. I examined a few possible approaches to handling variant parts. In particular, I considered having a DWARF variant part be a union (similar to how the Rust code works now); and I considered having type fields have a flag indicating that they are variants. Having separate types seemed bad conceptually, because these variants aren't truly separate -- they rely on the "parent" type. And, changing how fields worked seemed excessively invasive. So, in the end I thought the approach taken in this patch was both simple to implement and understand, without losing generality. The idea in this patch is that all the fields of a type with variant parts will be stored in a single field array, just as if they'd all been listed directly. Then, the variants are attached as a dynamic property. These control which fields end up in the type that's constructed during dynamic type resolution. gdb/ChangeLog 2020-04-24 Tom Tromey <tromey@adacore.com> * gdbtypes.c (is_dynamic_type_internal): Check for variant parts. (variant::matches, compute_variant_fields_recurse) (compute_variant_fields_inner, compute_variant_fields): New functions. (resolve_dynamic_struct): Check for DYN_PROP_VARIANT_PARTS. Use resolved_type after type is made. (operator==): Add new cases. * gdbtypes.h (TYPE_HAS_VARIANT_PARTS): New macro. (struct discriminant_range, struct variant, struct variant_part): New. (union dynamic_prop_data) <variant_parts, original_type>: New members. (enum dynamic_prop_node_kind) <DYN_PROP_VARIANT_PARTS>: New constant. (enum dynamic_prop_kind) <PROP_TYPE, PROP_VARIANT_PARTS>: New constants. * value.c (unpack_bits_as_long): Now public. * value.h (unpack_bits_as_long): Declare.
* Change how complex types are createdTom Tromey2020-04-011-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes how complex types are created. init_complex_type and arch_complex_type are unified, and complex types are reused, by attaching them to the underlying scalar type. gdb/ChangeLog 2020-04-01 Tom Tromey <tom@tromey.com> * stabsread.c (rs6000_builtin_type, read_sun_floating_type) (read_range_type): Update. * mdebugread.c (basic_type): Update. * go-lang.c (build_go_types): Use init_complex_type. * gdbtypes.h (struct main_type) <complex_type>: New member. (init_complex_type): Update. (arch_complex_type): Don't declare. * gdbtypes.c (init_complex_type): Remove "objfile" parameter. Make name if none given. Use alloc_type_copy. Look for cached complex type. (arch_complex_type): Remove. (gdbtypes_post_init): Use init_complex_type. * f-lang.c (build_fortran_types): Use init_complex_type. * dwarf2/read.c (read_base_type): Update. * d-lang.c (build_d_types): Use init_complex_type. * ctfread.c (read_base_type): Update.
* Remove some obsolete commentsTom Tromey2020-03-071-3/+1
| | | | | | | | | | | | While working on complex number support, I found a couple of apparently obsolete coments. This removes them. 2020-03-07 Tom Tromey <tom@tromey.com> * valops.c (value_literal_complex): Remove obsolete comment. * gdbtypes.h (enum type_code) <TYPE_CODE_FLT>: Remove obsolete comment.
* Update copyright year range in all GDB files.Joel Brobecker2020-01-011-1/+1
| | | | | | gdb/ChangeLog: Update copyright year range in all GDB files.
* Use enum bitfield for the calling_convention attribute of a subroutineTankut Baris Aktemur2019-12-201-2/+2
| | | | | | | | | | | | | | | | | | This is a refactoring. Instead of a plain unsigned value, use an enum bitfield. gdb/ChangeLog: 2019-12-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * dwarf2read.c (is_valid_DW_AT_calling_convention_for_subroutine): New function. (read_subroutine_type): Validate the parsed DW_AT_calling_convention value before assigning it to a subroutine's calling_convention attribute. * gdbtypes.h (struct func_type) <calling_convention>: Use an enum bitfield as its type, instead of plain unsigned. Change-Id: Ibc6b2f71e885cbc5c3c9d49734f7125acbfd1bcd
* gdb: recognize new DWARF attributes: defaulted, deleted, calling conv.Tankut Baris Aktemur2019-12-201-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend GDB's internal representation of types to include the DW_AT_calling_convention, DW_AT_defaulted, and DW_AT_deleted attributes that were introduced in DWARF5. These attributes will be helpful in a future patch about infcall'ing functions with call-by-value parameters. GDB will use the attributes to decide whether the type of a call-by-value parameter is implicitly pass-by-reference. gdb/ChangeLog: 2019-12-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * dwarf2read.c (dwarf2_add_member_fn): Read the DW_AT_defaulted and DW_AT_deleted attributes of a function. (read_structure_type): Read the DW_AT_calling_convention attribute of a type. (is_valid_DW_AT_defaulted): New function. (is_valid_DW_AT_calling_convention_for_type): New function. * gdbtypes.h: Include dwarf2.h. (struct fn_field)<defaulted>: New field to store the DW_AT_defaulted attribute. (struct fn_field)<is_deleted>: New field to store the DW_AT_deleted attribute. (struct cplus_struct_type)<calling_convention>: New field to store the DW_AT_calling_convention attribute. (TYPE_FN_FIELD_DEFAULTED): New macro. (TYPE_FN_FIELD_DELETED): New macro. (TYPE_CPLUS_CALLING_CONVENTION): New macro. * gdbtypes.c (dump_fn_fieldlists): Update for the changes made to the .h file. (print_cplus_stuff): Likewise. Change-Id: I54192f363115b78ec7435a8563b73fcace420765
* gdb: fix overload resolution for see-through referencesTankut Baris Aktemur2019-12-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The overload resolution mechanism assigns badness values to the necessary conversions to be made on types to pick a champion. A badness value consists of a "rank" that scores the conversion and a "subrank" to differentiate conversions of the same kind. An auxiliary function, 'sum_ranks', is used for adding two badness values. In all of its uses, except two, 'sum_ranks' is used for populating the subrank of a badness value. The two exceptions are in 'rank_one_type': ~~~ /* See through references, since we can almost make non-references references. */ if (TYPE_IS_REFERENCE (arg)) return (sum_ranks (rank_one_type (parm, TYPE_TARGET_TYPE (arg), NULL), REFERENCE_CONVERSION_BADNESS)); if (TYPE_IS_REFERENCE (parm)) return (sum_ranks (rank_one_type (TYPE_TARGET_TYPE (parm), arg, NULL), REFERENCE_CONVERSION_BADNESS)); ~~~ Here, the result of a recursive call is combined with REFERENCE_CONVERSION_BADNESS. This leads to the problem of over-punishment by combining two ranks. Consider this: void an_overloaded_function (const foo &); void an_overloaded_function (const foo &&); ... foo arg; an_overloaded_function(arg); When ranking 'an_overloaded_function (const foo &)', the badness values REFERENCE_CONVERSION_BADNESS and CV_CONVERSION_BADNESS are combined, whereas 'rank_one_type' assigns only the REFERENCE_CONVERSION_BADNESS value to 'an_overloaded_function (const foo &&)' (there is a different execution flow for that). This yields in GDB picking the latter function as the overload champion instead of the former. In fact, the 'rank_one_type' function should have given 'an_overloaded_function (const foo &)' the CV_CONVERSION_BADNESS value, with the see-through referencing increasing the subrank a little bit. This can be achieved by introducing a new badness value, REFERENCE_SEE_THROUGH_BADNESS, which bumps up the subrank only, and using it in the two "exceptional" cases of 'sum_ranks'. gdb/ChangeLog: 2019-12-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdbtypes.h: Define the REFERENCE_SEE_THROUGH_BADNESS value. * gdbtypes.c (rank_one_type): Use REFERENCE_SEE_THROUGH_BADNESS for ranking see-through reference cases. gdb/testsuite/ChangeLog: 2019-12-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.cp/rvalue-ref-overload.cc: Add a case that involves both CV and reference conversion for overload resolution. * gdb.cp/rvalue-ref-overload.exp: Test it. Change-Id: I39ae6505ab85ad0bd21915368c82540ceeb3aae9
* Remove gdbarch parameter of lookup_typenameSimon Marchi2019-12-051-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I noticed that the gdbarch parameter of lookup_typename was unused, so I removed it (as well as from lookup_signed_typename and lookup_unsigned_typename) and updated all callers. Tested by rebuilding. gdb/ChangeLog: * c-exp.y: Update calls to lookup_typename, lookup_signed_typename and lookup_unsigned_typename. * c-lang.c (evaluate_subexp_c): Likewise. * cp-namespace.c (cp_lookup_symbol_imports_or_template): Likewise. * eval.c (binop_promote): Likewise. * gdbtypes.c (lookup_typename): Remove gdbarch parameter. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. * gdbtypes.h (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (lookup_typename): Likewise. * guile/scm-type.c (tyscm_lookup_typename): Update calls to lookup_typename, lookup_signed_typename, lookup_unsigned_typename. * m2-exp.y: Likewise. * printcmd.c (printf_wide_c_string): Likewise. (ui_printf): Likewise. * python/py-type.c (typy_lookup_typename): Likewise. * python/py-xmethods.c (python_xmethod_worker::invoke): Likewise. * rust-exp.y: Likewise.
* Remove gdbarch_bits_big_endianTom Tromey2019-12-041-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From what I can tell, set_gdbarch_bits_big_endian has never been used. That is, all architectures since its introduction have simply used the default, which is simply check the architecture's byte-endianness. Because this interferes with the scalar_storage_order code, this patch removes this gdbarch setting entirely. In some places, type_byte_order is used rather than the plain gdbarch. gdb/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * ada-lang.c (decode_constrained_packed_array) (ada_value_assign, value_assign_to_component): Update. * dwarf2loc.c (rw_pieced_value, access_memory) (dwarf2_compile_expr_to_ax): Update. * dwarf2read.c (dwarf2_add_field): Update. * eval.c (evaluate_subexp_standard): Update. * gdbarch.c, gdbarch.h: Rebuild. * gdbarch.sh (bits_big_endian): Remove. * gdbtypes.h (union field_location): Update comment. * target-descriptions.c (make_gdb_type): Update. * valarith.c (value_bit_index): Update. * value.c (struct value) <bitpos>: Update comment. (unpack_bits_as_long, modify_field): Update. * value.h (value_bitpos): Update comment. Change-Id: I379b5e0c408ec8742f7a6c6b721108e73ed1b018
* Add scalar_storage_order support for floating pointTom Tromey2019-12-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | Testing the scalar_storage_order patch pointed out that it does not handle floating point properly. This patch fixes this problem. gdb/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * dwarf2read.c (dwarf2_init_float_type) (dwarf2_init_complex_target_type): Add byte_order parameter. (read_base_type): Compute byte order earlier. * gdbtypes.c (init_float_type): Add byte_order parameter. * gdbtypes.h (init_float_type): Add byte_order parameter. gdb/testsuite/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * gdb.base/endianity.c (struct otherendian) <f>: New field. (main): Initialize it. * gdb.base/endianity.exp: Update. Change-Id: Ic02eb711d80ce678ef0ecf8c506a626e441b8440
* gdb/fortran: array stride supportAndrew Burgess2019-12-011-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently GDB supports a byte or bit stride on arrays, in DWARF this would be DW_AT_bit_stride or DW_AT_byte_stride on DW_TAG_array_type. However, DWARF can also support DW_AT_byte_stride or DW_AT_bit_stride on DW_TAG_subrange_type, the tag used to describe each dimension of an array. Strides on subranges are used by gFortran to represent Fortran arrays, and this commit adds support for this to GDB. I've extended the range_bounds struct to include the stride information. The name is possibly a little inaccurate now, but this still sort of makes sense, the structure represents information about the bounds of the range, and also how to move from the lower to the upper bound (the stride). I've added initial support for bit strides, but I've never actually seen an example of this being generated. Further, I don't really see right now how GDB would currently handle a bit stride that was not a multiple of the byte size as the code in, for example, valarith.c:value_subscripted_rvalue seems geared around byte addressing. As a consequence if we see a bit stride that is not a multiple of 8 then GDB will give an error. gdb/ChangeLog: * dwarf2read.c (read_subrange_type): Read bit and byte stride and create a range with stride where appropriate. * f-valprint.c: Include 'gdbarch.h'. (f77_print_array_1): Take the stride into account when walking the array. Also convert the stride into addressable units. * gdbtypes.c (create_range_type): Initialise the stride to constant zero. (create_range_type_with_stride): New function, initialise the range as normal, and then setup the stride. (has_static_range): Include the stride here. Also change the return type to bool. (create_array_type_with_stride): Consider the range stride if the array isn't given its own stride. (resolve_dynamic_range): Resolve the stride if needed. * gdbtypes.h (struct range_bounds) <stride>: New member variable. (struct range_bounds) <flag_is_byte_stride>: New member variable. (TYPE_BIT_STRIDE): Define. (TYPE_ARRAY_BIT_STRIDE): Define. (create_range_type_with_stride): Declare. * valarith.c (value_subscripted_rvalue): Take range stride into account when walking the array. gdb/testsuite/ChangeLog: * gdb.fortran/derived-type-striding.exp: New file. * gdb.fortran/derived-type-striding.f90: New file. * gdb.fortran/array-slices.exp: New file. * gdb.fortran/array-slices.f90: New file. Change-Id: I9af2bcd1f2d4c56f76f5f3f9f89d8f06bef10d9a
* Make two range_bounds bitfields unsignedTom Tromey2019-11-281-2/+2
| | | | | | | | | | | | | | | | | While debugging gdb, I noticed that the bitfields in a range_bounds were signed, causing the values of these fields to be -1. I think this is odd; and while we haven't yet committed to boolean bitfields, I think it is a small improvement to change these types to unsigned. gdb/ChangeLog 2019-11-28 Tom Tromey <tom@tromey.com> * gdbtypes.h (struct range_bounds) <flag_upper_bound_is_count, flag_bound_evaluated>: Now unsigned. Change-Id: Ia377fd931594bbf8653180d4dcb4e60354d90139
* Adjust byte order variable display/change if DW_AT_endianity is present.Peeter Joot2019-11-211-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Rationale: It is possible for compilers to indicate the desired byte order interpretation of scalar variables using the DWARF attribute: DW_AT_endianity A type flagged with this variable would typically use one of: DW_END_big DW_END_little which instructs the debugger what the desired byte order interpretation of the variable should be. The GCC compiler (as of V6) has a mechanism for setting the desired byte ordering of the fields within a structure or union. For, example, on a little endian target, a structure declared as: struct big { int v; short a[4]; } __attribute__( ( scalar_storage_order( "big-endian" ) ) ); could be used to ensure all the structure members have a big-endian interpretation (the compiler would automatically insert byte swap instructions before and after respective store and load instructions). - To reproduce GCC V8 is required to correctly emit DW_AT_endianity DWARF attributes in all situations when the scalar_storage_order attribute is used. A fix for (dwarf endianity instrumentation) for GCC V6-V7 can be found in the URL field of the following PR: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509 - Test-case: A new test case (testsuite/gdb.base/endianity.*) is included with this patch. Manual testing for mixed endianity code has also been done with GCC V8. See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509#c4 - Observed vs. expected: Without this change, using scalar_storage_order that doesn't match the target, such as struct otherendian { int v; } __attribute__( ( scalar_storage_order( "big-endian" ) ) ); would behave like the following on a little endian target: Breakpoint 1 at 0x401135: file endianity.c, line 41. (gdb) run Starting program: /home/pjoot/freeware/t/a.out Missing separate debuginfos, use: debuginfo-install glibc-2.17-292.el7.x86_64 Breakpoint 1, main () at endianity.c:41 41 struct otherendian o = {3}; (gdb) n 43 do_nothing (&o); /* START */ (gdb) p o $1 = {v = 50331648} (gdb) p /x $2 = {v = 0x3000000} whereas with this gdb enhancement we can access the variable with the user specified endianity: Breakpoint 1, main () at endianity.c:41 41 struct otherendian o = {3}; (gdb) p o $1 = {v = 0} (gdb) n 43 do_nothing (&o); /* START */ (gdb) p o $2 = {v = 3} (gdb) p o.v = 4 $3 = 4 (gdb) p o.v $4 = 4 (gdb) x/4xb &o.v 0x7fffffffd90c: 0x00 0x00 0x00 0x04 (observe that the 4 byte int variable has a big endian representation in the hex dump.) gdb/ChangeLog 2019-11-21 Peeter Joot <peeter.joot@lzlabs.com> Byte reverse display of variables with DW_END_big, DW_END_little (DW_AT_endianity) dwarf attributes if different than the native byte order. * ada-lang.c (ada_value_binop): Use type_byte_order instead of gdbarch_byte_order. * ada-valprint.c (printstr): (ada_val_print_string): * ada-lang.c (value_pointer): (ada_value_binop): Use type_byte_order instead of gdbarch_byte_order. * c-lang.c (c_get_string): Use type_byte_order instead of gdbarch_byte_order. * c-valprint.c (c_val_print_array): Use type_byte_order instead of gdbarch_byte_order. * cp-valprint.c (cp_print_class_member): Use type_byte_order instead of gdbarch_byte_order. * dwarf2loc.c (rw_pieced_value): Use type_byte_order instead of gdbarch_byte_order. * dwarf2read.c (read_base_type): Handle DW_END_big, DW_END_little * f-lang.c (f_get_encoding): Use type_byte_order instead of gdbarch_byte_order. * findvar.c (default_read_var_value): Use type_byte_order instead of gdbarch_byte_order. * gdbtypes.c (check_types_equal): Require matching TYPE_ENDIANITY_NOT_DEFAULT if set. (recursive_dump_type): Print TYPE_ENDIANITY_BIG, and TYPE_ENDIANITY_LITTLE if set. (type_byte_order): new function. * gdbtypes.h (TYPE_ENDIANITY_NOT_DEFAULT): New macro. (struct main_type) <flag_endianity_not_default>: New field. (type_byte_order): New function. * infcmd.c (default_print_one_register_info): Use type_byte_order instead of gdbarch_byte_order. * p-lang.c (pascal_printstr): Use type_byte_order instead of gdbarch_byte_order. * p-valprint.c (pascal_val_print): Use type_byte_order instead of gdbarch_byte_order. * printcmd.c (print_scalar_formatted): Use type_byte_order instead of gdbarch_byte_order. * solib-darwin.c (darwin_current_sos): Use type_byte_order instead of gdbarch_byte_order. * solib-svr4.c (solib_svr4_r_ldsomap): Use type_byte_order instead of gdbarch_byte_order. * stap-probe.c (stap_modify_semaphore): Use type_byte_order instead of gdbarch_byte_order. * target-float.c (target_float_same_format_p): Use type_byte_order instead of gdbarch_byte_order. * valarith.c (scalar_binop): (value_bit_index): Use type_byte_order instead of gdbarch_byte_order. * valops.c (value_cast): Use type_byte_order instead of gdbarch_byte_order. * valprint.c (generic_emit_char): (generic_printstr): (val_print_string): Use type_byte_order instead of gdbarch_byte_order. * value.c (unpack_long): (unpack_bits_as_long): (unpack_value_bitfield): (modify_field): (pack_long): (pack_unsigned_long): Use type_byte_order instead of gdbarch_byte_order. * findvar.c (unsigned_pointer_to_address): (signed_pointer_to_address): (unsigned_address_to_pointer): (address_to_signed_pointer): (default_read_var_value): (default_value_from_register): Use type_byte_order instead of gdbarch_byte_order. * gnu-v3-abi.c (gnuv3_make_method_ptr): Use type_byte_order instead of gdbarch_byte_order. * riscv-tdep.c (riscv_print_one_register_info): Use type_byte_order instead of gdbarch_byte_order. gdb/testsuite/ChangeLog 2019-11-21 Peeter Joot <peeter.joot@lzlabs.com> * gdb.base/endianity.c: New test. * gdb.base/endianity.exp: New file. Change-Id: I4bd98c1b4508c2d7c5a5dbb15d7b7b1cb4e667e2
* [gdb] Fix more typos in comments (2)Tom de Vries2019-10-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix typos in comments. NFC. Tested on x86_64-linux. gdb/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * aarch64-linux-tdep.c: Fix typos in comments. * aarch64-tdep.c: Same. * ada-lang.c: Same. * amd64-nat.c: Same. * arc-tdep.c: Same. * arch/aarch64-insn.c: Same. * block.c: Same. * breakpoint.h: Same. * btrace.h: Same. * c-varobj.c: Same. * cli/cli-decode.c: Same. * cli/cli-script.c: Same. * cli/cli-utils.h: Same. * coff-pe-read.c: Same. * coffread.c: Same. * compile/compile-cplus-symbols.c: Same. * compile/compile-object-run.c: Same. * completer.c: Same. * corelow.c: Same. * cp-support.c: Same. * demangle.c: Same. * dwarf-index-write.c: Same. * dwarf2-frame.c: Same. * dwarf2-frame.h: Same. * eval.c: Same. * frame-base.h: Same. * frame.h: Same. * gdbcmd.h: Same. * gdbtypes.h: Same. * gnu-nat.c: Same. * guile/scm-objfile.c: Same. * i386-tdep.c: Same. * i386-tdep.h: Same. * infcall.c: Same. * infcall.h: Same. * linux-nat.c: Same. * m68k-tdep.c: Same. * macroexp.c: Same. * memattr.c: Same. * mi/mi-cmd-disas.c: Same. * mi/mi-getopt.h: Same. * mi/mi-main.c: Same. * minsyms.c: Same. * nat/aarch64-sve-linux-sigcontext.h: Same. * objfiles.h: Same. * ppc-linux-nat.c: Same. * ppc-linux-tdep.c: Same. * ppc-tdep.h: Same. * progspace.h: Same. * prologue-value.h: Same. * python/py-evtregistry.c: Same. * python/py-instruction.h: Same. * record-btrace.c: Same. * record-full.c: Same. * remote.c: Same. * rs6000-tdep.c: Same. * ser-tcp.c: Same. * sol-thread.c: Same. * sparc-sol2-tdep.c: Same. * sparc64-tdep.c: Same. * stabsread.c: Same. * symfile.c: Same. * symtab.h: Same. * target.c: Same. * tracepoint.c: Same. * tui/tui-data.h: Same. * tui/tui-io.c: Same. * tui/tui-win.c: Same. * tui/tui.c: Same. * unittests/rsp-low-selftests.c: Same. * user-regs.h: Same. * utils.c: Same. * utils.h: Same. * valarith.c: Same. * valops.c: Same. * valprint.c: Same. * valprint.h: Same. * value.c: Same. * value.h: Same. * varobj.c: Same. * x86-nat.h: Same. * xtensa-tdep.c: Same. gdb/gdbserver/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * linux-aarch64-low.c: Fix typos in comments. * linux-arm-low.c: Same. * linux-low.c: Same. * linux-ppc-low.c: Same. * proc-service.c: Same. * regcache.h: Same. * server.c: Same. * tracepoint.c: Same. * win32-low.c: Same. gdb/stubs/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * ia64vms-stub.c: Fix typos in comments. * m32r-stub.c: Same. * m68k-stub.c: Same. * sh-stub.c: Same. gdb/testsuite/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * gdb.base/bigcore.c: Fix typos in comments. * gdb.base/ctf-ptype.c: Same. * gdb.base/long_long.c: Same. * gdb.dwarf2/dw2-op-out-param.S: Same. * gdb.python/py-evthreads.c: Same. * gdb.reverse/i387-stack-reverse.c: Same. * gdb.trace/tfile.c: Same. * lib/compiler.c: Same. * lib/compiler.cc: Same. Change-Id: I8573d84a577894270179ae30f46c48d806fc1beb
* Move declaration of overload_debug to headerChristian Biesinger2019-10-081-0/+5
| | | | | | | | | | | gdb/ChangeLog: 2019-10-08 Christian Biesinger <cbiesinger@google.com> * gdbtypes.c (overload_debug): Move comment to header. * gdbtypes.h (overload_debug): Declare. * valops.c: Remove declaration of overload_debug, instead include gdbtypes.h.
* Handle biased typesTom Tromey2019-09-031-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ada, the programmer can request that a range type with a non-zero base be stored in the minimal number of bits required for the range. This is done by biasing the values; so, for example, a range of -7..-4 may be stored as two bits with a bias of -7. This patch implements this for gdb. It is done by adding a bias to struct range_bounds and then adjusting a few spots to handle this. The test case is written to use -fgnat-encodings=minimal, but a future compiler patch will change the compiler to emit DW_AT_GNU_bias with -fgnat-encodings=gdb. It seemed good to get the gdb patch in first. Tested on x86-64 Fedora 29; plus a variety of targets using AdaCore's internal test suite. gdb/ChangeLog 2019-09-03 Tom Tromey <tromey@adacore.com> * ada-valprint.c (ada_val_print_num): Don't recurse for range types. (has_negatives): Unbias a range type bound. * dwarf2read.c (read_subrange_type): Handle DW_AT_GNU_bias. * gdbtypes.c (operator==): Handle new field. (create_range_type): Add "bias" parameter. (create_static_range_type, resolve_dynamic_range): Update. * gdbtypes.h (struct range_bounds) <bias>: New member. (create_range_type): Add bias parameter. * printcmd.c (print_scalar_formatted): Unbias range types. * value.c (unpack_long): Unbias range types. (pack_long): Bias range types. gdb/testsuite/ChangeLog 2019-09-03 Tom Tromey <tromey@adacore.com> * gdb.ada/bias.exp: New file. * gdb.ada/bias/bias.adb: New file. * gdb.ada/print_chars.exp: Add regression test. * gdb.ada/print_chars/foo.adb (My_Character): New type. (MC): New variable.
* Don't include gdbarch.h from defs.hTom Tromey2019-07-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I touched symtab.h and was surprised to see how many files were rebuilt. I looked into it a bit, and found that defs.h includes gdbarch.h, which in turn includes many things. gdbarch.h is only needed by a minority ofthe files in gdb, so this patch removes the include from defs.h and updates the fallout. I did "wc -l" on the files in build/gdb/.deps; this patch reduces the line count from 139935 to 137030; so there are definitely future build-time savings here. Note that while I configured with --enable-targets=all, it's possible that some *-nat.c file needs an update. I could not test all of these. The buildbot caught a few problems along these lines. gdb/ChangeLog 2019-07-10 Tom Tromey <tom@tromey.com> * defs.h: Don't include gdbarch.h. * aarch64-ravenscar-thread.c, aarch64-tdep.c, alpha-bsd-tdep.h, alpha-linux-tdep.c, alpha-mdebug-tdep.c, arch-utils.h, arm-tdep.h, ax-general.c, btrace.c, buildsym-legacy.c, buildsym.h, c-lang.c, cli/cli-decode.h, cli/cli-dump.c, cli/cli-script.h, cli/cli-style.h, coff-pe-read.h, compile/compile-c-support.c, compile/compile-cplus.h, compile/compile-loc2c.c, corefile.c, cp-valprint.c, cris-linux-tdep.c, ctf.c, d-lang.c, d-namespace.c, dcache.c, dicos-tdep.c, dictionary.c, disasm-selftests.c, dummy-frame.c, dummy-frame.h, dwarf2-frame-tailcall.c, dwarf2expr.c, expression.h, f-lang.c, frame-base.c, frame-unwind.c, frv-linux-tdep.c, gdbarch-selftests.c, gdbtypes.h, go-lang.c, hppa-nbsd-tdep.c, hppa-obsd-tdep.c, i386-dicos-tdep.c, i386-tdep.h, ia64-vms-tdep.c, interps.h, language.c, linux-record.c, location.h, m2-lang.c, m32r-linux-tdep.c, mem-break.c, memattr.c, mn10300-linux-tdep.c, nios2-linux-tdep.c, objfiles.h, opencl-lang.c, or1k-linux-tdep.c, p-lang.c, parser-defs.h, ppc-tdep.h, probe.h, python/py-record-btrace.c, record-btrace.c, record.h, regcache-dump.c, regcache.h, riscv-fbsd-tdep.c, riscv-linux-tdep.c, rust-exp.y, sh-linux-tdep.c, sh-nbsd-tdep.c, source-cache.c, sparc-nbsd-tdep.c, sparc-obsd-tdep.c, sparc-ravenscar-thread.c, sparc64-fbsd-tdep.c, std-regs.c, target-descriptions.h, target-float.c, tic6x-linux-tdep.c, tilegx-linux-tdep.c, top.c, tracefile.c, trad-frame.c, type-stack.h, ui-style.c, utils.c, utils.h, valarith.c, valprint.c, varobj.c, x86-tdep.c, xml-support.h, xtensa-linux-tdep.c, cli/cli-cmds.h: Update. * s390-linux-nat.c, procfs.c, inf-ptrace.c: Likewise.
* Rename common to gdbsupportTom Tromey2019-07-091-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
* Two comment fixes in gdbtypes.hTom Tromey2019-05-301-2/+3
| | | | | | | | | | | | | | | This fixes a couple of comments in gdbtypes.h. One comment had a typo; and another comment referred to "Moto", which is presumably some long-gone Motorola-related project. Tested by rebuilding. gdb/ChangeLog 2019-05-30 Tom Tromey <tromey@adacore.com> * gdbtypes.h (struct range_bounds) <flag_upper_bound_is_count>: Fix comment. (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED): Rewrite comment.
* AArch64: Add half float view to V registersAlan Hayward2019-05-141-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | AArch64 can fill the vector registers with half precision floats. Add a view for this. Add builtin type ieee half and connect this to the existing floatformats_ieee_half. gdb/ChangeLog: 2019-05-14 Alan Hayward <alan.hayward@arm.com> * aarch64-tdep.c (aarch64_vnh_type): Add half view. (aarch64_vnv_type): Likewise. * target-descriptions.c (make_gdb_type): Add TDESC_TYPE_IEEE_HALF. * common/tdesc.c: Likewise. * common/tdesc.h (enum tdesc_type_kind): Likewise. * features/aarch64-fpu.c (create_feature_aarch64_fpu): Regenerate. * features/aarch64-fpu.xml: Add ieee half view. * features/aarch64-sve.c (create_feature_aarch64_fpu): Likewise. * gdbtypes.c (gdbtypes_post_init): Add builtin_half * gdbtypes.h (struct builtin_type): Likewise. (struct objfile_type): Likewise.
* gdb/fortran: Add allocatable type qualifierAndrew Burgess2019-04-301-0/+4
| | | | | | | | | | | | | | | | | | | | | | Types in Fortran can have the 'allocatable' qualifier attached to indicate that memory needs to be explicitly allocated by the user. This patch extends GDB to show this qualifier when printing types. Lots of tests results are then updated to include this new qualifier in the expected results. gdb/ChangeLog: * f-typeprint.c (f_type_print_base): Print 'allocatable' type qualifier. * gdbtypes.h (TYPE_IS_ALLOCATABLE): Define. gdb/testsuite/ChangeLog: * gdb.fortran/vla-datatypes.exp: Update expected results. * gdb.fortran/vla-ptype.exp: Likewise. * gdb.fortran/vla-type.exp: Likewise. * gdb.fortran/vla-value.exp: Likewise.
* Make copy_name return std::stringTom Tromey2019-04-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes copy_name to return a std::string, updating all the callers. In some cases, an extra copy was removed. This also required a little bit of constification. Tested by the buildbot. gdb/ChangeLog 2019-04-19 Tom Tromey <tom@tromey.com> * type-stack.h (struct type_stack) <insert>: Constify string. * type-stack.c (type_stack::insert): Constify string. * gdbtypes.h (lookup_template_type): Update. (address_space_name_to_int): Update. * gdbtypes.c (address_space_name_to_int): Make space_identifier const. (lookup_template_type): Make name const. * c-exp.y: Update rules. (lex_one_token, classify_name, classify_inner_name) (c_print_token): Update. * p-exp.y: Update rules. (yylex): Update. * f-exp.y: Update rules. (yylex): Update. * d-exp.y: Update rules. (lex_one_token, classify_name, classify_inner_name): Update. * parse.c (write_dollar_variable, copy_name): Return std::string. * parser-defs.h (copy_name): Change return type. * m2-exp.y: Update rules. (yylex): Update. * go-exp.y (lex_one_token): Update. Update rules. (classify_unsafe_function, classify_packaged_name) (classify_name, yylex): Update.
* Print non-Ada unions without crashingTom Tromey2019-04-191-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ada-lang.c is a bit too eager trying to decode unions in the Ada style -- looking for discriminants and such. This causes crashes when printing a non-Ada union in Ada mode, something that can easily happen when printing a value from history or certain registers on AArch64. This patch fixes the bug by changing ada-lang.c to only apply special Ada treatment to types coming from an Ada CU. This in turn required a couple of surprising changes. First, some of the Ada code was already using HAVE_GNAT_AUX_INFO to decide whether a type had already been fixed -- such types had INIT_CPLUS_SPECIFIC called on them. This patch changes these spots to use the "none" identifier instead. This then required changing value_rtti_type to avoid changing the language-specific object attached to an Ada type, which seems like a good change regardless. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-04-19 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_is_variant_part, ada_to_fixed_type_1): Check ADA_TYPE_P. (empty_record, ada_template_to_fixed_record_type_1) (template_to_static_fixed_type) (to_record_with_fixed_variant_part): Use INIT_NONE_SPECIFIC. * cp-abi.c (value_rtti_type): Check HAVE_CPLUS_STRUCT. * gdbtypes.h (INIT_NONE_SPECIFIC, ADA_TYPE_P): New macros. gdb/testsuite/ChangeLog 2019-04-19 Tom Tromey <tromey@adacore.com> * gdb.ada/ptype_union.c: New file. * gdb.ada/ptype_union.exp: New file.
* Allow really large fortran array bounds: TYPE_LENGTH to ULONGESTKeith Seitz2019-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This series is revisit of Siddhesh Poyarekar's patch from back in 2012. The last status on the patch is in the following gdb-patches thread: https://sourceware.org/ml/gdb-patches/2012-08/msg00562.html It appears that Tom approved the patch, but Jan had some issues with a compiler error that made the test fail on -m32 test runs. He wrote up a hand-tweaked .S file to deal with it. Siddesh said he would update tests. Then nothing. Siddesh and Jan have both moved on since. The patch originally required a large precursor patch to work. I have whittled this down to/rewritten the bare minimum, and this first patch is the result, changing the type of TYPE_LENGTH to ULONGEST from unsigned int. The majority of the changes involve changing printf format strings to use %s and pulongest instead of %d. gdb/ChangeLog: * ada-lang.c (ada_template_to_fixed_record_type_1): Use %s/pulongest for TYPE_LENGTH instead of %d in format strings. * ada-typerint.c (ada_print_type): Likewise. * amd64-windows-tdep.c (amd64_windows_store_arg_in_reg): Likewise. * compile/compile-c-support.c (generate_register_struct): Likewise. * gdbtypes.c (recursive_dump_type): Likewise. * gdbtypes.h (struct type) <length>: Change type to ULONGEST. * m2-typeprint.c (m2_array): Use %s/pulongest for TYPE_LENGTH instead of %d in format strings. * riscv-tdep.c (riscv_type_alignment): Cast second argument to std::min to ULONGEST. * symmisc.c (print_symbol): Use %s/pulongest for TYPE_LENGTH instead of %d in format strings. * tracepoint.c (info_scope_command): Likewise. * typeprint.c (print_offset_data::update) (print_offset_data::finish): Likewise. * xtensa-tdep.c (xtensa_store_return_value) (xtensa_push_dummy_call): Likewise.
* Add a more general version of lookup_struct_elt_type.John Baldwin2019-03-121-0/+38
| | | | | | | | | | | | | | | | | | | | | lookup_struct_elt is a new function which returns a tuple of information about a component of a structure or union. The returned tuple contains a pointer to the struct field object for the component as well as a bit offset of that field within the structure. If the field names a field in an anonymous substructure, the offset is the "global" offset relative to the original structure type. If noerr is set, then the returned tuple will set the field pointer to NULL to indicate a missing component rather than throwing an error. lookup_struct_elt_type is now reimplemented in terms of this new function. It simply returns the type of the returned field. gdb/ChangeLog: * gdbtypes.c (lookup_struct_elt): New function. (lookup_struct_elt_type): Reimplement via lookup_struct_elt. * gdbtypes.h (struct struct_elt): New type. (lookup_struct_elt): New prototype.
* Update copyright year range in all GDB files.Joel Brobecker2019-01-011-1/+1
| | | | | | | | | | | | | | | | 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.
* C++ify badness_vector, fix leaksPedro Alves2018-11-211-11/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | badness_vector is currently an open coded vector. This reimplements it as a std::vector. This fixes a few leaks as well: - find_oload_champ is leaking every badness vector calculated bar the one returned. - bv->rank is always leaked, since callers of rank_function only xfree the badness_vector pointer, not bv->rank. gdb/ChangeLog: 2018-11-21 Pedro Alves <palves@redhat.com> * gdbtypes.c (compare_badness): Change type of parameters to const reference. Adjust to badness_vector being a std::vector now. (rank_function): Adjust to badness_vector being a std::vector now. * gdbtypes.h (badness_vector): Now a typedef to std::vector. (LENGTH_MATCH): Delete. (compare_badness): Change type of parameters to const reference. (rank_function): Return a badness_vector by value now. (find_overload_match): Adjust to badness_vector being a std::vector now. Remove cleanups. (find_oload_champ_namespace): 'oload_champ_bv' parameter now a badness_vector pointer. (find_oload_champ_namespace_loop): 'oload_champ_bv' parameter now a badness_vector pointer. Adjust to badness_vector being a std::vector now. Remove cleanups. (find_oload_champ): 'oload_champ_bv' parameter now a badness_vector pointer. Adjust to badness_vector being a std::vector now. Remove cleanups.
* invoke_xmethod & array_viewPedro Alves2018-11-211-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces more pointer+length with gdb::array_view. This time, around invoke_xmethod, and then propagating the fallout around, which inevitably leaks to the overload resolution code. There are several places in the code that want to grab a slice of an array, by advancing the array pointer, and decreasing the length pointer. This patch introduces a pair of new gdb::array_view::slice(...) methods to make that convenient and clear. Unit test included. gdb/ChangeLog: 2018-11-21 Pedro Alves <palves@redhat.com> * common/array-view.h (array_view::splice(size_type, size_t)): New. (array_view::splice(size_type)): New. * eval.c (eval_call, evaluate_funcall): Adjust to use array_view. * extension.c (xmethod_worker::get_arg_types): Adjust to return an std::vector. (xmethod_worker::get_result_type): Adjust to use gdb::array_view. * extension.h: Include "common/array-view.h". (xmethod_worker::invoke): Adjust to use gdb::array_view. (xmethod_worker::get_arg_types): Adjust to return an std::vector. (xmethod_worker::get_result_type): Adjust to use gdb::array_view. (xmethod_worker::do_get_arg_types): Adjust to use std::vector. (xmethod_worker::do_get_result_type): Adjust to use gdb::array_view. * gdbtypes.c (rank_function): Adjust to use gdb::array_view. * gdbtypes.h: Include "common/array-view.h". (rank_function): Adjust to use gdb::array_view. * python/py-xmethods.c (python_xmethod_worker::invoke) (python_xmethod_worker::do_get_arg_types) (python_xmethod_worker::do_get_result_type) (python_xmethod_worker::invoke): Adjust to new interfaces. * valarith.c (value_user_defined_cpp_op, value_user_defined_op) (value_x_binop, value_x_unop): Adjust to use gdb::array_view. * valops.c (find_overload_match, find_oload_champ_namespace) (find_oload_champ_namespace_loop, find_oload_champ): Adjust to use gdb:array_view and the new xmethod_worker interfaces. * value.c (result_type_of_xmethod, call_xmethod): Adjust to use gdb::array_view. * value.h (find_overload_match, result_type_of_xmethod) (call_xmethod): Adjust to use gdb::array_view. * unittests/array-view-selftests.c: Add slicing tests.
* Use unsigned as base type for some enumsTom Tromey2018-10-031-1/+1
| | | | | | | | | | | | | | | | | | | | | -fsanitize=undefined complains about using operator~ on various enum types that are used with DEF_ENUM_FLAGS_TYPE. This patch fixes these problems by explicitly setting the base type for these enums to unsigned. It also adds a static assert to enum_flags to ensure that future enums used this way have an unsigned underlying type. gdb/ChangeLog 2018-10-03 Tom Tromey <tom@tromey.com> * common/enum-flags.h (enum_flags::operator~): Add static assert. * symfile-add-flags.h (enum symfile_add_flag): Use unsigned as base type. * objfile-flags.h (enum objfile_flag): Use unsigned as base type. * gdbtypes.h (enum type_instance_flag_value): Use unsigned as base type. * c-lang.h (enum c_string_type_values): Use unsigned as base type. * btrace.h (enum btrace_thread_flag): Use unsigned as base type.
* gdb: Don't leak memory with TYPE_ALLOC / TYPE_ZALLOCAndrew Burgess2018-09-141-16/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch started as an observation from valgrind that GDB appeared to be loosing track of some memory associated with types. An example valgrind stack would be: 24 bytes in 1 blocks are possibly lost in loss record 419 of 5,361 at 0x4C2EA1E: calloc (vg_replace_malloc.c:711) by 0x623D26: xcalloc (common-utils.c:85) by 0x623D65: xzalloc(unsigned long) (common-utils.c:95) by 0x72A066: make_function_type(type*, type**) (gdbtypes.c:510) by 0x72A098: lookup_function_type(type*) (gdbtypes.c:521) by 0x73635D: gdbtypes_post_init(gdbarch*) (gdbtypes.c:5439) by 0x727590: gdbarch_data(gdbarch*, gdbarch_data*) (gdbarch.c:5230) by 0x735B99: builtin_type(gdbarch*) (gdbtypes.c:5313) by 0x514D95: elf_rel_plt_read(minimal_symbol_reader&, objfile*, bfd_symbol**) (elfread.c:542) by 0x51662F: elf_read_minimal_symbols(objfile*, int, elfinfo const*) (elfread.c:1121) by 0x5168A5: elf_symfile_read(objfile*, enum_flags<symfile_add_flag>) (elfread.c:1207) by 0x8520F5: read_symbols(objfile*, enum_flags<symfile_add_flag>) (symfile.c:794) When we look in make_function_type we find a call to TYPE_ZALLOC (inside the INIT_FUNC_SPECIFIC macro). It is this call to TYPE_ZALLOC that is allocating memory with xcalloc, that is then getting lost. The problem is tht calling TYPE_ALLOC or TYPE_ZALLOC currently allocates memory from either the objfile obstack or by using malloc. The problem with this is that types are allocated either on the objfile obstack, or on the gdbarch obstack. As a result, if we discard a type associated with an objfile then auxiliary data allocated with TYPE_(Z)ALLOC will be correctly discarded. But, if we were ever to discard a gdbarch then any auxiliary type data would be leaked. Right now there are very few places in GDB where a gdbarch is ever discarded, but it shouldn't hurt to close down these bugs as we spot them. This commit ensures that auxiliary type data is allocated from the same obstack as the type itself, which should reduce leaked memory. The one problem case that I found with this change was in eval.c, where in one place we allocate a local type structure, and then used TYPE_ZALLOC to allocate some space for the type. This local type is neither object file owned, nor gdbarch owned, and so the updated TYPE_ALLOC code is unable to find an objstack to allocate space on. My proposed solution for this issue is that the space should be allocated with a direct call to xzalloc. We could extend TYPE_ALLOC to check for type->gdbarch being null, and then fall back to a direct call to xzalloc, however, I think that making this rare case of a local type require special handling is not a bad thing, this serves to highlight that clearing up the memory will require special handling too. This special case of a local type is interesting as the types owner field (contained within the main_type) is completely null. While reflecting on this I looked at how types use the get_type_arch function. It seems clear that, based on how this is used, it is never intended that null will be returned from this function. This only goes to reinforce, how locally alloctaed types, with no owner, are both special, and need to be handled carefully. To help spot errors earlier, I added an assert into get_type_arch that the returned arch is not null. Inside gdbarch.c I found a few other places where auxiliary type data was being allocated directly on the heap rather than on the types obstack. I have fixed these to call TYPE_ALLOC now. Finally, it is worth noting that as we don't clean up our gdbarch objects yet, then this will not make much of an impact on the amount of memory reported as lost at program termination time. Memory allocated for auxiliary type information is still not freed, however, it is now on the correct obstack. If we do ever start freeing our gdbarch structures then the associated type data will be cleaned up correctly. Tested on X86-64 GNU/Linux with no regressions. gdb/ChangeLog: * eval.c (fake_method::fake_method): Call xzalloc directly for a type that is neither object file owned, nor gdbarch owned. * gdbtypes.c (get_type_gdbarch): Add an assert that returned gdbarch is non-NULL. (alloc_type_instance): Allocate non-objfile owned types on the gdbarch obstack. (copy_type_recursive): Allocate TYPE_FIELDS and TYPE_RANGE_DATA using TYPE_ALLOC to ensure memory is allocated on the correct obstack. * gdbtypes.h (TYPE_ALLOC): Allocate space on either the objfile obstack, or the gdbarch obstack. (TYPE_ZALLOC): Rewrite using TYPE_ALLOC.
* gdb: Add builtin types for 24 bit integers.John Darrington2018-09-081-0/+2
| | | | | | | | | | Add int24 and uint24. These are used by the upcoming S12Z target, but will be needed for any arch which features 24 bit registers. * gdb/gdbtypes.h (struct builtin_type): New members builtin_int24 and builtin_uint24; * gdb/gdbtypes.c: Initialize them. * gdb/doc/gdb.texinfo (Predefined Target Types): Mention types int24 and uint24.
* Remove type_name_no_tag and rename type_name_no_tag_or_errorTom Tromey2018-06-011-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove TYPE_TAG_NAMETom Tromey2018-06-011-18/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove a VEC from type.cTom Tromey2018-05-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes a VEC from type.c, by using std::vector. While doing this I also took the opportunity to change types_deeply_equal to return bool. This caught some weird code in typy_richcompare, now fixed. And, since I was changing types_deeply_equal, it seemed like a good idea to also change types_equal, so this patch includes that as well. Tested by the buildbot. ChangeLog 2018-05-29 Tom Tromey <tom@tromey.com> * python/py-type.c (typy_richcompare): Update. * guile/scm-type.c (tyscm_equal_p_type_smob): Update. * gdbtypes.h (types_deeply_equal): Return bool. (types_equal): Likewise. * gdbtypes.c (type_equality_entry_d): Remove typedef. Don't declare VEC. (check_types_equal): Change worklist to std::vector. Return bool. (struct type_equality_entry): Add constructor. (compare_maybe_null_strings): Return bool. (check_types_worklist): Return bool. Change worklist to std::vector. (types_deeply_equal): Use std::vector. (types_equal): Return bool. (compare_maybe_null_strings): Simplify.
* Add initial type alignment supportTom Tromey2018-04-301-1/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds some basic type alignment support to gdb. It changes struct type to store the alignment, and updates dwarf2read.c to handle DW_AT_alignment. It also adds a new gdbarch method and updates i386-tdep.c. None of this new functionality is used anywhere yet, so tests will wait until the next patch. 2018-04-30 Tom Tromey <tom@tromey.com> * i386-tdep.c (i386_type_align): New function. (i386_gdbarch_init): Update. * gdbarch.sh (type_align): New method. * gdbarch.c, gdbarch.h: Rebuild. * arch-utils.h (default_type_align): Declare. * arch-utils.c (default_type_align): New function. * gdbtypes.h (TYPE_ALIGN_BITS): New define. (struct type) <align_log2>: New field. <instance_flags>: Now a bitfield. (TYPE_RAW_ALIGN): New macro. (type_align, type_raw_align, set_type_align): Declare. * gdbtypes.c (type_align, type_raw_align, set_type_align): New functions. * dwarf2read.c (quirk_rust_enum): Set type alignment. (get_alignment, maybe_set_alignment): New functions. (read_structure_type, read_enumeration_type, read_array_type) (read_set_type, read_tag_pointer_type, read_tag_reference_type) (read_subrange_type, read_base_type): Set type alignment.