-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfbt.py
More file actions
executable file
·30 lines (24 loc) · 919 Bytes
/
fbt.py
File metadata and controls
executable file
·30 lines (24 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
import functools
import usdt
class fbt(object):
"""
simple function boundary tracing decorator
"""
def __init__(self, func):
self.func = func
probename = func.__name__
self.entry_probe = usdt.Probe(probename, "entry", ["char *"])
self.return_probe = usdt.Probe(probename, "return", ["char *"])
self.provider = usdt.Provider("python-fbt", "fbt")
self.provider.add_probe(self.entry_probe)
self.provider.add_probe(self.return_probe)
self.provider.enable()
def __call__(self, *args):
self.entry_probe.fire([", ".join([str(x) for x in args])])
ret = self.func(*args)
self.return_probe.fire([str(ret)])
return ret
def __get__(self, obj, objtype):
"""Support instance methods. (http://stackoverflow.com/a/3296318)"""
return functools.partial(self.__call__, obj)