On Wed, 14 Aug 2013 16:14:34 +0530, nidhi mittal hada said:

> 1)if i want to get value of a local variable, of a function,  from stack
> trace thats bt-f output, obtained using crash ..
> No where AMD64 ABI mentions how local variables are stored ..
> is it in some specific sequence of registers ? is it in stack ?

Yes, no, maybe, depends on how smart the compiler is.  Local variables
are local, and thus by definition not part of the ABI.  The compiler
may decide that a given 'int' can be kept in %r8 for most of the
time, but stored at 24 bytes into the stack across 1 function call,
and another variable is in %r9 most of the time, but in that same location
24 bytes into the stack across a different function call (and that's
OK, because it always knows which variable is using that location
24 bytes into the stack when).

In some cases, a variable may even be totally optimized out of existence.
For example, if you have

int foo ( int c ) {
int a, b;

   b = c * 5;
   a = b + getpid();
   return a;
}

the compiler can (and probably *will*) optimize both a and b
away and convert it to 'return (c*5 + getpid());'

Attachment: pgpAGrPapZukE.pgp
Description: PGP signature

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Reply via email to