Armin Rigo avatar Armin Rigo committed 37b092c

Yay, finally found out the objdump option "-m i386:x86-64".
Solves the truncated addresses.

Comments (0)

Files changed (1)

rpython/jit/backend/tool/viewcode.py

         'arm': 'arm',
         'arm_32': 'arm',
     }
+    backend_to_machine = {
+        'x86-64': 'i386:x86-64',
+    }
     cmd = find_objdump()
     objdump = ('%(command)s -M %(backend)s -b binary -m %(machine)s '
                '--disassembler-options=intel-mnemonics '
     f = open(tmpfile, 'wb')
     f.write(data)
     f.close()
+    backend = objdump_backend_option[backend_name]
     p = subprocess.Popen(objdump % {
         'command': cmd,
         'file': tmpfile,
         'origin': originaddr,
-        'backend': objdump_backend_option[backend_name],
-        'machine': 'i386' if not backend_name.startswith('arm') else 'arm',
+        'backend': backend,
+        'machine': backend_to_machine.get(backend, backend),
     }, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     stdout, stderr = p.communicate()
     assert not p.returncode, ('Encountered an error running objdump: %s' %
         self.backend_name = None
         self.executable_name = None
 
-    def parse(self, f, textonly=True, truncate_addr=True):
+    def parse(self, f, textonly=True):
         for line in f:
             if line.startswith('BACKEND '):
                 self.backend_name = line.split(' ')[1].strip()
                 if len(pieces) == 3:
                     continue     # empty line
                 baseaddr = long(pieces[1][1:], 16)
-                if truncate_addr:
-                    baseaddr &= 0xFFFFFFFFL
-                elif baseaddr < 0:
+                if baseaddr < 0:
                     baseaddr += (2 * sys.maxint + 2)
                 offset = int(pieces[2][1:])
                 addr = baseaddr + offset
                 assert pieces[1].startswith('@')
                 assert pieces[2].startswith('+')
                 baseaddr = long(pieces[1][1:], 16)
-                if truncate_addr:
-                    baseaddr &= 0xFFFFFFFFL
-                elif baseaddr < 0:
+                if baseaddr < 0:
                     baseaddr += (2 * sys.maxint + 2)
                 offset = int(pieces[2][1:])
                 addr = baseaddr + offset
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.