]> granicus.if.org Git - strace/commitdiff
Simplify use of mpers printers
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 15 Sep 2015 21:51:15 +0000 (21:51 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 16 Sep 2015 00:14:55 +0000 (00:14 +0000)
* native_defs.h: New file.
* syscall.c: Include it.
* mpers_type.h [!IN_MPERS] (MPERS_DEFS): Change to "native_defs.h".
* defs.h (MPERS_PRINTER_NAME): Remove.
[SUPPORTED_PERSONALITIES > 1] (MPERS_PRINTER_NAME, printers): Move ...
* Makefile.am (printers.h): ... here.
Add macro definitions for mpers printers.
(m%_defs.h): Add redefinition of MPERS_PRINTER_NAME and inclusion
of "$(mpers_PREFIX)printer_decls.h".
(strace_SOURCES): Add native_defs.h.
* README-mpers: Update instructions for using mpers printers.
* ipc_msg.c (tprint_msgsnd, tprint_msgrcv): Call tprint_msgbuf directly.
* mq.c (sys_mq_open, mq_getsetattr): Call printmqattr directly.
* process.c (sys_ptrace): Call printsiginfo_at directly.
* signal.c (print_sigqueueinfo, sys_rt_sigtimedwait): Likewise.
* resource.c (sys_getrusage): Call printrusage directly.
* utimes.c (sys_utimensat): Call print_timespec_utime_pair directly.
(sys_utimes, sys_futimesat): Call print_timeval_pair directly.
* wait.c (printwaitn): Call printrusage directly.
(sys_waitid): Call printrusage and printsiginfo_at directly.

13 files changed:
Makefile.am
README-mpers
defs.h
ipc_msg.c
mpers_type.h
mq.c
native_defs.h [new file with mode: 0644]
process.c
resource.c
signal.c
syscall.c
utimes.c
wait.c

index 9e19b353723b9fcdfd06d1df2fc1d8ae599227e7..29d8fa766ba08427c3fd734175b7a311bcf364dc 100644 (file)
@@ -87,8 +87,9 @@ strace_SOURCES =      \
        mknod.c         \
        mount.c         \
        mpers_type.h    \
-       mq.c    \
+       mq.c            \
        mtd.c           \
+       native_defs.h   \
        net.c           \
        open.c          \
        or1k_atomic.c   \
@@ -686,6 +687,9 @@ m%_defs.h: $(srcdir_mpers_source_files)
        for f in $^; do \
                sed -n 's/^#include DEF_MPERS_TYPE(\([^)]\+\))/#ifdef MPERS_$(mpers_PREFIX)\1\n# define \1 MPERS_$(mpers_PREFIX)\1\n#endif/p' $$f || exit; \
        done > $@-t
+       echo '#undef MPERS_PRINTER_NAME' >> $@-t
+       echo '#define MPERS_PRINTER_NAME(printer_name) printer_name' >> $@-t
+       echo '#include "$(mpers_PREFIX)printer_decls.h"' >> $@-t
        mv $@-t $@
 
 m%_funcs.h: $(srcdir_mpers_source_files)
@@ -701,9 +705,11 @@ printers.h: $(srcdir_mpers_source_files)
        echo '/* Generated by Makefile from $^; do not edit. */' > $@-t
        echo 'typedef struct {' >> $@-t
        for f in $^; do \
-               sed -n 's/^MPERS_PRINTER_DECL(\([^,]\+\),[[:space:]]*\([^)]\+\))\(.*\)/ \1 (*\2) \3;/p' $$f || exit; \
+               sed -n 's/^MPERS_PRINTER_DECL(\([^,]\+\),[[:space:]]*\([^)]\+\))\(.*\)/ \1 (*\2) \3;\n#define \2 MPERS_PRINTER_NAME(\2)\n/p' $$f || exit; \
        done >> $@-t
        echo '} struct_printers;' >> $@-t
+       echo 'extern const struct_printers *printers;' >> $@-t
+       echo '#define MPERS_PRINTER_NAME(printer_name) printers->printer_name' >> $@-t
        mv $@-t $@
 
 %_printer_decls.h: $(srcdir_mpers_source_files)
index 725a2b6e27327bf988e25d6daf3800f5d65813d8..8ae418dff4f24d98f411ebe5dbc7044c841a9600 100644 (file)
@@ -8,5 +8,7 @@ be included conditionally;
 (containing definitions of these types or other behaviour-affecting
 defines);
 * printers should be defined
-as MPERS_PRINTER_DECL(return type, function name)(args) and called
-as MPERS_PRINTER_NAME(function name)(args).
+as MPERS_PRINTER_DECL(return_type, function_name)(args),
+inside files that include MPERS_DEFS these printers should be called
+as MPERS_FUNC_NAME(function_name)(args), in other files
+they should be called just as function_name(args).
diff --git a/defs.h b/defs.h
index cad250a4d4cb257d74a333d1e3bfbf95c7a70d3f..5531bbc40ff498b874ced3f841c5cce44fc0b91d 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -779,11 +779,8 @@ extern unsigned num_quals;
 
 #if SUPPORTED_PERSONALITIES > 1
 # include "printers.h"
-extern const struct_printers *printers;
-# define MPERS_PRINTER_NAME(printer_name) printers->printer_name
 #else
 # include "native_printer_decls.h"
-# define MPERS_PRINTER_NAME(printer_name) printer_name
 #endif
 
 /*
index 3ec04eb339789be939f99fda211da6ade2a3855c..55747cbb562773e79c132e981af291bcd5f60ba3 100644 (file)
--- a/ipc_msg.c
+++ b/ipc_msg.c
@@ -54,7 +54,7 @@ static void
 tprint_msgsnd(struct tcb *tcp, const long addr, const unsigned long count,
              const unsigned long flags)
 {
-       MPERS_PRINTER_NAME(tprint_msgbuf)(tcp, addr, count);
+       tprint_msgbuf(tcp, addr, count);
        printflags(ipc_msg_flags, flags, "MSG_???");
 }
 
@@ -75,7 +75,7 @@ static void
 tprint_msgrcv(struct tcb *tcp, const long addr, const unsigned long count,
              const long msgtyp)
 {
-       MPERS_PRINTER_NAME(tprint_msgbuf)(tcp, addr, count);
+       tprint_msgbuf(tcp, addr, count);
        tprintf("%ld, ", msgtyp);
 }
 
index 4ffd2bfdfe1427be60699570ff01b2a622005cb6..a9d94e11e60430efc105a03a7494ca851339d45d 100644 (file)
@@ -11,5 +11,5 @@
 #else
 # define MPERS_PREFIX
 # define DEF_MPERS_TYPE(args) "empty.h"
-# define MPERS_DEFS "empty.h"
+# define MPERS_DEFS "native_defs.h"
 #endif
diff --git a/mq.c b/mq.c
index 2d74573247da7cbcc4866502ba7e27dcff59d71a..59a093a0edfa56fd7c29c67446e9025c2b2fd335 100644 (file)
--- a/mq.c
+++ b/mq.c
@@ -38,7 +38,7 @@ SYS_FUNC(mq_open)
        if (tcp->u_arg[1] & O_CREAT) {
                /* mode */
                tprintf(", %#lo, ", tcp->u_arg[2]);
-               MPERS_PRINTER_NAME(printmqattr)(tcp, tcp->u_arg[3]);
+               printmqattr(tcp, tcp->u_arg[3]);
        }
        return RVAL_DECODED;
 }
