Rev 2936 | Rev 2938 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2936 | Rev 2937 | ||
---|---|---|---|
Line 58... | Line 58... | ||
58 | int cmd_argc; |
58 | int cmd_argc; |
59 | char *cmd_argv[MAX_ARGC + 1]; /* need one spare field for cmd_split() */ |
59 | char *cmd_argv[MAX_ARGC + 1]; /* need one spare field for cmd_split() */ |
60 | 60 | ||
61 | #define THBUF_SIZE 64 |
61 | #define THBUF_SIZE 64 |
62 | thash_t thread_hash_buf[THBUF_SIZE]; |
62 | thash_t thread_hash_buf[THBUF_SIZE]; |
- | 63 | ||
- | 64 | #define MAX_THREADS 64 |
|
- | 65 | thash_t thread_hash[MAX_THREADS]; |
|
- | 66 | int thread_id[MAX_THREADS]; |
|
63 | unsigned n_threads; |
67 | unsigned n_threads; |
- | 68 | int cwt; /* index into thread_hash/thread_id */ |
|
64 | 69 | ||
65 | int next_thread_id; |
70 | int next_thread_id; |
66 | 71 | ||
67 | int app_phone; |
72 | int app_phone; |
68 | volatile bool abort_debug; |
73 | volatile bool abort_debug; |
Line 185... | Line 190... | ||
185 | { |
190 | { |
186 | int rc; |
191 | int rc; |
187 | int tb_copied; |
192 | int tb_copied; |
188 | int tb_needed; |
193 | int tb_needed; |
189 | int i; |
194 | int i; |
- | 195 | int n; |
|
190 | 196 | ||
191 | cons_printf("send IPC_M_DEBUG_THREAD_READ message\n"); |
197 | cons_printf("send IPC_M_DEBUG_THREAD_READ message\n"); |
192 | rc = udebug_thread_read(app_phone, (unsigned)thread_hash_buf, |
198 | rc = udebug_thread_read(app_phone, (unsigned)thread_hash_buf, |
193 | THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed); |
199 | THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed); |
194 | cons_printf("-> %d\n", rc); |
200 | cons_printf("-> %d\n", rc); |
195 | if (rc < 0) return rc; |
201 | if (rc < 0) return rc; |
196 | 202 | ||
197 | n_threads = tb_copied / sizeof(unsigned); |
203 | n = tb_copied / sizeof(unsigned); |
198 | 204 | ||
199 | cons_printf("thread IDs:"); |
205 | cons_printf("thread IDs:"); |
200 | for (i=0; i<n_threads; i++) { |
206 | for (i=0; i<n; i++) { |
201 | cons_printf(" %u", thread_hash_buf[i]); |
207 | cons_printf(" %u", thread_hash_buf[i]); |
202 | } |
208 | } |
203 | cons_printf("\ntotal of %u threads\n", tb_needed/sizeof(unsigned)); |
209 | cons_printf("\ntotal of %u threads\n", tb_needed/sizeof(unsigned)); |
204 | 210 | ||
205 | return 0; |
211 | return n; |
206 | } |
212 | } |
207 | 213 | ||
208 | void event_thread_b(unsigned hash) |
214 | void event_thread_b(unsigned hash) |
209 | { |
215 | { |
210 | async_serialize_start(); |
216 | async_serialize_start(); |
Line 246... | Line 252... | ||
246 | cons_printf("unknown event type %d\n", ev_type); |
252 | cons_printf("unknown event type %d\n", ev_type); |
247 | break; |
253 | break; |
248 | } |
254 | } |
249 | } |
255 | } |
250 | 256 | ||
251 | void debug_loop(void *thread_hash_arg) |
257 | void debug_loop(void *thread_buf_idx_arg) |
252 | { |
258 | { |
253 | int rc; |
259 | int rc; |
254 | udebug_event_t ev_type; |
260 | udebug_event_t ev_type; |
255 | unsigned thread_hash; |
261 | unsigned thread_buf_idx; |
256 | unsigned thread_id; |
262 | thash_t thash; |
- | 263 | int tid; |
|
257 | unsigned val0, val1; |
264 | unsigned val0, val1; |
258 | 265 | ||
259 | thread_hash = (unsigned)thread_hash_arg; |
266 | thread_buf_idx = (unsigned)thread_buf_idx_arg; |
- | 267 | ||
- | 268 | thash = thread_hash[thread_buf_idx]; |
|
260 | thread_id = next_thread_id++; |
269 | tid = thread_id[thread_buf_idx]; |
261 | 270 | ||
262 | cons_printf("debug_loop(%d)\n", thread_id); |
271 | cons_printf("debug_loop(%d)\n", tid); |
263 | 272 | ||
264 | while (!abort_debug) { |
273 | while (!abort_debug) { |
265 | 274 | ||
266 | /* Run thread until an event occurs */ |
275 | /* Run thread until an event occurs */ |
267 | rc = udebug_go(app_phone, thread_hash, |
276 | rc = udebug_go(app_phone, thash, |
268 | &ev_type, &val0, &val1); |
277 | &ev_type, &val0, &val1); |
269 | 278 | ||
270 | if (ev_type == UDEBUG_EVENT_FINISHED) { |
279 | if (ev_type == UDEBUG_EVENT_FINISHED) { |
271 | cons_printf("thread %u debugging finished\n", thread_id); |
280 | cons_printf("thread %u debugging finished\n", tid); |
272 | break; |
281 | break; |
273 | } |
282 | } |
274 | if (rc >= 0) debug_event(thread_hash, ev_type, val0); |
283 | if (rc >= 0) debug_event(thash, ev_type, val0); |
275 | } |
284 | } |
276 | 285 | ||
277 | cons_printf("debug_loop(%d) exiting\n", thread_id); |
286 | cons_printf("debug_loop(%d) exiting\n", thread_id); |
278 | } |
287 | } |
279 | 288 | ||
280 | void thread_debug_start(unsigned thread_hash) |
289 | void thread_debug_start(unsigned thash) |
281 | { |
290 | { |
282 | fid_t fid; |
291 | fid_t fid; |
283 | 292 | ||
284 | thash = thread_hash; |
293 | thread_hash[n_threads] = thash; |
- | 294 | thread_id[n_threads] = next_thread_id++; |
|
285 | 295 | ||
286 | fid = fibril_create(debug_loop, (void *)thread_hash); |
296 | fid = fibril_create(debug_loop, (void *)n_threads++); |
287 | if (fid == 0) { |
297 | if (fid == 0) { |
288 | cons_printf("Warning: Failed creating fibril\n"); |
298 | cons_printf("Warning: Failed creating fibril\n"); |
289 | } |
299 | } |
290 | fibril_add_ready(fid); |
300 | fibril_add_ready(fid); |
291 | } |
301 | } |
Line 317... | Line 327... | ||
317 | return; |
327 | return; |
318 | } |
328 | } |
319 | 329 | ||
320 | abort_debug = false; |
330 | abort_debug = false; |
321 | 331 | ||
322 | for (i = 0; i < n_threads; i++) { |
332 | for (i = 0; i < rc; i++) { |
323 | thread_debug_start(thread_hash_buf[i]); |
333 | thread_debug_start(thread_hash_buf[i]); |
324 | } |
334 | } |
325 | 335 | ||
326 | while (!quit) { |
336 | while (!quit) { |
327 | cons_read_line(in_buf, IN_BUF_SIZE); |
337 | cons_read_line(in_buf, IN_BUF_SIZE); |