2018-02-24 03:58:30 +00:00
|
|
|
#ifndef _VM_DEBUG_H_
|
|
|
|
#define _VM_DEBUG_H_
|
|
|
|
|
2018-02-25 20:25:02 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2018-02-24 22:30:46 +00:00
|
|
|
struct vm_debug_args;
|
|
|
|
typedef struct vm_debug_args vm_debug_args;
|
2018-02-24 03:58:30 +00:00
|
|
|
|
|
|
|
typedef void (*vm_debug_func)(vm_debug_args *);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
/*
|
|
|
|
* The name field is the full name of the command; each command also
|
|
|
|
* has an abbreviated form (either is acceptable as input), which is
|
|
|
|
* defined in the abbrev field.
|
|
|
|
*/
|
|
|
|
char *name;
|
|
|
|
char *abbrev;
|
|
|
|
|
|
|
|
/*
|
2018-02-25 00:57:00 +00:00
|
|
|
* The function that will do something with the command's input
|
2018-02-24 03:58:30 +00:00
|
|
|
*/
|
2018-02-25 00:57:00 +00:00
|
|
|
vm_debug_func handler;
|
2018-02-24 03:58:30 +00:00
|
|
|
|
|
|
|
/*
|
2018-02-25 00:57:00 +00:00
|
|
|
* The number of arguments we expect to see
|
2018-02-24 03:58:30 +00:00
|
|
|
*/
|
2018-02-25 00:57:00 +00:00
|
|
|
int nargs;
|
2018-02-24 03:58:30 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* What do our arguments look like?
|
|
|
|
*/
|
|
|
|
char *argdesc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* What do we do?
|
|
|
|
*/
|
|
|
|
char *desc;
|
|
|
|
} vm_debug_cmd;
|
|
|
|
|
2018-02-24 22:30:46 +00:00
|
|
|
struct vm_debug_args {
|
|
|
|
/*
|
|
|
|
* Most commands that need an argument will simply use addr1, but a
|
|
|
|
* few have more than one address--hence addr2.
|
|
|
|
*/
|
|
|
|
int addr1;
|
|
|
|
int addr2;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we have a thing we want to work with, but want to leave what
|
|
|
|
* that is up to the helper func, then you can write it into the
|
|
|
|
* target.
|
|
|
|
*
|
|
|
|
* If a command uses target, followed by an address, that address
|
|
|
|
* will be in addr1.
|
|
|
|
*/
|
|
|
|
char *target;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The command our arguments are attached to; from here we can call
|
|
|
|
* the handler with ourselves. (Very meta.)
|
|
|
|
*/
|
|
|
|
vm_debug_cmd *cmd;
|
|
|
|
};
|
|
|
|
|
2018-02-24 03:58:30 +00:00
|
|
|
#define DEBUG_CMD(x) \
|
|
|
|
void vm_debug_cmd_##x (vm_debug_args *args)
|
|
|
|
|
2018-02-27 00:53:59 +00:00
|
|
|
extern int vm_debug_addr(const char *);
|
2018-02-25 20:25:02 +00:00
|
|
|
extern bool vm_debug_broke(int);
|
2018-02-27 00:53:59 +00:00
|
|
|
extern char *vm_debug_next_arg(char **);
|
2018-02-25 20:25:02 +00:00
|
|
|
extern char *vm_debug_prompt();
|
2018-02-24 22:30:46 +00:00
|
|
|
extern vm_debug_cmd *vm_debug_find_cmd(const char *);
|
2018-02-25 20:25:02 +00:00
|
|
|
extern void vm_debug_break(int);
|
2018-02-24 22:30:46 +00:00
|
|
|
extern void vm_debug_execute(const char *);
|
2018-02-25 20:25:02 +00:00
|
|
|
extern void vm_debug_quit();
|
2018-02-25 20:38:24 +00:00
|
|
|
extern void vm_debug_unbreak(int);
|
|
|
|
extern void vm_debug_unbreak_all();
|
2018-02-24 22:30:46 +00:00
|
|
|
|
2018-02-25 20:38:24 +00:00
|
|
|
extern DEBUG_CMD(break);
|
2018-02-24 03:58:30 +00:00
|
|
|
extern DEBUG_CMD(help);
|
2018-02-25 01:36:02 +00:00
|
|
|
extern DEBUG_CMD(jump);
|
2018-02-25 00:57:00 +00:00
|
|
|
extern DEBUG_CMD(printaddr);
|
|
|
|
extern DEBUG_CMD(printstate);
|
2018-02-25 20:25:02 +00:00
|
|
|
extern DEBUG_CMD(quit);
|
2018-02-24 22:30:46 +00:00
|
|
|
extern DEBUG_CMD(resume);
|
2018-02-25 21:41:37 +00:00
|
|
|
extern DEBUG_CMD(step);
|
2018-02-25 20:38:24 +00:00
|
|
|
extern DEBUG_CMD(unbreak);
|
2018-02-25 01:38:04 +00:00
|
|
|
extern DEBUG_CMD(writeaddr);
|
2018-02-25 20:25:02 +00:00
|
|
|
extern DEBUG_CMD(writestate);
|
2018-02-24 03:58:30 +00:00
|
|
|
|
|
|
|
#endif
|