@@ -75,9 +75,9 @@ SYS_FUNC(mq_getsetattr)
 {
        if (entering(tcp)) {
                tprintf("%ld, ", tcp->u_arg[0]);
-               MPERS_PRINTER_NAME(printmqattr)(tcp, tcp->u_arg[1]);
+               printmqattr(tcp, tcp->u_arg[1]);
                tprints(", ");
        } else
-               MPERS_PRINTER_NAME(printmqattr)(tcp, tcp->u_arg[2]);
+               printmqattr(tcp, tcp->u_arg[2]);
        return 0;
 }
diff --git a/native_defs.h b/native_defs.h
new file mode 100644 (file)
index 0000000..cdc735e
--- /dev/null
@@ -0,0 +1,4 @@
+#undef MPERS_PRINTER_NAME
+#define MPERS_PRINTER_NAME(printer_name) printer_name
+
+#include "native_printer_decls.h"
index a0144b8ff3b0361eb4d866b2c6f459873df631ef..8629184260673c2daade1d7c1aea764f715ccb25 100644 (file)
--- a/process.c
+++ b/process.c
@@ -105,7 +105,7 @@ SYS_FUNC(ptrace)
                        printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
                        break;
                case PTRACE_SETSIGINFO: {
-                       MPERS_PRINTER_NAME(printsiginfo_at)(tcp, tcp->u_arg[3]);
+                       printsiginfo_at(tcp, tcp->u_arg[3]);
                        break;
                }
                case PTRACE_SETREGSET:
@@ -131,7 +131,7 @@ SYS_FUNC(ptrace)
                        break;
 #endif
                case PTRACE_GETSIGINFO: {
-                       MPERS_PRINTER_NAME(printsiginfo_at)(tcp, tcp->u_arg[3]);
+                       printsiginfo_at(tcp, tcp->u_arg[3]);
                        break;
                }
                case PTRACE_GETREGSET:
