|
20 | 20 |
|
21 | 21 | # NOTE: you need to use gdb configured '--with-python'
|
22 | 22 | # usage: gdb -ix=./tools/nuttx-gdbinit nuttx
|
23 |
| -# new commands: info_nxthreads, nxthread pid, nxcontinue, nxthread_all_bt |
| 23 | +# new commands: nxthread pid, nxthread_all_bt |
24 | 24 |
|
25 | 25 | # Do not stop with SIGUSR1 which is used for the NuttX sim SMP
|
26 | 26 | handle SIGUSR1 "nostop" "pass" "noprint"
|
@@ -78,24 +78,23 @@ define _examine_target
|
78 | 78 | python if (type(gdb.lookup_global_symbol("g_assignedtasks")) is gdb.Symbol) : \
|
79 | 79 | gdb.execute("set $_target_has_smp = 1")
|
80 | 80 |
|
81 |
| - set $_target_max_tasks = g_npidhash |
82 |
| - |
83 |
| - printf "target examined\n" |
84 |
| - python print("_target_arch.name=" + _target_arch.name()) |
85 |
| - |
86 |
| - # NOTE: i386:x86-64 (qemu) does not work |
87 |
| - #printf "$_target_arch : %s\n", $_target_arch |
88 |
| - |
89 |
| - printf "$_target_has_fpu : %d\n", $_target_has_fpu |
90 |
| - printf "$_target_has_smp : %d\n", $_target_has_smp |
91 | 81 | set $_target_examined = 1
|
92 | 82 | end
|
93 | 83 | end
|
94 | 84 |
|
| 85 | +define _running_task |
| 86 | + if ($_target_has_smp == 0) |
| 87 | + set $rtcb = (struct tcb_s *)g_readytorun->head |
| 88 | + else |
| 89 | + set $rtcb = (struct tcb_s *)g_assignedtasks[up_cpu_index()]->head |
| 90 | + end |
| 91 | +end |
| 92 | + |
95 | 93 | define _print_thread
|
96 | 94 | set $tcb = (struct tcb_s *)$arg0
|
| 95 | + _running_task |
97 | 96 |
|
98 |
| - if ($tcb == $_current_tcb) |
| 97 | + if ($tcb == $rtcb) |
99 | 98 | printf "* "
|
100 | 99 | else
|
101 | 100 | printf " "
|
@@ -137,21 +136,13 @@ define _save_current_tcb
|
137 | 136 | _examine_target
|
138 | 137 |
|
139 | 138 | if ($_current_tcb == 0)
|
140 |
| - if ($_target_has_smp == 0) |
141 |
| - set $tcb = (struct tcb_s *)g_readytorun->head |
142 |
| - _save_tcb $tcb |
143 |
| - else |
144 |
| - set $cpu = up_cpu_index() |
145 |
| - set $tcb = (struct tcb_s *)g_assignedtasks[$cpu]->head |
146 |
| - _save_tcb $tcb |
147 |
| - end |
148 |
| - printf "saved current_tcb (pid=%d)\n", $tcb->pid |
149 |
| - set $_current_tcb = $tcb |
| 139 | + _running_task |
| 140 | + _save_tcb $rtcb |
| 141 | + set $_current_tcb = $rtcb |
150 | 142 | end
|
151 | 143 | end
|
152 | 144 |
|
153 | 145 | define _switch_tcb
|
154 |
| - _examine_target |
155 | 146 | _save_current_tcb
|
156 | 147 |
|
157 | 148 | # set the current frame to the newest before switching
|
@@ -406,56 +397,62 @@ define _switch_tcb_simx86
|
406 | 397 | end
|
407 | 398 |
|
408 | 399 | define _restore_current_tcb
|
409 |
| - # TODO: SMP |
410 |
| - set $tcb = g_readytorun->head |
411 |
| - _switch_tcb $tcb |
| 400 | + _examine_target |
| 401 | + _running_task |
| 402 | + _switch_tcb $rtcb |
412 | 403 | set $_current_tcb = 0x0
|
413 | 404 | end
|
414 | 405 |
|
415 | 406 | define nxthread
|
416 |
| - _examine_target |
417 |
| - _save_current_tcb |
418 |
| - set $hash = ($arg0 & ($_target_max_tasks - 1)) |
| 407 | + set $hash = ($arg0 & (g_npidhash - 1)) |
419 | 408 | set $tcb = g_pidhash[$hash]
|
420 | 409 | if ($tcb != 0x0)
|
| 410 | + _switch_tcb $tcb |
421 | 411 | _print_thread $tcb
|
422 |
| - if ($argc == 1) |
423 |
| - _switch_tcb $tcb |
424 |
| - end |
425 | 412 | if ($argc == 2)
|
426 | 413 | if ($arg1 == 1)
|
427 |
| - _switch_tcb $tcb |
428 |
| - where |
| 414 | + _switch_tcb $tcb |
| 415 | + where |
429 | 416 | end
|
430 | 417 | end
|
431 | 418 | end
|
432 |
| - _restore_current_tcb |
433 | 419 | end
|
434 | 420 |
|
435 | 421 | define nxthread_all_bt
|
436 | 422 | _save_current_tcb
|
437 | 423 | set $i = 0
|
438 |
| - while ($i < $_target_max_tasks) |
| 424 | + while ($i < g_npidhash) |
439 | 425 | # 1: backtrace
|
440 | 426 | nxthread $i 1
|
441 | 427 | set $i = $i + 1
|
442 | 428 | end
|
443 | 429 | _restore_current_tcb
|
444 | 430 | end
|
445 | 431 |
|
446 |
| -define info_nxthreads |
| 432 | +define info threads |
447 | 433 | _save_current_tcb
|
448 | 434 | set $i = 0
|
449 |
| - while ($i < $_target_max_tasks) |
| 435 | + while ($i < g_npidhash) |
450 | 436 | # dummy : 0 0
|
451 | 437 | nxthread $i 0 0
|
452 | 438 | set $i = $i + 1
|
453 | 439 | end
|
454 | 440 | _restore_current_tcb
|
455 | 441 | end
|
456 | 442 |
|
457 |
| -define nxcontinue |
458 |
| - printf "nxcontinue\n" |
| 443 | +define c |
459 | 444 | _restore_current_tcb
|
460 | 445 | continue
|
461 | 446 | end
|
| 447 | + |
| 448 | +define thread |
| 449 | + _save_current_tcb |
| 450 | + if ($argc == 0) |
| 451 | + _running_task |
| 452 | + set $pid = $rtcb->pid |
| 453 | + else |
| 454 | + set $pid = $arg0 |
| 455 | + end |
| 456 | + |
| 457 | + nxthread $pid |
| 458 | +end |
0 commit comments