Add a debugger menu option to toggle debugging inside components. Allow profiling into components.

[DEVELOPMENT ENVIRONMENT]
* NEW: Debugger: Debugger options are now stored in the project local settings, and not in the project configuration anymore.
* NEW: Debugger: Add a debugger menu option to toggle debugging inside components.
* NEW: Debugger: Disable debugger menu entries that are not relevant during debugging.
* NEW: Profiler: Profiling inside components is possible now.
* OPT: Project tree: Tree refresh is a bit faster now.
This commit is contained in:
gambas 2022-02-05 00:19:20 +01:00
parent d2eebaf136
commit f62e791f74
10 changed files with 7569 additions and 7295 deletions

File diff suppressed because it is too large Load diff

View file

@ -77,7 +77,7 @@ Private Sub Synchronize()
End
Public Sub GetCommands() As String
Public Sub GetCommands() As String[]
Dim aResult As New String[]
Dim aBreakpoints As Integer[]
@ -90,12 +90,12 @@ Public Sub GetCommands() As String
sClass = $cBreakpoints.Key
For Each iLine In aBreakpoints
aResult.Add("+" & sClass & "." & CStr(iLine + 1) & "\n")
aResult.Add("+" & sClass & "." & CStr(iLine + 1))
Next
Next
Return aResult.Join("")
Return aResult
End

View file

