Be more strict about what kinds of types can be passed.
gdb/ChangeLog: * gnu-v3-abi.c (gnuv3_dynamic_class): Assert only passed structs or unions. Return zero if union. (gnuv3_get_vtable): Call check_typedef. Assert only passed structs. (gnuv3_rtti_type): Pass already-check_typedef'd value to gnuv3_get_vtable. (compute_vtable_size): Assert only passed structs. (gnuv3_print_vtable): Don't call gnuv3_get_vtable for non-structs.
This commit is contained in:
parent
f6b3afbf2f
commit
5f4ce105ed
2 changed files with 28 additions and 4 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2015-01-31 Doug Evans <xdje42@gmail.com>
|
||||||
|
|
||||||
|
* gnu-v3-abi.c (gnuv3_dynamic_class): Assert only passed structs
|
||||||
|
or unions. Return zero if union.
|
||||||
|
(gnuv3_get_vtable): Call check_typedef. Assert only passed structs.
|
||||||
|
(gnuv3_rtti_type): Pass already-check_typedef'd value to
|
||||||
|
gnuv3_get_vtable.
|
||||||
|
(compute_vtable_size): Assert only passed structs.
|
||||||
|
(gnuv3_print_vtable): Don't call gnuv3_get_vtable for non-structs.
|
||||||
|
|
||||||
2015-01-31 Doug Evans <xdje42@gmail.com>
|
2015-01-31 Doug Evans <xdje42@gmail.com>
|
||||||
|
|
||||||
* gdbtypes.c (copy_type_recursive): Handle all TYPE_SPECIFIC_FIELD
|
* gdbtypes.c (copy_type_recursive): Handle all TYPE_SPECIFIC_FIELD
|
||||||
|
|
|
@ -202,6 +202,12 @@ gnuv3_dynamic_class (struct type *type)
|
||||||
{
|
{
|
||||||
int fieldnum, fieldelem;
|
int fieldnum, fieldelem;
|
||||||
|
|
||||||
|
gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT
|
||||||
|
|| TYPE_CODE (type) == TYPE_CODE_UNION);
|
||||||
|
|
||||||
|
if (TYPE_CODE (type) == TYPE_CODE_UNION)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (TYPE_CPLUS_DYNAMIC (type))
|
if (TYPE_CPLUS_DYNAMIC (type))
|
||||||
return TYPE_CPLUS_DYNAMIC (type) == 1;
|
return TYPE_CPLUS_DYNAMIC (type) == 1;
|
||||||
|
|
||||||
|
@ -246,9 +252,12 @@ gnuv3_get_vtable (struct gdbarch *gdbarch,
|
||||||
struct value *vtable_pointer;
|
struct value *vtable_pointer;
|
||||||
CORE_ADDR vtable_address;
|
CORE_ADDR vtable_address;
|
||||||
|
|
||||||
|
CHECK_TYPEDEF (container_type);
|
||||||
|
gdb_assert (TYPE_CODE (container_type) == TYPE_CODE_STRUCT);
|
||||||
|
|
||||||
/* If this type does not have a virtual table, don't read the first
|
/* If this type does not have a virtual table, don't read the first
|
||||||
field. */
|
field. */
|
||||||
if (!gnuv3_dynamic_class (check_typedef (container_type)))
|
if (!gnuv3_dynamic_class (container_type))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* We do not consult the debug information to find the virtual table.
|
/* We do not consult the debug information to find the virtual table.
|
||||||
|
@ -301,7 +310,7 @@ gnuv3_rtti_type (struct value *value,
|
||||||
if (using_enc_p)
|
if (using_enc_p)
|
||||||
*using_enc_p = 0;
|
*using_enc_p = 0;
|
||||||
|
|
||||||
vtable = gnuv3_get_vtable (gdbarch, value_type (value),
|
vtable = gnuv3_get_vtable (gdbarch, values_type,
|
||||||
value_as_address (value_addr (value)));
|
value_as_address (value_addr (value)));
|
||||||
if (vtable == NULL)
|
if (vtable == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -821,6 +830,8 @@ compute_vtable_size (htab_t offset_hash,
|
||||||
void **slot;
|
void **slot;
|
||||||
struct value_and_voffset search_vo, *current_vo;
|
struct value_and_voffset search_vo, *current_vo;
|
||||||
|
|
||||||
|
gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT);
|
||||||
|
|
||||||
/* If the object is not dynamic, then we are done; as it cannot have
|
/* If the object is not dynamic, then we are done; as it cannot have
|
||||||
dynamic base types either. */
|
dynamic base types either. */
|
||||||
if (!gnuv3_dynamic_class (type))
|
if (!gnuv3_dynamic_class (type))
|
||||||
|
@ -949,8 +960,11 @@ gnuv3_print_vtable (struct value *value)
|
||||||
}
|
}
|
||||||
|
|
||||||
gdbarch = get_type_arch (type);
|
gdbarch = get_type_arch (type);
|
||||||
vtable = gnuv3_get_vtable (gdbarch, type,
|
|
||||||
value_as_address (value_addr (value)));
|
vtable = NULL;
|
||||||
|
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
|
||||||
|
vtable = gnuv3_get_vtable (gdbarch, type,
|
||||||
|
value_as_address (value_addr (value)));
|
||||||
|
|
||||||
if (!vtable)
|
if (!vtable)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue