summaryrefslogtreecommitdiffstats
path: root/debugger.h
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2023-07-08 11:27:56 -0400
committerMalfurious <m@lfurio.us>2023-07-08 11:27:56 -0400
commit1b5f8d2e5a118a80a4373a7be1ca4e4eceebf7be (patch)
tree62ee155841728954887285e97f04d069ecdf39a4 /debugger.h
parentc29bf2efbdc4f4186f3fe571601b4d1acac4b321 (diff)
downloadmisplays-1b5f8d2e5a118a80a4373a7be1ca4e4eceebf7be.tar.gz
misplays-1b5f8d2e5a118a80a4373a7be1ca4e4eceebf7be.zip
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 <m@lfurio.us>
Diffstat (limited to 'debugger.h')
-rw-r--r--debugger.h55
1 files changed, 55 insertions, 0 deletions
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 <sys/user.h>
+#include <unistd.h>
+
+#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);