svn commit: r319595 - head/usr.bin/truss

John Baldwin jhb at FreeBSD.org
Mon Jun 5 05:25:51 UTC 2017


Author: jhb
Date: Mon Jun  5 05:25:50 2017
New Revision: 319595
URL: https://svnweb.freebsd.org/changeset/base/319595

Log:
  Decode arguments to dup, dup2, getdirentries, pread, and pwrite.
  
  - dup and dup2 print fd arguments in decimal.
  - pread and pwrite are similar to read and write with the addition of the
    file offset.
  - getdirentries displays the output entries as a string for now and also
    prints the value returned in *basep.  Eventually the buffer for
    getdirentries should perhaps be decoded as an array of dirent
    structures.
  
  PR:		214885
  Submitted by:	Jonathan de Boyne Pollard <J.deBoynePollard-newsgroups at NTLWorld.COM>

Modified:
  head/usr.bin/truss/syscall.h
  head/usr.bin/truss/syscalls.c

Modified: head/usr.bin/truss/syscall.h
==============================================================================
--- head/usr.bin/truss/syscall.h	Mon Jun  5 05:17:42 2017	(r319594)
+++ head/usr.bin/truss/syscall.h	Mon Jun  5 05:25:50 2017	(r319595)
@@ -48,7 +48,7 @@ enum Argtype { None = 1, Hex, Octal, Int, UInt, LongHe
 	Sysarch, ExecArgs, ExecEnv, PipeFds, QuadHex, Utrace, IntArray, Pipe2,
 	CapFcntlRights, Fadvice, FileFlags, Flockop, Getfsstatmode, Kldsymcmd,
 	Kldunloadflags, Sizet, Madvice, Socklent, Sockprotocol, Sockoptlevel,
-	Sockoptname, Msgflags, CapRights, PUInt,
+	Sockoptname, Msgflags, CapRights, PUInt, PQuadHex,
 
 	CloudABIAdvice, CloudABIClockID, ClouduABIFDSFlags,
 	CloudABIFDStat, CloudABIFileStat, CloudABIFileType,

Modified: head/usr.bin/truss/syscalls.c
==============================================================================
--- head/usr.bin/truss/syscalls.c	Mon Jun  5 05:17:42 2017	(r319594)
+++ head/usr.bin/truss/syscalls.c	Mon Jun  5 05:25:50 2017	(r319595)
@@ -125,6 +125,10 @@ static struct syscall decoded_syscalls[] = {
 	{ .name = "connectat", .ret_type = 1, .nargs = 4,
 	  .args = { { Atfd, 0 }, { Int, 1 }, { Sockaddr | IN, 2 },
 		    { Int, 3 } } },
+	{ .name = "dup", .ret_type = 1, .nargs = 1,
+	  .args = { { Int, 0 } } },
+	{ .name = "dup2", .ret_type = 1, .nargs = 2,
+	  .args = { { Int, 0 }, { Int, 1 } } },
 	{ .name = "eaccess", .ret_type = 1, .nargs = 2,
 	  .args = { { Name | IN, 0 }, { Accessmode, 1 } } },
 	{ .name = "execve", .ret_type = 1, .nargs = 3,
@@ -165,6 +169,9 @@ static struct syscall decoded_syscalls[] = {
 	  .args = { { Int, 0 }, { Timeval2 | IN, 1 } } },
 	{ .name = "futimesat", .ret_type = 1, .nargs = 3,
 	  .args = { { Atfd, 0 }, { Name | IN, 1 }, { Timeval2 | IN, 2 } } },
+	{ .name = "getdirentries", .ret_type = 1, .nargs = 4,
+	  .args = { { Int, 0 }, { BinString | OUT, 1 }, { Int, 2 },
+		    { PQuadHex | OUT, 3 } } },
 	{ .name = "getfsstat", .ret_type = 1, .nargs = 3,
 	  .args = { { Ptr, 0 }, { Long, 1 }, { Getfsstatmode, 2 } } },
 	{ .name = "getitimer", .ret_type = 1, .nargs = 2,
@@ -275,8 +282,14 @@ static struct syscall decoded_syscalls[] = {
 		    { Fadvice, 3 } } },
 	{ .name = "posix_openpt", .ret_type = 1, .nargs = 1,
 	  .args = { { Open, 0 } } },
+	{ .name = "pread", .ret_type = 1, .nargs = 4,
+	  .args = { { Int, 0 }, { BinString | OUT, 1 }, { Sizet, 2 },
+		    { QuadHex, 3 } } },
 	{ .name = "procctl", .ret_type = 1, .nargs = 4,
 	  .args = { { Idtype, 0 }, { Quad, 1 }, { Procctl, 2 }, { Ptr, 3 } } },
+	{ .name = "pwrite", .ret_type = 1, .nargs = 4,
+	  .args = { { Int, 0 }, { BinString | IN, 1 }, { Sizet, 2 },
+		    { QuadHex, 3 } } },
 	{ .name = "read", .ret_type = 1, .nargs = 3,
 	  .args = { { Int, 0 }, { BinString | OUT, 1 }, { Sizet, 2 } } },
 	{ .name = "readlink", .ret_type = 1, .nargs = 3,
@@ -1354,6 +1367,16 @@ print_arg(struct syscall_args *sc, unsigned long *args
 		break;
 	}
 #endif
+	case PQuadHex: {
+		uint64_t val;
+
+		if (get_struct(pid, (void *)args[sc->offset], &val,
+		    sizeof(val)) == 0) 
+			fprintf(fp, "{ 0x%jx }", (uintmax_t)val);
+		else
+			fprintf(fp, "0x%lx", args[sc->offset]);
+		break;
+	}
 	case Ptr:
 		fprintf(fp, "0x%lx", args[sc->offset]);
 		break;


More information about the svn-src-head mailing list