summaryrefslogtreecommitdiffstats
path: root/tools/gdb/python/rtems.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gdb/python/rtems.py')
-rw-r--r--tools/gdb/python/rtems.py126
1 files changed, 89 insertions, 37 deletions
diff --git a/tools/gdb/python/rtems.py b/tools/gdb/python/rtems.py
index 6c987cf..534cb0d 100644
--- a/tools/gdb/python/rtems.py
+++ b/tools/gdb/python/rtems.py
@@ -1,8 +1,34 @@
+# RTEMS Tools Project (http://www.rtems.org/)
+# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# All rights reserved.
#
-# RTEMS Pretty Printers
-# Copyright 2010 Chris Johns (chrisj@rtems.org)
+# This file is part of the RTEMS Tools package in 'rtems-tools'.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
#
-# $Id$
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+#
+# RTEMS Pretty Printers
#
import gdb
@@ -29,18 +55,18 @@ class rtems_object(gdb.Command):
"""Object sub-command for RTEMS"""
objects = {
- 'classic/semaphores': lambda obj: classic.semaphore(obj),
- 'classic/tasks': lambda obj: classic.task(obj),
+ 'classic/semaphores': lambda obj: classic.semaphore(obj),
+ 'classic/tasks': lambda obj: classic.task(obj),
'classic/message_queues': lambda obj: classic.message_queue(obj),
- 'classic/timers' : lambda obj: classic.timer(obj),
- 'classic/partitions' : lambda obj: classic.partition(obj),
- 'classic/regions' : lambda obj: classic.region(obj),
- 'classic/barriers' : lambda obj: classic.barrier(obj)
- }
+ 'classic/timers' : lambda obj: classic.timer(obj),
+ 'classic/partitions' : lambda obj: classic.partition(obj),
+ 'classic/regions' : lambda obj: classic.region(obj),
+ 'classic/barriers' : lambda obj: classic.barrier(obj)
+ }
def __init__(self):
- self.__doc__ = 'Display the RTEMS object given a numeric ID \
- (Or a reference to rtems_object).'
+ self.__doc__ = 'Display the RTEMS object given a numeric ID' \
+ '(Or a reference to the object).'
super(rtems_object, self).__init__('rtems object',
gdb.COMMAND_DATA,
gdb.COMPLETE_SYMBOL)
@@ -79,29 +105,47 @@ class rtems_index(gdb.Command):
gdb.COMMAND_DATA,
gdb.COMPLETE_NONE)
- def instance(self,obj):
- '''Returns a n instance of corresponding object, the child should extend this'''
+ def instance(self, obj):
+ '''Returns a n instance of corresponding object, the child should extend
+ this'''
return obj
def invoke(self, arg, from_tty):
- for val in arg.split():
- try:
- index = int(val)
- except ValueError:
- print "error: %s is not an index" % (val)
- return
- try:
- obj = objects.information.object_return( self.api,
- self._class,
- index ).dereference()
- except IndexError:
- print "error: index %s is invalid" % (index)
- return
-
- instance = self.instance(obj)
- instance.show(from_tty)
- objects.information.invalidate()
-
+ maximum = objects.information.maximum(self.api, self._class)
+ minimum_id = objects.ident(objects.information.minimum_id(self.api, self._class))
+ maximum_id = objects.ident(objects.information.minimum_id(self.api, self._class))
+ args = arg.split()
+ if len(args):
+ for val in args:
+ try:
+ index = int(val, base = 0)
+ if index < maximum:
+ if index < minimum_id.index():
+ print "error: %s is not an index (min is %d)" % (val,
+ minimum_id.index())
+ return
+ else:
+ index = objects.ident(index).index()
+ except ValueError:
+ print "error: %s is not an index" % (val)
+ return
+ try:
+ obj = objects.information.object_return(self.api,
+ self._class,
+ index)
+ except IndexError:
+ print "error: index %s is invalid" % (index)
+ return
+ instance = self.instance(obj)
+ instance.show(from_tty)
+ objects.information.invalidate()
+ else:
+ print '-' * 70
+ print ' %s: %d [%08x -> %08x]' % (objects.information.name(self.api, self._class),
+ maximum, minimum_id.value(), maximum_id.value())
+ for index in range(minimum_id.index(), minimum_id.index() + maximum):
+ print '-' * 70
+ self.invoke(str(index), from_tty)
class rtems_semaphore(rtems_index):
'''semaphore subcommand'''
@@ -111,7 +155,7 @@ class rtems_semaphore(rtems_index):
self.__doc__ = 'Display RTEMS semaphore(s) by index(es)'
super(rtems_semaphore, self).__init__('rtems semaphore')
- def instance(self,obj):
+ def instance(self, obj):
return classic.semaphore(obj)
class rtems_task(rtems_index):
@@ -123,10 +167,9 @@ class rtems_task(rtems_index):
self.__doc__ = 'Display RTEMS task(s) by index(es)'
super(rtems_task,self).__init__('rtems task')
- def instance(self,obj):
+ def instance(self, obj):
return classic.task(obj)
-
class rtems_message_queue(rtems_index):
'''Message Queue subcommand'''
@@ -136,7 +179,7 @@ class rtems_message_queue(rtems_index):
self.__doc__ = 'Display RTEMS message_queue(s) by index(es)'
super(rtems_message_queue,self).__init__('rtems mqueue')
- def instance(self,obj):
+ def instance(self, obj):
return classic.message_queue(obj)
class rtems_timer(rtems_index):
@@ -148,7 +191,7 @@ class rtems_timer(rtems_index):
self.__doc__ = 'Display RTEMS timer(s) by index(es)'
super(rtems_timer, self).__init__('rtems timer')
- def instance(self,obj):
+ def instance(self, obj):
return classic.timer(obj)
class rtems_partition(rtems_index):
@@ -252,3 +295,12 @@ class rtems_wsec(rtems_watchdog_chain):
self.__doc__ = 'Display watchdog seconds chain'
super(rtems_wsec, self).__init__('rtems wdseconds')
+def create():
+ return (rtems(),
+ rtems_object(),
+ rtems_semaphore(),
+ rtems_task(),
+ rtems_message_queue(),
+ rtems_tod(),
+ rtems_wdt(),
+ rtems_wsec())