From 5a1e8c7a83c17df130a48fb0a736cde6f22bfca9 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Thu, 13 Mar 2014 09:55:12 -0700 Subject: [PATCH] Fix pr 16612. * guile/scm-type.c (tyscm_copy_type_recursive): Move type to its new eq?-hashtab. testsuite/ * gdb.guile/scm-value.ep (test_value_after_death): Do a garbage collect after discarding symbols. --- gdb/ChangeLog | 6 ++++++ gdb/guile/scm-type.c | 19 +++++++++++++++++++ gdb/testsuite/ChangeLog | 6 ++++++ gdb/testsuite/gdb.guile/scm-value.exp | 3 +++ 4 files changed, 34 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f997cd649e..67cc7ddf13 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2014-03-13 Doug Evans + + PR guile/16612 + * guile/scm-type.c (tyscm_copy_type_recursive): Move type to its + new eq?-hashtab. + 2014-03-13 Doug Evans * value.c (record_latest_value): Call release_value_or_incref diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index 4fa0c28ed8..9345c2845f 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -363,11 +363,30 @@ tyscm_copy_type_recursive (void **slot, void *info) type_smob *t_smob = (type_smob *) *slot; htab_t copied_types = info; struct objfile *objfile = TYPE_OBJFILE (t_smob->type); + htab_t htab; + eqable_gdb_smob **new_slot; + type_smob t_smob_for_lookup; gdb_assert (objfile != NULL); htab_empty (copied_types); t_smob->type = copy_type_recursive (objfile, t_smob->type, copied_types); + + /* The eq?-hashtab that the type lived in is going away. + Add the type to its new eq?-hashtab: Otherwise if/when the type is later + garbage collected we'll assert-fail if the type isn't in the hashtab. + PR 16612. + + Types now live in "arch space", and things like "char" that came from + the objfile *could* be considered eq? with the arch "char" type. + However, they weren't before the objfile got deleted, so making them + eq? now is debatable. */ + htab = tyscm_type_map (t_smob->type); + t_smob_for_lookup.type = t_smob->type; + new_slot = gdbscm_find_eqable_gsmob_ptr_slot (htab, &t_smob_for_lookup.base); + gdb_assert (*new_slot == NULL); + gdbscm_fill_eqable_gsmob_ptr_slot (new_slot, &t_smob->base); + return 1; } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 78be1f7533..1ebde9b580 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-03-13 Doug Evans + + PR guile/16612 + * gdb.guile/scm-value.ep (test_value_after_death): Do a garbage + collect after discarding symbols. + 2014-03-13 Ludovic Courtès Doug Evans diff --git a/gdb/testsuite/gdb.guile/scm-value.exp b/gdb/testsuite/gdb.guile/scm-value.exp index a85d5bda9e..0bcd3816c6 100644 --- a/gdb/testsuite/gdb.guile/scm-value.exp +++ b/gdb/testsuite/gdb.guile/scm-value.exp @@ -286,6 +286,9 @@ proc test_value_after_death {} { "Discard symbol table from.*y or n. $" \ "y" + # First do a garbage collect to delete anything unused. PR 16612. + gdb_scm_test_silent_cmd "gu (gc)" "garbage collect" + # Now create a value using that type. Relies on arg0, created by # test_value_in_inferior. gdb_scm_test_silent_cmd "gu (define castval (value-cast arg0 (type-pointer ptrtype)))" \