Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Jun 2008 02:02:07 -0700
From:      "Peter Wemm" <peter@wemm.org>
To:        "Julian Elischer" <julian@elischer.org>
Cc:        FreeBSD Current <current@freebsd.org>
Subject:   Re: mprof and new systems..
Message-ID:  <e7db6d980806140202i28ef94abj28b7d849e7ff413@mail.gmail.com>
In-Reply-To: <48537D07.8050305@elischer.org>
References:  <48537B5F.30207@elischer.org> <48537D07.8050305@elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Jun 14, 2008 at 1:10 AM, Julian Elischer <julian@elischer.org> 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



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