Skip to content

Commit

Permalink
debug: enable compilation without execinfo.h
Browse files Browse the repository at this point in the history
Otherwise, the CI breaks, as Alpine does not have execinfo anymore. If
not present, we cannot generate a backtrace, so we just print that.
  • Loading branch information
ammen99 committed Sep 27, 2022
1 parent ce79985 commit 4f25189
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
container: alpine:edge
steps:
- run: apk --no-cache add git gcc g++ binutils pkgconf meson ninja musl-dev wayland-dev wayland-protocols libinput-dev libevdev-dev libxkbcommon-dev pixman-dev glm-dev libdrm-dev mesa-dev cairo-dev pango-dev eudev-dev libxml2-dev libexecinfo-dev libseat-dev libxcb-dev xcb-util-wm-dev xwayland doctest doctest-dev cmake
- run: apk --no-cache add git gcc g++ binutils pkgconf meson ninja musl-dev wayland-dev wayland-protocols libinput-dev libevdev-dev libxkbcommon-dev pixman-dev glm-dev libdrm-dev mesa-dev cairo-dev pango-dev eudev-dev libxml2-dev libseat-dev libxcb-dev xcb-util-wm-dev xwayland doctest doctest-dev cmake
- uses: actions/checkout@v1
- run: git config --global --add safe.directory /__w/wayfire/wayfire
- run: git submodule sync --recursive && git submodule update --init --force --recursive
Expand Down
18 changes: 16 additions & 2 deletions src/debug.cpp
Expand Up @@ -2,15 +2,20 @@
#include <wayfire/debug.hpp>
#include <sstream>
#include <iomanip>
#include <execinfo.h>
#include <cxxabi.h>

#if __has_include(<execinfo.h>)
#include <execinfo.h>
#include <cxxabi.h>
#endif

#include <cstdio>
#include <dlfcn.h>
#include <sys/stat.h>

#define MAX_FRAMES 256
#define MAX_FUNCTION_NAME 1024

#if __has_include(<execinfo.h>)
struct demangling_result
{
std::string executable;
Expand Down Expand Up @@ -254,6 +259,15 @@ void wf::print_trace(bool fast_mode)
free(symbollist);
}

#else // has <execinfo.h>
void wf::print_trace(bool)
{
LOGE("Compiled without execinfo.h, cannot provide a backtrace!",
" Try using address sanitizer.");
}

#endif

/* ------------------- Impl of debugging functions ---------------------------*/
#include <iomanip>
std::ostream& operator <<(std::ostream& out, const glm::mat4& mat)
Expand Down

0 comments on commit 4f25189

Please sign in to comment.