Hey guys,
   I'm a bit confused over the functionalities of track_new_mem_stack vs
new_mem_stack_signal.
When is the stack_signal called? I looked at pub_tool_tooliface.h but I'm
still confused.

I understand that the new_mem_stack is called when the SP changes, but what
I don't understand is 1) why is it called twice (llok at my trace [2]), and
2) how do I use this info to find the top of the stack including the size of
the memory reserved by the local variables that follow the function call?

For example I have a toy client [1], and a resulting trace given in [2]:
What I would like to find out is the top of the stack at any given time and
record when such change occurs, that is, the very lowest address accessed by
the stack (ignoring threads for right now).
I thought the address given by new_mem_stack is it, but...as can be seen
from the trace, the address returned with new_mem_stack points to he
beginning of the called function, not necessarily to the stack memory
reserved or accessed by individual variables/structures?

So my question is, what am I missing / not understanding here? How do I
capture the changing stack including the memory reserved by the local
variables?

Currently, within the tool, I check every memory read/write against the
accessed address and if it's higher than my global area or higher than my
tracked dynamic / mmaped area, I treat it as a stack access.
Any ideas?

the trace line format is similar to lackey with a few extensions:

store/load, virtual address, access size, thread_id, application segment
(stack, code, global, heap, mmap etc.), function name, scope, variable name
including the accessed offset.

[1] client code
  1 #include <stdio.h>
  2 #include <stdlib.h>
  |
  6 void doo(void){
  7   char doo_s[100];
  8
  9   doo_s[99] = 0;
 10   return;
 11 }
 12
 13 void boo(void){
 14   char boo_s[10];
 15
 16   boo_s[9] = 0;
 17
 18   return;
 19 }
 20
 21 void foo(void){
 22   long foo_v;
 23
 24   foo_v = 123;
 25
 26   return;
 27 }
 28
 29 int main(void){
 30   
 31
 32   foo();
 33   boo();
 34   doo();
 35
 36   
 37
 38   return 0;
 39 }

[2] trace when executing the client
  1 X START 0:1348 at 0
  2 X THREAD_CREATE 0:1
  3 S ffeffd408 8 1 S main
  4 L ffeffd408 8 1 S main
  5 new_stack @addr: ffeffd3b8, len: 8
  6 new_stack @addr: ffeffd3b0, len: 8
  7 S ffeffd3b8 8 1 S main
  8 S ffeffd3b0 8 1 S foo
  9 S ffeffd3a8 8 1 S foo LV foo_v
 10 die_stack @addr: ffeffd3b0, len: 8
 11 die_stack @addr: ffeffd3b8, len: 8
 12 L ffeffd3b0 8 1 S foo
 13 L ffeffd3b8 8 1 S foo
 14 new_stack @addr: ffeffd3b8, len: 8
 15 new_stack @addr: ffeffd3b0, len: 8
 16 S ffeffd3b8 8 1 S main
 17 S ffeffd3b0 8 1 S boo
 18 S ffeffd3a9 1 1 S boo LS boo_s[9]
 19 die_stack @addr: ffeffd3b0, len: 8
 20 die_stack @addr: ffeffd3b8, len: 8
 21 L ffeffd3b0 8 1 S boo
 22 L ffeffd3b8 8 1 S boo
 23 new_stack @addr: ffeffd3b8, len: 8
 24 new_stack @addr: ffeffd3b0, len: 8
 25 S ffeffd3b8 8 1 S main
 26 S ffeffd3b0 8 1 S doo
 27 S ffeffd3a3 1 1 S doo LS doo_s[99]
 28 die_stack @addr: ffeffd3b0, len: 8
 29 die_stack @addr: ffeffd3b8, len: 8
 30 L ffeffd3b0 8 1 S doo LS doo_s[16]
 31 L ffeffd3b8 8 1 S doo LS doo_s[24]
 32 S ffeffd3d0 8 1 S main LS _zzq_args[0]
 33 S ffeffd3d8 8 1 S main LS _zzq_args[1]
 34 S ffeffd3e0 8 1 S main LS _zzq_args[2]
 35 S ffeffd3e8 8 1 S main LS _zzq_args[3]
 36 S ffeffd3f0 8 1 S main LS _zzq_args[4]
 37 S ffeffd3f8 8 1 S main LS _zzq_args[5]
 38 X INST 141791
 39 X END 1348 at 141791





--
View this message in context: 
http://valgrind.10908.n7.nabble.com/track-new-mem-stack-vs-track-new-mam-stack-signal-tp50932.html
Sent from the Valgrind - Users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to