Skip to content

Commit

Permalink
Utilities/StaticAnayzers: Update script for generating ESR::get report.
Browse files Browse the repository at this point in the history
    Update regex used for finding top level functions and ESR::get function calls.
    Update module_to_package.yaml with mapping used in circles graph
  • Loading branch information
gartung committed Jul 7, 2021
1 parent ac5ca81 commit 533e372
Show file tree
Hide file tree
Showing 2 changed files with 4,495 additions and 16 deletions.
21 changes: 5 additions & 16 deletions Utilities/StaticAnalyzers/scripts/callgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,16 @@
topfunc = re.compile(r"::(accumulate|acquire|startingNewLoop|duringLoop|endOfLoop|beginOfJob|endOfJob|produce|analyze|filter|beginLuminosityBlock|beginRun|beginStream|streamBeginRun|streamBeginLuminosityBlock|streamEndRun|streamEndLuminosityBlock|globalBeginRun|globalEndRun|globalBeginLuminosityBlock|globalEndLuminosityBlock|endRun|endLuminosityBlock)\(")

baseclass = re.compile(
r"edm::(one::|stream::|global::)?(ED(Producer|Filter|Analyzer|(IterateNTimes|NavigateEvents)?Looper)(Base)?|impl::(ExternalWork|Accumulator))")
r"(edm::)?(one::|stream::|global::)?((DQM)?(Global|One)?ED(Producer|Filter|Analyzer|(IterateNTimes|NavigateEvents)?Looper)(Base)?|impl::(ExternalWork|Accumulator))")
farg = re.compile(r"\(.*?\)")
tmpl = re.compile(r'<.*?>')
toplevelfuncs = set()
epfuncre = re.compile(r"edm::eventsetup::EventSetupRecord::get<.*>\(.*\)")
epfuncre = re.compile(r"edm::eventsetup::EventSetupRecord::get<class edm::ESHandle<class .*>>(.*) const")
skipfunc = re.compile(r"TGraph::IsA\(.*\)")
epfuncs = set()

G = nx.DiGraph()

# g = open('module_to_package.txt')
# module2package=dict()
# for line in g:
# fields = line.strip().split(';')
# if len(fields) <2:
# continue
# module2package.setdefault(fields[1], []).append(fields[0])
#
# i = open('module_to_package.yaml', 'w')
# yaml.dump(module2package, i)
# i.close()

h = open('module_to_package.yaml', 'r')
module2package = yaml.load(h, Loader=yaml.FullLoader)

Expand Down Expand Up @@ -62,7 +50,7 @@
cs = str("")
previous = str("")
for p in path:
if epfuncre.search(p):
if epfuncre.match(p):
break
stripped = re.sub(farg, "()", p)
if previous != stripped:
Expand All @@ -75,9 +63,10 @@
report = dict()
for key in sorted(module2package.keys()):
for value in sorted(module2package[key]):
vre = re.compile(' %s::.*();' % value)
for cs in sorted(callstacks):
vre = re.compile(' %s::.*();' % value)
if vre.search(cs):
print(value, key, cs)
report.setdefault(key, {}).setdefault(value, []).append(cs)
r = open('eventsetuprecord-get.yaml', 'w')
yaml.dump(report, r)
Loading

0 comments on commit 533e372

Please sign in to comment.