Keep fixing breakpoint management, and try to be clever about which panel to show during debugging.

[DEVELOPMENT ENVIRONMENT]
* BUG: Keep fixing breakpoint management.
* NEW: Automatically show the console while the program is running, and the debugging tab when the program is stopped.
* NEW: Add a new button to the console output that suspends the terminal.
This commit is contained in:
gambas 2018-03-10 13:28:57 +01:00
parent 53cbe2370c
commit dd825e85c3
4 changed files with 70 additions and 19 deletions

View file

@ -45,17 +45,22 @@ Private $hPipeError As File
Private $hBrowser As Process
Private $iProcessId As Integer
Private $hTimerDebugPanel As Timer
Public Sub Init()
$sFifo = Debug.Begin()
SetState(STATE_STOP)
$hTimerDebugPanel = New Timer As "TimerDebugPanel"
$hTimerDebugPanel.Delay = 50
End
Public Sub Exit()
$hTimerDebugPanel = Null
Debug.End
End
@ -81,30 +86,46 @@ End
Private Sub SetState(iState As Integer)
Dim bDebug As Boolean
'Dim bDebug As Boolean
Dim bEnable As Boolean
'PRINT "SetState:"; iState
bDebug = $iState <> STATE_STOP And $iState <> STATE_STARTING
'bDebug = $iState <> STATE_STOP And $iState <> STATE_STARTING
$iState = iState
Action["pause"].Enabled = $iState = STATE_RUNNING
bEnable = $iState <> STATE_RUNNING And $iState <> STATE_STARTING
Action["pause"].Enabled = iState = STATE_RUNNING
bEnable = iState <> STATE_RUNNING And iState <> STATE_STARTING
Action["forward"].Enabled = bEnable
Action["step"].Enabled = bEnable
Action["return"].Enabled = bEnable And $iState <> STATE_STOP
Action["return"].Enabled = bEnable And iState <> STATE_STOP
Action["start"].Enabled = bEnable
Action["stop"].Enabled = $iState <> STATE_STOP
Action["stop"].Enabled = iState <> STATE_STOP
'btnInfo.Enabled = btnStop.Enabled
If iState = $iState Then Return
$iState = iState
FOutput.OnProjectDebugState
$hTimerDebugPanel.Restart
End
Public Sub TimerDebugPanel_Timer()
If $iState = STATE_RUNNING Then
FDebugInfo.ShowConsole
Else
FDebugInfo.ShowDebugging
Endif
$hTimerDebugPanel.Stop
End
' PRIVATE SUB HideForm(hForm AS Form)
'
@ -483,6 +504,8 @@ Private Sub AfterStop()
FMain.ActivateCurrentWindow
$hTimerDebugPanel.Stop
'IF Project.ActiveForm THEN
' TRY Project.ActiveForm.Show
'ENDIF
@ -651,17 +674,15 @@ Public Sub RunUntil(hForm As FEditor, iLine As Integer)
bOn = Not .[iLine].Breakpoint
End With
Inc iLine
If bOn Then
'PRINT "RunUntil "; sClass; "."; iLine
sBreak = sClass & "." & CStr(iLine)
If $iState <> STATE_DEBUG Then
$sAddBreakpoint = "+" & sBreak
$sAddBreakpoint = MakeBreakpoint(sBreak, True)
Else
WriteCommand("+" & sBreak)
WriteCommand(MakeBreakpoint(sBreak, True))
Endif
$sRemoveBreakpoint = "-" & sBreak
$sRemoveBreakpoint = MakeBreakpoint(sBreak, False)
Endif
Run
@ -773,6 +794,15 @@ End
'
' END
Private Sub MakeBreakpoint(sBreakpoint As String, bOn As Boolean) As String
Dim aBreak As String[]
aBreak = Split(sBreakpoint, ".")
Return If(bOn, "+", "-") & aBreak[0] & "." & CStr(CInt(aBreak[1]) + 1)
End
Private Sub Start(sCmd As String)
@ -826,7 +856,7 @@ Private Sub Start(sCmd As String)
For Each sBreakpoint In $aBreakpoint
If $cDisabledBreakpoint.Exist(sBreakpoint) Then Continue
$sCmdStart &= "+" & sBreakpoint & "\n"
$sCmdStart &= MakeBreakpoint(sBreakpoint, True) & "\n"
Next
If $sAddBreakpoint Then
@ -1269,10 +1299,10 @@ Public Sub SetBreakpoint(sBreakpoint As String, bOn As Boolean, Optional bDisabl
If bOn And If Not bDisabled Then
'Debug "+" & sClass & "." & CStr(iLine);; System.Backtrace.Join(" ")
WriteCommand("+" & aBreak[0] & "." & aBreak[1])
WriteCommand(MakeBreakpoint(sBreakpoint, True))
Else
'Debug "-" & sClass & "." & CStr(iLine);; System.Backtrace.Join(" ")
WriteCommand("-" & aBreak[0] & "." & aBreak[1])
WriteCommand(MakeBreakpoint(sBreakpoint, False))
Endif
End
@ -1409,3 +1439,4 @@ Public Sub SetBalloon(hCtrl As Control, Optional X As Integer = -1, Y As Integer
BalloonY = Y
End

View file

@ -35,7 +35,7 @@ Public Sub _new()
End With
With gvwBreakpoint
.AddColumn("", DS * 3)
.AddColumn(" ", DS * 3)
.AddColumn(("Class"))
.AddColumn(("Line"))
'.AddColumn(("Function"))
@ -1741,7 +1741,7 @@ Public Sub OnProjectDebug()
$sLastLocal = ""
$sLastObject = ""
FDebugButton.SelectButton(TAB_DEBUG)
FDebugButton.SelectButton(TAB_CONSOLE)
End

View file

@ -45,6 +45,7 @@ End
Public Sub Clear()
trmOutput.Clear
btnSuspend.Value = False
txtEnter.Clear
$iHistory = $aHistory.Count
SetFocus
@ -188,7 +189,13 @@ Public Sub OnProjectDebugState()
txtEnter.ReadOnly = Design.IsRunning()
If txtEnter.HasFocus Then trmOutput.SetFocus
If Design.IsStop() Then trmOutput.Reset()
If Design.IsStop() Then
trmOutput.Reset(True)
btnSuspend.Value = False
btnSuspend.Hide
Else
btnSuspend.Show
Endif
End
@ -486,3 +493,9 @@ Public Sub GetTerminal() As TerminalView
Return trmOutput
End
Public Sub btnSuspend_Click()
trmOutput.Suspended = btnSuspend.Value
End

View file

@ -46,6 +46,13 @@
ToolTip = ("Clear console")
Picture = Picture["icon:/small/clear"]
}
{ btnSuspend ToolButton
MoveScaled(12,0,4,4)
Visible = False
ToolTip = ("Suspend terminal")
Picture = Picture["icon:/small/lock"]
Toggle = True
}
{ btnCopy ToolButton
MoveScaled(16,0,4,4)
ToolTip = ("Copy")