Skip to content

Commit

Permalink
fix win64 mcjit backtrace support
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Nov 30, 2014
1 parent a0542e7 commit f027462
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/debuginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,24 +348,24 @@ extern "C" uint64_t jl_sysimage_base;
void jl_getDylibFunctionInfo(const char **name, size_t *line, const char **filename, size_t pointer, int *fromC, int skipC)
{
#ifdef _OS_WINDOWS_
char *fname = 0;
DWORD64 fbase = 0;
if (!jl_in_stackwalk) {
jl_in_stackwalk = 1;
fbase = SymGetModuleBase64(GetCurrentProcess(),(DWORD64)pointer);
jl_in_stackwalk = 0;
IMAGEHLP_MODULE64 ModuleInfo;
BOOL isvalid;
if (jl_in_stackwalk) {
*fromC = 1;
return;
}
if (fbase != 0) {
ModuleInfo.SizeOfStruct = sizeof(IMAGEHLP_MODULE64);
jl_in_stackwalk = 1;
isvalid = SymGetModuleInfo64(GetCurrentProcess(), (DWORD64)pointer, &ModuleInfo);
jl_in_stackwalk = 0;
if (isvalid) {
char *fname = ModuleInfo.LoadedImageName;
DWORD64 fbase = ModuleInfo.BaseOfImage;
size_t msize = ModuleInfo.ImageSize;
*fromC = (fbase != jl_sysimage_base);
if (skipC && *fromC) {
return;
}
IMAGEHLP_MODULE64 ModuleInfo;
ModuleInfo.SizeOfStruct = sizeof(IMAGEHLP_MODULE64);
jl_in_stackwalk = 1;
SymGetModuleInfo64(GetCurrentProcess(), (DWORD64)pointer, &ModuleInfo);
jl_in_stackwalk = 0;
fname = ModuleInfo.LoadedImageName;
static char frame_info_func[
sizeof(SYMBOL_INFO) +
MAX_SYM_NAME * sizeof(TCHAR)];
Expand Down Expand Up @@ -405,6 +405,7 @@ void jl_getDylibFunctionInfo(const char **name, size_t *line, const char **filen
if ((dladdr((void*)pointer, &dlinfo) != 0) && dlinfo.dli_fname) {
const char *fname;
uint64_t fbase = (uint64_t)dlinfo.dli_fbase;
size_t msize = (size_t)(((uint64_t)-1)-fbase));
*fromC = (fbase != jl_sysimage_base);
if (skipC && *fromC)
return;
Expand All @@ -426,18 +427,18 @@ void jl_getDylibFunctionInfo(const char **name, size_t *line, const char **filen
#endif
#ifdef LLVM36
std::unique_ptr<MemoryBuffer> membuf = MemoryBuffer::getMemBuffer(
StringRef((const char *)fbase, (size_t)(((uint64_t)-1)-fbase)),"",false);
StringRef((const char *)fbase, msize)), "", false);
auto origerrorobj = llvm::object::ObjectFile::createObjectFile(
membuf->getMemBufferRef(), sys::fs::file_magic::unknown);
#elif LLVM35
#elif defined(LLVM35)
MemoryBuffer *membuf = MemoryBuffer::getMemBuffer(
StringRef((const char *)fbase, (size_t)(((uint64_t)-1)-fbase)),"",false);
StringRef((const char *)fbase, msize), "", false);
std::unique_ptr<MemoryBuffer> buf(membuf);
auto origerrorobj = llvm::object::ObjectFile::createObjectFile(
buf, sys::fs::file_magic::unknown);
#else
MemoryBuffer *membuf = MemoryBuffer::getMemBuffer(
StringRef((const char *)fbase, (size_t)(((uint64_t)-1)-fbase)),"",false);
StringRef((const char *)fbase, msize, "", false);
llvm::object::ObjectFile *origerrorobj = llvm::object::ObjectFile::createObjectFile(
membuf);
#endif
Expand Down Expand Up @@ -757,6 +758,9 @@ RTDyldMemoryManager* createRTDyldMemoryManagerWin(RTDyldMemoryManager *MM) {
return new RTDyldMemoryManagerWin(MM);
}
#else
RTDyldMemoryManager* createRTDyldMemoryManagerWin(RTDyldMemoryManager *MM) {
return NULL;
}
extern "C"
DWORD64 jl_getUnwindInfo(ULONG64 dwAddr)
{
Expand Down

0 comments on commit f027462

Please sign in to comment.