Skip to content

Commit

Permalink
add backward-cpp stack trace log utility as a git submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
pkestene committed May 3, 2018
1 parent 31ddfb9 commit d91dba8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
path = external/kokkos
url = https://github.com/kokkos/kokkos.git
branch = develop
[submodule "external/backward-cpp"]
path = external/backward-cpp
url = https://github.com/bombela/backward-cpp.git
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ add_definitions( -Wall )
#
# sources
#
add_subdirectory(external/backward-cpp)
add_subdirectory(external/kokkos)

# pass Kokkos include directories to our target application
Expand Down
1 change: 1 addition & 0 deletions external/backward-cpp
Submodule backward-cpp added at c25d2e
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add_subdirectory(kokkos)

add_subdirectory(backward-cpp)
add_subdirectory(io)

if(USE_MPI)
Expand Down
4 changes: 4 additions & 0 deletions test/backward-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
add_executable(test_segfault
test_segfault.cpp
${BACKWARD_ENABLE})
add_backward(test_segfault)
26 changes: 26 additions & 0 deletions test/backward-cpp/test_segfault.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* A minimalist example to use library backward-cpp to pretty print
* error / stack trace...
*
* for as standalone build:
* g++ -DBACKWARD_HAS_DW=1 -g -I../../external/backward-cpp test_segfault.cpp ../../external/backward-cpp/backward.cpp -ldw
*
*/

#include <iostream>

#include "backward.hpp"

void badass_function() {
char* ptr = (char*)42;
*ptr = 42;
}

int main(int argc, char* argv[])
{

std::cout << "Create a segfault on purpose...\n";
badass_function();

return 0;
}

0 comments on commit d91dba8

Please sign in to comment.