简体   繁体   中英

debugging with gdb without sources

I have to debug a program with gdb. This program is compiled with debug options with gcc. My problem is that the sources are not in the same machine I use to debug and run this program. I can't use remote gdb debugging. Is there a way to now the line/file location when advancing in gdb? Is there some other solutions for this problem?

Thanks

You can debug it with the assembly code.

objdump -d shows all the contents. Then run gdb with break at main function, and ni to run the next instruction(assembly). Oh, don't forget to enable display $pc will help you.

The above advice is only for toy code.

If you have installed IDA(and the plugin), you can use its restore to C code function.

If you are experiencing a segmentation fault , you may use core dump on linux machine by enabling it

ulimit -c unlimited

then transfer the core dump file to the other machine where you've got the source and run gdb with coredump file to identify where in the code you are getting the segmentation fault.

I found the command info line in gdb which shows the location in source file, even if gdb did not find the source files. This workaround seems OK for me.

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