svn commit: r319876 - head/tools/test/ptrace

Konstantin Belousov kib at FreeBSD.org
Mon Jun 12 21:16:38 UTC 2017


Author: kib
Date: Mon Jun 12 21:16:37 2017
New Revision: 319876
URL: https://svnweb.freebsd.org/changeset/base/319876

Log:
  Update scescx test to print syscall number and arguments.
  
  Sponsored by:	The FreeBSD Foundation
  MFC after:	3 weeks

Modified:
  head/tools/test/ptrace/scescx.c

Modified: head/tools/test/ptrace/scescx.c
==============================================================================
--- head/tools/test/ptrace/scescx.c	Mon Jun 12 21:15:43 2017	(r319875)
+++ head/tools/test/ptrace/scescx.c	Mon Jun 12 21:16:37 2017	(r319876)
@@ -181,12 +181,33 @@ get_pathname(pid_t pid)
 static void
 wait_info(int pid, int status, struct ptrace_lwpinfo *lwpinfo)
 {
+	long *args;
+	int error, i;
 
 	printf(TRACE "pid %d wait %s", pid,
 	    decode_wait_status(status));
 	if (lwpinfo != NULL) {
 		printf(" event %s flags %s",
 		    decode_pl_event(lwpinfo), decode_pl_flags(lwpinfo));
+		if ((lwpinfo->pl_flags & (PL_FLAG_SCE | PL_FLAG_SCX)) != 0) {
+			printf(" sc%d", lwpinfo->pl_syscall_code);
+			args = calloc(lwpinfo->pl_syscall_narg, sizeof(long));
+			error = ptrace(PT_GET_SC_ARGS, lwpinfo->pl_lwpid,
+			    (caddr_t)args, lwpinfo->pl_syscall_narg *
+			    sizeof(long));
+			if (error == 0) {
+				for (i = 0; i < (int)lwpinfo->pl_syscall_narg;
+				    i++) {
+					printf("%c%#lx", i == 0 ? '(' : ',',
+					    args[i]);
+				}
+			} else {
+				fprintf(stderr, "PT_GET_SC_ARGS failed: %s",
+				    strerror(errno));
+			}
+			printf(")");
+			free(args);
+		}
 	}
 	printf("\n");
 }


More information about the svn-src-all mailing list