summaryrefslogtreecommitdiffstats
path: root/usr.bin/truss
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2015-10-01 17:50:41 +0000
committerjhb <jhb@FreeBSD.org>2015-10-01 17:50:41 +0000
commit2d7dbe7a28c08589e8614c6cf205ff1ac6e5d115 (patch)
tree5cb6c8163ead23d65741982ae4ba2a93363c540f /usr.bin/truss
parentc57d8fb993f96281d9407b5b272bb6b0b9159dc7 (diff)
downloadFreeBSD-src-2d7dbe7a28c08589e8614c6cf205ff1ac6e5d115.zip
FreeBSD-src-2d7dbe7a28c08589e8614c6cf205ff1ac6e5d115.tar.gz
The id_t type used to pass IDs to wait6(2) and procctl(6) is a 64-bit
integer. Fix the argument decoding to treat this as a quad instead of an int. This includes using QUAD_ALIGN and QUAD_SLOTS as necessary. To continue printing IDs in decimal, add a new QuadHex argument type that prints a 64-bit integer in hex, use QuadHex for the existing off_t arguments, repurpose Quad to print a 64-bit integer in decimal, and use Quad for id_t arguments. This fixes the decoding of wait6(2) and procctl(2) on 32-bit platforms.
Diffstat (limited to 'usr.bin/truss')
-rw-r--r--usr.bin/truss/syscall.h2
-rw-r--r--usr.bin/truss/syscalls.c30
2 files changed, 22 insertions, 10 deletions
diff --git a/usr.bin/truss/syscall.h b/usr.bin/truss/syscall.h
index 63b2299..ee35214 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, ExecArgs, ExecEnv, PipeFds };
+ Sysarch, ExecArgs, ExecEnv, PipeFds, QuadHex };
#define ARG_MASK 0xff
#define OUT 0x100
diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c
index 187f40d..02ae868 100644
--- a/usr.bin/truss/syscalls.c
+++ b/usr.bin/truss/syscalls.c
@@ -106,13 +106,13 @@ static struct syscall syscalls[] = {
.args = { { Atfd, 0 }, { Name, 1 }, { Readlinkres | OUT, 2 },
{ Int, 3 } } },
{ .name = "lseek", .ret_type = 2, .nargs = 3,
- .args = { { Int, 0 }, { Quad, 1 + QUAD_ALIGN },
+ .args = { { Int, 0 }, { QuadHex, 1 + QUAD_ALIGN },
{ Whence, 1 + QUAD_SLOTS + QUAD_ALIGN } } },
{ .name = "linux_lseek", .ret_type = 2, .nargs = 3,
.args = { { Int, 0 }, { Int, 1 }, { Whence, 2 } } },
{ .name = "mmap", .ret_type = 1, .nargs = 6,
.args = { { Ptr, 0 }, { Int, 1 }, { Mprot, 2 }, { Mmapflags, 3 },
- { Int, 4 }, { Quad, 5 + QUAD_ALIGN } } },
+ { Int, 4 }, { QuadHex, 5 + QUAD_ALIGN } } },
{ .name = "linux_mkdir", .ret_type = 1, .nargs = 2,
.args = { { Name | IN, 0 }, { Int, 1 } } },
{ .name = "mprotect", .ret_type = 1, .nargs = 3,
@@ -321,9 +321,9 @@ static struct syscall syscalls[] = {
{ .name = "pipe2", .ret_type = 1, .nargs = 2,
.args = { { Ptr, 0 }, { Open, 1 } } },
{ .name = "truncate", .ret_type = 1, .nargs = 2,
- .args = { { Name | IN, 0 }, { Quad | IN, 1 + QUAD_ALIGN } } },
+ .args = { { Name | IN, 0 }, { QuadHex | IN, 1 + QUAD_ALIGN } } },
{ .name = "ftruncate", .ret_type = 1, .nargs = 2,
- .args = { { Int | IN, 0 }, { Quad | IN, 1 + QUAD_ALIGN } } },
+ .args = { { Int | IN, 0 }, { QuadHex | IN, 1 + QUAD_ALIGN } } },
{ .name = "kill", .ret_type = 1, .nargs = 2,
.args = { { Int | IN, 0 }, { Signal | IN, 1 } } },
{ .name = "munmap", .ret_type = 1, .nargs = 2,
@@ -344,10 +344,15 @@ static struct syscall syscalls[] = {
.args = { { Int, 0 }, { ExitStatus | OUT, 1 }, { Waitoptions, 2 },
{ Rusage | OUT, 3 } } },
{ .name = "wait6", .ret_type = 1, .nargs = 6,
- .args = { { Idtype, 0 }, { Int, 1 }, { ExitStatus | OUT, 2 },
- { Waitoptions, 3 }, { Rusage | OUT, 4 }, { Ptr, 5 } } },
+ .args = { { Idtype, 0 }, { Quad, 1 + QUAD_ALIGN },
+ { ExitStatus | OUT, 1 + QUAD_ALIGN + QUAD_SLOTS },
+ { Waitoptions, 2 + QUAD_ALIGN + QUAD_SLOTS },
+ { Rusage | OUT, 3 + QUAD_ALIGN + QUAD_SLOTS },
+ { Ptr, 4 + QUAD_ALIGN + QUAD_SLOTS } } },
{ .name = "procctl", .ret_type = 1, .nargs = 4,
- .args = { { Idtype, 0 }, { Int, 1 }, { Procctl, 2 }, { Ptr, 3 } } },
+ .args = { { Idtype, 0 }, { Quad, 1 + QUAD_ALIGN },
+ { Procctl, 1 + QUAD_ALIGN + QUAD_SLOTS },
+ { Ptr, 2 + QUAD_ALIGN + QUAD_SLOTS } } },
{ .name = "sysarch", .ret_type = 1, .nargs = 2,
.args = { { Sysarch, 0 }, { Ptr, 1 } } },
{ .name = "_umtx_op", .ret_type = 1, .nargs = 5,
@@ -966,10 +971,14 @@ print_arg(struct syscall_args *sc, unsigned long *args, long *retval,
}
#ifdef __LP64__
case Quad:
+ fprintf(fp, "%ld", args[sc->offset]);
+ break;
+ case QuadHex:
fprintf(fp, "0x%lx", args[sc->offset]);
break;
#else
- case Quad: {
+ case Quad:
+ case QuadHex: {
unsigned long long ll;
#if _BYTE_ORDER == _LITTLE_ENDIAN
@@ -979,7 +988,10 @@ print_arg(struct syscall_args *sc, unsigned long *args, long *retval,
ll = (unsigned long long)args[sc->offset] << 32 |
args[sc->offset + 1];
#endif
- fprintf(fp, "0x%llx", ll);
+ if ((sc->type & ARG_MASK) == Quad)
+ fprintf(fp, "%lld", ll);
+ else
+ fprintf(fp, "0x%llx", ll);
break;
}
#endif
OpenPOWER on IntegriCloud