3 topfunc = re.compile(
"::(produce|analyze|filter|beginLuminosityBlock|beginRun)\(")
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)")
20 fields = line.split(
"'")
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=
' static variable ')
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])
38 for tfunc
in sorted(toplevelfuncs):
39 for static
in sorted(statics):
40 if nx.has_path(G,tfunc,static):
41 path = nx.shortest_path(G,tfunc,static)
43 print "Non-const static variable \'"+re.sub(farg,
"()",static)+
"' is accessed in call stack '",
44 for i
in range(0,len(path)-1) :
45 print re.sub(farg,
"()",path[i])+G[path[i]][path[i+1]][
'kind'],
46 print re.sub(farg,
"()",path[i+1])+
"' ,",
47 for key
in G[tfunc].
keys() :
48 if 'kind' in G[tfunc][key]
and G[tfunc][key][
'kind'] ==
' overrides function ' :
49 print "'"+re.sub(farg,
"()",tfunc)+
"' overrides '"+re.sub(farg,
"()",key)+
"'",
52 print "In call stack ' ",
53 for i
in range(0,len(path)-1) :
54 print re.sub(farg,
"()",path[i])+G[path[i]][path[i+1]][
'kind'],
55 print re.sub(farg,
"()",path[i+1])+
"' is accessed ,",
56 for key
in G[tfunc].
keys() :
57 if 'kind' in G[tfunc][key]
and G[tfunc][key][
'kind'] ==
' overrides function ' :
58 print "'"+re.sub(farg,
"()",tfunc)+
"' overrides '"+re.sub(farg,
"()",key)+
"'",