namhyung / uftrace

Function graph tracer for C/C++/Rust/Python
https://uftrace.github.io/slide/
GNU General Public License v2.0
3.01k stars 441 forks source link

Function Argument: Support for fetching value of pointer argument #840

Open DanielTimLee opened 5 years ago

DanielTimLee commented 5 years ago
int do_load_unload_xdp(int *progfd, enum net_load_type *load_type, int *ifindex)

$ F=do_load_unload_xdp
$ uftrace -A $F@arg1 -F $F -a $B net load id 16 xdp enp3s0
# DURATION     TID     FUNCTION
            [ 18362] | do_load_unload_xdp(0x7ffdfef04980) {
   1.678 us [ 18362] |   memset(0x7ffff1c44bbc, 0, 12);
   6.171 us [ 18362] |   socket(AF_NETLINK, SOCK_RAW, 0) = 5;
   2.969 us [ 18362] |   setsockopt();
   4.629 us [ 18362] |   bind(5, 0x7ffff1c44bbc, 12) = 0;
   1.467 us [ 18362] |   getsockname();
   0.323 us [ 18362] |   memset(0x7ffff1c44c10, 0, 96);
  17.763 us [ 18362] |   send();
   4.658 us [ 18362] |   recv();
   3.930 us [ 18362] |   close(5) = 0;
  51.869 us [ 18362] | } /* do_load_unload_xdp */

At here, when using function argument (-A), as we can see we can only figure out the pointer value of the function argument.

It would be really helpful if function argument supports fetching the value which is pointed by the pointer.

honggyukim commented 5 years ago

I also think that this is needed in some cases, but it also has a risk to crash the target program if the pointer value doesn't point to properly allocated memory location. It may be used as follows:

-A foo@arg1/*i32 -A bar@arg1/*u8
namhyung commented 5 years ago

Usually pointers are for complex data structure like struct or union. So we should support such aggregate types then.

DanielTimLee commented 5 years ago

So is it worth to implement it? Or should we avoid implementing it because of difficulties?