From: Mike McLaughlin Date: Mon, 8 Jul 2019 21:46:00 +0000 (-0700) Subject: Add Microsoft.DiaSymReader.Native to SOS package (#383) X-Git-Tag: submit/tizen/20190813.035844~4^2^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8f5fe7a0d67a688df2608d48a61c09b77545a528;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Add Microsoft.DiaSymReader.Native to SOS package (#383) Add Microsoft.DiaSymReader.Native to SOS package We no longer search for the diasymreader in the runtime host directory, DAC path, etc. because for WER/Watson/!analyze needs to work without assuming there is a .NET Core runtime to host on the machine. Update to version 1.1.35504 of clrmd. Fixes issues https://github.com/dotnet/diagnostics/issues/360 and "System.DllNotFoundException: Unable to load shared library 'libdl.so'..." failure. Cleanup symbinder instance and module --- diff --git a/.vsts-dotnet.yml b/.vsts-dotnet.yml index 39589a28e..85c38a0d7 100644 --- a/.vsts-dotnet.yml +++ b/.vsts-dotnet.yml @@ -250,7 +250,7 @@ phases: displayName: Copy Windows x64 Artifacts inputs: sourceFolder: '$(Build.SourcesDirectory)/artifacts/bin/Windows_NT.x64.Release' - contents: 'sos.dll' + contents: ?(sos.dll|Microsoft.DiaSymReader.Native.amd64.dll) targetFolder: '$(Build.SourcesDirectory)/artifacts/Windows_NT.x64.Release' condition: succeeded() @@ -276,7 +276,7 @@ phases: displayName: Copy Windows x86 Artifacts inputs: sourceFolder: '$(System.ArtifactsDirectory)/Windows_x86_Release' - contents: 'sos.dll' + contents: ?(sos.dll|Microsoft.DiaSymReader.Native.x86.dll) targetFolder: '$(Build.SourcesDirectory)/artifacts/bin/Windows_NT.x86.Release' condition: succeeded() @@ -302,7 +302,7 @@ phases: displayName: Copy Windows Arm Artifacts inputs: sourceFolder: '$(System.ArtifactsDirectory)/Windows_arm_Release' - contents: 'sos.dll' + contents: ?(sos.dll|Microsoft.DiaSymReader.Native.arm.dll) targetFolder: '$(Build.SourcesDirectory)/artifacts/bin/Windows_NT.arm.Release' condition: succeeded() diff --git a/eng/Build-Native.cmd b/eng/Build-Native.cmd index c865869cc..d073fa0b5 100644 --- a/eng/Build-Native.cmd +++ b/eng/Build-Native.cmd @@ -209,7 +209,7 @@ if /i %__BuildCrossArch% EQU 1 ( set "__ManagedBinaryDir=%__RootBinDir%\bin" set "__ManagedBinaryDir=!__ManagedBinaryDir:\=/!" - set __ExtraCmakeArgs="-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" "-DCLR_BUILD_TYPE=%__BuildType%" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCMAKE_SYSTEM_VERSION=10.0" + set __ExtraCmakeArgs="-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" "-DCLR_BUILD_TYPE=%__BuildType%" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCMAKE_SYSTEM_VERSION=10.0" "-DNUGET_PACKAGES=%NUGET_PACKAGES:\=/%" pushd "%__CrossCompIntermediatesDir%" call "%__ProjectDir%\eng\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__CrossArch% !__ExtraCmakeArgs! @@ -286,7 +286,7 @@ if %__Build% EQU 1 ( set "__ManagedBinaryDir=%__RootBinDir%\bin" set "__ManagedBinaryDir=!__ManagedBinaryDir:\=/!" - set __ExtraCmakeArgs=!___SDKVersion! "-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" "-DCLR_BUILD_TYPE=%__BuildType%" + set __ExtraCmakeArgs=!___SDKVersion! "-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" "-DCLR_BUILD_TYPE=%__BuildType%" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DNUGET_PACKAGES=%NUGET_PACKAGES:\=/%" pushd "%__IntermediatesDir%" call "%__ProjectDir%\eng\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs! diff --git a/eng/Versions.props b/eng/Versions.props index 48b13959c..1ca8fcc22 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -22,8 +22,8 @@ 1.0.0-dev-64131-02 - 1.0.5 - + 1.1.35504 + 1.7.0 2.0.43 0.2.0-alpha.19254.1 0.2.0-alpha.19254.1 diff --git a/eng/create-gallery-zip.ps1 b/eng/create-gallery-zip.ps1 index d04a2aee0..c8d77db9c 100644 --- a/eng/create-gallery-zip.ps1 +++ b/eng/create-gallery-zip.ps1 @@ -20,10 +20,13 @@ mkdir -Force "$GalleryDir\arm32" mkdir -Force "$ZipFilePath" Copy-Item $BinDir\Windows_NT.x64.Release\sos.dll $GalleryDir\x64 +Copy-Item $BinDir\Windows_NT.x64.Release\Microsoft.DiaSymReader.Native.amd64.dll $GalleryDir\x64 Copy-Item $SOSNETCorePath\*.dll $GalleryDir\x64 Copy-Item $BinDir\Windows_NT.x86.Release\sos.dll $GalleryDir\x86 +Copy-Item $BinDir\Windows_NT.x86.Release\Microsoft.DiaSymReader.Native.x86.dll $GalleryDir\x86 Copy-Item $SOSNETCorePath\*.dll $GalleryDir\x86 Copy-Item $BinDir\Windows_NT.arm.Release\sos.dll $GalleryDir\arm32 +Copy-Item $BinDir\Windows_NT.arm.Release\Microsoft.DiaSymReader.Native.arm.dll $GalleryDir\arm32 Copy-Item $SOSNETCorePath\*.dll $GalleryDir\arm32 cat $SourceDirectory\eng\GalleryManifest.xml | %{$_ -replace "X.X.X.X","$SOSGalleryVersion"} | Set-Content $BinDir\gallery\GalleryManifest.xml diff --git a/src/SOS/SOS.NETCore/CMakeLists.txt b/src/SOS/SOS.NETCore/CMakeLists.txt index 4c09fbf61..e92f5891f 100644 --- a/src/SOS/SOS.NETCore/CMakeLists.txt +++ b/src/SOS/SOS.NETCore/CMakeLists.txt @@ -10,3 +10,17 @@ if(NOT ${CLR_MANAGED_BINARY_DIR} STREQUAL "") install(FILES ${MANAGED_BINDIR}/System.Reflection.Metadata.dll DESTINATION . ) install(FILES ${MANAGED_BINDIR}/System.Collections.Immutable.dll DESTINATION . ) endif() + +if(NOT ${NUGET_PACKAGES} STREQUAL "") + set(DIASYMREADER_ARCH ${CLR_CMAKE_TARGET_ARCH}) + + if(NOT(CLR_CMAKE_TARGET_ARCH STREQUAL CLR_CMAKE_HOST_ARCH)) + set(DIASYMREADER_ARCH ${CLR_CMAKE_HOST_ARCH}) + endif() + + if (DIASYMREADER_ARCH STREQUAL x64) + set(DIASYMREADER_ARCH amd64) + endif() + + install(FILES ${NUGET_PACKAGES}/microsoft.diasymreader.native/1.7.0/runtimes/win/native/Microsoft.DiaSymReader.Native.${DIASYMREADER_ARCH}.dll DESTINATION . ) +endif() diff --git a/src/SOS/SOS.NETCore/SOS.NETCore.csproj b/src/SOS/SOS.NETCore/SOS.NETCore.csproj index 05949636f..8de923a3a 100644 --- a/src/SOS/SOS.NETCore/SOS.NETCore.csproj +++ b/src/SOS/SOS.NETCore/SOS.NETCore.csproj @@ -12,5 +12,6 @@ + diff --git a/src/SOS/Strike/hostcoreclr.cpp b/src/SOS/Strike/hostcoreclr.cpp index 1447718a5..05c90b4d9 100644 --- a/src/SOS/Strike/hostcoreclr.cpp +++ b/src/SOS/Strike/hostcoreclr.cpp @@ -47,6 +47,10 @@ LPCSTR g_dacFilePath = nullptr; LPCSTR g_dbiFilePath = nullptr; LPCSTR g_tmpPath = nullptr; SOSNetCoreCallbacks g_SOSNetCoreCallbacks; +#ifndef FEATURE_PAL +HMODULE g_hmoduleSymBinder = nullptr; +ISymUnmanagedBinder3 *g_pSymBinder = nullptr; +#endif #ifdef FEATURE_PAL #define TPALIST_SEPARATOR_STR_A ":" @@ -667,7 +671,7 @@ HRESULT InitializeHosting() if (GetModuleFileNameA(g_hInstance, szSOSModulePath, MAX_LONGPATH) == 0) { ExtErr("Error: Failed to get SOS module directory\n"); - return E_FAIL; + return HRESULT_FROM_WIN32(GetLastError()); } sosModuleDirectory = szSOSModulePath; @@ -947,6 +951,60 @@ HRESULT GetMetadataLocator( return g_SOSNetCoreCallbacks.GetMetadataLocatorDelegate(imagePath, imageTimestamp, imageSize, mvid, mdRva, flags, bufferSize, buffer, dataSize); } +#ifndef FEATURE_PAL + +/**********************************************************************\ +* A typesafe version of GetProcAddress +\**********************************************************************/ +template +BOOL GetProcAddressT(PCSTR FunctionName, PCSTR DllName, T* OutFunctionPointer, HMODULE* InOutDllHandle) +{ + _ASSERTE(InOutDllHandle != NULL); + _ASSERTE(OutFunctionPointer != NULL); + + T FunctionPointer = NULL; + HMODULE DllHandle = *InOutDllHandle; + if (DllHandle == NULL) + { + DllHandle = LoadLibraryEx(DllName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + if (DllHandle != NULL) + *InOutDllHandle = DllHandle; + } + if (DllHandle != NULL) + { + FunctionPointer = (T) GetProcAddress(DllHandle, FunctionName); + } + *OutFunctionPointer = FunctionPointer; + return FunctionPointer != NULL; +} + +/**********************************************************************\ +* CreateInstanceFromPath() instantiates a COM object using a passed in * +* fully-qualified path and a CLSID. * +\**********************************************************************/ +HRESULT CreateInstanceFromPath(REFCLSID clsid, REFIID iid, LPCSTR path, HMODULE* pModuleHandle, void** ppItf) +{ + HRESULT (__stdcall *pfnDllGetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID *ppv) = NULL; + HRESULT hr = S_OK; + + if (!GetProcAddressT("DllGetClassObject", path, &pfnDllGetClassObject, pModuleHandle)) { + return REGDB_E_CLASSNOTREG; + } + ToRelease pFactory; + if (SUCCEEDED(hr = pfnDllGetClassObject(clsid, IID_IClassFactory, (void**)&pFactory))) { + if (SUCCEEDED(hr = pFactory->CreateInstance(NULL, iid, ppItf))) { + return S_OK; + } + } + if (*pModuleHandle != NULL) { + FreeLibrary(*pModuleHandle); + *pModuleHandle = NULL; + } + return hr; +} + +#endif // FEATURE_PAL + /**********************************************************************\ * Load symbols for an ICorDebugModule. Used by "clrstack -i". \**********************************************************************/ @@ -1029,6 +1087,20 @@ HRESULT SymbolReader::LoadSymbols(___in IMetaDataImport* pMD, ___in IXCLRDataMod #ifndef FEATURE_PAL +static void CleanupSymBinder() +{ + if (g_pSymBinder != nullptr) + { + g_pSymBinder->Release(); + g_pSymBinder = nullptr; + } + if (g_hmoduleSymBinder != nullptr) + { + FreeLibrary(g_hmoduleSymBinder); + g_hmoduleSymBinder = nullptr; + } +} + /**********************************************************************\ * Attempts to load Windows PDBs on Windows. \**********************************************************************/ @@ -1039,22 +1111,38 @@ HRESULT SymbolReader::LoadSymbolsForWindowsPDB(___in IMetaDataImport* pMD, ___in if (m_pSymReader != NULL) return S_OK; - // Ignore errors to be able to run under a managed host (dotnet-dump). - CoInitialize(NULL); - - // We now need a binder object that will take the module and return a - ToRelease pSymBinder; - if (FAILED(Status = CreateInstanceCustom(CLSID_CorSymBinder_SxS, - IID_ISymUnmanagedBinder3, - NATIVE_SYMBOL_READER_DLL, - cciDacColocated|cciDbgPath, - (void**)&pSymBinder))) + if (g_pSymBinder == nullptr) { - ExtOut("SOS Error: Unable to CoCreateInstance class=CLSID_CorSymBinder_SxS, interface=IID_ISymUnmanagedBinder3, hr=0x%x\n", Status); - ExtOut("This usually means SOS was unable to locate a suitable version of DiaSymReader. The dll searched for was '%S'\n", NATIVE_SYMBOL_READER_DLL); - return Status; - } + // Ignore errors to be able to run under a managed host (dotnet-dump). + CoInitialize(NULL); + + std::string diasymreaderPath; + ArrayHolder szSOSModulePath = new char[MAX_LONGPATH + 1]; + if (GetModuleFileNameA(g_hInstance, szSOSModulePath, MAX_LONGPATH) == 0) + { + ExtErr("Error: Failed to get SOS module directory\n"); + return HRESULT_FROM_WIN32(GetLastError()); + } + diasymreaderPath = szSOSModulePath; + + // Get just the sos module directory + size_t lastSlash = diasymreaderPath.rfind(DIRECTORY_SEPARATOR_CHAR_A); + if (lastSlash == std::string::npos) + { + ExtErr("Error: Failed to parse sos module name\n"); + return E_FAIL; + } + diasymreaderPath.erase(lastSlash + 1); + diasymreaderPath.append(NATIVE_SYMBOL_READER_DLL); + // We now need a binder object that will take the module and return a + if (FAILED(Status = CreateInstanceFromPath(CLSID_CorSymBinder_SxS, IID_ISymUnmanagedBinder3, diasymreaderPath.c_str(), &g_hmoduleSymBinder, (void**)&g_pSymBinder))) + { + ExtOut("SOS error: Unable to find the diasymreader module/interface %08x at %s\n", Status, diasymreaderPath.c_str()); + return Status; + } + OnUnloadTask::Register(CleanupSymBinder); + } ToRelease spSym3(NULL); Status = g_ExtSymbols->QueryInterface(__uuidof(IDebugSymbols3), (void**)&spSym3); if (FAILED(Status)) @@ -1090,7 +1178,7 @@ HRESULT SymbolReader::LoadSymbolsForWindowsPDB(___in IMetaDataImport* pMD, ___in } // TODO: this should be better integrated with windbg's symbol lookup - Status = pSymBinder->GetReaderFromCallback(pMD, pModuleName, symbolPath, + Status = g_pSymBinder->GetReaderFromCallback(pMD, pModuleName, symbolPath, AllowRegistryAccess | AllowSymbolServerAccess | AllowOriginalPathAccess | AllowReferencePathAccess, pCallback, &m_pSymReader); if (FAILED(Status) && m_pSymReader != NULL) diff --git a/src/SOS/Strike/util.cpp b/src/SOS/Strike/util.cpp index 8bc368dea..651950af0 100644 --- a/src/SOS/Strike/util.cpp +++ b/src/SOS/Strike/util.cpp @@ -74,22 +74,12 @@ ICorDebugProcess *g_pCorDebugProcess = NULL; #define IfFailRet(EXPR) do { Status = (EXPR); if(FAILED(Status)) { return (Status); } } while (0) #endif -#ifndef IfFailGoto -#define IfFailGoto(EXPR, label) do { Status = (EXPR); if(FAILED(Status)) { goto label; } } while (0) -#endif // IfFailGoto - -#ifndef IfFailGo -#define IfFailGo(EXPR) IfFailGoto(EXPR, Error) -#endif // IfFailGo - // Max number of reverted rejit versions that !dumpmd and !ip2md will print const UINT kcMaxRevertedRejitData = 10; const UINT kcMaxTieredVersions = 10; #ifndef FEATURE_PAL -extern LPCSTR GetHostRuntimeDirectory(); - // ensure we always allocate on the process heap void* __cdecl operator new(size_t size) throw() { return HeapAlloc(GetProcessHeap(), 0, size); } @@ -101,334 +91,6 @@ void* __cdecl operator new[](size_t size) throw() void __cdecl operator delete[](void* pObj) throw() { HeapFree(GetProcessHeap(), 0, pObj); } -/**********************************************************************\ -* Here we define types and functions that support custom COM * -* activation rules, as defined by the CIOptions enum. * -* * -\**********************************************************************/ - -typedef unsigned __int64 QWORD; - -namespace com_activation -{ - // - // Forward declarations for the implementation methods - // - - HRESULT CreateInstanceCustomImpl( - REFCLSID clsid, - REFIID iid, - LPCWSTR dllName, - CIOptions cciOptions, - void** ppItf); - - HRESULT CreateInstanceFromPath( - REFCLSID clsid, - REFIID iid, - LPCWSTR path, - void** ppItf); - - BOOL GetPathFromModule( - HMODULE hModule, - __in_ecount(cFqPath) LPWSTR fqPath, - DWORD cFqPath); - - void CleanupClsidHmodMap(); - - // Helper structures for defining the CLSID -> HMODULE hash table we - // use for caching already activated objects - class hash_compareGUID - { - public: - static const size_t bucket_size = 4; - static const size_t min_buckets = 8; - hash_compareGUID() - { } - - size_t operator( )(const GUID& _Key) const - { - DWORD *pdw = (DWORD*)&_Key; - return (size_t)(pdw[0] ^ pdw[1] ^ pdw[2] ^ pdw[3]); - } - - bool operator( )(const GUID& _Key1, const GUID& _Key2) const - { return memcmp(&_Key1, &_Key2, sizeof(GUID)) == -1; } - }; - - static std::unordered_map *g_pClsidHmodMap = NULL; - - - -/**********************************************************************\ -* Routine Description: * -* * -* CreateInstanceCustomImpl() provides a way to activate a COM object * -* w/o triggering the FeatureOnDemand dialog. In order to do this we * -* must avoid using the CoCreateInstance() API, which, on a machine * -* with v4+ installed and w/o v2, would trigger this. * -* CreateInstanceCustom() activates the requested COM object according * -* to the specified passed in CIOptions, in the following order * -* (skipping the steps not enabled in the CIOptions flags passed in): * -* 1. Attempt to activate the COM object using a framework install: * -* a. If the debugger machine has a V4+ shell shim use the shim * -* to activate the object * -* b. Otherwise simply call CoCreateInstance * -* 2. If unsuccessful attempt to activate looking for the dllName in * -* the same folder as the DAC was loaded from * -* 3. If unsuccessful attempt to activate the COM object looking in * -* every path specified in the debugger's .exepath and .sympath * -\**********************************************************************/ -HRESULT CreateInstanceCustomImpl( - REFCLSID clsid, - REFIID iid, - LPCWSTR dllName, - CIOptions cciOptions, - void** ppItf) -{ - _ASSERTE(ppItf != NULL); - _ASSERTE(dllName != NULL); - - if (ppItf == NULL || dllName == NULL) - return E_POINTER; - - WCHAR wszClsid[64] = W(""); - - // Step 1: attempt activation using the host runtime directory - LPCSTR hostRuntimeDirectory = GetHostRuntimeDirectory(); - if (hostRuntimeDirectory != nullptr) - { - ArrayHolder path = new WCHAR[MAX_LONGPATH]; - int length = MultiByteToWideChar(CP_ACP, 0, hostRuntimeDirectory, -1, path, MAX_LONGPATH); - if (length > 0) - { - if (wcscat_s(path, MAX_LONGPATH, W("\\")) == 0 && wcscat_s(path, MAX_LONGPATH, dllName) == 0 && - SUCCEEDED(CreateInstanceFromPath(clsid, iid, path, ppItf))) - { - return S_OK; - } - } - } - - // Step 2: attempt activation using the folder the DAC was loaded from - if ((cciOptions & cciDacColocated) != 0) - { - HMODULE hDac = NULL; - ArrayHolder path = new WCHAR[MAX_LONGPATH]; - - if (SUCCEEDED(g_sos->GetDacModuleHandle(&hDac)) && - GetPathFromModule(hDac, path, MAX_LONGPATH)) - { - // build the fully qualified file name and attempt instantiation - if (wcscat_s(path, MAX_LONGPATH, dllName) == 0 && - SUCCEEDED(CreateInstanceFromPath(clsid, iid, path, ppItf))) - { - return S_OK; - } - } - - ExtDbgOut("Failed to instantiate {%ls} from DAC location.\n", wszClsid); - } - - // Step 3: attempt activation using the debugger's .exepath and .sympath - if ((cciOptions & cciDbgPath) != 0) - { - ToRelease spSym3(NULL); - HRESULT hr = g_ExtSymbols->QueryInterface(__uuidof(IDebugSymbols3), (void**)&spSym3); - if (FAILED(hr)) - { - ExtDbgOut("Unable to query IDebugSymbol3 HRESULT=0x%x.\n", hr); - goto ErrDbgPath; - } - - typedef HRESULT (__stdcall IDebugSymbols3::*GetPathFunc)(LPWSTR , ULONG, ULONG*); - - { - // Handle both the image path and the symbol path - GetPathFunc rgGetPathFuncs[] = - { &IDebugSymbols3::GetImagePathWide, &IDebugSymbols3::GetSymbolPathWide }; - - for (int i = 0; i < _countof(rgGetPathFuncs); ++i) - { - ULONG pathSize = 0; - - // get the path buffer size - if ((spSym3.GetPtr()->*rgGetPathFuncs[i])(NULL, 0, &pathSize) != S_OK) - { - continue; - } - - ArrayHolder imgPath = new WCHAR[pathSize+MAX_LONGPATH+1]; - - // actually get the path - if ((spSym3.GetPtr()->*rgGetPathFuncs[i])(imgPath, pathSize, NULL) != S_OK) - { - continue; - } - - LPWSTR ctx; - LPCWSTR pathElem = wcstok_s(imgPath, W(";"), &ctx); - while (pathElem != NULL) - { - ArrayHolder path = new WCHAR[MAX_LONGPATH]; - wcscpy_s(path, MAX_LONGPATH, pathElem); - if (wcscat_s(path, MAX_LONGPATH, W("\\")) == 0 && wcscat_s(path, MAX_LONGPATH, dllName) == 0) - { - if (SUCCEEDED(CreateInstanceFromPath(clsid, iid, path, ppItf))) - { - return S_OK; - } - } - - pathElem = wcstok_s(NULL, W(";"), &ctx); - } - } - } - - ErrDbgPath: - ExtDbgOut("Failed to instantiate {%ls} from debugger's image path.\n", wszClsid); - } - - return REGDB_E_CLASSNOTREG; -} - - -/**********************************************************************\ -* Routine Description: * -* * -* CreateInstanceFromPath() instantiates a COM object using a passed in * -* fully-qualified path and a CLSID. * -* * -* Note: * -* * -* It uses a unordered_map to cache the mapping between a CLSID and the * -* HMODULE that is successfully used to activate the CLSID from. When * -* SOS is unloaded (in DebugExtensionUninitialize()) we call * -* FreeLibrary() for all cached HMODULEs. * -\**********************************************************************/ -HRESULT CreateInstanceFromPath( - REFCLSID clsid, - REFIID iid, - LPCWSTR path, - void** ppItf) -{ - HRESULT Status = S_OK; - HRESULT (__stdcall *pfnDllGetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID *ppv) = NULL; - - HMODULE hmod = NULL; - - if (g_pClsidHmodMap == NULL) - { - g_pClsidHmodMap = new std::unordered_map(); - OnUnloadTask::Register(CleanupClsidHmodMap); - } - - auto it = g_pClsidHmodMap->find(clsid); - if (it != g_pClsidHmodMap->end()) - hmod = it->second; - - if (!GetProcAddressT("DllGetClassObject", path, &pfnDllGetClassObject, &hmod)) - return REGDB_E_CLASSNOTREG; - - ToRelease pFactory; - IfFailGo(pfnDllGetClassObject(clsid, IID_IClassFactory, (void**)&pFactory)); - - IfFailGo(pFactory->CreateInstance(NULL, iid, ppItf)); - - // only cache the HMODULE if we successfully created the COM object - (*g_pClsidHmodMap)[clsid] = hmod; - - return S_OK; - -Error: - if (hmod != NULL) - FreeLibrary(hmod); - - return Status; -} - - -/**********************************************************************\ -* Routine Description: * -* * -* CleanupClsidHmodMap() cleans up the CLSID -> HMODULE map used to * -* cache successful activations from specific paths. This is registered * -* as an OnUnloadTask in CreateInstanceFromPath(), and executes when * -* SOS is unloaded, in DebugExtensionUninitialize(). * -\**********************************************************************/ -void CleanupClsidHmodMap() -{ - if (g_pClsidHmodMap != NULL) - { - for (auto it = g_pClsidHmodMap->begin(); it != g_pClsidHmodMap->end(); ++it) - { - _ASSERTE(it->second != NULL); - FreeLibrary(it->second); - } - - delete g_pClsidHmodMap; - g_pClsidHmodMap = NULL; - } -} - - -/**********************************************************************\ -* Routine Description: * -* * -* GetPathFromModule() returns the name of the folder containing the * -* file associated with hModule. * - \**********************************************************************/ -BOOL GetPathFromModule( - HMODULE hModule, - __in_ecount(cFqPath) LPWSTR fqPath, - DWORD cFqPath) -{ - int len = GetModuleFileNameW(hModule, fqPath, cFqPath); - if (len == 0 || len == cFqPath) - return FALSE; - - WCHAR *pLastSep = _wcsrchr(fqPath, DIRECTORY_SEPARATOR_CHAR_W); - if (pLastSep == NULL || pLastSep+1 >= fqPath+cFqPath) - return FALSE; - - *(pLastSep+1) = L'\0'; - - return TRUE; -} - -} - -/**********************************************************************\ -* Routine Description: * -* * -* CreateInstanceCustom() provides a way to activate a COM object w/o * -* triggering the FeatureOnDemand dialog. In order to do this we * -* must avoid using the CoCreateInstance() API, which, on a machine * -* with v4+ installed and w/o v2, would trigger this. * -* CreateInstanceCustom() activates the requested COM object according * -* to the specified passed in CIOptions, in the following order * -* (skipping the steps not enabled in the CIOptions flags passed in): * -* 1. Attempt to activate the COM object using a framework install: * -* a. If the debugger machine has a V4+ shell shim use the shim * -* to activate the object * -* b. Otherwise simply call CoCreateInstance * -* 2. If unsuccessful attempt to activate looking for the dllName in * -* the same folder as the DAC was loaded from * -* 3. If unsuccessful attempt to activate the COM object looking in * -* every path specified in the debugger's .exepath and .sympath * -\**********************************************************************/ -HRESULT CreateInstanceCustom( - REFCLSID clsid, - REFIID iid, - LPCWSTR dllName, - CIOptions cciOptions, - void** ppItf) -{ - return com_activation::CreateInstanceCustomImpl(clsid, iid, dllName, cciOptions, ppItf); -} - - - - /**********************************************************************\ * Routine Description: * * * diff --git a/src/SOS/Strike/util.h b/src/SOS/Strike/util.h index 14a205de7..07a930561 100644 --- a/src/SOS/Strike/util.h +++ b/src/SOS/Strike/util.h @@ -89,15 +89,15 @@ DECLARE_HANDLE(OBJECTHANDLE); // The native symbol reader dll name #if defined(_AMD64_) -#define NATIVE_SYMBOL_READER_DLL W("Microsoft.DiaSymReader.Native.amd64.dll") +#define NATIVE_SYMBOL_READER_DLL "Microsoft.DiaSymReader.Native.amd64.dll" #elif defined(_X86_) -#define NATIVE_SYMBOL_READER_DLL W("Microsoft.DiaSymReader.Native.x86.dll") +#define NATIVE_SYMBOL_READER_DLL "Microsoft.DiaSymReader.Native.x86.dll" #elif defined(_ARM_) -#define NATIVE_SYMBOL_READER_DLL W("Microsoft.DiaSymReader.Native.arm.dll") +#define NATIVE_SYMBOL_READER_DLL "Microsoft.DiaSymReader.Native.arm.dll" #elif defined(_ARM64_) // Use diasymreader until the package has an arm64 version - issue #7360 -//#define NATIVE_SYMBOL_READER_DLL W("Microsoft.DiaSymReader.Native.arm64.dll") -#define NATIVE_SYMBOL_READER_DLL W("diasymreader.dll") +//#define NATIVE_SYMBOL_READER_DLL "Microsoft.DiaSymReader.Native.arm64.dll" +#define NATIVE_SYMBOL_READER_DLL "diasymreader.dll" #endif // PREFIX macros - Begin @@ -3056,78 +3056,6 @@ private: UnderlyingType m_val; }; -#ifndef FEATURE_PAL - -// Flags defining activation policy for COM objects -enum CIOptionsBits -{ - cciDacColocated = 0x01, // Look next to the already loaded DAC module - cciDbgPath = 0x02, // Look in all folders in the debuggers symbols and binary path -}; - -typedef Flags CIOptions; - -/**********************************************************************\ -* Routine Description: * -* * -* CreateInstanceCustom() provides a way to activate a COM object w/o * -* triggering the FeatureOnDemand dialog. In order to do this we * -* must avoid using the CoCreateInstance() API, which, on a machine * -* with v4+ installed and w/o v2, would trigger this. * -* CreateInstanceCustom() activates the requested COM object according * -* to the specified passed in CIOptions, in the following order * -* (skipping the steps not enabled in the CIOptions flags passed in): * -* 1. Attempt to activate the COM object using a framework install: * -* a. If the debugger machine has a V4+ shell shim use the shim * -* to activate the object * -* b. Otherwise simply call CoCreateInstance * -* 2. If unsuccessful attempt to activate looking for the dllName in * -* the same folder as the DAC was loaded from * -* 3. If unsuccessful attempt to activate the COM object looking in * -* every path specified in the debugger's .exepath and .sympath * -\**********************************************************************/ -HRESULT CreateInstanceCustom( - REFCLSID clsid, - REFIID iid, - LPCWSTR dllName, - CIOptions cciOptions, - void** ppItf); - - -//------------------------------------------------------------------------ -// A typesafe version of GetProcAddress -//------------------------------------------------------------------------ -template -BOOL -GetProcAddressT( - ___in PCSTR FunctionName, - __in_opt PCWSTR DllName, - __inout T* OutFunctionPointer, - __inout HMODULE* InOutDllHandle - ) -{ - _ASSERTE(InOutDllHandle != NULL); - _ASSERTE(OutFunctionPointer != NULL); - - T FunctionPointer = NULL; - HMODULE DllHandle = *InOutDllHandle; - if (DllHandle == NULL) - { - DllHandle = LoadLibraryExW(DllName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - if (DllHandle != NULL) - *InOutDllHandle = DllHandle; - } - if (DllHandle != NULL) - { - FunctionPointer = (T) GetProcAddress(DllHandle, FunctionName); - } - *OutFunctionPointer = FunctionPointer; - return FunctionPointer != NULL; -} - - -#endif // FEATURE_PAL - struct ImageInfo { ULONG64 modBase; diff --git a/src/Tools/dotnet-dump/Commands/ModulesCommand.cs b/src/Tools/dotnet-dump/Commands/ModulesCommand.cs index 2bbb4f2fd..6d0b0a9d1 100644 --- a/src/Tools/dotnet-dump/Commands/ModulesCommand.cs +++ b/src/Tools/dotnet-dump/Commands/ModulesCommand.cs @@ -33,7 +33,6 @@ namespace Microsoft.Diagnostics.Tools.Dump if (module.BuildId != null) { WriteLine(" BuildId: {0}", string.Concat(module.BuildId.Select((b) => b.ToString("x2")))); } - WriteLine(" IsRuntime: {0}", module.IsRuntime); WriteLine(" IsManaged: {0}", module.IsManaged); } else diff --git a/src/Tools/sos-packaging.props b/src/Tools/sos-packaging.props index df6012b8f..a70a37bd0 100644 --- a/src/Tools/sos-packaging.props +++ b/src/Tools/sos-packaging.props @@ -10,18 +10,29 @@ tools/$(TargetFramework)/any/win-x64 + + tools/$(TargetFramework)/any/win-x64 + + tools/$(TargetFramework)/any/win-x86 tools/$(TargetFramework)/any/win-x86 + + tools/$(TargetFramework)/any/win-x86 + + tools/$(TargetFramework)/any/win-arm tools/$(TargetFramework)/any/win-arm + + tools/$(TargetFramework)/any/win-arm + tools/$(TargetFramework)/any/linux-x64