Skip to content

Commit

Permalink
libdrgn: better error reporting of unsupported libkdumpfile format
Browse files Browse the repository at this point in the history
Return DRGN_ERROR_INVALID_ARGUMENT with a reasonable error message if
libkdumpfile cannot open a file.

The error output now looks something like:

error: cannot open File #0: Unknown file format

instead of this:

Traceback (most recent call last):
  File "/research/bin/drgn", line 33, in <module>
    sys.exit(load_entry_point('drgn', 'console_scripts', 'drgn')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/research/src/drgn/drgn/cli.py", line 264, in _main
    prog.set_core_dump(args.core)
Exception: kdump_set_number_attr(KDUMP_ATTR_FILE_FD): File #0: Unknown file format

Signed-off-by: Petr Tesarik <[email protected]>
  • Loading branch information
ptesarik committed Nov 10, 2023
1 parent b125f41 commit ab1e901
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libdrgn/kdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ struct drgn_error *drgn_program_set_kdump(struct drgn_program *prog)
}

ks = kdump_set_number_attr(ctx, KDUMP_ATTR_FILE_FD, prog->core_fd);
if (ks == KDUMP_ERR_NOTIMPL) {
err = drgn_error_format(DRGN_ERROR_INVALID_ARGUMENT,
"cannot open %s", kdump_get_err(ctx));
goto err;
}
if (ks != KDUMP_OK) {
err = drgn_error_format(DRGN_ERROR_OTHER,
"kdump_set_number_attr(KDUMP_ATTR_FILE_FD): %s",
Expand Down

0 comments on commit ab1e901

Please sign in to comment.