Rizin
unix-like reverse engineering framework and cli tools
bp_io.c File Reference
#include <rz_bp.h>
#include <config.h>

Go to the source code of this file.

Functions

RZ_API void rz_bp_restore_one (RzBreakpoint *bp, RzBreakpointItem *b, bool set)
 
RZ_API int rz_bp_restore (RzBreakpoint *bp, bool set)
 
RZ_API bool rz_bp_restore_except (RzBreakpoint *bp, bool set, ut64 addr)
 

Function Documentation

◆ rz_bp_restore()

RZ_API int rz_bp_restore ( RzBreakpoint bp,
bool  set 
)

reflect all rz_bp stuff in the process using dbg->bp_write or ->breakpoint

Definition at line 28 of file bp_io.c.

28  {
29  return rz_bp_restore_except(bp, set, UT64_MAX);
30 }
RZ_API bool rz_bp_restore_except(RzBreakpoint *bp, bool set, ut64 addr)
Definition: bp_io.c:37
#define UT64_MAX
Definition: rz_types_base.h:86

References rz_bp_restore_except(), and UT64_MAX.

Referenced by linux_remove_fork_bps(), rz_debug_bp_hit(), rz_debug_bps_enable(), rz_debug_continue_kill(), and rz_debug_step_hard().

◆ rz_bp_restore_except()

RZ_API bool rz_bp_restore_except ( RzBreakpoint bp,
bool  set,
ut64  addr 
)

reflect all rz_bp stuff in the process using dbg->bp_write or ->breakpoint

except the specified breakpoint...

Definition at line 37 of file bp_io.c.

37  {
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
#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
RzBreakpointCallback breakpoint
Definition: rz_bp.h:89
bool bpinmaps
Definition: rz_bp.h:83
RzBreakpointContext ctx
Definition: rz_bp.h:80
RzList * bps
Definition: rz_bp.h:93
static int addr
Definition: z80asm.c:58

References addr, b, rz_bp_t::bpinmaps, rz_bp_t::bps, rz_bp_t::breakpoint, rz_bp_t::ctx, rz_bp_context_t::maps_sync, rz_bp_is_valid(), rz_bp_restore_one(), and rz_bp_context_t::user.

Referenced by rz_bp_restore(), and rz_debug_recoil().

◆ rz_bp_restore_one()

RZ_API void rz_bp_restore_one ( RzBreakpoint bp,
RzBreakpointItem b,
bool  set 
)

Definition at line 7 of file bp_io.c.

7  {
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 }
#define eprintf(x, y...)
Definition: rlcc.c:7
RzIOBind iob
Definition: rz_bp.h:84
RzIOWriteAt write_at
Definition: rz_io.h:241
RzIO * io
Definition: rz_io.h:232

References b, eprintf, rz_io_bind_t::io, rz_bp_t::iob, and rz_io_bind_t::write_at.

Referenced by rz_bp_restore_except().