summaryrefslogtreecommitdiffstats
path: root/debugger.h
blob: cf2c442d3e855812376eedfe47bae3295d1de8ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#pragma once

#include <sys/user.h>
#include <unistd.h>

#include "console.h"
#include "list.h"

#define BREAKPOINT_INSN 0xcc

extern PANEL *consolepan;

struct breakpoint {
    LINKEDLIST;
    unsigned long orig;
    unsigned long address;
    unsigned long stack;
    pid_t tid;
    int enabled;
    int active;
    /* add count field
     * and stop boolean
     * to implement checkpoints? */
};

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 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 stopped;
    int signal;
    int cont;
    const char *status;
};

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 void dbg_free(struct tracee *dbg);