@@ -39,7 +39,7 @@ def dbg_hook(self: QlQdb, init_hook: str):
3939
4040 # self.ql.loader.entry_point # ld.so
4141 # self.ql.loader.elf_entry # .text of binary
42- if not self .ql .baremetal :
42+ if self .ql .archtype != QL_ARCH . CORTEX_M :
4343
4444 if init_hook :
4545 init_hook = parse_int (init_hook )
@@ -200,29 +200,22 @@ def do_step(self: QlQdb, *args) -> Optional[bool]:
200200 # save reg dump for data chaged highliting
201201 self ._saved_reg_dump = dict (filter (lambda d : isinstance (d [0 ], str ), self .ql .reg .save ().items ()))
202202
203+ if self .rr :
204+ self ._save ()
205+
203206 _ , next_stop = handle_bnj (self .ql , self .cur_addr )
204207
205208 if next_stop is CODE_END :
206209 return True
207210
208- if self .rr :
209- self ._save ()
210-
211- if self .ql .baremetal :
211+ if self .ql .archtype == QL_ARCH .CORTEX_M :
212212 self .ql .arch .step ()
213- # self.ql.arch.run(count=1, end=self.ql.exit_point)
214- # self._run(count=1)
215- self .do_context ()
213+ self .ql .count -= 1
216214
217215 else :
218-
219- count = 1
220- if self .ql .archtype == QL_ARCH .MIPS and next_stop != self .cur_addr + 4 :
221- # make sure delay slot executed
222- count = 2
223-
224216 self ._run (count = count )
225- self .do_context ()
217+
218+ self .do_context ()
226219
227220 def set_breakpoint (self : QlQdb , address : int , is_temp : bool = False ) -> None :
228221 """
@@ -231,7 +224,9 @@ def set_breakpoint(self: QlQdb, address: int, is_temp: bool = False) -> None:
231224
232225 bp = TempBreakpoint (address ) if is_temp else Breakpoint (address )
233226
234- bp .hook = self .ql .hook_address (self ._bp_handler , address )
227+ if self .ql .archtype != QL_ARCH .CORTEX_M :
228+ # skip hook_address for cortex_m
229+ bp .hook = self .ql .hook_address (self ._bp_handler , address )
235230
236231 self .bp_list .update ({address : bp })
237232
@@ -273,6 +268,18 @@ def do_continue(self: QlQdb, address: str = "") -> None:
273268
274269 print (f"{ color .CYAN } continued from 0x{ self .cur_addr :08x} { color .END } " )
275270
271+ count , end = 0 , 0
272+ if self .ql .archtype == QL_ARCH .CORTEX_M :
273+ count = self .ql .count
274+
275+ if len (self .bp_list ) > 0 :
276+ end = next (filter (lambda x : x > self .cur_addr , sorted (self .bp_list .keys ())))
277+
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 ()
281+ return
282+
276283 self ._run (address )
277284
278285 def do_examine (self : QlQdb , line : str ) -> None :
0 commit comments