35
35
#ifndef KERN_UDEBUG_H_
36
36
#define KERN_UDEBUG_H_
38
#define UDEBUG_EVMASK(event) (1 << ((event) - 1))
40
40
typedef enum { /* udebug_method_t */
42
/** Start debugging the recipient.
43
* Causes all threads in the receiving task to stop. When they
44
* are all stoped, an answer with retval 0 is generated.
48
/** Finish debugging the recipient.
49
* Answers all pending GO and GUARD messages.
53
/** Set which events should be captured.
57
/** Make sure the debugged task is still there.
58
* This message is answered when the debugged task dies
59
* or the debugging session ends.
63
/** Run a thread until a debugging event occurs.
64
* This message is answered when the thread stops
65
* in a debugging event.
67
* - ARG2 - id of the thread to run
71
/** Stop a thread being debugged.
72
* Creates a special STOP event in the thread, causing
73
* it to answer a pending GO message (if any).
77
/** Read arguments of a syscall.
79
* - ARG2 - thread identification
80
* - ARG3 - destination address in the caller's address space
85
/** Read thread's userspace register state (istate_t).
87
* - ARG2 - thread identification
88
* - ARG3 - destination address in the caller's address space
90
* or, on error, retval will be
91
* - ENOENT - thread does not exist
92
* - EBUSY - register state not available
96
/** Read the list of the debugged tasks's threads.
98
* - ARG2 - destination address in the caller's address space
99
* - ARG3 - size of receiving buffer in bytes
101
* The kernel fills the buffer with a series of sysarg_t values
102
* (thread ids). On answer, the kernel will set:
104
* - ARG2 - number of bytes that were actually copied
105
* - ARG3 - number of bytes of the complete data
108
UDEBUG_M_THREAD_READ,
110
/** Read the name of the debugged task.
112
* - ARG2 - destination address in the caller's address space
113
* - ARG3 - size of receiving buffer in bytes
115
* The kernel fills the buffer with a non-terminated string.
117
* - ARG2 - number of bytes that were actually copied
118
* - ARG3 - number of bytes of the complete data
123
/** Read the list of the debugged task's address space areas.
125
* - ARG2 - destination address in the caller's address space
126
* - ARG3 - size of receiving buffer in bytes
128
* The kernel fills the buffer with a series of as_area_info_t structures.
129
* Upon answer, the kernel will set:
131
* - ARG2 - number of bytes that were actually copied
132
* - ARG3 - number of bytes of the complete data
137
/** Read the debugged tasks's memory.
139
* - ARG2 - destination address in the caller's address space
140
* - ARG3 - source address in the recipient's address space
141
* - ARG4 - size of receiving buffer in bytes
42
/** Start debugging the recipient.
44
* Causes all threads in the receiving task to stop. When they
45
* are all stoped, an answer with retval 0 is generated.
50
/** Finish debugging the recipient.
52
* Answers all pending GO and GUARD messages.
57
/** Set which events should be captured. */
60
/** Make sure the debugged task is still there.
62
* This message is answered when the debugged task dies
63
* or the debugging session ends.
68
/** Run a thread until a debugging event occurs.
70
* This message is answered when the thread stops
71
* in a debugging event.
73
* - ARG2 - id of the thread to run
78
/** Stop a thread being debugged.
80
* Creates a special STOP event in the thread, causing
81
* it to answer a pending GO message (if any).
86
/** Read arguments of a syscall.
88
* - ARG2 - thread identification
89
* - ARG3 - destination address in the caller's address space
94
/** Read thread's userspace register state (istate_t).
96
* - ARG2 - thread identification
97
* - ARG3 - destination address in the caller's address space
99
* or, on error, retval will be
100
* - ENOENT - thread does not exist
101
* - EBUSY - register state not available
105
/** Read the list of the debugged tasks's threads.
107
* - ARG2 - destination address in the caller's address space
108
* - ARG3 - size of receiving buffer in bytes
110
* The kernel fills the buffer with a series of sysarg_t values
111
* (thread ids). On answer, the kernel will set:
113
* - ARG2 - number of bytes that were actually copied
114
* - ARG3 - number of bytes of the complete data
117
UDEBUG_M_THREAD_READ,
119
/** Read the name of the debugged task.
121
* - ARG2 - destination address in the caller's address space
122
* - ARG3 - size of receiving buffer in bytes
124
* The kernel fills the buffer with a non-terminated string.
126
* - ARG2 - number of bytes that were actually copied
127
* - ARG3 - number of bytes of the complete data
132
/** Read the list of the debugged task's address space areas.
134
* - ARG2 - destination address in the caller's address space
135
* - ARG3 - size of receiving buffer in bytes
137
* The kernel fills the buffer with a series of as_area_info_t structures.
138
* Upon answer, the kernel will set:
140
* - ARG2 - number of bytes that were actually copied
141
* - ARG3 - number of bytes of the complete data
146
/** Read the debugged tasks's memory.
148
* - ARG2 - destination address in the caller's address space
149
* - ARG3 - source address in the recipient's address space
150
* - ARG4 - size of receiving buffer in bytes
146
154
} udebug_method_t;
150
UDEBUG_EVENT_FINISHED = 1, /**< Debuging session has finished */
151
UDEBUG_EVENT_STOP, /**< Stopped on DEBUG_STOP request */
152
UDEBUG_EVENT_SYSCALL_B, /**< Before beginning syscall execution */
153
UDEBUG_EVENT_SYSCALL_E, /**< After finishing syscall execution */
154
UDEBUG_EVENT_THREAD_B, /**< The task created a new thread */
155
UDEBUG_EVENT_THREAD_E /**< A thread exited */
157
UDEBUG_EVENT_FINISHED = 1, /**< Debuging session has finished */
158
UDEBUG_EVENT_STOP, /**< Stopped on DEBUG_STOP request */
159
UDEBUG_EVENT_SYSCALL_B, /**< Before beginning syscall execution */
160
UDEBUG_EVENT_SYSCALL_E, /**< After finishing syscall execution */
161
UDEBUG_EVENT_THREAD_B, /**< The task created a new thread */
162
UDEBUG_EVENT_THREAD_E /**< A thread exited */
156
163
} udebug_event_t;
158
#define UDEBUG_EVMASK(event) (1 << ((event) - 1))
161
UDEBUG_EM_FINISHED = UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED),
162
UDEBUG_EM_STOP = UDEBUG_EVMASK(UDEBUG_EVENT_STOP),
163
UDEBUG_EM_SYSCALL_B = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B),
164
UDEBUG_EM_SYSCALL_E = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E),
165
UDEBUG_EM_THREAD_B = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B),
166
UDEBUG_EM_THREAD_E = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E),
168
UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED) |
169
UDEBUG_EVMASK(UDEBUG_EVENT_STOP) |
170
UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B) |
171
UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E) |
172
UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B) |
173
UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E)
166
UDEBUG_EM_FINISHED = UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED),
167
UDEBUG_EM_STOP = UDEBUG_EVMASK(UDEBUG_EVENT_STOP),
168
UDEBUG_EM_SYSCALL_B = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B),
169
UDEBUG_EM_SYSCALL_E = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E),
170
UDEBUG_EM_THREAD_B = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B),
171
UDEBUG_EM_THREAD_E = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E),
173
(UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED) |
174
UDEBUG_EVMASK(UDEBUG_EVENT_STOP) |
175
UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B) |
176
UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E) |
177
UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B) |
178
UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E))
174
179
} udebug_evmask_t;
178
184
#include <synch/mutex.h>
179
185
#include <synch/condvar.h>
180
186
#include <arch/interrupt.h>
209
215
/** Synchronize debug ops on this thread / access to this structure. */
214
unative_t syscall_args[6];
220
sysarg_t syscall_args[6];
215
221
istate_t *uspace_state;
217
223
/** What type of event are we stopped in or 0 if none. */
218
224
udebug_event_t cur_event;
219
bool go; /**< thread is GO */
220
bool stoppable; /**< thread is stoppable */
221
bool active; /**< thread is in a debugging session */
225
bool go; /**< Thread is GO */
226
bool stoppable; /**< Thread is stoppable */
227
bool active; /**< Thread is in a debugging session */
222
228
condvar_t active_cv;
223
229
} udebug_thread_t;
228
void udebug_task_init(udebug_task_t *ut);
229
void udebug_thread_initialize(udebug_thread_t *ut);
231
void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3,
232
unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc,
235
void udebug_thread_b_event_attach(struct thread *t, struct task *ta);
234
void udebug_task_init(udebug_task_t *);
235
void udebug_thread_initialize(udebug_thread_t *);
237
void udebug_syscall_event(sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
238
sysarg_t, sysarg_t, sysarg_t, bool);
240
void udebug_thread_b_event_attach(struct thread *, struct task *);
236
241
void udebug_thread_e_event(void);
238
243
void udebug_stoppable_begin(void);