From: John Salem Date: Tue, 19 Feb 2019 23:20:06 +0000 (-0800) Subject: Add array of managed assembly objects to StackFrameHelper class: X-Git-Tag: submit/tizen/20210909.063632~11030^2~2380^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=83643fba0cef350800cb1d3e741d2ee4fa215fed;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Add array of managed assembly objects to StackFrameHelper class: * allows for more robust caching of source info (in CoreFX) in light of unloadability * allows dynamic and regular assemblies to use the same key for source info caching (in CoreFX) dotnet/coreclr#20179 Commit migrated from https://github.com/dotnet/coreclr/commit/614876ade8dc6cb966932036c9a5adeba1769e0d --- diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs index e8d7ef5..c86a90f 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs @@ -34,6 +34,7 @@ namespace System.Diagnostics private IntPtr[] rgMethodHandle; private string[] rgAssemblyPath; + private Assembly[] rgAssembly; private IntPtr[] rgLoadedPeAddress; private int[] rgiLoadedPeSize; private IntPtr[] rgInMemoryPdbAddress; @@ -47,8 +48,8 @@ namespace System.Diagnostics private int iFrameCount; #pragma warning restore 414 - private delegate void GetSourceLineInfoDelegate(string assemblyPath, IntPtr loadedPeAddress, int loadedPeSize, - IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset, + private delegate void GetSourceLineInfoDelegate(Assembly assembly, string assemblyPath, IntPtr loadedPeAddress, + int loadedPeSize, IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset, out string sourceFile, out int sourceLine, out int sourceColumn); private static GetSourceLineInfoDelegate s_getSourceLineInfo = null; @@ -64,6 +65,7 @@ namespace System.Diagnostics rgiOffset = null; rgiILOffset = null; rgAssemblyPath = null; + rgAssembly = null; rgLoadedPeAddress = null; rgiLoadedPeSize = null; rgInMemoryPdbAddress = null; @@ -138,7 +140,7 @@ namespace System.Diagnostics // ENC or the source/line info was already retrieved, the method token is 0. if (rgiMethodToken[index] != 0) { - s_getSourceLineInfo(rgAssemblyPath[index], rgLoadedPeAddress[index], rgiLoadedPeSize[index], + s_getSourceLineInfo(rgAssembly[index], rgAssemblyPath[index], rgLoadedPeAddress[index], rgiLoadedPeSize[index], rgInMemoryPdbAddress[index], rgiInMemoryPdbSize[index], rgiMethodToken[index], rgiILOffset[index], out rgFilename[index], out rgiLineNumber[index], out rgiColumnNumber[index]); } diff --git a/src/coreclr/src/vm/debugdebugger.cpp b/src/coreclr/src/vm/debugdebugger.cpp index 3402a8b..a839340 100644 --- a/src/coreclr/src/vm/debugdebugger.cpp +++ b/src/coreclr/src/vm/debugdebugger.cpp @@ -402,6 +402,12 @@ FCIMPL4(void, DebugStackTrace::GetStackFramesInternal, SetObjectReference( (OBJECTREF *)&(pStackFrameHelper->rgAssemblyPath), (OBJECTREF)assemblyPathArray, pStackFrameHelper->GetAppDomain()); + // Allocate memory for the array of assemblies + MethodTable * pAssemblyMT = MscorlibBinder::GetClass(CLASS__ASSEMBLY); + PTRARRAYREF assemblyArray = (PTRARRAYREF) AllocateObjectArray(data.cElements, pAssemblyMT); + SetObjectReference( (OBJECTREF *)&(pStackFrameHelper->rgAssembly), (OBJECTREF)assemblyArray, + pStackFrameHelper->GetAppDomain()); + // Allocate memory for the LoadedPeAddress BASEARRAYREF loadedPeAddressArray = (BASEARRAYREF) AllocatePrimitiveArray(ELEMENT_TYPE_I, data.cElements); SetObjectReference( (OBJECTREF *)&(pStackFrameHelper->rgLoadedPeAddress), (OBJECTREF)loadedPeAddressArray, @@ -512,6 +518,10 @@ FCIMPL4(void, DebugStackTrace::GetStackFramesInternal, I4 *pILI4 = (I4 *)((I4ARRAYREF)pStackFrameHelper->rgiILOffset)->GetDirectPointerToNonObjectElements(); pILI4[iNumValidFrames] = data.pElements[i].dwILOffset; + // Assembly + OBJECTREF *pAssemblyArray = pStackFrameHelper->rgAssembly->GetDataPtr(); + pAssemblyArray[iNumValidFrames] = pFunc->GetAssembly()->GetDomainAssembly()->GetExposedAssemblyObject(); + if (data.fDoWeHaveAnyFramesFromForeignStackTrace) { // Set the BOOL indicating if the frame represents the last frame from a foreign exception stack trace. diff --git a/src/coreclr/src/vm/debugdebugger.h b/src/coreclr/src/vm/debugdebugger.h index 35758e1..e608ebd 100644 --- a/src/coreclr/src/vm/debugdebugger.h +++ b/src/coreclr/src/vm/debugdebugger.h @@ -48,6 +48,7 @@ public: PTRARRAYREF dynamicMethods; BASEARRAYREF rgMethodHandle; PTRARRAYREF rgAssemblyPath; + PTRARRAYREF rgAssembly; BASEARRAYREF rgLoadedPeAddress; I4ARRAYREF rgiLoadedPeSize; BASEARRAYREF rgInMemoryPdbAddress;