forked from OpenSDV/Linux_Kernel_map4vehicle
fix spacing
This commit is contained in:
parent
71124571d1
commit
e1c7f3643b
22
srcxray.py
22
srcxray.py
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
#
|
#
|
||||||
# srcxray - source code X-ray
|
# srcxray - source code X-ray
|
||||||
#
|
#
|
||||||
# Analyzes interconnections between functions and structures in source code.
|
# Analyzes interconnections between functions and structures in source code.
|
||||||
#
|
#
|
||||||
|
@ -20,14 +20,16 @@ level_limit = 7
|
||||||
limit = 10000
|
limit = 10000
|
||||||
n = 0
|
n = 0
|
||||||
|
|
||||||
|
|
||||||
def print_limited(a):
|
def print_limited(a):
|
||||||
print(a)
|
print(a)
|
||||||
global n
|
global n
|
||||||
n +=1
|
n += 1
|
||||||
if n > limit:
|
if n > limit:
|
||||||
print('Reached limit')
|
print('Reached limit')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def log(*args, **kwargs):
|
def log(*args, **kwargs):
|
||||||
print(inspect.stack()[1][3], str(*args).rstrip(), file=sys.stderr, **kwargs)
|
print(inspect.stack()[1][3], str(*args).rstrip(), file=sys.stderr, **kwargs)
|
||||||
pass
|
pass
|
||||||
|
@ -54,13 +56,13 @@ def extract_referer_test():
|
||||||
"f=bad (*good)()",
|
"f=bad (*good)()",
|
||||||
"f=int FNAME(good)(a)",
|
"f=int FNAME(good)(a)",
|
||||||
"f=TRACE_EVENT(a)",
|
"f=TRACE_EVENT(a)",
|
||||||
"f: a=in bad()" }:
|
"f: a=in bad()"}:
|
||||||
print(a, '->', extract_referer(a))
|
print(a, '->', extract_referer(a))
|
||||||
|
|
||||||
def func_referers_git_grep(name):
|
def func_referers_git_grep(name):
|
||||||
res = []
|
res = []
|
||||||
r = None
|
r = None
|
||||||
for line in popen(r'git grep --no-index --word-regexp --show-function "^\s.*\b%s"'%(name)):
|
for line in popen(r'git grep --no-index --word-regexp --show-function "^\s.*\b%s"' % (name)):
|
||||||
# Filter out names in comment afer function, when comment start from ' *'
|
# Filter out names in comment afer function, when comment start from ' *'
|
||||||
# To see the problem try "git grep -p and"
|
# To see the problem try "git grep -p and"
|
||||||
if re.match(r'.*: \* ', line):
|
if re.match(r'.*: \* ', line):
|
||||||
|
@ -80,7 +82,7 @@ def func_referers_cscope(name):
|
||||||
print("Recommended: cscope -bkR", file=sys.stderr)
|
print("Recommended: cscope -bkR", file=sys.stderr)
|
||||||
cscope_warned = True
|
cscope_warned = True
|
||||||
return []
|
return []
|
||||||
res = [ l.split()[1] for l in popen(r'cscope -d -L3 "%s"'%(name)) if not l in black_list]
|
res = [l.split()[1] for l in popen(r'cscope -d -L3 "%s"'%(name)) if not l in black_list]
|
||||||
if not res:
|
if not res:
|
||||||
res = func_referers_git_grep(name)
|
res = func_referers_git_grep(name)
|
||||||
return res
|
return res
|
||||||
|
@ -88,7 +90,7 @@ def func_referers_cscope(name):
|
||||||
def func_referers_all(name):
|
def func_referers_all(name):
|
||||||
return set(func_referers_git_grep(name) + func_referers_cscope(name))
|
return set(func_referers_git_grep(name) + func_referers_cscope(name))
|
||||||
|
|
||||||
def referers_tree(name, referer = None, printed = None, level = 0):
|
def referers_tree(name, referer=None, printed = None, level = 0):
|
||||||
if not referer:
|
if not referer:
|
||||||
if os.path.isfile('cscope.out'):
|
if os.path.isfile('cscope.out'):
|
||||||
referer = func_referers_cscope
|
referer = func_referers_cscope
|
||||||
|
@ -122,17 +124,17 @@ def call_tree(node, printed = None, level = 0):
|
||||||
if printed == None: printed = set()
|
if printed == None: printed = set()
|
||||||
if node in printed:
|
if node in printed:
|
||||||
limit= - 1
|
limit= - 1
|
||||||
print_limited(level*'\t' + node + '^')
|
print_limited(level*'\t' + node + ' ^')
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
print_limited(level*'\t' + node)
|
print_limited(level*'\t' + node)
|
||||||
printed.add(node)
|
printed.add(node)
|
||||||
if level > level_limit - 2 :
|
if level > level_limit - 2:
|
||||||
print_limited((level + 1)*'\t' + '...')
|
print_limited((level + 1)*'\t' + '...')
|
||||||
return ''
|
return ''
|
||||||
local_printed = set()
|
local_printed = set()
|
||||||
for line in popen('cscope -d -L2 "%s"'%(node)):
|
for line in popen('cscope -d -L2 "%s"'%(node)):
|
||||||
I = line.split()[1];
|
I = line.split()[1]
|
||||||
if I in local_printed or I in black_list: continue;
|
if I in local_printed or I in black_list: continue;
|
||||||
local_printed.add(I)
|
local_printed.add(I)
|
||||||
try:
|
try:
|
||||||
|
@ -158,7 +160,7 @@ def main():
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
print('Run', me, 'usage')
|
print('Run', me, 'usage')
|
||||||
else:
|
else:
|
||||||
if '(' in sys.argv[1]:
|
if '(' in sys.argv[1]:
|
||||||
ret = eval(sys.argv[1])
|
ret = eval(sys.argv[1])
|
||||||
else:
|
else:
|
||||||
ret = eval(sys.argv[1] + '(' + ', '.join("'%s'"%(a) for a in sys.argv[2:]) + ')')
|
ret = eval(sys.argv[1] + '(' + ', '.join("'%s'"%(a) for a in sys.argv[2:]) + ')')
|
||||||
|
|
Loading…
Reference in New Issue