From owner-freebsd-current@FreeBSD.ORG Sat Jun 14 14:43:31 2008 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1BEA91065671 for ; Sat, 14 Jun 2008 14:43:31 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.freebsd.org (Postfix) with ESMTP id E18D08FC12 for ; Sat, 14 Jun 2008 14:43:30 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id 379CD46B49; Sat, 14 Jun 2008 10:43:30 -0400 (EDT) Date: Sat, 14 Jun 2008 15:43:30 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Julian Elischer In-Reply-To: <48537B5F.30207@elischer.org> Message-ID: <20080614154218.J60241@fledge.watson.org> References: <48537B5F.30207@elischer.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: FreeBSD Current Subject: Re: mprof and new systems.. X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jun 2008 14:43:31 -0000 On Sat, 14 Jun 2008, Julian Elischer wrote: > mprof is a memory allocation profiler. > > as part of what it does it reads the stack for a call graph. > > it finds the current frame pointer from the address of a variable on the > stack and then from that traces back to previous return addresses. > > however there is a catch, at least on i386.. > > with -O2 the variable is 4 bytes below the fp and without it it is 12 bytes > below. so it has to know how it was compiled to get it right. > > in addition, with -O2 it seems that the address of the variable may actually > be wring if the optimiser never bothers to have the variable actually saved. I'm not sure if you've seen it or not, but stack(9) provides an automated stack capture facility for the kernel. It may not be ideal for your use, but it isn't a bad starting point for things along this line, and it works on (almost) all architectures in a portable way. It might need some extending for your purposes. Robert N M Watson Computer Laboratory University of Cambridge > > > one possibility would be to use #asm to just give the value of %ebp > > currently it does: > > > > findretaddr() > { > int first_var; > u_int *fp > u_int *retptr > > > fp = ((char *)(&first_var)) + 4; /* needs to be 12 if no -O2 */ > retptr = ((char *)fp) + 4; > prev_fp = *fp; > > [...] > > > } > > Anyone with ideas as to how to make the port act reliably? > > mprof is really cool but thos probelm makes it hard to use. > you have ot make sure you compile the library itself without -O > and change the code.. > > why it needs to be 12 is unknown the compiler seems to want > to push extra regs before savinghte frame pointer. > > > > > > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" >