Skip to content

Commit 95d7b8f

Browse files
committed
Generalize code to meet both Cortex A and M
1 parent b1ad033 commit 95d7b8f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

qiling/debugger/qdb/branch_predictor/branch_predictor_arm.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class BranchPredictorARM(BranchPredictor, ArchARM):
2727

2828
stop = 'udf'
2929

30-
def get_cpsr(self) -> Tuple[bool, bool, bool, bool]:
31-
"""Get flags map of CPSR.
30+
def get_cond_flags(self) -> Tuple[bool, bool, bool, bool]:
31+
"""Get condition status flags from CPSR / xPSR.
3232
"""
3333

3434
cpsr = self.read_reg(self._flags_reg)
@@ -122,9 +122,9 @@ def __parse_op(op: ArmOp, *args, **kwargs) -> Optional[int]:
122122

123123
def __is_taken(cc: int) -> Tuple[bool, Tuple[bool, ...]]:
124124
pred = predicate[cc]
125-
cpsr = self.get_cpsr()
125+
flags = self.get_cond_flags()
126126

127-
return pred(*cpsr), cpsr
127+
return pred(*flags), flags
128128

129129
# conditions predicate selector
130130
predicate: Dict[int, Callable[..., bool]] = {
@@ -215,13 +215,13 @@ def __is_taken(cc: int) -> Tuple[bool, Tuple[bool, ...]]:
215215
where = __parse_op(operands[1], **msize[suffix])
216216

217217
elif iname in binop:
218-
going, cpsr = __is_taken(insn.cc)
218+
going, flags = __is_taken(insn.cc)
219219

220220
if going:
221221
operator = binop[iname]
222222
op1 = __parse_op(operands[1])
223223
op2 = __parse_op(operands[2])
224-
carry = int(cpsr[1])
224+
carry = int(flags[1])
225225

226226
where = (op1 and op2) and operator(op1, op2, carry)
227227

qiling/debugger/qdb/render/render_arm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
44
#
55

6-
from typing import Iterator, Optional
6+
from typing import Iterator
77

88
from .render import Render, ContextRender
99
from ..arch import ArchARM, ArchCORTEX_M

0 commit comments

Comments
 (0)