[rtems-tools commit] Add region support.

Chris Johns chrisj at rtems.org
Sun Aug 24 23:45:34 UTC 2014


Module:    rtems-tools
Branch:    master
Commit:    b9ee5df588aa1a4cf0a64cf511b0585309ff5510
Changeset: http://git.rtems.org/rtems-tools/commit/?id=b9ee5df588aa1a4cf0a64cf511b0585309ff5510

Author:    Dhananjay Balan <mb.dhananjay at gmail.com>
Date:      Sun Jul 28 15:03:58 2013 +0530

Add region support.

Abstractions for classic/region added.

---

 tools/gdb/python/classic.py   |   27 ++++++++++++++++++++++++---
 tools/gdb/python/heaps.py     |   28 +++++++++++++++++++++++++---
 tools/gdb/python/helper.py    |    2 +-
 tools/gdb/python/objects.py   |    2 +-
 tools/gdb/python/rtems.py     |    3 ++-
 tools/gdb/python/supercore.py |    2 +-
 6 files changed, 54 insertions(+), 10 deletions(-)

diff --git a/tools/gdb/python/classic.py b/tools/gdb/python/classic.py
index f7d4dfc..e2ecfaa 100644
--- a/tools/gdb/python/classic.py
+++ b/tools/gdb/python/classic.py
@@ -8,10 +8,13 @@
 import gdb
 import itertools
 import re
+#ToDo This shouldn't be here
+import helper
 
 import objects
 import threads
 import watchdog
+import heaps
 import supercore
 
 class attribute:
@@ -41,7 +44,8 @@ class attribute:
                      'barrier'],
         'message_queue' : ['priority',
                            'scope'],
-        'partition' : ['scope']
+        'partition' : ['scope'],
+        'region' : ['priority']
         }
 
     masks = {
@@ -214,6 +218,23 @@ class partition:
         print '     Name:', self.object_control.name()
         print '     Attr:', self.attr.to_string()
         print '   Length:', self.length
-        print 'Buffer Size:', self.buffer_size
-        print 'Used Blocks:', self.used_blocks
+        print '   B Size:', self.buffer_size
+        print ' U Blocks:', self.used_blocks
 
+class region:
+    "prints a classic region"
+
+    def __init__(self,id):
+        self.id = id
+        self.object = objects.information.object(self.id).dereference()
+        self.object_control = objects.control(self.object['Object'])
+        self.attr = attribute(self.object['attribute_set'], 'region')
+        self.wait_queue = threads.queue(self.object['Wait_queue'])
+        self.heap = heaps.control(self.object['Memory'])
+
+    def show(self, from_tty):
+        print '     Name:', self.object_control.name()
+        print '     Attr:', self.attr.to_string()
+        helper.tasks_printer_routine(self.wait_queue)
+        print '   Memory:'
+        self.heap.show()
diff --git a/tools/gdb/python/heaps.py b/tools/gdb/python/heaps.py
index 4798912..2cc7907 100644
--- a/tools/gdb/python/heaps.py
+++ b/tools/gdb/python/heaps.py
@@ -15,6 +15,8 @@ class block:
             return False
         return True
 
+    def val(self):
+        return str(self.block)
 
     def next(self):
         if not self.null():
@@ -25,11 +27,15 @@ class block:
             self.block = self.block['prev']
 
 class stats:
-    ''heap statistics''
+    '''heap statistics'''
 
     def __init__(self,stat):
         self.stat = stat
 
+    def inst(self):
+        i = self.stat['instance']
+        return i
+
     def avail(self):
         val = self.stat['size']
         return val
@@ -37,9 +43,14 @@ class stats:
     def free(self):
         return self.stat['free_size']
 
+    def show(self):
+        print '  Instance:',self.inst()
+        print '     Avail:',self.avail()
+        print '      Free:',self.free()
+
     # ToDo : incorporate others
 
-def control:
+class control:
     '''Abstract a heap control structure'''
 
     def __init__(self, ctl):
@@ -59,4 +70,15 @@ def control:
 
     def stat(self):
         st = stats(self.ctl['stats'])
-        return st
\ No newline at end of file
+        return st
+
+    def show(self):
+        fi = self.first()
+        la = self.last()
+
+        print '     First:', fi.val()
+        print '      Last:', la.val()
+
+        stats = self.stat()
+        print '    stats:'
+        stats.show()
\ No newline at end of file
diff --git a/tools/gdb/python/helper.py b/tools/gdb/python/helper.py
index ec17400..c9c9a42 100644
--- a/tools/gdb/python/helper.py
+++ b/tools/gdb/python/helper.py
@@ -1,7 +1,7 @@
 #
 # RTEMS GDB support helper routins.
 
-def tasks_printer_rotuine(wait_queue):
+def tasks_printer_routine(wait_queue):
     tasks = wait_queue.tasks()
     print '    Queue: len = %d, state = %s' % (len(tasks),wait_queue.state())
     for t in range(0, len(tasks)):
diff --git a/tools/gdb/python/objects.py b/tools/gdb/python/objects.py
index c433039..1a64a8d 100644
--- a/tools/gdb/python/objects.py
+++ b/tools/gdb/python/objects.py
@@ -18,7 +18,7 @@ class infotables:
         'classic/semaphores'     : ('Semaphore_Control',     '_Semaphore_Information'),
         'classic/message_queues' : ('Message_queue_Control', '_Message_queue_Information'),
         'classic/partitions'     : ('Partition_Control',     '_Partition_Information'),
-        'classic/regions'        : ('Region_Control',        '_Regions_Information'),
+        'classic/regions'        : ('Region_Control',        '_Region_Information'),
         'classic/ports'          : ('Port_Control',          '_Port_Information'),
         'classic/periods'        : ('Period_Control',        '_Period_Information'),
         'classic/extensions'     : ('Extension_Control',     '_Extension_Information'),
diff --git a/tools/gdb/python/rtems.py b/tools/gdb/python/rtems.py
index eac5042..8738736 100644
--- a/tools/gdb/python/rtems.py
+++ b/tools/gdb/python/rtems.py
@@ -79,7 +79,8 @@ class rtems_object(gdb.Command):
         'classic/tasks': lambda id: classic.task(id),
         'classic/message_queues': lambda id: classic.message_queue(id),
         'classic/timers' : lambda id: classic.timer(id),
-        'classic/partitions' : lambda id: classic.partition(id)
+        'classic/partitions' : lambda id: classic.partition(id),
+        'classic/regions' : lambda id: classic.region(id)
         }
 
     def __init__(self):
diff --git a/tools/gdb/python/supercore.py b/tools/gdb/python/supercore.py
index 7e958b1..073bbd0 100644
--- a/tools/gdb/python/supercore.py
+++ b/tools/gdb/python/supercore.py
@@ -15,4 +15,4 @@ class CORE_message_queue:
         # self.buffer
 
     def show(self):
-        helper.tasks_printer_rotuine(self.wait_queue)
+        helper.tasks_printer_routine(self.wait_queue)



More information about the vc mailing list