一,工具简介

ucalls工具总结了包括Java、Perl、PHP、Python、Ruby、Tcl和Linux系统调用在内的各种高级语言中的方法调用。它显示最常调用方法的统计信息,以及这些方法的延迟(持续时间)。

通过系统调用支持,ucalls可以提供关于进程与系统交互的基本信息,包括系统调用计数和延迟。然后,可以使用其他BCC工具(如trace、argdist、biotop、fileslower等)进一步探索这些信息。

二,代码示例

#!/usr/bin/pythonfrom __future__ import print_functionimport argparsefrom time import sleepfrom bcc import BPF, USDT, utilsfrom bcc.syscall import syscall_namelanguages = ["java", "perl", "php", "python", "ruby", "tcl"]examples = """examples:./ucalls -l java 185# trace Java calls and print statistics on ^C./ucalls -l python 2020 1 # trace Python calls and print every second./ucalls -l java 185 -S # trace Java calls and syscalls./ucalls 6712 -S# trace only syscall counts./ucalls -l ruby 1344 -T 10 # trace top 10 Ruby method calls