Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Jun 2008 01:03:43 -0700
From:      Julian Elischer <julian@elischer.org>
To:        FreeBSD Current <current@freebsd.org>
Subject:   mprof and new systems..
Message-ID:  <48537B5F.30207@elischer.org>

next in thread | raw e-mail | index | archive | help
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.


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.








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