diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-09-11 15:25:58 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-09-11 15:25:58 +0000 |
commit | 228290c0d181b663f33680aea03e10843da5f907 (patch) | |
tree | 45fbc0aa476cc3a0bfa9414c912db2743e83d042 /test/Scripts | |
parent | 26c5663283f89f1624304723ebe8c25d253463a3 (diff) | |
download | external_llvm-228290c0d181b663f33680aea03e10843da5f907.zip external_llvm-228290c0d181b663f33680aea03e10843da5f907.tar.gz external_llvm-228290c0d181b663f33680aea03e10843da5f907.tar.bz2 |
Change section_data dumping to print hex numbers instead of using
python's %r.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113685 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Scripts')
-rw-r--r-- | test/Scripts/common_dump.py | 13 | ||||
-rwxr-xr-x | test/Scripts/elf-dump | 5 | ||||
-rwxr-xr-x | test/Scripts/macho-dump | 4 |
3 files changed, 20 insertions, 2 deletions
diff --git a/test/Scripts/common_dump.py b/test/Scripts/common_dump.py new file mode 100644 index 0000000..444b389 --- /dev/null +++ b/test/Scripts/common_dump.py @@ -0,0 +1,13 @@ +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() diff --git a/test/Scripts/elf-dump b/test/Scripts/elf-dump index 6572163..880e299 100755 --- a/test/Scripts/elf-dump +++ b/test/Scripts/elf-dump @@ -4,6 +4,8 @@ import struct import sys import StringIO +import common_dump + class Reader: def __init__(self, path): if path == "-": @@ -95,7 +97,8 @@ class Section: print " ])" elif dumpdata: f.seek(self.sh_offset) - print " ('_section_data', %r)" % f.read(self.sh_size) + data = f.read(self.sh_size) + print " ('_section_data', %s)" % common_dump.dataToHex(data) print " )," def dumpSymtab(f, section, strtab): diff --git a/test/Scripts/macho-dump b/test/Scripts/macho-dump index 72f8339..afef2ba 100755 --- a/test/Scripts/macho-dump +++ b/test/Scripts/macho-dump @@ -4,6 +4,8 @@ import struct import sys import StringIO +import common_dump + class Reader: def __init__(self, path): if path == '-': @@ -267,7 +269,7 @@ def dumpSection(f, i, opts, is64Bit): if opts.dumpSectionData: f.seek(offset) - print " ('_section_data', %r)" % f.read(size) + print " ('_section_data', '%s')" % common_dump.dataToHex(f.read(size)) f.seek(prev_pos) |