Skip to content

Commit e5ff806

Browse files
committed
Collect additional images and collect missing dynamic classes from MonoImage->reflection_info_unregister_classes
1 parent a48baf5 commit e5ff806

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

mono/metadata/unity-memory-info.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ static void CollectImageMetaData(MonoImage* image, gpointer value, CollectMetada
6565
{
6666
int i;
6767
MonoTableInfo *tdef = &image->tables[MONO_TABLE_TYPEDEF];
68+
GSList *list;
6869

6970
if (image->dynamic)
7071
{
@@ -84,6 +85,21 @@ static void CollectImageMetaData(MonoImage* image, gpointer value, CollectMetada
8485
}
8586
}
8687

88+
/* Some classes are only in this list.
89+
They are added in reflection_setup_internal_class_internal.
90+
*/
91+
list = image->reflection_info_unregister_classes;
92+
93+
while (list)
94+
{
95+
MonoClass *klass = (MonoClass *)list->data;
96+
97+
if (klass)
98+
ContextInsertClass(context, klass);
99+
100+
list = list->next;
101+
}
102+
87103
for (i = 1; i < tdef->rows; ++i)
88104
{
89105
MonoClass *klass;
@@ -586,8 +602,16 @@ static void VerifySnapshot(MonoManagedMemorySnapshot* snapshot, GHashTable* mono
586602

587603
static void CollectMonoImage(MonoImage* image, GHashTable* monoImages)
588604
{
589-
if (g_hash_table_lookup(monoImages, image) == NULL)
590-
g_hash_table_insert(monoImages, image, image);
605+
if (g_hash_table_lookup(monoImages, image) != NULL)
606+
return;
607+
608+
g_hash_table_insert(monoImages, image, image);
609+
610+
if (image->assembly->image != NULL &&
611+
image != image->assembly->image)
612+
{
613+
CollectMonoImage(image->assembly->image, monoImages);
614+
}
591615

592616
if (image->module_count > 0)
593617
{

0 commit comments

Comments
 (0)