From c2c9ac88c2bb62423ae91beeee4083b596922adc Mon Sep 17 00:00:00 2001 From: Dmitry Chagin Date: Fri, 26 May 2023 19:35:08 +0300 Subject: [PATCH] kdump: Add a facility to print numbers in decimal format always To help grepping kdump output by pid or tid it makes sence to print some numbers in decimal format always. Eg, process or thread identifier at least, as they already printed in decimal format. Switch to print pid/tid arguments of some Linux signal related syscalls in decimal format. Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D40099 MFC after: 1 week --- usr.bin/kdump/kdump.h | 13 +++++++++---- usr.bin/kdump/linux.c | 12 ++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/usr.bin/kdump/kdump.h b/usr.bin/kdump/kdump.h index f5b9b85f9779..1d3e9be2b6e0 100644 --- a/usr.bin/kdump/kdump.h +++ b/usr.bin/kdump/kdump.h @@ -34,7 +34,7 @@ extern bool decimal, fancy, resolv; -#define print_number64(first,i,n,c) do { \ +#define _print_number64(first,i,n,c,d) do { \ uint64_t __v; \ \ if (quad_align && (((ptrdiff_t)((i) - (first))) & 1) == 1) { \ @@ -46,7 +46,7 @@ extern bool decimal, fancy, resolv; ((uint64_t)(uint32_t)(i)[1]) << 32; \ else \ __v = (uint64_t)*(i); \ - if (decimal) \ + if (d) \ printf("%c%jd", (c), (intmax_t)__v); \ else \ printf("%c%#jx", (c), (uintmax_t)__v); \ @@ -55,8 +55,8 @@ extern bool decimal, fancy, resolv; (c) = ','; \ } while (0) -#define print_number(i,n,c) do { \ - if (decimal) \ +#define _print_number(i,n,c,d) do { \ + if (d) \ printf("%c%jd", c, (intmax_t)*i); \ else \ printf("%c%#jx", c, (uintmax_t)(u_register_t)*i); \ @@ -65,6 +65,11 @@ extern bool decimal, fancy, resolv; c = ','; \ } while (0) +#define print_number(i,n,c) _print_number(i,n,c,decimal) +#define print_decimal_number(i,n,c) _print_number(i,n,c,true) +#define print_number64(first,i,n,c) _print_number64(first,i,n,c,decimal) +#define print_decimal_number64(first,i,n,c) _print_number64(first,i,n,c,true) + void decode_filemode(int value); void print_integer_arg(const char *(*decoder)(int), int value); void print_integer_arg_valid(const char *(*decoder)(int), int value); diff --git a/usr.bin/kdump/linux.c b/usr.bin/kdump/linux.c index 6395f00b6e3b..48c82b2a8017 100644 --- a/usr.bin/kdump/linux.c +++ b/usr.bin/kdump/linux.c @@ -202,7 +202,7 @@ ktrsyscall_linux(struct ktr_syscall *ktr, register_t **resip, case LINUX_SYS_linux_kill: case LINUX_SYS_linux_tkill: case LINUX_SYS_linux_rt_sigqueueinfo: - print_number(ip, narg, c); + print_decimal_number(ip, narg, c); putchar(','); print_linux_signal(*ip); ip++; @@ -210,8 +210,8 @@ ktrsyscall_linux(struct ktr_syscall *ktr, register_t **resip, break; case LINUX_SYS_linux_tgkill: case LINUX_SYS_linux_rt_tgsigqueueinfo: - print_number(ip, narg, c); - print_number(ip, narg, c); + print_decimal_number(ip, narg, c); + print_decimal_number(ip, narg, c); putchar(','); print_linux_signal(*ip); ip++; @@ -411,7 +411,7 @@ ktrsyscall_linux32(struct ktr_syscall *ktr, register_t **resip, case LINUX32_SYS_linux_kill: case LINUX32_SYS_linux_tkill: case LINUX32_SYS_linux_rt_sigqueueinfo: - print_number(ip, narg, c); + print_decimal_number(ip, narg, c); putchar(','); print_linux_signal(*ip); ip++; @@ -419,8 +419,8 @@ ktrsyscall_linux32(struct ktr_syscall *ktr, register_t **resip, break; case LINUX32_SYS_linux_tgkill: case LINUX32_SYS_linux_rt_tgsigqueueinfo: - print_number(ip, narg, c); - print_number(ip, narg, c); + print_decimal_number(ip, narg, c); + print_decimal_number(ip, narg, c); putchar(','); print_linux_signal(*ip); ip++;