Add 6 tools tracking dbus.
[platform/upstream/bcc.git] / tools / dbus-message-type.py
1 #!/usr/bin/python
2
3 from bcc import BPF
4 from time import sleep
5 from ctypes import c_ushort, c_int, c_ulonglong
6 from sys import argv
7
8 b = BPF(src_file="dbus-message-type.c")
9
10 b.attach_uprobe(name="gio-2.0", sym="g_dbus_connection_send_message", fn_name="g_get_message_type")
11 #b.attach_uretprobe(name="dbus-1", sym="_dbus_header_get_message_type", fn_name="dbus_get_message_type")
12 b.attach_uprobe(name="dbus-1", sym="_dbus_connection_message_sent_unlocked", fn_name="message_type")
13
14 #b.trace_print()
15 count = 0
16 while(1):
17         count += 1
18         sleep(5)
19         print("%d:" % count)
20         print("%20s %20s" % ("MESSAGE_TYPE", "NUMBER\n"))
21         print("%20s %20d" % ("INVALID", b["msg_type"][0].value))
22         print("%20s %20d" % ("METHOD_CALL", b["msg_type"][1].value))
23         print("%20s %20d" % ("METHOD_RETURN", b["msg_type"][2].value))
24         print("%20s %20d" % ("ERROR", b["msg_type"][3].value))
25         print("%20s %20d" % ("SIGNAL", b["msg_type"][4].value))