[PATCH 1/4] Use printpid() to print pid embedded in clockid

Masatake YAMATO yamato at redhat.com
Fri Sep 3 20:28:40 UTC 2021


* src/time.c (printclockname): Add tcb as a parameter.
Use printpid instead of PRINT_VAL_D. printpid needs tcb.
(do_clock_settime, do_clock_gettime, do_clock_nanosleep,
do_clock_adjtime, SYS_FUNC(timer_create),
SYS_FUNC(timer_gettime64)): Pass tcb to printclockname.

Suggested-by: Ákos Uzonyi <uzonyi.akos at gmail.com>
Signed-off-by: Masatake YAMATO <yamato at redhat.com>
---
 src/time.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/time.c b/src/time.c
index 2b0ded515..656e4bee1 100644
--- a/src/time.c
+++ b/src/time.c
@@ -231,7 +231,7 @@ SYS_FUNC(adjtimex64)
 #include "xlat/clocknames.h"
 
 static void
-printclockname(int clockid)
+printclockname(struct tcb *const tcp, int clockid)
 {
 #ifdef CLOCKID_TO_FD
 # include "xlat/cpuclocknames.h"
@@ -253,7 +253,8 @@ printclockname(int clockid)
 			tprints_arg_begin(CPUCLOCK_PERTHREAD(clockid) ?
 					  "MAKE_THREAD_CPUCLOCK" :
 					  "MAKE_PROCESS_CPUCLOCK");
-			PRINT_VAL_D(CPUCLOCK_PID(clockid));
+			printpid(tcp, CPUCLOCK_PID(clockid),
+				 CPUCLOCK_PERTHREAD(clockid)? PT_TID : PT_TGID);
 			tprint_arg_next();
 			printxval(cpuclocknames, clockid & CLOCKFD_MASK,
 				  "CPUCLOCK_???");
@@ -271,7 +272,7 @@ static int
 do_clock_settime(struct tcb *const tcp, const print_obj_by_addr_fn print_ts)
 {
 	/* clockid */
-	printclockname(tcp->u_arg[0]);
+	printclockname(tcp, tcp->u_arg[0]);
 	tprint_arg_next();
 
 	/* tp */
@@ -297,7 +298,7 @@ do_clock_gettime(struct tcb *const tcp, const print_obj_by_addr_fn print_ts)
 {
 	if (entering(tcp)) {
 		/* clockid */
-		printclockname(tcp->u_arg[0]);
+		printclockname(tcp, tcp->u_arg[0]);
 		tprint_arg_next();
 	} else {
 		/* tp */
@@ -323,7 +324,7 @@ do_clock_nanosleep(struct tcb *const tcp, const print_obj_by_addr_fn print_ts)
 {
 	if (entering(tcp)) {
 		/* clockid */
-		printclockname(tcp->u_arg[0]);
+		printclockname(tcp, tcp->u_arg[0]);
 		tprint_arg_next();
 
 		/* flags */
@@ -367,7 +368,7 @@ do_clock_adjtime(struct tcb *const tcp, const print_obj_by_addr_fn print_tx)
 {
 	if (entering(tcp)) {
 		/* clockid */
-		printclockname(tcp->u_arg[0]);
+		printclockname(tcp, tcp->u_arg[0]);
 		tprint_arg_next();
 		return 0;
 	} else {
@@ -398,7 +399,7 @@ SYS_FUNC(timer_create)
 {
 	if (entering(tcp)) {
 		/* clockid */
-		printclockname(tcp->u_arg[0]);
+		printclockname(tcp, tcp->u_arg[0]);
 		tprint_arg_next();
 
 		/* sevp */
@@ -476,7 +477,7 @@ SYS_FUNC(timer_gettime64)
 SYS_FUNC(timerfd_create)
 {
 	/* clockid */
-	printclockname(tcp->u_arg[0]);
+	printclockname(tcp, tcp->u_arg[0]);
 	tprint_arg_next();
 
 	/* flags */
-- 
2.31.1



More information about the Strace-devel mailing list