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
)
37 if (symbolname
!= "" and start
> 0x1000 and end
== 0):
40 # Flags entries with no name
41 if (symbolname
== ""):
42 symbolname
= "<no name>"
44 # Ignore entries with no address
45 if (start
!= 0 and end
!= 0):
46 symbol
= (symbolname
, start
, end
)
47 module
.minaddr
= min(start
, module
.minaddr
)
48 module
.maxaddr
= max(end
, module
.maxaddr
)
49 module
.symbols
.append(symbol
)
53 def addmodulespec(line
, module
, output
):
60 module
.id = addmodulespec
.nextmoduleid
61 addmodulespec
.nextmoduleid
+= 1
62 modulename
= " " + module
.name
66 output
.write(prefix
+ "ob=(" + str(module
.id) + ")" + modulename
+ os
.linesep
)
70 modules
= loadsymbolinformation()
72 addmodulespec
.nextmoduleid
= 1000
76 reg
= r
'([c]*fn=\(\d*\) )0x([a-f0-9]*)'
77 output
= open(sys
.argv
[1] + ".processed", "w")
78 with
open(sys
.argv
[1]) as log
:
80 match
= re
.match(reg
, line
)
82 address
= int(match
.group(2), 16)
83 for module
in modules
:
84 # Skip modules that can't host this address
85 if (address
< module
.minaddr
):
87 if (address
> module
.maxaddr
):
90 for symbol
in module
.symbols
:
91 if (symbol
[1] <= address
and symbol
[2] >= address
):
92 # Write out additional module spec
93 addmodulespec(line
, module
, output
)
95 # Build out actuall symbol information
96 line
= match
.group(1) + symbol
[0] + os
.linesep
103 # Usage: vgpostprocess.py callgrind.out.<pid> symbols.out
105 if __name__
== "__main__":