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