-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Native->Managed (.net core) step-in not working in Visual Studio #85339
Comments
Tagging subscribers to this area: @tommcdon Issue DetailsDescriptionWhen interop debugging an app running .net core and stopped at a native frame, attempting to step into a managed function call fails to go into the managed side. Upon some investigation by us (the vs debugger), it appears that the same scenario in .net framework will send us a step complete event when this step in is requested. We then are able to correctly stop at the right spot on the managed side. In .net core, this event never comes in so we just step over the call to the managed function. We have our stepper use ICorDebugStepper->Step(stepIn:true) I am unsure if there's some callback we need to provide or some additional setup so that we get notified about the step completion. There is a good chance this is a long-standing issue. Recent efforts to increase our net core interop testing revealed this issue. This sample app shows the issue happening (open the .sln file) Reproduction Steps
Expected behaviorStep into managed side works Actual behaviorWe step over the managed function call Regression?No response Known WorkaroundsEnabling JMC partially hides this behavior. If the managed function being stepped into is user code, the step in works as expected. Configuration.net 6 and .net 8 preview both show this behavior Other informationNo response
|
@AaronRobinsonMSFT would you be interested in taking a look? |
Yep, the issue is in the
When stepping into Managed[UnmanagedCallersOnly]
static void M1()
{
Console.WriteLine($"Called {nameof(M1)}");
}
delegate void M2Del();
static void M2()
{
Console.WriteLine($"Called {nameof(M2)}");
}
static void Main(string[] args)
{
Test_1((delegate* unmanaged<void>)&M1);
var del = new M2Del(M2);
Test_1((void*)Marshal.GetFunctionPointerForDelegate(del));
GC.KeepAlive(del);
}
const string lib = @"NativeLibrary.dll";
[DllImport(lib, EntryPoint = "Test")]
private static extern void* Test_1(void* v); Native#define EXPORT_FUNC __declspec(dllexport)
#define CALLCONV __stdcall
extern "C"
{
using fptr_t = void(CALLCONV*)();
EXPORT_FUNC void* CALLCONV Test(fptr_t fptr)
{
fptr(); // Breakpoint here and step in
return nullptr;
}
} |
The conflict is between |
@tommcdon The OP states this also occurs in .NET 6. The fix for .NET 8 is rather complicated, but a fix for .NET 6 could be very narrow with minimal risk. Do you have any thoughts about porting a fix for .NET 6? |
@AaronRobinsonMSFT, this is a great question. I feel that since the issue is partially hidden when JMC is enabled, I feel we should hold until we receive a backport request from a customer. |
Description
When interop debugging an app running .net core and stopped at a native frame, attempting to step into a managed function call fails to go into the managed side.
Upon some investigation by us (the vs debugger), it appears that the same scenario in .net framework will send us a step complete event when this step in is requested. We then are able to correctly stop at the right spot on the managed side. In .net core, this event never comes in so we just step over the call to the managed function. We have our stepper use ICorDebugStepper->Step(stepIn:true)
I am unsure if there's some callback we need to provide or some additional setup so that we get notified about the step completion. There is a good chance this is a long-standing issue. Recent efforts to increase our net core interop testing revealed this issue.
This sample app shows the issue happening (open the .sln file)
ConsoleApp1.zip
Reproduction Steps
Expected behavior
Step into managed side works
Actual behavior
We step over the managed function call
Regression?
No response
Known Workarounds
Enabling JMC partially hides this behavior. If the managed function being stepped into is user code, the step in works as expected.
Configuration
.net 6 and .net 8 preview both show this behavior
Other information
No response
The text was updated successfully, but these errors were encountered: