Mercurial > cpython-lru_cache-weakref
annotate Mac/Tools/twit/TwitCore.py @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 0f7515ebe3bf |
| children |
| rev | line source |
|---|---|
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1 # Window-interface-independent part of twit |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
2 import sys |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
3 import types |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
4 import bdb |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
5 import types |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
6 import os |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
7 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
8 SIMPLE_TYPES=( |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
9 types.NoneType, |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
10 types.IntType, |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
11 types.LongType, |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
12 types.FloatType, |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
13 types.ComplexType, |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
14 types.StringType |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
15 ) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
16 |
| 4333 | 17 # XXXX Mac-specific |
|
4817
0f7515ebe3bf
Moved resources around to forestall conflicts with debuggee
Jack Jansen <jack.jansen@cwi.nl>
parents:
4387
diff
changeset
|
18 ICON_NORMAL=500 |
|
0f7515ebe3bf
Moved resources around to forestall conflicts with debuggee
Jack Jansen <jack.jansen@cwi.nl>
parents:
4387
diff
changeset
|
19 ICON_RETURN=503 |
|
0f7515ebe3bf
Moved resources around to forestall conflicts with debuggee
Jack Jansen <jack.jansen@cwi.nl>
parents:
4387
diff
changeset
|
20 ICON_CALL=504 |
|
0f7515ebe3bf
Moved resources around to forestall conflicts with debuggee
Jack Jansen <jack.jansen@cwi.nl>
parents:
4387
diff
changeset
|
21 ICON_ZERO=505 |
|
0f7515ebe3bf
Moved resources around to forestall conflicts with debuggee
Jack Jansen <jack.jansen@cwi.nl>
parents:
4387
diff
changeset
|
22 ICON_DEAD=506 |
| 4333 | 23 |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
24 class DebuggerStuff(bdb.Bdb): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
25 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
26 def __init__(self, parent): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
27 bdb.Bdb.__init__(self) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
28 self.parent = parent |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
29 self.exception_info = (None, None) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
30 self.reason = 'Not running' |
| 4333 | 31 self.icon = ICON_NORMAL |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
32 self.reset() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
33 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
34 def reset(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
35 bdb.Bdb.reset(self) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
36 self.forget() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
37 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
38 def forget(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
39 self.lineno = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
40 self.stack = [] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
41 self.curindex = 0 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
42 self.curframe = None |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
43 |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
44 def run(self, cmd, locals, globals): |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
45 self.reason = 'Running' |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
46 bdb.Bdb.run(self, cmd, locals, globals) |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
47 print 'RETURN from run' |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
48 self.reason = 'Not running' |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
49 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
50 def setup(self, f, t): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
51 self.forget() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
52 self.stack, self.curindex = self.get_stack(f, t) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
53 self.curframe = self.stack[self.curindex][0] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
54 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
55 def interaction(self, frame, traceback): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
56 self.setup(frame, traceback) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
57 self.parent.interact() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
58 self.exception_info = (None, None) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
59 |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
60 # def user_call(self, frame, argument_list): |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
61 # self.reason = 'Calling' |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
62 # self.icon = ICON_CALL |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
63 # self.interaction(frame, None) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
64 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
65 def user_line(self, frame): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
66 self.reason = 'Stopped' |
| 4333 | 67 self.icon = ICON_NORMAL |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
68 self.interaction(frame, None) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
69 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
70 def user_return(self, frame, return_value): |
| 4333 | 71 self.reason = 'Returning' |
| 72 self.icon = ICON_RETURN | |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
73 self.interaction(frame, None) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
74 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
75 def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
76 self.reason = 'Exception occurred' |
| 4333 | 77 self.icon = ICON_DEAD |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
78 self.parent.setstate('tb') |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
79 self.exception_info = (exc_type, exc_value) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
80 self.interaction(frame, exc_traceback) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
81 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
82 def getexception(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
83 tp, value = self.exception_info |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
84 if tp <> None and type(tp) <> type(''): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
85 tp = tp.__name__ |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
86 if value <> None and type(value) <> type(''): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
87 value = `value` |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
88 return tp, value |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
89 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
90 def getstacktrace(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
91 names, locations = [], [] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
92 for frame, lineno in self.stack: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
93 name = frame.f_code.co_name |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
94 if not name: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
95 name = "<lambda>" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
96 elif name == '?': |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
97 name = "<not a function>" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
98 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
99 name = name + '()' |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
100 names.append(name) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
101 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
102 if lineno == -1: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
103 lineno = getframelineno(frame) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
104 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
105 modname = getframemodname(frame) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
106 if not modname: modname = "<unknown>" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
107 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
108 locations.append("%s:%d" % (modname, lineno)) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
109 return names, locations |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
110 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
111 def getframe(self, number): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
112 if number < 0 or number >= len(self.stack): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
113 return None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
114 return self.stack[number][0] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
115 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
116 def getframevars(self, number, show_complex=1, show_system=1): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
117 frame = self.getframe(number) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
118 if not frame: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
119 return [], [] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
120 return getvarsfromdict(frame.f_locals, show_complex, show_system) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
121 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
122 def getframevar(self, number, var): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
123 frame = self.getframe(number) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
124 return frame.f_locals[var] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
125 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
126 def getframefilepos(self, frameno): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
127 if frameno == None or frameno < 0 or frameno >= len(self.stack): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
128 return None, None, None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
129 frame, line = self.stack[frameno] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
130 if line == -1: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
131 line = getframelineno(frame) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
132 modname = getframemodname(frame) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
133 filename = frame.f_code.co_filename |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
134 return filename, modname, line |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
135 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
136 def getprogramstate(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
137 return self.reason |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
138 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
139 class Application: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
140 """Base code for the application""" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
141 |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
142 def mi_init(self, sessiontype, arg): |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
143 self.dbg = DebuggerStuff(self) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
144 self.run_dialog = self.new_stack_browser(self) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
145 self.run_dialog.open() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
146 self.module_dialog = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
147 self.initial_cmd = None |
| 4333 | 148 self.cur_string_name = None |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
149 if sessiontype == 'tb': |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
150 while arg.tb_next <> None: |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
151 arg = arg.tb_next |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
152 self.dbg.setup(arg.tb_frame, arg) |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
153 self.run_dialog.setup() |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
154 elif sessiontype == 'run': |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
155 self.initial_cmd = arg |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
156 |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
157 def breaks_changed(self, filename): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
158 self.run_dialog.breaks_changed(filename) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
159 if self.module_dialog: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
160 self.module_dialog.breaks_changed(filename) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
161 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
162 def to_debugger(self): |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
163 cmd = self.initial_cmd |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
164 self.initial_cmd = None |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
165 self.setstate('run') |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
166 self.switch_to_app() |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
167 apply(self.dbg.run, cmd) |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
168 self.setstate('none') |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
169 self.switch_to_dbg() |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
170 self.run_dialog.update_views() |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
171 if self.module_dialog: |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
172 self.module_dialog.update_views() |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
173 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
174 def interact(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
175 # Interact with user. First, display correct info |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
176 self.switch_to_dbg() |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
177 self.run_dialog.update_views() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
178 if self.module_dialog: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
179 self.module_dialog.update_views() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
180 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
181 # Next, go into mainloop |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
182 self.one_mainloop() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
183 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
184 # Finally (before we start the debuggee again) show state |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
185 self.switch_to_app() |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
186 self.run_dialog.show_it_running() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
187 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
188 def quit_bdb(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
189 self.dbg.set_quit() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
190 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
191 def run(self): |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
192 cmd = self.AskString('Statement to execute:') |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
193 self.runstring(cmd) |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
194 |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
195 def runfile(self, path): |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
196 dir, file = os.path.split(path) |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
197 try: |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
198 os.chdir(dir) |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
199 except os.error, arg: |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
200 self.Message("%s: %s"%(dir, arg)) |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
201 return |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
202 ns = {'__name__':'__main__', '__file__':path} |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
203 cmd = "execfile('%s')"%file |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
204 self.runstring(cmd, ns, ns) |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
205 |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
206 def runstring(self, cmd, globals={}, locals={}): |
| 4333 | 207 self.cur_string_name = '<string: "%s">'%cmd |
| 208 try: | |
| 209 cmd = compile(cmd, self.cur_string_name, 'exec') | |
| 210 except SyntaxError, arg: | |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
211 self.Message('Syntax error: %s'%`arg`) |
| 4333 | 212 return |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
213 self.initial_cmd = (cmd, globals, locals) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
214 self.exit_mainloop() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
215 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
216 def cont(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
217 self.dbg.set_continue() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
218 self.exit_mainloop() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
219 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
220 def step(self, frame): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
221 self.dbg.set_next(frame) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
222 self.exit_mainloop() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
223 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
224 def step_in(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
225 self.dbg.set_step() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
226 self.exit_mainloop() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
227 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
228 def step_out(self, frame): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
229 self.dbg.set_return(frame) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
230 self.exit_mainloop() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
231 |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
232 def kill(self): |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
233 self.dbg.set_quit() |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
234 self.exit_mainloop() |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
235 |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
236 def quit(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
237 self.do_quit() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
238 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
239 def browse(self, module): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
240 if not self.module_dialog: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
241 self.module_dialog = self.new_module_browser(self) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
242 self.module_dialog.open(module) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
243 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
244 self.module_dialog.focus(module) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
245 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
246 def browse_var(self, var): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
247 b = self.new_var_browser(self, var) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
248 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
249 class StackBrowser: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
250 """Base code for stack browser""" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
251 def mi_open(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
252 """Setup initial data structures""" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
253 self.cur_stackitem = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
254 self.cur_source = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
255 self.cur_modname = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
256 self.cur_line = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
257 self.show_complex = 1 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
258 self.show_system = 0 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
259 self.setup() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
260 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
261 # create_items(self) should create self.modules, self.vars and self.source |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
262 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
263 def setup(self): |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
264 self.parent.SetWatch() |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
265 """Fill the various widgets with values""" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
266 name, value = self.parent.dbg.getexception() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
267 self.setexception(name, value) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
268 self.setprogramstate(self.parent.dbg.getprogramstate()) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
269 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
270 names, locations = self.parent.dbg.getstacktrace() |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
271 self.stack_setcontent(names, locations) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
272 self.cur_stackitem = len(names)-1 |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
273 self.stack_select(self.cur_stackitem) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
274 self.setup_frame() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
275 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
276 def setup_frame(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
277 """Setup frame-dependent widget data""" |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
278 self.parent.SetWatch() |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
279 self.cont_varnames, self.cont_varvalues = \ |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
280 self.parent.dbg.getframevars(self.cur_stackitem, |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
281 self.show_complex, self.show_system) |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
282 self.setvars() |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
283 self.set_var_buttons() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
284 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
285 msg = "" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
286 if self.cur_stackitem == None: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
287 self.cur_source = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
288 self.cur_modname = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
289 self.cur_line = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
290 msg = "No stackframe selected" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
291 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
292 self.cur_source, self.cur_modname, optnextline = \ |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
293 self.parent.dbg.getframefilepos(self.cur_stackitem) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
294 if optnextline >= 0: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
295 self.cur_line = optnextline |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
296 if self.cur_source == '<string>': |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
297 self.cur_source = None |
| 4333 | 298 msg = "Executing from unknown <string>" |
| 299 elif type(self.cur_source) == types.StringType and \ | |
| 300 self.cur_source[:8] == '<string:': | |
| 301 msg = "Executing from "+self.cur_source | |
| 302 self.cur_source = None | |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
303 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
304 self.setsource(msg) |
| 4333 | 305 if not self.cur_line: |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
306 self.source_setline(1, ICON_ZERO) |
| 4333 | 307 else: |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
308 self.source_setline(self.cur_line, self.parent.dbg.icon) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
309 self.breaks_changed(self.cur_source) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
310 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
311 |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
312 self.parent.SetCursor() |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
313 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
314 # setsource(msg) should display cur_source+content, or msg if None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
315 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
316 def show_it_running(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
317 self.setprogramstate("Running") |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
318 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
319 def update_views(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
320 self.setup() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
321 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
322 def click_stack(self, number, *dummy): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
323 if number == self.cur_stackitem: return |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
324 self.cur_stackitem = number |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
325 self.stack_select(self.cur_stackitem) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
326 self.setup_frame() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
327 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
328 def click_var(self, var, *dummy): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
329 v = self.parent.dbg.getframevar(self.cur_stackitem, var) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
330 self.parent.browse_var(v) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
331 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
332 def click_source(self, lineno, inborder): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
333 if not inborder: |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
334 self.source_select(lineno) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
335 self.cur_line = lineno |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
336 if lineno == None or not self.cur_source or not inborder: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
337 return |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
338 if self.parent.dbg.get_break(self.cur_source, lineno): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
339 self.parent.dbg.clear_break(self.cur_source, lineno) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
340 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
341 self.parent.dbg.set_break(self.cur_source, lineno) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
342 self.parent.breaks_changed(self.cur_source) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
343 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
344 def breaks_changed(self, filename): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
345 if filename == self.cur_source: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
346 list = self.parent.dbg.get_file_breaks(filename) |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
347 self.source_setbreaks(list) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
348 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
349 def click_quit(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
350 self.parent.quit() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
351 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
352 def click_run(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
353 self.parent.run() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
354 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
355 def click_continue(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
356 self.parent.cont() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
357 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
358 def click_step(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
359 if self.cur_stackitem <> None: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
360 frame = self.parent.dbg.getframe(self.cur_stackitem) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
361 self.parent.step(frame) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
362 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
363 self.parent.step_in() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
364 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
365 def click_step_in(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
366 self.parent.step_in() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
367 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
368 def click_step_out(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
369 if self.cur_stackitem <> None: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
370 frame = self.parent.dbg.getframe(self.cur_stackitem) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
371 self.parent.step_out(frame) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
372 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
373 self.parent.step_in() |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
374 |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
375 def click_kill(self): |
|
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
376 self.parent.kill() |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
377 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
378 def click_browse(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
379 self.parent.browse(self.cur_modname) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
380 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
381 def click_edit(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
382 lino = self.cur_line |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
383 if not lino: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
384 lino = 1 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
385 if self.cur_source: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
386 self.parent.edit(self.cur_source, lino) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
387 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
388 class ModuleBrowser: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
389 """Base code for a module-browser""" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
390 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
391 def mi_open(self, module): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
392 """Setup initial data structures""" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
393 self.cur_module = module |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
394 self.cur_source = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
395 self.cur_line = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
396 self.cont_modules = [] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
397 self.value_windows = [] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
398 self.setup() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
399 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
400 # create_items(self) should create self.modules, self.vars and self.source |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
401 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
402 def setup(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
403 """Fill the various widgets with values""" |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
404 self.parent.SetWatch() |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
405 modnames = getmodulenames() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
406 if not self.cur_module in modnames: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
407 self.cur_module = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
408 if modnames <> self.cont_modules: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
409 self.cont_modules = modnames |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
410 self.setmodulenames() |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
411 if self.cur_module: |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
412 self.module_select(self.cont_modules.index(self.cur_module)) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
413 else: |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
414 self.module_select(None) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
415 self.setup_module() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
416 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
417 def setup_module(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
418 """Setup module-dependent widget data""" |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
419 self.parent.SetWatch() |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
420 if not self.cur_module: |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
421 self.cont_varnames = [] |
|
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
422 self.cont_varvalues = [] |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
423 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
424 self.cont_varnames, self.cont_varvalues = getmodulevars(self.cur_module) |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
425 self.setvars() |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
426 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
427 msg = "" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
428 if not self.cur_module: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
429 self.cur_source = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
430 msg = "No module selected" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
431 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
432 m = sys.modules[self.cur_module] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
433 try: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
434 self.cur_source = m.__file__ |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
435 except AttributeError: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
436 self.cur_source = None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
437 msg = "Not a python module" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
438 self.cur_lineno = 0 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
439 self.setsource(msg) |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
440 self.source_select(self.cur_line) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
441 self.breaks_changed(self.cur_source) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
442 |
|
4336
4dbfd4dfe281
- Simplified inheritance structure (still not good enough)
Jack Jansen <jack.jansen@cwi.nl>
parents:
4333
diff
changeset
|
443 self.parent.SetCursor() |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
444 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
445 # setsource(msg) should display cur_source+content, or msg if None |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
446 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
447 def update_views(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
448 self.setup_module() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
449 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
450 def click_module(self, module, *dummy): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
451 if not module or module == self.cur_module: return |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
452 self.focus(module) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
453 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
454 def focus(self, module): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
455 self.cur_module = module |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
456 self.setup() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
457 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
458 def click_var(self, var, *dummy): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
459 if not var: return |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
460 m = sys.modules[self.cur_module] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
461 dict = m.__dict__ |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
462 self.parent.browse_var(dict[var]) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
463 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
464 def click_source(self, lineno, inborder): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
465 if not inborder: |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
466 self.source_select(lineno) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
467 self.cur_lineno = lineno |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
468 if lineno == None or not self.cur_source or not inborder: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
469 return |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
470 if self.parent.dbg.get_break(self.cur_source, lineno): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
471 self.parent.dbg.clear_break(self.cur_source, lineno) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
472 else: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
473 self.parent.dbg.set_break(self.cur_source, lineno) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
474 self.parent.breaks_changed(self.cur_source) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
475 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
476 def breaks_changed(self, filename): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
477 if filename == self.cur_source: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
478 list = self.parent.dbg.get_file_breaks(filename) |
|
4387
2e272bf5a43e
Prepared for Tk windowing implementation
Jack Jansen <jack.jansen@cwi.nl>
parents:
4336
diff
changeset
|
479 self.source_setbreaks(list) |
|
4331
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
480 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
481 def click_edit(self): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
482 lino = self.cur_lineno |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
483 if not lino: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
484 lino = 1 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
485 if self.cur_source: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
486 self.parent.edit(self.cur_source, lino) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
487 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
488 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
489 def getmodulenames(): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
490 """Return a list of all current modules, sorted""" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
491 list = sys.modules.keys()[:] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
492 list.sort() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
493 return list |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
494 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
495 def getmodulevars(name): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
496 """For given module return lists with names and values""" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
497 m = sys.modules[name] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
498 try: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
499 dict = m.__dict__ |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
500 except AttributeError: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
501 dict = {} |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
502 return getvarsfromdict(dict) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
503 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
504 def getvarsfromdict(dict, show_complex=1, show_system=1): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
505 allnames = dict.keys()[:] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
506 allnames.sort() |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
507 names = [] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
508 for n in allnames: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
509 if not show_complex: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
510 if not type(dict[n]) in SIMPLE_TYPES: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
511 continue |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
512 if not show_system: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
513 if n[:2] == '__' and n[-2:] == '__': |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
514 continue |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
515 names.append(n) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
516 values = [] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
517 for n in names: |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
518 v = pretty(dict[n]) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
519 values.append(v) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
520 return names, values |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
521 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
522 def pretty(var): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
523 t = type(var) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
524 if t == types.FunctionType: return '<function>' |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
525 if t == types.ClassType: return '<class>' |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
526 return `var` |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
527 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
528 def getframelineno(frame): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
529 """Given a frame return the line number""" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
530 return getcodelineno(frame.f_code) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
531 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
532 def getfunclineno(func): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
533 """Given a function return the line number""" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
534 return getcodelineno(func.func_code) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
535 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
536 def getcodelineno(cobj): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
537 """Given a code object return the line number""" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
538 code = cobj.co_code |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
539 lineno = -1 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
540 if ord(code[0]) == 127: # SET_LINENO instruction |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
541 lineno = ord(code[1]) | (ord(code[2]) << 8) |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
542 return lineno |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
543 |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
544 def getframemodname(frame): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
545 """Given a frame return the module name""" |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
546 globals = frame.f_globals |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
547 if globals.has_key('__name__'): |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
548 return globals['__name__'] |
|
c2eb38b674f3
The Window Independent Tracer (which will probably move elsewhere once
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
549 return None |
