Skip to content

Commit

Permalink
Revert "Merge branch 'stacktrace' of github.com:JuliaLang/julia"
Browse files Browse the repository at this point in the history
This reverts commit f233863, reversing
changes made to fa3afc5.

Conflicts:

	src/codegen.cpp
	src/debuginfo.cpp
	src/task.c
  • Loading branch information
JeffBezanson committed Jul 4, 2011
1 parent abb229a commit 7566578
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 148 deletions.
34 changes: 2 additions & 32 deletions external/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ LAPACK_VER = 3.3.1
ARPACK_VER = 96
FFTW_VER = 3.3-beta1
MONGOOSE_VER = 3.0
UNWIND_VER = 0.99

## high-level setup ##

JULIAHOME = $(shell pwd)/..
include ../Make.inc

OS = $(shell uname)
ARCH = $(shell uname -m)
LIBS = llvm readline pcre fdlibm dsfmt openblas lapack arpack fftw mongoose unwind
LIBS = llvm readline pcre fdlibm dsfmt openblas lapack arpack fftw mongoose

default: install
compile: $(addprefix compile-, $(LIBS))
Expand Down Expand Up @@ -306,36 +306,6 @@ mongoose-$(MONGOOSE_VER)/Makefile: mongoose-$(MONGOOSE_VER).tgz
clean-mongoose:
distclean-mongoose:
rm -rf mongoose-$(MONGOOSE_VER).tgz mongoose
## UNWIND ##

LIBUNWIND_TARGET_OBJ = $(EXTROOTLIB)/libunwind.a
LIBUNWIND_TARGET_SOURCE = $(JULIAHOME)/external/libunwind-$(UNWIND_VER)/Makefile

compile-unwind: $(LIBUNWIND_TARGET_SOURCE)
install-unwind: $(LIBUNWIND_TARGET_OBJ)

$(LIBUNWIND_TARGET_OBJ): $(LIBUNWIND_TARGET_SOURCE)
cd libunwind-$(UNWIND_VER) && make && make install



libunwind-$(UNWIND_VER).tar.gz:
$(DOWNLOAD) http:https://savannah.spinellicreations.com/libunwind/libunwind-$(UNWIND_VER).tar.gz

open-unwind: libunwind-$(UNWIND_VER).tar.gz
tar xvfz $<
touch $@

$(LIBUNWIND_TARGET_SOURCE): open-unwind
cd libunwind-$(UNWIND_VER) && ./configure CFLAGS="-U_FORTIFY_SOURCE -fPIC" --prefix=$(EXTROOT)

clean-unwind:
make -C libunwind-$(UNWIND_VER) clean
rm -rf $(LIBUNWIND_TARGET_OBJ) $(LIBUNWIND_TARGET_SOURCE)

distclean-unwind:
rm -rf libunwind-$(UWIND_VER).tar.gz libunwind-$(UNWIND_VER)


## phony targets ##

Expand Down
7 changes: 3 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ LLT = $(LLTDIR)/libllt.a
FLISP = $(FLISPDIR)/libflisp.a

FLAGS = -falign-functions -Wall -Wno-strict-aliasing \
-fno-omit-frame-pointer \
-I$(FLISPDIR) -I$(LLTDIR) $(HFILEDIRS:%=-I%) $(LIBDIRS:%=-L%) \
-I$(shell $(LLVMROOT)/bin/llvm-config --includedir)
-I$(shell $(LLVMROOT)/bin/llvm-config --includedir) -fvisibility=hidden
DEBUGFLAGS = -ggdb3 -DDEBUG $(FLAGS)
SHIPFLAGS = -O3 -DNDEBUG $(FLAGS)

LIBFILES = $(FLISP) $(LLT)
LIBS = $(LIBFILES) -L$(EXTROOTLIB) -lutil -ldl -lm $(EXTROOTLIB)/libunwind-generic.a $(EXTROOTLIB)/libunwind.a $(OSLIBS) \
LIBS = $(LIBFILES) -L$(EXTROOT)/lib -lutil -ldl -lm $(OSLIBS) \
$(shell $(LLVMROOT)/bin/llvm-config --ldflags --libs engine) -lpthread

ifeq ($(JULIAGC),MARKSWEEP)
Expand Down Expand Up @@ -52,7 +51,7 @@ julia_flisp.boot: julia-parser.scm julia-syntax.scm \
boot.j.inc: boot.j preparse.scm julia_flisp.boot
$(FLISPDIR)/flisp ./preparse.scm < $< | $(FLISPDIR)/flisp ./bin2hex.scm > $@

codegen.o codegen.do: intrinsics.cpp debuginfo.cpp
codegen.o codegen.do: intrinsics.cpp
builtins.o builtins.do: table.c

$(LLT): $(LLTDIR)/*.h $(LLTDIR)/*.c
Expand Down
10 changes: 2 additions & 8 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <sstream>
#include <map>
#include <vector>
#include "debuginfo.cpp"
#ifdef DEBUG
#undef NDEBUG
#endif
Expand Down Expand Up @@ -87,7 +86,6 @@ static GlobalVariable *jlsysmod_var;
static GlobalVariable *jlpgcstack_var;
#endif
static GlobalVariable *jlexc_var;
JuliaJITEventListener *jl_jit_events;

// important functions
static Function *jlnew_func;
Expand Down Expand Up @@ -200,7 +198,6 @@ extern "C" void jl_generate_fptr(jl_function_t *f)
Function *llvmf = (Function*)li->functionObject;
if (li->fptr == NULL)
li->fptr = (jl_fptr_t)jl_ExecutionEngine->getPointerToFunction(llvmf);
// should create a map, of fucntion names, and list of pointers so i can back trace.
assert(li->fptr != NULL);
f->fptr = li->fptr;
llvmf->deleteBody();
Expand Down Expand Up @@ -1921,10 +1918,9 @@ static void init_julia_llvm_env(Module *m)

extern "C" void jl_init_codegen()
{
#ifdef DEBUG
llvm::JITEmitDebugInfo = true;
llvm::NoFramePointerElim = true;
llvm::NoFramePointerElimNonLeaf = true;

#endif
InitializeNativeTarget();
jl_Module = new Module("julia", jl_LLVMContext);
jl_ExecutionEngine =
Expand All @@ -1934,6 +1930,4 @@ extern "C" void jl_init_codegen()
init_julia_llvm_env(jl_Module);

jl_init_intrinsic_functions();
jl_jit_events = new JuliaJITEventListener();
jl_ExecutionEngine->RegisterJITEventListener(jl_jit_events);
}
48 changes: 0 additions & 48 deletions src/debuginfo.cpp

This file was deleted.

57 changes: 1 addition & 56 deletions src/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
#include <unistd.h>
#include "llt.h"
#include "julia.h"
// This gives unwind only local unwinding options ==> faster code
#define UNW_LOCAL_ONLY
#include <libunwind.h>

/* This probing code is derived from Douglas Jones' user thread library */

/* the list of offsets in jmp_buf to be adjusted */
Expand Down Expand Up @@ -428,60 +426,9 @@ static void init_task(jl_task_t *t)
}
#endif

char* getFunctionInfo(size_t pointer);



void show_backtrace (void) {
unw_cursor_t cursor; unw_context_t uc;
unw_word_t ip, sp;

unw_getcontext(&uc);
unw_init_local(&cursor, &uc);
int index = unw_step(&cursor);
//printf("index %d\n", index);
while (index > 0) {
unw_get_reg(&cursor, UNW_REG_IP, &ip);
unw_get_reg(&cursor, UNW_REG_SP, &sp);
//printf("pre getFunc \n");
const char* funcName = getFunctionInfo(ip);
if(funcName != NULL) {
printf ("Function Name = %s, instruction pointer = %lx \n", funcName, (long) ip);
}
//printf("post getFunc \n");
index = unw_step(&cursor);
//printf("index %d\n", index);
}
//printf("exiting backtrace");
}


void backtrace () {
const int max_i = 10000;
int i = 0;
intptr_t rbp;
asm(" movq %%rbp, %0;"
: "=r" (rbp));
while (rbp != 0 && i<max_i) {
//printf(" rbp value %lx, value of i %d\n",rbp, i);
void **fp = ((void**)rbp)[0];
void *ip = ((void**)rbp)[1];
const char* info = getFunctionInfo(ip);
if(info != NULL) {
printf ("Function Name = %s, instruction pointer = %lx \n", info, (long) ip);
}
rbp = fp;
i++;
}
if (i == max_i){
printf("to prevent infitie loops stacktrace was cutoff at %d iterations\n to change this change max i backtrace in task.c\n",max_i);
}
}

// yield to exception handler
void jl_raise(jl_value_t *e)
{
show_backtrace();
jl_task_t *eh = jl_current_task->state.eh_task;
eh->state.err = 1;
jl_exception_in_transit = e;
Expand All @@ -499,8 +446,6 @@ void jl_raise(jl_value_t *e)
ctx_switch(eh, eh->state.eh_ctx);
// TODO: continued exception
}
printf("exiting jl_raise");

}

jl_task_t *jl_new_task(jl_function_t *start, size_t ssize)
Expand Down

0 comments on commit 7566578

Please sign in to comment.