-
Notifications
You must be signed in to change notification settings - Fork 105
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.Break in non-user code #149
Comments
Did you try Please note, in case of launch, debugger disable code optimization for each assembly during loading (this is especially need for release built assemblies): netcoredbg/src/metadata/modules.cpp Line 523 in aafa6f3
Unfortunately, in case you attach debugger to process with already loaded and optimized assemblies, debugger can't guarantee changes in assemblies code with SetJITCompilerFlags() .
|
Yes, before. Now I understand why Tested: For me the 1 and 3 are not so important. Just would like to use |
Will this be fixed? I think |
Inside debugger? No. This is not debugger related issue, but related to .NET runtime work itself. In case assembly load with "optimized" flag and have optimized code, debugger have nothing to do with this. You could care about this on your side with attributes, for example: |
I test only non-optimized assemblies. In the test process only .NET assemblies are optimized, including the one containing |
This console output shows it. Note the "---- DEBUG ASSERTION FAILED ----".
|
Debugger use runtime debug API, that provide callbacks and call this callbacks at "stop" events like step complete, exception, breakpoints,... if assert related logic don't call callbacks and just print some info in console, not sure that we could do something with this. I didn't see "assert" related callbacks (https://learn.microsoft.com/en-us/dotnet/framework/unmanaged-api/debugging/icordebugmanagedcallback-interface), this should be investigated first. |
Does this mean that Debug.Assert that you want to catch is somewhere in standard .NET library? According to MS docs (https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.debug.assert?view=net-8.0), Debug.Assert is not compiled if your dll is compiled in release (
This means that there's no Debug.Assert code in il code directly, thus, .NET runtime doesn't know there was an assert during jit compilation. If you want to debug .NET runtime libraries with Debug.Assert, you have to build runtime in debug/checked. |
The call to
If |
I removed this code in // Ignore break on Break() outside of code with loaded PDB (see JMC setup during module load).
if (iCorFrame != nullptr)
{
ToRelease<ICorDebugFunction> iCorFunction;
IfFailRet(iCorFrame->GetFunction(&iCorFunction));
ToRelease<ICorDebugFunction2> iCorFunction2;
IfFailRet(iCorFunction->QueryInterface(IID_ICorDebugFunction2, (LPVOID*) &iCorFunction2));
BOOL JMCStatus;
IfFailRet(iCorFunction2->GetJMCStatus(&JMCStatus));
if (JMCStatus == FALSE)
return S_OK;
} |
As you probably noticed, debugger don't provide stop events in code without PDB and this have a reason. Related to this issue fix should care about "special" status of process stop and don't allow anything except "continue", since, for example, we can't guaranty stepping work from such point. This case should be investigated first in order to care about all related code changes. |
Several bad things, possibly related:
Debugger.Break
in non-user code is ignored.Debug.Assert(false)
andDebug.Fail
don't pause.-gdb-set just-my-code 0
does not work.Note: I tested only in "attach" mode, not in "launch" mode.
The text was updated successfully, but these errors were encountered: