1

Linux system running an application. This application is a cpp binary without any debug symbols. Some how this application using 100% cpu. Would like to debug why it is running infinitely. If I stop and replace the binary with debug symbols, the issue may not be reproducible.

So, running the same application with debug symbols in another environment. Here it is running fine.

Can I compare them (with and without debug symbols binaries) and deduct what is the problem using GDB.

5
  • 2
    A profiler might help you narrow down the problem site. You probably won't get the function name, but you should get an address you can work back to the problem function with a memory map if you configure the linker to provide one. Commented Aug 25, 2018 at 5:29
  • 1
    Great. Can you explain with more details using some example. Commented Aug 25, 2018 at 5:33
  • Debug symbols don't need to be built into the running binary to debug, you just need to load the binary with the debug symbols into gcc Commented Aug 25, 2018 at 5:42
  • @AlanBirtles, Can you provide more details with an example? Commented Aug 25, 2018 at 17:26
  • sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html Commented Aug 25, 2018 at 20:09

1 Answer 1

2

This application is a cpp binary without any debug symbols

You don't need any debug symbols to understand where it is spending time, you just need the application to not be fully-stripped (most binaries aren't).

Use perf record -p $pid to collect CPU profile, then perf report to analyse it.

If the application is fully stripped, you can still use perf record to collect program counter values, then perf record --symfs ... to point it to unstripped copy of the application. Documentation here.

Beware: both stripped and unstripped copies must be built with exactly the same build flags, or you'll get garbage. Best practice is to always save unstripped copy as part of the build process.

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

2 Comments

But the application environment is restricted to take perf reports. Any other ways solve this using the GDB only.
@Kranthi Restricted in what way?

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.