Skip to content

Add IL offset and method token to stack frame details. #2130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2025

Conversation

joncham
Copy link
Member

@joncham joncham commented May 19, 2025

Add support to read IL offset and method token out-of-process (oop). This will enable the symbolication of managed frames to file/line level rather than just the method level.

Notes:

  • Remove int _GHashTable::threshold field. This was never updated, always had value 0, and thus always caused a rehash when checked.
  • Add gboolean _GHashTable::uses_default_hash_and_equality field. The out-of-process read logic needs to inspect a hash table, and thus can only be done when direct hash/equality is used; custom hash/equality functions are not supported.
  • Add g_hash_table_lookup_oop to perform the actual hash lookup. This was done in mono/eglib/ghashtable.c directly to avoid having to expose hashtable implementation internals.
  • In mono/metadata/oop.c replicate enough data/logic for a simple oop version of mono_debug_read_method that can retrieve the offset/token info.

These changes have some risk, but they are only invoked when processing a crash. Thus, we may lose some crash info in the case of errors, but we should not cause any additional crashes.

  • Should this pull request have release notes?
    • [] Yes
    • No
  • Do these changes need to be back ported?
    • Yes
    • No
  • Do these changes need to be upstreamed to mono/mono or dotnet/runtime repositories?
    • Yes
    • No

Reviewers: please consider these questions as well! ❤️

@joncham joncham self-assigned this May 19, 2025
@joncham joncham requested a review from MindWrapper May 19, 2025 18:24
@MindWrapper
Copy link

Thanks @joncham let me test it tomorrow. I'll get back to you!

@@ -48,8 +48,8 @@ struct _GHashTable {
Slot **table;
int table_size;
int in_use;
int threshold;
Copy link
Member Author

@joncham joncham Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only used in one place, but never updated.

int last_rehash;
gboolean uses_default_hash_and_equality;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows us to perform the same hashing/equality operations when out of process.

@@ -239,8 +240,7 @@ g_hash_table_insert_replace (GHashTable *hash, gpointer key, gpointer value, gbo
sanity_check (hash);

equal = hash->key_equal_func;
if (hash->in_use >= hash->threshold)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rehash was always occurring, as threshold was always 0.

@joncham joncham marked this pull request as ready for review July 28, 2025 18:38
Comment on lines +404 to +405
result |= (byte & 0x7f) << shift;
if ((byte & 0x80) == 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see in mono-debug that these hardcoded values are used there as well but I'm still curious what they are?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is variable length encoding of integer values. Thus small values could be contained within a single byte. Larger values two bytes, etc.

@joncham joncham merged commit 7720660 into unity-6000.3-mbe Aug 12, 2025
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants