[rtems-tools commit] Heavy refactoring + Improved mesege queu printing.

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


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

Author:    Dhananjay Balan <mb.dhananjay at gmail.com>
Date:      Fri Jul 12 19:22:37 2013 +0530

Heavy refactoring + Improved mesege queu printing.
- pretty printers moved to the corresponding api_printer module
- object abstractions moved to
	- their own name for core modules
	- supercore for other supercore objects
	- classic for classic api objects

---

 tools/gdb/python/__init__.py |    9 ++++++
 tools/gdb/python/chains.py   |    5 ++-
 tools/gdb/python/classic.py  |   64 ++++--------------------------------------
 tools/gdb/python/objects.py  |   63 -----------------------------------------
 tools/gdb/python/rtems.py    |   18 +++++++----
 tools/gdb/python/threads.py  |   12 --------
 6 files changed, 30 insertions(+), 141 deletions(-)

diff --git a/tools/gdb/python/__init__.py b/tools/gdb/python/__init__.py
index 0664d21..dd55529 100644
--- a/tools/gdb/python/__init__.py
+++ b/tools/gdb/python/__init__.py
@@ -3,14 +3,23 @@ if __name__ == "__main__":
     import sys
     import os.path
     sys.path.append(os.path.dirname(__file__))
+    import supercore
     import chains
     import rtems
     import classic
     import objects
     import threads
+
+    import supercore_printer
+    import classic_printer
+
+    # Needed to reload code inside gdb source command
+    reload(supercore)
     reload(chains)
     reload(rtems)
     reload(classic)
     reload(objects)
     reload(threads)
+    reload(supercore_printer)
+    reload(classic_printer)
     print 'RTEMS GDB Support loaded'
diff --git a/tools/gdb/python/chains.py b/tools/gdb/python/chains.py
index d691822..0826ba9 100644
--- a/tools/gdb/python/chains.py
+++ b/tools/gdb/python/chains.py
@@ -32,6 +32,8 @@ class node:
             return self.node_val.cast(nodetype)
         return None
 
+    def to_string(self):
+        return self.node_val['next'] + "Prev: "+self.node_val['previous']
 
 class control:
     """Manage the Chain_Control."""
@@ -44,4 +46,5 @@ class control:
         return t
 
     def last(self):
-        return node(self.ctrl['first'])
+        return node(self.ctrl['Tail']['Node'])
+
diff --git a/tools/gdb/python/classic.py b/tools/gdb/python/classic.py
index d3f624d..e82078d 100644
--- a/tools/gdb/python/classic.py
+++ b/tools/gdb/python/classic.py
@@ -11,6 +11,7 @@ import re
 
 import objects
 import threads
+import supercore
 
 class attribute:
     """The Classic API attribute."""
@@ -98,63 +99,6 @@ class attribute:
                     return True
         return False
 
-class attribute_printer:
-
-    def __init__(self, attr):
-        self.attr = attribute(attr,'all')
-
-    def to_string(self):
-        return gdb.Value(self.attr.to_string())
-
-class semaphore_printer:
-    """Print a Semaphore_Control object. Print using the struct display hint
-    and an iterator."""
-
-    class iterator:
-        """Use an iterator for each field expanded from the id so GDB output
-        is formatted correctly."""
-
-        def __init__(self, semaphore):
-            self.semaphore = semaphore
-            self.count = 0
-
-        def __iter__(self):
-            return self
-
-        def next(self):
-            self.count += 1
-            if self.count == 1:
-                return self.semaphore['Object']
-            elif self.count == 2:
-                attr = attribute(self.semaphore['attribute_set'],
-                                 'semaphore')
-                return attr.to_string()
-            elif self.count == 3:
-                return self.semaphore['Core_control']
-            raise StopIteration
-
-    def __init__(self, semaphore):
-        self.semaphore = semaphore
-
-    def to_string(self):
-        return ''
-
-    @staticmethod
-    def key(i):
-        if i == 0:
-            return 'Object'
-        elif i == 1:
-            return 'attribute_set'
-        elif i == 2:
-            return 'Core_control'
-        return 'bad'
-
-    def children(self):
-        counter = itertools.imap (self.key, itertools.count())
-        return itertools.izip (counter, self.iterator(self.semaphore))
-
-    def display_hint (self):
-        return 'struct'
 
 class semaphore:
     "Print a classic semaphore."
@@ -225,9 +169,13 @@ class message_queue:
         self.object_control = objects.control(self.object['Object'])
         self.attr = attribute(self.object['attribute_set'], \
             'message_queue')
+        self.wait_queue = threads.queue( \
+            self.object['message_queue']['Wait_queue'])
+
+        self.core_control = supercore.CORE_message_queue(self.object['message_queue'])
 
     def show(self, from_tty):
         print '     Name:', self.object_control.name()
         print '     Attr:', self.attr.to_string()
 
-
+        self.core_control.show()
\ No newline at end of file
diff --git a/tools/gdb/python/objects.py b/tools/gdb/python/objects.py
index 25353d7..d2ba216 100644
--- a/tools/gdb/python/objects.py
+++ b/tools/gdb/python/objects.py
@@ -247,71 +247,8 @@ class control:
         is_string = information.is_string(self._id.api(), self._id._class())
         return str(name(self.object['name'], is_string))
 
-class id_printer:
-    """Print an object given the ID. Print using the struct display hint and an
-    iterator."""
 
-    class iterator:
-        """Use an iterator for each field expanded from the id so GDB output
-        is formatted correctly."""
-
-        def __init__(self, id):
-            self.id = id
-            self.count = 0
 
-        def __iter__(self):
-            return self
-
-        def next(self):
-            self.count += 1
-            if self.count == 1:
-                return int(self.id.value())
-            elif self.count == 2:
-                return self.id.node()
-            elif self.count == 3:
-                return self.id.api()
-            elif self.count == 4:
-                return self.id._class()
-            elif self.count == 5:
-                return self.id.index()
-            raise StopIteration
-
-    def __init__(self, id):
-        self.id = ident(id)
-
-    def to_string(self):
-        return ''
-
-    @staticmethod
-    def key(i):
-        if i == 0:
-            return 'id'
-        elif i == 1:
-            return 'node'
-        elif i == 2:
-            return 'api'
-        elif i == 3:
-            return 'class'
-        elif i == 4:
-            return 'index'
-        return 'bad'
-
-    def children(self):
-        counter = itertools.imap (self.key, itertools.count())
-        return itertools.izip (counter, self.iterator(self.id))
-
-    def display_hint (self):
-        return 'struct'
-
-class name_printer:
-    """Pretty printer for an object's name. It has to guess the type as no
-    information is available to help determine it."""
-
-    def __init__(self, nameval):
-        self.name = name(nameval)
-
-    def to_string(self):
-        return gdb.Value(str(self.name))
 
 class control_printer:
 
diff --git a/tools/gdb/python/rtems.py b/tools/gdb/python/rtems.py
index 398f4e5..d530e6e 100644
--- a/tools/gdb/python/rtems.py
+++ b/tools/gdb/python/rtems.py
@@ -12,6 +12,10 @@ import objects
 import threads
 import classic
 
+# ToDo: Move every printing out
+import supercore_printer
+import classic_printer
+
 nesting = 0
 
 def type_from_value(val):
@@ -50,13 +54,13 @@ def lookup_function (val):
     return None
 
 def build_rtems_dict():
-    pp_dict[re.compile('^rtems_id$')]   = lambda val: objects.id_printer(val)
-    pp_dict[re.compile('^Objects_Id$')] = lambda val: objects.id_printer(val)
-    pp_dict[re.compile('^Objects_Name$')] = lambda val: objects.name_printer(val)
-    pp_dict[re.compile('^Objects_Control$')] = lambda val: objects.control_printer(val)
-    pp_dict[re.compile('^States_Control$')] = lambda val: threads.state_printer(val)
-    pp_dict[re.compile('^rtems_attribute$')] = lambda val: classic.attribute_printer(val)
-    pp_dict[re.compile('^Semaphore_Control$')] = lambda val: classic.semaphore_printer(val)
+    pp_dict[re.compile('^rtems_id$')]   = lambda val: supercore_printer.id_printer(val)
+    pp_dict[re.compile('^Objects_Id$')] = lambda val: supercore_printer.id_printer(val)
+    pp_dict[re.compile('^Objects_Name$')] = lambda val: supercore_printer.name_printer(val)
+    pp_dict[re.compile('^Objects_Control$')] = lambda val: supercore_printer.control_printer(val)
+    pp_dict[re.compile('^States_Control$')] = lambda val: supercore_printer.state_printer(val)
+    pp_dict[re.compile('^rtems_attribute$')] = lambda val: classic_printer.attribute_printer(val)
+    pp_dict[re.compile('^Semaphore_Control$')] = lambda val: classic_printer.semaphore_printer(val)
 
 class rtems(gdb.Command):
     """Prefix command for RTEMS."""
diff --git a/tools/gdb/python/threads.py b/tools/gdb/python/threads.py
index 3debbe7..b5ac3fb 100644
--- a/tools/gdb/python/threads.py
+++ b/tools/gdb/python/threads.py
@@ -191,17 +191,5 @@ class queue:
                     self.que['Queues']['Priority'][ph])))
         return t
 
-    def to_string(self):
-        if self.fifo():
-            s = 'fifo'
-        else:
-            s = 'priority'
-        return
 
-class state_printer:
 
-    def __init__(self, s):
-        self.s = state(s)
-
-    def to_string(self):
-        return self.s.to_string()



More information about the vc mailing list