From 7e07fddd98455c52b57ea820e557430ecdce4f1f Mon Sep 17 00:00:00 2001 From: jhb Date: Mon, 8 Oct 2018 17:18:55 +0000 Subject: [PATCH] MFC 337400: Remove spurious ABI tags from kdump output. The abidump routine output an ABI tag when -A was specified for records that were not displayed due to type or pid filtering. To fix, split the code to lookup the ABI from the code to display the ABI, move the code to display the ABI into dumpheader(), and move dumpheader() later in the main loop as a simplification. Previously dumpheader() was called under a condition that repeated conditions made later in the main loop. --- usr.bin/kdump/kdump.c | 82 ++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 47 deletions(-) diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 7db1a8b8794..5adb929e5fd 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -91,10 +91,10 @@ __FBSDID("$FreeBSD$"); #include #endif -u_int abidump(struct ktr_header *); int fetchprocinfo(struct ktr_header *, u_int *); +u_int findabi(struct ktr_header *); int fread_tail(void *, int, int); -void dumpheader(struct ktr_header *); +void dumpheader(struct ktr_header *, u_int); void ktrsyscall(struct ktr_syscall *, u_int); void ktrsysret(struct ktr_sysret *, u_int); void ktrnamei(char *, int); @@ -491,10 +491,6 @@ main(int argc, char *argv[]) drop_logged = 1; } } - if (trpoints & (1< size) { @@ -507,12 +503,13 @@ main(int argc, char *argv[]) errx(1, "data too short"); if (fetchprocinfo(&ktr_header, (u_int *)m) != 0) continue; - sv_flags = abidump(&ktr_header); if (pid && ktr_header.ktr_pid != pid && ktr_header.ktr_tid != pid) continue; if ((trpoints & (1<pid == kth->ktr_pid) { - flags = pi->sv_flags; - break; + return (pi->sv_flags); } } - - if (abiflag == 0) - return (flags); - - switch (flags & SV_ABI_MASK) { - case SV_ABI_LINUX: - abi = "L"; - break; - case SV_ABI_FREEBSD: - abi = "F"; - break; - case SV_ABI_CLOUDABI: - abi = "C"; - break; - default: - abi = "U"; - break; - } - - if (flags & SV_LP64) - arch = "64"; - else if (flags & SV_ILP32) - arch = "32"; - else - arch = "00"; - - printf("%s%s ", abi, arch); - - return (flags); + return (0); } void -dumpheader(struct ktr_header *kth) +dumpheader(struct ktr_header *kth, u_int sv_flags) { static char unknown[64]; static struct timeval prevtime, prevtime_e; struct timeval temp; + const char *abi; + const char *arch; const char *type; const char *sign; @@ -729,10 +696,6 @@ dumpheader(struct ktr_header *kth) case KTR_SYSCTL: type = "SCTL"; break; - case KTR_PROCCTOR: - /* FALLTHROUGH */ - case KTR_PROCDTOR: - return; case KTR_CAPFAIL: type = "CAP "; break; @@ -790,6 +753,31 @@ dumpheader(struct ktr_header *kth) } } printf("%s ", type); + if (abiflag != 0) { + switch (sv_flags & SV_ABI_MASK) { + case SV_ABI_LINUX: + abi = "L"; + break; + case SV_ABI_FREEBSD: + abi = "F"; + break; + case SV_ABI_CLOUDABI: + abi = "C"; + break; + default: + abi = "U"; + break; + } + + if ((sv_flags & SV_LP64) != 0) + arch = "64"; + else if ((sv_flags & SV_ILP32) != 0) + arch = "32"; + else + arch = "00"; + + printf("%s%s ", abi, arch); + } } #include -- 2.45.0