Skip to content

Commit

Permalink
debug: add interactive debug mode
Browse files Browse the repository at this point in the history
Introduce a new interactive debug cli which can be started by invoking the
ucode interpreter with the `-x` flag.

The main debugger functionality resides in the debug library while the cli
frontend just gains some minimal amount of code to load and instantiate the
debug library when the `-x` option is passed.

As a precondition for the new debug functionality, the ucode VM has been
extended with low level breakpoint support.

Signed-off-by: Jo-Philipp Wich <[email protected]>
  • Loading branch information
jow- committed May 24, 2024
1 parent 2a0240f commit 79e93c5
Show file tree
Hide file tree
Showing 5 changed files with 1,341 additions and 8 deletions.
8 changes: 7 additions & 1 deletion include/ucode/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,14 @@ typedef struct {
bool mcall, strict;
} uc_callframe_t;

typedef struct uc_breakpoint {
uint8_t *ip;
void (*cb)(uc_vm_t *, struct uc_breakpoint *);
} uc_breakpoint_t;

uc_declare_vector(uc_callframes_t, uc_callframe_t);
uc_declare_vector(uc_stack_t, uc_value_t *);
uc_declare_vector(uc_breakpoints_t, uc_breakpoint_t *);

typedef struct printbuf uc_stringbuf_t;

Expand All @@ -308,7 +314,7 @@ struct uc_vm {
uc_source_t *sources;
uc_weakref_t values;
uc_resource_types_t restypes;
char _reserved[sizeof(uc_modexports_t)];
uc_breakpoints_t breakpoints;
union {
uint32_t u32;
int32_t s32;
Expand Down
2 changes: 1 addition & 1 deletion include/ucode/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ typedef enum {

#define GC_DEFAULT_INTERVAL 1000

extern uint32_t insns[__I_MAX];
extern const int8_t insn_operand_bytes[__I_MAX];

void uc_vm_init(uc_vm_t *vm, uc_parse_config_t *config);
void uc_vm_free(uc_vm_t *vm);
Expand Down
Loading

0 comments on commit 79e93c5

Please sign in to comment.