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

Fix JIT debugger notification location #53590

Merged
2 commits merged into from
Jun 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 33 additions & 88 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12734,83 +12734,6 @@ CorJitResult invokeCompileMethod(EEJitManager *jitMgr,
return ret;
}

CorJitResult CallCompileMethodWithSEHWrapper(EEJitManager *jitMgr,
CEEInfo *comp,
struct CORINFO_METHOD_INFO *info,
CORJIT_FLAGS flags,
BYTE **nativeEntry,
uint32_t *nativeSizeOfCode,
NativeCodeVersion nativeCodeVersion)
{
// no dynamic contract here because SEH is used, with a finally clause
STATIC_CONTRACT_NOTHROW;
STATIC_CONTRACT_GC_TRIGGERS;

MethodDesc* ftn = nativeCodeVersion.GetMethodDesc();

LOG((LF_CORDB, LL_EVERYTHING, "CallCompileMethodWithSEHWrapper called...\n"));

struct Param
{
EEJitManager *jitMgr;
CEEInfo *comp;
struct CORINFO_METHOD_INFO *info;
CORJIT_FLAGS flags;
BYTE **nativeEntry;
uint32_t *nativeSizeOfCode;
MethodDesc *ftn;
CorJitResult res;
}; Param param;
param.jitMgr = jitMgr;
param.comp = comp;
param.info = info;
param.flags = flags;
param.nativeEntry = nativeEntry;
param.nativeSizeOfCode = nativeSizeOfCode;
param.ftn = ftn;
param.res = CORJIT_INTERNALERROR;

PAL_TRY(Param *, pParam, &param)
{
//
// Call out to the JIT-compiler
//

pParam->res = invokeCompileMethod( pParam->jitMgr,
pParam->comp,
pParam->info,
pParam->flags,
pParam->nativeEntry,
pParam->nativeSizeOfCode);
}
PAL_FINALLY
{
#if defined(DEBUGGING_SUPPORTED) && !defined(CROSSGEN_COMPILE)
if (!flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY) &&
!flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_MCJIT_BACKGROUND)
#ifdef FEATURE_STACK_SAMPLING
&& !flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_SAMPLING_JIT_BACKGROUND)
#endif // FEATURE_STACK_SAMPLING
)
{
//
// Notify the debugger that we have successfully jitted the function
//
if (g_pDebugInterface)
{
if (param.res == CORJIT_OK && !((CEEJitInfo*)param.comp)->JitAgain())
{
g_pDebugInterface->JITComplete(nativeCodeVersion, (TADDR)*nativeEntry);
}
}
}
#endif // DEBUGGING_SUPPORTED && !CROSSGEN_COMPILE
}
PAL_ENDTRY

return param.res;
}

/*********************************************************************/
// Figures out the compile flags that are used by both JIT and NGen

Expand Down Expand Up @@ -13309,17 +13232,16 @@ PCODE UnsafeJitFunction(PrepareCodeConfig* config,
QueryPerformanceCounter (&methodJitTimeStart);

#endif
// Note on debuggerTrackInfo arg: if we're only importing (ie, verifying/
// checking to make sure we could JIT, but not actually generating code (
// eg, for inlining), then DON'T TELL THE DEBUGGER about this.
res = CallCompileMethodWithSEHWrapper(jitMgr,
&jitInfo,
&methodInfo,
flags,
&nativeEntry,
&sizeOfCode,
nativeCodeVersion);
LOG((LF_CORDB, LL_EVERYTHING, "Got through CallCompile MethodWithSEHWrapper\n"));
LOG((LF_CORDB, LL_EVERYTHING, "Calling invokeCompileMethod...\n"));

res = invokeCompileMethod(jitMgr,
&jitInfo,
&methodInfo,
flags,
&nativeEntry,
&sizeOfCode);

LOG((LF_CORDB, LL_EVERYTHING, "Got through invokeCompileMethod\n"));

#if FEATURE_PERFMAP
// Save the code size so that it can be reported to the perfmap.
Expand Down Expand Up @@ -13355,6 +13277,29 @@ PCODE UnsafeJitFunction(PrepareCodeConfig* config,
if (SUCCEEDED(res))
{
jitInfo.WriteCode(jitMgr);
#if defined(DEBUGGING_SUPPORTED)
// Note: if we're only importing (ie, verifying/
// checking to make sure we could JIT, but not actually generating code (
// eg, for inlining), then DON'T TELL THE DEBUGGER about this.
if (!flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_IMPORT_ONLY) &&
!flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_MCJIT_BACKGROUND)
#ifdef FEATURE_STACK_SAMPLING
&& !flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_SAMPLING_JIT_BACKGROUND)
#endif // FEATURE_STACK_SAMPLING
)
{
//
// Notify the debugger that we have successfully jitted the function
//
if (g_pDebugInterface)
{
if (!jitInfo.JitAgain())
{
g_pDebugInterface->JITComplete(nativeCodeVersion, (TADDR)nativeEntry);
}
}
}
#endif // DEBUGGING_SUPPORTED
}
else
{
Expand Down