Skip to content

Commit

Permalink
simutils: find_inst_addr in dasmutil
Browse files Browse the repository at this point in the history
  • Loading branch information
dlp committed Jan 15, 2013
1 parent fccd2fe commit a4444d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions simutils/dasmutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,16 @@ def __iter__(self):

###############################################################################

def find_inst_addr(binary, which, cyc_offset=0):
"""Get a list of addresses of certain instructions, with given offset"""
dasm = DisAsm(binary)
allinst = [ inst for line, inst in dasm if inst ]
match = [ x+' ' in inst['inst'] for x in which for inst in allinst ]
return [ x['addr'] for i,x in enumerate(allinst) if match[i-cyc_offset] ]


def ret_points(binary):
dasm = DisAsm(binary)
cnt = 1
for line, inst in dasm:
if inst:
if cnt==0: yield inst['addr']
if 'call' in inst['inst']:
cnt = -2
continue
cnt = cnt + 1
return find_inst_addr(binary, ['call'], 3)


###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion simutils/simutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def trace_ex(binary):
with open(os.devnull, 'w') as fnull:
pasim = Popen(pasim_cmd, stderr=PIPE, stdout=fnull)
ro = re.compile(r'^.*PRR: ([0-9]{8}) .* PC : 0*([0-9a-fA-F]{1,8})') # regex object
pipeline = [None, None] # initial pipline fill
pipeline = [None, None] # initial pipeline fill
cyc = 0
for line in pasim.stderr:
mo = ro.match(line) # matcher object
Expand Down

0 comments on commit a4444d8

Please sign in to comment.