Changeset b061a67 in rtems-tools for tools/gdb


Ignore:
Timestamp:
Jul 12, 2013, 1:34:37 PM (6 years ago)
Author:
Dhananjay Balan <mb.dhananjay@…>
Branches:
4.10, 4.11, e9f48e9face6c4dea62712d73b35412c0fe10332
Children:
a785e25
Parents:
6e75f4e
git-author:
Dhananjay Balan <mb.dhananjay@…> (07/12/13 13:34:37)
git-committer:
Chris Johns <chrisj@…> (08/24/14 23:52:40)
Message:

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
Location:
tools/gdb/python
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • tools/gdb/python/__init__.py

    r6e75f4e rb061a67  
    44    import os.path
    55    sys.path.append(os.path.dirname(__file__))
     6    import supercore
    67    import chains
    78    import rtems
     
    910    import objects
    1011    import threads
     12
     13    import supercore_printer
     14    import classic_printer
     15
     16    # Needed to reload code inside gdb source command
     17    reload(supercore)
    1118    reload(chains)
    1219    reload(rtems)
     
    1421    reload(objects)
    1522    reload(threads)
     23    reload(supercore_printer)
     24    reload(classic_printer)
    1625    print 'RTEMS GDB Support loaded'
  • tools/gdb/python/chains.py

    r6e75f4e rb061a67  
    3333        return None
    3434
     35    def to_string(self):
     36        return self.node_val['next'] + "Prev: "+self.node_val['previous']
    3537
    3638class control:
     
    4547
    4648    def last(self):
    47         return node(self.ctrl['first'])
     49        return node(self.ctrl['Tail']['Node'])
     50
  • tools/gdb/python/classic.py

    r6e75f4e rb061a67  
    1212import objects
    1313import threads
     14import supercore
    1415
    1516class attribute:
     
    99100        return False
    100101
    101 class attribute_printer:
    102 
    103     def __init__(self, attr):
    104         self.attr = attribute(attr,'all')
    105 
    106     def to_string(self):
    107         return gdb.Value(self.attr.to_string())
    108 
    109 class semaphore_printer:
    110     """Print a Semaphore_Control object. Print using the struct display hint
    111     and an iterator."""
    112 
    113     class iterator:
    114         """Use an iterator for each field expanded from the id so GDB output
    115         is formatted correctly."""
    116 
    117         def __init__(self, semaphore):
    118             self.semaphore = semaphore
    119             self.count = 0
    120 
    121         def __iter__(self):
    122             return self
    123 
    124         def next(self):
    125             self.count += 1
    126             if self.count == 1:
    127                 return self.semaphore['Object']
    128             elif self.count == 2:
    129                 attr = attribute(self.semaphore['attribute_set'],
    130                                  'semaphore')
    131                 return attr.to_string()
    132             elif self.count == 3:
    133                 return self.semaphore['Core_control']
    134             raise StopIteration
    135 
    136     def __init__(self, semaphore):
    137         self.semaphore = semaphore
    138 
    139     def to_string(self):
    140         return ''
    141 
    142     @staticmethod
    143     def key(i):
    144         if i == 0:
    145             return 'Object'
    146         elif i == 1:
    147             return 'attribute_set'
    148         elif i == 2:
    149             return 'Core_control'
    150         return 'bad'
    151 
    152     def children(self):
    153         counter = itertools.imap (self.key, itertools.count())
    154         return itertools.izip (counter, self.iterator(self.semaphore))
    155 
    156     def display_hint (self):
    157         return 'struct'
    158102
    159103class semaphore:
     
    226170        self.attr = attribute(self.object['attribute_set'], \
    227171            'message_queue')
     172        self.wait_queue = threads.queue( \
     173            self.object['message_queue']['Wait_queue'])
     174
     175        self.core_control = supercore.CORE_message_queue(self.object['message_queue'])
    228176
    229177    def show(self, from_tty):
     
    231179        print '     Attr:', self.attr.to_string()
    232180
    233 
     181        self.core_control.show()
  • tools/gdb/python/objects.py

    r6e75f4e rb061a67  
    248248        return str(name(self.object['name'], is_string))
    249249
    250 class id_printer:
    251     """Print an object given the ID. Print using the struct display hint and an
    252     iterator."""
    253 
    254     class iterator:
    255         """Use an iterator for each field expanded from the id so GDB output
    256         is formatted correctly."""
    257 
    258         def __init__(self, id):
    259             self.id = id
    260             self.count = 0
    261 
    262         def __iter__(self):
    263             return self
    264 
    265         def next(self):
    266             self.count += 1
    267             if self.count == 1:
    268                 return int(self.id.value())
    269             elif self.count == 2:
    270                 return self.id.node()
    271             elif self.count == 3:
    272                 return self.id.api()
    273             elif self.count == 4:
    274                 return self.id._class()
    275             elif self.count == 5:
    276                 return self.id.index()
    277             raise StopIteration
    278 
    279     def __init__(self, id):
    280         self.id = ident(id)
    281 
    282     def to_string(self):
    283         return ''
    284 
    285     @staticmethod
    286     def key(i):
    287         if i == 0:
    288             return 'id'
    289         elif i == 1:
    290             return 'node'
    291         elif i == 2:
    292             return 'api'
    293         elif i == 3:
    294             return 'class'
    295         elif i == 4:
    296             return 'index'
    297         return 'bad'
    298 
    299     def children(self):
    300         counter = itertools.imap (self.key, itertools.count())
    301         return itertools.izip (counter, self.iterator(self.id))
    302 
    303     def display_hint (self):
    304         return 'struct'
    305 
    306 class name_printer:
    307     """Pretty printer for an object's name. It has to guess the type as no
    308     information is available to help determine it."""
    309 
    310     def __init__(self, nameval):
    311         self.name = name(nameval)
    312 
    313     def to_string(self):
    314         return gdb.Value(str(self.name))
     250
     251
    315252
    316253class control_printer:
  • tools/gdb/python/rtems.py

    r6e75f4e rb061a67  
    1212import threads
    1313import classic
     14
     15# ToDo: Move every printing out
     16import supercore_printer
     17import classic_printer
    1418
    1519nesting = 0
     
    5155
    5256def build_rtems_dict():
    53     pp_dict[re.compile('^rtems_id$')]   = lambda val: objects.id_printer(val)
    54     pp_dict[re.compile('^Objects_Id$')] = lambda val: objects.id_printer(val)
    55     pp_dict[re.compile('^Objects_Name$')] = lambda val: objects.name_printer(val)
    56     pp_dict[re.compile('^Objects_Control$')] = lambda val: objects.control_printer(val)
    57     pp_dict[re.compile('^States_Control$')] = lambda val: threads.state_printer(val)
    58     pp_dict[re.compile('^rtems_attribute$')] = lambda val: classic.attribute_printer(val)
    59     pp_dict[re.compile('^Semaphore_Control$')] = lambda val: classic.semaphore_printer(val)
     57    pp_dict[re.compile('^rtems_id$')]   = lambda val: supercore_printer.id_printer(val)
     58    pp_dict[re.compile('^Objects_Id$')] = lambda val: supercore_printer.id_printer(val)
     59    pp_dict[re.compile('^Objects_Name$')] = lambda val: supercore_printer.name_printer(val)
     60    pp_dict[re.compile('^Objects_Control$')] = lambda val: supercore_printer.control_printer(val)
     61    pp_dict[re.compile('^States_Control$')] = lambda val: supercore_printer.state_printer(val)
     62    pp_dict[re.compile('^rtems_attribute$')] = lambda val: classic_printer.attribute_printer(val)
     63    pp_dict[re.compile('^Semaphore_Control$')] = lambda val: classic_printer.semaphore_printer(val)
    6064
    6165class rtems(gdb.Command):
  • tools/gdb/python/threads.py

    r6e75f4e rb061a67  
    192192        return t
    193193
    194     def to_string(self):
    195         if self.fifo():
    196             s = 'fifo'
    197         else:
    198             s = 'priority'
    199         return
    200194
    201 class state_printer:
    202195
    203     def __init__(self, s):
    204         self.s = state(s)
    205 
    206     def to_string(self):
    207         return self.s.to_string()
Note: See TracChangeset for help on using the changeset viewer.