From nobody Wed Jun 22 11:40:59 2022 X-Original-To: dev-commits-src-all@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 8331B8715C6; Wed, 22 Jun 2022 11:41:00 +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 4LShKS195Qz4sS9; Wed, 22 Jun 2022 11:41:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655898060; 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=2WZgSqabDyoaqYay/fYsXrlpMZViBNdR9NWu6EqekW4=; b=wRjFmZ4wOcs3+8ONeXXXcaWU2LEqgfkEidBGU8xoFqGWX80W7UkvcdBBx9B06dcY9dtfGG CkAO6hjaXrOQkJ5xnLVoi0Z/9teVm+daqu4ixJ+kDa8uxxWEoMh7joysGeeFiUpRLmSK5G mQBe62JWSgYY+bKxca3MADFy7F7ujvXK4d/8yUYGx1zkCblfuVGFE++ZcWIKNfk1n8pjAQ DjJrMwSLjVc5Q3CMDSofhnuIFjmhZKGeGSTGagqsTO3f1CUDeVJmcVq4TNqK8rJ7GcUFEY 33ckrpcayTkg//fzG2PmLnmLRmU1YtV94JdQ97+ifhzuVDfHPvH0xS/iFEgFfg== 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 D5FA025719; Wed, 22 Jun 2022 11:40:59 +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 25MBexuH023658; Wed, 22 Jun 2022 11:40:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25MBexng023657; Wed, 22 Jun 2022 11:40:59 GMT (envelope-from git) Date: Wed, 22 Jun 2022 11:40:59 GMT Message-Id: <202206221140.25MBexng023657@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 8b8e2e8f4154 - main - kdump: For future use extract common code to a separate files List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: 8b8e2e8f4154e02670123caf9a1dd1c5188463cc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655898060; 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=2WZgSqabDyoaqYay/fYsXrlpMZViBNdR9NWu6EqekW4=; b=JlCDAbY6oHLeSWGPvNNWySc9tY4lDmGKd70Ohj5KYIUds68PfCX2lGYqabkY7HNm6durN0 w5d4zbJ9br63YU+/jeigLK9u7q1uOyAj7DlarM7Hkxj1HpuvOxuF/k44zAF0em3vQrLJPd 9NYg4cvAQCTMyauP2KWfDAk6jEX8WE1Xm4nMMmamQAPaZV4BBpROLVTG9+NCMdG+HF7niN qJTV1v98nZMHK0X+isNA44JnhOxG7wKUVebb52sIZiGK4FSMxDiG1+gtt4BNBBDVF0C82o mzdNHJqdST2AwbO9Wh+2Xfz31vHS6HuG3v62ISbHBJTCrWG/XhMwOTmseaLeYQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655898060; a=rsa-sha256; cv=none; b=Vzt+hwqYfJpMLAY7Jd4H+YElnyd9r2ZB7zONuWNyC2vaEa7bc50XqYUmbCrr4x52osGWCp YlwSQia8dXXcdZMW6VdYHmRkm1qBYz4vBG0blZsnZFznfED1cLPyxiPzjzdXVOJeCDmvLD aTfjsbS9Nd0EztMorb6vSxkMqsPdFfIOtRCol4QGePbRI+j1PJZC8Otsg6he04Xm+pze5F UxVDUZCOdh2yG4ozJuqxUU8PCFEdVXE1NqDEC5HLSSbNrIdVgGYIbforvLr4LySWM8AF1F kDVv5Hja1MfguO5Qetf+jqT993bcDOXJQa/jlRLOi1aYDx9jVjo2yZqbPOKOfw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=8b8e2e8f4154e02670123caf9a1dd1c5188463cc commit 8b8e2e8f4154e02670123caf9a1dd1c5188463cc Author: Dmitry Chagin AuthorDate: 2022-06-22 11:01:36 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-22 11:01:36 +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 --- 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 0f4ac9a0c262..e54f8ec1deb5 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__ */