Skip to content

Commit e2fb0bb

Browse files
committed
Simplify use of mpers printers
* 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.
1 parent b172a94 commit e2fb0bb

File tree

13 files changed

+34
-24
lines changed

13 files changed

+34
-24
lines changed

Makefile.am

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ strace_SOURCES = \
8787
mknod.c \
8888
mount.c \
8989
mpers_type.h \
90-
mq.c \
90+
mq.c \
9191
mtd.c \
92+
native_defs.h \
9293
net.c \
9394
open.c \
9495
or1k_atomic.c \
@@ -686,6 +687,9 @@ m%_defs.h: $(srcdir_mpers_source_files)
686687
for f in $^; do \
687688
sed -n 's/^#include DEF_MPERS_TYPE(\([^)]\+\))/#ifdef MPERS_$(mpers_PREFIX)\1\n# define \1 MPERS_$(mpers_PREFIX)\1\n#endif/p' $$f || exit; \
688689
done > $@-t
690+
echo '#undef MPERS_PRINTER_NAME' >> $@-t
691+
echo '#define MPERS_PRINTER_NAME(printer_name) printer_name' >> $@-t
692+
echo '#include "$(mpers_PREFIX)printer_decls.h"' >> $@-t
689693
mv $@-t $@
690694

691695
m%_funcs.h: $(srcdir_mpers_source_files)
@@ -701,9 +705,11 @@ printers.h: $(srcdir_mpers_source_files)
701705
echo '/* Generated by Makefile from $^; do not edit. */' > $@-t
702706
echo 'typedef struct {' >> $@-t
703707
for f in $^; do \
704-
sed -n 's/^MPERS_PRINTER_DECL(\([^,]\+\),[[:space:]]*\([^)]\+\))\(.*\)/ \1 (*\2) \3;/p' $$f || exit; \
708+
sed -n 's/^MPERS_PRINTER_DECL(\([^,]\+\),[[:space:]]*\([^)]\+\))\(.*\)/ \1 (*\2) \3;\n#define \2 MPERS_PRINTER_NAME(\2)\n/p' $$f || exit; \
705709
done >> $@-t
706710
echo '} struct_printers;' >> $@-t
711+
echo 'extern const struct_printers *printers;' >> $@-t
712+
echo '#define MPERS_PRINTER_NAME(printer_name) printers->printer_name' >> $@-t
707713
mv $@-t $@
708714

709715
%_printer_decls.h: $(srcdir_mpers_source_files)

README-mpers

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ be included conditionally;
88
(containing definitions of these types or other behaviour-affecting
99
defines);
1010
* printers should be defined
11-
as MPERS_PRINTER_DECL(return type, function name)(args) and called
12-
as MPERS_PRINTER_NAME(function name)(args).
11+
as MPERS_PRINTER_DECL(return_type, function_name)(args),
12+
inside files that include MPERS_DEFS these printers should be called
13+
as MPERS_FUNC_NAME(function_name)(args), in other files
14+
they should be called just as function_name(args).

defs.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,11 +779,8 @@ extern unsigned num_quals;
779779

780780
#if SUPPORTED_PERSONALITIES > 1
781781
# include "printers.h"
782-
extern const struct_printers *printers;
783-
# define MPERS_PRINTER_NAME(printer_name) printers->printer_name
784782
#else
785783
# include "native_printer_decls.h"
786-
# define MPERS_PRINTER_NAME(printer_name) printer_name
787784
#endif
788785

