Skip to content

[NativeAOT] Fire First Chance Exceptions if Debugger is Attached #115514

Closed
@tommcdon

Description

@tommcdon

Both NativeAOT and .NET Core share the same exception model, where managed exceptions and processed and handled inside of the runtime and we avoid OS notifications for them unless they are unhandled. For NativeAOT, we recommend setting a breakpoint on RhThrowEx to debug exceptions when they are thrown. To make it easier to stop on these exceptions, it would be useful to report the exceptions to the OS in NativeAOT so that native debuggers will automatically be notified, similar to .NET Core's mechanism:

void FirstChanceExceptionNotification()
{
#ifndef TARGET_UNIX
if (minipal_is_native_debugger_present())
{
PAL_TRY(VOID *, unused, NULL)
{
RaiseException(EXCEPTION_COMPLUS, 0, 0, NULL);
}
PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
}
PAL_ENDTRY;
}
#endif // TARGET_UNIX
}
.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Diagnostics-coreclrenhancementProduct code improvement that does NOT require public API changes/additions

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions