gdb: recognize new DWARF attributes: defaulted, deleted, calling conv.

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
This commit is contained in:
Tankut Baris Aktemur
2019-12-20 17:43:06 +01:00
parent b4b49dcbff
commit e35000a7f8
4 changed files with 111 additions and 1 deletions

View File

@@ -50,6 +50,7 @@
#include "gdbsupport/enum-flags.h"
#include "gdbsupport/underlying.h"
#include "gdbsupport/print-utils.h"
#include "dwarf2.h"
/* Forward declarations for prototypes. */
struct field;
@@ -957,9 +958,18 @@ struct fn_field
unsigned int is_constructor : 1;
/* * True if this function is deleted, false otherwise. */
unsigned int is_deleted : 1;
/* * DW_AT_defaulted attribute for this function. The value is one
of the DW_DEFAULTED constants. */
ENUM_BITFIELD (dwarf_defaulted_attribute) defaulted : 2;
/* * Unused. */
unsigned int dummy:9;
unsigned int dummy:6;
/* * Index into that baseclass's virtual function table, minus 2;
else if static: VOFFSET_STATIC; else: 0. */
@@ -1033,6 +1043,12 @@ struct cplus_struct_type
int is_dynamic : 2;
/* * The calling convention for this type, fetched from the
DW_AT_calling_convention attribute. The value is one of the
DW_CC constants. */
ENUM_BITFIELD (dwarf_calling_convention) calling_convention : 8;
/* * The base class which defined the virtual function table pointer. */
struct type *vptr_basetype;
@@ -1437,6 +1453,8 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
? (struct cplus_struct_type*)&cplus_struct_default \
: TYPE_RAW_CPLUS_SPECIFIC(thistype))
#define TYPE_RAW_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
#define TYPE_CPLUS_CALLING_CONVENTION(thistype) \
TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff->calling_convention
#define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat
#define TYPE_GNAT_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.gnat_stuff
#define TYPE_DESCRIPTIVE_TYPE(thistype) TYPE_GNAT_SPECIFIC(thistype)->descriptive_type
@@ -1553,6 +1571,8 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
#define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2)
#define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1)
#define TYPE_FN_FIELD_STATIC_P(thisfn, n) ((thisfn)[n].voffset == VOFFSET_STATIC)
#define TYPE_FN_FIELD_DEFAULTED(thisfn, n) ((thisfn)[n].defaulted)
#define TYPE_FN_FIELD_DELETED(thisfn, n) ((thisfn)[n].is_deleted)
/* Accessors for typedefs defined by a class. */
#define TYPE_TYPEDEF_FIELD_ARRAY(thistype) \