summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@tungstengraphics.com>2008-07-20 23:32:00 +0900
committerJosé Fonseca <jrfonseca@tungstengraphics.com>2008-07-22 09:45:32 +0900
commit1662be376465c22461f03ef01dad16cef70f746a (patch)
treea7882fe85b1bfde9b8d3de59fff27773a8d9531c /bin
parent4d38d86b2c5e572b1ea5ff4a5a84acb7ab5b87fc (diff)
win32kprof: Consider the section alignment when estimating the image base.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/win32kprof.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/bin/win32kprof.py b/bin/win32kprof.py
index b4f9ce95dc..1876fbc067 100755
--- a/bin/win32kprof.py
+++ b/bin/win32kprof.py
@@ -35,8 +35,6 @@ import struct
__version__ = '0.1'
-verbose = False
-
class ParseError(Exception):
pass
@@ -211,7 +209,7 @@ class Profile:
if self.base_addr is None:
ref_addr = self.lookup_symbol('__debug_profile_reference2')
if ref_addr:
- self.base_addr = addr - ref_addr
+ self.base_addr = (addr - ref_addr) & ~(options.align - 1)
else:
self.base_addr = 0
#print hex(self.base_addr)
@@ -224,27 +222,27 @@ class Profile:
delta += stamp - last_stamp
if not exit:
- if verbose >= 2:
+ if options.verbose >= 2:
print "%10u >> 0x%08x" % (stamp, addr)
- if verbose:
+ if options.verbose:
print "%10u >> %s" % (stamp, name)
delta -= caller_overhead
stack.append((name, stamp, delta))
delta = 0
else:
- if verbose >= 2:
+ if options.verbose >= 2:
print "%10u << 0x%08x" % (stamp, addr)
if len(stack):
self_time = delta - callee_overhead
entry_name, entry_stamp, delta = stack.pop()
if entry_name != name:
- if verbose:
+ if options.verbose:
print "%10u << %s" % (stamp, name)
#assert entry_name == name
break
total_time = stamp - entry_stamp
self.functions[entry_name] = self.functions.get(entry_name, 0) + self_time
- if verbose:
+ if options.verbose:
print "%10u << %s %+u" % (stamp, name, self_time)
else:
delta = 0
@@ -265,6 +263,10 @@ def main():
usage="\n\t%prog [options] [file] ...",
version="%%prog %s" % __version__)
parser.add_option(
+ '-a', '--align', metavar='NUMBER',
+ type="int", dest="align", default=16,
+ help="section alignment")
+ parser.add_option(
'-m', '--map', metavar='FILE',
type="string", dest="map",
help="map file")
@@ -277,10 +279,9 @@ def main():
action="count",
dest="verbose", default=0,
help="verbose output")
- (options, args) = parser.parse_args(sys.argv[1:])
- global verbose
- verbose = options.verbose
+ global options
+ (options, args) = parser.parse_args(sys.argv[1:])
profile = Profile()
if options.base is not None: