Browse Source

step_into command, stack now displayed with context numbers

Simon Van Mierlo 9 years ago
parent
commit
bb4fa74903

+ 10 - 0
kernel/mvk_server/classes/mvkcontroller.xml

@@ -203,6 +203,16 @@
                         </raise>
                     </transition>
                     
+                    <transition cond="self.input_queue[0][1] == 'step_into'" target="../wait">
+                        <script>
+                            source, op, args, username = self.input_queue.pop(0)
+                        </script>
+                        <raise event="step_into" scope="narrow" target="self.user_statecharts[username]">
+                            <parameter expr="source"/>
+                            <parameter expr="args"/>
+                        </raise>
+                    </transition>
+                    
                     <transition cond="self.input_queue[0][1] == 'attach_debugger'" target="../wait">
                         <script>
                             source, op, args, username = self.input_queue.pop(0)

+ 56 - 6
kernel/mvk_server/classes/user_statechart.xml

@@ -25,6 +25,7 @@
             
             self.big_step_info = None
             self.line_step_info = None
+            self.step_into_info = None
             ]]>
         </body>
     </constructor>
@@ -218,12 +219,21 @@
                             </transition>
                         </state>
                         <state id="checking_line_step">
-                            <transition target="../checking_big_step" cond="self.line_step_info and len(self.debug_info) == self.line_step_info['stack_len'] and (self.curr_file != self.line_step_info['file'] or self.curr_line != self.line_step_info['line'])">
+                            <transition target="../checking_step_into" cond="self.line_step_info and len(self.debug_info) == self.line_step_info['stack_len'] and (self.curr_file != self.line_step_info['file'] or self.curr_line != self.line_step_info['line'])">
                                 <raise event="line_step_done" />
                             </transition>
-                            <transition target="../checking_big_step" cond="not self.line_step_info or len(self.debug_info) > self.line_step_info['stack_len'] or (self.curr_file == self.line_step_info['file'] and self.curr_line == self.line_step_info['line'])" />
+                            <transition target="../checking_step_into" cond="not self.line_step_info or len(self.debug_info) > self.line_step_info['stack_len'] or (self.curr_file == self.line_step_info['file'] and self.curr_line == self.line_step_info['line'])" />
+                        </state>
+                        <state id="checking_step_into">
+                            <transition target="../checking_big_step" cond="self.step_into_info and (self.curr_file != self.step_into_info['file'] or self.curr_line != self.step_into_info['line'])">
+                                <raise event="step_into_done" />
+                            </transition>
+                            <transition target="../checking_big_step" cond="not self.step_into_info or (self.curr_file == self.step_into_info['file'] and self.curr_line == self.step_into_info['line'])" />
                         </state>
                         <state id="checking_big_step">
+                            <transition target="../checking_small_step" />
+                        </state>
+                        <state id="checking_small_step">
                             <transition target="../../check_termination" after="self.sccd_yield()" />
                         </state>
                         <state id="timeout">
@@ -294,6 +304,13 @@
                             <parameter expr="json.dumps({'user': self.username, 'result': 'not allowed'})"/>
                         </raise>
                     </transition>
+                    <transition target="execution_state_history" event="step_into">
+                        <parameter name="source"/>
+                        <parameter name="args"/>
+                        <raise event="HTTP_input" scope="narrow" target="'parent/to_mvi/' + source">
+                            <parameter expr="json.dumps({'user': self.username, 'result': 'not allowed'})"/>
+                        </raise>
+                    </transition>
                     <history id="execution_state_history" type="deep" />
                     <state id="running" initial="continuous">
                         <state id="continuous">
@@ -302,21 +319,38 @@
                                 <parameter name="source"/>
                                 <parameter name="args"/>
                                 <raise event="HTTP_input" scope="narrow" target="'parent/to_mvi/' + source">
-                                    <parameter expr="json.dumps({'user': self.username, 'result': 'success', 'state': 'paused', 'info': self.mvk.debug_info[self.username]})"/>
+                                    <parameter expr="json.dumps({'user': self.username, 'result': 'success', 'state': 'paused', 'info': self.debug_info})"/>
                                 </raise>
                             </transition>
                         </state>
                         <state id="big_step">
                             <transition event="big_step_done" target="../../paused">
                                 <raise event="HTTP_input" scope="narrow" target="'parent/to_mvi/' + self.big_step_source">
-                                    <parameter expr="json.dumps({'user': self.username, 'result': 'success', 'state': 'paused', 'info': self.mvk.debug_info[self.username]})"/>
+                                    <parameter expr="json.dumps({'user': self.username, 'result': 'success', 'state': 'paused', 'info': self.debug_info})"/>
+                                </raise>
+                            </transition>
+                        </state>
+                        <state id="small_step">
+                            <transition event="small_step_done" target="../../paused">
+                                <raise event="HTTP_input" scope="narrow" target="'parent/to_mvi/' + self.small_step_source">
+                                    <parameter expr="json.dumps({'user': self.username, 'result': 'success', 'state': 'paused', 'info': self.debug_info})"/>
+                                </raise>
+                            </transition>
+                        </state>
+                        <state id="step_into">
+                            <transition event="step_into_done" target="../../paused">
+                                <raise event="HTTP_input" scope="narrow" target="'parent/to_mvi/' + self.step_into_info['source']">
+                                    <parameter expr="json.dumps({'user': self.username, 'result': 'success', 'state': 'paused', 'info': self.debug_info})"/>
                                 </raise>
+                                <script>
+                                    self.step_into_info = None
+                                </script>
                             </transition>
                         </state>
                         <state id="line_step">
                             <transition event="line_step_done" target="../../paused">
                                 <raise event="HTTP_input" scope="narrow" target="'parent/to_mvi/' + self.line_step_info['source']">
-                                    <parameter expr="json.dumps({'user': self.username, 'result': 'success', 'state': 'paused', 'info': self.mvk.debug_info[self.username]})"/>
+                                    <parameter expr="json.dumps({'user': self.username, 'result': 'success', 'state': 'paused', 'info': self.debug_info})"/>
                                 </raise>
                                 <script>
                                     self.line_step_info = None
@@ -339,6 +373,23 @@
                                 self.big_step_source = source
                             </script>
                         </transition>
+                        <transition target="../running/small_step" event="small_step">
+                            <parameter name="source"/>
+                            <parameter name="args"/>
+                            <script>
+                                self.small_step_source = source
+                            </script>
+                        </transition>
+                        <transition target="../running/step_into" event="step_into">
+                            <parameter name="source"/>
+                            <parameter name="args"/>
+                            <script>
+                                self.step_into_info = {'source': source,
+                                                       'stack_len': len(self.debug_info),
+                                                       'file': self.curr_file,
+                                                       'line': self.curr_line}
+                            </script>
+                        </transition>
                         <transition target="../running/line_step" event="line_step">
                             <parameter name="source"/>
                             <parameter name="args"/>
@@ -347,7 +398,6 @@
                                                        'stack_len': len(self.debug_info),
                                                        'file': self.curr_file,
                                                        'line': self.curr_line}
-                                print self.line_step_info
                             </script>
                         </transition>
                     </state>

+ 1 - 1
scripts/debug_prompt.py

@@ -46,4 +46,4 @@ while 1:
     print "RES: %s" % reply['result']
     print "STATE: %s" % reply['state']
     if 'info' in reply:
-        print "STACK:\n%s" % '\n'.join(list(reversed(reply['info'])))
+        print "STACK:\n\t%s" % '\n\t'.join(["%s. %s" % item for item in reversed(list(enumerate(reply['info'])))])