[PATCH 07/11] util: Add getarg_ull/getarg_ll functions
Eugene Syromyatnikov
evgsyr at gmail.com
Wed Sep 21 21:21:27 UTC 2016
These allow retrieving specific argument in full taking into account
peculiarities of runtimes which employ EXT_ARG (x32, for example).
* defs.h: Add declarations of getarg_ull, getarg_ll.
* util.c (getarg_ull): New function.
(getarg_ll): Likewise.
(printargs): Use getarg_ull for argument retrieval.
---
defs.h | 2 ++
util.c | 44 ++++++++++++++++++++++++++++++++------------
2 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/defs.h b/defs.h
index 26dbf8e..593e316 100644
--- a/defs.h
+++ b/defs.h
@@ -546,6 +546,8 @@ extern int printllval(struct tcb *, const char *, int)
extern void printaddr(long);
extern void printxvals(const uint64_t, const char *, const struct xlat *, ...)
ATTRIBUTE_SENTINEL;
+extern unsigned long long getarg_ull(struct tcb *tcp, int argn);
+extern long long getarg_ll(struct tcb *tcp, int argn);
extern int printargs(struct tcb *);
extern int printargs_u(struct tcb *);
extern int printargs_d(struct tcb *);
diff --git a/util.c b/util.c
index 056711d..b17ab29 100644
--- a/util.c
+++ b/util.c
@@ -1413,24 +1413,44 @@ print_array(struct tcb *tcp,
return cur >= end_addr;
}
-int
-printargs(struct tcb *tcp)
+unsigned long long
+getarg_ull(struct tcb *tcp, int argn)
{
- if (entering(tcp)) {
- int i;
- int n = tcp->s_ent->nargs;
- for (i = 0; i < n; i++) {
#if HAVE_STRUCT_TCB_EXT_ARG
# if SUPPORTED_PERSONALITIES > 1
- if (current_personality == 1)
- tprintf("%s%#lx", i ? ", " : "", tcp->u_arg[i]);
- else
+ if (current_personality == 1)
+ return (unsigned long) tcp->u_arg[argn];
+ else
# endif
- tprintf("%s%#llx", i ? ", " : "", tcp->ext_arg[i]);
+ return (unsigned long long) tcp->ext_arg[argn];
#else
- tprintf("%s%#lx", i ? ", " : "", tcp->u_arg[i]);
+ return (unsigned long) tcp->u_arg[argn];
#endif
- }
+}
+
+long long
+getarg_ll(struct tcb *tcp, int argn)
+{
+#if HAVE_STRUCT_TCB_EXT_ARG
+# if SUPPORTED_PERSONALITIES > 1
+ if (current_personality == 1)
+ return (long) tcp->u_arg[argn];
+ else
+# endif
+ return (long long) tcp->ext_arg[argn];
+#else
+ return (long) tcp->u_arg[argn];
+#endif
+}
+
+int
+printargs(struct tcb *tcp)
+{
+ if (entering(tcp)) {
+ int i;
+ int n = tcp->s_ent->nargs;
+ for (i = 0; i < n; i++)
+ tprintf("%s%#llx", i ? ", " : "", getarg_ull(tcp, i));
}
return 0;
}
--
1.7.10.4
More information about the Strace-devel
mailing list