From owner-svn-src-all@freebsd.org Sun Jul 5 20:25:53 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 786AE34C061; Sun, 5 Jul 2020 20:25:53 +0000 (UTC) (envelope-from pawel.biernacki@gmail.com) Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4B0Kw053scz4Ldk; Sun, 5 Jul 2020 20:25:52 +0000 (UTC) (envelope-from pawel.biernacki@gmail.com) Received: by mail-ej1-f65.google.com with SMTP id w6so40404856ejq.6; Sun, 05 Jul 2020 13:25:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=8e2JXRl8piMcpqatjjLOfeG1tUviJAvlBD6u3w32Uo8=; b=Cb9t3Rz54qOWWlBQtdk/dF+9VvyLl1s9sHFdqqZMF0QknreRaIguQiFf6fIOlvMtlX jyjtI7u/ohKhI49injzxdv/Z8BUxPvZIvPt2TJAbcpmRwS0PC2tzygreQ7CQZt/RDYxA chCVuzdgw1gBzyADQ/pQmiPkLQJZUdDLaW4868hJMkMcKSBlK4RStDO8TJQSyPlAwBbZ y8WeMxEpr3dt/mMVfQ4mpnB4ZtSyME5mUKERPwPSmIoxSkahKnvov1BVQ7aONlUtbjmQ oZDJ+G0kft5rfFNIDEV+9z0nfHpbHBTCMrBkUpP5vkxLGAdRRf7CD/m7gYGtrYMN+tKs rDJQ== X-Gm-Message-State: AOAM533Pw5R/de7FizFEtHMvD3AM1oRsvKvhP9d6QXfQu87cdLFKj/hd jl4Q95YZ+3XKdw6E0YlcOmU0QheVpBM= X-Google-Smtp-Source: ABdhPJwkxe/9jj9jBLIAt9QRFVZ4da3F6ISDRJLZQXsCwQ3pemMVO2Gc8ChbP4PaltJnwdDocFrwyQ== X-Received: by 2002:ac2:5382:: with SMTP id g2mr14286434lfh.129.1593980303740; Sun, 05 Jul 2020 13:18:23 -0700 (PDT) Received: from macbook.localdomain (31-172-188-241.noc.fibertech.net.pl. [31.172.188.241]) by smtp.gmail.com with ESMTPSA id 11sm4980462lju.102.2020.07.05.13.18.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Jul 2020 13:18:23 -0700 (PDT) From: =?utf-8?Q?Pawe=C5=82_Biernacki?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: svn commit: r362947 - head/usr.bin/truss Date: Sun, 5 Jul 2020 22:18:18 +0200 References: <202007051953.065Jrs9T018207@repo.freebsd.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org In-Reply-To: <202007051953.065Jrs9T018207@repo.freebsd.org> Message-Id: <03E07B95-A86B-488C-B3C8-061546E54BBC@FreeBSD.org> X-Mailer: Apple Mail (2.3608.120.23.2.1) X-Rspamd-Queue-Id: 4B0Kw053scz4Ldk X-Spamd-Bar: +++++++++++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of pawelbiernacki@gmail.com designates 209.85.218.65 as permitted sender) smtp.mailfrom=pawelbiernacki@gmail.com X-Spamd-Result: default: False [11.85 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[209.85.218.65:from]; MV_CASE(0.50)[]; R_SPF_ALLOW(0.00)[+ip4:209.85.128.0/17]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.00)[-0.001]; FORGED_SENDER(0.30)[kaktus@FreeBSD.org,pawelbiernacki@gmail.com]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; FROM_NEQ_ENVFROM(0.00)[kaktus@FreeBSD.org,pawelbiernacki@gmail.com]; MID_RHS_MATCH_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; ARC_NA(0.00)[]; RECEIVED_SPAMHAUS_XBL(5.00)[31.172.188.241:received]; TAGGED_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_ALL(0.00)[]; SH_AUTHBL_RECEIVED(4.00)[31.172.188.241:received]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[FreeBSD.org]; NEURAL_SPAM_MEDIUM(1.05)[1.051]; BAD_REP_POLICIES(0.10)[]; NEURAL_SPAM_LONG(1.00)[1.004]; RCVD_IN_DNSWL_NONE(0.00)[209.85.218.65:from]; RCVD_TLS_ALL(0.00)[]; GREYLIST(0.00)[pass,body] X-Spam: Yes X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jul 2020 20:25:53 -0000 Before:=20 = __sysctl("sysctl.name2oid",2,0x7fffff763a80,0x7fffff763280,0x7fffff763680,= 8) =3D 0 (0x0) __sysctl("sysctl.oidfmt.6.2",4,0x7fffff763ae0,0x7fffff762e78,0x0,0) =3D = 0 (0x0) __sysctl("sysctl.name.6.2",4,0x7fffff762180,0x7fffff761d00,0x0,0) =3D 0 = (0x0) __sysctl("sysctl.oidfmt.6.2",4,0x7fffff762980,0x7fffff761d08,0x0,0) =3D = 0 (0x0) __sysctl("sysctl.oiddescr.6.2",4,0x7fffff762580,0x7fffff761d00,0x0,0) =3D = 0 (0x0) After: __sysctl("sysctl.name2oid = hw.model",2,0x7fffff161e60,0x7fffff161660,0x7fffff161a60,8) =3D 0 (0x0) __sysctl("sysctl.oidfmt hw.model",4,0x7fffff161ec0,0x7fffff161258,0x0,0) = =3D 0 (0x0) __sysctl("sysctl.name { 6.2 }",4,0x7fffff160560,0x7fffff1600e0,0x0,0) =3D = 0 (0x0) __sysctl("sysctl.oidfmt hw.model",4,0x7fffff160d60,0x7fffff1600e8,0x0,0) = =3D 0 (0x0) __sysctl("sysctl.oiddescr = hw.model",4,0x7fffff160960,0x7fffff1600e0,0x0,0) =3D 0 (0x0) Reminded by: mjg > On 5 Jul 2020, at 21:53, Pawel Biernacki wrote: >=20 > Author: kaktus > Date: Sun Jul 5 19:53:54 2020 > New Revision: 362947 > URL: https://svnweb.freebsd.org/changeset/base/362947 >=20 > Log: > truss: print more information about traced sysctls >=20 > MFC after: 2 weeks > Sponsored by: Mysterious Code Ltd. >=20 > Modified: > head/usr.bin/truss/syscalls.c >=20 > Modified: head/usr.bin/truss/syscalls.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/usr.bin/truss/syscalls.c Sun Jul 5 19:38:36 2020 = (r362946) > +++ head/usr.bin/truss/syscalls.c Sun Jul 5 19:53:54 2020 = (r362947) > @@ -1577,14 +1577,37 @@ print_cmsgs(FILE *fp, pid_t pid, bool receive, = struct=20 > } >=20 > static void > -print_sysctl_oid(FILE *fp, int *oid, int len) > +print_sysctl_oid(FILE *fp, int *oid, size_t len) > { > - int i; > + size_t i; > + bool first; >=20 > - for (i =3D 0; i < len; i++) > - fprintf(fp, ".%d", oid[i]); > + first =3D true; > + fprintf(fp, "{ "); > + for (i =3D 0; i < len; i++) { > + fprintf(fp, "%s%d", first ? "" : ".", oid[i]); > + first =3D false; > + } > + fprintf(fp, " }"); > } >=20 > +static void > +print_sysctl(FILE *fp, int *oid, size_t len) > +{ > + char name[BUFSIZ]; > + int qoid[CTL_MAXNAME + 2]; > + size_t i; > + > + qoid[0] =3D CTL_SYSCTL; > + qoid[1] =3D CTL_SYSCTL_NAME; > + memcpy(qoid + 2, oid, len * sizeof(int)); > + i =3D sizeof(name); > + if (sysctl(qoid, len + 2, name, &i, 0, 0) =3D=3D -1) > + print_sysctl_oid(fp, oid, len); > + else > + fprintf(fp, "%s", name); > +} > + > /* > * Converts a syscall argument into a string. Said string is > * allocated via malloc(), so needs to be free()'d. sc is > @@ -2298,9 +2321,8 @@ print_arg(struct syscall_args *sc, unsigned long = *args > break; > case Sysctl: { > char name[BUFSIZ]; > - int oid[CTL_MAXNAME + 2], qoid[CTL_MAXNAME + 2]; > - size_t i; > - int len; > + int oid[CTL_MAXNAME + 2]; > + size_t len; >=20 > memset(name, 0, sizeof(name)); > len =3D args[sc->offset + 1]; > @@ -2314,39 +2336,35 @@ print_arg(struct syscall_args *sc, unsigned = long *args > fprintf(fp, "debug"); > break; > case CTL_SYSCTL_NAME: > - fprintf(fp, "name"); > + fprintf(fp, "name "); > print_sysctl_oid(fp, oid + 2, = len - 2); > break; > case CTL_SYSCTL_NEXT: > fprintf(fp, "next"); > break; > case CTL_SYSCTL_NAME2OID: > - fprintf(fp, "name2oid"); > + fprintf(fp, "name2oid %s", > + get_string(pid, > + args[sc->offset + 4], > + args[sc->offset + 5])); > break; > case CTL_SYSCTL_OIDFMT: > - fprintf(fp, "oidfmt"); > - print_sysctl_oid(fp, oid + 2, = len - 2); > + fprintf(fp, "oidfmt "); > + print_sysctl(fp, oid + 2, len - = 2); > break; > case CTL_SYSCTL_OIDDESCR: > - fprintf(fp, "oiddescr"); > - print_sysctl_oid(fp, oid + 2, = len - 2); > + fprintf(fp, "oiddescr "); > + print_sysctl(fp, oid + 2, len - = 2); > break; > case CTL_SYSCTL_OIDLABEL: > - fprintf(fp, "oidlabel"); > - print_sysctl_oid(fp, oid + 2, = len - 2); > + fprintf(fp, "oidlabel "); > + print_sysctl(fp, oid + 2, len - = 2); > break; > default: > - print_sysctl_oid(fp, oid + 1, = len - 1); > + print_sysctl(fp, oid + 1, len - = 1); > } > } else { > - qoid[0] =3D CTL_SYSCTL; > - qoid[1] =3D CTL_SYSCTL_NAME; > - memcpy(qoid + 2, oid, len * = sizeof(int)); > - i =3D sizeof(name); > - if (sysctl(qoid, len + 2, name, &i, 0, = 0) =3D=3D -1) > - print_sysctl_oid(fp, qoid + 2, = len); > - else > - fprintf(fp, "%s", name); > + print_sysctl(fp, oid, len); > } > fprintf(fp, "\""); > }