Permalink
Browse files

Fix decoding of file descriptors

* defs.h (printfd): New function prototype.
* util.c (printfd): New function.
* file.c (print_dirfd): Update prototype to use printfd().
(sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat,
sys_unlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat,
sys_futimesat, sys_utimensat, sys_mknodat): Update use of print_dirfd().
(sys_lseek, sys_llseek, sys_readahead, sys_ftruncate, sys_ftruncate64,
sys_fstat, sys_fstat64, sys_oldfstat, sys_fstatfs, sys_fstatfs64,
sys_fchdir, sys_fchroot, sys_linkat, sys_fchown, sys_fchmod, sys_fsync,
sys_readdir, sys_getdents, sys_getdirentries, sys_fsetxattr,
sys_fgetxattr, sys_flistxattr, sys_fremovexattr, sys_fadvise64,
sys_fadvise64_64, sys_inotify_add_watch, sys_inotify_rm_watch,
sys_fallocate): Use printfd() for decoding of file descriptors.
* desc.c (sys_fcntl, sys_flock, sys_close, sys_dup, do_dup2,
decode_select, sys_epoll_ctl, epoll_wait_common): Use printfd() for
decoding of file descriptors.
* io.c (sys_read, sys_write, sys_readv, sys_writev, sys_pread,
sys_pwrite, sys_sendfile, sys_sendfile64, sys_pread64, sys_pwrite64,
sys_ioctl): Likewise.
* mem.c (print_mmap, sys_mmap64): Likewise.
* signal.c (do_signalfd): Likewise.
* stream.c (decode_poll): Likewise.
* time.c (sys_timerfd_settime, sys_timerfd_gettime): Likewise.
Based on patch from Grant Edwards <grant.b.edwards@gmail.com>.
  • Loading branch information...
1 parent 9cd3850 commit 3138213bc9a827a372ad9f8009ebcc5d8797ce2d @ldv-alt ldv-alt committed Mar 4, 2011
Showing with 182 additions and 130 deletions.
  1. +1 −0 defs.h
  2. +20 −11 desc.c
  3. +89 −60 file.c
  4. +48 −42 io.c
  5. +10 −13 mem.c
  6. +2 −1 signal.c
  7. +3 −1 stream.c
  8. +3 −2 time.c
  9. +6 −0 util.c
View
1 defs.h
@@ -550,6 +550,7 @@ extern void sprint_timespec(char *, struct tcb *, long);
#ifdef HAVE_SIGINFO_T
extern void printsiginfo(siginfo_t *, int);
#endif
+extern void printfd(struct tcb *, int);
extern void printsock(struct tcb *, long, int);
extern void print_sock_optmgmt(struct tcb *, long, int);
extern void printrusage(struct tcb *, long);
View
31 desc.c
@@ -309,7 +309,8 @@ int
sys_fcntl(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
printxval(fcntlcmds, tcp->u_arg[1], "F_???");
switch (tcp->u_arg[1]) {
case F_SETFD:
@@ -422,7 +423,8 @@ int
sys_flock(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
printflags(flockcmds, tcp->u_arg[1], "LOCK_???");
}
return 0;
@@ -433,7 +435,7 @@ int
sys_close(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
}
return 0;
}
@@ -442,7 +444,7 @@ int
sys_dup(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
}
return 0;
}
@@ -451,7 +453,9 @@ static int
do_dup2(struct tcb *tcp, int flags_arg)
{
if (entering(tcp)) {
- tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
+ printfd(tcp, tcp->u_arg[1]);
if (flags_arg >= 0) {
tprintf(", ");
printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
@@ -516,7 +520,8 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
tprintf(", [");
for (j = 0, sep = ""; j < nfds; j++) {
if (FD_ISSET(j, fds)) {
- tprintf("%s%u", sep, j);
+ tprintf("%s", sep);
+ printfd(tcp, j);
sep = " ";
}
}
@@ -703,9 +708,12 @@ int
sys_epoll_ctl(struct tcb *tcp)
{
if (entering(tcp)) {
- tprintf("%ld, ", tcp->u_arg[0]);
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
printxval(epollctls, tcp->u_arg[1], "EPOLL_CTL_???");
- tprintf(", %ld, ", tcp->u_arg[2]);
+ tprintf(", ");
+ printfd(tcp, tcp->u_arg[2]);
+ tprintf(", ");
if (tcp->u_arg[3] == 0)
tprintf("NULL");
else {
@@ -724,9 +732,10 @@ sys_epoll_ctl(struct tcb *tcp)
static void
epoll_wait_common(struct tcb *tcp)
{
- if (entering(tcp))
- tprintf("%ld, ", tcp->u_arg[0]);
- else {
+ if (entering(tcp)) {
+ printfd(tcp, tcp->u_arg[0]);
+ tprintf(", ");
+ } else {
if (syserror(tcp))
tprintf("%lx", tcp->u_arg[1]);
else if (tcp->u_rval == 0)
Oops, something went wrong.

0 comments on commit 3138213

Please sign in to comment.