import
types
def
dbg_hook(
self
, ql, address:
int
, size:
int
):
if
address
=
=
self
.last_bp:
self
.last_bp
=
None
elif
address
in
self
.bp_list:
self
.last_bp
=
address
ql.log.info(f
'gdb> breakpoint hit, stopped at {address:#x}'
)
ql.stop()
def
run(
self
, begin: Optional[
int
]
=
None
, end: Optional[
int
]
=
None
, timeout:
int
=
0
, count:
int
=
0
):
self
.entry_point
=
begin
self
.exit_point
=
end
self
.timeout
=
timeout
self
.count
=
count
debugger
=
select_debugger(
self
._debugger)
if
debugger:
debugger
=
debugger(
self
)
debugger.gdb.dbg_hook
=
types.MethodType(dbg_hook, debugger.gdb)
self
.do_bin_patch()
if
self
.baremetal:
if
self
.count <
=
0
:
self
.count
=
-
1
self
.arch.run(count
=
self
.count, end
=
self
.exit_point)
else
:
self
.write_exit_trap()
self
.os.run()
if
debugger
and
self
.debugger:
debugger.run()