From 0a554696d9a2bb069157d4c7d2d15b5772f56b2c Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Wed, 31 May 2017 11:00:18 +0000 Subject: [PATCH] Generate separate DWARF debug info The build now produces a ".dwo" file containing DWARF debug information. This contains a binary encoding of internal information about RaptorJIT e.g. the layout of all its internal data structures. The DWARF information is for use by debugging tools that need to understand JIT internals. The DWARF file is currently generated with gcc. I would prefer to use clang, for the sake of consistency with the rest of the build, but I seem to get _much_ more debug information from gcc so I stick with that for now. The nix build expression outputs the debug information as lib/raptorjit.dwo --- raptorjit.nix | 10 +++++++--- src/Makefile | 9 ++++++++- src/lj_dwarf.c | 24 ++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 src/lj_dwarf.c diff --git a/raptorjit.nix b/raptorjit.nix index 152a62e089..861ee73d20 100644 --- a/raptorjit.nix +++ b/raptorjit.nix @@ -9,10 +9,14 @@ mkDerivation rec { name = "raptorjit-${version}"; inherit version; src = source; - buildInputs = [ luajit ]; # LuaJIT to bootstrap DynASM + buildInputs = [ + luajit # LuaJIT to bootstrap DynASM + gcc6 # GCC for generating DWARF info + ]; + dontStrip = true; # No extra stripping (preserve debug info) installPhase = '' - mkdir -p $out/bin - cp src/luajit $out/bin/raptorjit + install -D src/luajit $out/bin/raptorjit + install -D src/lj_dwarf.dwo $out/lib/raptorjit.dwo ''; enableParallelBuilding = true; # Do 'make -j' diff --git a/src/Makefile b/src/Makefile index 896947fb98..5272a4351c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -475,6 +475,8 @@ LJCORE_O= lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o lj_buf.o \ lj_lib.o lj_alloc.o lib_aux.o \ $(LJLIB_O) lib_init.o +DWARF_DWO= lj_dwarf.dwo + LJVMCORE_O= $(LJVM_O) $(LJCORE_O) LJVMCORE_DYNO= $(LJVMCORE_O:.o=_dyn.o) @@ -566,7 +568,7 @@ E= @echo # Make targets. ############################################################################## -default all: $(TARGET_T) +default all: $(TARGET_T) $(DWARF_DWO) clean: $(HOST_RM) $(ALL_RM) @@ -655,6 +657,11 @@ $(HOST_O): %.o: %.c $(E) "HOSTCC $@" $(Q)$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $< +$(DWARF_DWO): %.dwo: %.c + $(E) "CC(debug) $@" +# GCC because clang does not seem to produce decent debug info (?) + $(Q)gcc -g3 -gdwarf-4 -fno-eliminate-unused-debug-types -gsplit-dwarf -c $< + include Makefile.dep ############################################################################## diff --git a/src/lj_dwarf.c b/src/lj_dwarf.c new file mode 100644 index 0000000000..5535ee175c --- /dev/null +++ b/src/lj_dwarf.c @@ -0,0 +1,24 @@ +/* +** Compilation unit for DWARF debug information. +*/ + +#include "lj_obj.h" +#include "lj_gc.h" +#include "lj_err.h" +#include "lj_debug.h" +#include "lj_str.h" +#include "lj_frame.h" +#include "lj_state.h" +#include "lj_bc.h" +#include "lj_ir.h" +#include "lj_jit.h" +#include "lj_iropt.h" +#include "lj_mcode.h" +#include "lj_trace.h" +#include "lj_snap.h" +#include "lj_gdbjit.h" +#include "lj_record.h" +#include "lj_asm.h" +#include "lj_dispatch.h" +#include "lj_vm.h" +#include "lj_target.h"