blob: 86e0eeb13b516784a42def41b6975f9cb4ff4161 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#
# RTEMS Classic pretty printers for GDB
#
import classic
import gdb
class attribute:
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:
"""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'
|