Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r66089:6688b05ff4aa Date: 2013-08-12 18:11 +0200 http://bitbucket.org/pypy/pypy/changeset/6688b05ff4aa/
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. 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 @@ -379,17 +379,17 @@ name = entry[:entry.find('(') - 1].lower() addr = int(m.group(1), 16) addrs.setdefault(addr, []).append(name) + from rpython.jit.backend.tool.viewcode import World + world = World() + for entry in extract_category(log, 'jit-backend-dump'): + world.parse(entry.splitlines(True), load_symbols=False, + truncate_addr=False) dumps = {} - for entry in extract_category(log, 'jit-backend-dump'): - backend, _, dump, _ = entry.split("\n") - _, 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) + 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 @@ -240,7 +240,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: if line.startswith('BACKEND '): self.backend_name = line.split(' ')[1].strip() @@ -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 != '??': self.symbols.update(load_symbols(filename)) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit