|
From: T. S. N. <tse...@ya...> - 2006-05-17 14:56:28
|
Dear Team,
Following is the bug report and reply from
Mr.Nicholas Nethercote.With respect to that, I would
like to get help from your team for getting the exact
stack usage of an application.
The stack are getting measured in massif option only
when there are some heap operations
malloc/calloc/free). But I would like to register the
stack values used when any function is called/returned
and present the actual picture of peak stack usage.
Please suggest me what and where are the modification
required for it to achieve this. Kindly do the needful
as soon as possible.
Thanking you,
T.Senthil Nathan.
BUG REPORT :
Dear Team,
I am trying to write a small program to find stack
utilization. The program is as follows.
void main()
{
sleep(10);
sleep(10);
}
The above program will have change in stack usage when
sleep is called twice.
The program is compiled by the following command "gcc
-g test.c -o test"
The valgrind command is executed to check the stack
usge by the following command
valgrind --tool=massif --heap=no --heap-admin=no test
From the .hp file generated I could find only 2 sample
one at MARK 0 with stack value 0, and the other one at
MARK 21004(End of the program) with value 0. The stack
used by the sleep are not registered.
If the same program is modified by the following, I
could get some stack value in between. The values are
MARK 0.0 - stacks 0 , MARK 10907.0 - stacks 1724,
MARK 20913 - stacks 1724, MARK 21012 - stacks 0.
void main()
{
sleep(10);
malloc(10);
sleep(10);
malloc(10);
}
Most Probably the trigger to which the stack values
are identified is heap operations(malloc/calloc/free).
But to find the peak usage of stack or to track the
stack usage this may not be good enough.
I would like to register the stack values used when
any function is called/returned and present the actual
picture of peak stack usage.
Please let me know a solution for this problem. Kindly
do the needful.
Thanking you,
T.Senthil Nathan
------- Additional Comment #1 From Nicholas Nethercote
2006-05-15 18:03 -------
You are right that heap allocations are the trigger
for memory measurements.
Massif wasn't designed to measure stack usage
accurately. If you want this measurement you'll have
to modify Massif yourself to do it. It is definitely
possible, but not trivial to do so. You could contact
the developer's list if you need some advice on how to
go about this.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|
|
From: Nicholas N. <nj...@cs...> - 2006-05-17 16:17:00
|
On Wed, 17 May 2006, T. Senthil Nathan wrote: > Dear Team, > Following is the bug report and reply from > Mr.Nicholas Nethercote.With respect to that, I would > like to get help from your team for getting the exact > stack usage of an application. > > The stack are getting measured in massif option only > when there are some heap operations > malloc/calloc/free). But I would like to register the > stack values used when any function is called/returned > and present the actual picture of peak stack usage. > > Please suggest me what and where are the modification > required for it to achieve this. Kindly do the needful > as soon as possible. You need to register a handler for the "new_mem_stack" and "die_mem_stack" events, which are called every time the stack grows/shrinks. See memcheck/mc_main.c for an example -- it uses VG_(track_new_mem_stack)() and VG_(track_die_mem_stack)() to register the handlers. See include/pub_tool_tooliface.h for more details about the core/tool interface. You could do a census (hp_census) every time these are called, but that would be very expensive. You could instead pull the stack-measuring part of hp_census() into a separate function and just call that. Even that might be overkill. If you program doesn't have multiple stacks, you could just use the sizes passed to new_mem_stack/die_mem_stack to track the stack size. Hope this helps. Nick |