@ -2,6 +2,14 @@
Private Const DEBUG_REMOTE As Boolean = False
Public UseTerminal As Boolean
Public RedirectStderr As Boolean
Public UseHttpServer As Boolean
Public Profiling As Boolean
Public DebugInside As Boolean
Private $iProfileIndex As Integer
Public Startup As String
Public ProcessId As Integer
@ -26,8 +34,7 @@ Private $iPosLine As Integer
Private $sError As String
Private $bStart As Boolean
Private $sCmdStart As String
'PRIVATE $sCmdStartRun AS String
Private $aCmdStart As String[]
Private $sAddBreakpoint As String
Private $sRemoveBreakpoint As String
@ -550,7 +557,7 @@ Public Sub Process_Kill()
$hProcess = Null
If Project.Profiling Then
If Profiling Then
FProfile.Open($sProfilePath)
Endif
@ -1076,23 +1083,8 @@ Private Sub Start(sCmd As String)
'PRINT "EXEC "; "gbx -gs " & File.Dir(Project.Path) & " -- " & Project.Arguments
ProcessId = 0
$sCmdStart = ""
ReadDebugSettings()
$sCmdStart &= Breakpoints.GetCommands()
If $sAddBreakpoint Then
$sCmdStart &= $sAddBreakpoint & "\n"
$sAddBreakpoint = ""
Endif
$sCmdStart &= FDebugInfo.GetWatches()
'If Project.BreakOnError Then $sCmdStart &= "b+\n"
$sCmdStart &= sCmd
'$sCmdStartRun = sCmd
MakeInitialCommands(sCmd)
$bStart = True
Project.Running = True
@ -1134,7 +1126,7 @@ Private Sub Start(sCmd As String)
Else
If Project.Profiling Then FProfile.CleanProfileFiles
If Profiling Then FProfile.CleanProfileFiles
If $bRemote Then
aExec = ["gbr" & System.Version]
@ -1142,7 +1134,10 @@ Private Sub Start(sCmd As String)
aExec = [System.Path &/ "bin/gbx" & System.Version]
Endif
aExec.Insert(["-g", "-f", sFifo])
aExec.Add("-g")
aExec.Add("-f")
aExec.Add(sFifo)
If Startup Then
aExec.Add("-s")
@ -1150,7 +1145,7 @@ Private Sub Start(sCmd As String)
Endif
If Project.CanUseHttpServer() Then
If Project.UseHttpServer Or If Project.Components.Exist("gb.httpd") Then
If UseHttpServer Or If Project.Components.Exist("gb.httpd") Then
aExec.Add("-H")
iPos = aEnv.Find("GB_HTTPD_PORT=*", gb.Like)
sPort = "8080"
@ -1163,12 +1158,12 @@ Private Sub Start(sCmd As String)
Endif
Endif
If Project.Profiling Then
If Profiling Then
aExec.Add("-p")
Inc Project.ProfileIndex
sFile = "." & CStr(Project.ProfileIndex) & ".prof"
Inc $iProfileIndex
sFile = "." & CStr($iProfileIndex) & ".prof"
If Project.ReadOnly Then
$sProfilePath = File.Dir(Temp$) &/ sFile
@ -1204,7 +1199,7 @@ Private Sub Start(sCmd As String)
Endif
If Project.UseTerminal Then
If UseTerminal Then
sTitle = Project.Name & " (" & ("Output terminal") & ")"
@ -1245,7 +1240,7 @@ Private Sub Start(sCmd As String)
Endif
If Project.RedirectStderr Then
If RedirectStderr Then
$sPipeError = Temp$()
aExec.Add("-r")
aExec.Add($sPipeError)
@ -1366,20 +1361,7 @@ Public Sub RunExtern()
ClearOutput
ProcessId = 0
$sCmdStart = ""
ReadDebugSettings()
$sCmdStart &= Breakpoints.GetCommands()
If $sAddBreakpoint Then
$sCmdStart &= $sAddBreakpoint & "\n"
$sAddBreakpoint = ""
Endif
$sCmdStart &= FDebugInfo.GetWatches()
$sCmdStart &= "g"
MakeInitialCommands("g")
$bExtern = True
$bStart = True
@ -1499,7 +1481,7 @@ Private Sub Signal()
If $bStart Then
If $bExtern Then FDebugInfo.StopWaitForRemote
'PRINT "START Debug.Write: "; $sCmdStart
WriteCommand($sCmdStart)
If $aCmdStart.Count Then WriteCommand($aCmdStart.Join("\n") & "\n")
$bStart = False
'Command("w", TRUE)
'Command($sCmdStartRun, FALSE, STATE_RUNNING)
@ -1598,20 +1580,47 @@ End
'
' END
Private Sub ReadSettings()
UseTerminal = Project.Config["/Debug/UseTerminal"]
RedirectStderr = Project.Config["/Debug/RedirectStderr"]
UseHttpServer = Project.Config["/Debug/UseHttpServer"]
Profiling = Project.Config["/Debug/Profiling"]
DebugInside = Project.Config["/Debug/DebugInside"]
End
Public Sub ReadDebugSettings()
ReadSettings
FDebugInfo.ReadWatchSettings()
FDebugExpr.ReadSettings()
End
Public Sub WriteSettings()
Project.Config["/Debug/UseTerminal"] = UseTerminal
Project.Config["/Debug/RedirectStderr"] = RedirectStderr
Project.Config["/Debug/UseHttpServer"] = UseHttpServer
Project.Config["/Debug/Profiling"] = Profiling
Project.Config["/Debug/DebugInside"] = DebugInside
End
Public Sub WriteDebugSettings()
WriteSettings
FDebugInfo.WriteWatchSettings()
FDebugExpr.WriteSettings()
End
Public Sub OnProjectChange()
ReadSettings
End
Public Sub SetBreakpoint(sClass As String, iLine As Integer, bOn As Boolean)
@ -1771,3 +1780,35 @@ Private Sub CreateDebuggerHelper() As String
Return $sRemoteDebuggerHelper
End
Public Sub SetDebugInside(bVal As Boolean)
DebugInside = bVal
WriteSettings
If Project.Running Then WriteCommand("og" & If(bVal, "+", "-"))
End
Private Sub MakeInitialCommands(sCmd As String)
$aCmdStart = New String[]
ReadDebugSettings()
If DebugInside Then $aCmdStart.Add("og+")
$aCmdStart.Insert(Breakpoints.GetCommands())
If $sAddBreakpoint Then
$aCmdStart.Add($sAddBreakpoint)
$sAddBreakpoint = ""
Endif
$aCmdStart.Insert(FDebugInfo.GetWatches())
'If Project.BreakOnError Then $aCmdStart.Add("o+")
$aCmdStart.Add(sCmd)
End

View file

@ -169,7 +169,7 @@ Public Sub UpdateProfile()
aProf = FProfile.FindAll()
panProfile.Children.Clear
If aProf.Count = 0 Then
panProfile.Hide
Return

View file

