Skip to content

Commit 0bf2c17

Browse files
committed
fix breakpoint in mcu
1 parent 8a29cbe commit 0bf2c17

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

qiling/debugger/qdb/qdb.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,17 @@ def _run(self: Qldbg, address: int = 0, end: int = 0, count: int = 0) -> None:
111111
if not address:
112112
address = self.cur_addr
113113

114+
if self.ql.archtype == QL_ARCH.CORTEX_M and self.ql.count != 0:
115+
count = self.ql.count
116+
114117
if self.ql.archtype in (QL_ARCH.ARM, QL_ARCH.ARM_THUMB, QL_ARCH.CORTEX_M) and is_thumb(self.ql.reg.cpsr):
115118
address |= 1
116119

117120
self.ql.emu_start(begin=address, end=end, count=count)
118121

122+
if self.ql.count:
123+
self.ql.count -= count
124+
119125
def parseline(self: QlQdb, line: str) -> Tuple[Optional[str], Optional[str], str]:
120126
"""
121127
Parse the line into a command name and a string containing
@@ -197,7 +203,7 @@ def do_step(self: QlQdb, *args) -> Optional[bool]:
197203
print(f"{color.RED}[!] The program is not being run.{color.END}")
198204

199205
else:
200-
# save reg dump for data chaged highliting
206+
# save reg dump for data highliting changes
201207
self._saved_reg_dump = dict(filter(lambda d: isinstance(d[0], str), self.ql.reg.save().items()))
202208

203209
if self.rr:
@@ -268,16 +274,21 @@ def do_continue(self: QlQdb, address: str = "") -> None:
268274

269275
print(f"{color.CYAN}continued from 0x{self.cur_addr:08x}{color.END}")
270276

271-
count, end = 0, 0
272277
if self.ql.archtype == QL_ARCH.CORTEX_M:
273-
count = self.ql.count
278+
end = 0
274279

275280
if len(self.bp_list) > 0:
276281
end = next(filter(lambda x: x > self.cur_addr, sorted(self.bp_list.keys())))
277282

278-
self._run(address, end=end, count=count)
279-
print(f"{color.CYAN}[+] hit breakpoint at 0x{self.cur_addr:08x}{color.END}")
280-
self.do_context()
283+
self._run(address, end=end)
284+
285+
if end != 0:
286+
print(f"{color.CYAN}[+] hit breakpoint at 0x{self.cur_addr:08x}{color.END}")
287+
288+
if self.ql.count:
289+
# print context if still running
290+
self.do_context()
291+
281292
return
282293

283294
self._run(address)

0 commit comments

Comments
 (0)