Skip to content

Commit

Permalink
Merge pull request #1521 from ucgJhe/qdb
Browse files Browse the repository at this point in the history
Qdb bug fix missing function `handle_bnj_arm`
  • Loading branch information
xwings authored Jan 20, 2025
2 parents 6c1d77c + d0cd4ea commit aa59bce
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions qiling/debugger/qdb/branch_predictor/branch_predictor_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ def get_cpsr(bits: int) -> (bool, bool, bool, bool):
bits & 0x80000000 != 0, # N, sign flag
)

def predict(self):
def predict(self, pref_addr=None):
prophecy = self.Prophecy()
cur_addr = self.cur_addr
cur_addr = self.cur_addr if pref_addr is None else pref_addr
line = self.disasm(cur_addr)

prophecy.where = cur_addr + line.size

if line.mnemonic == self.CODE_END: # indicates program exited
prophecy.where = True
return prophecy
Expand Down Expand Up @@ -160,7 +158,7 @@ def predict(self):
next_addr = cur_addr + self.THUMB_INST_SIZE
for each in it_block_range:
_insn = self.read_insn(next_addr)
n2_addr = handle_bnj_arm(ql, next_addr)
n2_addr = self.predict(ql, next_addr)

if (cond_met and each == "t") or (not cond_met and each == "e"):
if n2_addr != (next_addr+len(_insn)): # branch detected
Expand Down

0 comments on commit aa59bce

Please sign in to comment.