truss: decode sysctl names.
Submitted by: Pawel Biernacki MFC after: 1 week Differential revision: https://reviews.freebsd.org/D21688
This commit is contained in:
parent
230754ccca
commit
43ce0d902c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=352488
@ -131,6 +131,7 @@ enum Argtype {
|
|||||||
Sockprotocol,
|
Sockprotocol,
|
||||||
Socktype,
|
Socktype,
|
||||||
Sysarch,
|
Sysarch,
|
||||||
|
Sysctl,
|
||||||
Umtxop,
|
Umtxop,
|
||||||
Waitoptions,
|
Waitoptions,
|
||||||
Whence,
|
Whence,
|
||||||
|
@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#define _WANT_FREEBSD11_STAT
|
#define _WANT_FREEBSD11_STAT
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
@ -506,6 +507,12 @@ static struct syscall decoded_syscalls[] = {
|
|||||||
.args = { { Name, 0 }, { Atfd, 1 }, { Name, 2 } } },
|
.args = { { Name, 0 }, { Atfd, 1 }, { Name, 2 } } },
|
||||||
{ .name = "sysarch", .ret_type = 1, .nargs = 2,
|
{ .name = "sysarch", .ret_type = 1, .nargs = 2,
|
||||||
.args = { { Sysarch, 0 }, { Ptr, 1 } } },
|
.args = { { Sysarch, 0 }, { Ptr, 1 } } },
|
||||||
|
{ .name = "__sysctl", .ret_type = 1, .nargs = 6,
|
||||||
|
.args = { { Sysctl, 0 }, { Sizet, 1 }, { Ptr, 2 }, { Ptr, 3 },
|
||||||
|
{ Ptr, 4 }, { Sizet, 5 } } },
|
||||||
|
{ .name = "__sysctlbyname", .ret_type = 1, .nargs = 6,
|
||||||
|
.args = { { Name, 0 }, { Sizet, 1 }, { Ptr, 2 }, { Ptr, 3 },
|
||||||
|
{ Ptr, 4}, { Sizet, 5 } } },
|
||||||
{ .name = "thr_kill", .ret_type = 1, .nargs = 2,
|
{ .name = "thr_kill", .ret_type = 1, .nargs = 2,
|
||||||
.args = { { Long, 0 }, { Signal, 1 } } },
|
.args = { { Long, 0 }, { Signal, 1 } } },
|
||||||
{ .name = "thr_self", .ret_type = 1, .nargs = 1,
|
{ .name = "thr_self", .ret_type = 1, .nargs = 1,
|
||||||
@ -1551,6 +1558,15 @@ print_cmsgs(FILE *fp, pid_t pid, bool receive, struct msghdr *msghdr)
|
|||||||
free(cmsgbuf);
|
free(cmsgbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_sysctl_oid(FILE *fp, int *oid, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
fprintf(fp, ".%d", oid[i]);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Converts a syscall argument into a string. Said string is
|
* Converts a syscall argument into a string. Said string is
|
||||||
* allocated via malloc(), so needs to be free()'d. sc is
|
* allocated via malloc(), so needs to be free()'d. sc is
|
||||||
@ -2267,6 +2283,62 @@ print_arg(struct syscall_args *sc, unsigned long *args, register_t *retval,
|
|||||||
print_integer_arg(sysdecode_sysarch_number, fp,
|
print_integer_arg(sysdecode_sysarch_number, fp,
|
||||||
args[sc->offset]);
|
args[sc->offset]);
|
||||||
break;
|
break;
|
||||||
|
case Sysctl: {
|
||||||
|
char name[BUFSIZ];
|
||||||
|
int oid[CTL_MAXNAME + 2], qoid[CTL_MAXNAME + 2];
|
||||||
|
size_t i;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
memset(name, 0, sizeof(name));
|
||||||
|
len = args[sc->offset + 1];
|
||||||
|
if (get_struct(pid, (void *)args[sc->offset], oid,
|
||||||
|
len * sizeof(oid[0])) != -1) {
|
||||||
|
fprintf(fp, "\"");
|
||||||
|
if (oid[0] == CTL_SYSCTL) {
|
||||||
|
fprintf(fp, "sysctl.");
|
||||||
|
switch (oid[1]) {
|
||||||
|
case CTL_SYSCTL_DEBUG:
|
||||||
|
fprintf(fp, "debug");
|
||||||
|
break;
|
||||||
|
case CTL_SYSCTL_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");
|
||||||
|
break;
|
||||||
|
case CTL_SYSCTL_OIDFMT:
|
||||||
|
fprintf(fp, "oidfmt");
|
||||||
|
print_sysctl_oid(fp, oid + 2, len - 2);
|
||||||
|
break;
|
||||||
|
case CTL_SYSCTL_OIDDESCR:
|
||||||
|
fprintf(fp, "oiddescr");
|
||||||
|
print_sysctl_oid(fp, oid + 2, len - 2);
|
||||||
|
break;
|
||||||
|
case CTL_SYSCTL_OIDLABEL:
|
||||||
|
fprintf(fp, "oidlabel");
|
||||||
|
print_sysctl_oid(fp, oid + 2, len - 2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
print_sysctl_oid(fp, oid + 1, len - 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qoid[0] = CTL_SYSCTL;
|
||||||
|
qoid[1] = CTL_SYSCTL_NAME;
|
||||||
|
memcpy(qoid + 2, oid, len * sizeof(int));
|
||||||
|
i = sizeof(name);
|
||||||
|
if (sysctl(qoid, len + 2, name, &i, 0, 0) == -1)
|
||||||
|
print_sysctl_oid(fp, qoid + 2, len);
|
||||||
|
else
|
||||||
|
fprintf(fp, "%s", name);
|
||||||
|
}
|
||||||
|
fprintf(fp, "\"");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case PipeFds:
|
case PipeFds:
|
||||||
/*
|
/*
|
||||||
* The pipe() system call in the kernel returns its
|
* The pipe() system call in the kernel returns its
|
||||||
|
Loading…
Reference in New Issue
Block a user