diff options
author | Jan Kotas <jkotas@microsoft.com> | 2015-10-29 19:09:52 -0700 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2015-10-29 19:09:52 -0700 |
commit | a8192fbc7064ed96cfeb8872bcb6479c217f7b5f (patch) | |
tree | 738c092202d3ce5c7ed4ec08114c3c41b7b005d8 /src/debug | |
parent | 3c50dec5796206c6042fd6adc3133a0ad22649e5 (diff) | |
download | coreclr-a8192fbc7064ed96cfeb8872bcb6479c217f7b5f.tar.gz coreclr-a8192fbc7064ed96cfeb8872bcb6479c217f7b5f.tar.bz2 coreclr-a8192fbc7064ed96cfeb8872bcb6479c217f7b5f.zip |
Port .NET Framework 4.6.1 changes
Core runtime and GC changes from https://github.com/Microsoft/dotnet/blob/master/docs/releases/net461/dotnet461-changes.md that are not in CoreCLR yet
[tfs-changeset: 1543382]
Diffstat (limited to 'src/debug')
-rw-r--r-- | src/debug/daccess/daccess.cpp | 19 | ||||
-rw-r--r-- | src/debug/daccess/dacimpl.h | 9 | ||||
-rw-r--r-- | src/debug/daccess/enummem.cpp | 7 | ||||
-rw-r--r-- | src/debug/daccess/request.cpp | 87 | ||||
-rw-r--r-- | src/debug/daccess/request_svr.cpp | 25 | ||||
-rw-r--r-- | src/debug/ee/controller.cpp | 42 | ||||
-rw-r--r-- | src/debug/ee/controller.h | 6 | ||||
-rw-r--r-- | src/debug/ee/functioninfo.cpp | 1 |
8 files changed, 186 insertions, 10 deletions
diff --git a/src/debug/daccess/daccess.cpp b/src/debug/daccess/daccess.cpp index ff3a8172ad..829ddd904f 100644 --- a/src/debug/daccess/daccess.cpp +++ b/src/debug/daccess/daccess.cpp @@ -3267,6 +3267,10 @@ ClrDataAccess::QueryInterface(THIS_ { ifaceRet = static_cast<ISOSDacInterface2*>(this); } + else if (IsEqualIID(interfaceId, __uuidof(ISOSDacInterface3))) + { + ifaceRet = static_cast<ISOSDacInterface3*>(this); + } else { *iface = NULL; @@ -6849,8 +6853,19 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect { // Get the metadata PTR_SBuffer metadataBuffer = reflectionModule->GetDynamicMetadataBuffer(); - mdBaseTarget = dac_cast<PTR_CVOID>((metadataBuffer->DacGetRawBuffer()).StartAddress()); - mdSize = metadataBuffer->GetSize(); + if (metadataBuffer != PTR_NULL) + { + mdBaseTarget = dac_cast<PTR_CVOID>((metadataBuffer->DacGetRawBuffer()).StartAddress()); + mdSize = metadataBuffer->GetSize(); + } + else + { + if (throwEx) + { + DacError(E_FAIL); + } + return NULL; + } } else { diff --git a/src/debug/daccess/dacimpl.h b/src/debug/daccess/dacimpl.h index f33b7fc42b..d20bedf1a4 100644 --- a/src/debug/daccess/dacimpl.h +++ b/src/debug/daccess/dacimpl.h @@ -857,7 +857,8 @@ class ClrDataAccess : public IXCLRDataProcess2, public ICLRDataEnumMemoryRegions, public ISOSDacInterface, - public ISOSDacInterface2 + public ISOSDacInterface2, + public ISOSDacInterface3 { public: ClrDataAccess(ICorDebugDataTarget * pTarget, ICLRDataTarget * pLegacyTarget=0); @@ -1192,6 +1193,11 @@ public: virtual HRESULT STDMETHODCALLTYPE GetObjectExceptionData(CLRDATA_ADDRESS objAddr, struct DacpExceptionObjectData *data); virtual HRESULT STDMETHODCALLTYPE IsRCWDCOMProxy(CLRDATA_ADDRESS rcwAddr, BOOL* isDCOMProxy); + // ISOSDacInterface3 + virtual HRESULT STDMETHODCALLTYPE GetGCInterestingInfoData(CLRDATA_ADDRESS interestingInfoAddr, struct DacpGCInterestingInfoData *data); + virtual HRESULT STDMETHODCALLTYPE GetGCInterestingInfoStaticData(struct DacpGCInterestingInfoData *data); + virtual HRESULT STDMETHODCALLTYPE GetGCGlobalMechanisms(size_t* globalMechanisms); + // // ClrDataAccess. // @@ -1271,6 +1277,7 @@ public: DacpGcHeapDetails *detailsData); HRESULT GetServerAllocData(unsigned int count, struct DacpGenerationAllocData *data, unsigned int *pNeeded); HRESULT ServerOomData(CLRDATA_ADDRESS addr, DacpOomData *oomData); + HRESULT ServerGCInterestingInfoData(CLRDATA_ADDRESS addr, DacpGCInterestingInfoData *interestingInfoData); HRESULT ServerGCHeapAnalyzeData(CLRDATA_ADDRESS heapAddr, DacpGcHeapAnalyzeData *analyzeData); diff --git a/src/debug/daccess/enummem.cpp b/src/debug/daccess/enummem.cpp index 0d50ec6767..b65d086b55 100644 --- a/src/debug/daccess/enummem.cpp +++ b/src/debug/daccess/enummem.cpp @@ -802,6 +802,7 @@ HRESULT ClrDataAccess::EnumMemWalkStackHelper(CLRDataEnumMemoryFlags flags, { frameHadContext = false; status = pStackWalk->GetFrame(&pFrame); + PCODE addr = NULL; if (status == S_OK && pFrame != NULL) { // write out the code that ip pointed to @@ -812,7 +813,8 @@ HRESULT ClrDataAccess::EnumMemWalkStackHelper(CLRDataEnumMemoryFlags flags, { // Enumerate the code around the call site to help debugger stack walking heuristics ::FillRegDisplay(®Disp, &context); - TADDR callEnd = PCODEToPINSTR(GetControlPC(®Disp)); + addr = GetControlPC(®Disp); + TADDR callEnd = PCODEToPINSTR(addr); DacEnumCodeForStackwalk(callEnd); frameHadContext = true; } @@ -969,8 +971,7 @@ HRESULT ClrDataAccess::EnumMemWalkStackHelper(CLRDataEnumMemoryFlags flags, DebugInfoManager::EnumMemoryRegionsForMethodDebugInfo(flags, pMethodDesc); #ifdef WIN64EXCEPTIONS - PCODE addr = pMethodDesc->GetNativeCode(); - + if (addr != NULL) { EECodeInfo codeInfo(addr); diff --git a/src/debug/daccess/request.cpp b/src/debug/daccess/request.cpp index af5848288a..1925465c92 100644 --- a/src/debug/daccess/request.cpp +++ b/src/debug/daccess/request.cpp @@ -3060,6 +3060,89 @@ ClrDataAccess::GetOOMData(CLRDATA_ADDRESS oomAddr, struct DacpOomData *data) } HRESULT +ClrDataAccess::GetGCGlobalMechanisms(size_t* globalMechanisms) +{ +#ifdef GC_CONFIG_DRIVEN + if (globalMechanisms == NULL) + return E_INVALIDARG; + + SOSDacEnter(); + memset(globalMechanisms, 0, (sizeof(size_t) * MAX_GLOBAL_GC_MECHANISMS_COUNT)); + + for (int i = 0; i < MAX_GLOBAL_GC_MECHANISMS_COUNT; i++) + { + globalMechanisms[i] = gc_global_mechanisms[i]; + } + + SOSDacLeave(); + return hr; +#else + return E_NOTIMPL; +#endif //GC_CONFIG_DRIVEN +} + +HRESULT +ClrDataAccess::GetGCInterestingInfoStaticData(struct DacpGCInterestingInfoData *data) +{ +#ifdef GC_CONFIG_DRIVEN + if (data == NULL) + return E_INVALIDARG; + + SOSDacEnter(); + memset(data, 0, sizeof(DacpGCInterestingInfoData)); + + if (!GCHeap::IsServerHeap()) + { + for (int i = 0; i < NUM_GC_DATA_POINTS; i++) + data->interestingDataPoints[i] = WKS::interesting_data_per_heap[i]; + for (int i = 0; i < MAX_COMPACT_REASONS_COUNT; i++) + data->compactReasons[i] = WKS::compact_reasons_per_heap[i]; + for (int i = 0; i < MAX_EXPAND_MECHANISMS_COUNT; i++) + data->expandMechanisms[i] = WKS::expand_mechanisms_per_heap[i]; + for (int i = 0; i < MAX_GC_MECHANISM_BITS_COUNT; i++) + data->bitMechanisms[i] = WKS::interesting_mechanism_bits_per_heap[i]; + } + else + { + hr = E_FAIL; + } + + SOSDacLeave(); + return hr; +#else + return E_NOTIMPL; +#endif //GC_CONFIG_DRIVEN +} + +HRESULT +ClrDataAccess::GetGCInterestingInfoData(CLRDATA_ADDRESS interestingInfoAddr, struct DacpGCInterestingInfoData *data) +{ +#ifdef GC_CONFIG_DRIVEN + if (interestingInfoAddr == 0 || data == NULL) + return E_INVALIDARG; + + SOSDacEnter(); + memset(data, 0, sizeof(DacpGCInterestingInfoData)); + + if (!GCHeap::IsServerHeap()) + hr = E_FAIL; // doesn't make sense to call this on WKS mode + +#ifdef FEATURE_SVR_GC + else + hr = ServerGCInterestingInfoData(interestingInfoAddr, data); +#else + _ASSERTE_MSG(false, "IsServerHeap returned true but FEATURE_SVR_GC not defined"); + hr = E_NOTIMPL; +#endif //FEATURE_SVR_GC + + SOSDacLeave(); + return hr; +#else + return E_NOTIMPL; +#endif //GC_CONFIG_DRIVEN +} + +HRESULT ClrDataAccess::GetHeapAnalyzeData(CLRDATA_ADDRESS addr, struct DacpGcHeapAnalyzeData *data) { if (addr == 0 || data == NULL) @@ -3823,8 +3906,8 @@ HRESULT ClrDataAccess::GetClrWatsonBucketsWorker(Thread * pThread, GenericModeBl OBJECTHANDLE ohThrowable = pThread->GetThrowableAsHandle(); if (ohThrowable != NULL) { - // Get the object from handle and check if the throwable is preallocated or not - OBJECTREF oThrowable = ObjectFromHandle(ohThrowable); + // Get the object from handle and check if the throwable is preallocated or not + OBJECTREF oThrowable = ObjectFromHandle(ohThrowable); if (oThrowable != NULL) { // Does the throwable have buckets? diff --git a/src/debug/daccess/request_svr.cpp b/src/debug/daccess/request_svr.cpp index 97b064898f..9dfd26046e 100644 --- a/src/debug/daccess/request_svr.cpp +++ b/src/debug/daccess/request_svr.cpp @@ -194,6 +194,31 @@ ClrDataAccess::ServerOomData(CLRDATA_ADDRESS addr, DacpOomData *oomData) return S_OK; } +HRESULT +ClrDataAccess::ServerGCInterestingInfoData(CLRDATA_ADDRESS addr, DacpGCInterestingInfoData *interestingInfoData) +{ +#ifdef GC_CONFIG_DRIVEN + SVR::gc_heap *pHeap = PTR_SVR_gc_heap(TO_TADDR(addr)); + + size_t* dataPoints = (size_t*)&(pHeap->interesting_data_per_heap); + for (int i = 0; i < NUM_GC_DATA_POINTS; i++) + interestingInfoData->interestingDataPoints[i] = dataPoints[i]; + size_t* mechanisms = (size_t*)&(pHeap->compact_reasons_per_heap); + for (int i = 0; i < MAX_COMPACT_REASONS_COUNT; i++) + interestingInfoData->compactReasons[i] = mechanisms[i]; + mechanisms = (size_t*)&(pHeap->expand_mechanisms_per_heap); + for (int i = 0; i < MAX_EXPAND_MECHANISMS_COUNT; i++) + interestingInfoData->expandMechanisms[i] = mechanisms[i]; + mechanisms = (size_t*)&(pHeap->interesting_mechanism_bits_per_heap); + for (int i = 0; i < MAX_GC_MECHANISM_BITS_COUNT; i++) + interestingInfoData->bitMechanisms[i] = mechanisms[i]; + + return S_OK; +#else + return E_NOTIMPL; +#endif //GC_CONFIG_DRIVEN +} + HRESULT ClrDataAccess::ServerGCHeapAnalyzeData(CLRDATA_ADDRESS heapAddr, DacpGcHeapAnalyzeData *analyzeData) { if (!heapAddr) diff --git a/src/debug/ee/controller.cpp b/src/debug/ee/controller.cpp index 9988378c7a..4e1ab6557a 100644 --- a/src/debug/ee/controller.cpp +++ b/src/debug/ee/controller.cpp @@ -990,6 +990,7 @@ void DebuggerController::DeleteAllControllers() while (pDebuggerController != NULL) { pNextDebuggerController = pDebuggerController->m_next; + pDebuggerController->DebuggerDetachClean(); pDebuggerController->Delete(); pDebuggerController = pNextDebuggerController; } @@ -1056,6 +1057,11 @@ void DebuggerController::Delete() } } +void DebuggerController::DebuggerDetachClean() +{ + //do nothing here +} + //static void DebuggerController::AddRef(DebuggerControllerPatch *patch) { @@ -4463,6 +4469,42 @@ DebuggerPatchSkip::~DebuggerPatchSkip() #endif } +void DebuggerPatchSkip::DebuggerDetachClean() +{ +// Since for ARM SharedPatchBypassBuffer isn't existed, we don't have to anything here. +#ifndef _TARGET_ARM_ + // Fix for Bug 1176448 + // When a debugger is detaching from the debuggee, we need to move the IP if it is pointing + // somewhere in PatchBypassBuffer.All managed threads are suspended during detach, so changing + // the context without notifications is safe. + // Notice: + // THIS FIX IS INCOMPLETE!It attempts to update the IP in the cases we can easily detect.However, + // if a thread is in pre - emptive mode, and its filter context has been propagated to a VEH + // context, then the filter context we get will be NULL and this fix will not work.Our belief is + // that this scenario is rare enough that it doesn’t justify the cost and risk associated with a + // complete fix, in which we would have to either : + // 1. Change the reference counting for DebuggerController and then change the exception handling + // logic in the debuggee so that we can handle the debugger event after detach. + // 2. Create a "stack walking" implementation for native code and use it to get the current IP and + // set the IP to the right place. + + Thread *thread = GetThread(); + if (thread != NULL) + { + BYTE *patchBypass = m_pSharedPatchBypassBuffer->PatchBypass; + CONTEXT *context = thread->GetFilterContext(); + if (patchBypass != NULL && + context != NULL && + (size_t)GetIP(context) >= (size_t)patchBypass && + (size_t)GetIP(context) <= (size_t)(patchBypass + MAX_INSTRUCTION_LENGTH + 1)) + { + SetIP(context, (PCODE)((BYTE *)GetIP(context) - (patchBypass - (BYTE *)m_address))); + } + } +#endif +} + + // // We have to have a whole seperate function for this because you // can't use __try in a function that requires object unwinding... diff --git a/src/debug/ee/controller.h b/src/debug/ee/controller.h index 4782565dfa..5a0d5cf027 100644 --- a/src/debug/ee/controller.h +++ b/src/debug/ee/controller.h @@ -1105,6 +1105,8 @@ private: static void ApplyTraceFlag(Thread *thread); static void UnapplyTraceFlag(Thread *thread); + virtual void DebuggerDetachClean(); + public: static const BYTE *g_pMSCorEEStart, *g_pMSCorEEEnd; @@ -1324,7 +1326,7 @@ public: // still send. // // Returns true if send an event, false elsewise. - virtual bool SendEvent(Thread *thread, bool fInteruptedBySetIp); + virtual bool SendEvent(Thread *thread, bool fInteruptedBySetIp); AppDomain *m_pAppDomain; @@ -1380,6 +1382,8 @@ class DebuggerPatchSkip : public DebuggerController void DecodeInstruction(CORDB_ADDRESS_TYPE *code); + void DebuggerDetachClean(); + CORDB_ADDRESS_TYPE *m_address; int m_iOrigDisp; // the original displacement of a relative call or jump InstructionAttribute m_instrAttrib; // info about the instruction being skipped over diff --git a/src/debug/ee/functioninfo.cpp b/src/debug/ee/functioninfo.cpp index af52ab5c9d..ece74aa8ed 100644 --- a/src/debug/ee/functioninfo.cpp +++ b/src/debug/ee/functioninfo.cpp @@ -806,7 +806,6 @@ DWORD DebuggerJitInfo::MapNativeOffsetToIL(SIZE_T nativeOffsetToMap, { // If the caller requested to skip prologs, we simply restart the walk // with the offset set to the end of the prolog. - m = GetSequenceMap(); nativeOffset = m->nativeEndOffset; continue; } |