Rev 2832 | Rev 2837 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2832 | Rev 2835 | ||
---|---|---|---|
Line 6... | Line 6... | ||
6 | 6 | ||
7 | #include <stdio.h> |
7 | #include <stdio.h> |
8 | #include <unistd.h> |
8 | #include <unistd.h> |
9 | #include <syscall.h> |
9 | #include <syscall.h> |
10 | #include <ipc/ipc.h> |
10 | #include <ipc/ipc.h> |
11 | #include <udebug.h> |
11 | #include <fibril.h> |
- | 12 | #include <errno.h> |
|
12 | 13 | ||
13 | #include "syscalls.h" |
14 | #include "syscalls.h" |
14 | #include "errors.h" |
15 | #include "errors.h" |
15 | #include "debug_api.h" |
16 | #include "debug_api.h" |
16 | 17 | ||
17 | #define TIDBUF_SIZE 64 |
18 | #define TIDBUF_SIZE 64 |
18 | unsigned threadid_buf[TIDBUF_SIZE]; |
19 | unsigned threadid_buf[TIDBUF_SIZE]; |
19 | 20 | ||
20 | int phoneid; |
21 | int phoneid; |
- | 22 | int abort_trace; |
|
21 | 23 | ||
22 | int task_connect(int taskid) |
24 | int task_connect(int taskid) |
23 | { |
25 | { |
24 | int rc; |
26 | int rc; |
25 | 27 | ||
Line 112... | Line 114... | ||
112 | ipc_args[0], ipc_args[1], ipc_args[2], |
114 | ipc_args[0], ipc_args[1], ipc_args[2], |
113 | ipc_args[3], ipc_args[4], ipc_args[5]); |
115 | ipc_args[3], ipc_args[4], ipc_args[5]); |
114 | } |
116 | } |
115 | } |
117 | } |
116 | 118 | ||
- | 119 | int keyboard_fibril(void *arg) |
|
- | 120 | { |
|
- | 121 | (void)arg; |
|
- | 122 | ||
- | 123 | printf("keyboard fibril started\n"); |
|
- | 124 | ||
- | 125 | getchar(); |
|
- | 126 | printf("keyboard fibril setting abort_trace\n"); |
|
- | 127 | abort_trace = 1; |
|
- | 128 | printf("keyboard fibril sending debug_end()\n"); |
|
- | 129 | debug_end(phoneid); |
|
- | 130 | printf("keyboard fibril exitting\n"); |
|
- | 131 | ||
- | 132 | return EOK; |
|
- | 133 | } |
|
- | 134 | ||
117 | void trace_loop(void) |
135 | void trace_loop(void) |
118 | { |
136 | { |
119 | int rc; |
137 | int rc; |
120 | unsigned sc_args[6]; |
138 | unsigned sc_args[6]; |
121 | unsigned copied; |
139 | unsigned copied; |
122 | unsigned ev_type; |
140 | unsigned ev_type; |
123 | unsigned sc_id; |
141 | unsigned sc_id; |
124 | int sc_rc; |
142 | int sc_rc; |
125 | int rv_type; |
143 | int rv_type; |
- | 144 | fid_t kb_fid; |
|
- | 145 | ||
- | 146 | abort_trace = 0; |
|
- | 147 | kb_fid = fibril_create(keyboard_fibril, NULL); |
|
- | 148 | if (kb_fid == 0) { |
|
- | 149 | printf("Failed creating keyboard fibril\n"); |
|
- | 150 | return; |
|
- | 151 | } |
|
- | 152 | fibril_add_ready(kb_fid); |
|
- | 153 | ||
- | 154 | while (!abort_trace) { |
|
126 | 155 | ||
127 | while (1) { |
- | |
128 | /* Run thread until a syscall is executed */ |
156 | /* Run thread until a syscall is executed */ |
129 | rc = debug_go(phoneid, threadid_buf[0], |
157 | rc = debug_go(phoneid, threadid_buf[0], |
130 | &ev_type, &sc_id, &sc_rc); |
158 | &ev_type, &sc_id, &sc_rc); |
131 | 159 | ||
132 | /* Read syscall arguments */ |
160 | /* Read syscall arguments */ |
Line 149... | Line 177... | ||
149 | break; |
177 | break; |
150 | default: |
178 | default: |
151 | break; |
179 | break; |
152 | } |
180 | } |
153 | } |
181 | } |
- | 182 | ||
- | 183 | printf("trace_loop() exiting\n"); |
|
154 | } |
184 | } |
155 | 185 | ||
156 | 186 | ||
157 | void trace_active_task(void) |
187 | void trace_active_task(void) |
158 | { |
188 | { |
Line 179... | Line 209... | ||
179 | printf("Failed to get thread list (error %d)\n", rc); |
209 | printf("Failed to get thread list (error %d)\n", rc); |
180 | return; |
210 | return; |
181 | } |
211 | } |
182 | 212 | ||
183 | trace_loop(); |
213 | trace_loop(); |
- | 214 | /* |
|
- | 215 | printf("press 'd' to disconnect\n"); |
|
- | 216 | while ((i = getchar()) != 'd') |
|
- | 217 | putchar(i); |
|
184 | 218 | ||
- | 219 | printf("call debug_end()\n"); |
|
- | 220 | debug_end(phoneid); |
|
- | 221 | */ |
|
185 | printf("done\n"); |
222 | printf("done\n"); |
186 | return; |
223 | return; |
187 | } |
224 | } |
188 | 225 | ||
189 | int main(void) |
226 | int main(void) |
190 | { |
227 | { |
- | 228 | while (1) { |
|
191 | trace_active_task(); |
229 | trace_active_task(); |
- | 230 | } |
|
192 | } |
231 | } |
193 | 232 | ||
194 | /** @} |
233 | /** @} |
195 | */ |
234 | */ |