source: rtems-tools/tools/gdb/python/heaps.py @ 7a415d4

4.104.115
Last change on this file since 7a415d4 was b9ee5df, checked in by Dhananjay Balan <mb.dhananjay@…>, on 07/28/13 at 09:15:58

Add region support.

Abstractions for classic/region added.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#
2# RTEMS heap
3#
4
5class block:
6    '''Abstract a heap block structure'''
7
8    def __init__(self, blk):
9        self.block = blk
10        self.prev_size = self.block['prev_size']
11        self.size_flag = self.block['size_and_flag']
12
13    def null(self):
14        if self.block:
15            return False
16        return True
17
18    def val(self):
19        return str(self.block)
20
21    def next(self):
22        if not self.null():
23            self.block = self.block['next']
24
25    def prev(self):
26        if not self.null():
27            self.block = self.block['prev']
28
29class stats:
30    '''heap statistics'''
31
32    def __init__(self,stat):
33        self.stat = stat
34
35    def inst(self):
36        i = self.stat['instance']
37        return i
38
39    def avail(self):
40        val = self.stat['size']
41        return val
42
43    def free(self):
44        return self.stat['free_size']
45
46    def show(self):
47        print '  Instance:',self.inst()
48        print '     Avail:',self.avail()
49        print '      Free:',self.free()
50
51    # ToDo : incorporate others
52
53class control:
54    '''Abstract a heap control structure'''
55
56    def __init__(self, ctl):
57        self.ctl = ctl
58
59    def first(self):
60        b = block(self.ctl['first_block'])
61        return b
62
63    def last(self):
64        b = block(self.ctl['last_block'])
65        return b
66
67    def free(self):
68        b = block(self.ctl['free_list'])
69        return b
70
71    def stat(self):
72        st = stats(self.ctl['stats'])
73        return st
74
75    def show(self):
76        fi = self.first()
77        la = self.last()
78
79        print '     First:', fi.val()
80        print '      Last:', la.val()
81
82        stats = self.stat()
83        print '    stats:'
84        stats.show()
Note: See TracBrowser for help on using the repository browser.