Ejemplo n.º 1
0
        def run():
            state = self.debugState
            wx.PostEvent(self,
                         UpdateGUIEvent(lambda: self.sidePanel.update(state)))

            lines = self.textPanel.textBox.GetValue().split('\n')

            while not self.stopFlag:
                node: nodes.InstructionNode = state.getInstructionFromMem(
                    state.getReg("PC"))
                state, success = interpreter.executeInstruction(
                    node, state, self.fileName, lines)
                if not success:
                    break

            # program has exited
            wx.PostEvent(
                self,
                UpdateGUIEvent(
                    lambda: [self.sidePanel.update(state),
                             self.resetTools()]))

            self.runThread = None
            self.debugState = None
            self.stopFlag = False

            self.textPanel.textBox.MarkerDeleteAll(MARK_CURRENT_LINE)
            self.textPanel.textBox.SetEditable(True)
Ejemplo n.º 2
0
    def OnStep(self, _):
        lines = self.textPanel.textBox.GetValue().split('\n')

        node: nodes.InstructionNode = self.debugState.getInstructionFromMem(
            self.debugState.getReg("PC"))
        state, success = interpreter.executeInstruction(
            node, self.debugState, self.fileName, lines)

        self.sidePanel.update(state)

        if not success:
            # program has exited
            self.debugState = None
            self.runThread = None
            self.stopFlag = False

            self.resetTools()

            self.textPanel.textBox.MarkerDeleteAll(MARK_CURRENT_LINE)
            self.textPanel.textBox.SetEditable(True)
        else:
            self.debugState = state
            nextNode: nodes.InstructionNode = self.debugState.getInstructionFromMem(
                self.debugState.getReg("PC"))
            if not isinstance(nextNode, nodes.SystemCall):
                self.textPanel.markLine(nextNode.line)
Ejemplo n.º 3
0
        def run():
            self.textPanel.textBox.SetEditable(False)

            file_contents: str = self.textPanel.textBox.GetValue()
            state = interpreter.parse(self.fileName, file_contents, stackSize,
                                      startLabel)
            if state is not None:
                self.textPanel.setAddresses(state)
                wx.PostEvent(
                    self, UpdateGUIEvent(lambda: self.sidePanel.update(state)))

                lines = file_contents.split('\n')

                while not self.stopFlag:
                    node: nodes.InstructionNode = state.getInstructionFromMem(
                        state.getReg("PC"))
                    if node.line in breakpoints:
                        # breakpoint found - save state and enable the single-step and resume tools
                        self.debugState = state
                        self.runThread = None

                        wx.PostEvent(
                            self,
                            UpdateGUIEvent(lambda: [
                                self.sidePanel.update(state),
                                self.textPanel.markLine(node.line),
                                self.enableDebugTools(True)
                            ]))

                        return
                    state, success = interpreter.executeInstruction(
                        node, state, self.fileName, lines)
                    if not success:
                        break

                # program has exited
                wx.PostEvent(
                    self,
                    UpdateGUIEvent(
                        lambda:
                        [self.sidePanel.update(state),
                         self.resetTools()]))
            else:
                wx.PostEvent(self, UpdateGUIEvent(lambda: self.resetTools()))

            self.runThread = None
            self.stopFlag = False

            self.textPanel.textBox.MarkerDeleteAll(MARK_CURRENT_LINE)
            self.textPanel.textBox.SetEditable(True)
Ejemplo n.º 4
0
        def run():
            firstRun = True  # make sure to not block on the same breakpoint right away

            state = self.debugState
            wx.PostEvent(self,
                         UpdateGUIEvent(lambda: self.sidePanel.update(state)))

            lines = self.textPanel.textBox.GetValue().split('\n')

            while not self.stopFlag:
                node: nodes.InstructionNode = state.getInstructionFromMem(
                    state.getReg("PC"))
                if node.line in breakpoints and not firstRun:
                    # breakpoint found - save state and enable the single-step and resume tools
                    self.debugState = state
                    self.runThread = None

                    wx.PostEvent(
                        self,
                        UpdateGUIEvent(lambda: [
                            self.sidePanel.update(state),
                            self.textPanel.markLine(node.line),
                            self.enableDebugTools(True)
                        ]))

                    return
                state, success = interpreter.executeInstruction(
                    node, state, self.fileName, lines)
                firstRun = False
                if not success:
                    break

            # program has exited
            wx.PostEvent(
                self,
                UpdateGUIEvent(
                    lambda: [self.sidePanel.update(state),
                             self.resetTools()]))

            self.runThread = None
            self.debugState = None
            self.stopFlag = False

            self.textPanel.textBox.MarkerDeleteAll(MARK_CURRENT_LINE)
            self.textPanel.textBox.SetEditable(True)
Ejemplo n.º 5
0
        def run():
            self.textPanel.textBox.SetEditable(False)

            file_contents: str = self.textPanel.textBox.GetValue()
            state = interpreter.parse(self.fileName, file_contents, stackSize,
                                      startLabel)

            if state is not None:
                self.textPanel.setAddresses(state)
                wx.PostEvent(
                    self, UpdateGUIEvent(lambda: self.sidePanel.update(state)))

                lines = file_contents.split('\n')

                while True:
                    if self.stopFlag:
                        break
                    state, success = interpreter.executeInstruction(
                        state.getInstructionFromMem(state.getReg("PC")), state,
                        self.fileName, lines)
                    if not success:
                        break

                # program has exited
                wx.PostEvent(
                    self,
                    UpdateGUIEvent(
                        lambda:
                        [self.sidePanel.update(state),
                         self.resetTools()]))
            else:
                wx.PostEvent(self, UpdateGUIEvent(lambda: self.resetTools()))

            self.runThread = None
            self.stopFlag = False

            self.textPanel.textBox.MarkerDeleteAll(MARK_CURRENT_LINE)
            self.textPanel.textBox.SetEditable(True)