From owner-freebsd-bugs Tue Oct 8 3:40:17 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1454737B401 for ; Tue, 8 Oct 2002 03:40:14 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7B73C43E7B for ; Tue, 8 Oct 2002 03:40:13 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id g98Ae4Co041459 for ; Tue, 8 Oct 2002 03:40:04 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g98Ae4Ya041458; Tue, 8 Oct 2002 03:40:04 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 73CB537B401 for ; Tue, 8 Oct 2002 03:37:37 -0700 (PDT) Received: from mail.netbeat.de (mail.netbeat.de [62.208.140.19]) by mx1.FreeBSD.org (Postfix) with SMTP id EFDDD43E77 for ; Tue, 8 Oct 2002 03:37:35 -0700 (PDT) (envelope-from slaven@rezic.de) Received: (qmail 2804 invoked from network); 8 Oct 2002 10:37:56 -0000 Received: from bb8a0.pppool.de (HELO vran.herceg.de) (213.7.184.160) by mail.netbeat.de with SMTP; 8 Oct 2002 10:37:56 -0000 Received: (from eserte@localhost) by vran.herceg.de (8.12.4/8.12.4/Submit) id g98AVlSS006536; Tue, 8 Oct 2002 12:31:47 +0200 (CEST) (envelope-from eserte) Message-Id: <200210081031.g98AVlSS006536@vran.herceg.de> Date: Tue, 8 Oct 2002 12:31:47 +0200 (CEST) From: Slaven Rezic Reply-To: slaven.rezic@berlin.de To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/43819: changed truss output for utrace calls Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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