From owner-freebsd-current@FreeBSD.ORG Sat Jun 14 09:02:09 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 2C99D10656BA for ; Sat, 14 Jun 2008 09:02:09 +0000 (UTC) (envelope-from peter@wemm.org) Received: from ag-out-0708.google.com (ag-out-0708.google.com [72.14.246.244]) by mx1.freebsd.org (Postfix) with ESMTP id E1FF18FC0C for ; Sat, 14 Jun 2008 09:02:08 +0000 (UTC) (envelope-from peter@wemm.org) Received: by ag-out-0708.google.com with SMTP id 8so7751399agc.3 for ; Sat, 14 Jun 2008 02:02:08 -0700 (PDT) Received: by 10.100.140.10 with SMTP id n10mr5395712and.129.1213434127951; Sat, 14 Jun 2008 02:02:07 -0700 (PDT) Received: by 10.100.154.11 with HTTP; Sat, 14 Jun 2008 02:02:07 -0700 (PDT) Message-ID: Date: Sat, 14 Jun 2008 02:02:07 -0700 From: "Peter Wemm" To: "Julian Elischer" In-Reply-To: <48537D07.8050305@elischer.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <48537B5F.30207@elischer.org> <48537D07.8050305@elischer.org> 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 09:02:09 -0000 On Sat, Jun 14, 2008 at 1:10 AM, Julian Elischer wrote: > Julian Elischer wrote: [..] >> Anyone with ideas as to how to make the port act reliably? Check out __builtin_return_address() and __builtin_frame_pointer(). Or look at src/sys/i386/i386/stack_machdep.c (it is present on all platforms). info gcc -> 'C Extensions' -> 'Return Address' -- Built-in Function: void * __builtin_return_address (unsigned int LEVEL) This function returns the return address of the current function, or of one of its callers. .. -- Built-in Function: void * __builtin_frame_address (unsigned int LEVEL) This function is similar to `__builtin_return_address', but it returns the address of the function frame rather than the return address of the function. __builtin_frame_address() on i386 is basically: register_t ebp; __asm __volatile("movl %%ebp,%0" : "=r" (ebp)); or for amd64: register_t rbp; __asm __volatile("movq %%rbp,%0" : "=r" (rbp)); -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5 "If Java had true garbage collection, most programs would delete themselves upon execution." -- Robert Sewell