Home > Backend Development > Golang > How to load debugging symbols for a running process?

How to load debugging symbols for a running process?

WBOY
Release: 2024-02-09 11:18:08
forward
859 people have browsed it

How to load debugging symbols for a running process?

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.

Question content

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

Workaround

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!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template