Add core errors and use them to implement file descriptor tracker
All the tool error callbacks now have a core error equivalent.
core errors are negative (while tool errors are positive).
There are two new ones for tracking issues with file descriptors.
FdBadClose (-2) and FdNotClosed (-3).
Add following core error functions with delegates to file descriptor
specific functions (implemented in syswrap-generic):
- core_eq_Error (fd_eq_Error)
Compares core errors to detect duplicates
- core_before_pp_Error (fd_before_pp_Error)
Currently prints nothing for known core errors and
exists with FATAL for unknown core errors
- core_pp_Error (fd_pp_Error)
For FdBadClose prints the backtraces for the file descriptor was
opened, where it was originally closed and where it was closed again.
For FdNotClosed prints where the file descriptor was opened.
- core_update_extra (fd_update_extra)
Returns the size of the BadCloseExtra or FdNotClosedExtra struct
which data needs to be saved (the fd number, pathname/description
and previous backtraces).
We now accept the error (ExeContext) where to be NULL.
This is necessary for reporting not closed file descriptors when
the descriptor is inherited from the parent (so wasn't actually
created and doesn't have a 'where' in the current process code).
All the testcases still pass since the (stderr) output is the
same. But now they count as "real" errors. And so --error-exitcode
does now also work for file descriptor errors or leaks.
https://bugs.kde.org/show_bug.cgi?id=362680
Co-authored-by: Alexandra Hájková <ahajkova@redhat.com>