summaryrefslogtreecommitdiffstats
path: root/llvm/test/Scripts
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-09-11 15:25:58 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-09-11 15:25:58 +0000
commit2833e392ab2a4f3bd4c30b8caf287590ee6900a3 (patch)
tree76fe4785dee3d791b995448082327249f07750c1 /llvm/test/Scripts
parent42daac442b769c6f9c1b80f77771e5f919f52038 (diff)
downloadbcm5719-llvm-2833e392ab2a4f3bd4c30b8caf287590ee6900a3.tar.gz
bcm5719-llvm-2833e392ab2a4f3bd4c30b8caf287590ee6900a3.zip
Change section_data dumping to print hex numbers instead of using
python's %r. llvm-svn: 113685
Diffstat (limited to 'llvm/test/Scripts')
-rw-r--r--llvm/test/Scripts/common_dump.py13
-rwxr-xr-xllvm/test/Scripts/elf-dump5
-rwxr-xr-xllvm/test/Scripts/macho-dump4
3 files changed, 20 insertions, 2 deletions
diff --git a/llvm/test/Scripts/common_dump.py b/llvm/test/Scripts/common_dump.py
new file mode 100644
index 00000000000..444b389dd0e
--- /dev/null
+++ b/llvm/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/llvm/test/Scripts/elf-dump b/llvm/test/Scripts/elf-dump
index 657216358e0..880e299a2c5 100755
--- a/llvm/test/Scripts/elf-dump
+++ b/llvm/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/llvm/test/Scripts/macho-dump b/llvm/test/Scripts/macho-dump
index 72f833975d0..afef2ba5043 100755
--- a/llvm/test/Scripts/macho-dump
+++ b/llvm/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)
OpenPOWER on IntegriCloud