1

I have a stripped down linux system for which i have to cross compile all the applications i need, on another system. These applications core often and the only information i get from it is the function which cored and the instruction offset. If i have no other option, i do an objdump on the executable, and try to guess the source code from the instruction offset and assembly snippets. This is my life.

Note: The applications are cross-compiled using g++ and are stripped down. So gdb have not helped me much

Question: Since the compiler/gcc has converted the source lines to assembly instructions, wouldnt there be some option which would give a correlation between the instruction offset and the line?

3 Answers 3

5

Create build with -g, then get symbol map out of it. Save it somewhere (i would recommend saving binary with debugging symbols too - it's easier that way), then strip debugging symbols out (with strip program) and deploy resulting binary to target system. Here is howto: https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html

After it crashes, either restore dump with -g-compiled binary or with release binary and separate debug file. If you have crash address and binary with debugging symbols and you want to map it to source code line - you could use addr2line -e your_binary crash_address instead of gdb.

2

You need to compile the source code with -g flag which enables the debug information, providing exactly that correlation that you are asking for.

Then, if your application crashes, you can run it in gdb and inspect the program state at the moment of the crash.

2

you can get the line/file info if you use the non-stripped binary to debug the core file(which was generated by a stripped binary).

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.