allow to debug a custom executable

This commit is contained in:
Basile Burg 2020-06-06 17:32:26 +02:00
parent 5f206595d3
commit 017fef6fc1
3 changed files with 71 additions and 32 deletions

View File

@ -1,3 +1,9 @@
# v3.9.5-dev
## Enhancements
- GDB commander: added a 3rd choice in the menu associated to first toolbar button. It allows to debug a custom executable, i.e not tied to a project or a runnable script.
# v3.9.4 # v3.9.4
## Enhancements ## Enhancements

View File

@ -20,31 +20,31 @@ inherited GdbWidget: TGdbWidget
ClientWidth = 672 ClientWidth = 672
object Panel1: TPanel[0] object Panel1: TPanel[0]
Left = 0 Left = 0
Height = 380 Height = 387
Top = 205 Top = 205
Width = 672 Width = 672
Align = alClient Align = alClient
AutoSize = True AutoSize = True
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 380 ClientHeight = 387
ClientWidth = 672 ClientWidth = 672
TabOrder = 0 TabOrder = 0
object GroupBox3: TGroupBox object GroupBox3: TGroupBox
Left = 0 Left = 0
Height = 174 Height = 181
Top = 206 Top = 206
Width = 672 Width = 672
Align = alClient Align = alClient
Caption = 'CPU' Caption = 'CPU'
ClientHeight = 155 ClientHeight = 162
ClientWidth = 668 ClientWidth = 668
TabOrder = 0 TabOrder = 0
object cpuViewer: TTIPropertyGrid object cpuViewer: TTIPropertyGrid
Left = 0 Left = 0
Height = 156 Height = 162
Hint = 'cpu registers' Hint = 'cpu registers'
Top = 0 Top = 0
Width = 670 Width = 668
Align = alClient Align = alClient
CheckboxForBoolean = True CheckboxForBoolean = True
DefaultValueFont.Color = clWindowText DefaultValueFont.Color = clWindowText
@ -81,21 +81,21 @@ inherited GdbWidget: TGdbWidget
ClientWidth = 670 ClientWidth = 670
object lstVariables: TListView object lstVariables: TListView
Left = 2 Left = 2
Height = 130 Height = 141
Top = 37 Top = 30
Width = 658 Width = 666
Align = alClient Align = alClient
BorderSpacing.Around = 2 BorderSpacing.Around = 2
Columns = < Columns = <
item item
AutoSize = True AutoSize = True
Caption = 'name' Caption = 'name'
Width = 58 Width = 45
end end
item item
AutoSize = True AutoSize = True
Caption = 'value' Caption = 'value'
Width = 598 Width = 619
end> end>
GridLines = True GridLines = True
HideSelection = False HideSelection = False
@ -109,10 +109,10 @@ inherited GdbWidget: TGdbWidget
end end
object varListFlt: TListViewFilterEdit object varListFlt: TListViewFilterEdit
Left = 2 Left = 2
Height = 33 Height = 26
Hint = 'locate variables' Hint = 'locate variables'
Top = 2 Top = 2
Width = 658 Width = 666
ButtonWidth = 24 ButtonWidth = 24
Align = alTop Align = alTop
BorderSpacing.Around = 2 BorderSpacing.Around = 2
@ -139,7 +139,7 @@ inherited GdbWidget: TGdbWidget
item item
AutoSize = True AutoSize = True
Caption = 'address' Caption = 'address'
Width = 77 Width = 59
end end
item item
Caption = 'instruction' Caption = 'instruction'
@ -158,19 +158,19 @@ inherited GdbWidget: TGdbWidget
end end
object Panel3: TPanel[1] object Panel3: TPanel[1]
Left = 4 Left = 4
Height = 33 Height = 26
Top = 589 Top = 596
Width = 664 Width = 664
Align = alBottom Align = alBottom
AutoSize = True AutoSize = True
BorderSpacing.Around = 4 BorderSpacing.Around = 4
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 33 ClientHeight = 26
ClientWidth = 664 ClientWidth = 664
TabOrder = 1 TabOrder = 1
object btnSendCom: TSpeedButton object btnSendCom: TSpeedButton
Left = 659 Left = 659
Height = 31 Height = 24
Top = 1 Top = 1
Width = 4 Width = 4
Align = alRight Align = alRight
@ -180,7 +180,7 @@ inherited GdbWidget: TGdbWidget
end end
object Edit1: TComboBox object Edit1: TComboBox
Left = 0 Left = 0
Height = 33 Height = 26
Hint = 'enter a custom GDB command or the program input with ">"' Hint = 'enter a custom GDB command or the program input with ">"'
Top = 0 Top = 0
Width = 658 Width = 658
@ -218,10 +218,10 @@ inherited GdbWidget: TGdbWidget
ClientWidth = 670 ClientWidth = 670
object lstCallStack: TListView object lstCallStack: TListView
Left = 0 Left = 0
Height = 169 Height = 173
Hint = 'call stack' Hint = 'call stack'
Top = 0 Top = 0
Width = 662 Width = 670
Align = alClient Align = alClient
AutoSort = False AutoSort = False
Columns = < Columns = <
@ -239,7 +239,7 @@ inherited GdbWidget: TGdbWidget
end end
item item
Caption = 'line' Caption = 'line'
Width = 320 Width = 328
end> end>
GridLines = True GridLines = True
ReadOnly = True ReadOnly = True
@ -266,32 +266,32 @@ inherited GdbWidget: TGdbWidget
item item
AutoSize = True AutoSize = True
Caption = 'id' Caption = 'id'
Width = 31 Width = 20
end end
item item
AutoSize = True AutoSize = True
Caption = 'state' Caption = 'state'
Width = 54 Width = 41
end end
item item
AutoSize = True AutoSize = True
Caption = 'core' Caption = 'core'
Width = 49 Width = 36
end end
item item
AutoSize = True AutoSize = True
Caption = 'function' Caption = 'function'
Width = 80 Width = 61
end end
item item
AutoSize = True AutoSize = True
Caption = 'address' Caption = 'address'
Width = 77 Width = 59
end end
item item
AutoSize = True AutoSize = True
Caption = 'filename' Caption = 'filename'
Width = 82 Width = 65
end end
item item
Caption = 'line' Caption = 'line'
@ -353,7 +353,7 @@ inherited GdbWidget: TGdbWidget
end end
object button4: TDexedToolButton[2] object button4: TDexedToolButton[2]
Left = 205 Left = 205
Height = 5 Height = 28
Top = 0 Top = 0
AutoSize = True AutoSize = True
Caption = 'button4' Caption = 'button4'
@ -489,6 +489,11 @@ inherited GdbWidget: TGdbWidget
Caption = 'Debug runnable' Caption = 'Debug runnable'
OnClick = mnuSelRunnableClick OnClick = mnuSelRunnableClick
end end
object mnuSelCustom: TMenuItem
AutoCheck = True
Caption = 'Debug custom executable...'
OnClick = mnuSelCustomClick
end
end end
object mnuWatch: TPopupMenu[4] object mnuWatch: TPopupMenu[4]
left = 56 left = 56

