moonchild
moonchild

Reputation: 21

Extracting debugging information from core files

I've been tasked with writing a script to clean up old core files on production Linux servers. While the script is not difficult to write, I'd like to save a basic stack backtrace to a log file before removing the core files.

Being that these servers are production, and we do not have GDB or any development tools installed, I'm looking for some quick and dirty program that will give the analog of a gdb backtrace command for a multithreaded application.

Does anyone know of such a tool?

Thanks in advance.

Upvotes: 0

Views: 1401

Answers (1)

Tom Tromey
Tom Tromey

Reputation: 22539

There are a few things like this. Mostly they are incomplete relative to gdb -- for example it is uncommon for backtracers to print information about function arguments or locals, but gdb can do this. Also gdb can often unwind in cases where other unwinders choke.

Anyway, one I know of is elfutils. https://fedorahosted.org/elfutils/. It has an unwinder in development (not sure if it is in or yet, check git).

There's also libbacktrace. It is part of gcc and is designed for in-process unwinding. However, it could perhaps be adapted to core files.

There's also libunwind. I hear it is kind of terrible but YMMV.

One thing to note is that many of these require debuginfo to be available.

One last thought -- there has been a lot of work in the "catch a trace" area from the ABRT folks. ABRT uses a kernel hook to catch a core dump while it is being made. Then it does analysis by uploading the core to a server, files bugs, etc. You could maybe reuse a lot of their work. There's some other work in this space as well.

Kind of a brain dump, I hope it helps.

Upvotes: 2

Related Questions