@ -1712,21 +1712,21 @@ Public Sub IsWatch(sExpr As String) As Boolean
End
Public Sub GetWatches() As String
Public Sub GetWatches() As String[]
Dim sCmd As String
Dim aCmd As New String[]
Dim sExpr As String
If cvwVariable.MoveTo("@") Then Return
If cvwVariable.MoveChild() Then Return
If cvwVariable.MoveTo("@") Then Return aCmd
If cvwVariable.MoveChild() Then Return aCmd
Repeat
sExpr = cvwVariable.Item.Text
sCmd &= "?W" & sExpr & "\t" & sExpr & "\n"
If $cTrack.Exist("@" & sExpr) Then sCmd &= "w" & $cTrack["@" & sExpr] & "\t" & sExpr & "\n"
aCmd.Add("?W" & sExpr & "\t" & sExpr)
If $cTrack.Exist("@" & sExpr) Then aCmd.Add("w" & $cTrack["@" & sExpr] & "\t" & sExpr)
Until cvwVariable.MoveNext()
Return sCmd
Return aCmd
End

View file

@ -36,7 +36,9 @@ Static Public Sub Open(sPath As String)
If Not Exist(sPath) Then Return
hProf = New FProfile
Project.SetMessage(("Loading profiling file..."))
hProf.Init(sPath)
Project.SetMessage(("OK"), True)
End
@ -396,14 +398,29 @@ Fast Public Sub Init(sPath As String)
iOldTime = iTime
Dec iLastLine
Try aLine[iLastLine] += iTime - iLastTime
If Not Error Then
Inc aCount[iLastLine]
Else
If iLastLine >= 0 Then Debug hCurrent.Name; "."; iLastLine + 1; " ("; aLine.Count; ")"
If iLastLine < 0 Then
hCurrent.FirstTime += iTime - iLastTime
Else
If iLastLine >= aLine.Count Then
aLine.Resize((iLastLine + 128) And Not 127)
aCount.Resize(aLine.Count)
Endif
aLine[iLastLine] += iTime - iLastTime
Inc aCount[iLastLine]
Endif
' If Not Error Then
' Else
' If iLastLine >= 0 Then Debug hCurrent.Name; "."; iLastLine + 1; " ("; aLine.Count; ")"
' hCurrent.FirstTime += iTime - iLastTime
' Endif
iLastLine = iLine
Next
@ -441,7 +458,7 @@ Fast Public Sub Init(sPath As String)
Catch
Dec Application.Busy
FMain.ShowErrorWith(Subst(("Unable to load profile file: &1"), File.Name(sPath)))
FMain.ShowErrorWith(Subst(("Unable to load profile file: &1"), File.Name(sPath)), "*")
End

View file

