add a MRU for the customized executable used in gdb commander

This commit is contained in:
Basile Burg 2023-09-17 13:03:13 +02:00
parent e576ad1702
commit f1c6b38c38
2 changed files with 87 additions and 1 deletions

View File

@ -3,6 +3,7 @@
## Enhancements ## Enhancements
- Editor, added the _Undo All_ action. - Editor, added the _Undo All_ action.
- GDB Commander, custom executables selected for debugging are now stored in a persistent MRU list.
## Bugx fixed ## Bugx fixed

View File

@ -8,7 +8,7 @@ uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, RegExpr, ComCtrls, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, RegExpr, ComCtrls,
PropEdits, GraphPropEdits, RTTIGrids, Dialogs, ExtCtrls, Menus, Buttons, PropEdits, GraphPropEdits, RTTIGrids, Dialogs, ExtCtrls, Menus, Buttons,
StdCtrls, process, fpjson, typinfo, {$IFDEF UNIX}Unix,{$ELSE} Windows,{$ENDIF} StdCtrls, process, fpjson, typinfo, {$IFDEF UNIX}Unix,{$ELSE} Windows,{$ENDIF}
ListViewFilterEdit, SynEdit, ObjectInspector, math, ListViewFilterEdit, SynEdit, ObjectInspector, math, u_mru,
u_common, u_interfaces, u_widget, u_processes, u_observer, u_synmemo, u_common, u_interfaces, u_widget, u_processes, u_observer, u_synmemo,
u_sharedres, u_stringrange, u_dsgncontrols, u_dialogs, u_dbgitf, u_sharedres, u_stringrange, u_dsgncontrols, u_dialogs, u_dbgitf,
u_ddemangle, u_writableComponent, EditBtn, strutils, u_controls; u_ddemangle, u_writableComponent, EditBtn, strutils, u_controls;
@ -319,11 +319,13 @@ type
fGdbPath: TFilename; fGdbPath: TFilename;
fUseCustomCommandsHistory: boolean; fUseCustomCommandsHistory: boolean;
fAutoDotCompletion: boolean; fAutoDotCompletion: boolean;
fDebugRecentMru: TMRUFileList;
procedure setIgnoredSignals(value: TStringList); procedure setIgnoredSignals(value: TStringList);
procedure setCommandsHistory(value: TStringList); procedure setCommandsHistory(value: TStringList);
procedure setCustomEvalHistory(value: TStringList); procedure setCustomEvalHistory(value: TStringList);
procedure setShortcuts(value: TDebugShortcuts); procedure setShortcuts(value: TDebugShortcuts);
procedure setMaxCallStackDepth(value: integer); procedure setMaxCallStackDepth(value: integer);
procedure setDebugRecentMru(value: TMRUFileList);
procedure cleanInvalidHistoryEntries; procedure cleanInvalidHistoryEntries;
published published
property asmSyntax: TAsmSyntax read fAsmSyntax write fAsmSyntax; property asmSyntax: TAsmSyntax read fAsmSyntax write fAsmSyntax;
@ -338,6 +340,7 @@ type
property coreBreakingSymbols: TDlangBreakpoints read fDlangBreakpoints write fDlangBreakpoints; property coreBreakingSymbols: TDlangBreakpoints read fDlangBreakpoints write fDlangBreakpoints;
property currentEvalKind: TGdbEvalKind read fCurrentEvalKind write fCurrentEvalKind; property currentEvalKind: TGdbEvalKind read fCurrentEvalKind write fCurrentEvalKind;
property customEvalHistory: TStringList read fCustomEvalHistory write setCustomEvalHistory; property customEvalHistory: TStringList read fCustomEvalHistory write setCustomEvalHistory;
property debugRecentMru: TMRUFileList read fDebugRecentMru write setDebugRecentMru;
property gdbPath: TFilename read fGdbPath write fGdbPath; property gdbPath: TFilename read fGdbPath write fGdbPath;
property hideCpuView: boolean read fHideCpuView write fHideCpuView default false; property hideCpuView: boolean read fHideCpuView write fHideCpuView default false;
property ignoredSignals: TStringList read fIgnoredSignals write setIgnoredSignals; property ignoredSignals: TStringList read fIgnoredSignals write setIgnoredSignals;
@ -437,6 +440,7 @@ type
Edit1: TComboBox; Edit1: TComboBox;
GroupBox3: TGroupBox; GroupBox3: TGroupBox;
lstThreads: TListView; lstThreads: TListView;
mnuDebugRecent: TMenuItem;
mnuSelCustom: TMenuItem; mnuSelCustom: TMenuItem;
mnuEvalDeref: TMenuItem; mnuEvalDeref: TMenuItem;
mnuEvalSelected: TMenuItem; mnuEvalSelected: TMenuItem;
@ -604,6 +608,10 @@ type
function evaluate(const exp: string): string; function evaluate(const exp: string): string;
procedure executeFromShortcut(sender: TObject); procedure executeFromShortcut(sender: TObject);
procedure itemCompletetionClick(sender: TObject); procedure itemCompletetionClick(sender: TObject);
procedure mruDebugRecentChange(Sender: TObject);
procedure mruDebugRecentClick(Sender: TObject);
procedure mruDebugRecentClearClick(Sender: TObject);
procedure mruDebugRecentDeleteInvalidClick(Sender: TObject);
public public
constructor create(aOwner: TComponent); override; constructor create(aOwner: TComponent); override;
destructor destroy; override; destructor destroy; override;
@ -717,6 +725,7 @@ begin
fCustomEvalHistory := TstringList.Create; fCustomEvalHistory := TstringList.Create;
fCustomEvalHistory.Duplicates:= dupIgnore; fCustomEvalHistory.Duplicates:= dupIgnore;
fCustomEvalHistory.Sorted:=true; fCustomEvalHistory.Sorted:=true;
fDebugRecentMru := TMRUFileList.create;
for d in [low(TDlangBreakpoint) .. high(TDlangBreakpoint)] do for d in [low(TDlangBreakpoint) .. high(TDlangBreakpoint)] do
include(fDlangBreakpoints, d); include(fDlangBreakpoints, d);
end; end;
@ -727,6 +736,7 @@ begin
fCommandsHistory.Free; fCommandsHistory.Free;
fCustomEvalHistory.Free; fCustomEvalHistory.Free;
fShortcuts.Free; fShortcuts.Free;
fDebugRecentMru.free;
inherited; inherited;
end; end;
@ -769,6 +779,11 @@ begin
fShortcuts.assign(value); fShortcuts.assign(value);
end; end;
procedure TDebugOptionsBase.setDebugRecentMru(value: TMRUFileList);
begin
fDebugRecentMru.assign(value);
end;
procedure TDebugOptionsBase.setMaxCallStackDepth(value: integer); procedure TDebugOptionsBase.setMaxCallStackDepth(value: integer);
begin begin
value := max(1, value); value := max(1, value);
@ -801,6 +816,7 @@ begin
fCurrentEvalKind := src.fCurrentEvalKind; fCurrentEvalKind := src.fCurrentEvalKind;
fUseCustomCommandsHistory:= src.fUseCustomCommandsHistory; fUseCustomCommandsHistory:= src.fUseCustomCommandsHistory;
fAutoDotCompletion:=src.fAutoDotCompletion; fAutoDotCompletion:=src.fAutoDotCompletion;
fDebugRecentMru.assign(src.fDebugRecentMru);
end end
else inherited; else inherited;
end; end;
@ -1278,6 +1294,7 @@ begin
fSubj:= TDebugObserverSubject.Create; fSubj:= TDebugObserverSubject.Create;
fOptions:= TDebugOptions.create(self); fOptions:= TDebugOptions.create(self);
fOptions.onChangesApplied:=@optionsChangesApplied; fOptions.onChangesApplied:=@optionsChangesApplied;
fOptions.debugRecentMru.OnChange:=@mruDebugRecentChange;
fDebugeeOptions:= TDebugeeOptions.Create(self); fDebugeeOptions:= TDebugeeOptions.Create(self);
Edit1.Items.Assign(fOptions.commandsHistory); Edit1.Items.Assign(fOptions.commandsHistory);
fAddWatchPointKind := wpkWrite; fAddWatchPointKind := wpkWrite;
@ -1324,6 +1341,7 @@ begin
end; end;
end; end;
mruDebugRecentChange(nil);
updateCpuViewVisibility; updateCpuViewVisibility;
updateMenu; updateMenu;
updateButtonsState; updateButtonsState;
@ -2023,6 +2041,7 @@ begin
fLastFunction := ''; fLastFunction := '';
// gdb process // gdb process
killGdb; killGdb;
fOptions.debugRecentMru.Insert(0, fExe);
fGdb := TDexedProcess.create(nil); fGdb := TDexedProcess.create(nil);
fGdb.Executable:= gdb; fGdb.Executable:= gdb;
fgdb.Options:= [poUsePipes, poStderrToOutPut]; fgdb.Options:= [poUsePipes, poStderrToOutPut];
@ -3064,6 +3083,72 @@ begin
Edit1.Text := (sender as TMenuItem).Caption; Edit1.Text := (sender as TMenuItem).Caption;
end; end;
procedure TGdbWidget.mruDebugRecentChange(Sender: TObject);
var
srcLst: TMRUFileList;
itm: TMenuItem;
fname: string;
i: integer;
s: string;
begin
srcLst := fOptions.debugRecentMru;
mnuDebugRecent.Clear;
for i := 0 to srcLst.Count-1 do
begin
s := srcLst.Strings[i];
fname := s.extractFileName;
itm := TMenuItem.Create(mnuDebugRecent);
itm.Hint := s;
itm.Caption := fname + ' - (' + itm.Hint + ')';
itm.OnClick := @mruDebugRecentClick;
mnuDebugRecent.Add(itm);
end;
mnuDebugRecent.AddSeparator;
itm := TMenuItem.Create(mnuDebugRecent);
itm.Caption := 'Clear all';
itm.OnClick := @mruDebugRecentClearClick;
itm.Tag := PtrInt(srcLst);
mnuDebugRecent.Add(itm);
itm := TMenuItem.Create(mnuDebugRecent);
itm.Caption := 'Remove invalid entries';
itm.OnClick := @mruDebugRecentDeleteInvalidClick;
itm.Tag := PtrInt(srcLst);
mnuDebugRecent.Add(itm);
end;
procedure TGdbWidget.mruDebugRecentClick(Sender: TObject);
begin
fCustomTargetFile := TMenuItem(sender).Hint;
fDebugTargetKind := dtkCustom;
mnuSelProj.Checked:=false;
mnuSelRunnable.Checked:=false;
mnuSelCustom.Checked:=true;
updateDebugeeOptionsEditor;
btnStart.Click();
end;
procedure TGdbWidget.mruDebugRecentClearClick(Sender: TObject);
begin
mnuDebugRecent.Clear;
end;
procedure TGdbWidget.mruDebugRecentDeleteInvalidClick(Sender: TObject);
var
srcLst: TMRUFileList;
i: integer;
begin
srcLst := fOptions.debugRecentMru;
if srcLst.isNotAssigned then
exit;
srcLst.BeginUpdate;
for i := srcLst.Count-1 downto 0 do
if not srcLst.Strings[i].fileExists then
srcLst.Delete(i);
srcLst.EndUpdate;
end;
procedure TGdbWidget.btnSendComClick(Sender: TObject); procedure TGdbWidget.btnSendComClick(Sender: TObject);
begin begin
sendCustomCommand; sendCustomCommand;