aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2019-12-20 17:43:06 +0100
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2019-12-20 17:43:06 +0100
commite35000a7f8be021459102751db7e0b7e2868b57e (patch)
treeaa3a333c82cf88c9d3e542142cddca842f7898d2
parentb4b49dcbff6b437fa8b4e2fc0c3f27b457f11310 (diff)
downloadgdb-e35000a7f8be021459102751db7e0b7e2868b57e.zip
gdb-e35000a7f8be021459102751db7e0b7e2868b57e.tar.gz
gdb-e35000a7f8be021459102751db7e0b7e2868b57e.tar.bz2
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
-rw-r--r--gdb/ChangeLog22
-rw-r--r--gdb/dwarf2read.c61
-rw-r--r--gdb/gdbtypes.c7
-rw-r--r--gdb/gdbtypes.h22
4 files changed, 111 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0f35def..5175ebc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,25 @@
+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.
+
2019-12-20 Tom Tromey <tom@tromey.com>
* tui/tui.c (tui_show_source): Remove.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index ecfae68..6492889 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15472,6 +15472,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 (%lu)"), value);
+ return false;
+}
+
/* Add a member function to the proper fieldlist. */
static void
@@ -15584,6 +15603,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 +15852,26 @@ 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 "
+ "(%lu) for a type"), 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 +15953,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)
{
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 0896f71..7e80b45 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -4494,6 +4494,10 @@ dump_fn_fieldlists (struct type *type, int spaces)
TYPE_FN_FIELD_PROTECTED (f, overload_idx));
printfi_filtered (spaces + 8, "is_stub %d\n",
TYPE_FN_FIELD_STUB (f, overload_idx));
+ printfi_filtered (spaces + 8, "defaulted %d\n",
+ TYPE_FN_FIELD_DEFAULTED (f, overload_idx));
+ printfi_filtered (spaces + 8, "is_deleted %d\n",
+ TYPE_FN_FIELD_DELETED (f, overload_idx));
printfi_filtered (spaces + 8, "voffset %u\n",
TYPE_FN_FIELD_VOFFSET (f, overload_idx));
}
@@ -4557,6 +4561,9 @@ print_cplus_stuff (struct type *type, int spaces)
{
dump_fn_fieldlists (type, spaces);
}
+
+ printfi_filtered (spaces, "calling_convention %d\n",
+ TYPE_CPLUS_CALLING_CONVENTION (type));
}
/* Print the contents of the TYPE's type_specific union, assuming that
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index a1d95e0..12fa437 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -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) \