forked from mickelson/attract
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use backward-cpp for a stack trace if we crash
- Loading branch information
Showing
5 changed files
with
4,569 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,9 @@ | |
#FE_HWACCEL_VAAPI=1 | ||
#FE_HWACCEL_VDPAU=1 | ||
# | ||
# Uncomment the next line to build attract.debug file with debug symbols | ||
#ENABLE_DEBUG_SYMBOLS=1 | ||
# | ||
############################### | ||
|
||
#FE_DEBUG=1 | ||
|
@@ -70,22 +73,24 @@ CC=gcc | |
CXX=g++ | ||
CFLAGS=$(EXTRA_CFLAGS) | ||
STRIP=strip | ||
OBJCOPY=objcopy | ||
PKG_CONFIG=pkg-config | ||
AR=ar | ||
ARFLAGS=rc | ||
RM=rm -f | ||
MD=mkdir -p | ||
WINDRES=windres | ||
|
||
ifndef OPTIMIZE | ||
OPTIMIZE=2 | ||
endif | ||
-include attract.mk | ||
|
||
OPTIMIZE ?= 2 | ||
|
||
ifndef VERBOSE | ||
SILENT=@ | ||
SILENT = @ | ||
CC_MSG = @echo Compiling $@... | ||
AR_MSG = @echo Archiving $@... | ||
EXE_MSG = @echo Creating executable: $@ | ||
DEBUG_MSG = @echo Writing debug symbols: $@.debug | ||
endif | ||
|
||
ifneq ($(origin TOOLCHAIN),undefined) | ||
|
@@ -100,19 +105,19 @@ override PKG_CONFIG := $(TOOLCHAIN)-$(PKG_CONFIG) | |
override WINDRES := $(TOOLCHAIN)-$(WINDRES) | ||
endif | ||
|
||
prefix=/usr/local | ||
datarootdir=$(prefix)/share | ||
datadir=$(datarootdir) | ||
exec_prefix=$(prefix) | ||
bindir=$(exec_prefix)/bin | ||
prefix ?= /usr/local | ||
datarootdir ?= $(prefix)/share | ||
datadir ?= $(datarootdir) | ||
exec_prefix ?= $(prefix) | ||
bindir ?= $(exec_prefix)/bin | ||
|
||
DATA_PATH:=$(datadir)/attract/ | ||
EXE_BASE=attract | ||
EXE_EXT= | ||
OBJ_DIR=obj | ||
SRC_DIR=src | ||
EXTLIBS_DIR=extlibs | ||
FE_FLAGS= | ||
FE_FLAGS := | ||
|
||
_DEP =\ | ||
fe_base.hpp \ | ||
|
@@ -305,8 +310,9 @@ endif | |
# Now process the various settings... | ||
# | ||
ifeq ($(FE_DEBUG),1) | ||
CFLAGS += -g -Wall | ||
CFLAGS += -Wall | ||
FE_FLAGS += -DFE_DEBUG | ||
ENABLE_DEBUG_SYMBOLS=1 | ||
else | ||
CFLAGS += -O$(OPTIMIZE) -DNDEBUG | ||
endif | ||
|
@@ -397,6 +403,30 @@ ifeq ($(USE_LIBCURL),1) | |
_OBJ += fe_net.o | ||
endif | ||
|
||
ifeq ($(ENABLE_DEBUG_SYMBOLS),1) | ||
CFLAGS += -g | ||
# | ||
# libs for pretty output from backward-cpp | ||
# | ||
ifeq ($(shell $(PKG_CONFIG) --exists libdw && echo "1" || echo "0"), 1) | ||
TEMP_LIBS += libdw | ||
CFLAGS +=-DBACKWARD_HAS_DW=1 | ||
_OBJ += backward.o | ||
else | ||
ifeq ($(shell $(PKG_CONFIG) --exists libbfd && echo "1" || echo "0"), 1) | ||
TEMP_LIBS += libbfd | ||
CFLAGS +=-g -DBACKWARD_HAS_BFD=1 | ||
_OBJ += backward.o | ||
else | ||
ifeq ($(shell $(PKG_CONFIG) --exists libdwarf && echo "1" || echo "0"), 1) | ||
TEMP_LIBS += libdwarf | ||
CFLAGS += -DBACKWARD_HAS_DWARF=1 | ||
_OBJ += backward.o | ||
endif | ||
endif | ||
endif | ||
endif | ||
|
||
ifeq ($(NO_MOVIE),1) | ||
FE_FLAGS += -DNO_MOVIE | ||
ifeq ($(WINDOWS_STATIC),1) | ||
|
@@ -497,8 +527,13 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.mm $(DEP) | $(OBJ_DIR) | |
|
||
$(EXE): $(OBJ) $(EXPAT) $(SQUIRREL) $(AUDIO) | ||
$(EXE_MSG) | ||
$(SILENT)$(CXX) -o $@ $^ $(CFLAGS) $(FE_FLAGS) $(LIBS) | ||
ifneq ($(FE_DEBUG),1) | ||
$(CXX) -o $@ $^ $(CFLAGS) $(FE_FLAGS) $(LIBS) | ||
ifeq ($(ENABLE_DEBUG_SYMBOLS),1) | ||
$(DEBUG_MSG) | ||
$(SILENT)$(OBJCOPY) --only-keep-debug $@ [email protected] | ||
$(SILENT)$(STRIP) --strip-debug --strip-unneeded $@ | ||
$(SILENT)$(OBJCOPY) [email protected] $@ | ||
else | ||
$(SILENT)$(STRIP) $@ | ||
endif | ||
|
||
|
@@ -777,4 +812,4 @@ smallclean: | |
-$(RM) $(OBJ_DIR)/*.o *~ core | ||
|
||
clean: | ||
-$(RM) $(OBJ_DIR)/*.o $(EXPAT_OBJ_DIR)/*.o $(SQUIRREL_OBJ_DIR)/*.o $(SQSTDLIB_OBJ_DIR)/*.o $(AUDIO_OBJ_DIR)/*.o $(NOWIDE_OBJ_DIR)/*.o $(GSBASE_OBJ_DIR)/*.o $(GAMESWF_OBJ_DIR)/*.o $(GAMESWF_OBJ_DIR)/gameswf_as_classes/*.o $(OBJ_DIR)/*.a $(OBJ_DIR)/*.res *~ core | ||
-$(RM) $(OBJ_DIR)/*.o $(EXPAT_OBJ_DIR)/*.o $(SQUIRREL_OBJ_DIR)/*.o $(SQSTDLIB_OBJ_DIR)/*.o $(AUDIO_OBJ_DIR)/*.o $(NOWIDE_OBJ_DIR)/*.o $(GSBASE_OBJ_DIR)/*.o $(GAMESWF_OBJ_DIR)/*.o $(GAMESWF_OBJ_DIR)/gameswf_as_classes/*.o $(OBJ_DIR)/*.a $(OBJ_DIR)/*.res *~ core attract attract.debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Pick your poison. | ||
// | ||
// On GNU/Linux, you have few choices to get the most out of your stack trace. | ||
// | ||
// By default you get: | ||
// - object filename | ||
// - function name | ||
// | ||
// In order to add: | ||
// - source filename | ||
// - line and column numbers | ||
// - source code snippet (assuming the file is accessible) | ||
|
||
// Install one of the following libraries then uncomment one of the macro (or | ||
// better, add the detection of the lib and the macro definition in your build | ||
// system) | ||
|
||
// - apt-get install libdw-dev ... | ||
// - g++/clang++ -ldw ... | ||
// #define BACKWARD_HAS_DW 1 | ||
|
||
// - apt-get install binutils-dev ... | ||
// - g++/clang++ -lbfd ... | ||
// #define BACKWARD_HAS_BFD 1 | ||
|
||
// - apt-get install libdwarf-dev ... | ||
// - g++/clang++ -ldwarf ... | ||
// #define BACKWARD_HAS_DWARF 1 | ||
|
||
// Regardless of the library you choose to read the debug information, | ||
// for potentially more detailed stack traces you can use libunwind | ||
// - apt-get install libunwind-dev | ||
// - g++/clang++ -lunwind | ||
// #define BACKWARD_HAS_LIBUNWIND 1 | ||
|
||
#include "backward.hpp" | ||
|
||
namespace backward { | ||
|
||
backward::SignalHandling sh; | ||
|
||
} // namespace backward |
Oops, something went wrong.