From 1b5f8d2e5a118a80a4373a7be1ca4e4eceebf7be Mon Sep 17 00:00:00 2001 From: Malfurious Date: Sat, 8 Jul 2023 11:27:56 -0400 Subject: Initial debugger core and test UI This is vaguely competent at tracing single-threaded programs. Vi-like keybinds defined in misplays.c. Signed-off-by: Malfurious --- debugger.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 debugger.h (limited to 'debugger.h') diff --git a/debugger.h b/debugger.h new file mode 100644 index 0000000..6305e96 --- /dev/null +++ b/debugger.h @@ -0,0 +1,55 @@ +#pragma once + +#include +#include + +#include "console.h" +#include "list.h" + +#define BREAKPOINT_INSN 0xcc + +struct breakpoint { + LINKEDLIST; + unsigned long address; + unsigned long stack; + unsigned long orig; + int enabled; + int active; +}; + +struct map { + LINKEDLIST; + unsigned long start; + unsigned long end; + void *data; +}; + +struct state { + LINKEDLIST; + struct user_regs_struct regs; + struct user_fpregs_struct fpregs; + struct list maps; +}; + +struct tracee { + struct list breaks; + struct list states; + struct state *state; + pid_t id; + int child; + int stopped; + int status; + int signal; + int cont; + void *buff; + size_t buffsize; +}; + +extern int dbg_process(struct tracee *dbg, pid_t pid); +extern int dbg_new_process(struct tracee *dbg, char **argv, struct console *cons); +extern int dbg_wait(struct tracee *dbg); +extern int dbg_stepin(struct tracee *dbg); +extern int dbg_stepover(struct tracee *dbg); +//extern int dbg_stepout(struct tracee *dbg); +extern int dbg_cont(struct tracee *dbg, int mode); +extern void *deref(struct tracee *dbg, unsigned long addr, size_t size); -- cgit v1.2.3