Date: Sun, 5 Jul 2020 22:18:18 +0200 From: =?utf-8?Q?Pawe=C5=82_Biernacki?= <kaktus@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r362947 - head/usr.bin/truss Message-ID: <03E07B95-A86B-488C-B3C8-061546E54BBC@FreeBSD.org> In-Reply-To: <202007051953.065Jrs9T018207@repo.freebsd.org> References: <202007051953.065Jrs9T018207@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <kaktus@FreeBSD.org> 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, "\""); > }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?03E07B95-A86B-488C-B3C8-061546E54BBC>