This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Trapping malloc using systemtap
- From: "Frank Ch. Eigler" <fche at redhat dot com>
- To: deepak dot venkatesh at wipro dot com
- Cc: systemtap at sourceware dot org, giribalaji dot ragavan at wipro dot com
- Date: Wed, 23 Feb 2011 07:32:40 -0500
- Subject: Re: Trapping malloc using systemtap
- References: <81939A763626854B8ECA106278B28F3402D06ADC@BLR-SJP-MBX02.wipro.com>
Hi -
deepak.venkatesh wrote:
> [...]
> How can I probe the function call to malloc. Also how can I get
> return value of malloc in systemtap script considering the below piece
> of code.
> [...]
> The steps I followed:
> $ gcc -g test.c #which generated a.out file
> $ stap -e 'probe process("a.out").function("malloc")
> {print_ubacktrace()}' -c './a.out'
The problem here is that the malloc function is not *defined* in the
a.out process, only referenced from there. At this time, we have no
syntax for probing the shared library PLT to trap references
(PR12215). However, we can probe the definition site in the shared
library:
probe process("/lib*/libc.so.*").function("malloc") {}
To grab the return value:
probe process("/lib*/libc.so.*").function("malloc").return {
do_something_with($return)
}
> Also can you please tell me whether system tap supports static linking
> of shared libraries. If yes, please direct me to the corresponding page.
systemtap does not get involved in how you link your programs. If you
link libc statically, your original process("a.out").function("malloc")
probe would probably work.
- FChE