]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/coredump/coredump.c
coredump: with --backtrace accept a journal entry on stdin
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 6 Nov 2016 15:06:32 +0000 (10:06 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 15 Feb 2017 05:31:55 +0000 (00:31 -0500)
commit5b45a16067d7b8ce12e4732de7cc14b3f804ef06
treeba0c84ed2545328c472f7683e8fd08531d1f5c91
parentf06a6bcd761f2a643377b17c16776512404ac3b0
coredump: with --backtrace accept a journal entry on stdin

The entry must be a single entry in the journal export format, including the
terminating double newline. The MESSAGE field is now generated on the sender
side.

The advantage is that the reporter can easily pass additional metadata.
Continuing with the example of the python excepthook:

COREDUMP_PYTHON_EXECUTABLE=/usr/bin/python3
COREDUMP_PYTHON_VERSION=3.5.2 (default, Sep 14 2016, 11:28:32)
                        [GCC 6.2.1 20160901 (Red Hat 6.2.1-1)]
COREDUMP_PYTHON_THREAD_INFO=sys.thread_info(name='pthread', lock='semaphore', version='NPTL 2.24')
COREDUMP_PYTHON_EXCEPTION_TYPE=ZeroDivisionError
COREDUMP_PYTHON_EXCEPTION_VALUE=division by zero
MESSAGE=Process 29514 (systemd_coredump_exception_handler.py) of user zbyszek failed with ZeroDivisionError: division by zero

        Traceback (most recent call last):
          File "systemd_coredump_exception_handler.py", line 134, in <module>
            g()
          File "systemd_coredump_exception_handler.py", line 133, in g
            f()
          File "systemd_coredump_exception_handler.py", line 131, in f
            div0 = 1 / 0
        ZeroDivisionError: division by zero

        Local variables in innermost frame:
          a=3
          h=<function f at 0x7efdc14b6ea0>

One consideration is whether to use the Journal Export Format, or send packets
over a UNIX socket instead. The advantage of current solution is that although
parsing is more complicated on the receiver side, it is much easier to use on the
sender side. I hope this can be used by various languages for which writing
binary structures to a UNIX socket is harder and more likely to be done wrong
than piping of a simple textyish format.
src/coredump/coredump.c