diff options
-rw-r--r-- | src/vm/gdbjit.cpp | 18 | ||||
-rw-r--r-- | src/vm/gdbjit.h | 4 | ||||
-rw-r--r-- | src/vm/prestub.cpp | 16 | ||||
-rw-r--r-- | src/vm/util.cpp | 10 |
4 files changed, 29 insertions, 19 deletions
diff --git a/src/vm/gdbjit.cpp b/src/vm/gdbjit.cpp index 6c23b81997..1d0bcc8435 100644 --- a/src/vm/gdbjit.cpp +++ b/src/vm/gdbjit.cpp @@ -15,6 +15,8 @@ #include "gdbjit.h" #include "gdbjithelpers.h" +__declspec(thread) bool tls_isSymReaderInProgress = false; + TypeInfoBase* GetTypeInfoFromTypeHandle(TypeHandle typeHandle, NotifyGdb::PTK_TypeInfoMap pTypeMap, @@ -2393,11 +2395,16 @@ static void BuildDebugFrame(Elf_Builder &elfBuilder, PCODE pCode, TADDR codeSize #endif // FEATURE_GDBJIT_FRAME /* Create ELF/DWARF debug info for jitted method */ -void NotifyGdb::MethodCompiled(MethodDesc* methodDescPtr) +void NotifyGdb::MethodPrepared(MethodDesc* methodDescPtr) { EX_TRY { - NotifyGdb::OnMethodCompiled(methodDescPtr); + if (!tls_isSymReaderInProgress) + { + tls_isSymReaderInProgress = true; + NotifyGdb::OnMethodPrepared(methodDescPtr); + tls_isSymReaderInProgress = false; + } } EX_CATCH { @@ -2405,7 +2412,7 @@ void NotifyGdb::MethodCompiled(MethodDesc* methodDescPtr) EX_END_CATCH(SwallowAllExceptions); } -void NotifyGdb::OnMethodCompiled(MethodDesc* methodDescPtr) +void NotifyGdb::OnMethodPrepared(MethodDesc* methodDescPtr) { PCODE pCode = methodDescPtr->GetNativeCode(); if (pCode == NULL) @@ -2413,6 +2420,11 @@ void NotifyGdb::OnMethodCompiled(MethodDesc* methodDescPtr) /* Get method name & size of jitted code */ EECodeInfo codeInfo(pCode); + if (!codeInfo.IsValid()) + { + return; + } + TADDR codeSize = codeInfo.GetCodeManager()->GetFunctionSize(codeInfo.GetGCInfoToken()); pCode = PCODEToPINSTR(pCode); diff --git a/src/vm/gdbjit.h b/src/vm/gdbjit.h index f06fc20c8d..533c496b50 100644 --- a/src/vm/gdbjit.h +++ b/src/vm/gdbjit.h @@ -331,7 +331,7 @@ class Elf_Builder; class NotifyGdb { public: - static void MethodCompiled(MethodDesc* methodDescPtr); + static void MethodPrepared(MethodDesc* methodDescPtr); static void MethodPitched(MethodDesc* methodDescPtr); template <typename PARENT_TRAITS> class DeleteValuesOnDestructSHashTraits : public PARENT_TRAITS @@ -405,7 +405,7 @@ private: } }; - static void OnMethodCompiled(MethodDesc* methodDescPtr); + static void OnMethodPrepared(MethodDesc* methodDescPtr); #ifdef FEATURE_GDBJIT_FRAME static bool EmitFrameInfo(Elf_Builder &, PCODE pCode, TADDR codeSzie); diff --git a/src/vm/prestub.cpp b/src/vm/prestub.cpp index ee8cae7c1e..0109316a01 100644 --- a/src/vm/prestub.cpp +++ b/src/vm/prestub.cpp @@ -50,6 +50,10 @@ #include "callcounter.h" #endif +#if defined(FEATURE_GDBJIT) +#include "gdbjit.h" +#endif // FEATURE_GDBJIT + #ifndef DACCESS_COMPILE #if defined(FEATURE_JIT_PITCHING) @@ -222,17 +226,13 @@ void DACNotifyCompilationFinished(MethodDesc *methodDesc) _ASSERTE(modulePtr); -#ifndef FEATURE_GDBJIT // Are we listed? USHORT jnt = jn.Requested((TADDR) modulePtr, t); if (jnt & CLRDATA_METHNOTIFY_GENERATED) { // If so, throw an exception! -#endif DACNotify::DoJITNotification(methodDesc); -#ifndef FEATURE_GDBJIT } -#endif } } @@ -245,7 +245,13 @@ PCODE MethodDesc::PrepareInitialCode() { STANDARD_VM_CONTRACT; PrepareCodeConfig config(NativeCodeVersion(this), TRUE, TRUE); - return PrepareCode(&config); + PCODE pCode = PrepareCode(&config); + +#if defined(FEATURE_GDBJIT) && defined(FEATURE_PAL) && !defined(CROSSGEN_COMPILE) + NotifyGdb::MethodPrepared(this); +#endif + + return pCode; } PCODE MethodDesc::PrepareCode(NativeCodeVersion codeVersion) diff --git a/src/vm/util.cpp b/src/vm/util.cpp index 12c3cea83a..2c71289c8d 100644 --- a/src/vm/util.cpp +++ b/src/vm/util.cpp @@ -2846,7 +2846,6 @@ void InitializeClrNotifications() #if defined(FEATURE_GDBJIT) #include "gdbjit.h" -__declspec(thread) bool tls_isSymReaderInProgress = false; #endif // FEATURE_GDBJIT // called from the runtime @@ -2860,14 +2859,7 @@ void DACNotify::DoJITNotification(MethodDesc *MethodDescPtr) MODE_PREEMPTIVE; } CONTRACTL_END; -#if defined(FEATURE_GDBJIT) && defined(FEATURE_PAL) && !defined(CROSSGEN_COMPILE) - if(!tls_isSymReaderInProgress) - { - tls_isSymReaderInProgress = true; - NotifyGdb::MethodCompiled(MethodDescPtr); - tls_isSymReaderInProgress = false; - } -#endif + TADDR Args[2] = { JIT_NOTIFICATION, (TADDR) MethodDescPtr }; DACNotifyExceptionHelper(Args, 2); } |