From d070fde6478431c71fb4a55e783a577439c7cb99 Mon Sep 17 00:00:00 2001 From: Malfurious Date: Thu, 20 Jul 2023 14:55:13 -0400 Subject: Multithread version 1 Signed-off-by: Malfurious --- debugger.h | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 14 deletions(-) (limited to 'debugger.h') diff --git a/debugger.h b/debugger.h index 6305e96..cf2c442 100644 --- a/debugger.h +++ b/debugger.h @@ -8,13 +8,19 @@ #define BREAKPOINT_INSN 0xcc +extern PANEL *consolepan; + struct breakpoint { LINKEDLIST; + unsigned long orig; unsigned long address; unsigned long stack; - unsigned long orig; + pid_t tid; int enabled; int active; + /* add count field + * and stop boolean + * to implement checkpoints? */ }; struct map { @@ -31,25 +37,77 @@ struct state { struct list maps; }; -struct tracee { - struct list breaks; +struct process { + pid_t id; + int child; + struct list breakpoints; + struct list threads; +}; + +struct thread { + LINKEDLIST; + struct process *proc; + struct list states; struct state *state; + int clearstates; + pid_t id; - int child; int stopped; - int status; int signal; int cont; - void *buff; - size_t buffsize; + const char *status; }; -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 void add_breakpoint(struct process *proc, unsigned long address, unsigned long stack, pid_t tid, int enabled); +extern int is_breakpoint(struct process *proc, unsigned long address); + +extern int dbg_process(struct process *proc, pid_t pid, int child); +extern int dbg_detach(struct process *proc); +extern int dbg_wait(struct thread *th, int dostops); +extern int dbg_cont(struct thread *th, int cont); +extern int dbg_stepin(struct thread *th); +extern int dbg_intr(struct thread *th); +extern void *deref(struct thread *th, unsigned long addr, size_t size); + + + + + + + + + +/* how to do an async 'all-cont': + * + * mark all threads for PTRACE_CONT + * singlestep all threads + * this is needed to step past any thread that may be starting at a breakpoint + * wait all single steps (note that some may hang...) + * once all single steps completed, install breakpoints and actually cont threads + */ + +//extern void add_breakpoint(struct process *proc, unsigned long address, unsigned long stack, pid_t tid, int enabled); +//extern int is_breakpoint(struct process *proc, unsigned long address); +// +//extern int dbg_process(struct process *proc, pid_t pid); +//extern int dbg_wait(struct thread *th, int dostops); +//extern int dbg_stepin(struct thread *th); +//extern int dbg_stepover(struct thread *th); +//extern int dbg_cont(struct thread *th, int cont); +//extern int dbg_intr(struct thread *th); +//extern int dbg_detach(struct process *proc); +//extern void *deref(struct thread *th, unsigned long addr, size_t size); + + + + +//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, PANEL *pan); +//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); +//extern int dbg_cont(struct tracee *dbg, int mode); +//extern void *deref(struct tracee *dbg, unsigned long addr, size_t size); +//extern void dbg_free(struct tracee *dbg); -- cgit v1.2.3 From b4abda51217101ceffd19c3d403e40781e15dcec Mon Sep 17 00:00:00 2001 From: Malfurious Date: Tue, 19 Sep 2023 11:02:03 -0400 Subject: Multithread version 2 Signed-off-by: Malfurious --- debugger.h | 75 +++++++++++++++----------------------------------------------- 1 file changed, 18 insertions(+), 57 deletions(-) (limited to 'debugger.h') diff --git a/debugger.h b/debugger.h index cf2c442..845bf69 100644 --- a/debugger.h +++ b/debugger.h @@ -3,24 +3,19 @@ #include #include -#include "console.h" #include "list.h" -#define BREAKPOINT_INSN 0xcc - -extern PANEL *consolepan; - struct breakpoint { LINKEDLIST; - unsigned long orig; + unsigned long address; + unsigned long text; + int installed; + int hits; + unsigned long stack; pid_t tid; int enabled; - int active; - /* add count field - * and stop boolean - * to implement checkpoints? */ }; struct map { @@ -38,10 +33,11 @@ struct state { }; struct process { + LINKEDLIST; pid_t id; int child; - struct list breakpoints; struct list threads; + struct list breakpoints; }; struct thread { @@ -56,58 +52,23 @@ struct thread { int stopped; int signal; int cont; + const char *status; }; +//extern struct list global_processes; +//extern struct thread *global_thread; + extern void add_breakpoint(struct process *proc, unsigned long address, unsigned long stack, pid_t tid, int enabled); extern int is_breakpoint(struct process *proc, unsigned long address); -extern int dbg_process(struct process *proc, pid_t pid, int child); +extern struct process *dbg_attach(pid_t pid, int child); extern int dbg_detach(struct process *proc); -extern int dbg_wait(struct thread *th, int dostops); -extern int dbg_cont(struct thread *th, int cont); -extern int dbg_stepin(struct thread *th); -extern int dbg_intr(struct thread *th); -extern void *deref(struct thread *th, unsigned long addr, size_t size); - - - - - - - - - -/* how to do an async 'all-cont': - * - * mark all threads for PTRACE_CONT - * singlestep all threads - * this is needed to step past any thread that may be starting at a breakpoint - * wait all single steps (note that some may hang...) - * once all single steps completed, install breakpoints and actually cont threads - */ - -//extern void add_breakpoint(struct process *proc, unsigned long address, unsigned long stack, pid_t tid, int enabled); -//extern int is_breakpoint(struct process *proc, unsigned long address); -// -//extern int dbg_process(struct process *proc, pid_t pid); -//extern int dbg_wait(struct thread *th, int dostops); -//extern int dbg_stepin(struct thread *th); -//extern int dbg_stepover(struct thread *th); -//extern int dbg_cont(struct thread *th, int cont); -//extern int dbg_intr(struct thread *th); -//extern int dbg_detach(struct process *proc); -//extern void *deref(struct thread *th, unsigned long addr, size_t size); - - +extern int dbg_wait(struct thread *th, int recursion); +extern int dbg_intr(struct thread *th); +extern int dbg_cont(struct thread *th, int cont); +extern int dbg_step(struct thread *th, int stepover); +extern int dbg_pets(struct thread *th); -//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, PANEL *pan); -//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); -//extern void dbg_free(struct tracee *dbg); +extern void *deref(struct thread *th, unsigned long address, size_t size); -- cgit v1.2.3 From 41945242524f9ecc795138fdb5beb31362f7826a Mon Sep 17 00:00:00 2001 From: Malfurious Date: Thu, 28 Sep 2023 15:05:51 -0400 Subject: dbg_realcont for testing purposes Signed-off-by: Malfurious --- debugger.h | 1 + 1 file changed, 1 insertion(+) (limited to 'debugger.h') diff --git a/debugger.h b/debugger.h index 845bf69..2705f92 100644 --- a/debugger.h +++ b/debugger.h @@ -68,6 +68,7 @@ extern int dbg_wait(struct thread *th, int recursion); extern int dbg_intr(struct thread *th); extern int dbg_cont(struct thread *th, int cont); +extern int dbg_realcont(struct thread *th); extern int dbg_step(struct thread *th, int stepover); extern int dbg_pets(struct thread *th); -- cgit v1.2.3 From 46f72be263cf29688f684e90f2e149e5c911016b Mon Sep 17 00:00:00 2001 From: Malfurious Date: Mon, 2 Oct 2023 03:18:21 -0400 Subject: Multithread version 3 Signed-off-by: Malfurious --- debugger.h | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'debugger.h') diff --git a/debugger.h b/debugger.h index 2705f92..ef08d43 100644 --- a/debugger.h +++ b/debugger.h @@ -12,6 +12,7 @@ struct breakpoint { unsigned long text; int installed; int hits; + int user; unsigned long stack; pid_t tid; @@ -28,7 +29,6 @@ struct map { struct state { LINKEDLIST; struct user_regs_struct regs; - struct user_fpregs_struct fpregs; struct list maps; }; @@ -36,8 +36,9 @@ struct process { LINKEDLIST; pid_t id; int child; - struct list threads; struct list breakpoints; + struct list threads; + char status[128]; }; struct thread { @@ -52,24 +53,25 @@ struct thread { int stopped; int signal; int cont; + int shouldcont; - const char *status; + char status[128]; }; -//extern struct list global_processes; -//extern struct thread *global_thread; - -extern void add_breakpoint(struct process *proc, unsigned long address, unsigned long stack, pid_t tid, int enabled); -extern int is_breakpoint(struct process *proc, unsigned long address); +extern struct breakpoint*add_breakpoint(struct process*proc,unsigned long address); +extern struct breakpoint*get_breakpoint(struct process*proc,unsigned long address); extern struct process *dbg_attach(pid_t pid, int child); -extern int dbg_detach(struct process *proc); -extern int dbg_wait(struct thread *th, int recursion); +extern void dbg_detach(struct process *proc); +extern int dbg_free(struct thread *th); + +extern int dbg_wait(struct thread *th, int primary); extern int dbg_intr(struct thread *th); -extern int dbg_cont(struct thread *th, int cont); -extern int dbg_realcont(struct thread *th); -extern int dbg_step(struct thread *th, int stepover); -extern int dbg_pets(struct thread *th); +extern int dbg_cont(struct thread *th); +extern int dbg_syscall(struct thread *th); +extern int dbg_stepin(struct thread *th); +extern int dbg_stepover(struct thread *th); +extern int dbg_stepback(struct thread *th); extern void *deref(struct thread *th, unsigned long address, size_t size); -- cgit v1.2.3 From 66db439988aa07828593aac109f5690bb48f2dc9 Mon Sep 17 00:00:00 2001 From: Malfurious Date: Fri, 6 Oct 2023 04:55:18 -0400 Subject: Independent thread control refactor Signed-off-by: Malfurious --- debugger.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'debugger.h') diff --git a/debugger.h b/debugger.h index ef08d43..cea3bba 100644 --- a/debugger.h +++ b/debugger.h @@ -52,8 +52,8 @@ struct thread { pid_t id; int stopped; int signal; - int cont; - int shouldcont; + int doing; + int donext; char status[128]; }; @@ -65,7 +65,7 @@ extern struct process *dbg_attach(pid_t pid, int child); extern void dbg_detach(struct process *proc); extern int dbg_free(struct thread *th); -extern int dbg_wait(struct thread *th, int primary); +extern void dbg_sync(struct process *proc); extern int dbg_intr(struct thread *th); extern int dbg_cont(struct thread *th); -- cgit v1.2.3