@ -1273,7 +1273,14 @@ Public Sub UpdateMenu()
Action[sAction].Enabled = bEnabled
Next
Action["run-with"].Enabled = bEnabled
For Each sAction In ["run-extern", "terminal", "redirect", "httpserver", "gui", "profile", "open-profile", "run-with", "run-remote"]
Action[sAction].Enabled = bEnabled
Next
mnuEnvDbDebug.Enabled = bEnabled
mnuEnvJitDebug.Enabled = bEnabled
mnuEnvNoJit.Enabled = bEnabled
mnuEnvReverse.Enabled = bEnabled
sText = If(Project.Running, ("Continue"), ("Run"))
mnuRun.Text = sText
@ -1415,10 +1422,11 @@ Public Sub OnProjectChange()
mnuFilterModified.Visible = VersionControl.Enabled
txtSearchProject.Clear
mnuUseTerminal.Value = Project.UseTerminal
mnuRedirectStderr.Value = Project.RedirectStderr
mnuUseHttpServer.Value = Project.UseHttpServer
mnuProfile.Value = Project.Profiling
mnuUseTerminal.Value = Design.UseTerminal
mnuRedirectStderr.Value = Design.RedirectStderr
mnuUseHttpServer.Value = Design.UseHttpServer
mnuProfile.Value = Design.Profiling
mnuDebugInside.Value = Design.DebugInside
OnRefreshComponents
@ -1620,20 +1628,23 @@ Public Sub Action_Activate((Key) As String) As Boolean
CPosition.MoveNext
Case "terminal"
Project.UseTerminal = Action["terminal"].Value
Project.WriteProject(True)
Design.UseTerminal = Action["terminal"].Value
Design.WriteSettings
Case "redirect"
Project.RedirectStderr = Action["redirect"].Value
Project.WriteProject(True)
Design.RedirectStderr = Action["redirect"].Value
Design.WriteSettings
Case "httpserver"
Project.UseHttpServer = Action["httpserver"].Value
Project.WriteProject(True)
Design.UseHttpServer = Action["httpserver"].Value
Design.WriteSettings
Case "profile"
Project.Profiling = Action["profile"].Value
Project.WriteProject(True)
Design.Profiling = Action["profile"].Value
Design.WriteSettings
Case "debug-inside"
Design.SetDebugInside(Action["debug-inside"].Value)
' Case "breakerr"
' Project.BreakOnError = Action["breakerr"].Value
@ -2294,7 +2305,7 @@ Public Sub ShowErrorWith(sTitle As String, Optional sMsg As String, Optional sKe
Dim sBacktrace As String
If Not sMsg Or If sMsg = "*" Then
If sMsg = "*" Then sBacktrace = Error.Backtrace.Join(" ")
If sMsg = "*" Then Try sBacktrace = Error.Backtrace.Join(" ")
sMsg = Tr(Error.Text)
If sMsg Not Ends "." Then sMsg &= "."
If sBacktrace Then sMsg &= "\n<font size=\"-1\"><tt>" & sBacktrace & "</tt></font>"

View file

@ -270,18 +270,6 @@
Text = ("Debug extern process") & "..."
Picture = Picture["icon:/small/connect"]
}
{ Menu49 Menu
}
{ Menu45 Menu
Action = "run-with"
Text = ("Program arguments") & "..."
Picture = Picture["icon:/small/text-list-order"]
}
{ mnuDebugRemote Menu
Action = "run-remote"
Text = ("Remote debugging") & "..."
Picture = Picture["icon:/small/network"]
}
{ Menu14 Menu
}
{ mnuPause Menu
@ -395,7 +383,7 @@
}
{ mnuProfile Menu
Action = "profile"
Text = Shortcut(("Activate profiling"), "g")
Text = ("Activate profiling")
Toggle = True
}
{ mnuOpenProfile Menu
@ -407,12 +395,29 @@
}
{ mnuClearBreakpoints Menu
Action = "clear-break"
Text = Shortcut(("Clear all breakpoints"), "a")
Text = ("Clear all breakpoints")
}
{ mnuClearDebugWindows Menu
Action = "close-all-debug"
Text = Shortcut(("Close all debug windows"), "d")
}
{ Menu49 Menu
}
{ mnuDebugInside Menu
Action = "debug-inside"
Text = ("Debug inside components")
Toggle = True
}
{ Menu45 Menu
Action = "run-with"
Text = ("Program arguments") & "..."
Picture = Picture["icon:/small/text-list-order"]
}
{ mnuDebugRemote Menu
Action = "run-remote"
Text = ("Remote debugging") & "..."
Picture = Picture["icon:/small/network"]
}
}
{ mnuView Menu
Action = "menu-view"
@ -1272,15 +1277,6 @@
Menu = "mnuVersionControl"
MenuOnly = True
}
{ btnRunWith ToolButton
MoveScaled(89,4,15,4)
Visible = False
ToolTip = ("Run with arguments")
Action = "run-with"
AutoResize = True
Text = ("Run with") & "..."
Picture = Picture["icon:/small/play"]
}
{ btnRunRemote ToolButton
MoveScaled(104,4,4,4)
Visible = False
@ -1630,6 +1626,10 @@
Shortcut = "Ctrl+X"
Picture = "icon:/small/cut"
}
{ Action debug-inside
Text = "Debug inside components"
Shortcut = ""
}
{ Action delete
Text = "Delete"
Shortcut = "Del"
@ -1870,9 +1870,9 @@
Picture = "icon:/small/play"
}
{ Action run-with
Text = "Run with"
Text = "Program arguments"
Shortcut = ""
Picture = "icon:/small/play"
Picture = "icon:/small/text-list-order"
}
{ Action save-project
Text = "Save project"
@ -1985,7 +1985,7 @@
{ Toolbars
{ Toolbar main
Text = ""
List = "new-project,open-project,save-project,save-project-as,project-property,refresh-project,option,shortcut,exec,translate,archive,install,project,property,control,console,find,help,compile,compile-all,test,start,pause,stop,step,forward,return,until,find-project,go-back,go-forward,browse-project,open-terminal,send-mail,publish,farm,gui,menu-file,menu-edit,menu-project,menu-debug,menu-view,menu-tool,menu-help,version-control,run-with,run-extern"
List = "new-project,open-project,save-project,save-project-as,project-property,refresh-project,option,shortcut,exec,translate,archive,install,project,property,control,console,find,help,compile,compile-all,test,start,pause,stop,step,forward,return,until,find-project,go-back,go-forward,browse-project,open-terminal,send-mail,publish,farm,gui,menu-file,menu-edit,menu-project,menu-debug,menu-view,menu-tool,menu-help,version-control,run-extern"
Default = "new-project,open-project,save-project,save-project-as,project-property,option,|,exec,translate,|,compile,compile-all,test,start,pause,stop,step,forward,return,until,-,find-project,go-back,go-forward,version-control"
}
}

View file

@ -105,11 +105,6 @@ Public DefaultLanguage As String
Public Type As Integer
Public Authors As String
Public VersionFile As Boolean
Public UseTerminal As Boolean
Public RedirectStderr As Boolean
Public UseHttpServer As Boolean
Public Profiling As Boolean
Public ProfileIndex As Integer
Public DoNotTranslate As String[]
Public CompressFiles As Boolean
Public CompressedFiles As String[]
@ -801,19 +796,20 @@ _INIT_AGAIN:
If Not bIsFake Then CRecentProject.Add(sDir)
If Not $bTesting
If Not $bTesting Then
If Not bIsFake Then
Design.OnProjectChange
Breakpoints.OnProjectChange
FDebugInfo.OnProjectChange
Endif
FMain.OnProjectChange
FSearch.OnProjectChange
If Class.IsLoaded("FHelpBrowser") Then FHelpBrowser.OnProjectChange
FProfile.OnProjectChange
'FOpenProject.OnUpdateRecent
If Not bIsFake Then
Breakpoints.OnProjectChange
FDebugInfo.OnProjectChange
'FDebugButton.OnProjectChange
Endif
Endif
$hLock = hLock
@ -3434,11 +3430,6 @@ Public Sub ReadProject(Optional bConvert As Boolean)
RunAfterMakingExec = ""
DefaultLanguage = ""
VersionFile = False
UseTerminal = False
RedirectStderr = False
UseHttpServer = False
Profiling = False
ProfileIndex = 0
Maintainer = ""
Vendor = ""
VendorPrefix = ""
@ -3722,18 +3713,6 @@ Public Sub ReadProject(Optional bConvert As Boolean)
Case "sourcepath"
SourcePath = sVal
Case "useterminal"
UseTerminal = CInt(sVal) <> 0
Case "redirectstderr"
RedirectStderr = CInt(sVal) <> 0
Case "usehttpserver"
UseHttpServer = CInt(sVal) <> 0
Case "profiling"
Profiling = CInt(sVal) <> 0
' Case "breakonerror"
' BreakOnError = CInt(sVal) <> 0
'
@ -3876,13 +3855,6 @@ Public Sub WriteProject(Optional bComponentDoNotChange As Boolean, Optional bMak
If Title Then Print #hFile, "Title="; Title
If Startup Then Print #hFile, "Startup="; Startup
'If Stack Then Print #hFic, "Stack="; Stack
'If StackTrace Then Print #hFic, "StackTrace=1"
If UseTerminal Then Print #hFile, "UseTerminal=1"
If RedirectStderr Then Print #hFile, "RedirectStderr=1"
If UseHttpServer Then Print #hFile, "UseHttpServer=1"
If Profiling Then Print #hFile, "Profiling=1"
'If BreakOnError Then Print #hFic, "BreakOnError=1"
If Icon Then Print #hFile, "Icon="; Icon
GetVersion()

View file

@ -318,21 +318,23 @@ End
Private Procedure AddDir(Optional sDir As String)
Dim cDir As New String[]
Dim aDir As New String[]
Dim sFile As String
Dim aFile As New String[]
If sDir Then
cDir.Add(sDir)
aDir.Add(sDir)
Else
cDir.Add($sDir)
If $sDir <> $sSourceDir Then cDir.Add($sSourceDir)
aDir.Add($sDir)
If $sDir <> $sSourceDir Then aDir.Add($sSourceDir)
Endif
$hTree._Begin()
Repeat
sDir = cDir[0]
cDir.Remove(0)
sDir = aDir[0]
aDir.Remove(0)
If Not IsDir(sDir) Then Continue
@ -355,14 +357,16 @@ Private Procedure AddDir(Optional sDir As String)
For Each sFile In aFile
sFile = Mid$(sFile, 2)
If AddFile(sDir, sFile, True) Then cDir.Add(sDir &/ sFile)
'AddFile(sDir, sFile, True)
If AddFile(sDir, sFile) Then aDir.Add(sDir &/ sFile)
Next
DoRefreshAfter
Until cDir.Count = 0
Until aDir.Count = 0
$hTree._End()
End