What is a good way to dump a Linux core file from inside a process?

前端 未结 8 1967
醉梦人生
醉梦人生 2020-12-08 23:14

We have a server (written in C and C++) that currently catches a SEGV and dumps some internal info to a file. I would like to generate a core file and write it to disk at th

相关标签:
8条回答
  • 2020-12-08 23:44

    I saw pmbrett's post and thought "hey, thats cool" but couldn't find that utility anywhere on my system ( Gentoo ).

    So I did a bit of prodding, and discovered GDB has this option in it.

    gdb --pid=4049 --batch -ex gcore

    Seemed to work fine for me.

    Its not however very useful because it traps the very lowest function that was in use at the time, but it still does a good job outside that ( With no memory limitations, Dumped 350M snapshot of a firefox process with it )

    0 讨论(0)
  • 2020-12-08 23:45

    Some possible solutions^W ways of dealing with this situation:

    1. Fix the ulimit!!!
    2. Accept that you don't get a core file and run inside gdb, scripted to do a "thread all apply bt" on SIGSEGV
    3. Accept that you don't get a core file and acquired a stack trace from within the application. The Stack Backtracing Inside Your Program article is pretty old but it should be possible these days too.
    0 讨论(0)
提交回复
热议问题