1313 types .StringType
1414)
1515
16+ # XXXX Mac-specific
17+ ICON_NORMAL = 512
18+ ICON_RETURN = 515
19+ ICON_CALL = 516
20+ ICON_ZERO = 517
21+ ICON_DEAD = 518
22+
1623def Initialize ():
1724 pass
1825
@@ -23,20 +30,23 @@ def __init__(self, parent):
2330 self .parent = parent
2431 self .exception_info = (None , None )
2532 self .reason = 'Not running'
33+ self .icon = ICON_NORMAL
2634 self .reset ()
2735
2836 def reset (self ):
2937 bdb .Bdb .reset (self )
3038 self .forget ()
3139
3240 def forget (self ):
41+ print 'FORGET'
3342 self .lineno = None
3443 self .stack = []
3544 self .curindex = 0
3645 self .curframe = None
3746
3847 def setup (self , f , t ):
3948 self .forget ()
49+ print 'SETUP' , f , t
4050 self .stack , self .curindex = self .get_stack (f , t )
4151 self .curframe = self .stack [self .curindex ][0 ]
4252
@@ -46,19 +56,23 @@ def interaction(self, frame, traceback):
4656 self .exception_info = (None , None )
4757
4858 def user_call (self , frame , argument_list ):
49- self .reason = 'Calling function'
59+ self .reason = 'Calling'
60+ self .icon = ICON_CALL
5061 self .interaction (frame , None )
5162
5263 def user_line (self , frame ):
5364 self .reason = 'Stopped'
65+ self .icon = ICON_NORMAL
5466 self .interaction (frame , None )
5567
5668 def user_return (self , frame , return_value ):
57- self .reason = 'Returning from function'
69+ self .reason = 'Returning'
70+ self .icon = ICON_RETURN
5871 self .interaction (frame , None )
5972
6073 def user_exception (self , frame , (exc_type , exc_value , exc_traceback )):
6174 self .reason = 'Exception occurred'
75+ self .icon = ICON_DEAD
6276 self .exception_info = (exc_type , exc_value )
6377 self .interaction (frame , exc_traceback )
6478
@@ -71,6 +85,7 @@ def getexception(self):
7185 return tp , value
7286
7387 def getstacktrace (self ):
88+ print 'DBG GETSTACKTRACE' , self .stack
7489 names , locations = [], []
7590 for frame , lineno in self .stack :
7691 name = frame .f_code .co_name
@@ -89,6 +104,7 @@ def getstacktrace(self):
89104 if not modname : modname = "<unknown>"
90105
91106 locations .append ("%s:%d" % (modname , lineno ))
107+ print 'DBG RETURNS' , names , locations
92108 return names , locations
93109
94110 def getframe (self , number ):
@@ -128,11 +144,13 @@ def mi_init(self, run_args, pm_args):
128144 self .run_dialog .open ()
129145 self .module_dialog = None
130146 self .initial_cmd = None
147+ self .cur_string_name = None
131148 if pm_args :
132149 while pm_args .tb_next <> None :
133150 pm_args = pm_args .tb_next
134151 self .dbg .setup (pm_args .tb_frame , pm_args )
135152 self .run_dialog .setsession_pm ()
153+ self .run_dialog .update_views ()
136154 elif run_args :
137155 self .run_dialog .setsession_run ()
138156 self .initial_cmd = run_args
@@ -164,6 +182,12 @@ def quit_bdb(self):
164182
165183 def run (self ):
166184 cmd = AskString ('Statement to execute:' )
185+ self .cur_string_name = '<string: "%s">' % cmd
186+ try :
187+ cmd = compile (cmd , self .cur_string_name , 'exec' )
188+ except SyntaxError , arg :
189+ ShowMessage ('Syntax error: %s' % `arg` )
190+ return
167191 self .initial_cmd = (cmd , None , None )
168192 self .run_dialog .setsession_run ()
169193 self .exit_mainloop ()
@@ -247,12 +271,19 @@ def setup_frame(self):
247271 self .cur_line = optnextline
248272 if self .cur_source == '<string>' :
249273 self .cur_source = None
250- msg = "Executing from <string>"
274+ msg = "Executing from unknown <string>"
275+ elif type (self .cur_source ) == types .StringType and \
276+ self .cur_source [:8 ] == '<string:' :
277+ msg = "Executing from " + self .cur_source
278+ self .cur_source = None
251279 print 'SOURCE' , self .cur_source
252280 print 'LINE' , self .cur_line
253281
254282 self .setsource (msg )
255- self .source .setcurline (self .cur_line )
283+ if not self .cur_line :
284+ self .source .setcurline (1 , ICON_ZERO )
285+ else :
286+ self .source .setcurline (self .cur_line , self .parent .dbg .icon )
256287 self .breaks_changed (self .cur_source )
257288
258289
0 commit comments