8 self
.minaddr
= 0xFFFFFFFF
11 def loadsymbolinformation():
12 reg
= r
'S\|(.*)\|(.*)\|(.*)\|(.*)'
18 with
open(sys
.argv
[2]) as f
:
20 match
= re
.match(reg
, line
)
22 modname
= match
.group(1)
23 symbolname
= match
.group(2)
24 start
= int(match
.group(3), 16)
25 end
= int(match
.group(4), 16)
27 # New module is needed
28 if (modname
!= lastmodname
):
30 print "%s %x %x" % (module
.name
, module
.minaddr
, module
.maxaddr
)
33 modules
.append(module
)
36 # Flags entries with no name
37 if (symbolname
== ""):
38 symbolname
= "<no name>"
40 # Ignore entries with no address
41 if (start
!= 0 and end
!= 0):
42 symbol
= (symbolname
, start
, end
)
43 module
.minaddr
= min(start
, module
.minaddr
)
44 module
.maxaddr
= max(end
, module
.maxaddr
)
45 module
.symbols
.append(symbol
)
49 def addmodulespec(line
, module
, output
):
56 module
.id = addmodulespec
.nextmoduleid
57 addmodulespec
.nextmoduleid
+= 1
58 modulename
= " " + module
.name
62 output
.write(prefix
+ "ob=(" + str(module
.id) + ")" + modulename
+ os
.linesep
)
66 modules
= loadsymbolinformation()
68 addmodulespec
.nextmoduleid
= 1000
72 reg
= r
'([c]*fn=\(\d*\) )0x([a-f0-9]*)'
73 output
= open(sys
.argv
[1] + ".processed", "w")
74 with
open(sys
.argv
[1]) as log
:
76 match
= re
.match(reg
, line
)
78 address
= int(match
.group(2), 16)
79 for module
in modules
:
80 # Skip modules that can't host this address
81 if (address
< module
.minaddr
):
83 if (address
> module
.maxaddr
):
86 for symbol
in module
.symbols
:
87 if (symbol
[1] <= address
and symbol
[2] >= address
):
88 # Write out additional module spec
89 addmodulespec(line
, module
, output
)
91 # Build out actuall symbol information
92 line
= match
.group(1) + symbol
[0] + os
.linesep
99 # Usage: vgpostprocess.py callgrind.out.<pid> symbols.out
101 if __name__
== "__main__":