[PATCH v3] Decode paths associated with file descriptors returned by syscalls
zubin.mithra at gmail.com
zubin.mithra at gmail.com
Tue Jun 3 15:38:23 UTC 2014
From: Zubin Mithra <zubin.mithra at gmail.com>
* defs.h (RVAL_FD): New macro.
* defs.h (RVAL_MASK, RVAL_STR, RVAL_NONE): Macro values modified.
* desc.c (sys_dup): New function.
* desc.c (sys_delete_module): New function.
* desc.c (do_dup2, sys_open): Modified to return RVAL_FD.
* linux/dummy.h (sys_delete_module, sys_dup): Macros removed.
* linux/syscall.h (sys_close, sys_delete_module, sys_dup): New
prototype.
* syscall.c (trace_syscall_exiting): Modified to handle RVAL_FD
return value.
Signed-off-by: Zubin Mithra <zubin.mithra at gmail.com>
---
defs.h | 7 ++++---
desc.c | 11 ++++++++++-
file.c | 8 +++++++-
linux/dummy.h | 2 --
linux/syscall.h | 2 ++
syscall.c | 8 ++++++++
6 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/defs.h b/defs.h
index c862de5..99493b3 100644
--- a/defs.h
+++ b/defs.h
@@ -533,10 +533,11 @@ extern const struct xlat whence_codes[];
# endif
# define RVAL_LUDECIMAL 007 /* long unsigned decimal format */
#endif
-#define RVAL_MASK 007 /* mask for these values */
+#define RVAL_FD 010 /* file descriptors */
+#define RVAL_MASK 017 /* mask for these values */
-#define RVAL_STR 010 /* Print `auxstr' field after return val */
-#define RVAL_NONE 020 /* Print nothing */
+#define RVAL_STR 020 /* Print `auxstr' field after return val */
+#define RVAL_NONE 040 /* Print nothing */
#define TRACE_FILE 001 /* Trace file-related syscalls. */
#define TRACE_IPC 002 /* Trace IPC-related syscalls. */
diff --git a/desc.c b/desc.c
index 0c9a817..5b8869b 100644
--- a/desc.c
+++ b/desc.c
@@ -265,6 +265,15 @@ sys_close(struct tcb *tcp)
return 0;
}
+int
+sys_dup(struct tcb *tcp)
+{
+ if (entering(tcp)) {
+ printfd(tcp, tcp->u_arg[0]);
+ }
+ return RVAL_FD;
+}
+
static int
do_dup2(struct tcb *tcp, int flags_arg)
{
@@ -277,7 +286,7 @@ do_dup2(struct tcb *tcp, int flags_arg)
printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
}
}
- return 0;
+ return RVAL_FD;
}
int
diff --git a/file.c b/file.c
index c322242..92a5873 100644
--- a/file.c
+++ b/file.c
@@ -309,6 +309,12 @@ decode_open(struct tcb *tcp, int offset)
int
sys_open(struct tcb *tcp)
{
+ decode_open(tcp, 0);
+ return RVAL_FD;
+}
+
+int sys_delete_module(struct tcb *tcp)
+{
return decode_open(tcp, 0);
}
@@ -348,7 +354,7 @@ sys_creat(struct tcb *tcp)
printpath(tcp, tcp->u_arg[0]);
tprintf(", %#lo", tcp->u_arg[1]);
}
- return 0;
+ return RVAL_FD;
}
#include "xlat/access_flags.h"
diff --git a/linux/dummy.h b/linux/dummy.h
index 4f3e920..6068666 100644
--- a/linux/dummy.h
+++ b/linux/dummy.h
@@ -57,8 +57,6 @@
#define sys_acct sys_chdir
#define sys_chroot sys_chdir
#define sys_clock_getres sys_clock_gettime
-#define sys_delete_module sys_open
-#define sys_dup sys_close
#define sys_fchdir sys_close
#define sys_fdatasync sys_close
#define sys_fsync sys_close
diff --git a/linux/syscall.h b/linux/syscall.h
index 1943297..38aa4bd 100644
--- a/linux/syscall.h
+++ b/linux/syscall.h
@@ -52,6 +52,8 @@ int sys_close();
int sys_connect();
int sys_creat();
int sys_create_module();
+int sys_delete_module();
+int sys_dup();
int sys_dup2();
int sys_dup3();
int sys_epoll_create();
diff --git a/syscall.c b/syscall.c
index c95eb6c..b0ad47e 100644
--- a/syscall.c
+++ b/syscall.c
@@ -2688,6 +2688,14 @@ trace_syscall_exiting(struct tcb *tcp)
case RVAL_DECIMAL:
tprintf("= %ld", tcp->u_rval);
break;
+ case RVAL_FD:
+ if (show_fd_path) {
+ tprints("= ");
+ printfd(tcp, tcp->u_rval);
+ }
+ else
+ tprintf("= %ld", tcp->u_rval);
+ break;
#if defined(LINUX_MIPSN32) || defined(X32)
/*
case RVAL_LHEX:
--
1.8.4
More information about the Strace-devel
mailing list