[PATCH v3 3/3] trace-cruncher: Example for event probes API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



trace-cruncher APIs should have examples, to demonstrate their usage
in a real use case. Added an example for newly introduced event
probes API.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@xxxxxxxxx>
---
 examples/eprobe.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100755 examples/eprobe.py

diff --git a/examples/eprobe.py b/examples/eprobe.py
new file mode 100755
index 0000000..85b0685
--- /dev/null
+++ b/examples/eprobe.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+
+"""
+SPDX-License-Identifier: CC-BY-4.0
+
+Copyright 2022 VMware Inc, Tzvetomir Stoyanov (VMware) <tz.stoyanov@xxxxxxxxx>
+"""
+
+import sys
+
+import tracecruncher.ftracepy as ft
+import tracecruncher.ft_utils as tc
+
+open_probe = ft.eprobe(event='sopen_in', target_system='syscalls',
+                       target_event='sys_enter_openat', fetchargs='file=+0($filename):ustring')
+
+tep = tc.local_tep()
+
+def callback(event, record):
+    print(tep.info(event, record))
+
+if __name__ == "__main__":
+    if len(sys.argv) < 2:
+        print('Usage: ', sys.argv[0], ' [PROCESS]')
+        sys.exit(1)
+
+    inst = ft.create_instance(tracing_on=False)
+    open_probe.enable(instance=inst)
+    ft.trace_process(instance=inst, argv=sys.argv[1:])
-- 
2.34.1




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux