简体   繁体   中英

Debugging shared library with gdb

I wrote quite a big program and I received shared library test.so to test it. 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. 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:

_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.

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.

In your backtrace, frames 0-8 are all from libstdc++ or 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.

The fix is to recompile with -g.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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