Skip to content

uftrace v0.16

Latest
Compare
Choose a tag to compare
@namhyung namhyung released this 25 Apr 03:49
· 27 commits to master since this release

From now on, it supports reading symbol and debug information from the
separate debug files which are usually installed with debug packages.
This can be useful when you trace system binaries which may be stripped.

For example, you can only see library calls for such a binary. Let's
trace pwd program which just prints the current directory name.

$ nm /usr/bin/pwd
nm: /usr/bin/pwd: no symbols

$ uftrace pwd
uftrace: /home/namhyung/project/uftrace/cmds/record.c:1677:check_binary
 ERROR: Can't find 'mcount' symbol in the '/usr/bin/pwd'.
    It seems not to be compiled with -pg or -finstrument-functions flag.
    You can rebuild your program with it or use -P option for dynamic tracing.

$ uftrace -P. pwd
/home/namhyung/tmp
# DURATION     TID     FUNCTION
   3.156 us [955818] | getenv();
   0.739 us [955818] | strrchr();
 488.277 us [955818] | setlocale();
   1.372 us [955818] | bindtextdomain();
   0.886 us [955818] | textdomain();
   0.703 us [955818] | __cxa_atexit();
   5.760 us [955818] | getopt_long();
   5.014 us [955818] | getcwd();
  11.120 us [955818] | puts();
   0.597 us [955818] | free();
...

But if you install the debug package, it can see the symbols and enable
the dynamic tracing as well.

$ sudo apt install coreutils-dbgsym

$ uftrace -P. -F main pwd
/home/namhyung/tmp
# DURATION     TID     FUNCTION
            [955863] | main() {
   1.779 us [955863] |   getenv();
            [955863] |   set_program_name() {
   0.423 us [955863] |     strrchr();
   0.734 us [955863] |   } /* set_program_name */
 222.047 us [955863] |   setlocale();
   1.089 us [955863] |   bindtextdomain();
   0.461 us [955863] |   textdomain();
            [955863] |   atexit() {
   0.604 us [955863] |     __cxa_atexit();
   0.850 us [955863] |   } /* atexit */
   0.992 us [955863] |   getopt_long();
            [955863] |   xgetcwd() {
   1.337 us [955863] |     getcwd();
   1.668 us [955863] |   } /* xgetcwd */
   7.242 us [955863] |   puts();
   0.312 us [955863] |   free();
 240.040 us [955863] | } /* main */

The next change is to support octal format argument which is usally used
in the library functions dealing with filesystems. It used to have a
predefined set of mode bits like 0755 and 0644 as an enum data type. But
obviously it cannot support all combination and shows broken numbers for
them. Now it works as expected with octal arguments.

$ uftrace -F .*chmod.* -a -- chmod 747 myfile
# DURATION     TID     FUNCTION
 173.103 us [963584] | fchmodat(-100, "myfile", 0747, 0) = 0;

Also uftrace report got two new output fields of (relative) standard
deviation for total and self time respectively. It'll be added when one
of --avg-total or --avg-self option is used.

$ uftrace report --avg-total
   Total avg   Total min   Total max  Total stdv  Function
  ==========  ==========  ==========  ==========  ====================
  671.447 us  671.447 us  671.447 us       0.00%  setlocale
   15.323 us   15.323 us   15.323 us       0.00%  puts
    8.458 us    8.458 us    8.458 us       0.00%  getopt_long
    7.044 us    7.044 us    7.044 us       0.00%  getcwd
    4.116 us    4.116 us    4.116 us       0.00%  getenv
    1.908 us    1.476 us    2.340 us      22.64%  fclose
    1.843 us    1.843 us    1.843 us       0.00%  bindtextdomain
    1.307 us    1.307 us    1.307 us       0.00%  __cxa_atexit
    1.294 us    1.294 us    1.294 us       0.00%  strrchr
    1.147 us    1.147 us    1.147 us       0.00%  textdomain
    0.980 us    0.980 us    0.980 us       0.00%  free
    0.734 us    0.251 us    1.217 us      65.80%  __fpending
    0.692 us    0.258 us    1.126 us      62.72%  fileno
    0.674 us    0.283 us    1.065 us      58.01%  fflush
    0.440 us    0.167 us    1.109 us      88.12%  __freading

There are also more fixes and improvements. Notably it got big improvements
in Python tracing. So it can now trace sizeable projects written in Python
thanks to bug fixes in the debug file handling and symbol management without
affecting GC. Also there's a bug fix for library call tracing.

What's Changed

New Contributors

Full Changelog: v0.15...v0.16