3

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

2
  • @AStopher Well, when i try to do the research, this page comes up first in the search results. Never tell people to google the problem first on stackoverflow, you will get them stuck in an infinite loop. Commented Apr 23, 2020 at 13:34
  • @Youda008 That was 6 years ago... back then the top result was literally what the OP copied and pasted into their answer. Commented Apr 23, 2020 at 14:02

3 Answers 3

3

You can debug it with the assembly code.

objdump -d shows all the contents. Then run gdb with break atmain 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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

-1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.