-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
conan package does not print pretty stack. #299
Comments
without the necessary libraries it won't be able to read the debug symbols.
this might be the reason
…On Thu, Jun 22, 2023, 00:56 jbongseo ***@***.***> wrote:
Following is my sample project setup.
# conan file
$ cat <<EOF > conanfile.txt[requires]backward-cpp/1.6[generators]CMakeDepsCMakeToolchainEOF
# CMakeLists.txt file
$ cat <<EOF > CMakeLists.txtcmake_minimum_required(VERSION 3.14...3.22)project( backward_sample LANGUAGES CXX VERSION 0.1 DESCRIPTION "backward_sample")set(CMAKE_CXX_STANDARD 17)set(CMAKE_CXX_STANDARD_REQUIRED ON)set(CMAKE_EXPORT_COMPILE_COMMANDS ON)include(./conan_deps/conan_toolchain.cmake)find_package(Backward REQUIRED)add_executable(backward_sample backward_sample.cpp)set_target_properties(backward_sample PROPERTIES CXX_STANDARD 17 OUTPUT_NAME backward_sample)target_link_libraries(backward_sample PRIVATE Backward::Backward)EOF
# test source file
$ cat <<EOF > backward_sample.cpp#include "backward.hpp"namespace backward {backward::SignalHandling sh;} // namespace backwardvoid crash() { volatile int* a = (int*)(NULL); *a = 1;}int main(int argc, char* argv[]) { crash(); return 0;}EOF
I compiled this project by following step:
$ mkdir conan_deps && cd conan_deps
$ conan install .. -pr Debug
$ cmake -B build -DCMAKE_BUILD_TYPE=Debug
$ cmake --build build --verbose
I can see that it is compiled with -g option and DBACKWARD_HAS_DWARF=1
flag.
It also seems be linked with libdwarf and libelf.
[ 50%] Building CXX object CMakeFiles/backward_sample.dir/backward_sample.cpp.o
/usr/bin/c++ -DBACKWARD_HAS_BACKTRACE=0 -DBACKWARD_HAS_BACKTRACE_SYMBOL=0 -DBACKWARD_HAS_BFD=0 -DBACKWARD_HAS_DW=0 -DBACKWARD_HAS_DWARF=1 -DBACKWARD_HAS_LIBUNWIND=0 -DBACKWARD_HAS_PDB_SYMBOL=0 -DBACKWARD_HAS_UNWIND=1 -isystem /home/jbseo/.conan/data/backward-cpp/1.6/_/_/package/2e02edff0a8a2b4d15d2baca54e2cbc7ecca7eae/include -isystem /home/jbseo/.conan/data/libdwarf/20191104/_/_/package/29a01e41514e57b26ac6cb3d59a534cdaa425a4d/include -isystem /home/jbseo/.conan/data/libelf/0.8.13/_/_/package/be27726f9885116da1158027505be62e913cd585/include -isystem /home/jbseo/.conan/data/libelf/0.8.13/_/_/package/be27726f9885116da1158027505be62e913cd585/include/libelf -isystem /home/jbseo/.conan/data/zlib/1.2.13/_/_/package/be27726f9885116da1158027505be62e913cd585/include -g -std=gnu++17 -MD -MT CMakeFiles/backward_sample.dir/backward_sample.cpp.o -MF CMakeFiles/backward_sample.dir/backward_sample.cpp.o.d -o CMakeFiles/backward_sample.dir/backward_sample.cpp.o -c /home/jbseo/playground/backward_cpp/backward_sample.cpp
[100%] Linking CXX executable backward_sample
/usr/bin/cmake -E cmake_link_script CMakeFiles/backward_sample.dir/link.txt --verbose=1
/usr/bin/c++ -g CMakeFiles/backward_sample.dir/backward_sample.cpp.o -o backward_sample /home/jbseo/.conan/data/backward-cpp/1.6/_/_/package/2e02edff0a8a2b4d15d2baca54e2cbc7ecca7eae/lib/libbackward.a -ldl -lm /home/jbseo/.conan/data/libdwarf/20191104/_/_/package/29a01e41514e57b26ac6cb3d59a534cdaa425a4d/lib/libdwarf.a /home/jbseo/.conan/data/zlib/1.2.13/_/_/package/be27726f9885116da1158027505be62e913cd585/lib/libz.a /home/jbseo/.conan/data/libelf/0.8.13/_/_/package/be27726f9885116da1158027505be62e913cd585/lib/libelf.a
However, the generated binary only print simple stack without debug info.
$ ./build/backward_sample
Stack trace (most recent call last):
#5 Object "", at 0xffffffffffffffff, in
#4 Object "/home/jbseo/playground/backward_cpp/build/backward_sample", at 0x55d51ff8e924, in
#3 Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f6ebd166e3f, in __libc_start_main
#2 Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f6ebd166d8f, in
#1 Object "/home/jbseo/playground/backward_cpp/build/backward_sample", at 0x55d51ff8ea1d, in
#0 Object "/home/jbseo/playground/backward_cpp/build/backward_sample", at 0x55d51ff8e9fd, in
Segmentation fault (Address not mapped to object [(nil)])
Segmentation fault
I cannot figure out what I have missed.
Thanks for your advice in advance.
—
Reply to this email directly, view it on GitHub
<#299>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABUZDF2FEZH2HCSSESHDYTXMP3BPANCNFSM6AAAAAAZPZ3HM4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
That may be the source of the problem.
And we can check that using
By the way, I tried installing those library globally and linked them forcefully.
Now,
and it works well now.
I do not know the reason. Thanks for the great library! |
Sadly I don't know anything about conan (and not much about CMake)! I
accepted pull requests from kind people :D
…On Thu, Jun 22, 2023, 17:21 jbongseo ***@***.***> wrote:
without the necessary libraries it won't be able to read the debug symbols.
That may be the source of the problem.
libdwarf and libelf is compiled and linked statically as specified by
conan receipt and we can see that in the build log.
/usr/bin/c++ -g CMakeFiles/backward_sample.dir/backward_sample.cpp.o -o backward_sample
[BLAH_PATH]/libbackward.a
-ldl -lm // <- ldl
[BLAH_PATH]/libdwarf.a // <- linked statically
[BLAH_PATH]/libz.a
[BLAH_PATH]/libelf.a // <- linked statically
And we can check that using ldd command.
$ ldd build/backward_sample
linux-vdso.so.1 (0x00007ffe2c943000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f46f6dd0000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f46f6db0000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f46f6b88000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f46f6aa1000)
/lib64/ld-linux-x86-64.so.2 (0x00007f46f70a3000)
By the way, I tried installing those library globally and linked them
forcefully.
Then it worked as expected.
sudo apt-get install libdwarf-dev libelf-dev
# CMakeLists.txt
# add -ldwarf -lelf flag to forcefully link global library
target_link_libraries(backward_sample PRIVATE Backward::Backward -ldwarf -lelf)
$ cmake --build build --clean-first --verbose
...
[100%] Linking CXX executable backward_sample
/usr/bin/cmake -E cmake_link_script CMakeFiles/backward_sample.dir/link.txt --verbose=1
/usr/bin/c++ -g CMakeFiles/backward_sample.dir/backward_sample.cpp.o -o backward_sample
-ldwarf -lelf <-- forcefully injected link
[BLAH_PATH]/libbackward.a
-ldl -lm
[BLAH_PATH]/libdwarf.a <-- provided by cmake. maybe ignored?
[BLAH_PATH]/libz.a
[BLAH_PATH]/libelf.a <-- provided by cmake. maybe ignored?
Now, libdwarf, libelf, libz are linked dynamically.
$ ldd ./build/backward_sample
linux-vdso.so.1 (0x00007ffde4d86000)
libdwarf.so.1 => /lib/x86_64-linux-gnu/libdwarf.so.1 (0x00007f7ffa159000)
libelf.so.1 => /lib/x86_64-linux-gnu/libelf.so.1 (0x00007f7ffa13b000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f7ff9f11000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f7ff9ef1000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7ff9cc9000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f7ff9cab000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7ffa23a000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7ff9bc4000)
and it works well now.
$ ./build/backward_sample
Stack trace (most recent call last):
#5 Object "", at 0xffffffffffffffff, in
#4 Object "/home/jbseo/playground/backward_cpp/build/backward_sample", at 0x55a592030a84, in _start
#3 Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f76f1442e3f, in __libc_start_main
#2 Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f76f1442d8f, in __libc_init_first
#1 Source "/home/jbseo/playground/backward_cpp/backward_sample.cpp", line 15, in int main(int argc, char **argv) [0x55a592030b7d]
12: }
13:
14: int main(int argc, char* argv[]) {
> 15: crash();
16: return 0;
17: }
#0 Source "/home/jbseo/playground/backward_cpp/backward_sample.cpp", line 11, in crash() [0x55a592030b5d]
9: void crash() {
10: volatile int* a = (int*)(NULL);
> 11: *a = 1;
12: }
13:
14: int main(int argc, char* argv[]) {
Segmentation fault (Address not mapped to object [(nil)])
Segmentation fault
I do not know the reason.
Maybe libdwarf should not be linked statically or libdwarf conan package
has some problem in it.
Anyway, conan package should not be encouraged currently.
Thanks for the great library!
—
Reply to this email directly, view it on GitHub
<#299 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABUZDCJOTOEAIZUSVEVVTLXMTOQBANCNFSM6AAAAAAZPZ3HM4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hi, can you elaborate more about the steps?? I'm not familiar with cpp.... |
Following is my sample project setup.
I compiled this project by following step:
I can see that it is compiled with
-g
option andDBACKWARD_HAS_DWARF=1
flag.It also seems be linked with
libdwarf
andlibelf
.However, the generated binary only print simple stack without debug info.
I cannot figure out what I have missed.
Thanks for your advice in advance.
The text was updated successfully, but these errors were encountered: