Use htab_up in type copying
This changes create_copied_types_hash to return an htab_up, then modifies the callers to avoid explicit use of htab_delete. gdb/ChangeLog 2020-09-17 Tom Tromey <tom@tromey.com> * value.c (preserve_values): Update. * python/py-type.c (save_objfile_types): Update. * guile/scm-type.c (save_objfile_types): Update. * gdbtypes.h (create_copied_types_hash): Return htab_up. * gdbtypes.c (create_copied_types_hash): Return htab_up. * compile/compile-object-run.c (compile_object_run): Update.
This commit is contained in:
parent
fa9b11648c
commit
6108fd1823
7 changed files with 27 additions and 28 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2020-09-17 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* value.c (preserve_values): Update.
|
||||||
|
* python/py-type.c (save_objfile_types): Update.
|
||||||
|
* guile/scm-type.c (save_objfile_types): Update.
|
||||||
|
* gdbtypes.h (create_copied_types_hash): Return htab_up.
|
||||||
|
* gdbtypes.c (create_copied_types_hash): Return htab_up.
|
||||||
|
* compile/compile-object-run.c (compile_object_run): Update.
|
||||||
|
|
||||||
2020-09-17 Tom Tromey <tom@tromey.com>
|
2020-09-17 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* typeprint.h (class typedef_hash_table) <~typedef_hash_table>:
|
* typeprint.h (class typedef_hash_table) <~typedef_hash_table>:
|
||||||
|
|
|
@ -140,14 +140,12 @@ compile_object_run (struct compile_module *module)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
struct type *func_type = SYMBOL_TYPE (func_sym);
|
struct type *func_type = SYMBOL_TYPE (func_sym);
|
||||||
htab_t copied_types;
|
|
||||||
int current_arg = 0;
|
int current_arg = 0;
|
||||||
struct value **vargs;
|
struct value **vargs;
|
||||||
|
|
||||||
/* OBJFILE may disappear while FUNC_TYPE still will be in use. */
|
/* OBJFILE may disappear while FUNC_TYPE still will be in use. */
|
||||||
copied_types = create_copied_types_hash (objfile);
|
htab_up copied_types = create_copied_types_hash (objfile);
|
||||||
func_type = copy_type_recursive (objfile, func_type, copied_types);
|
func_type = copy_type_recursive (objfile, func_type, copied_types.get ());
|
||||||
htab_delete (copied_types);
|
|
||||||
|
|
||||||
gdb_assert (func_type->code () == TYPE_CODE_FUNC);
|
gdb_assert (func_type->code () == TYPE_CODE_FUNC);
|
||||||
func_val = value_from_pointer (lookup_pointer_type (func_type),
|
func_val = value_from_pointer (lookup_pointer_type (func_type),
|
||||||
|
|
|
@ -5227,13 +5227,13 @@ type_pair_eq (const void *item_lhs, const void *item_rhs)
|
||||||
types without duplicates. We use OBJFILE's obstack, because
|
types without duplicates. We use OBJFILE's obstack, because
|
||||||
OBJFILE is about to be deleted. */
|
OBJFILE is about to be deleted. */
|
||||||
|
|
||||||
htab_t
|
htab_up
|
||||||
create_copied_types_hash (struct objfile *objfile)
|
create_copied_types_hash (struct objfile *objfile)
|
||||||
{
|
{
|
||||||
return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
|
return htab_up (htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
|
||||||
NULL, &objfile->objfile_obstack,
|
NULL, &objfile->objfile_obstack,
|
||||||
hashtab_obstack_allocate,
|
hashtab_obstack_allocate,
|
||||||
dummy_obstack_deallocate);
|
dummy_obstack_deallocate));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Recursively copy (deep copy) a dynamic attribute list of a type. */
|
/* Recursively copy (deep copy) a dynamic attribute list of a type. */
|
||||||
|
|
|
@ -2472,7 +2472,7 @@ extern int class_or_union_p (const struct type *);
|
||||||
|
|
||||||
extern void maintenance_print_type (const char *, int);
|
extern void maintenance_print_type (const char *, int);
|
||||||
|
|
||||||
extern htab_t create_copied_types_hash (struct objfile *objfile);
|
extern htab_up create_copied_types_hash (struct objfile *objfile);
|
||||||
|
|
||||||
extern struct type *copy_type_recursive (struct objfile *objfile,
|
extern struct type *copy_type_recursive (struct objfile *objfile,
|
||||||
struct type *type,
|
struct type *type,
|
||||||
|
|
|
@ -387,20 +387,17 @@ static void
|
||||||
save_objfile_types (struct objfile *objfile, void *datum)
|
save_objfile_types (struct objfile *objfile, void *datum)
|
||||||
{
|
{
|
||||||
htab_t htab = (htab_t) datum;
|
htab_t htab = (htab_t) datum;
|
||||||
htab_t copied_types;
|
|
||||||
|
|
||||||
if (!gdb_scheme_initialized)
|
if (!gdb_scheme_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
copied_types = create_copied_types_hash (objfile);
|
htab_up copied_types = create_copied_types_hash (objfile);
|
||||||
|
|
||||||
if (htab != NULL)
|
if (htab != NULL)
|
||||||
{
|
{
|
||||||
htab_traverse_noresize (htab, tyscm_copy_type_recursive, copied_types);
|
htab_traverse_noresize (htab, tyscm_copy_type_recursive, copied_types.get ());
|
||||||
htab_delete (htab);
|
htab_delete (htab);
|
||||||
}
|
}
|
||||||
|
|
||||||
htab_delete (copied_types);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Administrivia for field smobs. */
|
/* Administrivia for field smobs. */
|
||||||
|
|
|
@ -1066,7 +1066,6 @@ static void
|
||||||
save_objfile_types (struct objfile *objfile, void *datum)
|
save_objfile_types (struct objfile *objfile, void *datum)
|
||||||
{
|
{
|
||||||
type_object *obj = (type_object *) datum;
|
type_object *obj = (type_object *) datum;
|
||||||
htab_t copied_types;
|
|
||||||
|
|
||||||
if (!gdb_python_initialized)
|
if (!gdb_python_initialized)
|
||||||
return;
|
return;
|
||||||
|
@ -1075,23 +1074,22 @@ save_objfile_types (struct objfile *objfile, void *datum)
|
||||||
operating on. */
|
operating on. */
|
||||||
gdbpy_enter enter_py (objfile->arch (), current_language);
|
gdbpy_enter enter_py (objfile->arch (), current_language);
|
||||||
|
|
||||||
copied_types = create_copied_types_hash (objfile);
|
htab_up copied_types = create_copied_types_hash (objfile);
|
||||||
|
|
||||||
while (obj)
|
while (obj)
|
||||||
{
|
{
|
||||||
type_object *next = obj->next;
|
type_object *next = obj->next;
|
||||||
|
|
||||||
htab_empty (copied_types);
|
htab_empty (copied_types.get ());
|
||||||
|
|
||||||
obj->type = copy_type_recursive (objfile, obj->type, copied_types);
|
obj->type = copy_type_recursive (objfile, obj->type,
|
||||||
|
copied_types.get ());
|
||||||
|
|
||||||
obj->next = NULL;
|
obj->next = NULL;
|
||||||
obj->prev = NULL;
|
obj->prev = NULL;
|
||||||
|
|
||||||
obj = next;
|
obj = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
htab_delete (copied_types);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
11
gdb/value.c
11
gdb/value.c
|
@ -2519,22 +2519,19 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile,
|
||||||
void
|
void
|
||||||
preserve_values (struct objfile *objfile)
|
preserve_values (struct objfile *objfile)
|
||||||
{
|
{
|
||||||
htab_t copied_types;
|
|
||||||
struct internalvar *var;
|
struct internalvar *var;
|
||||||
|
|
||||||
/* Create the hash table. We allocate on the objfile's obstack, since
|
/* Create the hash table. We allocate on the objfile's obstack, since
|
||||||
it is soon to be deleted. */
|
it is soon to be deleted. */
|
||||||
copied_types = create_copied_types_hash (objfile);
|
htab_up copied_types = create_copied_types_hash (objfile);
|
||||||
|
|
||||||
for (const value_ref_ptr &item : value_history)
|
for (const value_ref_ptr &item : value_history)
|
||||||
preserve_one_value (item.get (), objfile, copied_types);
|
preserve_one_value (item.get (), objfile, copied_types.get ());
|
||||||
|
|
||||||
for (var = internalvars; var; var = var->next)
|
for (var = internalvars; var; var = var->next)
|
||||||
preserve_one_internalvar (var, objfile, copied_types);
|
preserve_one_internalvar (var, objfile, copied_types.get ());
|
||||||
|
|
||||||
preserve_ext_lang_values (objfile, copied_types);
|
preserve_ext_lang_values (objfile, copied_types.get ());
|
||||||
|
|
||||||
htab_delete (copied_types);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue