Skip to content

Commit

Permalink
test libccalltest.so with split debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Aug 15, 2016
1 parent b67fd06 commit 0dbb1d1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ endif #ARCH
LD := link
endif #USEMSVC
RANLIB := $(CROSS_COMPILE)ranlib
OBJCOPY := $(CROSS_COMPILE)objcopy

# file extensions
ifeq ($(OS), WINNT)
Expand Down
19 changes: 18 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,22 @@ $(BUILDDIR)/%.dbg.obj: $(SRCDIR)/%.cpp $(SRCDIR)/llvm-version.h $(HEADERS) $(LLV
@$(call PRINT_CC, $(CXX) $(shell $(LLVM_CONFIG_HOST) --cxxflags) $(CPPFLAGS) $(CXXFLAGS) $(DEBUGFLAGS) -c $< -o $@)

libccalltest: $(build_shlibdir)/libccalltest.$(SHLIB_EXT)

ifeq ($(OS), Linux)
JULIA_SPLITDEBUG := 1
else
JULIA_SPLITDEBUG := 0
endif
$(build_shlibdir)/libccalltest.$(SHLIB_EXT): $(SRCDIR)/ccalltest.c
@$(call PRINT_CC, $(CC) $(CFLAGS) $(CPPFLAGS) $(DEBUGFLAGS) -O3 $< $(fPIC) -shared -o $@ $(LDFLAGS))
@$(call PRINT_CC, $(CC) $(CFLAGS) $(CPPFLAGS) $(DEBUGFLAGS) -O3 $< $(fPIC) -shared -o $@.tmp $(LDFLAGS))
ifeq ($(JULIA_SPLITDEBUG),1)
@# Create split debug info file for libccalltest stacktraces test
@# packagers should disable this by setting JULIA_SPLITDEBUG=0 if this is already done by your build system
$(OBJCOPY) --only-keep-debug $@.tmp $@.debug
$(OBJCOPY) --strip-debug $@.tmp
$(OBJCOPY) --add-gnu-debuglink=$@.debug $@.tmp
endif
mv $@.tmp $@

julia_flisp.boot.inc.phony: $(BUILDDIR)/julia_flisp.boot.inc

Expand Down Expand Up @@ -221,9 +235,11 @@ ifneq ($(OS), WINNT)
@ln -sf libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT) $(build_shlibdir)/libjulia-debug.$(SHLIB_EXT)
endif
$(DSYMUTIL) $@

$(BUILDDIR)/libjulia-debug.a: $(SRCDIR)/julia.expmap $(DOBJS) $(BUILDDIR)/flisp/libflisp-debug.a $(BUILDDIR)/support/libsupport-debug.a
rm -f $@
@$(call PRINT_LINK, ar -rcs $@ $(DOBJS))

libjulia-debug: $(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT)

$(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT): $(SRCDIR)/julia.expmap $(OBJS) $(BUILDDIR)/flisp/libflisp.a $(BUILDDIR)/support/libsupport.a $(LIBUV)
Expand All @@ -234,6 +250,7 @@ ifneq ($(OS), WINNT)
@ln -sf libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT) $(build_shlibdir)/libjulia.$(SHLIB_EXT)
endif
$(DSYMUTIL) $@

$(BUILDDIR)/libjulia.a: julia.expmap $(OBJS) $(BUILDDIR)/flisp/libflisp.a $(BUILDDIR)/support/libsupport.a
rm -f $@
@$(call PRINT_LINK, ar -rcs $@ $(OBJS))
Expand Down
3 changes: 3 additions & 0 deletions src/debuginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,9 @@ static int lookup_pointer(DIContext *context, jl_frame_t **frames,

int fromC = (*frames)[0].fromC;
int n_frames = inlineInfo.getNumberOfFrames();
if (n_frames == 0)
// no line number info available in the context, return without the context
return lookup_pointer(NULL, frames, pointer, demangle, noInline);
if (noInline)
n_frames = 1;
if (n_frames > 1) {
Expand Down
10 changes: 10 additions & 0 deletions test/stacktraces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,13 @@ let li = typeof(getfield).name.mt.cache.func::LambdaInfo,
repr = string(sf)
@test repr == " in getfield(...) at b:3"
end

let ctestptr = cglobal((:ctest, "libccalltest")),
ctest = StackTraces.lookup(ctestptr + 1)

@test length(ctest) == 1
@test ctest[1].func === :ctest
@test isnull(ctest[1].linfo)
@test ctest[1].from_c
@test ctest[1].pointer === Int64(ctestptr)
end

0 comments on commit 0dbb1d1

Please sign in to comment.