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 
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 
38  bool rc = true;
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_API bool rz_bp_is_valid(RzBreakpoint *bp, RzBreakpointItem *b)
Definition: bp.c:406
RZ_API void rz_bp_restore_one(RzBreakpoint *bp, RzBreakpointItem *b, bool set)
Definition: bp_io.c:7
RZ_API int rz_bp_restore(RzBreakpoint *bp, bool set)
Definition: bp_io.c:28
RZ_API bool rz_bp_restore_except(RzBreakpoint *bp, bool set, ut64 addr)
Definition: bp_io.c:37
#define RZ_API
#define eprintf(x, y...)
Definition: rlcc.c:7
#define UT64_MAX
Definition: rz_types_base.h:86
#define b(i)
Definition: sha256.c:42
void * user
Definition: rz_bp.h:72
void(* maps_sync)(void *user)
synchronize any maps from the debugee
Definition: rz_bp.h:74
Definition: rz_bp.h:78
RzBreakpointCallback breakpoint
Definition: rz_bp.h:89
bool bpinmaps
Definition: rz_bp.h:83
RzBreakpointContext ctx
Definition: rz_bp.h:80
RzIOBind iob
Definition: rz_bp.h:84
RzList * bps
Definition: rz_bp.h:93
RzIOWriteAt write_at
Definition: rz_io.h:241
RzIO * io
Definition: rz_io.h:232
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58