source: rtems-testing/sim-scripts/rtems-gdb-macros-4.8 @ 9f356d1

4.11
Last change on this file since 9f356d1 was ae48b5a, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 15, 2009 at 10:05:50 PM

2009-09-15 Joel Sherrill <joel.sherrill@…>

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