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

Add instructions how to debug NativeAOT exceptions on the ARM64 #44631

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

Conversation

kant2002
Copy link
Contributor

@kant2002 kant2002 commented Jan 31, 2025

@kant2002 kant2002 requested review from adegeo and a team as code owners January 31, 2025 08:47
@dotnetrepoman dotnetrepoman bot added this to the January 2025 milestone Jan 31, 2025
@dotnet-policy-service dotnet-policy-service bot added dotnet-fundamentals/svc community-contribution Indicates PR is created by someone from the .NET community. labels Jan 31, 2025
@@ -62,7 +62,7 @@ You can launch a Native AOT-compiled executable under the Visual Studio debugger

To set a breakpoint that breaks whenever an exception is thrown, choose the **Breakpoints** option from the **Debug > Windows** menu. In the new window, select **New > Function** breakpoint. Specify `RhThrowEx` as the Function Name and leave the Language option at **All Languages** (don't select C#).

To see what exception was thrown, start debugging (**Debug > Start Debugging** or <kbd>F5</kbd>), open the Watch window (**Debug > Windows > Watch**), and add following expression as one of the watches: `(S_P_CoreLib_System_Exception*)@rcx`. This mechanism leverages the fact that at the time `RhThrowEx` is called, the x64 CPU register RCX contains the thrown exception. You can also paste the expression into the Immediate window; the syntax is the same as for watches.
To see what exception was thrown, start debugging (`Debug` -> `Start Debugging` or `F5`), open the Watches window (`Debug` -> `Windows` -> `Watch`) and add following expression as one of the watches: `(S_P_CoreLib_System_Exception*)@rcx` on x64, or `(S_P_CoreLib_System_Exception*)x0` on ARM64. This leverages the fact that at the time `RhThrowEx` is called, the registers RCX and X0 contain the thrown exception, on x64 and ARM64, respectively. You can also paste the expression into the `Immediate Window`; the syntax is the same as for watches.
Copy link
Member

Choose a reason for hiding this comment

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

What's the motivation behind the formatting changes?

Is the (S_P_CoreLib_System_Exception*)x0 part missing a @?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly that was copypaste, because it looks similar. Let me check again.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the VS menu items should not be code fenced. They should be bold.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fix an issues with formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates PR is created by someone from the .NET community. dotnet-fundamentals/svc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants