Display information on debugged process. Fix git repository detection.

[DEVELOPMENT ENVIRONMENT]
* NEW: Update French translation.
* NEW: Debugger: Display the memory used by the debugged process (actually the PSS returned by Linux), and the number of its open file descriptors.
* BUG: Version control: Fix git repository detection.
This commit is contained in:
gambas 2021-10-21 13:54:44 +02:00
parent a40d11b528
commit 1474d6cef0
6 changed files with 631 additions and 227 deletions

File diff suppressed because it is too large Load diff

View file

@ -32,7 +32,7 @@ Component=gb.util.web
Description="Integrated Development Environment for Gambas"
Authors="Benoît Minisini\nFabien Bodard\nCharlie Reinl\nJosé Luis Redrejo\nRobert Rowe\nTobias Boege"
Arguments=[["-L"],["-t","/home/benoit/gambas/git/master/app/src/gambas3"],["--help"]]
Environment=" GTK_DEBUG=interactive"
Environment="GB_GUI=gb.qt5\n GTK_DEBUG=interactive"
TabSize=2
Translate=1
Language=en

View file

@ -2,6 +2,10 @@
Public Startup As String
Public ProcessId As Integer
Public ProcessFiles As Integer
Public ProcessMemory As Long
Public Enum ACTION_RUN, ACTION_RUN_WITH, ACTION_STEP, ACTION_FORWARD, ACTION_RETURN_FROM, ACTION_RUN_REMOTE
Private Const STATE_LAST As Integer = -1
@ -48,13 +52,13 @@ Private $sProfilePath As String
Private $sPipeError As String
Private $hPipeError As File
Private $hBrowser As Process
Private $iProcessId As Integer
Private $hTimerShowConsole As Timer
Private $bRemote As Boolean
Private $sRemoteLink As String
Private $hTimerRemote As Timer
Private $hTimerWatch As Timer
Public Sub Init()
@ -120,6 +124,12 @@ Private Sub SetState(iState As Integer)
FOutput.OnProjectDebugState
FDebugInfo.OnProjectDebugState
If $hTimerWatch Then
If $iState = STATE_RUNNING Then
'TimerWatch_Timer
$hTimerWatch.Restart
Endif
Endif
'$hTimerDebugPanel.Restart
End
@ -143,7 +153,7 @@ Public Sub Pause()
' If Project.UseTerminal Then
' If $iProcessId Then Signal.Send($iProcessId, Signal.SIGUSR2)
' Else
If $iProcessId Then Signal.Send($iProcessId, Signal.SIGUSR2)
If ProcessId Then Signal.Send(ProcessId, Signal.SIGUSR2)
End
@ -292,9 +302,17 @@ Public Sub Debug_Read(Data As String)
' [3] Local variables
' [4] Current object
If $iProcessId = 0 Then
Try $iProcessId = CInt(Scan(aData[0], "?[[]*]")[0])
FDebugInfo.UpdateProcessID($iProcessId)
If ProcessId = 0 Then
Try ProcessId = CInt(Scan(aData[0], "?[[]*]")[0])
If ProcessId Then
ProcessFiles = -1
ProcessMemory = -1
$hTimerWatch = New Timer As "TimerWatch"
$hTimerWatch.Delay = 1000
$hTimerWatch.Start
TimerWatch_Timer
FDebugInfo.UpdateProcessId()
Endif
Endif
aPos = Split(Trim(aData[2]), " ")
@ -566,6 +584,11 @@ Private Sub AfterStop()
FMain.ActivateCurrentWindow
If $hTimerWatch Then
$hTimerWatch.Stop
$hTimerWatch = Null
Endif
'$hTimerShowConsole.Stop
'IF Project.ActiveForm THEN
@ -935,7 +958,7 @@ Private Sub Start(sCmd As String)
'PRINT "EXEC "; "gbx -gs " & File.Dir(Project.Path) & " -- " & Project.Arguments
$iProcessId = 0
ProcessId = 0
$sCmdStart = ""
' FDebugInfo.ClearBreakpoint
@ -1233,7 +1256,7 @@ Public Sub RunRemote()
ClearOutput
$iProcessId = 0
ProcessId = 0
$sCmdStart = ""
ReadDebugSettings()
@ -1295,7 +1318,7 @@ Public Sub TimerRemote_Timer()
Dim sPath As String
Dim hLock As File
If $iProcessId Then
If ProcessId Then
sPath = File.SetExt($sFifo, "lock")
Try hLock = Lock sPath
If Not Error Then
@ -1379,6 +1402,8 @@ Private Sub Signal()
Return
Endif
If $hTimerWatch Then TimerWatch_Timer
' If $bUpdateBreakOnError Then
' $bUpdateBreakOnError = False
' BreakOnError
@ -1719,3 +1744,40 @@ Public Sub IsRemote() As Boolean
Return $bRemote
End
Public Sub TimerWatch_Timer()
Dim sDir As String
Dim aMaps As String[]
Dim sMap As String
Dim iPos As Integer
If $iState <> STATE_RUNNING Then
Stop Event
Return
Endif
sDir = "/proc" &/ CStr(ProcessId)
If Not IsDir(sDir) Then
$hTimerWatch.Stop
Return
Endif
Try ProcessFiles = Dir(sDir &/ "fd").Count
If Error Then ProcessFiles = -1
aMaps = Split(Trim(File.Load(sDir &/ "smaps_rollup")), "\n")
ProcessMemory = 0
For Each sMap In aMaps
If sMap Begins "Pss:" Then
sMap = LTrim(Mid$(sMap, 5))
iPos = InStr(sMap, " ")
ProcessMemory = CInt(Left(sMap, iPos - 1)) * 1024
Break
Endif
Next
FDebugInfo.UpdateProcessInfo()
End

View file

@ -1449,19 +1449,70 @@ Public Sub OnProjectDebug()
panError.Hide
sepError.Hide
If Design.IsRemote() Then
btnDebugProcess.Picture = Picture["icon:/small/connect"]
Else
btnDebugProcess.Picture = Picture["icon:/small/exec"]
Endif
btnDebugProcess.Text = ""
' If Design.IsRemote() Then
' btnDebugProcess.Picture = Picture["icon:/small/connect"]
' Else
' btnDebugProcess.Picture = Picture["icon:/small/exec"]
' Endif
'
' btnDebugProcess.Text = ""
End
Public Sub UpdateProcessId(iId As Integer)
' Public Sub UpdateProcessId(iId As Integer)
'
' btnDebugProcess.Text = Subst(("Process &1"), iId)
'
' End
Public Sub UpdateProcessId()
btnDebugProcess.Text = Subst(("Process &1"), iId)
If Design.IsRemote() Then
picProcess.Picture = Picture["icon:/small/connect"]
Else
picProcess.Picture = Picture["icon:/small/exec"]
Endif
If Design.ProcessId = 0 Then
lblProcessId.Hide
Else
lblProcessId.Show
lblProcessId.Text = Subst(("Process &1"), Design.ProcessId)
UpdateProcessInfo
Endif
End
Public Sub UpdateProcessInfo()
If Design.ProcessId = 0 Then
panProcessFiles.Hide
panProcessMemoryRead.Hide
Else
If Design.ProcessFiles < 0 Then
panProcessFiles.Hide
Else
panProcessFiles.Show
lblProcessFiles.Text = CStr(Design.ProcessFiles)
Endif
If Design.ProcessMemory < 0 Then
panProcessMemory.Hide
Else
panProcessMemory.Show
lblProcessMemory.Text = File.FormatSize(Design.ProcessMemory, True)
Endif
Endif
End
@ -1831,3 +1882,4 @@ Public Sub btnVcChanges_Click()
FFileInfoVC.Run(Project.Dir)
End

View file

