Changes between Version 8 and Version 9 of Debugging/GDBScripts


Ignore:
Timestamp:
Jul 22, 2008, 4:00:20 PM (11 years ago)
Author:
ChrisJohns
Comment:

Moved to the FTP server.

Legend:

Unmodified
Added
Removed
Modified
  • Debugging/GDBScripts

    v8 v9  
    55
    66{{{
    7 sparc-rtems4.7-gdb --command=gdb-macros sp01.exe
     7sparc-rtems4.7-gdb --command=rtems-gdb-macros sp01.exe
    88}}}
    99
     
    1313sparc-rtems-gdb sp01.exe
    1414...
    15 (gdb) source gdb-macros
     15(gdb) source rtems-gdb-macros
    1616}}}
    1717
     
    3333----
    3434
    35 {{{
    36 ###
    37 # GDB macros for analyzing RTEMS threads
    38 #
    39 #
    40 #  7 August 2006 - Joel:
    41 #    + Use Thread_Control_struct not Thread_Control to make gdb happy.
    42 #      Who knows why this makes gdb happier?
    43 #  10 July 2006 - Joel:
    44 #    + Renamed all methods to start with rtems_ if public and rtems_helper_
    45 #       if private
    46 #    + Merged code to dump timer delta chain
    47 #    + Added code to dump Classic Semaphores, Message Queues, and Regions
    48 #    + Added support code to dump SuperCore Mutexes, Semaphores,
    49 #        Message Queues, Thread Queues, and Heaps
    50 #
    51 #  TODO:
    52 #    + rtems_task_backtrack is CPU specific.  How to fix?
    53 #    + Need to detect when POSIX and ITRON are not configured so
    54 #      a nice message is printed when those commands are used
    55 #    + Add support for Classic API
    56 #       - Periods
    57 #       - Timers
    58 #       - Partitions
    59 #    + Add support for POSIX API
    60 #       - Message Queues
    61 #
    62 # Commands implemented:
    63 #    rtems_task_backtrack TCB
    64 #    rtems_print_name name
    65 #    rtems_internal_task index
    66 #    rtems_internal_tasks
    67 #    rtems_classic_tasks
    68 #    rtems_classic_task index
    69 #    rtems_classic_semaphore index
    70 #    rtems_classic_semaphores
    71 #    rtems_classic_message_queue index
    72 #    rtems_classic_message_queues
    73 #    rtems_classic_region index
    74 #    rtems_classic_regions
    75 #    rtems_posix_thread index
    76 #    rtems_posix_threads
    77 #    rtems_posix_semaphore index
    78 #    rtems_posix_semaphores
    79 #    rtems_posix_mutex index
    80 #    rtems_posix_mutexes
    81 #    rtems_tasks
    82 #    rtems_internal_ticks_chain
    83 #    rtems_internal_seconds_chain
    84 #    rtems_malloc_walk
    85 #    rtems_workspace_walk
    86 #    rtems_tod
    87 #    rtems_check_state
    88 #
     35Moved out of the Wiki to the FTP server and updated for RTEMS 4.9. Check out http://www.rtems.org/ftp/pub/rtems/people/chrisj/gdb-scripts.
    8936
    90 #############################################################################
    91 ########                   Public Helper Macros                      ########
    92 #############################################################################
     37Add support for the i386. You need to edit the script file to get back trace support for your target.
    9338
    94 ####################
    95 # rtems_task_backtrack
    96 #
    97 # ABSTRACT
    98 #    Print backtrace of an RTEMS task
    99 #
    100 # ARGUMENTS:
    101 #    arg0 = pointer to the Thread_Control_struct of the task.
    102 #
    103 define rtems_task_backtrack
    104   # Uncomment the following line for PowerPC support
    105   # set $stkp = $arg0->Registers.gpr1
    106 
    107   # Uncomment the following line for Coldfire support
    108   # set $stkp = $arg0->Registers.a6
    109 
    110   set $stkp = *(void**)$stkp
    111   while $stkp != 0
    112       info line **((void**)$stkp+1)
    113     set $stkp = *(void**)$stkp
    114   end
    115 end
    116 document rtems_task_backtrack
    117   Usage: rtems_task_backtrack TCB
    118   Displays a stack trace for the specific task
    119 end
    120 
    121 ####################
    122 # rtems_print_name
    123 #
    124 # ABSTRACT
    125 #    Print backtrace of an RTEMS task
    126 #
    127 # ARGUMENTS:
    128 #    arg0 = object name -- 32 bit format
    129 #
    130 define rtems_print_name
    131         set $name = $arg0
    132   set $n0 = (char) ($name >> 24)
    133   if $n0 < ' ' || $n0 > 'z'
    134       set $n0=' '
    135   end
    136   printf "%c",$n0
    137   set $n1 = (char) (0xff & ($name >> 16))
    138   if $n1 < ' ' || $n1 > 'z'
    139       set $n1=' '
    140   end
    141   printf "%c",$n1
    142   set $n2 = (char) (0xff & ($name >> 8))
    143   if $n2 < ' ' || $n2 > 'z'
    144       set $n2=' '
    145   end
    146   printf "%c",$n2
    147   set $n3 = (char) (0xff & $name)
    148   if $n3 < ' ' || $n3 > 'z'
    149       set $n3=' '
    150   end
    151   printf "%c | ",$n3
    152 end
    153 document rtems_print_name
    154   Usage: rtems_print_name name
    155   Attempt to print the Classic API style name in ASCII
    156 end
    157 
    158 #############################################################################
    159 ########         Helper Macros - Use Only From Other Macros          ########
    160 #############################################################################
    161 
    162 ####################
    163 # rtems_helper_task_dump
    164 #
    165 # ABSTRACT
    166 #    Print information about an RTEMS task
    167 #
    168 # ARGUMENTS
    169 #    arg0 = Task index in the corresponding _Information table.
    170 #    arg1 = pointer to the Thread_Control_struct of the task.
    171 #    arg2 = 1 for verbose output, 0 otherwise
    172 #
    173 define rtems_helper_task_dump
    174   set $d1t_num = $arg0
    175   set $pt = $arg1
    176   set $d1t_verbose = $arg2
    177 
    178   printf "%2d | ", $d1t_num
    179   set $id = $pt->Object.id
    180   set $name = (unsigned int)$pt->Object.name
    181 
    182         rtems_print_name $name
    183   printf "%08x | ",$id
    184 
    185   set $state = $pt->current_state
    186   set $pri = $pt->current_priority
    187   printf "%3d | ",$pri
    188   set $ticks = $pt->ticks_executed
    189   printf "%8d | ", $ticks
    190 
    191   if $state == 0
    192     printf "READY"
    193   end
    194   if $state & 1
    195     printf "DORM "
    196   end
    197   if $state & 2
    198     printf "SUSP "
    199   end
    200   if $state & 4
    201     printf "TRANS "
    202   end
    203   if $state & 8
    204     printf "DELAY "
    205   end
    206   if $state & 0x10
    207     printf "Wtime "
    208   end
    209   if $state & 0x20
    210     printf "Wbuf "
    211   end
    212   if $state & 0x40
    213     printf "Wseg "
    214   end
    215   if $state & 0x80
    216     printf "Wmsg "
    217   end
    218   if $state & 0x100
    219     printf "Wevnt "
    220   end
    221   if $state & 0x200
    222     printf "Wsem "
    223   end
    224   if $state & 0x400
    225     printf "Wmutex 0x%8x", $pt->Wait.id
    226   end
    227   if $state & 0x800
    228     printf "Wcvar "
    229   end
    230   if $state & 0x1000
    231     printf "Wjatx "
    232   end
    233   if $state & 0x2000
    234     printf "Wrpc "
    235   end
    236   if $state & 0x4000
    237     printf "Wrate "
    238   end
    239   if $state & 0x8000
    240     printf "Wsig "
    241   end
    242   if $state & 0x10000
    243     printf "Wisig "
    244   end
    245 
    246         printf "\n"
    247 #    printf "\
    248 #---+------+----------+-----+----------+------------------------------\n"
    249   if $d1t_verbose
    250      printf "\
    251 BACKTRACE\n\
    252 13:37, 11 Jul 2006 (CDT)[wiki:User:JoelSherrill Dr. Joel] 13:37, 11 Jul 2006 (CDT)\n"
    253      rtems_task_backtrack $pt
    254   end
    255 end
    256 # Internal Helper Do Not Document
    257 
    258 ####################
    259 # rtems_helper_task_header
    260 #
    261 # ABSTRACT
    262 #    Print the header of the task list table
    263 #
    264 define rtems_helper_task_header
    265     printf "\==  ===============================================================\n"
    266   printf "\
    267  # | Name |    ID    | Pri |  Ticks   | State\n"
    268     printf "\
    269 ---+------+----------+-----+----------+------------------------------\n"
    270 end
    271 # Internal Helper Do Not Document
    272 
    273 ####################
    274 # rtems_helper_show_task
    275 #
    276 # ABSTRACT
    277 #    Support routine for verbose listing of a single task
    278 #
    279 # ARGUMENTS
    280 #    arg0 = _Information table.
    281 #    arg1 = index.
    282 #
    283 define rtems_helper_show_task
    284     rtems_helper_task_header
    285     set $pt = (Thread_Control_struct *)$arg0.local_table[$arg1]
    286     rtems_helper_task_dump $arg1 $pt 1
    287 end
    288 # Internal Helper Do Not Document
    289 
    290 ####################
    291 # rtems_helper_show_tasks
    292 #
    293 # ABSTRACT
    294 #    Support routine for verbose listing of all tasks of a given class
    295 #
    296 # ARGUMENTS
    297 #    arg0 = _Information table for the class (internal, classic, POSIX etc.).
    298 #
    299 define rtems_helper_show_tasks
    300   rtems_helper_task_header
    301   set $index = 1
    302   while $index <= $arg0.maximum
    303     set $pt = (Thread_Control_struct *)$arg0.local_table[$index]
    304     if $pt != 0
    305     rtems_helper_task_dump $index $pt 0
    306     end
    307     set $index = $index + 1
    308   end
    309 end
    310 # Internal Helper Do Not Document
    311 
    312 #############################################################################
    313 ########   Helper Macros For SuperCore - Use Only From Other Macros  ########
    314 #############################################################################
    315 
    316 ####################
    317 # rtems_helper_score_threadq
    318 #
    319 # ABSTRACT
    320 #    Verbosely list a single SuperCore thread queue
    321 #
    322 # ARGUMENTS
    323 #    arg0 = pointer to the thread queue
    324 #
    325 define rtems_helper_score_threadq
    326   set $tq = $arg0
    327   set $THREAD_QUEUE_DISCIPLINE_FIFO     = 0
    328   set $THREAD_QUEUE_DISCIPLINE_PRIORITY = 1
    329 
    330   if $tq->discipline == $THREAD_QUEUE_DISCIPLINE_FIFO
    331     printf "  FIFO - "
    332     set $limit = 1
    333   end
    334 
    335   if $tq->discipline == $THREAD_QUEUE_DISCIPLINE_PRIORITY
    336     printf "  PRIO - "
    337     set $limit = 3
    338   end
    339 
    340 
    341   # now walk them
    342   set $count = 0
    343   set $pri_index = 0
    344   set $queues = &$tq->Queues
    345   while $pri_index < $limit
    346     set $chain = &$queues.Priority[$pri_index]
    347     set $ptail = &$chain->permanent_null
    348     set $next = $chain->first
    349     while $next != $ptail
    350       set $t = (Thread_Control_struct *)$next
    351       printf "0x%08x@%d ", $t->Object.id, $t->current_priority
    352       set $next = $next->next
    353       set $count = $count + 1
    354     end
    355     set $pri_index = $pri_index + 1
    356   end
    357   if $count == 0
    358     printf "%s", "No waiting threads"
    359   end
    360 end
    361 # Internal Helper Do Not Document
    362 
    363 ####################
    364 # rtems_helper_score_heap
    365 #
    366 # ABSTRACT
    367 #    Verbosely list contents of a SuperCore Heap
    368 #
    369 # ARGUMENTS
    370 #    arg0 = pointer to heap
    371 #
    372 define rtems_helper_score_heap
    373    set $heap = $arg0
    374 
    375    set $heapstart = $heap->start
    376    set $currentblock = $heapstart
    377    set $used = 0
    378    set $numused = 0
    379    set $free = 0
    380    set $numfree = 0
    381    while $currentblock->front_flag != 1
    382      if $currentblock->front_flag & 1
    383        if $arg0 != 0
    384         printf "USED: %p %d\n", $currentblock, $currentblock->front_flag & ~1
    385        else
    386          printf "*"
    387        end
    388        set $used = $used + $currentblock->front_flag & ~1
    389        set $numused = $numused + 1
    390      else
    391        if $arg0 != 0
    392         printf "FREE: %p %d\n", $currentblock, $currentblock->front_flag & ~1
    393        else
    394          printf "."
    395        end
    396        set $free = $free + $currentblock->front_flag & ~1
    397        set $numfree = $numfree + 1
    398      end
    399      set $currentblock = \
    400        (Heap_Block *)((char *)$currentblock + ($currentblock->front_flag&~1))
    401    end
    402    if $arg0 == 0
    403      printf "\n"
    404    end
    405    printf "TOTAL: %d (%d)\tUSED: %d (%d) \tFREE: %d (%d)\n", \
    406      $used + $free, $numused + $numfree, \
    407      $used, $numused, \
    408      $free, $numfree
    409 end
    410 # Internal Helper Do Not Document
    411 
    412 ####################
    413 # rtems_helper_score_watchdog_chain
    414 #
    415 # ABSTRACT
    416 #    Verbosely list a single SuperCore Watchdog chain
    417 #
    418 # ARGUMENTS
    419 #    arg0 = pointer to Watchdog delta chain
    420 #
    421 define rtems_helper_score_watchdog_chain
    422   set $permt = &$arg0.permanent_null
    423   set $node = $arg0.first
    424 
    425   if $node == $permt
    426     printf "Empty\n"
    427   end
    428   while $node != $permt
    429    set $wnode = (Watchdog_Control *)$node
    430    #print $wnode
    431    printf "======================\n0x%x, %d handler=", \
    432       $wnode, $wnode.delta_interval
    433    print $wnode.routine
    434    print/x *$wnode
    435    set $node = $node.next
    436   end
    437 end
    438 # Internal Helper Do Not Document
    439 
    440 ####################
    441 # rtems_helper_score_mutex
    442 #
    443 # ABSTRACT
    444 #    Verbosely list a single SuperCore mutex
    445 #
    446 # ARGUMENTS
    447 #    arg0 = pointer to the mutex
    448 #
    449 define rtems_helper_score_mutex
    450   set $m = $arg0
    451   set $CORE_MUTEX_DISCIPLINES_FIFO               = 0
    452   set $CORE_MUTEX_DISCIPLINES_PRIORITY           = 1
    453   set $CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT   = 2
    454   set $CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING   = 3
    455 
    456   set $d = $m->Attributes.discipline
    457   if $d == $CORE_MUTEX_DISCIPLINES_FIFO
    458     printf "FIFO "
    459   end
    460   if $d == $CORE_MUTEX_DISCIPLINES_PRIORITY
    461     printf "PRIO "
    462   end
    463   if $d == $CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT
    464     printf "INHT "
    465   end
    466   if $d == $CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING
    467     printf "CEIL "
    468   end
    469 
    470   if $m->lock == 0
    471     printf "LCK holder=0x%08x nest=%d\n", $m->holder_id, $m->nest_count
    472   else
    473     printf "UNL"
    474   end
    475 
    476   rtems_helper_score_threadq &$m->Wait_queue
    477 end
    478 # Internal Helper Do Not Document
    479 
    480 ####################
    481 # rtems_helper_score_semaphore
    482 #
    483 # ABSTRACT
    484 #    Verbosely list a single SuperCore semaphore
    485 #
    486 # ARGUMENTS
    487 #    arg0 = pointer to the semaphore
    488 #
    489 define rtems_helper_score_semaphore
    490   set $s = $arg0
    491 
    492   if $s->count == 0
    493     printf "Unavailable "
    494     rtems_helper_score_threadq &$s->Wait_queue
    495   else
    496     printf "Available Count=%d", $s->count
    497   end
    498 end
    499 # Internal Helper Do Not Document
    500 
    501 ####################
    502 # rtems_helper_score_message_queue
    503 #
    504 # ABSTRACT
    505 #    Verbosely list a single SuperCore Message Queue
    506 #
    507 # ARGUMENTS
    508 #    arg0 = pointer to the message queue
    509 #
    510 define rtems_helper_score_message_queue
    511   set $mq = $arg0
    512 
    513   printf "%d/%d msgs ", \
    514     $mq->number_of_pending_messages, $mq->maximum_pending_messages
    515   if $mq->number_of_pending_messages == 0
    516     rtems_helper_score_threadq &$mq->Wait_queue
    517   end
    518 end
    519 # Internal Helper Do Not Document
    520 
    521 #############################################################################
    522 ########                     Internal Objects                        ########
    523 #############################################################################
    524 
    525 ####################
    526 # rtems_internal_task
    527 #
    528 # ABSTRACT
    529 #    Verbosely list a single internal task
    530 #
    531 # ARGUMENTS
    532 #    arg0 = index in the _Information table
    533 #
    534 define rtems_internal_task
    535   rtems_helper_show_task  _Thread_Internal_information $arg0
    536 end
    537 document rtems_internal_task
    538   Usage: rtems_internal_task index
    539   Displays detailed information about the specified internal RTEMS task
    540 end
    541 
    542 ####################
    543 # rtems_internal_tasks
    544 #
    545 # ABSTRACT
    546 #    Dump all internal tasks
    547 #
    548 define rtems_internal_tasks
    549   rtems_helper_show_tasks  _Thread_Internal_information
    550 end
    551 document rtems_internal_tasks
    552   Usage: rtems_internal_tasks
    553   Displays a list of all internal RTEMS tasks
    554 end
    555 
    556 #############################################################################
    557 ########                        Classic API                          ########
    558 #############################################################################
    559 
    560 ####################
    561 # rtems_classic_tasks
    562 #
    563 # ABSTRACT
    564 #    Dump all Classic tasks
    565 #
    566 define rtems_classic_tasks
    567   rtems_helper_show_tasks  _RTEMS_tasks_Information
    568 end
    569 document rtems_classic_tasks
    570   Usage: rtems_classic_tasks
    571   Displays a list of all Classic API RTEMS tasks
    572 end
    573 
    574 ####################
    575 # rtems_classic_task
    576 #
    577 # ABSTRACT
    578 #    Verbosely list a single classic task
    579 #
    580 # ARGUMENTS
    581 #    arg0 = index in the _Information table
    582 #
    583 define rtems_classic_task
    584   rtems_helper_show_task  _RTEMS_tasks_Information $arg0
    585 end
    586 document rtems_classic_task
    587   Usage: rtems_classic_task index
    588   Displays detailed information about the specified Classic API task
    589 end
    590 
    591 ####################
    592 # rtems_classic_semaphore
    593 #
    594 # ABSTRACT
    595 #    Verbosely list a single Classic API semaphore
    596 #
    597 # ARGUMENTS
    598 #    arg0 = index in the _Information table
    599 #
    600 define rtems_classic_semaphore
    601 
    602   set $d1t_num = $arg0
    603   set $inf = _Semaphore_Information
    604   set $sem = (Semaphore_Control *)$inf.local_table[$arg0]
    605   set $id = $sem->Object.id
    606   set $name = (unsigned int)$sem->Object.name
    607 
    608   printf "%2d | ", $d1t_num
    609         rtems_print_name $name
    610   printf "%08x | ",$id
    611   #  hack for is a mutex
    612   if $sem->attribute_set != 0
    613     printf "  Mutex "
    614     rtems_helper_score_mutex &$sem->Core_control.mutex
    615   else
    616     printf "  Sem   "
    617     rtems_helper_score_semaphore &$sem->Core_control.semaphore
    618   end
    619   printf "\n"
    620  
    621 end
    622 document rtems_classic_semaphore
    623   Usage: rtems_classic_semaphore index
    624   Displays information about the specified Classic API Semaphore
    625 end
    626 
    627 ####################
    628 # rtems_classic_semaphores
    629 #
    630 # ABSTRACT
    631 #    Verbosely list all Classic API semaphores
    632 #
    633 # ARGUMENTS: NONE
    634 #
    635 define rtems_classic_semaphores
    636   set $inf = _Semaphore_Information
    637   printf "\==  ===============================================================\n"
    638   printf "\
    639  # | Name |    ID    | Information\n"
    640     printf "\
    641 ---+------+----------+-----------------------------------------------\n"
    642   set $index = 1
    643   while $index <= $inf.maximum
    644     set $pt = (Semaphore_Control *)$inf.local_table[$index]
    645     if $pt != 0
    646     rtems_classic_semaphore $index
    647     end
    648     set $index = $index + 1
    649   end
    650 end
    651 document rtems_classic_semaphores
    652   Usage: rtems_classic_semaphores
    653   Displays a list of all Classic API Semaphores
    654 end
    655 
    656 
    657 ####################
    658 # rtems_classic_message_queue
    659 #
    660 # ABSTRACT
    661 #    Verbosely list a single Classic API Message Queue
    662 #
    663 # ARGUMENTS
    664 #    arg0 = index in the _Information table
    665 #
    666 define rtems_classic_message_queue
    667   set $d1t_num = $arg0
    668   set $inf = _Message_queue_Information
    669   set $queue = (Message_queue_Control *)$inf.local_table[$arg0]
    670   set $id = $queue->Object.id
    671   set $name = (unsigned int)$queue->Object.name
    672 
    673   printf "%2d | ", $d1t_num
    674   rtems_print_name $name
    675   printf "%08x | ",$id
    676   rtems_helper_score_message_queue &$queue->message_queue
    677   printf "\n"
    678 end
    679 document rtems_classic_message_queue
    680   Usage: rtems_classic_message_queue index
    681   Displays information about the specified Classic API Message Queue
    682 end
    683 
    684 ####################
    685 # rtems_classic_message_queues
    686 #
    687 # ABSTRACT
    688 #    Verbosely list all Classic API Message Queues
    689 #
    690 # ARGUMENTS: NONE
    691 #
    692 define rtems_classic_message_queues
    693   set $inf = _Message_queue_Information
    694   printf "\==  ===============================================================\n"
    695   printf "\
    696  # | Name |    ID    | Information\n"
    697     printf "\
    698 ---+------+----------+-----------------------------------------------\n"
    699   set $index = 1
    700   while $index <= $inf.maximum
    701     set $pt = (Message_queue_Control *)$inf.local_table[$index]
    702     if $pt != 0
    703     rtems_classic_message_queue $index
    704     end
    705     set $index = $index + 1
    706   end
    707 end
    708 document rtems_classic_message_queues
    709   Usage: rtems_classic_message_queues
    710   Displays a list of all Classic API Message Queues
    711 end
    712 
    713 ####################
    714 # rtems_classic_region
    715 #
    716 # ABSTRACT
    717 #    Verbosely list a single Classic API Region
    718 #
    719 # ARGUMENTS
    720 #    arg0 = index in the _Information table
    721 #
    722 define rtems_classic_region
    723   set $inf = _Region_Information
    724   set $d1t_num = $arg0
    725   set $r = (Region_Control *)$inf.local_table[$arg0]
    726   set $id = $r->Object.id
    727   set $name = (unsigned int)$r->Object.name
    728 
    729   printf "%2d | ", $d1t_num
    730   rtems_print_name $name
    731   printf "%08x | ",$id
    732   rtems_helper_score_heap &$r->Memory
    733   printf "\n"
    734 end
    735 document rtems_classic_region
    736   Usage: rtems_classic_region index
    737   Displays information about the specified Classic API Region
    738 end
    739 
    740 ####################
    741 # rtems_classic_regions
    742 #
    743 # ABSTRACT
    744 #    Verbosely list all Classic API Regions
    745 #
    746 # ARGUMENTS: NONE
    747 #
    748 define rtems_classic_regions
    749   set $inf = _Region_Information
    750   printf "\==  ===============================================================\n"
    751   printf "\
    752  # | Name |    ID    | Information\n"
    753     printf "\
    754 ---+------+----------+-----------------------------------------------\n"
    755   set $index = 1
    756   while $index <= $inf.maximum
    757     set $pt = (Region_Control *)$inf.local_table[$index]
    758     if $pt != 0
    759     rtems_classic_region $index
    760     end
    761     set $index = $index + 1
    762   end
    763 end
    764 document rtems_classic_regions
    765   Usage: rtems_classic_regions
    766   Displays a list of all Classic API Regions
    767 end
    768 
    769 #############################################################################
    770 ########                          POSIX API                          ########
    771 #############################################################################
    772 
    773 ####################
    774 # rtems_posix_thread
    775 #
    776 # ABSTRACT
    777 #    Verbosely list a single POSIX thread
    778 #
    779 # ARGUMENTS
    780 #    arg0 = index in the _Information table
    781 #
    782 define rtems_posix_thread
    783   rtems_helper_show_task  _POSIX_Threads_Information $arg0
    784 end
    785 document rtems_posix_thread
    786   Usage: rtems_posix_thread index
    787   Displays detailed information about the specified POSIX API thread
    788 end
    789 
    790 ####################
    791 # rtems_posix_threads
    792 #
    793 # ABSTRACT
    794 #    Dump all POSIX threads
    795 #
    796 # ARGUMENTS: NONE
    797 #
    798 define rtems_posix_threads
    799   rtems_helper_show_tasks  _POSIX_Threads_Information
    800 end
    801 document rtems_posix_threads
    802   Usage: rtems_posix_threads
    803   Displays a list of all POSIX API threads
    804 end
    805 
    806 ####################
    807 # rtems_posix_semaphore
    808 #
    809 # ABSTRACT
    810 #    Verbosely list a single POSIX API semaphore
    811 #
    812 # ARGUMENTS
    813 #    arg0 = index in the _Information table
    814 #
    815 define rtems_posix_semaphore
    816 
    817   set $d1t_num = $arg0
    818   set $inf = _POSIX_Semaphore_Information
    819   set $sem = (POSIX_Semaphore_Control *)$inf.local_table[$arg0]
    820   set $id = $sem->Object.id
    821 
    822   printf "%2d | ", $d1t_num
    823   if $sem->named
    824     printf "%s", (char *)$sem->Object.name
    825   end
    826   printf " %08x | ",$id
    827   rtems_helper_score_semaphore &$sem->Semaphore
    828   printf "\n"
    829  
    830 end
    831 document rtems_posix_semaphore
    832   Usage: rtems_posix_semaphore index
    833   Displays information about the specified POSIX API Semaphore
    834 end
    835 
    836 ####################
    837 # rtems_posix_semaphores
    838 #
    839 # ABSTRACT
    840 #    Verbosely list all POSIX API semaphores
    841 #
    842 # ARGUMENTS: NONE
    843 #
    844 define rtems_posix_semaphores
    845   set $inf = _POSIX_Semaphore_Information
    846   printf "\==  ===============================================================\n"
    847   printf "\
    848  # |     ID    | Information\n"
    849     printf "\
    850 ---+-----------+-----------------------------------------------\n"
    851   set $index = 1
    852   while $index <= $inf.maximum
    853     set $pt = (POSIX_Semaphore_Control *)$inf.local_table[$index]
    854     if $pt != 0
    855     rtems_posix_semaphore $index
    856     end
    857     set $index = $index + 1
    858   end
    859 end
    860 document rtems_posix_semaphores
    861   Usage: rtems_posix_semaphores
    862   Displays a list of all POSIX API Semaphores
    863 end
    864 
    865 ####################
    866 # rtems_posix_mutex
    867 #
    868 # ABSTRACT
    869 #    Verbosely list a single POSIX API mutex
    870 #
    871 # ARGUMENTS
    872 #    arg0 = index in the _Information table
    873 #
    874 define rtems_posix_mutex
    875 
    876   set $d1t_num = $arg0
    877   set $inf = _POSIX_Mutex_Information
    878   set $mutex = (POSIX_Mutex_Control *)$inf.local_table[$arg0]
    879   set $id = $mutex->Object.id
    880 
    881   printf "%2d | ", $d1t_num
    882   printf "%08x | ",$id
    883   rtems_helper_score_mutex &$mutex->Mutex
    884   printf "\n"
    885  
    886 end
    887 document rtems_posix_mutex
    888   Usage: rtems_posix_mutex index
    889   Displays information about the specified POSIX API Semaphore
    890 end
    891 
    892 ####################
    893 # rtems_posix_mutexes
    894 #
    895 # ABSTRACT
    896 #    Verbosely list all POSIX API mutexes
    897 #
    898 # ARGUMENTS: NONE
    899 #
    900 define rtems_posix_mutexes
    901   set $inf = _POSIX_Mutex_Information
    902   printf "\==  ===============================================================\n"
    903   printf "\
    904  # |    ID    | Information\n"
    905     printf "\
    906 ---+----------+-----------------------------------------------\n"
    907   set $index = 1
    908   while $index <= $inf.maximum
    909     set $pt = (POSIX_Mutex_Control *)$inf.local_table[$index]
    910     if $pt != 0
    911     rtems_posix_mutex $index
    912     end
    913     set $index = $index + 1
    914   end
    915 end
    916 document rtems_posix_mutexes
    917   Usage: rtems_posix_mutexes
    918   Displays a list of all POSIX API Mutexes
    919 end
    920 
    921 #############################################################################
    922 ########                    General and Cross API                    ########
    923 #############################################################################
    924 
    925 ####################
    926 # rtems_tasks
    927 #
    928 # ABSTRACT
    929 #    Dump all tasks of all classes (internal, POSIX and Classic)
    930 #
    931 # ARGUMENTS: NONE
    932 #
    933 # TODO: For 4.6, check object information table for non-NULL
    934 define rtems_tasks
    935   printf "Executing: 0x%x, Heir: 0x%x\n", _Thread_Executing->Object.id, \
    936     _Thread_Heir.Object.id
    937   printf "================================================================\n"
    938   printf "Internal Tasks\n"
    939   rtems_helper_show_tasks  _Thread_Internal_information
    940   printf "================================================================\n"
    941   printf "Classic Tasks\n"
    942   rtems_helper_show_tasks  _RTEMS_tasks_Information
    943   printf "================================================================\n"
    944   printf "POSIX Tasks\n"
    945   rtems_helper_show_tasks  _POSIX_Threads_Information
    946 end
    947 document rtems_tasks
    948   Usage: rtems_tasks
    949   Displays a list of all internal and API defined tasks/threads
    950 end
    951 
    952 ####################
    953 # rtems_internal_ticks_chain
    954 #
    955 # ABSTRACT
    956 #    Verbosely list contents of ticks chain tickled from clock tick
    957 #
    958 # ARGUMENTS: NONE
    959 #
    960 define rtems_internal_ticks_chain
    961   rtems_helper_score_watchdog_chain _Watchdog_Ticks_chain
    962 end
    963 document rtems_internal_ticks_chain
    964   Usage: rtems_internal_ticks_chain
    965   Lists the contains of the internal RTEMS delta chain used to manage
    966   all timing events that are tick based.  This chain will contain
    967   timeouts, delays, API defined timers, and the TOD update timer.
    968 end
    969 
    970 ####################
    971 # rtems_internal_seconds_chain
    972 #
    973 # ABSTRACT
    974 #    Verbosely list contents of seconds chain tickled from clock tick
    975 #
    976 # ARGUMENTS: NONE
    977 #
    978 define rtems_internal_seconds_chain
    979   rtems_helper_score_watchdog_chain _Watchdog_Seconds_chain
    980 end
    981 document rtems_internal_seconds_chain
    982   Usage: rtems_internal_seconds_chain
    983   Lists the contains of the internal RTEMS delta chain used to manage
    984   all timing events that are TOD based.
    985 end
    986 
    987 ####################
    988 # rtems_malloc_walk
    989 #
    990 # ABSTRACT
    991 #    Verbosely list the contents and state of the C Program Heap
    992 #
    993 # ARGUMENTS: None
    994 #
    995 define rtems_malloc_walk
    996   set $heap = &(((Region_Control *)\
    997     _Region_Information->local_table[RTEMS_Malloc_Heap&0xffff])->Memory)
    998    
    999   rtems_helper_score_heap $heap
    1000 end
    1001 document rtems_malloc_walk
    1002   Usage: rtems_malloc_walk
    1003   Display information about the C program heap
    1004 end
    1005 
    1006 ####################
    1007 # rtems_workspace_walk
    1008 #
    1009 # ABSTRACT
    1010 #    Verbosely list the contents and state of the C Program Heap
    1011 #
    1012 # ARGUMENTS: None
    1013 #
    1014 define rtems_workspace_walk
    1015   set $heap = &_Workspace_Area
    1016 
    1017   rtems_helper_score_heap $heap
    1018 end
    1019 document rtems_workspace_walk
    1020   Usage: rtems_workspace_walk
    1021   Display information about the RTEMS Executive Workspace
    1022 end
    1023 
    1024 ####################
    1025 # rtems_tod
    1026 #
    1027 # ABSTRACT
    1028 #    Print out the current time of day
    1029 #
    1030 # ARGUMENTS: NONE
    1031 #
    1032 define rtems_tod
    1033   printf "Current Time MM/DD/YYYY HH:MM:SS -- %02d/%02d/%d %02d:%02d:%02d\n", \
    1034     _TOD_Current.month, _TOD_Current.day, _TOD_Current.year, \
    1035     _TOD_Current.hour, _TOD_Current.minute, _TOD_Current.second
    1036 end
    1037 document rtems_tod
    1038   Usage: rtems_tod
    1039   Display the current time of day according to RTEMS
    1040   NOTE: If the TOD is not set, it will start at 1988.
    1041 end
    1042 
    1043 ####################
    1044 # rtems_check_state
    1045 #
    1046 # ABSTRACT
    1047 #    Check system state, dispatching critical section and ISR states
    1048 #
    1049 # ARGUMENTS: NONE
    1050 #
    1051 define rtems_check_state
    1052 
    1053   printf "RTEMS System State is: \n    "
    1054   p _System_state_Current
    1055   # Check Thread Dispatching Critical Sections
    1056   set $tddl = _Thread_Dispatch_disable_level
    1057   if $tddl == 0
    1058     printf "NOT inside dispatching critical section\n"
    1059   end
    1060   if $tddl != 0
    1061     printf "Inside dispatching critical section -- level = %d\n", $tddl
    1062     if $tddl >= 100
    1063       printf "HIGHLY PROBABLY DISPATCHING CRITICAL SECTION ERROR\n"
    1064     end
    1065   end
    1066 
    1067   # Check ISR Nesting and Dispatching Critical Sections
    1068   set $isrnl = _ISR_Nest_level
    1069   if $isrnl == 0
    1070     printf "NOT inside an ISR\n"
    1071   end
    1072   if $isrnl != 0
    1073     printf "Inside interrupt -- nest level = %d\n", $isrnl
    1074     if $isrnl > $tddl
    1075       printf "HIGHLY PROBABLY DISPATCHING CRITICAL SECTION ERROR\n"
    1076       printf "ISR NEST LEVEL SHOULD ALWAYS BE >= DISPATCH DISABLE LEVEL\n"
    1077     end
    1078     if $isrnl < $tddl
    1079       printf "It looks like you interrupted a dispatching critical section\n"
    1080     end
    1081   end
    1082 end
    1083 document rtems_check_state
    1084   Usage: rtems_check_state
    1085   This method displays information about the current state of RTEMS including
    1086   dispatching disable critical sections and ISR nesting.  It performs some
    1087   rudimentary consistency checks which might highlight problems.
    1088 end
    1089 }}}
     39--[wiki:User:ChrisJohns ChrisJohns] 07:00, 22 July 2008 (CDT)