radare2/libr/debug/regset.c
pancake 14ef1cf602 * Initial work on the register API for r_debug
- r_debug_reg and r_debug_regset
  - Handles dbg->newstate to force register sync
  - Only dbg.reg.read() for x86-32 and 64
* Added dummy copy of manpages (from old radare1)
2009-04-15 11:09:36 +00:00

39 lines
974 B
C

/* radare - LGPL - Copyright 2009 pancake<nopcode.org> */
#include <r_types.h>
#include <r_debug.h>
R_API struct r_debug_regset_t *r_debug_regset_new(int size)
{
struct r_debug_regset_t *r = MALLOC_STRUCT(struct r_debug_regset_t);
r->regs = MALLOC_STRUCTS(struct r_debug_regset_t, size);
r->nregs = size;
return r;
}
R_API void r_debug_regset_free(struct r_debug_regset_t *r)
{
if (r) {
free(r->regs);
free(r);
}
}
R_API int r_debug_regset_set(struct r_debug_regset_t *r, int idx, const char *name, u64 value)
{
if (idx<0 || idx>=r->nregs) {
eprintf("Out of range register index! More registers needs to be allocated in r_debug_regset_new()\n");
return R_FALSE;
}
strncpy(r->regs[idx].name, name, R_DEBUG_REG_NAME_MAX);
r->regs[idx].value = value;
r->regs[idx].isfloat = R_FALSE;
return R_TRUE;
}
R_API struct r_debug_regset_t *r_debug_regset_diff(struct r_debug_regset_t *a, struct r_debug_regset_t *b)
{
if (a == NULL || b == NULL)
return 0;
}