Skip to content

Commit

Permalink
WIP: Windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
Julia Windows Test Machine committed Jun 8, 2014
1 parent 1f163f4 commit 7498ac9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ endif
ifeq ($(OS), WINNT)
ifneq ($(USEMSVC), 1)
OSLIBS += -Wl,--export-all-symbols -Wl,--version-script=$(JULIAHOME)/src/julia.expmap \
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -lssp
$(NO_WHOLE_ARCHIVE) -lz -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -lssp
JLDFLAGS = -Wl,--stack,8388608
ifeq ($(ARCH),i686)
JLDFLAGS += -Wl,--large-address-aware
Expand Down
41 changes: 29 additions & 12 deletions src/debuginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,14 @@ extern "C"
const char *jl_demangle(const char *name) {
const char *start = name;
const char *end = start;
char *ret;
while ((*start++ != '_') && (*start != '\0'));
if (*name == '\0') goto done;
while ((*end++ != ';') && (*end != '\0'));
if (*name == '\0') goto done;
return strndup(start, end-start-1);
ret = (char*)malloc(end-start-1);
memcpy(ret,start,end-start-1);
return ret;
done:
return strdup(name);
}
Expand Down Expand Up @@ -181,12 +184,12 @@ void lookup_pointer(DIContext *context, const char **name, int *line, const char
#endif
}

#include <dlfcn.h>
#ifdef _OS_DARWIN_
#include <mach-o/dyld.h>
#endif

#ifndef _OS_WINDOWS_
#include <dlfnc.h>
#endif
typedef struct {
llvm::object::ObjectFile *obj;
DIContext *ctx;
Expand Down Expand Up @@ -241,11 +244,16 @@ bool jl_is_sysimg(const char *path)

void jl_getDylibFunctionInfo(const char **name, int *line, const char **filename, size_t pointer, int skipC)
{
#ifdef _OS_WINDOWS_
DWORD fbase = SymGetModuleBase64(GetCurrentProcess(),(DWORD)pointer);
if (fbase != 0) {
#else
Dl_info dlinfo;
if (dladdr((void*)pointer, &dlinfo) != 0) {
if (skipC && !jl_is_sysimg(dlinfo.dli_fname))
return;
uint64_t fbase = (uint64_t)dlinfo.dli_fbase;
#endif
obfiletype::iterator it = objfilemap.find(fbase);
llvm::object::ObjectFile *obj = NULL;
DIContext *context = NULL;
Expand Down Expand Up @@ -296,12 +304,21 @@ void jl_getDylibFunctionInfo(const char **name, int *line, const char **filename
llvm::object::ObjectFile *errorobj = llvm::object::ObjectFile::createObjectFile(dsympath);
#endif
#else
#ifndef _OS_WINDOWS_
char *fname = dlinfo.dli_fname
#else
IMAGEHLP_MODULE64 ModuleInfo;
ModuleInfo.SizeOfStruct = sizeof(IMAGEHLP_MODULE64);
SymGetModuleInfo64(GetCurrentProcess(), (DWORD64)pointer, &ModuleInfo);
char *fname = ModuleInfo.LoadedImageName;
JL_PRINTF(JL_STDOUT,fname);
#endif
// On non OS X systems we need to mmap another copy because of the permissions on the mmaped
// shared library.
#ifdef LLVM35
ErrorOr<llvm::object::ObjectFile*> errorobj = llvm::object::ObjectFile::createObjectFile(dlinfo.dli_fname);
ErrorOr<llvm::object::ObjectFile*> errorobj = llvm::object::ObjectFile::createObjectFile(fname);
#else
llvm::object::ObjectFile *errorobj = llvm::object::ObjectFile::createObjectFile(dlinfo.dli_fname);
llvm::object::ObjectFile *errorobj = llvm::object::ObjectFile::createObjectFile(fname);
#endif
#endif
#ifdef LLVM35
Expand All @@ -322,6 +339,13 @@ void jl_getDylibFunctionInfo(const char **name, int *line, const char **filename
#endif

}
if (errorobj != NULL)
JL_PRINTF(JL_STDOUT,"errorobj");
if (context != NULL) {
JL_PRINTF(JL_STDOUT,"context");
raw_fd_ostream out(2,false,true);
context->dump(out);
}
objfileentry_t entry = {obj,context,slide};
objfilemap[fbase] = entry;
} else {
Expand All @@ -335,13 +359,6 @@ void jl_getDylibFunctionInfo(const char **name, int *line, const char **filename
return;
}

#else
void jl_getDylibFunctionInfo(const char **name, int *line, const char **filename, size_t pointer, int skipC)
{
return;
}
#endif

void jl_getFunctionInfo(const char **name, int *line, const char **filename, size_t pointer, int skipC)
{
*name = NULL;
Expand Down
6 changes: 5 additions & 1 deletion src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#endif
#include "julia.h"
#include "julia_internal.h"
#include "uv.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -548,7 +549,10 @@ jl_value_t *jl_load(const char *fname)
{
if (jl_current_module == jl_base_module) {
//This deliberatly uses ios, because stdio initialization has been moved to Julia
jl_printf(JL_STDOUT, "%s\n", fname);
jl_printf(JL_STDOUT, "%s\r\n", fname);
#ifdef _OS_WINDOWS_
uv_run(uv_default_loop(), 1);
#endif
}
char *fpath = (char*)fname;
uv_stat_t stbuf;
Expand Down

0 comments on commit 7498ac9

Please sign in to comment.