1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00
llvm-mirror/test/Scripts/common_dump.py
Rafael Espindola f926b1b27d Change section_data dumping to print hex numbers instead of using
python's %r.

llvm-svn: 113685
2010-09-11 15:25:58 +00:00

14 lines
384 B
Python

def dataToHex(d):
""" Convert the raw data in 'd' to an hex string with a space every 4 bytes.
"""
bytes = []
for i,c in enumerate(d):
byte = ord(c)
hex_byte = hex(byte)[2:]
if byte <= 0xf:
hex_byte = '0' + hex_byte
if i % 4 == 3:
hex_byte += ' '
bytes.append(hex_byte)
return ''.join(bytes).strip()