source: rtems-tools/tools/gdb/python/classic_printer.py @ 0967a1b

4.104.115
Last change on this file since 0967a1b was 0967a1b, checked in by Dhananjay Balan <mb.dhananjay@…>, on 07/13/13 at 11:01:59

Refactoring

  • drop _printer suffix from printer classes.
  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[a785e25]1#
2# RTEMS Classic pretty printers for GDB
3#
4
[0967a1b]5class attribute:
[a785e25]6
7    def __init__(self, attribute):
8        ''' ToDo: Verify - usage of all '''
9        self.attr = classic.attribute(attribute,'all')
10
11    def to_string(self):
12        return gdb.Value(self.attr.to_string())
13
[0967a1b]14class semaphore:
15    """ToDo: Print a Semaphore_Control object. Print using the struct display hint
[a785e25]16    and an iterator. """
17
18    class iterator:
19        """Use an iterator for each field expanded from the id so GDB output
20        is formatted correctly."""
21
22        def __init__(self, semaphore):
23            self.semaphore = semaphore
24            self.count = 0
25
26        def __iter__(self):
27            return self
28
29        def next(self):
30            self.count += 1
31            if self.count == 1:
32                return self.semaphore['Object']
33            elif self.count == 2:
34                attr = attribute(self.semaphore['attribute_set'],
35                                 'semaphore')
36                return attr.to_string()
37            elif self.count == 3:
38                return self.semaphore['Core_control']
39            raise StopIteration
40
41    def __init__(self, semaphore):
42        self.semaphore = semaphore
43
44    def to_string(self):
45        return ''
46
47    @staticmethod
48    def key(i):
49        if i == 0:
50            return 'Object'
51        elif i == 1:
52            return 'attribute_set'
53        elif i == 2:
54            return 'Core_control'
55        return 'bad'
56
57    def children(self):
58        counter = itertools.imap (self.key, itertools.count())
59        return itertools.izip (counter, self.iterator(self.semaphore))
60
61    def display_hint (self):
62        return 'struct'
Note: See TracBrowser for help on using the repository browser.