简体   繁体   English

使用gdb调试共享库

[英]Debugging shared library with gdb

I wrote quite a big program and I received shared library test.so to test it. 我写了一个很大的程序,并收到了共享库test.so进行测试。 After launching it a lot of tests are passed, but somewhere it is stucked. 启动它之后,通过了许多测试,但是卡在了某个地方。 It displays constantly error message: "ERR 65", probably provided by test.so, not by gdb. 它不断显示错误消息:“ ERR 65”,可能由test.so而不是gdb提供。 When I try to put breakpoints somewhere, there is always so much code to go through, that I can't reach trouble-maker function. 当我尝试将断点放置在某个地方时,总是要经过很多代码,以至于无法实现麻烦制造者的功能。

When I clicked ctrl+c to stop it an write step I got: 当我单击ctrl + c停止它时,我得到了一个写步骤:

_IO_new_file_write (f=0x2aaaab7b7280 <_IO_2_1_stdout_>, data=<optimized out>, n=17) at     
fileops.c:1263
1263    fileops.c: No such file or directory.

which it gives me nothing and when I write backtrace I got something like that: 它什么也没有给我,当我写回溯时,我得到了类似的东西:

#0  0x00002aaaab4e1700 in __write_nocancel () at ../sysdeps/unix/syscall-template.S:81
#1  0x00002aaaab46f243 in _IO_new_file_write (f=0x2aaaab7b7280 <_IO_2_1_stdout_>, data=        
<optimized out>, n=17) at fileops.c:1262
#2  0x00002aaaab46f122 in new_do_write (fp=0x2aaaab7b7280 <_IO_2_1_stdout_>,         
data=0x2aaaaaad2000 "ERR 65: Za duzo.\n+ 15 elementow.\n elementow.\n\nin.\n", 
to_do=17) at fileops.c:538
#3  0x00002aaaab470855 in _IO_new_do_write (fp=<optimized out>, data=<optimized out>,         
to_do=17) at fileops.c:511
#4  0x00002aaaab46fac1 in _IO_new_file_xsputn (n=5, data=<optimized out>,     
f=0x2aaaab7b7280 <_IO_2_1_stdout_>) at fileops.c:1333
#5  _IO_new_file_xsputn (f=0x2aaaab7b7280 <_IO_2_1_stdout_>, data=<optimized out>, n=5)     
at fileops.c:1278
#6  0x00002aaaab464e15 in __GI__IO_fwrite (buf=<optimized out>, size=1, count=5,     
fp=0x2aaaab7b7280 <_IO_2_1_stdout_>) at iofwrite.c:43
#7  0x00002aaaaaf6fb45 in std::basic_ostream<char, std::char_traits<char> >&     
std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char,     
std::char_traits<char> >&, char const*, long) () from /usr/lib/x86_64-linux-    
gnu/libstdc++.so.6
#8  0x00002aaaaaf6fe07 in std::basic_ostream<char, std::char_traits<char> >&     
std::operator<< <std::char_traits<char> >(std::basic_ostream<char,     
std::char_traits<char> >&, char const*) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#9  0x00002aaaaacd73e7 in Test2() () from ./tests/ltest_liniowe2.so
#10 0x0000000000404eb6 in main ()

which also it gives me nothing. 这也没有给我任何东西。

Next solution was to put breakpoint on all function and write output to the file so that I would have flow of program, but I don't know how to automize gdb problam so that it itself write "continue" function in order to go to the next function. 下一个解决方案是在所有函数上放置断点,然后将输出写入文件,这样我就可以执行程序流程,但是我不知道如何使gdb problam自动化,以便它自己编写“ continue”函数以便转到下一个功能。

How do I find trouble maker function? 如何找到麻烦制造者功能?

Thank You very much for any advice! 非常感谢您的任何建议!

Your problem is that you didn't compile your test.so with debugging information. 您的问题是您没有使用调试信息编译test.so。

In your backtrace, frames 0-8 are all from libstdc++ or libc. 在回溯中,第0-8帧全部来自libstdc ++或libc。 Frame #9 is the first frame that is from your program -- but since it doesn't have debuginfo, even if you go up to that frame, you won't find out anything interesting. 第9帧是程序中的第一帧-但由于它没有debuginfo,即使您转到该帧,也不会发现任何有趣的东西。

The fix is to recompile with -g. 解决方法是使用-g重新编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM