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@NTLWorld.COM>
This commit is contained in:
John Baldwin 2017-06-05 05:25:50 +00:00
parent c8fab231f1
commit b60a095b93
2 changed files with 24 additions and 1 deletions

View File

@ -48,7 +48,7 @@ enum Argtype { None = 1, Hex, Octal, Int, UInt, LongHex, Name, Ptr, Stat, Ioctl,
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,

View File

@ -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, long *retval,
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;