From 2b82d76bbde9764e5f914b523a5ed8285e18870d Mon Sep 17 00:00:00 2001 From: Bojun Seo Date: Thu, 7 Nov 2024 18:35:09 +0900 Subject: [PATCH] tools/threadsnoop: Add -h option Import argparser and add basic implementation for this. Now user can use -h option for threadsnoop tool. --- tools/threadsnoop.py | 14 ++++++++++++++ tools/threadsnoop_example.txt | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/tools/threadsnoop.py b/tools/threadsnoop.py index fcf28e20a283..7285730db861 100755 --- a/tools/threadsnoop.py +++ b/tools/threadsnoop.py @@ -14,6 +14,20 @@ from __future__ import print_function from bcc import BPF +import argparse + +examples = """examples: + ./threadsnoop # list new thread creation +""" + +description = """ +List new thread creation. +""" + +parser = argparse.ArgumentParser(description=description, + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=examples) +args = parser.parse_args() # load BPF program b = BPF(text=""" diff --git a/tools/threadsnoop_example.txt b/tools/threadsnoop_example.txt index e65b503fa4a6..6fa4fd3a23a3 100644 --- a/tools/threadsnoop_example.txt +++ b/tools/threadsnoop_example.txt @@ -25,3 +25,16 @@ The output shows a dockerd process creating several threads with the start routine threadentry(), and docker-containe (truncated) and systemd-journal also starting threads: in their cases, the function had no symbol information available, so their addresses are printed in hex. + +USAGE message: + +# ./threadsnoop.py -h +usage: threadsnoop.py [-h] + +List new thread creation. + +options: + -h, --help show this help message and exit + +examples: + ./threadsnoop # list new thread creation