From nobody Wed Jul 06 11:04:00 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 64AEF1D00BA1; Wed, 6 Jul 2022 11:04:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LdGrK14p9z3N6J; Wed, 6 Jul 2022 11:04:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657105441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Dczk7+wZXf7jnAuW4rf6Jg2VYYAxiQBzAAWHfypOpDE=; b=q4j6UgR3s47eclMI3h0ljn8qlC3G3G79nF00GzstYfSnuclPYda9pn48a28jBs44VDEe/Z 4y3sDP+osK2u+tWWbqKHpzTGDh75uDFeAzO0JYHJVqdFev9VoWI+18omQr5kGYc/zRaczb 10Eo3ho2MyJK9w8IMHyqKL6HMVtaTIVLWwZhv7AKcrnkhcfABQ6bsV4tqFWuvk93CmkNHq 3qbPCpTyZ/sS+MLTE5Gpcxi0DxKzp/TlgXZ1JTOUjN34Nmx5fuVF25ISWKcHfR8ElKlRMm LB0c3cL/zU0U2IPhSc1ydYRWaKYgGchRrudXZ97DsEGAo172VRRWcYLcxs+Vuw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C69D9194B9; Wed, 6 Jul 2022 11:04:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 266B40MZ096423; Wed, 6 Jul 2022 11:04:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 266B40pM096422; Wed, 6 Jul 2022 11:04:00 GMT (envelope-from git) Date: Wed, 6 Jul 2022 11:04:00 GMT Message-Id: <202207061104.266B40pM096422@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: b31a7b84b397 - stable/13 - kdump: For future use extract common code to a separate files List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b31a7b84b3975effc3c627b9ebc8786837a28a5b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657105441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Dczk7+wZXf7jnAuW4rf6Jg2VYYAxiQBzAAWHfypOpDE=; b=IY+3yKIb0VnfQZfe95GSEjyO+KMX1m+v4UrE0dqqKjhoOEYmLbVRK94ZF2kd4AHInlt1NH D29cOa8k0yqmzBykEuf28xOWudtS6ZDfQgy62bK/enUMBiTb5fsUu8OGy5sKMKkY9kZAIL Eua/sJ/kQa/kX1zVmDGka9mFWoefK4LQOlmDnfMvVz1keaY1yA/aPH/4c/BuPeycEbpk7D nnUqOY0qvvh2MTCaPshkafoklc1zQIIaFseyYVYB6mBE7g54r75CdoBP+IFlj8xehRRkCO LPRCJmCRCLq+zTR6lpHj/LSB9xvkl+HwhaySjChLDfHYS4LsamkDBIg37l5f9A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657105441; a=rsa-sha256; cv=none; b=WcDSzQOtMxSobUoPP8PM15mNExTBbDiRMp8CSQpj7Y3HL4C3wNSRtv+U7GYrny1zqrkO4X SWNluCS/JBR1t/Xy+T6875Y7SBYyElJ62pO2qZDV7LxUtyp7AWBryl7UlBvTtcIkP7yzk9 fZUWyT9dzIKzdU5rCsv8fYcpOovURx910qIa+vJLxjGAslUJtN387SeNYAjBsUB2SALgaF ASSt3temRDIEarpsWXQlYwXCvBI4AMeAZlxUbBituxqlJw9Ze2ygEyI2E0Kl6IFBcquiz7 DNq1z2X4LHmDaT39cn+Q5F54WFUCKPE8wDpcRGgkm493/uo13e2Wp8SZWcQf6w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=b31a7b84b3975effc3c627b9ebc8786837a28a5b commit b31a7b84b3975effc3c627b9ebc8786837a28a5b Author: Dmitry Chagin AuthorDate: 2022-06-22 11:01:36 +0000 Commit: Dmitry Chagin CommitDate: 2022-07-06 11:02:13 +0000 kdump: For future use extract common code to a separate files Reviewed by: jhb Differential revision: https://reviews.freebsd.org/D35356 MFC after: 2 weeks (cherry picked from commit 8b8e2e8f4154e02670123caf9a1dd1c5188463cc) --- usr.bin/kdump/kdump.c | 50 +++++++------------------------- usr.bin/kdump/kdump.h | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 40 deletions(-) diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index c9344d001f32..cafc524ca6d3 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$"); #include #include #include "ktrace.h" +#include "kdump.h" #ifdef WITH_CASPER #include @@ -130,8 +131,8 @@ void usage(void); #define TIMESTAMP_ELAPSED 0x2 #define TIMESTAMP_RELATIVE 0x4 -static bool abiflag, decimal, fancy = true, resolv, suppressdata, syscallno, - tail, threads; +bool decimal, fancy = true, resolv; +static bool abiflag, suppressdata, syscallno, tail, threads; static int timestamp, maxdata; static const char *tracefile = DEF_TRACEFILE; static struct ktr_header ktr_header; @@ -139,37 +140,6 @@ static struct ktr_header ktr_header; #define TIME_FORMAT "%b %e %T %Y" #define eqs(s1, s2) (strcmp((s1), (s2)) == 0) -#define print_number64(first,i,n,c) do { \ - uint64_t __v; \ - \ - if (quad_align && (((ptrdiff_t)((i) - (first))) & 1) == 1) { \ - (i)++; \ - (n)--; \ - } \ - if (quad_slots == 2) \ - __v = (uint64_t)(uint32_t)(i)[0] | \ - ((uint64_t)(uint32_t)(i)[1]) << 32; \ - else \ - __v = (uint64_t)*(i); \ - if (decimal) \ - printf("%c%jd", (c), (intmax_t)__v); \ - else \ - printf("%c%#jx", (c), (uintmax_t)__v); \ - (i) += quad_slots; \ - (n) -= quad_slots; \ - (c) = ','; \ -} while (0) - -#define print_number(i,n,c) do { \ - if (decimal) \ - printf("%c%jd", c, (intmax_t)*i); \ - else \ - printf("%c%#jx", c, (uintmax_t)(u_register_t)*i); \ - i++; \ - n--; \ - c = ','; \ -} while (0) - struct proc_info { TAILQ_ENTRY(proc_info) info; @@ -225,7 +195,7 @@ cappwdgrp_setup(cap_channel_t **cappwdp, cap_channel_t **capgrpp) } #endif /* WITH_CASPER */ -static void +void print_integer_arg(const char *(*decoder)(int), int value) { const char *str; @@ -242,7 +212,7 @@ print_integer_arg(const char *(*decoder)(int), int value) } /* Like print_integer_arg but unknown values are treated as valid. */ -static void +void print_integer_arg_valid(const char *(*decoder)(int), int value) { const char *str; @@ -258,7 +228,7 @@ print_integer_arg_valid(const char *(*decoder)(int), int value) } } -static bool +bool print_mask_arg_part(bool (*decoder)(FILE *, int, int *), int value, int *rem) { @@ -266,7 +236,7 @@ print_mask_arg_part(bool (*decoder)(FILE *, int, int *), int value, int *rem) return (decoder(stdout, value, rem)); } -static void +void print_mask_arg(bool (*decoder)(FILE *, int, int *), int value) { bool invalid; @@ -278,7 +248,7 @@ print_mask_arg(bool (*decoder)(FILE *, int, int *), int value) printf("%u", rem); } -static void +void print_mask_arg0(bool (*decoder)(FILE *, int, int *), int value) { bool invalid; @@ -329,7 +299,7 @@ decode_filemode(int value) printf("%u", rem); } -static void +void print_mask_arg32(bool (*decoder)(FILE *, uint32_t, uint32_t *), uint32_t value) { bool invalid; @@ -342,7 +312,7 @@ print_mask_arg32(bool (*decoder)(FILE *, uint32_t, uint32_t *), uint32_t value) printf("%u", rem); } -static void +void print_mask_argul(bool (*decoder)(FILE *, u_long, u_long *), u_long value) { bool invalid; diff --git a/usr.bin/kdump/kdump.h b/usr.bin/kdump/kdump.h new file mode 100644 index 000000000000..faf8e03e541d --- /dev/null +++ b/usr.bin/kdump/kdump.h @@ -0,0 +1,79 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __KDUMP_H__ +#define __KDUMP_H__ + +extern bool decimal, fancy, resolv; + +#define print_number64(first,i,n,c) do { \ + uint64_t __v; \ + \ + if (quad_align && (((ptrdiff_t)((i) - (first))) & 1) == 1) { \ + (i)++; \ + (n)--; \ + } \ + if (quad_slots == 2) \ + __v = (uint64_t)(uint32_t)(i)[0] | \ + ((uint64_t)(uint32_t)(i)[1]) << 32; \ + else \ + __v = (uint64_t)*(i); \ + if (decimal) \ + printf("%c%jd", (c), (intmax_t)__v); \ + else \ + printf("%c%#jx", (c), (uintmax_t)__v); \ + (i) += quad_slots; \ + (n) -= quad_slots; \ + (c) = ','; \ +} while (0) + +#define print_number(i,n,c) do { \ + if (decimal) \ + printf("%c%jd", c, (intmax_t)*i); \ + else \ + printf("%c%#jx", c, (uintmax_t)(u_register_t)*i); \ + i++; \ + n--; \ + c = ','; \ +} while (0) + +void print_integer_arg(const char *(*decoder)(int), int value); +void print_integer_arg_valid(const char *(*decoder)(int), int value); +void print_mask_arg(bool (*decoder)(FILE *, int, int *), int value); +void print_mask_arg0(bool (*decoder)(FILE *, int, int *), int value); +void print_mask_arg32(bool (*decoder)(FILE *, uint32_t, uint32_t *), + uint32_t value); +void print_mask_argul(bool (*decoder)(FILE *, u_long, u_long *), + u_long value); +bool print_mask_arg_part(bool (*decoder)(FILE *, int, int *), + int value, int *rem); + +#endif /* !__KDUMP_H__ */