Add Microsoft.DiaSymReader.Native to SOS package (#383)
authorMike McLaughlin <mikem@microsoft.com>
Mon, 8 Jul 2019 21:46:00 +0000 (14:46 -0700)
committerGitHub <noreply@github.com>
Mon, 8 Jul 2019 21:46:00 +0000 (14:46 -0700)
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

.vsts-dotnet.yml
eng/Build-Native.cmd
eng/Versions.props
eng/create-gallery-zip.ps1
src/SOS/SOS.NETCore/CMakeLists.txt
src/SOS/SOS.NETCore/SOS.NETCore.csproj
src/SOS/Strike/hostcoreclr.cpp
src/SOS/Strike/util.cpp
src/SOS/Strike/util.h
src/Tools/dotnet-dump/Commands/ModulesCommand.cs
src/Tools/sos-packaging.props

index 39589a28ec16c119f7e6a823c3ab2fbb24692de4..85c38a0d769c14b42bad010dd8edefb23d8fdbeb 100644 (file)
@@ -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()
 
index c865869cca28b70152b9706c0666d31c4a622db3..d073fa0b51d5e128f7f53439f29fb24cc91914e7 100644 (file)
@@ -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!
index 48b13959c2d9e68a12837106b979644626a1ae84..1ca8fcc22ce4892cec9ee5f57e84d3845c3f4d82 100644 (file)
@@ -22,8 +22,8 @@
 
     <!-- Other libs -->
     <MicrosoftSymbolStoreVersion>1.0.0-dev-64131-02</MicrosoftSymbolStoreVersion>
-    <MicrosoftDiagnosticsRuntimeVersion>1.0.5</MicrosoftDiagnosticsRuntimeVersion>
-
+    <MicrosoftDiagnosticsRuntimeVersion>1.1.35504</MicrosoftDiagnosticsRuntimeVersion>
+    <MicrosoftDiaSymReaderNativePackageVersion>1.7.0</MicrosoftDiaSymReaderNativePackageVersion>
     <MicrosoftDiagnosticsTracingTraceEventVersion>2.0.43</MicrosoftDiagnosticsTracingTraceEventVersion>
     <SystemCommandLineExperimentalVersion>0.2.0-alpha.19254.1</SystemCommandLineExperimentalVersion>
     <SystemCommandLineRenderingVersion>0.2.0-alpha.19254.1</SystemCommandLineRenderingVersion>
index d04a2aee0f2c6f56f59ca7f6e057441545fde818..c8d77db9cefffd0d40fa6fd991801ec91803df2d 100644 (file)
@@ -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
 
index 4c09fbf616623008f921979e2c159198165771dc..e92f5891f8abb60f9130f502e965156fd409fb63 100644 (file)
@@ -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()
index 05949636f4ac6d4b0520b25f8ae69801766f834b..8de923a3ae94d0754278e80aaa5c85cf6414378f 100644 (file)
@@ -12,5 +12,6 @@
   <ItemGroup>
     <PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" />
     <PackageReference Include="Microsoft.SymbolStore" Version="$(MicrosoftSymbolStoreVersion)" />
+    <PackageReference Include="Microsoft.DiaSymReader.Native" Version="$(MicrosoftDiaSymReaderNativePackageVersion)" Condition="'$(OS)' == 'Windows_NT'" />
   </ItemGroup>
 </Project>
index 1447718a5eea7cc1f6bd9273f2d6b5c96fa3fdae..05c90b4d94343d4f857cf96981a05ee42bd59109 100644 (file)
@@ -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 <typename T>
+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<IClassFactory> 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<ISymUnmanagedBinder3> 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<char> 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<IDebugSymbols3> 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)
index 8bc368dea0246f8048c518e8d9eb82d804350318..651950af0506151af858c87a46294f41ac0eb2d3 100644 (file)
@@ -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<GUID, HMODULE, hash_compareGUID> *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("<CLSID>");
-
-    // Step 1: attempt activation using the host runtime directory
-    LPCSTR hostRuntimeDirectory = GetHostRuntimeDirectory();
-    if (hostRuntimeDirectory != nullptr)
-    {
-        ArrayHolder<WCHAR> 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<WCHAR> 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<IDebugSymbols3> 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<WCHAR> 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<WCHAR> 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<GUID, HMODULE, hash_compareGUID>();
-        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<IClassFactory> 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:                                                 *
 *                                                                      *
index 14a205de7d32464e81fba0682de37ddafc4dae23..07a93056161b0dd56ce97bade0792207db7d2f2c 100644 (file)
@@ -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<DWORD, CIOptionsBits> 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 <typename T>
-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;
index 2bbb4f2fdc8d1a0572818809e9e65109e81dd0cc..6d0b0a9d11204aa542a04a7c83d5032ae2256b60 100644 (file)
@@ -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
index df6012b8f8b2fb93ed1b62a58681b1b048c22c65..a70a37bd0ff8a0945d7c484a2b8394677e9bb1d9 100644 (file)
     <None Include="$(ArtifactsBinDir)\Windows_NT.x64.$(Configuration)\sos.dll" Pack="true" Visible="false">
       <PackagePath>tools/$(TargetFramework)/any/win-x64</PackagePath>
     </None>
+    <None Include="$(ArtifactsBinDir)\Windows_NT.x64.$(Configuration)\Microsoft.DiaSymReader.Native.amd64.dll" Pack="true" Visible="false">
+      <PackagePath>tools/$(TargetFramework)/any/win-x64</PackagePath>
+    </None>
+      
     <None Include="$(SOSNETCoreBinaries)" Pack="true" Visible="false">
       <PackagePath>tools/$(TargetFramework)/any/win-x86</PackagePath>
     </None>
     <None Include="$(ArtifactsBinDir)\Windows_NT.x86.$(Configuration)\sos.dll" Pack="true" Visible="false">
       <PackagePath>tools/$(TargetFramework)/any/win-x86</PackagePath>
     </None>
+    <None Include="$(ArtifactsBinDir)\Windows_NT.x86.$(Configuration)\Microsoft.DiaSymReader.Native.x86.dll" Pack="true" Visible="false">
+      <PackagePath>tools/$(TargetFramework)/any/win-x86</PackagePath>
+    </None>
+      
     <None Include="$(SOSNETCoreBinaries)" Pack="true" Visible="false">
       <PackagePath>tools/$(TargetFramework)/any/win-arm</PackagePath>
     </None>
     <None Include="$(ArtifactsBinDir)\Windows_NT.arm.$(Configuration)\sos.dll" Pack="true" Visible="false">
       <PackagePath>tools/$(TargetFramework)/any/win-arm</PackagePath>
     </None>
+    <None Include="$(ArtifactsBinDir)\Windows_NT.arm.$(Configuration)\Microsoft.DiaSymReader.Native.arm.dll" Pack="true" Visible="false">
+      <PackagePath>tools/$(TargetFramework)/any/win-arm</PackagePath>
+    </None>
 
     <None Include="$(SOSNETCoreBinaries)" Pack="true" Visible="false">
       <PackagePath>tools/$(TargetFramework)/any/linux-x64</PackagePath>