Rev 2939 | Rev 2942 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2939 | Rev 2940 | ||
|---|---|---|---|
| Line 57... | Line 57... | ||
| 57 | 57 | ||
| 58 | #define MAX_ARGC 10 |
58 | #define MAX_ARGC 10 |
| 59 | int cmd_argc; |
59 | int cmd_argc; |
| 60 | char *cmd_argv[MAX_ARGC + 1]; /* need one spare field for cmd_split() */ |
60 | char *cmd_argv[MAX_ARGC + 1]; /* need one spare field for cmd_split() */ |
| 61 | 61 | ||
| 62 | #define THBUF_SIZE 64 |
- | |
| 63 | thash_t thread_hash_buf[THBUF_SIZE]; |
- | |
| 64 | 62 | ||
| 65 | int next_thread_id; |
63 | int next_thread_id; |
| 66 | 64 | ||
| 67 | int app_phone; |
65 | int app_phone; |
| 68 | volatile bool abort_debug; |
66 | volatile bool abort_debug; |
| Line 140... | Line 138... | ||
| 140 | } |
138 | } |
| 141 | 139 | ||
| 142 | static void thread_stop(void) |
140 | static void thread_stop(void) |
| 143 | { |
141 | { |
| 144 | dthread_t *dt; |
142 | dthread_t *dt; |
| - | 143 | uintptr_t pc; |
|
| 145 | 144 | ||
| 146 | dt = dthread_get(); |
145 | dt = dthread_get(); |
| - | 146 | pc = dthread_get_pc(dt); |
|
| 147 | cons_printf("[thread %d] stopped\n", dt->id); |
147 | cons_printf("[thread %d] stopped at 0x%lx\n", dt->id, pc); |
| 148 | dthread_stop_me(); |
148 | dthread_stop_me(); |
| 149 | cons_printf("[thread %d] go\n", dt->id); |
149 | cons_printf("[thread %d] go\n", dt->id); |
| 150 | } |
150 | } |
| 151 | 151 | ||
| 152 | /* |
152 | /* |
| Line 181... | Line 181... | ||
| 181 | if (rc < 0) return rc; |
181 | if (rc < 0) return rc; |
| 182 | 182 | ||
| 183 | return 0; |
183 | return 0; |
| 184 | } |
184 | } |
| 185 | 185 | ||
| - | 186 | #define THASH_BUF_INIT_LENGTH 32 |
|
| - | 187 | ||
| 186 | static int get_thread_list(void) |
188 | static int get_thread_list(thash_t **thash_buf_ptr, int *n) |
| 187 | { |
189 | { |
| 188 | int rc; |
190 | int rc; |
| 189 | int tb_copied; |
191 | int tb_copied; |
| 190 | int tb_needed; |
192 | int tb_needed; |
| 191 | int i; |
193 | int i; |
| 192 | int n; |
194 | size_t tb_size; |
| - | 195 | thash_t *thash_buf; |
|
| 193 | 196 | ||
| 194 | cons_printf("send IPC_M_DEBUG_THREAD_READ message\n"); |
197 | tb_size = THASH_BUF_INIT_LENGTH * sizeof(thash_t); |
| - | 198 | thash_buf = malloc(tb_size); |
|
| - | 199 | ||
| 195 | rc = udebug_thread_read(app_phone, (unsigned)thread_hash_buf, |
200 | rc = udebug_thread_read(app_phone, (sysarg_t)thash_buf, |
| 196 | THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed); |
201 | tb_size, &tb_copied, &tb_needed); |
| 197 | cons_printf("-> %d\n", rc); |
- | |
| 198 | if (rc < 0) return rc; |
202 | if (rc < 0) return rc; |
| 199 | 203 | ||
| - | 204 | if (tb_needed > tb_size) { |
|
| - | 205 | /* Larger buffer needed */ |
|
| - | 206 | ||
| - | 207 | free(thash_buf); |
|
| - | 208 | ||
| - | 209 | tb_size = tb_needed; |
|
| - | 210 | thash_buf = malloc(tb_size); |
|
| - | 211 | ||
| - | 212 | if (!thash_buf) { |
|
| - | 213 | printf("malloc failed\n"); |
|
| - | 214 | exit(1); |
|
| - | 215 | } |
|
| - | 216 | ||
| - | 217 | /* Try again */ |
|
| - | 218 | ||
| - | 219 | rc = udebug_thread_read(app_phone, (sysarg_t)thash_buf, |
|
| 200 | n = tb_copied / sizeof(unsigned); |
220 | tb_size, &tb_copied, &tb_needed); |
| 201 | 221 | ||
| 202 | cons_printf("thread IDs:"); |
- | |
| 203 | for (i=0; i<n; i++) { |
222 | if (rc < 0) return rc; |
| 204 | cons_printf(" %u", thread_hash_buf[i]); |
- | |
| 205 | } |
223 | } |
| 206 | cons_printf("\ntotal of %u threads\n", tb_needed/sizeof(unsigned)); |
- | |
| 207 | 224 | ||
| - | 225 | *n = tb_copied / sizeof(thash_t); |
|
| - | 226 | ||
| - | 227 | cons_printf("thread hashes:"); |
|
| - | 228 | ||
| - | 229 | for (i = 0; i < *n; ++i) { |
|
| - | 230 | cons_printf("0x%x\n", thash_buf[i]); |
|
| - | 231 | } |
|
| - | 232 | ||
| - | 233 | cons_printf("Total of %u threads\n", *n); |
|
| - | 234 | ||
| - | 235 | *thash_buf_ptr = thash_buf; |
|
| - | 236 | ||
| 208 | return n; |
237 | return 0; |
| 209 | } |
238 | } |
| 210 | 239 | ||
| 211 | void event_thread_b(unsigned hash) |
240 | void event_thread_b(unsigned hash) |
| 212 | { |
241 | { |
| 213 | async_serialize_start(); |
242 | async_serialize_start(); |
| Line 293... | Line 322... | ||
| 293 | int taskid; |
322 | int taskid; |
| 294 | int i; |
323 | int i; |
| 295 | int rc; |
324 | int rc; |
| 296 | int c; |
325 | int c; |
| 297 | 326 | ||
| - | 327 | thash_t *thash_buffer; |
|
| - | 328 | int n_threads; |
|
| - | 329 | ||
| 298 | cons_printf("Breakpoint Debugger\n"); |
330 | cons_printf("Breakpoint Debugger\n"); |
| 299 | cons_printf("Press 'c' to connect\n"); |
331 | cons_printf("Press 'c' to connect\n"); |
| 300 | while ((i = getchar()) != 'c') |
332 | while ((i = getchar()) != 'c') |
| 301 | putchar(i); |
333 | putchar(i); |
| 302 | 334 | ||
| Line 307... | Line 339... | ||
| 307 | return; |
339 | return; |
| 308 | } |
340 | } |
| 309 | 341 | ||
| 310 | cons_printf("Connected to task %d\n", taskid); |
342 | cons_printf("Connected to task %d\n", taskid); |
| 311 | 343 | ||
| 312 | rc = get_thread_list(); |
344 | rc = get_thread_list(&thash_buffer, &n_threads); |
| 313 | if (rc < 0) { |
345 | if (rc < 0) { |
| 314 | cons_printf("Failed to get thread list (error %d)\n", rc); |
346 | cons_printf("Failed to get thread list\n", rc); |
| 315 | return; |
347 | return; |
| 316 | } |
348 | } |
| 317 | 349 | ||
| 318 | abort_debug = false; |
350 | abort_debug = false; |
| 319 | 351 | ||
| 320 | for (i = 0; i < rc; i++) { |
352 | for (i = 0; i < n_threads; i++) { |
| 321 | thread_debug_start(thread_hash_buf[i]); |
353 | thread_debug_start(thash_buffer[i]); |
| 322 | } |
354 | } |
| 323 | 355 | ||
| 324 | while (!quit) { |
356 | while (!quit) { |
| 325 | cons_read_line(in_buf, IN_BUF_SIZE); |
357 | cons_read_line(in_buf, IN_BUF_SIZE); |
| 326 | command_split(in_buf); |
358 | command_split(in_buf); |