-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcallprofiler
More file actions
executable file
·81 lines (64 loc) · 1.86 KB
/
callprofiler
File metadata and controls
executable file
·81 lines (64 loc) · 1.86 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/python3
#
# callprofiler.py
#
###########################################################################
#
# cscope command line searches
# cscope.out should have been built.
#
# cscope -d -R -L<n> where n is one of ...
# 0: Find this C symbol
# 1: Find this definition
# 2: Find functions called by this function
# 3: Find functions calling this function
# 4: Find this text string
# 6: Find this egrep pattern
# 7: Find this file
# 8: Find files #including this file
# 9: Find places where this symbol is assigned a value
#
###########################################################################
#
# Find the callers at the first tier and store them in a list.
#
import sys
import os
import subprocess
from subprocess import Popen, PIPE, STDOUT
import array
import numpy as np # efficient memory management
scriptname = os.path.basename(__file__)
# scriptname = sys.argv[0]
usagestr = """
Trace callers of the named function. Without a named directory, the trace
will be kernel-wide.
NOTE: Must have cscope.out in the Current Working Directory.
Current Working Directory must be the top of a linux kernel tree.
Current Working Directory: $BLD$PWD$OFF
Arguments:
function - function to trace
directory - limits search to the named directory and its subdirectories
Options:
-h - help
"""
def usage():
print("\n%s function [directory]" % scriptname)
print(usagestr)
def get_callers(func):
print("Getting ", func)
args = ["cscope", "-d", "-R", "-L3", func]
p = Popen(args, shell=True, stdout=PIPE)
output = p.communicate()
#callers = str(output)
#callers = callers.split('\\n')
# callers = process.communicate()
#print("length: ", len(callers))
#for line in range(len(callers)):
# print(callers[line])
def main():
# usage()
func = sys.argv[1]
get_callers(func)
return 0
exit(main())