* Added r_reg pkgconfig file
* Some fixes in the r_reg VAPI - Added vala test program * r_debug is now broken because the new r_reg * Add r_free_internal to reduce leaks in r_reg
This commit is contained in:
parent
b881d4b080
commit
85dfbe5255
|
@ -368,7 +368,7 @@ for A in ${ENVWORDS} ; do
|
|||
SEDFLAGS="${SEDFLAGS}s,@${A}@,${VAR},g;"
|
||||
done
|
||||
SEDFLAGS="${SEDFLAGS}'"
|
||||
for A in ./config-user.mk libr/include/r_userconf.h pkgcfg/libr.pc pkgcfg/r_io.pc pkgcfg/r_asm.pc pkgcfg/r_bin.pc pkgcfg/r_cons.pc pkgcfg/r_diff.pc pkgcfg/r_core.pc pkgcfg/r_socket.pc pkgcfg/r_line.pc pkgcfg/r_syscall.pc pkgcfg/r_macro.pc pkgcfg/r_util.pc pkgcfg/r_search.pc pkgcfg/r_vm.pc pkgcfg/r_th.pc pkgcfg/r_bp.pc pkgcfg/r_db.pc ; do # SUBDIRS
|
||||
for A in ./config-user.mk libr/include/r_userconf.h pkgcfg/libr.pc pkgcfg/r_io.pc pkgcfg/r_asm.pc pkgcfg/r_bin.pc pkgcfg/r_cons.pc pkgcfg/r_diff.pc pkgcfg/r_core.pc pkgcfg/r_socket.pc pkgcfg/r_debug.pc pkgcfg/r_reg.pc pkgcfg/r_line.pc pkgcfg/r_syscall.pc pkgcfg/r_macro.pc pkgcfg/r_util.pc pkgcfg/r_search.pc pkgcfg/r_vm.pc pkgcfg/r_th.pc pkgcfg/r_bp.pc pkgcfg/r_db.pc ; do # SUBDIRS
|
||||
if [ -f "${VPATH}/${A}.acr" ]; then
|
||||
SD_TARGET=${A}
|
||||
else
|
||||
|
|
|
@ -44,6 +44,8 @@ SUBDIRS ./config-user.mk libr/include/r_userconf.h
|
|||
pkgcfg/r_diff.pc
|
||||
pkgcfg/r_core.pc
|
||||
pkgcfg/r_socket.pc
|
||||
pkgcfg/r_debug.pc
|
||||
pkgcfg/r_reg.pc
|
||||
pkgcfg/r_line.pc
|
||||
pkgcfg/r_syscall.pc
|
||||
pkgcfg/r_macro.pc
|
||||
|
|
|
@ -18,6 +18,7 @@ static int r_debug_gdb_step(int pid)
|
|||
|
||||
struct r_debug_regset_t * r_debug_gdb_reg_read(int pid)
|
||||
{
|
||||
#if 0
|
||||
struct r_debug_regset *r = NULL;
|
||||
/* only for x86-32 */
|
||||
gdbwrap_gdbreg32 *reg = gdbwrap_readgenreg(desc);
|
||||
|
@ -32,6 +33,7 @@ struct r_debug_regset_t * r_debug_gdb_reg_read(int pid)
|
|||
r_debug_regset_set(r, 7, "ebp", reg->ebp);
|
||||
r_debug_regset_set(r, 8, "eip", reg->eip);
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int r_debug_gdb_reg_write(int pid, struct r_debug_regset_t *regs)
|
||||
|
|
|
@ -65,6 +65,7 @@ struct r_regset_t* r_debug_ptrace_reg_read(int pid)
|
|||
struct user_regs_struct regs;
|
||||
memset(®s,0, sizeof(regs));
|
||||
ptrace(PTRACE_GETREGS, pid, 0, ®s);
|
||||
#if 0
|
||||
#if __WORDSIZE == 64
|
||||
r = r_regset_new(17);
|
||||
r_regset_set(r, 0, "rax", regs.rax);
|
||||
|
@ -99,6 +100,7 @@ struct r_regset_t* r_debug_ptrace_reg_read(int pid)
|
|||
r_regset_set(r, 8, "eip", (ut64)(ut32)regs.eip);
|
||||
#endif
|
||||
#endif /* linux */
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -158,7 +160,7 @@ struct r_debug_handle_t r_debug_plugin_ptrace = {
|
|||
.detach = &r_debug_ptrace_detach,
|
||||
.wait = &r_debug_ptrace_wait,
|
||||
.get_arch = &r_debug_get_arch,
|
||||
.bp_write = &r_debug_ptrace_bp_write,
|
||||
//.bp_write = &r_debug_ptrace_bp_write,
|
||||
.reg_read = &r_debug_ptrace_reg_read,
|
||||
.reg_write = &r_debug_ptrace_reg_write,
|
||||
//.bp_read = &r_debug_ptrace_bp_read,
|
||||
|
|
|
@ -18,6 +18,7 @@ R_API int r_debug_reg_sync(struct r_debug_t *dbg, int write)
|
|||
}
|
||||
return (dbg->regs != NULL);
|
||||
}
|
||||
#if 0
|
||||
|
||||
R_API struct r_regset_t *r_debug_reg_diff(struct r_debug_t *dbg)
|
||||
{
|
||||
|
@ -66,3 +67,4 @@ R_API int r_debug_reg_list(struct r_debug_t *dbg, struct r_regset_t *rs, int rad
|
|||
}
|
||||
return R_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _INCLUDE_R_REG_H_
|
||||
|
||||
#include <r_types.h>
|
||||
#include <r_util.h>
|
||||
#include <list.h>
|
||||
|
||||
enum {
|
||||
|
|
|
@ -7,5 +7,5 @@ Name: libr
|
|||
Description: radare framework libraries
|
||||
Version: 0.1
|
||||
Requires:
|
||||
Libs: -L${libdir} -lr_core -lr_lang -lr_search -lr_cmd -lr_meta -lr_asm -lr_util
|
||||
Libs: -L${libdir} -lr_core -lr_lang -lr_search -lr_cmd -lr_meta -lr_asm -lr_util -lr_reg
|
||||
Cflags: -I${includedir}/libr
|
||||
|
|
|
@ -8,6 +8,17 @@
|
|||
|
||||
static void r_reg_free_internal(struct r_reg_t *reg)
|
||||
{
|
||||
struct list_head *pos, *n;
|
||||
struct r_reg_item_t *r;
|
||||
int i;
|
||||
|
||||
for(i=0;i<R_REG_TYPE_LAST;i++) {
|
||||
list_for_each_safe(pos, n, ®->regset[i].regs) {
|
||||
r = list_entry(pos, struct r_reg_item_t, list);
|
||||
list_del(&r->list);
|
||||
free(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
R_API struct r_reg_t *r_reg_free(struct r_reg_t *reg)
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Radare {
|
|||
[Compact]
|
||||
[CCode (cname="struct r_reg_t", free_function="r_reg_free", cprefix="r_reg_")]
|
||||
public class Register {
|
||||
[CCode (cprefix="R_REG_TYPE")]
|
||||
[CCode (cprefix="R_REG_TYPE_")]
|
||||
public enum Type {
|
||||
GPR,
|
||||
DRX,
|
||||
|
@ -17,8 +17,8 @@ namespace Radare {
|
|||
}
|
||||
|
||||
[Compact]
|
||||
[CCode (cname="struct r_reg_item_t", destroy_function="" )]
|
||||
public struct Item {
|
||||
[CCode (cname="struct r_reg_item_t", destroy_function="", free_function="" )]
|
||||
public class Item {
|
||||
public string name;
|
||||
public int size;
|
||||
public int offset;
|
||||
|
@ -27,25 +27,25 @@ namespace Radare {
|
|||
}
|
||||
|
||||
[Compact]
|
||||
[CCode (cname="struct r_reg_arena_t", destroy_function="" )]
|
||||
public struct Arena {
|
||||
[CCode (cname="struct r_reg_arena_t", destroy_function="", free_function="" )]
|
||||
public class Arena {
|
||||
public uint8* bytes;
|
||||
public int size;
|
||||
}
|
||||
|
||||
[Compact]
|
||||
[CCode (cname="struct r_reg_set_t", destroy_function="" )]
|
||||
public struct Set {
|
||||
[CCode (cname="struct r_reg_set_t", destroy_function="", free_function="" )]
|
||||
public class Set {
|
||||
public Register.Arena arena;
|
||||
public Radare.List<Register.Arena> arenas;
|
||||
public Radare.List<Register.Item> regs;
|
||||
public Radare.List<Register.Arena*> arenas;
|
||||
public Radare.List<Register.Item*> regs;
|
||||
}
|
||||
|
||||
public Register();
|
||||
public bool set_profile(string file);
|
||||
public bool set_profile_string(string profile);
|
||||
public Register.Item get(string name);
|
||||
public Radare.List<Register.Item> get_list(string profile);
|
||||
public Radare.List<Register.Item*> get_list(Register.Type type);
|
||||
|
||||
public uint64 get_value(Register.Item item);
|
||||
public bool set_value(Register.Item item, uint64 val);
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
all: core hash sc socket asm search iter bin db io list
|
||||
all: core regs hash sc socket asm search iter bin db io list
|
||||
@true
|
||||
|
||||
regs:
|
||||
valac --pkg r_reg regs.vala --pkg r_util
|
||||
|
||||
# XXX
|
||||
list:
|
||||
valac -o list list_c.c list.vala --pkg r_util --vapidir=${PWD}/.. -X -I.
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
using Radare;
|
||||
|
||||
void main() {
|
||||
|
||||
Register reg = new Register();
|
||||
|
||||
reg.set_profile_string("""
|
||||
gpr eip .32 0 0
|
||||
gpr eax .32 4 0
|
||||
"""
|
||||
);
|
||||
reg.set_value(reg.get("eax"), 666);
|
||||
|
||||
Radare.List<Register.Item*> head =
|
||||
reg.get_list(Register.Type.GPR);
|
||||
|
||||
foreach(Register.Item* item in head) {
|
||||
stdout.printf(" - %s (%d) = 0x%08llx\n",
|
||||
item->name, item->size,
|
||||
reg.get_value(item));
|
||||
}
|
||||
}
|
|
@ -7,5 +7,5 @@ Name: r_debug
|
|||
Description: radare foundation libraries
|
||||
Version: 0.2
|
||||
Requires:
|
||||
Libs: -L${libdir} -lr_debug
|
||||
Libs: -L${libdir} -lr_debug -lr_reg -lr_bp
|
||||
Cflags: -I${includedir}/libr
|
||||
|
|
Loading…
Reference in New Issue