]> git.ipfire.org Git - thirdparty/systemd.git/commit
coredump: add JSON output support to coredumpctl info
authornoxiouz <atiurin@proton.me>
Tue, 17 Mar 2026 23:55:51 +0000 (23:55 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 14 May 2026 14:53:13 +0000 (15:53 +0100)
commitbb233dcb4be131990e2222c8a65e63f6771e28fa
treebe8381ccd8019edf9537bec19cefc6b54b214643
parent868223f78caa93d9c6c6f1212602c99fb2683e6b
coredump: add JSON output support to coredumpctl info

Implement support for the --json= flag in the info subcommand
(issue #38844). Previously, coredumpctl info always produced
human-readable text output regardless of --json=.

Add a CoredumpFields struct that holds all journal fields extracted
for a coredump entry, along with coredump_fields_done() to release
member resources and coredump_fields_load() to populate the struct
from a journal entry. Both print_info() and the new print_info_json()
use this shared loader, eliminating the duplicate RETRIEVE loop.

print_info_json() builds a JSON object with the same fields shown by
print_info(). Missing fields are omitted via SD_JSON_BUILD_PAIR_CONDITION,
matching the tolerant behavior of print_info() rather than skipping the
entry entirely. Signal/Reason handling mirrors print_info(): normal
coredumps (MESSAGE_ID == SD_MESSAGE_COREDUMP_STR) emit a numeric Signal
field; non-normal entries (kernel oops, etc.) emit a Reason field with
the raw text from COREDUMP_SIGNAL.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
src/coredump/coredumpctl.c
test/units/TEST-87-AUX-UTILS-VM.coredump.sh