namhyung / uftrace

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

full-dynamic tracing doesn't nicely work with -F filter #775

Open honggyukim opened 5 years ago

honggyukim commented 5 years ago

Please see the following output.

$ uftrace record -P. gcc ~/hello.c

$ uftrace replay -t 10us
# DURATION     TID     FUNCTION
  51.756 us [ 30300] | setlocale();
 133.615 us [ 30300] | gettext();
  13.255 us [ 30300] | __realpath_chk();
  34.159 us [ 30300] | mkstemps();
            [ 30300] | vfork() {
            [ 30309] | } /* vfork */
            [ 30309] | execv() {
 355.139 us [ 30300] | } /* vfork */
            [ 30300] | waitpid() {
            [ 30309] | main() {
            [ 30309] |   toplev::main() {
            [ 30309] |     gcc_init_libintl() {
  57.686 us [ 30309] |       setlocale();
 173.421 us [ 30309] |       gettext();
 260.452 us [ 30309] |     } /* gcc_init_libintl */
            [ 30309] |     diagnostic_initialize() {
  17.978 us [ 30309] |       diagnostic_set_caret_max_width();
  26.049 us [ 30309] |     } /* diagnostic_initialize */
...

It shows some other library functions are executed before toplev::main. I tested to apply -F filter to toplev::main as follows:

$ uftrace record -P. -F toplev::main gcc ~/hello.c

$ uftrace replay -t 10us
# DURATION     TID     FUNCTION
  44.289 us [ 30352] | setlocale();
 136.151 us [ 30352] | gettext();
  31.806 us [ 30352] | mkstemps();
            [ 30352] | vfork() {
            [ 30361] | } /* vfork */
            [ 30361] | execv() {
 361.134 us [ 30352] | } /* vfork */
            [ 30352] | waitpid() {
            [ 30361] | toplev::main() {
            [ 30361] |   gcc_init_libintl() {
  56.928 us [ 30361] |     setlocale();
 135.535 us [ 30361] |     gettext();
 217.833 us [ 30361] |   } /* gcc_init_libintl */
            [ 30361] |   diagnostic_initialize() {
...

However, it still shows other functions from different tasks, but only hide functions from the same task.

namhyung commented 5 years ago

I guess it's in a different session and disabled the filter since the symbol is not found

namhyung commented 5 months ago

I think the toplev::main() is a function in a new executable. It's executed after execv() and the original binary didn't know about the function. So it couldn't apply the filter to the original executable and showed other functions too.

honggyukim commented 5 months ago

We currently ignore filters if nothing is matched. Can we hide everything is nothing is matched with -F and other filters? -N or -H can be counter examples though.