@ -1,7 +1,7 @@
# Gambas Form File 3.0
{ Form Form
MoveScaled(0,0,125,50)
MoveScaled(0,0,141,50)
Text = ("Debug")
Persistent = True
Arrangement = Arrange.Fill
@ -13,7 +13,7 @@
}
}
{ wizDebug Wizard
MoveScaled(2,5,122,44)
MoveScaled(1,2,137,44)
Arrangement = Arrange.Vertical
Count = 8
ShowTitle = False
@ -22,53 +22,85 @@
Index = 0
Text = ("Debugging")
{ panDebug VBox
MoveScaled(0,3,119,40)
MoveScaled(0,3,137,40)
Expand = True
{ panRemoteDebug Panel
MoveScaled(96,3,22,18)
Visible = False
Background = Color.TextBackground
Expand = True
Arrangement = Arrange.Vertical
Centered = True
Spacing = True
Margin = True
{ spnRemoteDebug Spinner
MoveScaled(4,2,13,6)
Type = Spinner.Circle
}
{ Label1 TextLabel
MoveScaled(2,10,18,5)
Foreground = Color.LightForeground
AutoResize = True
Text = ("Waiting for remote process") & "..."
Alignment = Align.Center
}
}
{ splDebug HSplit
MoveScaled(1,1,94,32)
MoveScaled(1,1,127,32)
Expand = True
{ Panel16 VBox
MoveScaled(1,1,22,30)
MoveScaled(1,1,53,30)
{ HBox1 HBox
MoveScaled(2,1,18,4)
{ btnDebugProcess ToolButton
MoveScaled(2,0,8,4)
MoveScaled(1,5,44,4)
Font = Font["-2"]
Spacing = True
{ Panel17 HBox
MoveScaled(0,0,9,4)
AutoResize = True
{ picProcess PictureBox
MoveScaled(0,0,4,4)
Alignment = Align.Center
}
{ lblProcessId Label
MoveScaled(4,0,4,4)
AutoResize = True
}
}
{ panProcessMemoryRead HBox
MoveScaled(10,0,9,4)
Visible = False
ToolTip = ("Read-only memory")
AutoResize = True
{ picProcessMemoryRead PictureBox
MoveScaled(0,0,4,4)
Picture = Picture.Load("icon:/small/cdrom")
Alignment = Align.Center
}
{ lblProcessMemoryRead Label
MoveScaled(4,0,4,4)
AutoResize = True
}
}
{ panProcessMemory HBox
MoveScaled(20,0,9,4)
ToolTip = ("Allocated memory")
AutoResize = True
{ picProcessMemory PictureBox
MoveScaled(0,0,4,4)
Picture = Picture.Load("icon:/small/statistics")
Alignment = Align.Center
}
{ lblProcessMemory Label
MoveScaled(4,0,4,4)
AutoResize = True
}
}
{ panProcessFiles HBox
MoveScaled(32,0,9,4)
ToolTip = ("Open file descriptors")
AutoResize = True
{ picProcessFiles PictureBox
MoveScaled(0,0,4,4)
Picture = Picture.Load("icon:/small/script")
Alignment = Align.Center
}
{ lblProcessFiles Label
MoveScaled(4,0,4,4)
AutoResize = True
}
}
}
{ Separator8 Separator
MoveScaled(4,7,11,0)
MoveScaled(4,10,11,0)
}
{ lvwStack ListView
MoveScaled(1,8,18,20)
MoveScaled(1,16,18,12)
Mouse = Mouse.Pointing
Expand = True
Border = False
}
}
{ Panel7 VBox
MoveScaled(28,1,63,30)
MoveScaled(61,2,63,30)
{ panWatch HBox
MoveScaled(1,1,61,4)
Drop = True
@ -163,6 +195,27 @@
Alignment = Align.Normal
}
}
{ panRemoteDebug Panel
MoveScaled(113,34,20,18)
Visible = False
Background = Color.TextBackground
Expand = True
Arrangement = Arrange.Vertical
Centered = True
Spacing = True
Margin = True
{ spnRemoteDebug Spinner
MoveScaled(4,2,13,6)
Type = Spinner.Circle
}
{ Label1 TextLabel
MoveScaled(1,10,18,5)
Foreground = Color.LightForeground
AutoResize = True
Text = ("Waiting for remote process") & "..."
Alignment = Align.Center
}
}
}
Index = 1
Text = ("Console")

View file

@ -64,7 +64,7 @@ Public Sub Check() As Boolean
If $bHasGit Then
'sResult = RunShell("git status --porcelain .project")
Exec ["git", "status", "--porcelain", Project.Dir &/ ".project"] To sResult
Exec ["git", "status", "--porcelain", ".project"] With ["PWD=" & Project.Dir] To sResult
If Process.LastValue Then
$bCanInit = True
@ -78,7 +78,7 @@ Public Sub Check() As Boolean
If sRoot Then
$sRoot = File.Dir(sRoot)
'$bHasRemote = RunShell("git remote show")
Exec ["git", "remote", "show"] To sResult
Exec ["git", "remote", "show"] With ["PWD=" & Project.Dir] To sResult
$bHasRemote = Trim(sResult)
Return True
Endif