aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System/Win32
diff options
context:
space:
mode:
authorJeff Cohen <jeffc@jolt-lang.org>2004-12-25 04:50:17 +0000
committerJeff Cohen <jeffc@jolt-lang.org>2004-12-25 04:50:17 +0000
commitc2b9162e5db5426321c0e2e5c95a3b8fe8060dd8 (patch)
tree6a432f9cbb6330bff80e0c1da11b2dbd75d0886e /lib/System/Win32
parenta4c9751265670d152211081e64f99f6d9a5a65c1 (diff)
downloadexternal_llvm-c2b9162e5db5426321c0e2e5c95a3b8fe8060dd8.zip
external_llvm-c2b9162e5db5426321c0e2e5c95a3b8fe8060dd8.tar.gz
external_llvm-c2b9162e5db5426321c0e2e5c95a3b8fe8060dd8.tar.bz2
mingw doesn't support the official debug API.
Old versions of the C runtime somehow get loaded into the process. Make sure they aren't searched for symbols. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19141 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Win32')
-rw-r--r--lib/System/Win32/DynamicLibrary.cpp37
-rw-r--r--lib/System/Win32/DynamicLibrary.inc37
2 files changed, 56 insertions, 18 deletions
diff --git a/lib/System/Win32/DynamicLibrary.cpp b/lib/System/Win32/DynamicLibrary.cpp
index 2707883..ef435f4 100644
--- a/lib/System/Win32/DynamicLibrary.cpp
+++ b/lib/System/Win32/DynamicLibrary.cpp
@@ -7,12 +7,17 @@
//
//===----------------------------------------------------------------------===//
//
-// This file provides the Win32 specific implementation of DynamicLibrary.
+// This file provides the Win32 specific implementation of DynamicLibrary.
//
//===----------------------------------------------------------------------===//
#include "Win32.h"
+
+#ifdef __MINGW
+#include <imagehlp.h>
+#else
#include <dbghelp.h>
+#endif
#pragma comment(lib, "dbghelp.lib")
@@ -26,13 +31,27 @@ using namespace sys;
static std::vector<HMODULE> OpenedHandles;
-BOOL CALLBACK ELM_Callback(PSTR ModuleName,
- ULONG ModuleBase,
- ULONG ModuleSize,
- PVOID UserContext)
-{
- OpenedHandles.push_back((HMODULE)ModuleBase);
- return TRUE;
+extern "C" {
+ static BOOL CALLBACK ELM_Callback(PSTR ModuleName,
+ ULONG ModuleBase,
+ ULONG ModuleSize,
+ PVOID UserContext)
+ {
+ // Ignore VC++ runtimes prior to 7.1. Somehow some of them get loaded
+ // into the process.
+ if (stricmp(ModuleName, "msvci70") != 0 &&
+ stricmp(ModuleName, "msvcirt") != 0 &&
+ stricmp(ModuleName, "msvcp50") != 0 &&
+ stricmp(ModuleName, "msvcp60") != 0 &&
+ stricmp(ModuleName, "msvcp70") != 0 &&
+ stricmp(ModuleName, "msvcr70") != 0 &&
+ stricmp(ModuleName, "msvcrt") != 0 &&
+ stricmp(ModuleName, "msvcrt20") != 0 &&
+ stricmp(ModuleName, "msvcrt40") != 0) {
+ OpenedHandles.push_back((HMODULE)ModuleBase);
+ }
+ return TRUE;
+ }
}
DynamicLibrary::DynamicLibrary() : handle(0) {
@@ -83,7 +102,7 @@ void DynamicLibrary::LoadLibraryPermanently(const char* filename) {
EnumerateLoadedModules(GetCurrentProcess(), ELM_Callback, 0);
}
- // Because we don't remember the handles, we will never free them; hence,
+ // Because we don't remember the handle, we will never free it; hence,
// it is loaded permanently.
}
diff --git a/lib/System/Win32/DynamicLibrary.inc b/lib/System/Win32/DynamicLibrary.inc
index 2707883..ef435f4 100644
--- a/lib/System/Win32/DynamicLibrary.inc
+++ b/lib/System/Win32/DynamicLibrary.inc
@@ -7,12 +7,17 @@
//
//===----------------------------------------------------------------------===//
//
-// This file provides the Win32 specific implementation of DynamicLibrary.
+// This file provides the Win32 specific implementation of DynamicLibrary.
//
//===----------------------------------------------------------------------===//
#include "Win32.h"
+
+#ifdef __MINGW
+#include <imagehlp.h>
+#else
#include <dbghelp.h>
+#endif
#pragma comment(lib, "dbghelp.lib")
@@ -26,13 +31,27 @@ using namespace sys;
static std::vector<HMODULE> OpenedHandles;
-BOOL CALLBACK ELM_Callback(PSTR ModuleName,
- ULONG ModuleBase,
- ULONG ModuleSize,
- PVOID UserContext)
-{
- OpenedHandles.push_back((HMODULE)ModuleBase);
- return TRUE;
+extern "C" {
+ static BOOL CALLBACK ELM_Callback(PSTR ModuleName,
+ ULONG ModuleBase,
+ ULONG ModuleSize,
+ PVOID UserContext)
+ {
+ // Ignore VC++ runtimes prior to 7.1. Somehow some of them get loaded
+ // into the process.
+ if (stricmp(ModuleName, "msvci70") != 0 &&
+ stricmp(ModuleName, "msvcirt") != 0 &&
+ stricmp(ModuleName, "msvcp50") != 0 &&
+ stricmp(ModuleName, "msvcp60") != 0 &&
+ stricmp(ModuleName, "msvcp70") != 0 &&
+ stricmp(ModuleName, "msvcr70") != 0 &&
+ stricmp(ModuleName, "msvcrt") != 0 &&
+ stricmp(ModuleName, "msvcrt20") != 0 &&
+ stricmp(ModuleName, "msvcrt40") != 0) {
+ OpenedHandles.push_back((HMODULE)ModuleBase);
+ }
+ return TRUE;
+ }
}
DynamicLibrary::DynamicLibrary() : handle(0) {
@@ -83,7 +102,7 @@ void DynamicLibrary::LoadLibraryPermanently(const char* filename) {
EnumerateLoadedModules(GetCurrentProcess(), ELM_Callback, 0);
}
- // Because we don't remember the handles, we will never free them; hence,
+ // Because we don't remember the handle, we will never free it; hence,
// it is loaded permanently.
}