Skip to content

Error finding location for probe (usdt) #328

@DavidVentura

Description

@DavidVentura

I started playing with bpftrace and bcc tools, but I cannot get bpftrace to work with usdt probes. bcc's trace works fine.

Issue:

$ sudo ./build/src/bpftrace  -e 'usdt:/home/david/git/bpftrace/a.out:testprobe { time("%H:%M:%S  "); printf("%-6d %d\n", pid, arg0); }'
Attaching 1 probe...
Error finding location for probe: usdt:/home/david/git/bpftrace/a.out:testprobe

bcc on the same binary

$ sudo ../../bcc/tools/trace.py   'u:/home/david/git/bpftrace/a.out:testprobe "%d" retval'
PID     TID     COMM            FUNC             -
7442    7442    a.out           testprobe        1547067909
7442    7442    a.out           testprobe        1547067910

example code from here

$ cat test.c                                                                                                                                                                                                                                                                                
#include <sys/sdt.h>                                                                                                                                                                                                                                                                                                         
#include <sys/time.h>                                                                                                                                                                                                                                                                                                        
#include <unistd.h>                                                                                                                                                                                                                                                                                                          
#include <stdio.h>                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                             
long int myclock() {                                                                                                                                                                                                                                                                                                         
    struct timeval tv;                                                                                                                                                                                                                                                                                                       
    gettimeofday(&tv, NULL);                                                                                                                                                                                                                                                                                                 
    //printf("%ld\n", tv.tv_sec);
    DTRACE_PROBE1(test-app, testprobe, tv.tv_sec);
    return tv.tv_sec;
}

int main(int argc, char **argv)
{

    while(1) {
        myclock();
        sleep(1);
    }
    return 0;
}

Using an uretprobe on the function works though

$ sudo ./build/src/bpftrace  -e 'uretprobe:/home/david/git/bpftrace/a.out:myclock { time("%H:%M:%S  "); printf("%-6d %d\n", pid, retval); }'
Attaching 1 probe...
22:13:17  7660   1547068397
22:13:18  7660   1547068398

What am I doing wrong? I am on HEAD on both projects..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions