Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Oct 2002 12:31:47 +0200 (CEST)
From:      Slaven Rezic <eserte@vran.herceg.de>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/43819: changed truss output for utrace calls
Message-ID:  <200210081031.g98AVlSS006536@vran.herceg.de>

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


>Number:         43819
>Category:       bin
>Synopsis:       changed truss output for utrace calls
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 08 03:40:03 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Slaven Rezic
>Release:        FreeBSD 4.6-STABLE i386
>Organization:
www.rezic.de
>Environment:
System: FreeBSD vran.herceg.de 4.6-STABLE FreeBSD 4.6-STABLE #15: Sat Jul 27 09:32:28 CEST 2002 root@vran.herceg.de:/usr/local/src/FreeBSD-4/src/sys/compile/VRAN i386


>Description:

	FreeBSD's malloc has a feature to emit utrace syscalls for
	debugging when MALLOC_OPTIONS contains the "U" character.
	Using ktrace, one can find the following entries with kdump:
	
  4059 perl5.8.0 CALL  utrace(0xbfbff2a4,0xc)
  4059 perl5.8.0 USER  12  00 00 00 00 01 00 00 00 30 90 11 08
  4059 perl5.8.0 RET   utrace 0

	These lines can easily be converted into malloc/free/realloc
	calls. 

	However, with truss the output looks as follows:

utrace(0xbfbff2a4,0xc)                           = 0 (0x0)

	That is, the first argument is only a pointer to the utrace
	buffer. I propose to change truss to dump the contents
	of the buffer instead:

utrace(0x000000005000000000b01108)               = 0 (0x0)

	The second parameter (the size of the buffer) has gone,
	because	it can be determined by the length of the buffer
	string.

>How-To-Repeat:
	
>Fix:

	This patch should be applied in the /usr/src/usr.bin/truss
	directory:

--- syscalls.c.orig	Tue Oct  8 11:21:24 2002
+++ syscalls.c	Tue Oct  8 11:53:36 2002
@@ -101,6 +101,8 @@ struct syscall syscalls[] = {
 	  { { Hex, 0 }, { Sockaddr | OUT, 1 }, { Ptr | OUT, 2 } } },
 	{ "getsockname", 1, 3,
 	  { { Hex, 0 }, { Sockaddr | OUT, 1 }, { Ptr | OUT, 2 } } },
+	{ "utrace", 1, 1,
+	  { { Utrace, 0 } } },
 	{ 0, 0, 0, { { 0, 0 }}},
 };
 
@@ -341,6 +343,23 @@ print_arg(int fd, struct syscall_args *s
       }
     }
     break;
+  case Utrace:
+    {
+      int i, len;
+      unsigned char *p;
+      unsigned char *utrace_buffer;
+      len = args[sc->offset+1];
+      tmp = malloc(len*2+2+1);
+      utrace_buffer = malloc(len);
+      if (get_struct(fd, (void *)args[sc->offset], (void *)utrace_buffer,
+		     len) == -1)
+	err(1, "get_struct %p", (void *)args[sc->offset]);
+      strcpy(tmp, "0x");
+      for(i = 0; i < len; i++) {
+	sprintf(tmp+2+i*2, "%02x", *(utrace_buffer+i));
+      }
+      free(utrace_buffer);
+    }
   }
   return tmp;
 }



>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




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