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
## Enhancements

View File

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

View File

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