]> granicus.if.org Git - strace/commitdiff
util: add getarg_ll and getarg_ull functions
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 21 Sep 2016 21:21:27 +0000 (00:21 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 28 Sep 2016 03:00:10 +0000 (03:00 +0000)
These allow retrieving specific argument in full taking into account
peculiarities of runtimes which employ tcp->ext_arg (e.g. x32).

* defs.h (getarg_ll, getarg_ull): New prototypes.
* util.c (getarg_ll, getarg_ull): New functions.
(printargs): Use getarg_ull.

defs.h
util.c

diff --git a/defs.h b/defs.h
index 4c7a0637b628e5f18b97e4d6bdf73d0b826784e6..d447eb1e39e1f7b42890aa413d05dab646106628 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -542,6 +542,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 long long getarg_ll(struct tcb *tcp, int argn);
+extern unsigned long long getarg_ull(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 056711d107c66f96503c49e501b9f24940c58182..0dbe20c92ae42a3806b50240811f27c5869b93b9 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1413,24 +1413,44 @@ print_array(struct tcb *tcp,
        return cur >= end_addr;
 }
 
-int
-printargs(struct tcb *tcp)
+long long
+getarg_ll(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 (long) tcp->u_arg[argn];
+       else
 # endif
-                       tprintf("%s%#llx", i ? ", " : "", tcp->ext_arg[i]);
+       return (long long) tcp->ext_arg[argn];
 #else
-                       tprintf("%s%#lx", i ? ", " : "", tcp->u_arg[i]);
+       return (long) tcp->u_arg[argn];
 #endif
-               }
+}
+
+unsigned long long
+getarg_ull(struct tcb *tcp, int argn)
+{
+#if HAVE_STRUCT_TCB_EXT_ARG
+# if SUPPORTED_PERSONALITIES > 1
+       if (current_personality == 1)
+               return (unsigned long) tcp->u_arg[argn];
+       else
+# endif
+       return (unsigned long long) tcp->ext_arg[argn];
+#else
+       return (unsigned 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;
 }