Comments (6)
It looks like you are not collecting all the trace details in your _get_trace
method. Try calling abort()
with backward-cpp
signal handler installed for comparison.
The README doesn't specify what needs to be in code for pretty code ?
It does, read again :) And as far as I can tell, your define
s are correct in your cmake output. (But I am not experienced with CMake, so take my affirmation with a grain of salt). You have unwind
and BFD
.
Do i need to throw special Exceptions or is everything catched ?
Do i need a TRY/CATCH block in main which covers everything ?
backward-cpp
doesn't offer any function to attach stacktrace onto Exceptions (I had a work in progress branch at some point, but never took the time to finish the work).
If you never catch an exception, eventually your program will call abort()
. This will effectively get you a stacktrace from backward-cpp
assuming signal handlers are registered. But this stackstrace will start from the abort()
call not were the exception was raised.
So your idea of storing a stacktrace alongside the Exception is perfectly good, but make sure to collect all the details :) I would advise you to collect the stacktrace in the exception without resolving anything yet, and use the stacktrace printer whenever you want to resolve and print details about the exception stacktrace.
Best,
from backward-cpp.
I was not sure if
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lbfd")
is the correct way to link against the library, so i added:
target_link_libraries(PfTEngineTest "libbfd.so")
now when calling abort in f() i get a pretty nice stacktrace.
`i=0
i=1
i=2
i=3
i=4
i=5
i=6
i=7
i=8
i=9
i=10
i=11
i=12
i=13
i=14
i=15
i=16
i=17
i=18
i=19
i=20
i=21
i=22
i=23
i=24
i=25
i=26
i=27
i=28
i=29
i=30
i=31
i=32
i=33
i=34
i=35
i=36
i=37
i=38
i=39
i=40
i=41
Stack trace (most recent call last):
#31 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#30 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#29 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#28 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#27 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#26 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#25 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#24 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#23 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#22 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#21 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#20 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#19 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#18 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#17 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#16 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#15 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#14 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#13 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#12 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#11 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#10 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#9 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#8 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#7 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#6 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#5 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#4 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#3 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 50, in f(int) [0x4be574]
47: else
48: {
49: std::cout << "i=" << i << "\n";
> 50: f(i + 1);
51: }
52: }
#2 Source "/home/gitlab-runner/builds/0c2717af/0/PfTTech/PfTEngine/src/test/pfthread.cpp", line 44, in f(int) [0x4be53b]
41: {
42: if (i >= 42)
43: {
> 44: abort();
45: throw TracedException();
46: }
47: else
#1 Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7faf86b13029, in abort
#0 Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7faf86b11428, in gsignal
Aborted (Signal sent by tkill() 19122 999)
Aborted
from backward-cpp.
I am glad that it works now :)
from backward-cpp.
So the pretty output only shows up if you link against the right libraries? I think there's a bug in the conan recipe then :(
from backward-cpp.
from backward-cpp.
From the package recipe perspective, conan is just a python script that tells how to get your project sources, build them, and what build artifacts must be packaged (In this way it works very similar to some system package managers). The only thing that makes it special is that conan is specifically designed for C++, so it keeps track of compiler versioning, abi, platform, etc when building and resolving the dependencies.
With this in mind, if there's a bug in the way optional libraries are handled is because I didn't take this right into account when writing the recipe. Specifically, I put one conan option (A package can define multiple options that result in different "variants" of the same package, for example "MyFooLib" Debug vs Release) for each backward-cpp option. Then conan build() method just invokes your CMakeLists.txt with those options. What I forgot is to tell the library (Maybe by modifying how the cmake library target is handled in the CMakeLists.txt) to link against different optional libraries depending on the options.
from backward-cpp.
Related Issues (20)
- Unable to trace in mingw HOT 1
- Add Support for Baremetal
- Libunwind on ARM Mac can't compile
- Make print_***() ostream arguments templated HOT 1
- Default source line format compatible with compiler error format HOT 1
- How to suppress clang-tidy warnings HOT 1
- Problem calling load_here() in a parent constructor
- Load stack trace into user-provided storage HOT 1
- using "backward" in Windows OS HOT 4
- build error
- new tagged Release
- Slow stacktraces in large projects HOT 1
- Is there some situation that will not print the call stack
- Macos with libunwind do not work. HOT 2
- Source code accessibility HOT 3
- Slow stacktraces when built with clang HOT 1
- fixing this library HOT 2
- libdwarf cannot find when using vcpkg, and ibdw has become a rerequisite for libdwarf? HOT 5
- cmake vcpkg elfutil libdw missing '<dlfcn.h>'
- On arm signal trace error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backward-cpp.