• Yonghong Song's avatar
    usdt: permit each probe to have locations from more than one binary path · 24894573
    Yonghong Song authored
    Fixing issue #1515.
    
    Currently, each usdt probe (provider, probe_name) can only
    have locations from the single binary. It is possible that
    USDT probes are defined in a header file which eventually causes
    the same usdt probe having locations in several different
    binary/shared_objects. In such cases, we are not able to attach
    the same bpf program to all these locations.
    
    This patch addresses this issue by defining each location to
    be `bin_path + addr_offset` vs. previous `addr_offset` only.
    This way, each internal Probe class can represent all locations
    for the same (provider, probe_name) pair.
    
    The `tplist.py` output is re-organized with the (provider, probe_name)
    in the top level like below:
    ```
    ...
    rtld:lll_futex_wake [sema 0x0]
      location #1 /usr/lib64/ld-2.17.so 0xaac8
        argument #1 8 unsigned bytes @ di
        argument #2 4 signed   bytes @ 1
        argument #3 4 signed   bytes @ 0
      location #2 /usr/lib64/ld-2.17.so 0xe9b9
        argument #1 8 unsigned bytes @ di
        argument #2 4 signed   bytes @ 1
        argument #3 4 signed   bytes @ 0
      location #3 /usr/lib64/ld-2.17.so 0xef3b
        argument #1 8 unsigned bytes @ di
        argument #2 4 signed   bytes @ 1
        argument #3 4 signed   bytes @ 0
    ...
    ```
    
    Tested with the following commands
    ```
      tplist.py
      trace.py -p <pid> 'u::probe "arg1 = %d", arg1'
      trace.py u:<binary_path>:probe "arg1 = %d", arg1'
      argdist.py -p <pid> 'u::probe():s64:arg1'
      argdist.py -C 'u:<binary_path>:probe():s64:arg1'
      funccount.py -p <pid> 'u:<binary_path>:probe'
      funccount.py 'u:<binary_path>:probe'
    ```
    Signed-off-by: default avatarYonghong Song <yhs@fb.com>
    24894573
tplist_example.txt 4.4 KB