X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fdwarf2read.c;h=d6471e5bc316b6185a427c585e8c3cd23b68aaf9;hb=3318ac0e53a673f9989f5e9bbaa9d1c5d536f4e5;hp=85ac324cc42966f1ccbe821e95673da7d56486d1;hpb=95655446a6f136b654fa5fe1ff6fa2b7466a3545;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 85ac324cc4..d6471e5bc3 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1,6 +1,7 @@ /* DWARF 2 debugging format support for GDB. - Copyright (C) 1994-2019 Free Software Foundation, Inc. + Copyright (C) 1994-2020 Free Software Foundation, Inc. + Copyright (C) 2019-2020 Advanced Micro Devices, Inc. All rights reserved. Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology, Inc. with support from Florida State University (under contract @@ -9953,7 +9954,7 @@ fixup_go_packaging (struct dwarf2_cu *cu) sym = allocate_symbol (objfile); sym->set_language (language_go, &objfile->objfile_obstack); - SYMBOL_SET_NAMES (sym, saved_package_name, false, objfile); + sym->compute_and_set_names (saved_package_name, false, objfile->per_bfd); /* This is not VAR_DOMAIN because we want a way to ensure a lookup of, e.g., "main" finds the "main" module and not C's main(). */ SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN; @@ -10878,7 +10879,7 @@ dwarf2_compute_name (const char *name, /* For Fortran GDB prefers DW_AT_*linkage_name for the physname if present but otherwise compute it by typename_concat inside GDB. FIXME: Actually this is not really true, or at least not always true. - It's all very confusing. SYMBOL_SET_NAMES doesn't try to demangle + It's all very confusing. compute_and_set_names doesn't try to demangle Fortran names because there is no mangling standard. So new_symbol will set the demangled name to the result of dwarf2_full_name, and it is the demangled name that GDB uses if it exists. */ @@ -15472,6 +15473,25 @@ dwarf2_is_constructor (struct die_info *die, struct dwarf2_cu *cu) && (type_name[len] == '\0' || type_name[len] == '<')); } +/* Check if the given VALUE is a recognized enum + dwarf_defaulted_attribute constant according to DWARF5 spec, + Table 7.24. */ + +static bool +is_valid_DW_AT_defaulted (ULONGEST value) +{ + switch (value) + { + case DW_DEFAULTED_no: + case DW_DEFAULTED_in_class: + case DW_DEFAULTED_out_of_class: + return true; + } + + complaint (_("unrecognized DW_AT_defaulted value (%s)"), pulongest (value)); + return false; +} + /* Add a member function to the proper fieldlist. */ static void @@ -15584,6 +15604,16 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, if (attr && DW_UNSND (attr) != 0) fnp->is_artificial = 1; + /* Check for defaulted methods. */ + attr = dwarf2_attr (die, DW_AT_defaulted, cu); + if (attr != nullptr && is_valid_DW_AT_defaulted (DW_UNSND (attr))) + fnp->defaulted = (enum dwarf_defaulted_attribute) DW_UNSND (attr); + + /* Check for deleted methods. */ + attr = dwarf2_attr (die, DW_AT_deleted, cu); + if (attr != nullptr && DW_UNSND (attr) != 0) + fnp->is_deleted = 1; + fnp->is_constructor = dwarf2_is_constructor (die, cu); /* Get index in virtual function table if it is a virtual member @@ -15823,6 +15853,52 @@ maybe_set_alignment (struct dwarf2_cu *cu, struct die_info *die, objfile_name (cu->per_cu->dwarf2_per_objfile->objfile)); } +/* Check if the given VALUE is a valid enum dwarf_calling_convention + constant for a type, according to DWARF5 spec, Table 5.5. */ + +static bool +is_valid_DW_AT_calling_convention_for_type (ULONGEST value) +{ + switch (value) + { + case DW_CC_normal: + case DW_CC_pass_by_reference: + case DW_CC_pass_by_value: + return true; + + default: + complaint (_("unrecognized DW_AT_calling_convention value " + "(%s) for a type"), pulongest (value)); + return false; + } +} + +/* Check if the given VALUE is a valid enum dwarf_calling_convention + constant for a subroutine, according to DWARF5 spec, Table 3.3, and + also according to GNU-specific values (see include/dwarf2.h). */ + +static bool +is_valid_DW_AT_calling_convention_for_subroutine (ULONGEST value) +{ + switch (value) + { + case DW_CC_normal: + case DW_CC_program: + case DW_CC_nocall: + return true; + + case DW_CC_GNU_renesas_sh: + case DW_CC_GNU_borland_fastcall_i386: + case DW_CC_GDB_IBM_OpenCL: + return true; + + default: + complaint (_("unrecognized DW_AT_calling_convention value " + "(%s) for a subroutine"), pulongest (value)); + return false; + } +} + /* Called when we find the DIE that starts a structure or union scope (definition) to create a type for the structure or union. Fill in the type's name and general properties; the members will not be @@ -15904,6 +15980,18 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) if (cu->language == language_cplus && die->tag == DW_TAG_class_type) TYPE_DECLARED_CLASS (type) = 1; + /* Store the calling convention in the type if it's available in + the die. Otherwise the calling convention remains set to + the default value DW_CC_normal. */ + attr = dwarf2_attr (die, DW_AT_calling_convention, cu); + if (attr != nullptr + && is_valid_DW_AT_calling_convention_for_type (DW_UNSND (attr))) + { + ALLOCATE_CPLUS_STRUCT_TYPE (type); + TYPE_CPLUS_CALLING_CONVENTION (type) + = (enum dwarf_calling_convention) (DW_UNSND (attr)); + } + attr = dwarf2_attr (die, DW_AT_byte_size, cu); if (attr != nullptr) { @@ -17479,8 +17567,10 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) the subroutine die. Otherwise set the calling convention to the default value DW_CC_normal. */ attr = dwarf2_attr (die, DW_AT_calling_convention, cu); - if (attr != nullptr) - TYPE_CALLING_CONVENTION (ftype) = DW_UNSND (attr); + if (attr != nullptr + && is_valid_DW_AT_calling_convention_for_subroutine (DW_UNSND (attr))) + TYPE_CALLING_CONVENTION (ftype) + = (enum dwarf_calling_convention) (DW_UNSND (attr)); else if (cu->producer && strstr (cu->producer, "IBM XL C for OpenCL")) TYPE_CALLING_CONVENTION (ftype) = DW_CC_GDB_IBM_OpenCL; else @@ -21784,7 +21874,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, /* Cache this symbol's name and the name's demangled form (if any). */ sym->set_language (cu->language, &objfile->objfile_obstack); linkagename = dwarf2_physname (name, die, cu); - SYMBOL_SET_NAMES (sym, linkagename, false, objfile); + sym->compute_and_set_names (linkagename, false, objfile->per_bfd); /* Fortran does not have mangling standard and the mangling does differ between gfortran, iFort etc. */