summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Robinson <arobins@microsoft.com>2019-01-14 18:41:00 -0800
committerGitHub <noreply@github.com>2019-01-14 18:41:00 -0800
commitdbdae9cc324a97ebc9199b973abe9a21b1177f01 (patch)
tree81f6b4658bc0bda942e232787cf743337c8ed332
parentf2d3dfeda5140ea003f0dae166cc62f0fb1d31d8 (diff)
downloadcoreclr-dbdae9cc324a97ebc9199b973abe9a21b1177f01.tar.gz
coreclr-dbdae9cc324a97ebc9199b973abe9a21b1177f01.tar.bz2
coreclr-dbdae9cc324a97ebc9199b973abe9a21b1177f01.zip
Finding Standalone GC and CoreDisTools in non-standard host testing (#21983)
* Use GetInternalSystemDirectory() as the directory for standalone GC * Use GetInternalSystemDirectory() as the directory for coredistools
-rwxr-xr-xsrc/vm/disassembler.cpp57
-rw-r--r--src/vm/gcheaputilities.cpp24
2 files changed, 24 insertions, 57 deletions
diff --git a/src/vm/disassembler.cpp b/src/vm/disassembler.cpp
index 6bb80f1d44..77497f66da 100755
--- a/src/vm/disassembler.cpp
+++ b/src/vm/disassembler.cpp
@@ -79,61 +79,14 @@ namespace
{
LIMITED_METHOD_CONTRACT;
- //
- // Look for the coredistools module next to the hosting binary
- //
-
- DWORD result = WszGetModuleFileName(nullptr, libPath);
- if (result == 0)
- {
- DISPLAYERROR(
- W("GetModuleFileName failed, function 'DisasmInstruction': error %u\n"),
- GetLastError());
- return nullptr;
- }
-
+ LPCWSTR sysDirectory = GetInternalSystemDirectory();
LPCWSTR libFileName = MAKEDLLNAME(W("coredistools"));
- PathString::Iterator iter = libPath.End();
- if (libPath.FindBack(iter, DIRECTORY_SEPARATOR_CHAR_W))
- {
- libPath.Truncate(++iter);
- libPath.Append(libFileName);
- }
- else
- {
- _ASSERTE(false && "unreachable");
- }
- LPCWSTR libraryName = libPath.GetUnicode();
- HMODULE libraryHandle = CLRLoadLibrary(libraryName);
- if (libraryHandle != nullptr)
- return libraryHandle;
-
- DISPLAYERROR(W("LoadLibrary failed for '%s': error %u\n"), libraryName, GetLastError());
-
- //
- // Fallback to the CORE_ROOT path
- //
-
- DWORD pathLen = GetEnvironmentVariableW(W("CORE_ROOT"), nullptr, 0);
- if (pathLen == 0) // not set
- return nullptr;
+ // Look for the coredistools module next to the clr binary
+ libPath.AppendPrintf(W("%s%s"), sysDirectory, libFileName);
- pathLen += 1; // Add 1 for null
- PathString coreRoot;
- WCHAR *coreRootRaw = coreRoot.OpenUnicodeBuffer(pathLen);
- GetEnvironmentVariableW(W("CORE_ROOT"), coreRootRaw, pathLen);
-
- libPath.Clear();
- libPath.AppendPrintf(W("%s%s%s"), coreRootRaw, DIRECTORY_SEPARATOR_STR_W, libFileName);
-
- libraryName = libPath.GetUnicode();
- libraryHandle = CLRLoadLibrary(libraryName);
- if (libraryHandle != nullptr)
- return libraryHandle;
-
- DISPLAYERROR(W("LoadLibrary failed for '%s': error %u\n"), libraryName, GetLastError());
- return nullptr;
+ LPCWSTR libraryName = libPath.GetUnicode();
+ return CLRLoadLibrary(libraryName);
}
}
diff --git a/src/vm/gcheaputilities.cpp b/src/vm/gcheaputilities.cpp
index fda07ce675..9f13eff75b 100644
--- a/src/vm/gcheaputilities.cpp
+++ b/src/vm/gcheaputilities.cpp
@@ -152,6 +152,21 @@ void StashKeywordAndLevel(bool isPublicProvider, GCEventKeyword keywords, GCEven
}
}
+#ifdef FEATURE_STANDALONE_GC
+HMODULE LoadStandaloneGc(LPCWSTR libFileName)
+{
+ LIMITED_METHOD_CONTRACT;
+
+ // Look for the standalone GC module next to the clr binary
+ PathString libPath = GetInternalSystemDirectory();
+ libPath.Append(libFileName);
+
+ LPCWSTR libraryName = libPath.GetUnicode();
+ LOG((LF_GC, LL_INFO100, "Loading standalone GC from path %S\n", libraryName));
+ return CLRLoadLibrary(libraryName);
+}
+#endif // FEATURE_STANDALONE_GC
+
// Loads and initializes a standalone GC, given the path to the GC
// that we should load. Returns S_OK on success and the failed HRESULT
// on failure.
@@ -166,13 +181,12 @@ HRESULT LoadAndInitializeGC(LPWSTR standaloneGcLocation)
LOG((LF_GC, LL_FATALERROR, "EE not built with the ability to load standalone GCs"));
return E_FAIL;
#else
- LOG((LF_GC, LL_INFO100, "Loading standalone GC from path %S\n", standaloneGcLocation));
- HMODULE hMod = CLRLoadLibrary(standaloneGcLocation);
+ HMODULE hMod = LoadStandaloneGc(standaloneGcLocation);
if (!hMod)
{
HRESULT err = GetLastError();
LOG((LF_GC, LL_FATALERROR, "Load of %S failed\n", standaloneGcLocation));
- return err;
+ return __HRESULT_FROM_WIN32(err);
}
// a standalone GC dispatches virtually on GCToEEInterface, so we must instantiate
@@ -189,7 +203,7 @@ HRESULT LoadAndInitializeGC(LPWSTR standaloneGcLocation)
{
HRESULT err = GetLastError();
LOG((LF_GC, LL_FATALERROR, "Load of `GC_VersionInfo` from standalone GC failed\n"));
- return err;
+ return __HRESULT_FROM_WIN32(err);
}
g_gc_load_status = GC_LOAD_STATUS_GET_VERSIONINFO;
@@ -216,7 +230,7 @@ HRESULT LoadAndInitializeGC(LPWSTR standaloneGcLocation)
{
HRESULT err = GetLastError();
LOG((LF_GC, LL_FATALERROR, "Load of `GC_Initialize` from standalone GC failed\n"));
- return err;
+ return __HRESULT_FROM_WIN32(err);
}
g_gc_load_status = GC_LOAD_STATUS_GET_INITIALIZE;