View File

@ -17,7 +17,7 @@ type
TAsmSyntax = (intel, att); TAsmSyntax = (intel, att);
TDebugTargetKind = (dtkProject, dtkRunnable); TDebugTargetKind = (dtkProject, dtkRunnable, dtkCustom);
{$IFDEF CPU64} {$IFDEF CPU64}
TCpuRegister = (rax, rbx, rcx, rdx, rsi, rdi, rbp, rsp, r8, r9, r10, r11, r12, r13, TCpuRegister = (rax, rbx, rcx, rdx, rsi, rdi, rbp, rsp, r8, r9, r10, r11, r12, r13,
@ -426,6 +426,7 @@ type
Edit1: TComboBox; Edit1: TComboBox;
GroupBox3: TGroupBox; GroupBox3: TGroupBox;
lstThreads: TListView; lstThreads: TListView;
mnuSelCustom: TMenuItem;
mnuEvalDeref: TMenuItem; mnuEvalDeref: TMenuItem;
mnuEvalSelected: TMenuItem; mnuEvalSelected: TMenuItem;
mnuEvalCustom: TMenuItem; mnuEvalCustom: TMenuItem;
@ -483,6 +484,7 @@ type
procedure mnuEvalSelectedClick(Sender: TObject); procedure mnuEvalSelectedClick(Sender: TObject);
procedure mnuReadWClick(Sender: TObject); procedure mnuReadWClick(Sender: TObject);
procedure mnuReadWriteWClick(Sender: TObject); procedure mnuReadWriteWClick(Sender: TObject);
procedure mnuSelCustomClick(Sender: TObject);
procedure mnuSelProjClick(Sender: TObject); procedure mnuSelProjClick(Sender: TObject);
procedure mnuSelRunnableClick(Sender: TObject); procedure mnuSelRunnableClick(Sender: TObject);
procedure mnuWriteWClick(Sender: TObject); procedure mnuWriteWClick(Sender: TObject);
@ -507,6 +509,7 @@ type
fCatchCustomEvalAsString: boolean; fCatchCustomEvalAsString: boolean;
fCaughtCustomEvalAstring: string; fCaughtCustomEvalAstring: string;
fProj: ICommonProject; fProj: ICommonProject;
fCustomTargetFile: string;
fJson: TJsonObject; fJson: TJsonObject;
fLog: TStringList; fLog: TStringList;
fDocHandler: IMultiDocHandler; fDocHandler: IMultiDocHandler;
@ -1834,6 +1837,7 @@ procedure TGdbWidget.mnuSelProjClick(Sender: TObject);
begin begin
fDebugTargetKind := dtkProject; fDebugTargetKind := dtkProject;
mnuSelRunnable.Checked:=false; mnuSelRunnable.Checked:=false;
mnuSelCustom.Checked:=false;
updateDebugeeOptionsEditor; updateDebugeeOptionsEditor;
end; end;
@ -1841,9 +1845,27 @@ procedure TGdbWidget.mnuSelRunnableClick(Sender: TObject);
begin begin
fDebugTargetKind := dtkRunnable; fDebugTargetKind := dtkRunnable;
mnuSelProj.Checked:=false; mnuSelProj.Checked:=false;
mnuSelCustom.Checked:=false;
updateDebugeeOptionsEditor; updateDebugeeOptionsEditor;
end; end;
procedure TGdbWidget.mnuSelCustomClick(Sender: TObject);
begin
with TOpenDialog.Create(nil) do
try
if execute then
begin
fCustomTargetFile := FileName;
fDebugTargetKind := dtkCustom;
mnuSelProj.Checked:=false;
mnuSelRunnable.Checked:=false;
updateDebugeeOptionsEditor;
end;
finally
free;
end;
end;
procedure TGdbWidget.mnuWriteWClick(Sender: TObject); procedure TGdbWidget.mnuWriteWClick(Sender: TObject);
begin begin
fAddWatchPointKind := wpkWrite; fAddWatchPointKind := wpkWrite;
@ -1906,6 +1928,7 @@ begin
case fDebugTargetKind of case fDebugTargetKind of
dtkProject: fExe := fProj.outputFilename; dtkProject: fExe := fProj.outputFilename;
dtkRunnable: fExe := fDoc.fileName.stripFileExt + exeExt; dtkRunnable: fExe := fDoc.fileName.stripFileExt + exeExt;
dtkCustom : fExe := fCustomTargetFile;
end; end;
if (fExe = '/') or not fExe.fileExists then if (fExe = '/') or not fExe.fileExists then
@ -1939,6 +1962,7 @@ begin
case fDebugTargetKind of case fDebugTargetKind of
dtkRunnable: o := fDebugeeOptions.projectByFile[fDoc.fileName]; dtkRunnable: o := fDebugeeOptions.projectByFile[fDoc.fileName];
dtkProject: o := fDebugeeOptions.projectByFile[fProj.fileName]; dtkProject: o := fDebugeeOptions.projectByFile[fProj.fileName];
dtkCustom: o := fDebugeeOptions.projectByFile[fCustomTargetFile];
end; end;
fLastFunction := ''; fLastFunction := '';
// gdb process // gdb process
@ -2050,8 +2074,12 @@ begin
dbgeeOptsEd.ItemIndex:=-1; dbgeeOptsEd.ItemIndex:=-1;
dbgeeOptsEd.TIObject := nil; dbgeeOptsEd.TIObject := nil;
case fDebugTargetKind of case fDebugTargetKind of
dtkProject : if fProj <> nil then nme := fProj.filename; dtkProject : if fProj <> nil then
dtkRunnable : if fDoc.isNotNil then nme := fDoc.filename; nme := fProj.filename;
dtkRunnable : if fDoc.isNotNil then
nme := fDoc.filename;
dtkCustom : if fCustomTargetFile.fileExists then
nme := fCustomTargetFile;
end; end;
if nme.fileExists then if nme.fileExists then
begin begin