Debugging in Linux using core dumps

后端 未结 3 1721
没有蜡笔的小新
没有蜡笔的小新 2021-01-31 21:41

What are the \'best practices\' when it comes to debugging core dumps using GDB?

Currently, I am facing a problem:

  • The release version of my application is
3条回答
  •  青春惊慌失措
    2021-01-31 21:59

    It sounds like there are other differences between your release and debug build then simply the absence/presence of the -g flag. Assuming that's the case, there is nothing you can do right now, but you can adjust your build to handle this better:

    Here's what we do at my place of work.

    1. Include the -g flag when building the release version.
    2. Archive that version.
    3. run strip --strip-unneeded on the binary before shipping it to customers.

    Now, when we get a crash we can use the archived version with symbols to do debugging.

    One thing to note is that if your release version includes optimization, debugging may be difficult even with symbols. For example, the optimizer can reorder your code so even though the debugger will say you crashed on line N, you can't assume that the code actually executed line N-1.

提交回复
热议问题