My application was built using library libmtmalloc.so.1 in which "malloc" and 
"free" is used for memory allocation and deallocation.  

When I wanted to use DTrace ( I am using Solaris 10) to trace application's 
memory usage, I could not get the address of the allocated memory in probe 
"malloc:return".


Below is my D script:

----------------
#!/usr/sbin/dtrace -s

pid$1:libmtmalloc.so.1:malloc:entry
{
 self->trace = 1;
 self->size = arg0;
}

pid$1:libmtmalloc.so.1:malloc:return
/self->trace == 1/
{
 printf("Ptr=0x%p Size=%d", arg1, self->size);
 ustack();
 self->trace = 0;
 self->size = 0;
}
pid$1:libmtmalloc.so.1:free:entry
{
 printf("Ptr=0x%p ", arg0);
 ustack();
}
... ...

---------------------------


The output of the D script is as follows:

CPU     ID                    FUNCTION:NAME
  0  49823                    malloc:return Ptr=0x1f4 Size=500
              libmtmalloc.so.1`malloc+0x9c
              a.out`0x10e7c
              a.out`0x10e48

  0  49826                       free:entry Ptr=0xca068
              libmtmalloc.so.1`free
              a.out`0x10e98
              a.out`0x10e48

So, I can't get the address allocated by malloc in proble "malloc:return".  I 
tried printing out our arguments, such as arg0, arg1 and arg2, none of them 
looks like the address value.  Actually in probe "malloc:return", arg1 equals 
the size of the memory to be allocated ( 0x1f4 == 500 ), instead of the address 
of the memory.

If I use malloc of libary libc.so.1, everything goes well.
 
 
This message posted from opensolaris.org
_______________________________________________
opensolaris-help mailing list
[email protected]

Reply via email to