789786
/*

ipc_msg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static void
5454
tprint_msgsnd(struct tcb *tcp, const long addr, const unsigned long count,
5555
const unsigned long flags)
5656
{
57-
MPERS_PRINTER_NAME(tprint_msgbuf)(tcp, addr, count);
57+
tprint_msgbuf(tcp, addr, count);
5858
printflags(ipc_msg_flags, flags, "MSG_???");
5959
}
6060

@@ -75,7 +75,7 @@ static void
7575
tprint_msgrcv(struct tcb *tcp, const long addr, const unsigned long count,
7676
const long msgtyp)
7777
{
78-
MPERS_PRINTER_NAME(tprint_msgbuf)(tcp, addr, count);
78+
tprint_msgbuf(tcp, addr, count);
7979
tprintf("%ld, ", msgtyp);
8080
}
8181

mpers_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
#else
1212
# define MPERS_PREFIX
1313
# define DEF_MPERS_TYPE(args) "empty.h"
14-
# define MPERS_DEFS "empty.h"
14+
# define MPERS_DEFS "native_defs.h"
1515
#endif

mq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ SYS_FUNC(mq_open)
3838
if (tcp->u_arg[1] & O_CREAT) {
3939
/* mode */
4040
tprintf(", %#lo, ", tcp->u_arg[2]);
41-
MPERS_PRINTER_NAME(printmqattr)(tcp, tcp->u_arg[3]);
41+
printmqattr(tcp, tcp->u_arg[3]);
4242
}
4343
return RVAL_DECODED;
4444
}
@@ -75,9 +75,9 @@ SYS_FUNC(mq_getsetattr)
7575
{
7676
if (entering(tcp)) {
7777
tprintf("%ld, ", tcp->u_arg[0]);
78-
MPERS_PRINTER_NAME(printmqattr)(tcp, tcp->u_arg[1]);
78+
printmqattr(tcp, tcp->u_arg[1]);
7979
tprints(", ");
8080
} else
81-
MPERS_PRINTER_NAME(printmqattr)(tcp, tcp->u_arg[2]);
81+
printmqattr(tcp, tcp->u_arg[2]);
8282
return 0;
8383
}

native_defs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#undef MPERS_PRINTER_NAME
2+
#define MPERS_PRINTER_NAME(printer_name) printer_name
3+
4+
#include "native_printer_decls.h"

process.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ SYS_FUNC(ptrace)
105105
printflags(ptrace_setoptions_flags, tcp->u_arg[3], "PTRACE_O_???");
106106
break;
107107
case PTRACE_SETSIGINFO: {
108-
MPERS_PRINTER_NAME(printsiginfo_at)(tcp, tcp->u_arg[3]);
108+
printsiginfo_at(tcp, tcp->u_arg[3]);
109109
break;
110110
}
111111
case PTRACE_SETREGSET:
@@ -131,7 +131,7 @@ SYS_FUNC(ptrace)
131131
break;
132132
#endif
133133
case PTRACE_GETSIGINFO: {
134-
MPERS_PRINTER_NAME(printsiginfo_at)(tcp, tcp->u_arg[3]);
134+
printsiginfo_at(tcp, tcp->u_arg[3]);
135135
break;
136136
}
137137
case PTRACE_GETREGSET:

resource.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ SYS_FUNC(getrusage)
162162
tprints(", ");
163163
}
164164
else
165-
MPERS_PRINTER_NAME(printrusage)(tcp, tcp->u_arg[1]);
165+
printrusage(tcp, tcp->u_arg[1]);
166166
return 0;
167167
}
168168

signal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ print_sigqueueinfo(struct tcb *tcp, int sig, unsigned long uinfo)
633633
{
634634
printsignal(sig);
635635
tprints(", ");
636-
MPERS_PRINTER_NAME(printsiginfo_at)(tcp, uinfo);
636+
printsiginfo_at(tcp, uinfo);
637637
}
638638

639639
SYS_FUNC(rt_sigqueueinfo)
@@ -666,7 +666,7 @@ SYS_FUNC(rt_sigtimedwait)
666666
}
667667
else if (tcp->u_arg[1] != 0) {
668668
/* syscall exit, and u_arg[1] wasn't NULL */
669-
MPERS_PRINTER_NAME(printsiginfo_at)(tcp, tcp->u_arg[1]);
669+
printsiginfo_at(tcp, tcp->u_arg[1]);
670670
tprints(", ");
671671
}
672672
else {

0 commit comments

Comments
 (0)