index be44aa92796dce6d9083e292d3b19c324165361e..c68f0456e51eba102b6ea7a4eaab699034075fbc 100644 (file)
@@ -162,7 +162,7 @@ SYS_FUNC(getrusage)
                tprints(", ");
        }
        else
-               MPERS_PRINTER_NAME(printrusage)(tcp, tcp->u_arg[1]);
+               printrusage(tcp, tcp->u_arg[1]);
        return 0;
 }
 
index 978926fbdc96665a4847d746bd0d7e5bdcf2d489..1df3fe5bed43b82e988a955e3e321e688b4898d2 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -633,7 +633,7 @@ print_sigqueueinfo(struct tcb *tcp, int sig, unsigned long uinfo)
 {
        printsignal(sig);
        tprints(", ");
-       MPERS_PRINTER_NAME(printsiginfo_at)(tcp, uinfo);
+       printsiginfo_at(tcp, uinfo);
 }
 
 SYS_FUNC(rt_sigqueueinfo)
@@ -666,7 +666,7 @@ SYS_FUNC(rt_sigtimedwait)
        }
        else if (tcp->u_arg[1] != 0) {
                /* syscall exit, and u_arg[1] wasn't NULL */
-               MPERS_PRINTER_NAME(printsiginfo_at)(tcp, tcp->u_arg[1]);
+               printsiginfo_at(tcp, tcp->u_arg[1]);
                tprints(", ");
        }
        else {
index 00060c9b4c8c983781af579cc29ecff32caf725e..b59388b364189df5442bc3ec47176234f46002cb 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -32,6 +32,7 @@
  */
 
 #include "defs.h"
+#include "native_defs.h"
 #include <sys/param.h>
 
 /* for struct iovec */
index f8ef9540fe84e44dfabe82555f8249c8e06ee7b8..22b21a55606896ad3cd1ade7c32376db71a98b4e 100644 (file)
--- a/utimes.c
+++ b/utimes.c
@@ -4,7 +4,7 @@ SYS_FUNC(utimes)
 {
        printpath(tcp, tcp->u_arg[0]);
        tprints(", ");
-       MPERS_PRINTER_NAME(print_timeval_pair)(tcp, tcp->u_arg[1]);
+       print_timeval_pair(tcp, tcp->u_arg[1]);
 
        return RVAL_DECODED;
 }
@@ -14,7 +14,7 @@ SYS_FUNC(futimesat)
        print_dirfd(tcp, tcp->u_arg[0]);
        printpath(tcp, tcp->u_arg[1]);
        tprints(", ");
-       MPERS_PRINTER_NAME(print_timeval_pair)(tcp, tcp->u_arg[2]);
+       print_timeval_pair(tcp, tcp->u_arg[2]);
 
        return RVAL_DECODED;
 }
@@ -24,7 +24,7 @@ SYS_FUNC(utimensat)
        print_dirfd(tcp, tcp->u_arg[0]);
        printpath(tcp, tcp->u_arg[1]);
        tprints(", ");
-       MPERS_PRINTER_NAME(print_timespec_utime_pair)(tcp, tcp->u_arg[2]);
+       print_timespec_utime_pair(tcp, tcp->u_arg[2]);
        tprints(", ");
        printflags(at_flags, tcp->u_arg[3], "AT_???");
 
diff --git a/wait.c b/wait.c
index 07cc36148205529e48210cf192f73902d338c600..2e495dbf94117a5acf861a28eecff4a5a7b8c35b 100644 (file)
--- a/wait.c
+++ b/wait.c
@@ -114,7 +114,7 @@ printwaitn(struct tcb *tcp, int n, int bitness)
                                        printrusage32(tcp, tcp->u_arg[3]);
                                else
 #endif
-                                       MPERS_PRINTER_NAME(printrusage)(tcp, tcp->u_arg[3]);
+                                       printrusage(tcp, tcp->u_arg[3]);
                        }
                        else
                                printaddr(tcp->u_arg[3]);
@@ -149,14 +149,14 @@ SYS_FUNC(waitid)
                tprintf(", %ld, ", tcp->u_arg[1]);
        } else {
                /* siginfo */
-               MPERS_PRINTER_NAME(printsiginfo_at)(tcp, tcp->u_arg[2]);
+               printsiginfo_at(tcp, tcp->u_arg[2]);
                /* options */
                tprints(", ");
                printflags(wait4_options, tcp->u_arg[3], "W???");
                if (tcp->s_ent->nargs > 4) {
                        /* usage */
                        tprints(", ");
-                       MPERS_PRINTER_NAME(printrusage)(tcp, tcp->u_arg[4]);
+                       printrusage(tcp, tcp->u_arg[4]);
                }
        }
        return 0;