Commit 86775706 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files

Address EDISOFT's pseudo-recursive nature of rtems_clock_get

parent 4d605285
......@@ -115,7 +115,7 @@ def main() -> None:
functionNamePattern = Matcher(r'^(\S+) <([a-zA-Z0-9_]+?)>:')
callPattern = Matcher(r'^.*call\s+\S+\s+<([a-zA-Z0-9_]+)>')
stackUsagePattern = Matcher(
r'^.*save.*%sp, (-([0-9]{2}|[3-9])[0-9]{2}), %sp')
r'^.*save.*%sp, (-[0-9]{1,}), %sp')
else:
binarySignature = os.popen("file \"%s\"" % sys.argv[-1]).readlines()[0]
......@@ -262,14 +262,29 @@ def main() -> None:
CheckForCycles(callGraph, badNodes)
if not badNodes:
break
badNodesPrinted = badNodes[:]
badNodesPrinted.pop()
lastStep = badNodes[-1] + " (recursive)"
badNodes.pop()
badNodes.append(lastStep)
badNodesPrinted.append(lastStep)
print("Detected cycle and will ignore these functions:\n\t",
"\n\t".join(badNodes))
"\n\t".join(badNodesPrinted))
# There are bounded recursive calls in e.g. EDISOFT's BSP
# (_Error_Report calls rtems_clock_get which calls _Error_Report,
# ...but not forever; the recursion is bounded via a global.
# To avoid propagation of "false positive recursiveness",
# don't mark this one as recursive.
# The user is supposed to use the qualified RTEMS version, that
# takes care of non-infinite recursion, etc.
for n in set(badNodes):
stackUsagePerFunction[n] = None # marked as recursive
if n == '_Error_Report':
calledFunctions = callGraph[n]
assert calledFunctions
callGraph[n] = set(
x for x in calledFunctions
if x != 'rtems_clock_get')
continue
callGraph[n] = None # marked as recursive
stackUsagePerFunction[n] = None # marked as recursive
print("Cumulative stack usage per function:")
# Then, navigate the graph to calculate stack needs per function
......@@ -278,8 +293,7 @@ def main() -> None:
if value is not None:
results.append(
(fn, findStackUsage(fn, stackUsagePerFunction, callGraph)))
# else:
# results.append((fn, 'recursive'))
results = [x for x in results if x[1] is not None]
for fn, value in sorted(results, key=operator.itemgetter(1)):
print("%10s: %s" % (value, fn))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment