Este contenido no está disponible en el idioma seleccionado.
Chapter 24. Creating uprobes with perf
24.1. Creating uprobes at the function level with perf Copiar enlaceEnlace copiado en el portapapeles!
You can use the perf tool to create dynamic tracepoints at arbitrary points in a process or application. These tracepoints can then be used in conjunction with other perf tools such as perf stat and perf record to better understand the process or applications behavior.
Prerequisites
-
You have the
perfuser space tool installed as described in Installing perf.
Procedure
Create the uprobe in the process or application you are interested in monitoring at a location of interest within the process or application:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
24.2. Creating uprobes on lines within a function with perf Copiar enlaceEnlace copiado en el portapapeles!
These tracepoints can then be used in conjunction with other perf tools such as perf stat and perf record to better understand the process or applications behavior.
Prerequisites
-
You have the
perfuser space tool installed as described in Installing perf. You have gotten the debugging symbols for your executable:
objdump -t ./your_executable | head
# objdump -t ./your_executable | headCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteTo do this, the
debuginfopackage of the executable must be installed or, if the executable is a locally developed application, the application must be compiled with debugging information, the-goption in GCC.
Procedure
View the function lines where you can place a uprobe:
perf probe -x ./your_executable -L main
$ perf probe -x ./your_executable -L mainCopy to Clipboard Copied! Toggle word wrap Toggle overflow Output of this command looks similar to:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the uprobe for the desired function line:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
24.3. Perf script output of data recorded over uprobes Copiar enlaceEnlace copiado en el portapapeles!
A common method to analyze data collected using uprobes is using the perf script command to read a perf.data file and display a detailed trace of the recorded workload.
In the perf script example output:
- A uprobe is added to the function isprime() in a program called my_prog
- a is a function argument added to the uprobe. Alternatively, a could be an arbitrary variable visible in the code scope of where you add your uprobe: