Support restrict qualifier in dwarf debug info
Newer clang/llvm emit DW_TAG_restrict_type, which wasn't handled by gdb. Import support from Apple's gdb-1822: | 2009-03-24 Jason Molenda (jmolenda@apple.com) | | * gdbtypes.c (make_cv_type): Rename this function to make_cvr_type to | also handle restrict qualifiers. | (check_typedef): Handle TYPE_RESTRICT. | * gdbtypes.h (TYPE_FLAG_RESTRICT, TYPE_RESTRICT): New. | * hpread.c (hpread_type_lookup): Update to use make_cvr_type. | * stabsread.c (read_type): Pass the restrict qualifiers along. | * parse.c (follow_types): Pass the restrict qualifiers along. | * dwarf2read.c (read_tag_const_type): Call make_cvr_type. | (read_tag_volatile_type): Same. | (read_tag_restrict_type): New function. | (read_type_die): Handle DW_TAG_restrict_type. Obtained from: Apple Sponsored by: ADARA Networks
This commit is contained in:
parent
07a8e07896
commit
6b926c8f45
@ -834,6 +834,8 @@ static void read_tag_const_type (struct die_info *, struct dwarf2_cu *);
|
||||
|
||||
static void read_tag_volatile_type (struct die_info *, struct dwarf2_cu *);
|
||||
|
||||
static void read_tag_restrict_type (struct die_info *, struct dwarf2_cu *);
|
||||
|
||||
static void read_tag_string_type (struct die_info *, struct dwarf2_cu *);
|
||||
|
||||
static void read_subroutine_type (struct die_info *, struct dwarf2_cu *);
|
||||
@ -3729,7 +3731,8 @@ read_tag_const_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
}
|
||||
|
||||
base_type = die_type (die, cu);
|
||||
die->type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type, 0);
|
||||
die->type = make_cvr_type (1, TYPE_VOLATILE (base_type),
|
||||
TYPE_RESTRICT (base_type), base_type, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3743,7 +3746,23 @@ read_tag_volatile_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
}
|
||||
|
||||
base_type = die_type (die, cu);
|
||||
die->type = make_cv_type (TYPE_CONST (base_type), 1, base_type, 0);
|
||||
die->type = make_cvr_type (TYPE_CONST (base_type), 1,
|
||||
TYPE_RESTRICT (base_type), base_type, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
read_tag_restrict_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
{
|
||||
struct type *base_type;
|
||||
|
||||
if (die->type)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base_type = die_type (die, cu);
|
||||
die->type = make_cvr_type (TYPE_CONST (base_type), TYPE_VOLATILE (base_type),
|
||||
1, base_type, 0);
|
||||
}
|
||||
|
||||
/* Extract all information from a DW_TAG_string_type DIE and add to
|
||||
@ -6086,6 +6105,9 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu)
|
||||
case DW_TAG_volatile_type:
|
||||
read_tag_volatile_type (die, cu);
|
||||
break;
|
||||
case DW_TAG_restrict_type:
|
||||
read_tag_restrict_type (die, cu);
|
||||
break;
|
||||
case DW_TAG_string_type:
|
||||
read_tag_string_type (die, cu);
|
||||
break;
|
||||
|
@ -502,7 +502,8 @@ make_type_with_address_space (struct type *type, int space_flag)
|
||||
We allocate new memory if needed. */
|
||||
|
||||
struct type *
|
||||
make_cv_type (int cnst, int voltl, struct type *type, struct type **typeptr)
|
||||
make_cvr_type (int cnst, int voltl, int restrct, struct type *type,
|
||||
struct type **typeptr)
|
||||
{
|
||||
struct type *ntype; /* New type */
|
||||
struct type *tmp_type = type; /* tmp type */
|
||||
@ -517,6 +518,9 @@ make_cv_type (int cnst, int voltl, struct type *type, struct type **typeptr)
|
||||
if (voltl)
|
||||
new_flags |= TYPE_FLAG_VOLATILE;
|
||||
|
||||
if (restrct)
|
||||
new_flags |= TYPE_FLAG_RESTRICT;
|
||||
|
||||
if (typeptr && *typeptr != NULL)
|
||||
{
|
||||
/* Objfile is per-core-type. This const-qualified type had best
|
||||
@ -1371,7 +1375,7 @@ struct type *
|
||||
check_typedef (struct type *type)
|
||||
{
|
||||
struct type *orig_type = type;
|
||||
int is_const, is_volatile;
|
||||
int is_const, is_volatile, is_restrict;
|
||||
|
||||
while (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
|
||||
{
|
||||
@ -1407,6 +1411,7 @@ check_typedef (struct type *type)
|
||||
|
||||
is_const = TYPE_CONST (type);
|
||||
is_volatile = TYPE_VOLATILE (type);
|
||||
is_restrict = TYPE_RESTRICT (type);
|
||||
|
||||
/* If this is a struct/class/union with no fields, then check whether a
|
||||
full definition exists somewhere else. This is for systems where a
|
||||
@ -1424,7 +1429,7 @@ check_typedef (struct type *type)
|
||||
}
|
||||
newtype = lookup_transparent_type (name);
|
||||
if (newtype)
|
||||
make_cv_type (is_const, is_volatile, newtype, &type);
|
||||
make_cvr_type (is_const, is_volatile, is_restrict, newtype, &type);
|
||||
}
|
||||
/* Otherwise, rely on the stub flag being set for opaque/stubbed types */
|
||||
else if (TYPE_STUB (type) && !currently_reading_symtab)
|
||||
@ -1442,7 +1447,8 @@ check_typedef (struct type *type)
|
||||
}
|
||||
sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);
|
||||
if (sym)
|
||||
make_cv_type (is_const, is_volatile, SYMBOL_TYPE (sym), &type);
|
||||
make_cvr_type (is_const, is_volatile, is_restrict, SYMBOL_TYPE (sym),
|
||||
&type);
|
||||
}
|
||||
|
||||
if (TYPE_TARGET_STUB (type))
|
||||
|
@ -273,6 +273,13 @@ enum type_code
|
||||
#define TYPE_ADDRESS_CLASS_ALL(t) (TYPE_INSTANCE_FLAGS(t) \
|
||||
& TYPE_FLAG_ADDRESS_CLASS_ALL)
|
||||
|
||||
/* Restrict type. If this is set, the corresponding type has a
|
||||
* restrict modifier.
|
||||
*/
|
||||
|
||||
#define TYPE_FLAG_RESTRICT (1 << 17)
|
||||
#define TYPE_RESTRICT(t) (TYPE_INSTANCE_FLAGS (t) & TYPE_FLAG_RESTRICT)
|
||||
|
||||
/* Array bound type. */
|
||||
enum array_bound_type
|
||||
{
|
||||
@ -1099,7 +1106,8 @@ extern struct type *lookup_reference_type (struct type *);
|
||||
|
||||
extern struct type *make_reference_type (struct type *, struct type **);
|
||||
|
||||
extern struct type *make_cv_type (int, int, struct type *, struct type **);
|
||||
extern struct type *make_cvr_type (int, int, int, struct type *,
|
||||
struct type **);
|
||||
|
||||
extern void replace_type (struct type *, struct type *);
|
||||
|
||||
|
@ -4939,8 +4939,9 @@ hpread_type_lookup (dnttpointer hp_type, struct objfile *objfile)
|
||||
* "m_void" modifiers? Is static_flag really needed here?
|
||||
* (m_static used for methods of classes, elsewhere).
|
||||
*/
|
||||
tmp_type = make_cv_type (dn_bufp->dmodifier.m_const,
|
||||
tmp_type = make_cvr_type (dn_bufp->dmodifier.m_const,
|
||||
dn_bufp->dmodifier.m_volatile,
|
||||
0,
|
||||
hpread_type_lookup (dn_bufp->dmodifier.type, objfile),
|
||||
0);
|
||||
return tmp_type;
|
||||
|
@ -1167,13 +1167,15 @@ follow_types (struct type *follow_type)
|
||||
case tp_end:
|
||||
done = 1;
|
||||
if (make_const)
|
||||
follow_type = make_cv_type (make_const,
|
||||
TYPE_VOLATILE (follow_type),
|
||||
follow_type, 0);
|
||||
follow_type = make_cvr_type (make_const,
|
||||
TYPE_VOLATILE (follow_type),
|
||||
TYPE_RESTRICT (follow_type),
|
||||
follow_type, 0);
|
||||
if (make_volatile)
|
||||
follow_type = make_cv_type (TYPE_CONST (follow_type),
|
||||
make_volatile,
|
||||
follow_type, 0);
|
||||
follow_type = make_cvr_type (TYPE_CONST (follow_type),
|
||||
make_volatile,
|
||||
TYPE_RESTRICT (follow_type),
|
||||
follow_type, 0);
|
||||
if (make_addr_space)
|
||||
follow_type = make_type_with_address_space (follow_type,
|
||||
make_addr_space);
|
||||
@ -1192,13 +1194,15 @@ follow_types (struct type *follow_type)
|
||||
case tp_pointer:
|
||||
follow_type = lookup_pointer_type (follow_type);
|
||||
if (make_const)
|
||||
follow_type = make_cv_type (make_const,
|
||||
TYPE_VOLATILE (follow_type),
|
||||
follow_type, 0);
|
||||
follow_type = make_cvr_type (make_const,
|
||||
TYPE_VOLATILE (follow_type),
|
||||
TYPE_RESTRICT (follow_type),
|
||||
follow_type, 0);
|
||||
if (make_volatile)
|
||||
follow_type = make_cv_type (TYPE_CONST (follow_type),
|
||||
make_volatile,
|
||||
follow_type, 0);
|
||||
follow_type = make_cvr_type (TYPE_CONST (follow_type),
|
||||
make_volatile,
|
||||
TYPE_RESTRICT (follow_type),
|
||||
follow_type, 0);
|
||||
if (make_addr_space)
|
||||
follow_type = make_type_with_address_space (follow_type,
|
||||
make_addr_space);
|
||||
@ -1208,13 +1212,15 @@ follow_types (struct type *follow_type)
|
||||
case tp_reference:
|
||||
follow_type = lookup_reference_type (follow_type);
|
||||
if (make_const)
|
||||
follow_type = make_cv_type (make_const,
|
||||
TYPE_VOLATILE (follow_type),
|
||||
follow_type, 0);
|
||||
follow_type = make_cvr_type (make_const,
|
||||
TYPE_VOLATILE (follow_type),
|
||||
TYPE_RESTRICT (follow_type),
|
||||
follow_type, 0);
|
||||
if (make_volatile)
|
||||
follow_type = make_cv_type (TYPE_CONST (follow_type),
|
||||
make_volatile,
|
||||
follow_type, 0);
|
||||
follow_type = make_cvr_type (TYPE_CONST (follow_type),
|
||||
make_volatile,
|
||||
TYPE_RESTRICT (follow_type),
|
||||
follow_type, 0);
|
||||
if (make_addr_space)
|
||||
follow_type = make_type_with_address_space (follow_type,
|
||||
make_addr_space);
|
||||
|
@ -1750,13 +1750,13 @@ again:
|
||||
|
||||
case 'k': /* Const qualifier on some type (Sun) */
|
||||
type = read_type (pp, objfile);
|
||||
type = make_cv_type (1, TYPE_VOLATILE (type), type,
|
||||
type = make_cvr_type (1, TYPE_VOLATILE (type), TYPE_RESTRICT(type), type,
|
||||
dbx_lookup_type (typenums));
|
||||
break;
|
||||
|
||||
case 'B': /* Volatile qual on some type (Sun) */
|
||||
type = read_type (pp, objfile);
|
||||
type = make_cv_type (TYPE_CONST (type), 1, type,
|
||||
type = make_cvr_type (TYPE_CONST (type), 1, TYPE_RESTRICT(type), type,
|
||||
dbx_lookup_type (typenums));
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user