2009-02-05 21:08:46 +00:00
|
|
|
#ifndef _INCLUDE_R_DEBUG_H_
|
|
|
|
#define _INCLUDE_R_DEBUG_H_
|
|
|
|
|
|
|
|
#include <r_types.h>
|
|
|
|
#include <r_util.h>
|
|
|
|
#include <r_reg.h>
|
2009-04-11 21:22:20 +00:00
|
|
|
#include <r_bp.h>
|
2009-09-10 20:51:34 +00:00
|
|
|
#include <r_io.h>
|
2009-02-05 21:08:46 +00:00
|
|
|
#include <r_syscall.h>
|
|
|
|
#include "list.h"
|
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
enum {
|
|
|
|
R_DBG_PROC_STOP,
|
|
|
|
R_DBG_PROC_RUN,
|
|
|
|
R_DBG_PROC_SLEEP,
|
|
|
|
R_DBG_PROC_ZOMBIE,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct r_debug_t {
|
2009-09-20 00:16:14 +00:00
|
|
|
int pid; /* selected process id */
|
|
|
|
int tid; /* selected thread id */
|
|
|
|
int swstep; /* steps with software traps */
|
|
|
|
int steps; /* counter of steps done */
|
|
|
|
int newstate;
|
2010-01-19 10:25:17 +00:00
|
|
|
char *reg_profile;
|
2009-09-20 00:16:14 +00:00
|
|
|
struct r_reg_t *reg;
|
2009-09-22 11:27:33 +00:00
|
|
|
//struct r_regset_t *oregs;
|
|
|
|
//struct r_regset_t *regs;
|
2009-09-20 00:16:14 +00:00
|
|
|
struct r_bp_t *bp;
|
|
|
|
void *user;
|
|
|
|
/* io */
|
|
|
|
void (*printf)(const char *str, ...);
|
|
|
|
struct r_debug_handle_t *h;
|
|
|
|
struct list_head handlers;
|
|
|
|
/* TODO
|
|
|
|
- list of processes and their threads
|
|
|
|
- list of mapped memory (from /proc/XX/maps)
|
|
|
|
- list of managed memory (allocated in child...)
|
|
|
|
*/
|
2009-12-24 02:17:53 +00:00
|
|
|
} rDebug;
|
2009-09-20 00:16:14 +00:00
|
|
|
|
2009-02-05 21:08:46 +00:00
|
|
|
/* TODO: pass dbg and user data pointer everywhere */
|
2009-12-24 02:17:53 +00:00
|
|
|
typedef struct r_debug_handle_t {
|
2009-02-05 21:08:46 +00:00
|
|
|
const char *name;
|
2009-04-15 11:09:36 +00:00
|
|
|
const char **archs;
|
2009-09-15 11:24:28 +00:00
|
|
|
int (*get_arch)();
|
|
|
|
/* life */
|
2009-08-22 01:54:24 +00:00
|
|
|
int (*startv)(int argc, char **argv);
|
2009-02-05 21:08:46 +00:00
|
|
|
int (*attach)(int pid);
|
|
|
|
int (*detach)(int pid);
|
2009-09-15 11:24:28 +00:00
|
|
|
/* flow */
|
2009-02-16 10:24:45 +00:00
|
|
|
int (*step)(int pid); // if step() is NULL; reimplement it with traps
|
2010-01-19 10:25:17 +00:00
|
|
|
int (*cont)(int pid, int sig);
|
2009-02-18 00:43:57 +00:00
|
|
|
int (*wait)(int pid);
|
2009-02-05 21:08:46 +00:00
|
|
|
int (*contsc)(int pid, int sc);
|
2009-09-15 11:24:28 +00:00
|
|
|
/* registers */
|
2010-01-21 01:38:52 +00:00
|
|
|
rBreakpointCallback breakpoint;
|
2009-09-20 00:16:14 +00:00
|
|
|
int (*reg_read)(struct r_debug_t *dbg, int type, ut8 *buf, int size);
|
|
|
|
char* (*reg_profile)();
|
2010-01-19 10:25:17 +00:00
|
|
|
int (*reg_write)(int pid, int type, const ut8 *buf, int size); //XXX struct r_regset_t regs);
|
2009-09-15 11:24:28 +00:00
|
|
|
/* memory */
|
2010-01-21 01:38:52 +00:00
|
|
|
ut64 (*mem_alloc)(void *user, ut64 size, ut64 addr);
|
|
|
|
int (*mem_free)(void *user, ut64 addr);
|
2009-09-15 11:24:28 +00:00
|
|
|
|
2009-02-05 21:08:46 +00:00
|
|
|
struct list_head list;
|
2009-12-24 02:17:53 +00:00
|
|
|
} rDebugHandle;
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
// TODO: rename to r_debug_process_t ? maybe a thread too ?
|
|
|
|
typedef struct r_debug_pid_t {
|
2009-04-01 22:44:43 +00:00
|
|
|
int pid;
|
|
|
|
int status; /* stopped, running, zombie, sleeping ,... */
|
|
|
|
int runnable; /* when using 'run', 'continue', .. this proc will be runnable */
|
|
|
|
struct list_head threads;
|
|
|
|
struct list_head childs;
|
|
|
|
struct r_debug_pid_t *parent;
|
|
|
|
struct list_head list;
|
2009-12-24 02:17:53 +00:00
|
|
|
} rDebugPid;
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
#ifdef R_API
|
2009-09-20 00:16:14 +00:00
|
|
|
R_API int r_debug_use(struct r_debug_t *dbg, const char *str);
|
2009-04-16 20:49:18 +00:00
|
|
|
R_API int r_debug_handle_add(struct r_debug_t *dbg, struct r_debug_handle_t *foo);
|
|
|
|
R_API int r_debug_handle_init(struct r_debug_t *dbg);
|
2009-09-22 11:27:33 +00:00
|
|
|
R_API int r_debug_handle_list(struct r_debug_t *dbg);
|
2009-09-20 00:16:14 +00:00
|
|
|
|
2010-01-19 10:25:17 +00:00
|
|
|
R_API struct r_debug_t *r_debug_init(struct r_debug_t *dbg, int hard);
|
2009-08-22 03:11:33 +00:00
|
|
|
R_API struct r_debug_t *r_debug_new();
|
|
|
|
R_API struct r_debug_t *r_debug_free(struct r_debug_t *dbg);
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2009-04-01 22:44:43 +00:00
|
|
|
/* send signals */
|
2009-04-16 20:49:18 +00:00
|
|
|
R_API int r_debug_kill(struct r_debug_t *dbg, int pid, int sig);
|
|
|
|
R_API int r_debug_step(struct r_debug_t *dbg, int steps);
|
|
|
|
R_API int r_debug_continue(struct r_debug_t *dbg);
|
2010-01-19 10:25:17 +00:00
|
|
|
R_API int r_debug_continue_kill(struct r_debug_t *dbg, int signal);
|
2009-04-16 20:49:18 +00:00
|
|
|
R_API int r_debug_select(struct r_debug_t *dbg, int pid, int tid);
|
2009-08-14 00:37:18 +00:00
|
|
|
|
2009-03-06 00:00:41 +00:00
|
|
|
/* handle.c */
|
2009-04-16 20:49:18 +00:00
|
|
|
R_API int r_debug_handle_init(struct r_debug_t *dbg);
|
|
|
|
R_API int r_debug_handle_set(struct r_debug_t *dbg, const char *str);
|
2009-08-22 01:54:24 +00:00
|
|
|
R_API int r_debug_handle_list(struct r_debug_t *dbg);
|
2009-04-16 20:49:18 +00:00
|
|
|
R_API int r_debug_handle_add(struct r_debug_t *dbg, struct r_debug_handle_t *foo);
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2009-09-17 09:48:36 +00:00
|
|
|
/* memory */
|
2010-01-21 01:38:52 +00:00
|
|
|
R_API ut64 r_debug_mem_alloc(struct r_debug_t *dbg, ut64 size, ut64 addr);
|
|
|
|
R_API int r_debug_mem_free(struct r_debug_t *dbg, ut64 addr);
|
2009-04-16 20:49:18 +00:00
|
|
|
|
|
|
|
/* registers */
|
2009-09-20 00:16:14 +00:00
|
|
|
R_API int r_debug_reg_sync(struct r_debug_t *dbg, int type, int write);
|
|
|
|
R_API int r_debug_reg_list(struct r_debug_t *dbg, int type, int size, int rad);
|
2009-09-22 11:27:33 +00:00
|
|
|
#endif
|
2009-12-24 02:17:53 +00:00
|
|
|
#endif
|
2009-04-16 20:49:18 +00:00
|
|
|
|
|
|
|
/* regset */
|
2009-09-22 11:27:33 +00:00
|
|
|
//R_API struct r_regset_t* r_regset_diff(struct r_regset_t *a, struct r_regset_t *b);
|
|
|
|
//R_API int r_regset_set(struct r_regset_t *r, int idx, const char *name, ut64 value);
|
|
|
|
//R_API struct r_regset_t *r_regset_new(int size);
|
|
|
|
//R_API void r_regset_free(struct r_regset_t *r);
|
2009-08-14 00:37:18 +00:00
|
|
|
|
2009-02-05 21:08:46 +00:00
|
|
|
#if 0
|
|
|
|
Missing callbacks
|
|
|
|
=================
|
|
|
|
- alloc
|
|
|
|
- dealloc
|
|
|
|
- list maps
|
|
|
|
- change memory protections
|
|
|
|
- touchtrace
|
|
|
|
- filedescriptor set/get/mod..
|
|
|
|
- get/set signals
|
|
|
|
- get regs, set regs
|
|
|
|
|
|
|
|
#endif
|