Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions scripts/itrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ class X86_64(Extractor):
branchpattern = re.compile(r'^(?:repz\s+)?(j\w*|call|ret)q?')
# e.g. 0x400(%rax,%rbx,8), 0x123(%rdx), etc.
eapattern = re.compile(r'(-?(?:0x)?[0-9a-f]+)?'
'\(''%([a-z0-9]+)'
'(?:,%([a-z0-9]+),'
'([1248]))?''\)'
'(?:\s*,\s*%([a-z0-9]+))?')
r'\(''%([a-z0-9]+)'
r'(?:,%([a-z0-9]+),'
r'([1248]))?'
r'\)'
r'(?:\s*,\s*%([a-z0-9]+))?')

def printHeader(self, function):
frame = gdb.newest_frame()
Expand Down Expand Up @@ -128,8 +129,9 @@ class ARM64(Extractor):
branchpattern = re.compile(r'^(b\.\w+|bl?r?|cbn?z|ret)\b')
# e.g. [x20,#40], [x20],#8, [x20,x21]
eapattern = re.compile(r'\[(x[0-9]+|sp)'
'(?:\s*,\s*(x[0-9]+|#-?(?:0x)?[0-9a-fA-F]+))?''\]'
'(?:\s*,\s*#(-?(?:0x)?[0-9a-fA-F]+))?')
r'(?:\s*,\s*(x[0-9]+|#-?(?:0x)?[0-9a-fA-F]+))?'
r'\]'
r'(?:\s*,\s*#(-?(?:0x)?[0-9a-fA-F]+))?')

def printHeader(self, function):
frame = gdb.newest_frame()
Expand Down Expand Up @@ -171,8 +173,9 @@ def getEA(self, insn, frame):
class ARM32(Extractor):
branchpattern = re.compile(r'^(b(?!f)\w*|cbn?z)\b')
eapattern = re.compile(r'(?:\[([a-z]+[0-9]*)'
'(?:\s*,\s*([a-z0-9]+|#-?(?:0x)?[0-9a-fA-F]+)|\s*:\d+)?''\]'
'|(?:ld|st)m\w*\.?\w*\s+(\w+)!?,)')
r'(?:\s*,\s*([a-z0-9]+|#-?(?:0x)?[0-9a-fA-F]+)|\s*:\d+)?'
r'\]'
r'|(?:ld|st)m\w*\.?\w*\s+(\w+)!?,)')

def printHeader(self, function):
frame = gdb.newest_frame()
Expand Down Expand Up @@ -379,7 +382,7 @@ def trace():
unit = 'g' if wordsize == 64 else 'w'
try :
value = gdb.execute("x/1x{0} 0x{1:x}".format(unit, ea["addr"]), False, True)
value = re.match('0x[0-9a-fA-F]+\s*<?.*>?\s*:\s+(0x[0-9a-fA-F]+)', value).group(1)
value = re.match(r'0x[0-9a-fA-F]+\s*<?.*>?\s*:\s+(0x[0-9a-fA-F]+)', value).group(1)
except gdb.MemoryError :
value = "'?'"
print("\t{0:48s}#! EA = L0x{1:x}; Value = {2}; PC = 0x{3:x}"
Expand Down