Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 May 2003 13:34:53 -0500 (CDT)
From:      Dan Nelson <dnelson@allantgroup.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/52190: [Patch] decode more syscalls in truss
Message-ID:  <200305131834.h4DIYreY097942@dan.emsphone.com>
Resent-Message-ID: <200305131840.h4DIe5Sx022022@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         52190
>Category:       bin
>Synopsis:       [Patch] decode more syscalls in truss
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 13 11:40:05 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Dan Nelson
>Release:        FreeBSD 5.1-BETA i386
>Organization:
The Allant Group
>Environment:
System: FreeBSD dan.emsphone.com 5.1-BETA FreeBSD 5.1-BETA #269: Tue May 13 09:30:33 CDT 2003 zsh@dan.emsphone.com:/usr/src/sys/i386/compile/DANSMP i386


	
>Description:
	
>How-To-Repeat:
	
>Fix:

This adds the ability to decode struct timespec and timeval, and adds a
bunch of syscalls that use them.  As a bonus, describe recvfrom to its
sockaddr can be printed.

Index: syscall.h
===================================================================
RCS file: /home/ncvs/src/usr.bin/truss/syscall.h,v
retrieving revision 1.10
diff -u -p -r1.10 syscall.h
--- syscall.h	4 Aug 2002 02:24:21 -0000	1.10
+++ syscall.h	13 May 2003 17:24:08 -0000
@@ -9,9 +9,14 @@
  *	write() arguments as such, even though they may *not* be
  *	printable data.
  * Ptr -- pointer to some specific structure.  Just print as hex for now.
- * Quad -- a double-word value.  e.g., lseek(int, offset_t, int)
  * Stat -- a pointer to a stat buffer.  Currently unused.
  * Ioctl -- an ioctl command.  Woefully limited.
+ * Quad -- a double-word value.  e.g., lseek(int, offset_t, int)
+ * Signal -- a signal number.  Prints the signal name (SIGxxx)
+ * Sockaddr -- a pointer to a struct sockaddr.  Prints symbolic AF, and IP:Port
+ * StringArray -- a pointer to an array of string pointers.
+ * Timespec -- a pointer to a struct timespec.  Prints both elements.
+ * Timeval -- a pointer to a struct timeval.  Prints both elements.
  *
  * In addition, the pointer types (String, Ptr) may have OUT masked in --
  * this means that the data is set on *return* from the system call -- or
@@ -22,7 +27,7 @@
  */
 
 enum Argtype { None = 1, Hex, Octal, Int, String, Ptr, Stat, Ioctl, Quad,
-	Signal, Sockaddr, StringArray };
+	Signal, Sockaddr, StringArray, Timespec, Timeval };
 
 #define ARG_MASK	0xff
 #define OUT	0x100
Index: syscalls.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/truss/syscalls.c,v
retrieving revision 1.28
diff -u -p -r1.28 syscalls.c
--- syscalls.c	15 Apr 2003 06:12:12 -0000	1.28
+++ syscalls.c	13 May 2003 16:18:16 -0000
@@ -131,6 +131,12 @@ struct syscall syscalls[] = {
 	{ "kldnext", 0, 1, { { Int, 0 }}},
 	{ "kldstat", 0, 2, { { Int, 0 }, { Ptr, 1 }}},
 	{ "kldfirstmod", 0, 1, { { Int, 0 }}},
+	{ "nanosleep", 0, 1, { { Timespec, 0 }}},
+	{ "select", 1, 5, { { Int, 0 }, { Ptr, 1 }, { Ptr, 2 }, { Ptr, 3 }, { Timeval, 4 }}},
+	{ "poll", 1, 3, { { Ptr, 0 }, { Int, 1 }, { Int, 2 }}},
+	{ "gettimeofday", 1, 2, { { Timeval | OUT, 0 }, { Ptr, 1 }}},
+	{ "clock_gettime", 1, 2, { { Int, 0 }, { Timeval | OUT, 1 }}},
+	{ "recvfrom", 1, 6, { { Int, 0 }, { Ptr | OUT, 1 }, { Int, 2 }, { Int, 3 }, { Sockaddr | OUT, 4}, {Ptr | OUT, 5}}},
 	{ 0, 0, 0, { { 0, 0 }}},
 };
 
@@ -333,6 +339,24 @@ print_arg(int fd, struct syscall_args *s
       }
     }
     break;
+  case Timespec:
+    {
+      struct timespec ts;
+      if(get_struct(fd, (void *)args[sc->offset], &ts, sizeof(struct timespec)) != -1)
+        asprintf(&tmp, "{%d,%d}", ts.tv_sec, ts.tv_nsec);
+      else
+        asprintf(&tmp, "0x%lx", args[sc->offset]);
+    }
+    break;
+  case Timeval:
+    {
+      struct timeval tv;
+      if(get_struct(fd, (void *)args[sc->offset], &tv, sizeof(struct timeval)) != -1)
+        asprintf(&tmp, "{%d,%d}", tv.tv_sec, tv.tv_usec);
+      else
+        asprintf(&tmp, "0x%lx", args[sc->offset]);
+    }
+    break;
   case Signal:
     {
       long sig;
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200305131834.h4DIYreY097942>