|
From: Janne H. <ja...@hy...> - 2006-10-04 16:16:16
|
Hi all, We do embedded development and have generally very limited amount of stack space available (4-8KB or so). Is it somehow possible to use valgrind to track how many bytes of stack is used during the execution of an application? Just getting the peak usage is enough for us. I remember trying to do it with massif, but IIRC I couldn't get fine-grained enough results out of it. Is this possible out of the box or should I look into patching say massif myself? If patching is the only option, what would be the best place to start? Thank you so much for valgrind! Janne |
|
From: Nicholas N. <nj...@cs...> - 2006-10-04 22:09:58
|
On Wed, 4 Oct 2006, Janne Hellsten wrote:
> We do embedded development and have generally very limited amount of
> stack space available (4-8KB or so). Is it somehow possible to
> use valgrind to track how many bytes of stack is used during the
> execution of an application? Just getting the peak usage is enough
> for us. I remember trying to do it with massif, but IIRC I couldn't
> get fine-grained enough results out of it.
>
> Is this possible out of the box or should I look into patching say
> massif myself? If patching is the only option, what would be the best
> place to start?
Easier would be writing a new tool from scratch.
This probably sounds intimidating, but it shouldn't be. Use "nulgrind" (the
tool that does nothing) as the starting point, and have it register callback
functions for the "new_mem_stack" and "die_mem_stack" functions, which are
called every time the SP changes. See VG_(track_{new,die}_mem_stack) in
include/pub_tool_tooliface.h.
Nick
|
|
From: Janne H. <jjh...@gm...> - 2006-10-05 19:57:22
|
> Easier would be writing a new tool from scratch.
>
> This probably sounds intimidating, but it shouldn't be. Use "nulgrind" (the
> tool that does nothing) as the starting point, and have it register callback
> functions for the "new_mem_stack" and "die_mem_stack" functions, which are
> called every time the SP changes. See VG_(track_{new,die}_mem_stack) in
> include/pub_tool_tooliface.h.
Thanks for the tip! I modified the nulgrind tool to track the SP extremes.
I'd like to be able to control my tool from inside my instrumented
application. I thought that a pretty easy interface for this would be
to register my own software interrupt handler. This way I could
control my tool with a couple of syscalls. Is there an easier way to
do this? I'd rather not make the instrumented app depend on valgrind
header files to make it easier to build.
Janne
|
|
From: Janne H. <jjh...@gm...> - 2006-10-06 09:01:40
|
> I'd like to be able to control my tool from inside my instrumented > application. I thought that a pretty easy interface for this would be > to register my own software interrupt handler. This way I could > control my tool with a couple of syscalls. Is there an easier way to > do this? I'd rather not make the instrumented app depend on valgrind > header files to make it easier to build. Looks like I came into this conclusion a bit hastily. Reading through the documentation & code has convinced me that using the valgrind client request mechanism is a better way to control my tool. Janne |