Rev 2894 | Rev 2899 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2894 | Rev 2898 | ||
---|---|---|---|
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 | /** Make sure the debugged task is still there. |
51 | /** Make sure the debugged task is still there. |
52 | * This message is answered when the debugged task dies |
52 | * This message is answered when the debugged task dies |
53 | * or the debugging session ends. |
53 | * or the debugging session ends. |
54 | */ |
54 | */ |
55 | UDEBUG_M_GUARD, |
55 | UDEBUG_M_GUARD, |
56 | 56 | ||
57 | /** Run a thread until a debugging event occurs. |
57 | /** Run a thread until a debugging event occurs. |
58 | * This message is answered when the thread stops |
58 | * This message is answered when the thread stops |
59 | * in a debugging event. |
59 | * in a debugging event. |
60 | * |
60 | * |
61 | * - ARG2 - id of the thread to run |
61 | * - ARG2 - id of the thread to run |
62 | */ |
62 | */ |
63 | UDEBUG_M_GO, |
63 | UDEBUG_M_GO, |
64 | 64 | ||
65 | /** Stop a thread being debugged. |
65 | /** Stop a thread being debugged. |
66 | * Creates a special STOP event in the thread, causing |
66 | * Creates a special STOP event in the thread, causing |
67 | * it to answer a pending GO message (if any). |
67 | * it to answer a pending GO message (if any). |
68 | */ |
68 | */ |
69 | UDEBUG_M_STOP, |
69 | UDEBUG_M_STOP, |
70 | 70 | ||
71 | /** Read arguments of a syscall. |
71 | /** Read arguments of a syscall. |
72 | * |
72 | * |
73 | * - ARG2 - thread identification |
73 | * - ARG2 - thread identification |
74 | * - ARG3 - destination address in the caller's address space |
74 | * - ARG3 - destination address in the caller's address space |
75 | * |
75 | * |
76 | */ |
76 | */ |
77 | UDEBUG_M_ARGS_READ, |
77 | UDEBUG_M_ARGS_READ, |
78 | 78 | ||
79 | /** Read thread's userspace register state (istate_t). |
79 | /** Read thread's userspace register state (istate_t). |
80 | * |
80 | * |
81 | * - ARG2 - thread identification |
81 | * - ARG2 - thread identification |
82 | * - ARG3 - destination address in the caller's address space |
82 | * - ARG3 - destination address in the caller's address space |
83 | * - ARG4 - size of receiving buffer in bytes |
83 | * - ARG4 - size of receiving buffer in bytes |
84 | * |
84 | * |
85 | * on answer, the kernel will set: |
85 | * on answer, the kernel will set: |
86 | * |
86 | * |
87 | * - ARG1 - actual size in bytes of data read |
87 | * - ARG1 - actual size in bytes of data read |
88 | * - ARG2 - total size in bytes of data available |
88 | * - ARG2 - total size in bytes of data available |
89 | * |
89 | * |
90 | * or, on error, retval will be |
90 | * or, on error, retval will be |
91 | * - ENOENT - thread does not exist |
91 | * - ENOENT - thread does not exist |
92 | * - EBUSY - register state not available |
92 | * - EBUSY - register state not available |
93 | */ |
93 | */ |
94 | UDEBUG_M_REGS_READ, |
94 | UDEBUG_M_REGS_READ, |
95 | 95 | ||
96 | /** Write thread's userspace register state (istate_t). |
96 | /** Write thread's userspace register state (istate_t). |
97 | * |
97 | * |
98 | * - ARG2 - thread identification |
98 | * - ARG2 - thread identification |
99 | * - ARG3 - source address in the caller's address space |
99 | * - ARG3 - source address in the caller's address space |
100 | * - ARG4 - size of source data in bytes |
100 | * - ARG4 - size of source data in bytes |
101 | * |
101 | * |
102 | * on answer, the kernel will set: |
102 | * on answer, the kernel will set: |
103 | * |
103 | * |
104 | * - ARG1 - actual size in bytes of data copied |
104 | * - ARG1 - actual size in bytes of data copied |
105 | * - ARG2 - max size in bytes that could have been copied |
105 | * - ARG2 - max size in bytes that could have been copied |
106 | * |
106 | * |
107 | * or, on error, retval will be |
107 | * or, on error, retval will be |
108 | * - ENOENT - thread does not exist |
108 | * - ENOENT - thread does not exist |
109 | * - EBUSY - register state not available |
109 | * - EBUSY - register state not available |
110 | */ |
110 | */ |
111 | UDEBUG_M_REGS_WRITE, |
111 | UDEBUG_M_REGS_WRITE, |
112 | 112 | ||
113 | /** Read the list of the debugged tasks's threads. |
113 | /** Read the list of the debugged tasks's threads. |
114 | * |
114 | * |
115 | * - ARG2 - destination address in the caller's address space |
115 | * - ARG2 - destination address in the caller's address space |
116 | * - ARG3 - size of receiving buffer in bytes |
116 | * - ARG3 - size of receiving buffer in bytes |
117 | * |
117 | * |
118 | * The kernel fills the buffer with a series of sysarg_t values |
118 | * The kernel fills the buffer with a series of sysarg_t values |
119 | * (thread ids). On answer, the kernel will set: |
119 | * (thread ids). On answer, the kernel will set: |
120 | * |
120 | * |
121 | * - ARG2 - number of bytes that were actually copied |
121 | * - ARG2 - number of bytes that were actually copied |
122 | * - ARG3 - number of bytes of the complete data |
122 | * - ARG3 - number of bytes of the complete data |
123 | * |
123 | * |
124 | */ |
124 | */ |
125 | UDEBUG_M_THREAD_READ, |
125 | UDEBUG_M_THREAD_READ, |
126 | 126 | ||
127 | /** Read the debugged tasks's memory. |
127 | /** Read the debugged tasks's memory. |
128 | * |
128 | * |
129 | * - ARG2 - destination address in the caller's address space |
129 | * - ARG2 - destination address in the caller's address space |
130 | * - ARG3 - source address in the recipient's address space |
130 | * - ARG3 - source address in the recipient's address space |
131 | * - ARG4 - size of receiving buffer in bytes |
131 | * - ARG4 - size of receiving buffer in bytes |
132 | * |
132 | * |
133 | */ |
133 | */ |
134 | UDEBUG_M_MEM_READ, |
134 | UDEBUG_M_MEM_READ, |
135 | 135 | ||
136 | /** Write the debugged tasks's memory. |
136 | /** Write the debugged tasks's memory. |
137 | * |
137 | * |
138 | * - ARG2 - source address in the caller's address space |
138 | * - ARG2 - source address in the caller's address space |
139 | * - ARG3 - destination address in the recipient's address space |
139 | * - ARG3 - destination address in the recipient's address space |
140 | * - ARG4 - size of receiving buffer in bytes |
140 | * - ARG4 - size of receiving buffer in bytes |
141 | * |
141 | * |
142 | */ |
142 | */ |
143 | UDEBUG_M_MEM_WRITE |
143 | UDEBUG_M_MEM_WRITE |
144 | 144 | ||
145 | 145 | ||
146 | } udebug_method_t; |
146 | } udebug_method_t; |
147 | 147 | ||
148 | 148 | ||
149 | typedef enum { |
149 | typedef enum { |
150 | UDEBUG_EVENT_FINISHED = 1, /**< Debuging session has finished */ |
150 | UDEBUG_EVENT_FINISHED = 1, /**< Debuging session has finished */ |
- | 151 | UDEBUG_EVENT_STOP, /**< Stopped on DEBUG_STOP request */ |
|
151 | UDEBUG_EVENT_SYSCALL, /**< A syscall has been executed */ |
152 | UDEBUG_EVENT_SYSCALL, /**< A syscall has been executed */ |
152 | UDEBUG_EVENT_NEW_THREAD /**< The task created a new thread */ |
153 | UDEBUG_EVENT_NEW_THREAD /**< The task created a new thread */ |
153 | } udebug_event_t; |
154 | } udebug_event_t; |
154 | 155 | ||
155 | #ifdef KERNEL |
156 | #ifdef KERNEL |
156 | 157 | ||
157 | typedef enum { |
158 | typedef enum { |
158 | /** Task is not being debugged */ |
159 | /** Task is not being debugged */ |
159 | UDEBUG_TS_INACTIVE, |
160 | UDEBUG_TS_INACTIVE, |
160 | /** BEGIN operation in progress (waiting for threads to stop) */ |
161 | /** BEGIN operation in progress (waiting for threads to stop) */ |
161 | UDEBUG_TS_BEGINNING, |
162 | UDEBUG_TS_BEGINNING, |
162 | /** Debugger fully connected */ |
163 | /** Debugger fully connected */ |
163 | UDEBUG_TS_ACTIVE, |
164 | UDEBUG_TS_ACTIVE, |
164 | /** Task is shutting down, no more debug activities allowed */ |
165 | /** Task is shutting down, no more debug activities allowed */ |
165 | UDEBUG_TS_SHUTDOWN |
166 | UDEBUG_TS_SHUTDOWN |
166 | } udebug_task_state_t; |
167 | } udebug_task_state_t; |
167 | 168 | ||
168 | struct task; |
169 | struct task; |
169 | struct thread; |
170 | struct thread; |
170 | 171 | ||
171 | void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3, |
172 | void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3, |
172 | unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc); |
173 | unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc); |
173 | void udebug_new_thread_event(struct thread *t); |
174 | void udebug_new_thread_event(struct thread *t); |
174 | 175 | ||
175 | void udebug_stoppable_begin(void); |
176 | void udebug_stoppable_begin(void); |
176 | void udebug_stoppable_end(void); |
177 | void udebug_stoppable_end(void); |
177 | 178 | ||
178 | int udebug_task_cleanup(struct task *ta); |
179 | int udebug_task_cleanup(struct task *ta); |
179 | 180 | ||
180 | #endif |
181 | #endif |
181 | 182 | ||
182 | #endif |
183 | #endif |
183 | 184 | ||
184 | /** @} |
185 | /** @} |
185 | */ |
186 | */ |
186 | 187 |