一,stacksnoop简介
stacksnoop用于跟踪内核函数,并打印出所有的内核栈。
二,代码示例
#!/usr/bin/python# USAGE: stacksnoop [-h] [-p PID] [-s] [-v] functionfrom __future__ import print_function
from bcc import BPF
import argparse
import time# 参数
examples = """examples:./stacksnoop ext4_sync_fs # print kernel stack traces for ext4_sync_fs./stacksnoop -s ext4_sync_fs # ... also show symbol offsets./stacksnoop -v ext4_sync_fs # ... show extra columns./stacksnoop -p 185 ext4_sync_fs # ... only when PID 185 is on-CPU
"""
parser = argparse.ArgumentParser(description="Trace and print kernel stack traces for a kernel function",formatter_class=argparse.RawDescriptionHelpFormatter,epilog=examples)
parser.add_argument("-p", "--pid",help="trace this PID only")
parser.add_argument("-s", "--offset", action&#