source: rtems-tools/tools/gdb/python/classic_printer.py @ 09086b4

4.104.11
Last change on this file since 09086b4 was 09086b4, checked in by Dhananjay Balan <mb.dhananjay@…>, on Jul 27, 2013 at 8:41:19 AM

Support classic/partitions
Added support for partition object.

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