From dd825e85c35ef8b01272e2b7fe3ab482f3688da9 Mon Sep 17 00:00:00 2001 From: gambas Date: Sat, 10 Mar 2018 13:28:57 +0100 Subject: [PATCH] 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. --- app/src/gambas3/.src/Debug/Design.module | 63 +++++++++++++++------ app/src/gambas3/.src/Debug/FDebugInfo.class | 4 +- app/src/gambas3/.src/Debug/FOutput.class | 15 ++++- app/src/gambas3/.src/Debug/FOutput.form | 7 +++ 4 files changed, 70 insertions(+), 19 deletions(-) diff --git a/app/src/gambas3/.src/Debug/Design.module b/app/src/gambas3/.src/Debug/Design.module index 03853d924..a72cffa32 100644 --- a/app/src/gambas3/.src/Debug/Design.module +++ b/app/src/gambas3/.src/Debug/Design.module @@ -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 + diff --git a/app/src/gambas3/.src/Debug/FDebugInfo.class b/app/src/gambas3/.src/Debug/FDebugInfo.class index a51a588fa..7b1e1a1be 100644 --- a/app/src/gambas3/.src/Debug/FDebugInfo.class +++ b/app/src/gambas3/.src/Debug/FDebugInfo.class @@ -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 diff --git a/app/src/gambas3/.src/Debug/FOutput.class b/app/src/gambas3/.src/Debug/FOutput.class index 010eecad2..84f18a91d 100644 --- a/app/src/gambas3/.src/Debug/FOutput.class +++ b/app/src/gambas3/.src/Debug/FOutput.class @@ -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 diff --git a/app/src/gambas3/.src/Debug/FOutput.form b/app/src/gambas3/.src/Debug/FOutput.form index c9bc812b1..5ac6a7754 100644 --- a/app/src/gambas3/.src/Debug/FOutput.form +++ b/app/src/gambas3/.src/Debug/FOutput.form @@ -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")