在Linux中调试段错误(core dumped)(3)

我的程序执行bt后发现有很多问号, 这是因为gdb没有加载我程序库的信息, 编译的时候需要加上-g选项:

(gdb) bt #0 0x0000556393da88ad in ?? () #1 0x00000009b6f194c0 in ?? () #2 0x00005563b686d1b0 in ?? () #3 0x00005563b688abe0 in ?? () #4 0x00007ffe22b8c070 in ?? () #5 0x00005563b5f36460 in ?? () #6 0x0000000000002bf9 in ?? () #7 0x0000000000000004 in ?? () #8 0x00005563b718a580 in ?? () #9 0x0000000000000020 in ?? () #10 0x00007ffe22b8c510 in ?? () #11 0x00007ffe22b8bf50 in ?? () #12 0x00005563b6a2ffd0 in ?? () #13 0x00007ffe22b8bf50 in ?? () #14 0x0000000000000008 in ?? () #15 0x00005563b6a30004 in ?? () #16 0x00007ffe22b8c450 in ?? () #17 0x00007ffe22b8c590 in ?? () #18 0x0000556393dabd1e in ?? () #19 0x00007f1b3f2da1f0 in ?? () #20 0x0000556393dabcd2 in ?? () #21 0x00007ffe22b8c610 in ?? () #22 0x00007ffe22b8bf00 in ?? () #23 0x00007ffe22b8c550 in ?? () #24 0x00007ffe22f747d0 in ?? () #25 0x00007ffe22b8c220 in ?? () #26 0x00007ffe22b8c200 in ?? () #27 0x0000000000000032 in ?? () #28 0x00007ffe22b8c470 in ?? () #29 0x00007ffe22b8c530 in ?? () #30 0x00007ffe22b8c070 in ?? () #31 0x00007ffe22b8c4f0 in ?? () #32 0x00007ffe22b8c510 in ?? () #33 0x00000000000211e0 in ?? () #34 0x00007ffe22b8c5b0 in ?? () #35 0x0000000022b8c490 in ?? () #36 0x0000000000000198 in ?? () #37 0x00007ffe22b8c490 in ?? () #38 0x00007ffe22b8c630 in ?? () #39 0x00007ffe22b8befc in ?? () #40 0x00003d2400000005 in ?? () #41 0x0000000000000000 in ?? ()

在gdb中执行symbol-file 共享动态库的路径进行加载gdb调试时的动态库搜索路径.

ldd命令可以列出一个二进制文件的依赖关系.

利用set solib-search-path进行寻找依赖库.

#0 0x0000556393da88ad in ?? () #1 0x00000009b6f194c0 in ?? () #2 0x00005563b686d1b0 in ?? () #3 0x00005563b688abe0 in ?? () #4 0x00007ffe22b8c070 in ?? () #5 0x00005563b5f36460 in ?? () #6 0x0000000000002bf9 in ?? () #7 0x0000000000000004 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .isra.44] () #8 0x00007ffe22b8c510 in ?? () #9 0x00007ffe22b8bf50 in ?? () #10 0x00005563b6a2ffd0 in ?? () #11 0x00007ffe22b8bf50 in ?? () #12 0x0000000000000008 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .isra.44] () #13 0x0000556393dabd1e in ?? () #14 0x00007f1b3f2da1f0 in ?? () #15 0x0000556393dabcd2 in ?? () #16 0x00007ffe22b8c610 in ?? () #17 0x00007ffe22b8bf00 in ?? () #18 0x00007ffe22b8c550 in ?? () #19 0x00007ffe22f747d0 in ?? () #20 0x00007ffe22b8c220 in ?? () #21 0x00007ffe22b8c200 in ?? () #22 0x0000000000000032 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .isra.44] () #23 0x00000000000211e0 in ?? () #24 0x00007ffe22b8c5b0 in ?? () #25 0x0000000022b8c490 in ?? () Backtrace stopped: Cannot access memory at address 0x195

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/64ec0cd5759bfa40452f88e9f85fc868.html