Skip to content
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

Update stepping through ExternalMethodFixup under the Debugger #108942

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mikelle-rogers
Copy link
Member

This PR updates stepping through the ExternalMethodFixup stub, used when calling other modules in a R2R app, under the debugger by introducing a callback rather than setting a breakpoint within the stub. This is needed as a result of the app crashing on MacOS arm64 if the breakpoint is set on the text section of the module.

Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@mikelle-rogers mikelle-rogers marked this pull request as ready for review October 16, 2024 19:46
@@ -1563,13 +1568,7 @@ BOOL RangeSectionStubManager::DoTraceStub(PCODE stubStartAddress, TraceDestinati
#ifdef DACCESS_COMPILE
DacNotImpl();
#else
#if defined(TARGET_ARM64) && defined(__APPLE__)
// On ARM64 Mac, we cannot put a breakpoint inside of ExternalMethodFixupPatchLabel
Copy link
Member

Choose a reason for hiding this comment

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

Delete all occurrences of ExternalMethodFixupPatchLabel?

Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

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

LGTM, a few minor suggestions inline 👍

@@ -4123,6 +4198,10 @@ void DebuggerController::TriggerMulticastDelegate(DELEGATEREF pDel, INT32 delega
{
_ASSERTE(!"This code should be unreachable. If your controller enables MulticastDelegateHelper events,it should also override this callback to do something useful when the event arrives.");
}
void DebuggerController::TriggerExternalMethodFixup(PCODE target)
{
_ASSERTE(!"This code should be unreachable. If your controller enables ExternalMethodFixup events,it should also override this callback to do something useful when the event arrives.");
Copy link
Member

Choose a reason for hiding this comment

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

Nit: the same missing space is in the message above too

Suggested change
_ASSERTE(!"This code should be unreachable. If your controller enables ExternalMethodFixup events,it should also override this callback to do something useful when the event arrives.");
_ASSERTE(!"This code should be unreachable. If your controller enables ExternalMethodFixup events, it should also override this callback to do something useful when the event arrives.");

@@ -3401,6 +3402,10 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl
pEMFrame->Pop(CURRENT_THREAD); // Pop the ExternalMethodFrame from the frame stack

END_PRESERVE_LAST_ERROR;
if (g_externalMethodFixupTraceActiveCount > 0)
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest moving this code up to 3398. The INSTALL/UNINSTALL_xyz macros are creating try/catch regions to handle exceptions. I don't expect the debugger code to throw exceptions in any normal circumstance, but if there were some error (for example memory is corrupted causing an AV or stack space runs out) then its nice to treat those errors the same way as if they had happened anywhere else in the method body. Also the END_PRESERVE_LAST_ERROR macro is ensuring that the thread local GetLastError() value gets restored before this method returns. Its easier to put our debugger call above that point than to audit ensuring that nothing in the debugger call would ever cause it to change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants