From a862576da8d88a84e20c24a86c2b561778d6e7c3 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 20 Jun 2019 09:49:27 +0000 Subject: [PATCH] Enhance decoding of CLONE_PARENT_SETTID flag of clone syscall * clone.c (SYS_FUNC(clone)): Print the parent_tid returned by the kernel instead of its address when CLONE_PARENT_SETTID flag is set. * tests/clone-flags.c (main): Check it. --- clone.c | 4 ++-- tests/clone-flags.c | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/clone.c b/clone.c index f43431ae..66be1645 100644 --- a/clone.c +++ b/clone.c @@ -121,8 +121,8 @@ SYS_FUNC(clone) return RVAL_DECODED; } else { if (flags & CLONE_PARENT_SETTID) { - tprints(", parent_tidptr="); - printaddr(tcp->u_arg[ARG_PTID]); + tprints(", parent_tid="); + printnum_int(tcp, tcp->u_arg[ARG_PTID], "%u"); } if (flags & CLONE_SETTLS) { tprints(", tls="); diff --git a/tests/clone-flags.c b/tests/clone-flags.c index 49cdbb49..c6fb49be 100644 --- a/tests/clone-flags.c +++ b/tests/clone-flags.c @@ -116,5 +116,13 @@ main(void) SYSCALL_NAME, child_stack_printed, STACK_SIZE_ARG "CLONE_FS|SIGCHLD", pid); + TAIL_ALLOC_OBJECT_CONST_PTR(pid_t, ptid); + pid = do_clone(child, child_stack, child_stack_size, + CLONE_PARENT_SETTID|SIGCHLD, 0, ptid); + printf("%s(child_stack=%#lx" STACK_SIZE_FMT ", flags=%s" + ", parent_tid=[%u]) = %d\n", + SYSCALL_NAME, child_stack_printed, STACK_SIZE_ARG + "CLONE_PARENT_SETTID|SIGCHLD", *ptid, pid); + return 0; } -- 2.40.0