Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | """repository for focus object, breakpoints, watchpoints, etc. |
2 | """ | |
3 | ||
4 | # message header | |
5 | msghead = __name__ | |
6 | msghead_dbx = "DBX-" + msghead | |
7 | ||
8 | ||
9 | # a global id counter to generate unique ids for watchpoints, breakpoints, | |
10 | # etc. Use Repository.nextid() to receive the next available id. | |
11 | __objectid = 0 | |
12 | ||
13 | def nextid(): | |
14 | """function used to generate a unique id for watchpoints, breakpoints, etc. | |
15 | """ | |
16 | global __objectid | |
17 | __objectid += 1 | |
18 | return str(__objectid) | |
19 | ||
20 | ||
21 | class Repository: | |
22 | """class that serves as repository for shared data | |
23 | """ | |
24 | ||
25 | def __init__ (self): | |
26 | """ | |
27 | globals - top level globals(), so that we can eval() expression in | |
28 | other places as they are at top level. | |
29 | """ | |
30 | self.console = None | |
31 | self.topName = None | |
32 | self.globals = None | |
33 | self.riesling = None | |
34 | self.fldTable = None | |
35 | self.modTable = None | |
36 | self.cmdTable = None | |
37 | self.symTable = None | |
38 | self.memLoad = None | |
39 | ||
40 | #self.cycle = 0L | |
41 | # the current focus module, in original string | |
42 | self.focusSrc = None | |
43 | # the corresponding riesling backend module | |
44 | self.focus = None | |
45 | self.groups = { } | |
46 | self.breakpoints = { } | |
47 | self.watchpoints = { } | |
48 | self.cmdAlias = { } | |
49 | # 1 means in rioesling interpreter mode, otherwise in normal python | |
50 | # mode | |
51 | self.imode = 0 | |
52 | # 1 means output message will be printed | |
53 | self.echo = 1 | |
54 | ||
55 | # arch config | |
56 | self.ncpus = 0 | |
57 | self.ncores = 0 | |
58 | self.nucores = 0 | |
59 | self.nstrands = 0 | |
60 | # pointer (as uint64_t) to backend system object | |
61 | self.sysAddr = 0L | |
62 | self.optdir = None | |
63 | # fp values | |
64 | self.nSpregs = 0 | |
65 | self.nDpregs = 0 | |
66 | self.nQpregs = 0 | |
67 | # array to cpu/core/strand objects | |
68 | self.cpus = None | |
69 | self.cores = None | |
70 | self.ucores = None | |
71 | self.strands = None | |
72 | self.riesLib = None | |
73 | self.socketAPI = None | |
74 | self.prompt = 'NA' | |
75 | # used in sam mode to indicate whether blaze is running or not, | |
76 | # blaze must be in 'stop" mode when conduct breakpoint operaiton. | |
77 | # this variable remains as 0 when not in sam mode. | |
78 | self.running = 0 | |
79 | # keep track of blaze numcpu and corresponding pmask | |
80 | self.blazeNumcpu = 1 | |
81 | self.pmask = 0x1L | |
82 | # indicate the type of cpu architecture, e.g., n2, etc | |
83 | self.arch = None | |
84 | ||
85 | ||
86 | def addBreakpoint (self, breakpoint): | |
87 | """ | |
88 | """ | |
89 | if self.breakpoints.has_key(breakpoint.id): | |
90 | raise KeyError, "duplicated breakpoint id %d" % breakpoint.id | |
91 | ||
92 | self.breakpoints[breakpoint.id] = breakpoint | |
93 | ||
94 | ||
95 | def deleteBreakpoint (self, id): | |
96 | """ | |
97 | """ | |
98 | idstr = str(id) | |
99 | if self.breakpoints.has_key(idstr): | |
100 | del self.breakpoints[idstr] | |
101 | else: | |
102 | raise KeyError, "does not have breakpoint with id=%s" % idstr | |
103 | ||
104 | ||
105 | def showBreakpoint (self, focus=None): | |
106 | """ | |
107 | """ | |
108 | ids = self.breakpoints.keys() | |
109 | ids.sort() | |
110 | result = [ ] | |
111 | for id in ids: | |
112 | bpoint = self.breakpoints[id] | |
113 | if (focus == None) or (focus == bpoint.modSrc): | |
114 | result.append("id=%s, mod=%s, cmd='%s', action=%s" % (bpoint.id, bpoint.modSrc, bpoint.src, bpoint.action)) | |
115 | ||
116 | return '\n'.join(result) | |
117 | ||
118 | ||
119 | def addWatchpoint (self, watchpoint): | |
120 | """ | |
121 | """ | |
122 | if self.watchpoints.has_key(watchpoint.id): | |
123 | raise KeyError, "duplicated watchpoint id %d" % watchpoint.id | |
124 | ||
125 | self.watchpoints[watchpoint.id] = watchpoint | |
126 | ||
127 | ||
128 | def showWatchpoint (self): | |
129 | """ | |
130 | """ | |
131 | ids = self.watchpoints.keys() | |
132 | ids.sort() | |
133 | result = [ ] | |
134 | for id in ids: | |
135 | wpoint = self.watchpoints[id] | |
136 | result.append("id=%s, disable=%d, cmd='%s', watch='%s', action=%s" % (wpoint.id, wpoint.disable, wpoint.src, wpoint.watch, wpoint.action)) | |
137 | result.append("DBX: id=%s, watchExpr=%s" % (wpoint.id, wpoint.watchExpr)) #dbx | |
138 | return '\n'.join(result) | |
139 | ||
140 | ||
141 | """self-testing | |
142 | """ | |
143 | if __name__ == "__main__": | |
144 | pass |