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
This commit is contained in:
Dmitry Chagin 2023-05-26 19:35:08 +03:00
parent 829f3d7d26
commit c2c9ac88c2
2 changed files with 15 additions and 10 deletions

View File

@ -34,7 +34,7 @@
extern bool decimal, fancy, resolv; 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; \ uint64_t __v; \
\ \
if (quad_align && (((ptrdiff_t)((i) - (first))) & 1) == 1) { \ 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; \ ((uint64_t)(uint32_t)(i)[1]) << 32; \
else \ else \
__v = (uint64_t)*(i); \ __v = (uint64_t)*(i); \
if (decimal) \ if (d) \
printf("%c%jd", (c), (intmax_t)__v); \ printf("%c%jd", (c), (intmax_t)__v); \
else \ else \
printf("%c%#jx", (c), (uintmax_t)__v); \ printf("%c%#jx", (c), (uintmax_t)__v); \
@ -55,8 +55,8 @@ extern bool decimal, fancy, resolv;
(c) = ','; \ (c) = ','; \
} while (0) } while (0)
#define print_number(i,n,c) do { \ #define _print_number(i,n,c,d) do { \
if (decimal) \ if (d) \
printf("%c%jd", c, (intmax_t)*i); \ printf("%c%jd", c, (intmax_t)*i); \
else \ else \
printf("%c%#jx", c, (uintmax_t)(u_register_t)*i); \ printf("%c%#jx", c, (uintmax_t)(u_register_t)*i); \
@ -65,6 +65,11 @@ extern bool decimal, fancy, resolv;
c = ','; \ c = ','; \
} while (0) } 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 decode_filemode(int value);
void print_integer_arg(const char *(*decoder)(int), int value); void print_integer_arg(const char *(*decoder)(int), int value);
void print_integer_arg_valid(const char *(*decoder)(int), int value); void print_integer_arg_valid(const char *(*decoder)(int), int value);

View File

@ -202,7 +202,7 @@ ktrsyscall_linux(struct ktr_syscall *ktr, register_t **resip,
case LINUX_SYS_linux_kill: case LINUX_SYS_linux_kill:
case LINUX_SYS_linux_tkill: case LINUX_SYS_linux_tkill:
case LINUX_SYS_linux_rt_sigqueueinfo: case LINUX_SYS_linux_rt_sigqueueinfo:
print_number(ip, narg, c); print_decimal_number(ip, narg, c);
putchar(','); putchar(',');
print_linux_signal(*ip); print_linux_signal(*ip);
ip++; ip++;
@ -210,8 +210,8 @@ ktrsyscall_linux(struct ktr_syscall *ktr, register_t **resip,
break; break;
case LINUX_SYS_linux_tgkill: case LINUX_SYS_linux_tgkill:
case LINUX_SYS_linux_rt_tgsigqueueinfo: case LINUX_SYS_linux_rt_tgsigqueueinfo:
print_number(ip, narg, c); print_decimal_number(ip, narg, c);
print_number(ip, narg, c); print_decimal_number(ip, narg, c);
putchar(','); putchar(',');
print_linux_signal(*ip); print_linux_signal(*ip);
ip++; ip++;
@ -411,7 +411,7 @@ ktrsyscall_linux32(struct ktr_syscall *ktr, register_t **resip,
case LINUX32_SYS_linux_kill: case LINUX32_SYS_linux_kill:
case LINUX32_SYS_linux_tkill: case LINUX32_SYS_linux_tkill:
case LINUX32_SYS_linux_rt_sigqueueinfo: case LINUX32_SYS_linux_rt_sigqueueinfo:
print_number(ip, narg, c); print_decimal_number(ip, narg, c);
putchar(','); putchar(',');
print_linux_signal(*ip); print_linux_signal(*ip);
ip++; ip++;
@ -419,8 +419,8 @@ ktrsyscall_linux32(struct ktr_syscall *ktr, register_t **resip,
break; break;
case LINUX32_SYS_linux_tgkill: case LINUX32_SYS_linux_tgkill:
case LINUX32_SYS_linux_rt_tgsigqueueinfo: case LINUX32_SYS_linux_rt_tgsigqueueinfo:
print_number(ip, narg, c); print_decimal_number(ip, narg, c);
print_number(ip, narg, c); print_decimal_number(ip, narg, c);
putchar(','); putchar(',');
print_linux_signal(*ip); print_linux_signal(*ip);
ip++; ip++;