1
2 import gtk
3 import gobject
4 from gtk import gdk
5
6 blue = (0, 0, 0x99)
7 green = (0, 0xff, 0)
8 yellow = (0xff, 0xff, 0)
9 orange = (0xff, 0x66, 0)
10 red = (0xff, 0, 0)
11
44
46 """
47 Render a box which draws arrows for references between
48 "locations" in it's known address space.
49 """
53
55 if addr < self.base:
56 return False
57 if addr >= self.base + self.size:
58 return False
59 return True
60
62 self.base = base
63 self.size = size
64 self.refs = []
65 self.deps = []
66 for r in refs:
67 fromus = self.inRange(r[0])
68 tous = self.inRange(r[1])
69 if fromus and tous:
70 self.refs.insert(0, r)
71
72 elif not fromus and not tous:
73 continue
74
75 else:
76 self.refs.append(refs)
77
78 for i in range(len(self.refs)):
79 depth = 2
80 r = self.refs[i]
81 for j in range(i, 0, -1):
82 if self.isOverlap(r, self.refs[j]):
83 depth += 2
84
85 if self.flags() & gtk.REALIZED:
86 self.move_resize(*self.allocation)
87
89 x, y, w, h = self.allocation
90 cr = self.window.cairo_create()
91
92
93 cr.set_source_rgb(0, 0, 0)
94 cr.rectangle(0, 0, h, w)
95 cr.fill()
96
97 for base,size,color,text in self.spaces:
98 start = ((base-self.min) * h) / self.range
99 size = ((size * h) / self.range) + 1
100 cr.rectangle(0, start, w, size)
101 cr.set_source_rgb(*color)
102 cr.fill()
103
104 cr.update_layout(self._layout)
105 cr.show_layout(self._layout)
106
108 """
109 Render a potentially sparse space which may be backed by varied
110 types of maps/pages/etc.
111 """
112 - def __init__(self, spaces, dheight=300, dwidth=20):
113 """
114 Render a list of "spaces". These are a list of tuples
115 with the following contents (<base>,<len>,<color_tuple>,<text>).
116 """
117 VWidget.__init__(self, dheight=dheight, dwidth=dwidth)
118 self.updateSpaces(spaces)
119
121 self.spaces = spaces
122
123
124 min = 0xffffffff
125 max = 0
126 for base,size,color,text in self.spaces:
127 if base < min:
128 min = base
129 end = base+size
130 if end > max:
131 max = end
132
133
134 self.min = min
135 self.max = max
136 self.range = max - min
137
138 if self.flags() & gtk.REALIZED:
139 self.queue_draw()
140
141 - def goto(self, value):
144
151
153 x, y, w, h = self.allocation
154 cr = self.window.cairo_create()
155
156
157 cr.set_source_rgb(0, 0, 0)
158 cr.rectangle(0, 0, h, w)
159 cr.fill()
160
161 for base,size,color,text in self.spaces:
162 start = ((base-self.min) * h) / self.range
163 size = ((size * h) / self.range) + 1
164 cr.rectangle(0, start, w, size)
165 cr.set_source_rgb(*color)
166 cr.fill()
167
168 cr.update_layout(self._layout)
169 cr.show_layout(self._layout)
170
173
174 gobject.type_register(SpaceView)
175 gobject.type_register(RefView)
176
177 cmap = { 4: red,
178 6: blue,
179 5: orange }
180
190
192 spaces = []
193 for chunk in segment.getChunks():
194 if chunk.isBusy():
195 color = (0xff, 0, 0)
196 else:
197 color = (0, 0xff, 0)
198 spaces.append((chunk.address, len(chunk), color, "stuff"))
199
200 return spaces
201