Bug 43819

Summary: [patch] changed truss(1) output for utrace calls
Product: Base System Reporter: Slaven Rezic <eserte>
Component: binAssignee: Bryan Drewery <bdrewery>
Status: Closed FIXED    
Severity: Affects Only Me CC: bdrewery
Priority: Normal    
Version: 4.6-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Slaven Rezic 2002-10-08 11:40:03 UTC
	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.

Fix: This patch should be applied in the /usr/src/usr.bin/truss
	directory:
Comment 1 Bryan Drewery freebsd_committer freebsd_triage 2015-10-05 21:00:43 UTC
https://reviews.freebsd.org/D3819 uses kdump's code to handle this.
Comment 2 commit-hook freebsd_committer freebsd_triage 2015-10-06 21:59:41 UTC
A commit references this bug:

Author: bdrewery
Date: Tue Oct  6 21:58:39 UTC 2015
New revision: 288957
URL: https://svnweb.freebsd.org/changeset/base/288957

Log:
  truss: Add support for utrace(2).

  This uses the kdump(1) utrace support code directly until a common library
  is created.

  This allows malloc(3) tracing with MALLOC_CONF=utrace:true and rtld tracing
  with LD_UTRACE=1.  Unknown utrace(2) data is just printed as hex.

  PR:		43819 [inspired by]
  Reviewed by:	jhb
  MFC after:	2 weeks
  Relnotes:	yes
  Differential Revision:	https://reviews.freebsd.org/D3819

Changes:
  head/lib/libc/sys/utrace.2
  head/usr.bin/kdump/Makefile
  head/usr.bin/kdump/kdump.c
  head/usr.bin/kdump/utrace.c
  head/usr.bin/truss/Makefile
  head/usr.bin/truss/syscall.h
  head/usr.bin/truss/syscalls.c
  head/usr.bin/truss/truss.1