diff options
Diffstat (limited to 'tools/gdb/python/classic_printer.py')
-rw-r--r-- | tools/gdb/python/classic_printer.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/gdb/python/classic_printer.py b/tools/gdb/python/classic_printer.py new file mode 100644 index 0000000..e9d7cb8 --- /dev/null +++ b/tools/gdb/python/classic_printer.py @@ -0,0 +1,62 @@ +# +# RTEMS Classic pretty printers for GDB +# + +class attribute_printer: + + def __init__(self, attribute): + ''' ToDo: Verify - usage of all ''' + self.attr = classic.attribute(attribute,'all') + + def to_string(self): + return gdb.Value(self.attr.to_string()) + +class semaphore_printer: + """WIP: 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' |