diff options
author | Tom Tromey <tom@tromey.com> | 2022-05-24 15:17:19 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-07-28 14:16:50 -0600 |
commit | bde539c2f9e19271d6d6c740f875b4129e03eba3 (patch) | |
tree | 0e92a4f02b0411afcf14297bc6c200c69ef62aee /gdb/value.c | |
parent | b382c16682acc33d2e81e5604c9dbd408be376d2 (diff) | |
download | fsf-binutils-gdb-bde539c2f9e19271d6d6c740f875b4129e03eba3.zip fsf-binutils-gdb-bde539c2f9e19271d6d6c740f875b4129e03eba3.tar.gz fsf-binutils-gdb-bde539c2f9e19271d6d6c740f875b4129e03eba3.tar.bz2 |
Change allocation of type-copying hash table
When an objfile is destroyed, types that are still in use and
allocated on that objfile are copied. A temporary hash map is created
during this process, and it is allocated on the destroyed objfile's
obstack -- which normally is fine, as that is going to be destroyed
shortly anyway.
However, this approach requires that the objfile be passed to registry
destruction, and this won't be possible in the rewritten registry.
This patch changes the copied type hash table to simply use the heap
instead. It also removes the 'objfile' parameter from
copy_type_recursive, to make this all more clear.
This patch also fixes an apparent bug in copy_type_recursive.
Previously it was copying the dynamic property list to the dying
objfile's obstack:
- = copy_dynamic_prop_list (&objfile->objfile_obstack,
However I think this is incorrect -- that obstack is about to be
destroyed.
Diffstat (limited to 'gdb/value.c')
-rw-r--r-- | gdb/value.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/gdb/value.c b/gdb/value.c index d027eef..557e221 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2571,11 +2571,10 @@ preserve_one_value (struct value *value, struct objfile *objfile, htab_t copied_types) { if (value->type->objfile_owner () == objfile) - value->type = copy_type_recursive (objfile, value->type, copied_types); + value->type = copy_type_recursive (value->type, copied_types); if (value->enclosing_type->objfile_owner () == objfile) - value->enclosing_type = copy_type_recursive (objfile, - value->enclosing_type, + value->enclosing_type = copy_type_recursive (value->enclosing_type, copied_types); } @@ -2591,7 +2590,7 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile, if (var->u.integer.type && var->u.integer.type->objfile_owner () == objfile) var->u.integer.type - = copy_type_recursive (objfile, var->u.integer.type, copied_types); + = copy_type_recursive (var->u.integer.type, copied_types); break; case INTERNALVAR_VALUE: @@ -2612,7 +2611,7 @@ preserve_one_varobj (struct varobj *varobj, struct objfile *objfile, && varobj->type->objfile_owner () == objfile) { varobj->type - = copy_type_recursive (objfile, varobj->type, copied_types); + = copy_type_recursive (varobj->type, copied_types); } if (varobj->value != nullptr) @@ -2632,7 +2631,7 @@ preserve_values (struct objfile *objfile) /* Create the hash table. We allocate on the objfile's obstack, since it is soon to be deleted. */ - htab_up copied_types = create_copied_types_hash (objfile); + htab_up copied_types = create_copied_types_hash (); for (const value_ref_ptr &item : value_history) preserve_one_value (item.get (), objfile, copied_types.get ()); |