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

Go to the source code of this file.

Functions

RZ_IPI void rz_bp_item_insert (RzBreakpoint *bp, RzBreakpointItem *b)
 
static void rz_bp_watch_add_hw (RzBreakpoint *bp, RzBreakpointItem *b)
 
RZ_API RZ_BORROW RzBreakpointItemrz_bp_watch_add (RZ_NONNULL RzBreakpoint *bp, ut64 addr, int size, int hw, int perm)
 
RZ_API void rz_bp_watch_del (void)
 

Function Documentation

◆ rz_bp_item_insert()

RZ_IPI void rz_bp_item_insert ( RzBreakpoint bp,
RzBreakpointItem b 
)

Put an allocated RzBreakpointItem into the RzBreakpoint's list and give it an index

Definition at line 189 of file bp.c.

189  {
190  int i;
191  /* find empty slot */
192  for (i = 0; i < bp->bps_idx_count; i++) {
193  if (!bp->bps_idx[i]) {
194  break;
195  }
196  }
197  if (i == bp->bps_idx_count) {
198  /* allocate new slot */
199  bp->bps_idx_count += 16; // allocate space for 16 more bps
200  RzBreakpointItem **newbps = realloc(bp->bps_idx, bp->bps_idx_count * sizeof(RzBreakpointItem *));
201  if (newbps) {
202  bp->bps_idx = newbps;
203  for (int j = i; j < bp->bps_idx_count; j++) {
204  bp->bps_idx[j] = NULL;
205  }
206  } else {
207  bp->bps_idx_count -= 16; // allocate space for 16 more bps
208  i = 0; // avoid oob below
209  }
210  }
211  /* empty slot */
212  bp->bps_idx[i] = b;
213  bp->nbps++;
214  rz_list_append(bp->bps, b);
215 }
lzma_index ** i
Definition: index.h:629
#define NULL
Definition: cris-opc.c:27
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
void * realloc(void *ptr, size_t size)
Definition: malloc.c:144
#define b(i)
Definition: sha256.c:42
int nbps
Definition: rz_bp.h:91
RzBreakpointItem ** bps_idx
Definition: rz_bp.h:94
int bps_idx_count
Definition: rz_bp.h:95
RzList * bps
Definition: rz_bp.h:93

References b, rz_bp_t::bps, rz_bp_t::bps_idx, rz_bp_t::bps_idx_count, i, rz_bp_t::nbps, NULL, realloc(), and rz_list_append().

Referenced by rz_bp_add(), and rz_bp_watch_add().

◆ rz_bp_watch_add()

RZ_API RZ_BORROW RzBreakpointItem* rz_bp_watch_add ( RZ_NONNULL RzBreakpoint bp,
ut64  addr,
int  size,
int  hw,
int  perm 
)

Definition at line 15 of file bp_watch.c.

15  {
17  if (addr == UT64_MAX || size < 1) {
18  return NULL;
19  }
20  if (rz_bp_get_in(bp, addr, perm)) {
21  RZ_LOG_ERROR("Breakpoint already set at this address.\n");
22  return NULL;
23  }
25  if (!b) {
26  return NULL;
27  }
28  b->addr = addr;
29  b->size = size;
30  b->enabled = true;
31  b->perm = perm;
32  b->hw = hw;
33  if (hw) {
34  rz_bp_watch_add_hw(bp, b);
35  } else {
36  RZ_LOG_ERROR("[TODO]: Software watchpoint is not implemented yet (use ESIL)\n");
37  /* TODO */
38  }
39  rz_bp_item_insert(bp, b);
40  return b;
41 }
RZ_API RzBreakpointItem * rz_bp_get_in(RzBreakpoint *bp, ut64 addr, int perm)
Definition: bp.c:139
static void rz_bp_watch_add_hw(RzBreakpoint *bp, RzBreakpointItem *b)
Definition: bp_watch.c:9
RZ_IPI void rz_bp_item_insert(RzBreakpoint *bp, RzBreakpointItem *b)
Definition: bp.c:189
voidpf void uLong size
Definition: ioapi.h:138
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define UT64_MAX
Definition: rz_types_base.h:86
static int addr
Definition: z80asm.c:58

References addr, b, NULL, rz_bp_get_in(), rz_bp_item_insert(), rz_bp_watch_add_hw(), RZ_LOG_ERROR, RZ_NEW0, rz_return_val_if_fail, and UT64_MAX.

Referenced by rz_debug_bp_add().

◆ rz_bp_watch_add_hw()

static void rz_bp_watch_add_hw ( RzBreakpoint bp,
RzBreakpointItem b 
)
static

Definition at line 9 of file bp_watch.c.

9  {
10  if (bp->breakpoint) {
11  bp->breakpoint(bp, b, true);
12  }
13 }
RzBreakpointCallback breakpoint
Definition: rz_bp.h:89

References b, and rz_bp_t::breakpoint.

Referenced by rz_bp_watch_add().

◆ rz_bp_watch_del()

RZ_API void rz_bp_watch_del ( void  )

Definition at line 43 of file bp_watch.c.

43  {
44 }