Skip to content

write metadata to a cache file when applicable

Harald Sitter requested to merge work/metadata into master

on linux there's the option of having crash raise into system level services via the kernel's core dump mechanism. most notably systemd sports coredumpd for this very use case and allows us to even deal with crashes that ordinarily would entirely pass us by. for example crashes on logout, or crashes that can't be debugged using drkonqi on the live instance because something else is controlling the life time of the crashed application (e.g. the app is managed as a systemd unit).

the caveat is that we first need to figure out if a crashed application is one a KDE one, and then we also somehow need the metadata that would ordinarily get passed to drkonqi as arguments.

to help us implement this, argv construction has been refactored into a metadata system. the main metadata is still the ARGV but it may be backed by other writers. this commit also adds an INI writer which dumps the data pretty much verbatim into a file. this is using INI because it is super easy to write and since we must only use signal-safe functions the easier the format is to write the better.

the INI files are written to ~/.cache. house keeping is entirely delegated to something outside kcrash.

the INI tech is build-time limited to linux (since this is all entirely pointless without coredumpd and its only available on linux) additionally this is runtime limited to only when the core_pattern is actually delegating to coredumpd (e.g. metadata writing also makes no sense on ubuntu or fedora, where distro-specific tooling is capturing crashes instead)

as a side effect argv handling itself has been modernized a bit, and is asserting well behaved code more aggressively (e.g. bounds checking)

to control this piece of tech there are two new env variables:

  • KCRASH_NO_METADATA - disables file writing
  • KCRASH_DUMP_ONLY - disables interactive drkonqi, i.e. we only write the metadata and then dump the core. this is set apart from KDE_DEBUG which disables drkonqi globally

Merge request reports