Logging stacktrace for a legacy C program

73 views
Skip to first unread message

Jeff Wang

unread,
Feb 1, 2021, 12:19:03 AM2/1/21
to Crashpad-dev
Hi all,

I will need to address diagnosability of a legacy C program (running in Linux) by logging a stacktrace when a crash happens.

I have a few questions. I am not a C/C++ programmer so please bear with me :-).
1. crashpad is written in C++. I know that C can call C++ with wrapper. So it should be possible to use crashpad in the legacy C program, correct? Also can you elaborate what might entail in addition to C wrappers?
2. My use case is to log stacktrace only and the program is running in Linux only. From reading crashpad documentation, it seems crashpad will need an extra process (crashpad handler) which receives crash metadata from crashpad embedder (the legacy C program). Is there a way to eliminate the extra process?
3. https://stackoverflow.com/questions/4636456/how-to-get-a-stack-trace-for-c-using-gcc-with-line-number-information shows a way to generate a stacktrace. I am wondering if it will be a good solution assuming I only need to log it and the OS is Linux.

Thanks,
Jeff

Joshua Peraza

unread,
Feb 1, 2021, 12:41:07 PM2/1/21
to Jeff Wang, Crashpad-dev
On Sun, Jan 31, 2021 at 9:19 PM Jeff Wang <zhifeng...@gmail.com> wrote:
Hi all,

I will need to address diagnosability of a legacy C program (running in Linux) by logging a stacktrace when a crash happens.

I have a few questions. I am not a C/C++ programmer so please bear with me :-).
1. crashpad is written in C++. I know that C can call C++ with wrapper. So it should be possible to use crashpad in the legacy C program, correct? Also can you elaborate what might entail in addition to C wrappers?
2. My use case is to log stacktrace only and the program is running in Linux only. From reading crashpad documentation, it seems crashpad will need an extra process (crashpad handler) which receives crash metadata from crashpad embedder (the legacy C program). Is there a way to eliminate the extra process?

It doesn't sound like Crashpad is the right fit for your project. Crashpad generates minidumps, which are like core dumps and can be used with a debugger like LLDB.

 
3. https://stackoverflow.com/questions/4636456/how-to-get-a-stack-trace-for-c-using-gcc-with-line-number-information shows a way to generate a stacktrace. I am wondering if it will be a good solution assuming I only need to log it and the OS is Linux.

Thanks,
Jeff

--
You received this message because you are subscribed to the Google Groups "Crashpad-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to crashpad-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/crashpad-dev/d9bdcf96-6c63-4d34-8180-1407cedc286fn%40chromium.org.

Jeff Wang

unread,
Feb 1, 2021, 9:51:24 PM2/1/21
to Crashpad-dev, Joshua Peraza, Crashpad-dev, Jeff Wang
Thanks for the reply.

Are there integration documentations available, especially for C program? I found an integration guide for breakpad, https://chromium.googlesource.com/breakpad/breakpad/+/master/docs/linux_starter_guide.md, but not crashpad.

Thanks,
Jeff

Reply all
Reply to author
Forward
0 new messages