jw-pkg/make/debugger.mk

71 lines
1.6 KiB
Makefile
Raw Normal View History

ifeq "$(COMPILER_SUITE)" "gcc"
DEBUGGER = gdb
endif
ifeq "$(COMPILER_SUITE)" "clang"
DEBUGGER = lldb
endif
CORE_DUMPER = $(shell echo -e "quit" | $(DEBUGGER) --core=$(CORE) 2>&1 | \
2012-02-04 10:59:02 +00:00
$(SED) '/Core was generated/ !d; s/Core was generated by `//; s/ .*//' | xargs -r which)
ifeq ($(CORE_DUMPER),)
CORE_DUMPER = $(EXE_PATH)
endif
PID = $(shell ps aux | $(SED) "/$(notdir $(EXE_PATH))\( \|$$\)/ !d; /sed/ d; /defunct/ d" | awk '{print $$2}')
2011-02-24 18:39:09 +00:00
all:
gdb ddd:
ifneq ($(CORE),)
$@ --core=$(firstword $(CORE)) --args $(CORE_DUMPER) $(EXE_ARGS)
else
$@ --args $(CORE_DUMPER) $(EXE_ARGS)
endif
lldb:
ifneq ($(CORE),)
$@ --core $(firstword $(CORE)) -f $(CORE_DUMPER) -- $(EXE_ARGS)
else
$@ -f $(CORE_DUMPER) -- $(EXE_ARGS)
endif
kdbg:
$@ $(CORE_DUMPER) $(firstword $(CORE)) -a "$(EXE_ARGS)"
cgdb:
ifneq ($(CORE),)
$@ -- --core=$(firstword $(CORE)) --args $(CORE_DUMPER) $(EXE_ARGS)
else
$@ -- --args $(CORE_DUMPER) $(EXE_ARGS)
endif
attach:
$(DEBUGGER) $(EXE_PATH) -p $(PID)
attach-ddd:
ddd $(EXE_PATH) -p $(PID)
2011-02-24 18:39:09 +00:00
attach-strace:
strace -f $(EXE_PATH) -p $(PID)
report:
generate-coredump-report.sh -l
mkdir -p crashes
if ls *core*.txt.bz2* >/dev/null 2>&1; then mv *core*.txt.bz2 crashes/; fi
view-report:
less `ls -rt crashes/*core*.txt.bz2 | tail -1`
localcore:
echo core.%h.%e.%p | sudo tee /proc/sys/kernel/core_pattern
cp `ls -rt /var/cores/*core* 2>/dev/null | tail -1` .
centralcore:
echo /var/cores/core.%h.%e.%p | sudo tee /proc/sys/kernel/core_pattern
coreclean: centralcore-clean
centralcore-clean:
rm -f /var/cores/core* /var/cores/vgcore* || exit 0