aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/truss
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2015-08-20 14:51:11 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2015-08-20 14:51:11 +0000
commit68055893c1b120a93db70578dc013fb2dd2b8c9f (patch)
tree896e831b4318d4d968b07de02aaeb1b08498d600 /usr.bin/truss
parent890843c15b84b40f8e6fdce6a7e07a087f66418c (diff)
Notes
Diffstat (limited to 'usr.bin/truss')
-rw-r--r--usr.bin/truss/amd64-fbsd.c22
-rw-r--r--usr.bin/truss/amd64-fbsd32.c22
-rw-r--r--usr.bin/truss/amd64-linux32.c22
-rw-r--r--usr.bin/truss/arm-fbsd.c22
-rw-r--r--usr.bin/truss/i386-fbsd.c22
-rw-r--r--usr.bin/truss/i386-linux.c22
-rw-r--r--usr.bin/truss/mips-fbsd.c22
-rw-r--r--usr.bin/truss/powerpc-fbsd.c22
-rw-r--r--usr.bin/truss/powerpc64-fbsd.c22
-rw-r--r--usr.bin/truss/sparc64-fbsd.c22
-rw-r--r--usr.bin/truss/syscall.h2
-rw-r--r--usr.bin/truss/syscalls.c22
12 files changed, 19 insertions, 225 deletions
diff --git a/usr.bin/truss/amd64-fbsd.c b/usr.bin/truss/amd64-fbsd.c
index 4a70a83976a0..eeea8db96205 100644
--- a/usr.bin/truss/amd64-fbsd.c
+++ b/usr.bin/truss/amd64-fbsd.c
@@ -233,28 +233,6 @@ amd64_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/amd64-fbsd32.c b/usr.bin/truss/amd64-fbsd32.c
index 9b827f1061a8..40aa152f81cc 100644
--- a/usr.bin/truss/amd64-fbsd32.c
+++ b/usr.bin/truss/amd64-fbsd32.c
@@ -233,28 +233,6 @@ amd64_fbsd32_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "freebsd32_execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "freebsd32_execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/amd64-linux32.c b/usr.bin/truss/amd64-linux32.c
index 77cacdbe6a69..b2d0d040406f 100644
--- a/usr.bin/truss/amd64-linux32.c
+++ b/usr.bin/truss/amd64-linux32.c
@@ -206,28 +206,6 @@ amd64_linux32_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "linux_execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "linux_execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/arm-fbsd.c b/usr.bin/truss/arm-fbsd.c
index 9de616257775..8dc4d5bef414 100644
--- a/usr.bin/truss/arm-fbsd.c
+++ b/usr.bin/truss/arm-fbsd.c
@@ -264,28 +264,6 @@ arm_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/i386-fbsd.c b/usr.bin/truss/i386-fbsd.c
index ec6b8d6008ce..ef326f02020f 100644
--- a/usr.bin/truss/i386-fbsd.c
+++ b/usr.bin/truss/i386-fbsd.c
@@ -227,28 +227,6 @@ i386_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/i386-linux.c b/usr.bin/truss/i386-linux.c
index 2dd672e470ee..6bd930955177 100644
--- a/usr.bin/truss/i386-linux.c
+++ b/usr.bin/truss/i386-linux.c
@@ -206,28 +206,6 @@ i386_linux_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "linux_execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "linux_execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/mips-fbsd.c b/usr.bin/truss/mips-fbsd.c
index 7d064ba248cd..d45241ac3be9 100644
--- a/usr.bin/truss/mips-fbsd.c
+++ b/usr.bin/truss/mips-fbsd.c
@@ -261,28 +261,6 @@ mips_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/powerpc-fbsd.c b/usr.bin/truss/powerpc-fbsd.c
index 2bfaf450890b..cdbd1331f47b 100644
--- a/usr.bin/truss/powerpc-fbsd.c
+++ b/usr.bin/truss/powerpc-fbsd.c
@@ -238,28 +238,6 @@ powerpc_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/powerpc64-fbsd.c b/usr.bin/truss/powerpc64-fbsd.c
index f02e04dc8e2c..1f50429515a9 100644
--- a/usr.bin/truss/powerpc64-fbsd.c
+++ b/usr.bin/truss/powerpc64-fbsd.c
@@ -226,28 +226,6 @@ powerpc64_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/sparc64-fbsd.c b/usr.bin/truss/sparc64-fbsd.c
index a5e927668bbd..4e64c7027112 100644
--- a/usr.bin/truss/sparc64-fbsd.c
+++ b/usr.bin/truss/sparc64-fbsd.c
@@ -255,28 +255,6 @@ sparc64_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/syscall.h b/usr.bin/truss/syscall.h
index db79fef6ec78..6f4d9a3807ea 100644
--- a/usr.bin/truss/syscall.h
+++ b/usr.bin/truss/syscall.h
@@ -42,7 +42,7 @@ enum Argtype { None = 1, Hex, Octal, Int, LongHex, Name, Ptr, Stat, Ioctl, Quad,
Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2,
Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl,
LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long,
- Sysarch };
+ Sysarch, ExecArgs, ExecEnv };
#define ARG_MASK 0xff
#define OUT 0x100
diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c
index 91769fb4c91a..fac47f4568a7 100644
--- a/usr.bin/truss/syscalls.c
+++ b/usr.bin/truss/syscalls.c
@@ -245,11 +245,11 @@ static struct syscall syscalls[] = {
.args = { { Int, 0 }, { BinString | IN, 1 }, { Int, 2 }, { Hex, 3 },
{ Sockaddr | IN, 4 }, { Ptr | IN, 5 } } },
{ .name = "execve", .ret_type = 1, .nargs = 3,
- .args = { { Name | IN, 0 }, { StringArray | IN, 1 },
- { StringArray | IN, 2 } } },
+ .args = { { Name | IN, 0 }, { ExecArgs | IN, 1 },
+ { ExecEnv | IN, 2 } } },
{ .name = "linux_execve", .ret_type = 1, .nargs = 3,
- .args = { { Name | IN, 0 }, { StringArray | IN, 1 },
- { StringArray | IN, 2 } } },
+ .args = { { Name | IN, 0 }, { ExecArgs | IN, 1 },
+ { ExecEnv | IN, 2 } } },
{ .name = "kldload", .ret_type = 0, .nargs = 1,
.args = { { Name | IN, 0 } } },
{ .name = "kldunload", .ret_type = 0, .nargs = 1,
@@ -912,6 +912,8 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
}
break;
}
+ case ExecArgs:
+ case ExecEnv:
case StringArray: {
uintptr_t addr;
union {
@@ -923,6 +925,18 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
int first, i;
/*
+ * Only parse argv[] and environment arrays from exec calls
+ * if requested.
+ */
+ if (((sc->type & ARG_MASK) == ExecArgs &&
+ (trussinfo->flags & EXECVEARGS) == 0) ||
+ ((sc->type & ARG_MASK) == ExecEnv &&
+ (trussinfo->flags & EXECVEENVS) == 0)) {
+ fprintf(fp, "0x%lx", args[sc->offset]);
+ break;
+ }
+
+ /*
* Read a page of pointers at a time. Punt if the top-level
* pointer is not aligned. Note that the first read is of
* a partial page.