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

[debugger] Support step into a tail call #110334

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

thaystg
Copy link
Member

@thaystg thaystg commented Dec 2, 2024

I got this test case:
https://github.com/dotnet/runtime/blob/80d8c46f071d9e3d8ede2d98cb2c918d9b0d7d31/src/tests/JIT/Regression/JitBlue/Runtime_39581/Runtime_39581.il
Added a breakpoint on line 93 and tried to step into to Runtime_39581.Program::Callee and it behaves like a step over.
With this change the step into works correctly.

Fixes #110441

@thaystg thaystg requested a review from tommcdon December 2, 2024 22:12
@thaystg thaystg changed the title Support step into a tail call [debugger] Support step into a tail call Dec 2, 2024
Copy link
Member

@mikem8361 mikem8361 left a comment

Choose a reason for hiding this comment

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

I'm not an expert on this code but it looks good to me.

@@ -2203,6 +2203,7 @@ DWORD DbgTransportSession::GetEventSize(DebuggerIPCEvent *pEvent)
case DB_IPCE_AFTER_GARBAGE_COLLECTION:
case DB_IPCE_DISABLE_OPTS_RESULT:
case DB_IPCE_CATCH_HANDLER_FOUND_RESULT:
case DB_IPCE_SET_ENABLE_CUSTOM_NOTIFICATION_RESULT:
Copy link
Member

Choose a reason for hiding this comment

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

Is this intentionally part of this PR?

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 was causing a boring assertion in the debug build, I can open a separate PR with this fix but it can be here together.

Copy link
Member

Choose a reason for hiding this comment

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

I don't have a strong preference. Would we want to include that changes as part of a backport to .NET servicing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, okay, I will remove it, it will be better for backporting only the change.

Comment on lines 5831 to 5840
TraceDestination trace;
if (!g_pEEInterface->TraceStub(ip, &trace) || !g_pEEInterface->FollowTrace(&trace))
{
return false;
}

MethodDesc* pTargetMD =
trace.GetTraceType() == TRACE_UNJITTED_METHOD
? trace.GetMethodDesc()
: g_pEEInterface->GetNativeCodeMethodDesc(trace.GetAddress());
Copy link
Member

Choose a reason for hiding this comment

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

Very minor nit: this looks like a copy of the code in IsTailCallThatReturns, can we consolidate this into a shared function?

TraceDestination trace;
if (!g_pEEInterface->TraceStub(ip, &trace) || !g_pEEInterface->FollowTrace(&trace))
{
return false;
}
MethodDesc* pTargetMD =
trace.GetTraceType() == TRACE_UNJITTED_METHOD
? trace.GetMethodDesc()
: g_pEEInterface->GetNativeCodeMethodDesc(trace.GetAddress());

Copy link
Member

@tommcdon tommcdon left a comment

Choose a reason for hiding this comment

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

This looks good to me! Left a couple comments for your review.

Copy link
Member

@tommcdon tommcdon left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!!

@thaystg
Copy link
Member Author

thaystg commented Dec 5, 2024

/backport to release/9.0-staging

Copy link
Contributor

github-actions bot commented Dec 5, 2024

Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/12181390920

@thaystg
Copy link
Member Author

thaystg commented Dec 5, 2024

/backport to release/8.0-staging

Copy link
Contributor

github-actions bot commented Dec 5, 2024

Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/12181421329

Copy link
Contributor

github-actions bot commented Dec 5, 2024

@thaystg backporting to release/8.0-staging failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Support step into a tail call
.git/rebase-apply/patch:54: trailing whitespace.
    case DB_IPCE_SET_ENABLE_CUSTOM_NOTIFICATION_RESULT:    
warning: 1 line adds whitespace errors.
Using index info to reconstruct a base tree...
M	src/coreclr/debug/ee/controller.cpp
M	src/coreclr/debug/shared/dbgtransportsession.cpp
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/debug/shared/dbgtransportsession.cpp
CONFLICT (content): Merge conflict in src/coreclr/debug/shared/dbgtransportsession.cpp
Auto-merging src/coreclr/debug/ee/controller.cpp
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 Support step into a tail call
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Addressing Tom's and Mikelle's comments

Removing unrelated change and adding enum

Changing the comment.
@thaystg thaystg force-pushed the dev/thays/support_step_into_tailcall branch from 68a5b88 to 12f0cf5 Compare December 5, 2024 14:47
@thaystg
Copy link
Member Author

thaystg commented Dec 5, 2024

/backport to release/8.0-staging

@thaystg
Copy link
Member Author

thaystg commented Dec 5, 2024

/backport to release/9.0-staging

Copy link
Contributor

github-actions bot commented Dec 5, 2024

Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/12182141863

Copy link
Contributor

github-actions bot commented Dec 5, 2024

Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/12182142995

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.

Cannot step into a Tail Call
4 participants