diff options
| author | Brooks Davis <brooks@FreeBSD.org> | 2026-08-03 16:51:19 +0000 |
|---|---|---|
| committer | Brooks Davis <brooks@FreeBSD.org> | 2026-08-03 21:43:23 +0000 |
| commit | 7516130eb91264b2faf0c532b29a8e27c2ddd098 (patch) | |
| tree | 321968d474857fb7e2f960d3db559e83fa1d296b | |
| parent | 5dff273d680ab848c62ca50efacb19f199217ab7 (diff) | |
kdump(1): minimally adapt to exterror category sources
Add some minimal handling of category sources other than static kernel
sources. We don't actually look up dynamic sources yet (that would
require extended trace records to add the file names to the trace file
since we can't assume the trace file is running on a kernel with the
same numbers.)
Make the decision to append a "src/" prefix to each file name
dependent on the category source.
Reviewed by: kib
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D58412
| -rw-r--r-- | usr.bin/kdump/kdump.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 398478c2d86c..d7352b28768c 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -2448,12 +2448,31 @@ static const char * const cat_to_filenames[] = { }; static const char * +cat_to_file_prefix(int category) +{ + switch (EXTERR_CAT_SRC(category)) { + case EXTERR_CAT_SRC_KERN_STATIC: + return ("sys/"); + default: + return (""); + } +} + +static const char * cat_to_filename(int category) { - if (category < 0 || (unsigned)category >= nitems(cat_to_filenames) || - cat_to_filenames[category] == NULL) + switch (EXTERR_CAT_SRC(category)) { + case EXTERR_CAT_SRC_KERN_STATIC: + if (category < 0 || + (unsigned)category >= nitems(cat_to_filenames) || + cat_to_filenames[category] == NULL) + return ("unknown"); + return (cat_to_filenames[category]); + case EXTERR_CAT_SRC_KERN_DYNAMIC: + return ("kern:dynamic"); + default: return ("unknown"); - return (cat_to_filenames[category]); + } } static void @@ -2464,9 +2483,10 @@ ktrexterr(struct ktr_exterr *ke) ue = &ke->ue; asprintf(&msg, ue->msg, (uintmax_t)ue->p1, (uintmax_t)ue->p2); - printf("{ errno %d sys/%s:%u \"%s\" (category %u p1 %#jx p2 %#jx) }\n", - ue->error, cat_to_filename(ue->cat), ue->src_line, msg, - ue->cat, (uintmax_t)ue->p1, (uintmax_t)ue->p2); + printf("{ errno %d %s%s:%u \"%s\" (category %u p1 %#jx p2 %#jx) }\n", + ue->error, cat_to_file_prefix(ue->cat), cat_to_filename(ue->cat), + ue->src_line, msg, ue->cat, + (uintmax_t)ue->p1, (uintmax_t)ue->p2); free(msg); } |
