Author: Armin Rigo <[email protected]>
Branch: stmgc-c4
Changeset: r66095:66dd859b8759
Date: 2013-08-12 18:11 +0200
http://bitbucket.org/pypy/pypy/changeset/66dd859b8759/

Log:    Try to reuse the World class from viewcode. It will correctly
        handle the patching, so unlike the previous version, we see correct
        jump targets, for example. It's still a mess because of various
        issues like objdump truncating addresses to 4 bytes. (transplanted
        from 6688b05ff4aa2c733d5150b9a0a757bc95ea4bb3)

diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py
--- a/pypy/tool/jitlogparser/parser.py
+++ b/pypy/tool/jitlogparser/parser.py
@@ -394,29 +394,19 @@
             name = entry[:entry.find('(') - 1].lower()
             addr = int(m.group(1), 16)
         addrs.setdefault(addr, []).append(name)
-    dumps = {}
-    executables = set(["??",])
-    symbols = {}
+    from rpython.jit.backend.tool.viewcode import World
+    world = World()
     for entry in extract_category(log, 'jit-backend-dump'):
         entry = purge_thread_numbers(entry)
-        backend, executable, dump, _ = entry.split("\n")
-        if "(out of memory!)" not in executable:
-            _, executable = executable.split(" ")
-            if executable not in executables:
-                try:
-                    symbols.update(load_symbols(executable))
-                except Exception as e:
-                    print e
-                executables.add(executable)
-        _, addr, _, data = re.split(" +", dump)
-        backend_name = backend.split(" ")[1]
-        addr = int(addr[1:], 16)
-        if addr < 0:
-            addr += (2 * sys.maxint + 2)
-        if addr in addrs and addrs[addr]:
-            name = addrs[addr].pop(0) # they should come in order
-            dumps[name] = (backend_name, addr, data)
-    
+        world.parse(entry.splitlines(True), load_symbols=False,
+                    truncate_addr=False)
+    dumps = {}
+    symbols = world.symbols
+    for r in world.ranges:
+        if r.addr in addrs and addrs[r.addr]:
+            name = addrs[r.addr].pop(0) # they should come in order
+            data = r.data.encode('hex')       # backward compatibility
+            dumps[name] = (world.backend_name, r.addr, data)
     loops = []
     for entry in extract_category(log, 'jit-log-opt'):
         parser = ParserCls(entry, None, {}, 'lltype', None,
diff --git a/rpython/jit/backend/tool/viewcode.py 
b/rpython/jit/backend/tool/viewcode.py
--- a/rpython/jit/backend/tool/viewcode.py
+++ b/rpython/jit/backend/tool/viewcode.py
@@ -239,7 +239,7 @@
         self.backend_name = None
         self.executable_name = None
 
-    def parse(self, f, textonly=True):
+    def parse(self, f, textonly=True, load_symbols=True, truncate_addr=True):
         for line in f:
             line = line[line.find('#') + 1:].strip()
             if line.startswith('BACKEND '):
@@ -250,7 +250,11 @@
                 assert pieces[2].startswith('+')
                 if len(pieces) == 3:
                     continue     # empty line
-                baseaddr = long(pieces[1][1:], 16) & 0xFFFFFFFFL
+                baseaddr = long(pieces[1][1:], 16)
+                if truncate_addr:
+                    baseaddr &= 0xFFFFFFFFL
+                elif baseaddr < 0:
+                    baseaddr += (2 * sys.maxint + 2)
                 offset = int(pieces[2][1:])
                 addr = baseaddr + offset
                 data = pieces[3].replace(':', '').decode('hex')
@@ -268,11 +272,17 @@
                 pieces = line.split(None, 3)
                 assert pieces[1].startswith('@')
                 assert pieces[2].startswith('+')
-                baseaddr = long(pieces[1][1:], 16) & 0xFFFFFFFFL
+                baseaddr = long(pieces[1][1:], 16)
+                if truncate_addr:
+                    baseaddr &= 0xFFFFFFFFL
+                elif baseaddr < 0:
+                    baseaddr += (2 * sys.maxint + 2)
                 offset = int(pieces[2][1:])
                 addr = baseaddr + offset
                 self.logentries[addr] = pieces[3]
             elif line.startswith('SYS_EXECUTABLE '):
+                if not load_symbols:
+                    continue
                 filename = line[len('SYS_EXECUTABLE '):].strip()
                 if filename != self.executable_name and filename != '??':
                     try:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to