3 topfunc = re.compile(
"::(produce|analyze|filter|beginLuminosityBlock|beginRun|beginStream|streamBeginRun|streamBeginLuminosityBlock|streamEndRun|streamEndLuminosityBlock|globalBeginRun|globalEndRun|globalBeginLuminosityBlock|globalEndLuminosityBlock|endRun|endLuminosityBlock)\(")
4 baseclass = re.compile(
"edm::(one::|stream::|global::)?ED(Producer|Filter|Analyzer)(Base)?")
5 farg = re.compile(
"\(.*\)")
6 fre = re.compile(
"function")
10 skipfunc = re.compile(
"(edm::(LuminosityBlock::|Run::|Event::)getBy(Label|Token))|(fwlite::|edm::EDProductGetter::getIt|edm::Event::|edm::eventsetup::EventSetupRecord::get|edm::eventsetup::DataProxy::getImpl|edm::EventPrincipal::unscheduledFill|edm::ServiceRegistry::get|edm::eventsetup::EventSetupRecord::getImplementation|edm::eventsetup::EventSetupRecord::getFromProxy|edm::eventsetup::DataProxy::get|edm::serviceregistry::ServicesManager::MakerHolder::add|(cond::service::PoolDBOutputService::(writeOne|appendSinceTime|tagInfo))|edm::EventProcessor::|edm::SubProcess::)")
17 for line
in fileinput.input(files =(
'function-statics-db.txt',
'function-calls-db.txt')):
19 fields = line.split(
"'")
20 if topfunc.search(fields[1])
and not baseclass.search(fields[1]): toplevelfuncs.add(fields[1])
21 if fields[2] ==
' calls function ':
22 if skipfunc.search(line) : skipfuncs.add(line)
23 else : G.add_edge(fields[1],fields[3],kind=fields[2])
24 if fields[2] ==
' overrides function ' :
25 if baseclass.search(fields[3]) :
26 if topfunc.search(fields[3]) : toplevelfuncs.add(fields[1])
27 G.add_edge(fields[1],fields[3],kind=fields[2])
29 if skipfunc.search(line) : skipfuncs.add(line)
30 else : G.add_edge(fields[3],fields[1],kind=
' calls function ')
31 if fields[2] ==
' static variable ' :
32 G.add_edge(fields[1],fields[3],kind=fields[2])
33 statics.add(fields[3])
34 if fields[2] ==
' known thread unsafe function ' :
35 G.add_edge(fields[1],fields[3],kind=
' known thread unsafe function ')
36 statics.add(fields[3])
39 for tfunc
in sorted(toplevelfuncs):
40 for static
in sorted(statics):
41 if nx.has_path(G,tfunc,static):
42 path = nx.shortest_path(G,tfunc,static)
44 print "Non-const static variable \'"+re.sub(farg,
"()",static)+
"' is accessed in call stack '",
45 for i
in range(0,len(path)-1) :
46 print re.sub(farg,
"()",path[i])+G[path[i]][path[i+1]][
'kind'],
47 print re.sub(farg,
"()",path[i+1])+
"' ,",
48 for key
in G[tfunc].
keys() :
49 if 'kind' in G[tfunc][key]
and G[tfunc][key][
'kind'] ==
' overrides function ' :
50 print "'"+re.sub(farg,
"()",tfunc)+
"' overrides '"+re.sub(farg,
"()",key)+
"'",
53 print "In call stack ' ",
54 for i
in range(0,len(path)-1) :
55 print re.sub(farg,
"()",path[i])+G[path[i]][path[i+1]][
'kind'],
56 print re.sub(farg,
"()",path[i+1])+
"' is accessed ,",
57 for key
in G[tfunc].
keys() :
58 if 'kind' in G[tfunc][key]
and G[tfunc][key][
'kind'] ==
' overrides function ' :
59 print "'"+re.sub(farg,
"()",tfunc)+
"' overrides '"+re.sub(farg,
"()",key)+
"'",