Skip to content

Commit

Permalink
Use backward-cpp for backtrace (#55)
Browse files Browse the repository at this point in the history
* Use backward-cpp for backtrace
  • Loading branch information
kingster authored May 28, 2021
1 parent c23eed4 commit f63b172
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
7 changes: 6 additions & 1 deletion .devcontainer/Dockerfile.orkaudio.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN . /etc/os-release && apt-key adv --keyserver keyserver.ubuntu.com --recv-key

RUN apt-get update && apt-get install -y build-essential libtool automake git tree rpm libboost1.70-dev`
libpcap-dev libsndfile1-dev libapr1-dev libspeex-dev liblog4cxx-dev libace-dev `
libopus-dev libxerces-c3-dev libssl-dev cmake`
libopus-dev libxerces-c3-dev libssl-dev cmake libdw-dev liblzma-dev libunwind-dev`
&& rm -rf /var/lib/apt/lists/*

#silk
Expand Down Expand Up @@ -42,6 +42,11 @@ RUN mkdir -p /opt/bcg729 && chmod 777 /opt/bcg729`
&& make `
&& make install

#backward-cpp
RUN mkdir -p /opt/backward-cpp && chmod 777 /opt/backward-cpp`
&& git clone --depth 1 https://github.com/bombela/backward-cpp.git /opt/backward-cpp `
&& ln -s /opt/backward-cpp/backward.hpp /usr/local/include/backward.hpp

COPY .devcontainer/build.sh /entrypoint.sh

#INSERT_HERE
Expand Down
9 changes: 7 additions & 2 deletions distribution/docker/Dockerfile.orkaudio
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN . /etc/os-release && apt-key adv --keyserver keyserver.ubuntu.com --recv-key

RUN apt-get update && apt-get install -y build-essential libtool automake git tree rpm libboost1.70-dev`
libpcap-dev libsndfile1-dev libapr1-dev libspeex-dev liblog4cxx-dev libace-dev `
libopus-dev libxerces-c3-dev libssl-dev cmake`
libopus-dev libxerces-c3-dev libssl-dev cmake libdw-dev liblzma-dev libunwind-dev`
&& rm -rf /var/lib/apt/lists/*

#silk
Expand Down Expand Up @@ -43,6 +43,11 @@ RUN mkdir -p /opt/bcg729 && chmod 777 /opt/bcg729`
&& make `
&& make install

#backward-cpp
RUN mkdir -p /opt/backward-cpp && chmod 777 /opt/backward-cpp`
&& git clone --depth 1 https://github.com/bombela/backward-cpp.git /opt/backward-cpp `
&& ln -s /opt/backward-cpp/backward.hpp /usr/local/include/backward.hpp

RUN mkdir -p /opt/oreka && chmod 777 /opt/oreka`
&& git clone --depth 1 https://github.com/voiceip/oreka.git /opt/oreka `
&& cd /opt/oreka/orkbasecxx `
Expand All @@ -62,7 +67,7 @@ MAINTAINER Kinshuk B ([email protected])

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y libpcap0.8 libsndfile1 libapr1 libspeex1 liblog4cxx10v5 libace-6.3.3 `
libopus0 libxerces-c3.1 libssl1.0.0 && rm -rf /var/lib/apt/lists/*
libopus0 libxerces-c3.1 libssl1.0.0 libdw1 libunwind8 && rm -rf /var/lib/apt/lists/*

# Mount the image from "builder" stage at `/artifacts` during this run
RUN --mount=type=bind,source=/,target=/artifacts,from=builder `
Expand Down
18 changes: 5 additions & 13 deletions orkaudio/OrkAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
#include <iostream>
#include "stdio.h"

#define BOOST_STACKTRACE_USE_ADDR2LINE
#include <boost/stacktrace.hpp>
#define BACKWARD_HAS_DW 1
#define BACKWARD_HAS_LIBUNWIND 1
#include "backward.hpp"

#include "MultiThreadedServer.h"
#include "OrkAudio.h"
Expand Down Expand Up @@ -406,19 +407,10 @@ void MainThread()
OrkLogManager::Instance()->Shutdown();
}

void sig_handler(int sig) {
// print out all the frames to stderr
fprintf(stderr, "Error: signal %d:\n", sig);
try {
std::cerr << boost::stacktrace::stacktrace();
} catch (...) {}
exit(1);
}

int main(int argc, char* argv[])
{
signal(SIGSEGV, sig_handler); // install fatal error handler
signal(SIGABRT, sig_handler); // install abort error handler

backward::SignalHandling sh; //install fatal error backtrace handler.

OrkAprSingleton::Initialize();

Expand Down
14 changes: 11 additions & 3 deletions orkaudio/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ if [grep "release 5" /etc/redhat-release]; then
CXXFLAGS+="-DCENTOS_5"
fi

AC_LANG_CPLUSPLUS
AC_PROG_CXX([g++])
AM_PROG_LIBTOOL

# Check if gcc supports cpp11
if [echo "main(){}" | $CXX -std=c++11 -xc++ -S - &>/dev/null] ; then
CXXFLAGS+=" -g -O2 -fno-inline-functions -std=c++11 -DSUPPORTS_CPP11 -fPIC"
Expand All @@ -27,9 +31,13 @@ else
CXXFLAGS+=" -g -O2 -fno-inline-functions"
fi

AC_LANG_CPLUSPLUS
AC_PROG_CXX
AM_PROG_LIBTOOL
AC_SEARCH_LIBS([dwarf_begin],[dw],[][
LDFLAGS+=" -ldw"
], AC_MSG_ERROR([libdw is not installed.]))

AC_SEARCH_LIBS([unw_backtrace],[unwind],[][
LDFLAGS+=" -lunwind"
], AC_MSG_ERROR([libunwind is not installed.]))

AC_PREFIX_DEFAULT(/usr)

Expand Down

0 comments on commit f63b172

Please sign in to comment.