From 665f10c9a4c45b36b6afe70353d1948a9021a9ba Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 11 Dec 2014 19:21:54 +0000 Subject: [PATCH] process.c: move getcpu parser to a separate file * getcpu.c: New file. * Makefile.am (strace_SOURCES): Add it. * process.c (sys_getcpu): Move to getcpu.c. --- Makefile.am | 1 + getcpu.c | 23 +++++++++++++++++++++++ process.c | 22 ---------------------- 3 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 getcpu.c diff --git a/Makefile.am b/Makefile.am index b6503ed9..cd097a45 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,6 +33,7 @@ strace_SOURCES = \ fallocate.c \ fanotify.c \ file.c \ + getcpu.c \ getcwd.c \ inotify.c \ io.c \ diff --git a/getcpu.c b/getcpu.c new file mode 100644 index 00000000..522786fd --- /dev/null +++ b/getcpu.c @@ -0,0 +1,23 @@ +#include "defs.h" + +int +sys_getcpu(struct tcb *tcp) +{ + if (exiting(tcp)) { + unsigned u; + if (tcp->u_arg[0] == 0) + tprints("NULL, "); + else if (umove(tcp, tcp->u_arg[0], &u) < 0) + tprintf("%#lx, ", tcp->u_arg[0]); + else + tprintf("[%u], ", u); + if (tcp->u_arg[1] == 0) + tprints("NULL, "); + else if (umove(tcp, tcp->u_arg[1], &u) < 0) + tprintf("%#lx, ", tcp->u_arg[1]); + else + tprintf("[%u], ", u); + tprintf("%#lx", tcp->u_arg[2]); + } + return 0; +} diff --git a/process.c b/process.c index ede4224b..648d9ba2 100644 --- a/process.c +++ b/process.c @@ -2510,25 +2510,3 @@ sys_arch_prctl(struct tcb *tcp) return 0; } #endif /* X86_64 || X32 */ - -int -sys_getcpu(struct tcb *tcp) -{ - if (exiting(tcp)) { - unsigned u; - if (tcp->u_arg[0] == 0) - tprints("NULL, "); - else if (umove(tcp, tcp->u_arg[0], &u) < 0) - tprintf("%#lx, ", tcp->u_arg[0]); - else - tprintf("[%u], ", u); - if (tcp->u_arg[1] == 0) - tprints("NULL, "); - else if (umove(tcp, tcp->u_arg[1], &u) < 0) - tprintf("%#lx, ", tcp->u_arg[1]); - else - tprintf("[%u], ", u); - tprintf("%#lx", tcp->u_arg[2]); - } - return 0; -} -- 2.40.0