Rizin
unix-like reverse engineering framework and cli tools
bp_io.c
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2009-2018 pancake <pancake@nopcode.org>
2
// SPDX-License-Identifier: LGPL-3.0-only
3
4
#include <
rz_bp.h
>
5
#include <config.h>
6
7
RZ_API
void
rz_bp_restore_one
(
RzBreakpoint
*bp,
RzBreakpointItem
*
b
,
bool
set) {
8
if
(set) {
9
// eprintf ("Setting bp at 0x%08"PFMT64x"\n", b->addr);
10
if
(
b
->hw || !
b
->bbytes) {
11
eprintf
(
"hw breakpoints not yet supported\n"
);
12
}
else
{
13
bp->
iob
.
write_at
(bp->
iob
.
io
,
b
->addr,
b
->bbytes,
b
->size);
14
}
15
}
else
{
16
// eprintf ("Clearing bp at 0x%08"PFMT64x"\n", b->addr);
17
if
(
b
->hw || !
b
->obytes) {
18
eprintf
(
"hw breakpoints not yet supported\n"
);
19
}
else
{
20
bp->
iob
.
write_at
(bp->
iob
.
io
,
b
->addr,
b
->obytes,
b
->size);
21
}
22
}
23
}
24
28
RZ_API
int
rz_bp_restore
(
RzBreakpoint
*bp,
bool
set) {
29
return
rz_bp_restore_except
(bp, set,
UT64_MAX
);
30
}
31
37
RZ_API
bool
rz_bp_restore_except
(
RzBreakpoint
*bp,
bool
set,
ut64
addr
) {
38
bool
rc =
true
;
39
RzListIter
*
iter
;
40
RzBreakpointItem
*
b
;
41
42
if
(set && bp->
bpinmaps
&& bp->
ctx
.
maps_sync
) {
43
bp->
ctx
.
maps_sync
(bp->
ctx
.
user
);
44
}
45
46
rz_list_foreach (bp->
bps
,
iter
,
b
) {
47
if
(
addr
&&
b
->addr ==
addr
) {
48
continue
;
49
}
50
// Avoid restoring disabled breakpoints
51
if
(set && !
b
->enabled) {
52
continue
;
53
}
54
// Check if the breakpoint is in a valid map
55
if
(set && bp->
bpinmaps
&& !
rz_bp_is_valid
(bp,
b
)) {
56
continue
;
57
}
58
if
(bp->
breakpoint
&& bp->
breakpoint
(bp,
b
, set)) {
59
continue
;
60
}
61
62
/* write (o|b)bytes from every breakpoint in rz_bp if not handled by plugin */
63
rz_bp_restore_one
(bp,
b
, set);
64
rc =
true
;
65
}
66
return
rc;
67
}
rz_bp_is_valid
RZ_API bool rz_bp_is_valid(RzBreakpoint *bp, RzBreakpointItem *b)
Definition:
bp.c:406
rz_bp_restore_one
RZ_API void rz_bp_restore_one(RzBreakpoint *bp, RzBreakpointItem *b, bool set)
Definition:
bp_io.c:7
rz_bp_restore
RZ_API int rz_bp_restore(RzBreakpoint *bp, bool set)
Definition:
bp_io.c:28
rz_bp_restore_except
RZ_API bool rz_bp_restore_except(RzBreakpoint *bp, bool set, ut64 addr)
Definition:
bp_io.c:37
RZ_API
#define RZ_API
Definition:
core_plugin_example.c:36
iter
Definition:
test_winkernel.cpp:47
eprintf
#define eprintf(x, y...)
Definition:
rlcc.c:7
rz_bp.h
UT64_MAX
#define UT64_MAX
Definition:
rz_types_base.h:86
b
#define b(i)
Definition:
sha256.c:42
rz_bp_context_t::user
void * user
Definition:
rz_bp.h:72
rz_bp_context_t::maps_sync
void(* maps_sync)(void *user)
synchronize any maps from the debugee
Definition:
rz_bp.h:74
rz_bp_item_t
Definition:
rz_bp.h:41
rz_bp_t
Definition:
rz_bp.h:78
rz_bp_t::breakpoint
RzBreakpointCallback breakpoint
Definition:
rz_bp.h:89
rz_bp_t::bpinmaps
bool bpinmaps
Definition:
rz_bp.h:83
rz_bp_t::ctx
RzBreakpointContext ctx
Definition:
rz_bp.h:80
rz_bp_t::iob
RzIOBind iob
Definition:
rz_bp.h:84
rz_bp_t::bps
RzList * bps
Definition:
rz_bp.h:93
rz_io_bind_t::write_at
RzIOWriteAt write_at
Definition:
rz_io.h:241
rz_io_bind_t::io
RzIO * io
Definition:
rz_io.h:232
rz_list_iter_t
Definition:
rz_list.h:13
ut64
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
addr
static int addr
Definition:
z80asm.c:58
librz
bp
bp_io.c
Generated by
1.9.1