Rev 2903 | Rev 2919 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2903 | Rev 2918 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2008 Jiri Svoboda |
2 | * Copyright (c) 2008 Jiri Svoboda |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup generic |
29 | /** @addtogroup generic |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | #ifndef KERN_UDEBUG_H_ |
35 | #ifndef KERN_UDEBUG_H_ |
36 | #define KERN_UDEBUG_H_ |
36 | #define KERN_UDEBUG_H_ |
37 | 37 | ||
38 | typedef enum { /* udebug_method_t */ |
38 | typedef enum { /* udebug_method_t */ |
39 | 39 | ||
40 | /** Start debugging the recipient. |
40 | /** Start debugging the recipient. |
41 | * Causes all threads in the receiving task to stop. When they |
41 | * Causes all threads in the receiving task to stop. When they |
42 | * are all stoped, an answer with retval 0 is generated. |
42 | * are all stoped, an answer with retval 0 is generated. |
43 | */ |
43 | */ |
44 | UDEBUG_M_BEGIN = 1, |
44 | UDEBUG_M_BEGIN = 1, |
45 | 45 | ||
46 | /** Finish debugging the recipient. |
46 | /** Finish debugging the recipient. |
47 | * Answers all pending GO and GUARD messages. |
47 | * Answers all pending GO and GUARD messages. |
48 | */ |
48 | */ |
49 | UDEBUG_M_END, |
49 | UDEBUG_M_END, |
50 | 50 | ||
51 | /** Set which events should be captured. |
51 | /** Set which events should be captured. |
52 | */ |
52 | */ |
53 | UDEBUG_M_SET_EVMASK, |
53 | UDEBUG_M_SET_EVMASK, |
54 | 54 | ||
55 | /** Make sure the debugged task is still there. |
55 | /** Make sure the debugged task is still there. |
56 | * This message is answered when the debugged task dies |
56 | * This message is answered when the debugged task dies |
57 | * or the debugging session ends. |
57 | * or the debugging session ends. |
58 | */ |
58 | */ |
59 | UDEBUG_M_GUARD, |
59 | UDEBUG_M_GUARD, |
60 | 60 | ||
61 | /** Run a thread until a debugging event occurs. |
61 | /** Run a thread until a debugging event occurs. |
62 | * This message is answered when the thread stops |
62 | * This message is answered when the thread stops |
63 | * in a debugging event. |
63 | * in a debugging event. |
64 | * |
64 | * |
65 | * - ARG2 - id of the thread to run |
65 | * - ARG2 - id of the thread to run |
66 | */ |
66 | */ |
67 | UDEBUG_M_GO, |
67 | UDEBUG_M_GO, |
68 | 68 | ||
69 | /** Stop a thread being debugged. |
69 | /** Stop a thread being debugged. |
70 | * Creates a special STOP event in the thread, causing |
70 | * Creates a special STOP event in the thread, causing |
71 | * it to answer a pending GO message (if any). |
71 | * it to answer a pending GO message (if any). |
72 | */ |
72 | */ |
73 | UDEBUG_M_STOP, |
73 | UDEBUG_M_STOP, |
74 | 74 | ||
75 | /** Read arguments of a syscall. |
75 | /** Read arguments of a syscall. |
76 | * |
76 | * |
77 | * - ARG2 - thread identification |
77 | * - ARG2 - thread identification |
78 | * - ARG3 - destination address in the caller's address space |
78 | * - ARG3 - destination address in the caller's address space |
79 | * |
79 | * |
80 | */ |
80 | */ |
81 | UDEBUG_M_ARGS_READ, |
81 | UDEBUG_M_ARGS_READ, |
82 | 82 | ||
83 | /** Read thread's userspace register state (istate_t). |
83 | /** Read thread's userspace register state (istate_t). |
84 | * |
84 | * |
85 | * - ARG2 - thread identification |
85 | * - ARG2 - thread identification |
86 | * - ARG3 - destination address in the caller's address space |
86 | * - ARG3 - destination address in the caller's address space |
87 | * - ARG4 - size of receiving buffer in bytes |
87 | * - ARG4 - size of receiving buffer in bytes |
88 | * |
88 | * |
89 | * on answer, the kernel will set: |
89 | * on answer, the kernel will set: |
90 | * |
90 | * |
91 | * - ARG1 - actual size in bytes of data read |
91 | * - ARG1 - actual size in bytes of data read |
92 | * - ARG2 - total size in bytes of data available |
92 | * - ARG2 - total size in bytes of data available |
93 | * |
93 | * |
94 | * or, on error, retval will be |
94 | * or, on error, retval will be |
95 | * - ENOENT - thread does not exist |
95 | * - ENOENT - thread does not exist |
96 | * - EBUSY - register state not available |
96 | * - EBUSY - register state not available |
97 | */ |
97 | */ |
98 | UDEBUG_M_REGS_READ, |
98 | UDEBUG_M_REGS_READ, |
99 | 99 | ||
100 | /** Write thread's userspace register state (istate_t). |
100 | /** Write thread's userspace register state (istate_t). |
101 | * |
101 | * |
102 | * - ARG2 - thread identification |
102 | * - ARG2 - thread identification |
103 | * - ARG3 - source address in the caller's address space |
103 | * - ARG3 - source address in the caller's address space |
104 | * - ARG4 - size of source data in bytes |
104 | * - ARG4 - size of source data in bytes |
105 | * |
105 | * |
106 | * on answer, the kernel will set: |
106 | * on answer, the kernel will set: |
107 | * |
107 | * |
108 | * - ARG1 - actual size in bytes of data copied |
108 | * - ARG1 - actual size in bytes of data copied |
109 | * - ARG2 - max size in bytes that could have been copied |
109 | * - ARG2 - max size in bytes that could have been copied |
110 | * |
110 | * |
111 | * or, on error, retval will be |
111 | * or, on error, retval will be |
112 | * - ENOENT - thread does not exist |
112 | * - ENOENT - thread does not exist |
113 | * - EBUSY - register state not available |
113 | * - EBUSY - register state not available |
114 | */ |
114 | */ |
115 | UDEBUG_M_REGS_WRITE, |
115 | UDEBUG_M_REGS_WRITE, |
116 | 116 | ||
117 | /** Read the list of the debugged tasks's threads. |
117 | /** Read the list of the debugged tasks's threads. |
118 | * |
118 | * |
119 | * - ARG2 - destination address in the caller's address space |
119 | * - ARG2 - destination address in the caller's address space |
120 | * - ARG3 - size of receiving buffer in bytes |
120 | * - ARG3 - size of receiving buffer in bytes |
121 | * |
121 | * |
122 | * The kernel fills the buffer with a series of sysarg_t values |
122 | * The kernel fills the buffer with a series of sysarg_t values |
123 | * (thread ids). On answer, the kernel will set: |
123 | * (thread ids). On answer, the kernel will set: |
124 | * |
124 | * |
125 | * - ARG2 - number of bytes that were actually copied |
125 | * - ARG2 - number of bytes that were actually copied |
126 | * - ARG3 - number of bytes of the complete data |
126 | * - ARG3 - number of bytes of the complete data |
127 | * |
127 | * |
128 | */ |
128 | */ |
129 | UDEBUG_M_THREAD_READ, |
129 | UDEBUG_M_THREAD_READ, |
130 | 130 | ||
131 | /** Read the debugged tasks's memory. |
131 | /** Read the debugged tasks's memory. |
132 | * |
132 | * |
133 | * - ARG2 - destination address in the caller's address space |
133 | * - ARG2 - destination address in the caller's address space |
134 | * - ARG3 - source address in the recipient's address space |
134 | * - ARG3 - source address in the recipient's address space |
135 | * - ARG4 - size of receiving buffer in bytes |
135 | * - ARG4 - size of receiving buffer in bytes |
136 | * |
136 | * |
137 | */ |
137 | */ |
138 | UDEBUG_M_MEM_READ, |
138 | UDEBUG_M_MEM_READ, |
139 | 139 | ||
140 | /** Write the debugged tasks's memory. |
140 | /** Write the debugged tasks's memory. |
141 | * |
141 | * |
142 | * - ARG2 - source address in the caller's address space |
142 | * - ARG2 - source address in the caller's address space |
143 | * - ARG3 - destination address in the recipient's address space |
143 | * - ARG3 - destination address in the recipient's address space |
144 | * - ARG4 - size of receiving buffer in bytes |
144 | * - ARG4 - size of receiving buffer in bytes |
145 | * |
145 | * |
146 | */ |
146 | */ |
147 | UDEBUG_M_MEM_WRITE |
147 | UDEBUG_M_MEM_WRITE |
148 | 148 | ||
149 | 149 | ||
150 | } udebug_method_t; |
150 | } udebug_method_t; |
151 | 151 | ||
152 | 152 | ||
153 | typedef enum { |
153 | typedef enum { |
154 | UDEBUG_EVENT_FINISHED = 1, /**< Debuging session has finished */ |
154 | UDEBUG_EVENT_FINISHED = 1, /**< Debuging session has finished */ |
155 | UDEBUG_EVENT_STOP, /**< Stopped on DEBUG_STOP request */ |
155 | UDEBUG_EVENT_STOP, /**< Stopped on DEBUG_STOP request */ |
156 | UDEBUG_EVENT_SYSCALL_B, /**< Before beginning syscall execution */ |
156 | UDEBUG_EVENT_SYSCALL_B, /**< Before beginning syscall execution */ |
157 | UDEBUG_EVENT_SYSCALL_E, /**< After finishing syscall execution */ |
157 | UDEBUG_EVENT_SYSCALL_E, /**< After finishing syscall execution */ |
158 | UDEBUG_EVENT_THREAD_B, /**< The task created a new thread */ |
158 | UDEBUG_EVENT_THREAD_B, /**< The task created a new thread */ |
159 | UDEBUG_EVENT_THREAD_E, /**< A thread exited */ |
159 | UDEBUG_EVENT_THREAD_E, /**< A thread exited */ |
- | 160 | UDEBUG_EVENT_BREAKPOINT /**< Breakpoint instruction executed */ |
|
160 | } udebug_event_t; |
161 | } udebug_event_t; |
161 | 162 | ||
162 | #define UDEBUG_EVMASK(event) (1 << ((event) - 1)) |
163 | #define UDEBUG_EVMASK(event) (1 << ((event) - 1)) |
163 | 164 | ||
164 | typedef enum { |
165 | typedef enum { |
165 | UDEBUG_EM_FINISHED = UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED), |
166 | UDEBUG_EM_FINISHED = UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED), |
166 | UDEBUG_EM_STOP = UDEBUG_EVMASK(UDEBUG_EVENT_STOP), |
167 | UDEBUG_EM_STOP = UDEBUG_EVMASK(UDEBUG_EVENT_STOP), |
167 | UDEBUG_EM_SYSCALL_B = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B), |
168 | UDEBUG_EM_SYSCALL_B = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B), |
168 | UDEBUG_EM_SYSCALL_E = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E), |
169 | UDEBUG_EM_SYSCALL_E = UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E), |
169 | UDEBUG_EM_THREAD_B = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B), |
170 | UDEBUG_EM_THREAD_B = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B), |
170 | UDEBUG_EM_THREAD_E = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E), |
171 | UDEBUG_EM_THREAD_E = UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E), |
- | 172 | UDEBUG_EM_BREAKPOINT = UDEBUG_EVMASK(UDEBUG_EVENT_BREAKPOINT), |
|
171 | UDEBUG_EM_ALL = |
173 | UDEBUG_EM_ALL = |
172 | UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED) | |
174 | UDEBUG_EVMASK(UDEBUG_EVENT_FINISHED) | |
173 | UDEBUG_EVMASK(UDEBUG_EVENT_STOP) | |
175 | UDEBUG_EVMASK(UDEBUG_EVENT_STOP) | |
174 | UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B) | |
176 | UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_B) | |
175 | UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E) | |
177 | UDEBUG_EVMASK(UDEBUG_EVENT_SYSCALL_E) | |
176 | UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B) | |
178 | UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_B) | |
177 | UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E) |
179 | UDEBUG_EVMASK(UDEBUG_EVENT_THREAD_E) | |
- | 180 | UDEBUG_EVMASK(UDEBUG_EVENT_BREAKPOINT) |
|
178 | } udebug_evmask_t; |
181 | } udebug_evmask_t; |
179 | 182 | ||
180 | #ifdef KERNEL |
183 | #ifdef KERNEL |
181 | 184 | ||
182 | typedef enum { |
185 | typedef enum { |
183 | /** Task is not being debugged */ |
186 | /** Task is not being debugged */ |
184 | UDEBUG_TS_INACTIVE, |
187 | UDEBUG_TS_INACTIVE, |
185 | /** BEGIN operation in progress (waiting for threads to stop) */ |
188 | /** BEGIN operation in progress (waiting for threads to stop) */ |
186 | UDEBUG_TS_BEGINNING, |
189 | UDEBUG_TS_BEGINNING, |
187 | /** Debugger fully connected */ |
190 | /** Debugger fully connected */ |
188 | UDEBUG_TS_ACTIVE, |
191 | UDEBUG_TS_ACTIVE, |
189 | /** Task is shutting down, no more debug activities allowed */ |
192 | /** Task is shutting down, no more debug activities allowed */ |
190 | UDEBUG_TS_SHUTDOWN |
193 | UDEBUG_TS_SHUTDOWN |
191 | } udebug_task_state_t; |
194 | } udebug_task_state_t; |
192 | 195 | ||
193 | struct task; |
196 | struct task; |
194 | struct thread; |
197 | struct thread; |
195 | 198 | ||
196 | void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3, |
199 | void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3, |
197 | unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc, |
200 | unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc, |
198 | bool end_variant); |
201 | bool end_variant); |
199 | 202 | ||
200 | void udebug_thread_b_event(struct thread *t); |
203 | void udebug_thread_b_event(struct thread *t); |
201 | void udebug_thread_e_event(void); |
204 | void udebug_thread_e_event(void); |
202 | 205 | ||
203 | void udebug_stoppable_begin(void); |
206 | void udebug_stoppable_begin(void); |
204 | void udebug_stoppable_end(void); |
207 | void udebug_stoppable_end(void); |
205 | 208 | ||
- | 209 | void udebug_breakpoint_event(uintptr_t addr); |
|
- | 210 | ||
206 | int udebug_task_cleanup(struct task *ta); |
211 | int udebug_task_cleanup(struct task *ta); |
207 | 212 | ||
208 | #endif |
213 | #endif |
209 | 214 | ||
210 | #endif |
215 | #endif |
211 | 216 | ||
212 | /** @} |
217 | /** @} |
213 | */ |
218 | */ |
214 | 219 |