@@ -93,6 +93,35 @@ find_package(Backward)
93
93
# through an IMPORTED target.
94
94
target_link_libraries(mytarget PUBLIC Backward::Backward)
95
95
```
96
+ ### Libraries to unwind the stack
97
+
98
+ On Linux and macOS, backtrace can back-trace or "walk" the stack using the
99
+ following libraries:
100
+
101
+ #### unwind
102
+
103
+ Unwind comes from libgcc, but there is an equivalent inside clang itself. With
104
+ unwind, the stacktrace is as accurate as it can possibly be, since this is
105
+ used by the C++ runtine in gcc/clang for stack unwinding on exception.
106
+
107
+ Normally libgcc is already linked to your program by default.
108
+
109
+ #### libunwind from the [ libunwind project] ( https://github.com/libunwind/libunwind )
110
+
111
+ apt-get install binutils-dev (or equivalent)
112
+
113
+ Libunwind provides, in some cases, a more accurate stacktrace as it knows
114
+ to decode signal handler frames and lets us edit the context registers when
115
+ unwinding, allowing stack traces over bad function references.
116
+
117
+ For best results make sure you are using libunwind 1.3 or later, which added
118
+ ` unw_init_local2 ` and support for handling signal frames.
119
+
120
+ CMake will warn you when configuring if your libunwind version doesn't support
121
+ signal frames.
122
+
123
+ On macOS clang provides a libunwind API compatible library as part of its
124
+ environment, so no third party libraries are necessary.
96
125
97
126
### Compile with debug info
98
127
@@ -110,17 +139,17 @@ your sources.
110
139
111
140
### Libraries to read the debug info
112
141
113
- Backward support pretty printed stack traces on GNU/Linux only, it will compile
114
- fine under other platforms but will not do anything. ** Pull requests are
115
- welcome :)**
142
+ Backward supports pretty printed stack traces on GNU/Linux, macOS and Windows,
143
+ it will compile fine under other platforms but will not do anything. ** Pull
144
+ requests are welcome :)**
116
145
117
146
Also, by default you will get a really basic stack trace, based on the
118
147
` backtrace_symbols ` API:
119
148
120
149
![ default trace] ( doc/nice.png )
121
150
122
- You will need to install some dependencies to get the ultimate stack trace. Two
123
- libraries are currently supported, the only difference is which one is the
151
+ You will need to install some dependencies to get the ultimate stack trace.
152
+ Three libraries are currently supported, the only difference is which one is the
124
153
easiest for you to install, so pick your poison:
125
154
126
155
#### libbfd from the [ GNU/binutils] ( http://www.gnu.org/software/binutils/ )
0 commit comments