jit/backend/x86/test/test_runner.py::TestX86::()::test_compile_asmlen
self = <rpython.jit.backend.x86.test.test_runner.TestX86 object at 0x00007fd7210990f8>
def test_compile_asmlen(self):
if not isinstance(self.cpu, AbstractLLCPU):
py.test.skip("pointless test on non-asm")
from rpython.jit.backend.tool.viewcode import machine_code_dump, ObjdumpNotFound
import ctypes
targettoken = TargetToken()
ops = """
[i2]
i0 = same_as_i(i2) # but forced to be in a register
label(i0, descr=targettoken)
i1 = int_add(i0, i0)
guard_true(i1, descr=faildescr) [i1]
jump(i1, descr=targettoken)
"""
faildescr = BasicFailDescr(2)
loop = parse(ops, self.cpu, namespace=locals())
bridge_ops = """
[i0]
jump(i0, descr=targettoken)
"""
bridge = parse(bridge_ops, self.cpu, namespace=locals())
looptoken = JitCellToken()
self.cpu.assembler.set_debug(False)
info = self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
bridge_info = self.cpu.compile_bridge(faildescr, bridge.inputargs,
bridge.operations,
looptoken)
self.cpu.assembler.set_debug(True) # always on untranslated
assert info.asmlen != 0
cpuname = autodetect()
# XXX we have to check the precise assembler, otherwise
# we don't quite know if borders are correct
def checkops(mc, ops_regexp):
import re
words = []
print('----- checkops -----')
for line in mc:
print(line.rstrip())
t = line.split("\t")
if len(t) <= 2:
continue
w = t[2].split()
if len(w) == 0:
if '<UNDEFINED>' in line:
w = ['UNDEFINED']
else:
continue
words.append(w[0] + ';')
print('[[%s]]' % (w[0],))
text = ' '.join(words)
assert re.compile(ops_regexp).match(text)
data = ctypes.string_at(info.asmaddr, info.asmlen)
try:
> mc = list(machine_code_dump(data, info.asmaddr, cpuname))
jit/backend/test/runner_test.py:4675:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
data = 'H\x8b\x8d \x01\x00\x00\x0f\x1f\x00H\x01\xc9H\x85\xc9\x0f\x84T\x00\x00\x00\xe9\xef\xff\xff\xff\x0f\x0bffff.\x0f\x1f\x84\x00\x00\x00\x00\x00'
originaddr = 481131760246, backend_name = 'x86-64', label_list = None
def machine_code_dump(data, originaddr, backend_name, label_list=None):
objdump_machine_option = {
'x86': 'i386',
'x86-without-sse2': 'i386',
'x86_32': 'i386',
'x86_64': 'i386:x86-64',
'x86-64': 'i386:x86-64',
'i386': 'i386',
'arm': 'arm',
'arm_32': 'arm',
'aarch64': 'aarch64',
'ppc' : 'powerpc:common64',
'ppc-64' : 'powerpc:common64',
'riscv64': 'riscv:rv64',
's390x': 's390:64-bit',
}
machine_endianness = {
# default value: 'little'
'ppc' : sys.byteorder, # i.e. same as the running machine...
'ppc-64' : sys.byteorder, # i.e. same as the running machine...
's390x' : sys.byteorder, # i.e. same as the running machine...
}
cmd = find_objdump()
objdump = ('%(command)s -b binary -m %(machine)s '
'--endian=%(endianness)s '
'--disassembler-options=intel-mnemonics '
'--adjust-vma=%(origin)d -D %(file)s')
#
f = open(tmpfile, 'wb')
f.write(data)
f.close()
p = subprocess.Popen(objdump % {
'command': cmd,
'file': tmpfile,
'origin': originaddr,
'machine': objdump_machine_option[backend_name],
'endianness': machine_endianness.get(backend_name, 'little'),
}, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
assert not p.returncode, ('Encountered an error running objdump: %s' %
> stderr)
E AssertionError: Encountered an error running objdump: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: error: unknown argument '-b'
jit/backend/tool/viewcode.py:82: AssertionError
builder: rpython-macos-x86-64 build #277+
test: jit/backend/x86/test/test_runner.py::TestX86::()::test_compile_asmlen