php editor Xiaoxin will introduce you how to load debugging symbols for the running process. In the software development process, debugging is a very important link. When we encounter a problem with a running process, we need to load debugging symbols for debugging. Debugging symbols contain symbol information of the code, which allows us to more accurately locate the problem during debugging. In this article, we will explain in detail how to load debugging symbols for the running process to help you better debug.
I have a C application that runs on many machines, and sometimes one instance will have issues and behave strangely. Unfortunately, this almost never happens. These product instances are compiled with heavy optimizations (-march=XXX -Ofast
) and do not contain any debugging symbols, so I cannot easily attach a debugger to analyze their status.
But I think it should be possible to compile the application again using the same flags plus -g3
and then I can load it into gdb using symbol-file application_executable_with_debug_symbols
. However, if I do this, the breakpoint never fires.
Is there another way to attach a debugger to a running application and load debugging symbols? Or am I doing something wrong (obviously)?
Thanks
Best practice is to build the application with debugging symbols, keep the resulting binaries for debugging, but run strip -g app.debug - o app.release
and run the stripped binary in production.
When you find an instance that is behaving strangely, you can copy the full debug version to the target machine and run gdb -ex 'attach $PID' app.debug
. Voila: you have complete debugging symbols.
The most likely reason compiling the application again doesn't work is that you get a new binary with different symbols (compare nm app.debug
with nm app.release
), And the most likely reason (if using GCC) is that you omitted some optimization flags for building app.release
, or you used a slightly different source - you Must use the exact same flags (and add -g
) and the exact same source for this method to succeed.
The above is the detailed content of How to load debugging symbols for a running process?. For more information, please follow other related articles on the PHP Chinese website!