gdbcom, add history to eval custom expr and add shortcut to repeat command, close #274

This commit is contained in:
Basile Burg 2018-03-28 10:54:46 +02:00
parent 91602dd9e7
commit 682150df1f
2 changed files with 56 additions and 19 deletions

View File

@ -14,38 +14,38 @@ inherited CEGdbWidget: TCEGdbWidget
ClientHeight = 662 ClientHeight = 662
ClientWidth = 517 ClientWidth = 517
inherited Content: TPanel inherited Content: TPanel
Height = 628 Height = 626
Top = 34 Top = 36
Width = 517 Width = 517
ClientHeight = 628 ClientHeight = 626
ClientWidth = 517 ClientWidth = 517
object Panel1: TPanel[0] object Panel1: TPanel[0]
Left = 0 Left = 0
Height = 386 Height = 384
Top = 205 Top = 205
Width = 517 Width = 517
Align = alClient Align = alClient
AutoSize = True AutoSize = True
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 386 ClientHeight = 384
ClientWidth = 517 ClientWidth = 517
TabOrder = 0 TabOrder = 0
object GroupBox3: TGroupBox object GroupBox3: TGroupBox
Left = 0 Left = 0
Height = 180 Height = 178
Top = 206 Top = 206
Width = 517 Width = 517
Align = alClient Align = alClient
Caption = 'CPU' Caption = 'CPU'
ClientHeight = 161 ClientHeight = 160
ClientWidth = 513 ClientWidth = 515
TabOrder = 0 TabOrder = 0
object cpuViewer: TTIPropertyGrid object cpuViewer: TTIPropertyGrid
Left = 0 Left = 0
Height = 161 Height = 160
Hint = 'cpu registers' Hint = 'cpu registers'
Top = 0 Top = 0
Width = 513 Width = 515
Align = alClient Align = alClient
CheckboxForBoolean = True CheckboxForBoolean = True
DefaultValueFont.Color = clWindowText DefaultValueFont.Color = clWindowText
@ -82,8 +82,8 @@ inherited CEGdbWidget: TCEGdbWidget
ClientWidth = 511 ClientWidth = 511
object lstVariables: TListView object lstVariables: TListView
Left = 2 Left = 2
Height = 132 Height = 136
Top = 31 Top = 27
Width = 507 Width = 507
Align = alClient Align = alClient
AutoWidthLastColumn = True AutoWidthLastColumn = True
@ -109,7 +109,7 @@ inherited CEGdbWidget: TCEGdbWidget
end end
object varListFlt: TListViewFilterEdit object varListFlt: TListViewFilterEdit
Left = 2 Left = 2
Height = 27 Height = 23
Hint = 'locate variables' Hint = 'locate variables'
Top = 2 Top = 2
Width = 507 Width = 507
@ -159,7 +159,7 @@ inherited CEGdbWidget: TCEGdbWidget
object Panel3: TPanel[1] object Panel3: TPanel[1]
Left = 4 Left = 4
Height = 29 Height = 29
Top = 595 Top = 593
Width = 509 Width = 509
Align = alBottom Align = alBottom
AutoSize = True AutoSize = True
@ -330,7 +330,6 @@ inherited CEGdbWidget: TCEGdbWidget
end end
end end
inherited toolbar: TCEToolBar inherited toolbar: TCEToolBar
Height = 28
Width = 509 Width = 509
object btnStack: TCEToolButton[0] object btnStack: TCEToolButton[0]
Left = 238 Left = 238

View File

@ -251,7 +251,7 @@ type
TCEDebugShortcuts = class(TPersistent) TCEDebugShortcuts = class(TPersistent)
private private
fStart, fStop, fPause, fContinue, fStep, fStepOver, fStack, fRegs, fStart, fStop, fPause, fContinue, fStep, fStepOver, fStack, fRegs,
fVariables: TShortCut; fVariables, fRepeatCustomEval: TShortCut;
published published
property start: TShortCut read fStart write fStart; property start: TShortCut read fStart write fStart;
property stop: TShortCut read fStop write fStop; property stop: TShortCut read fStop write fStop;
@ -262,6 +262,7 @@ type
property updateStack: TShortCut read fStack write fStack; property updateStack: TShortCut read fStack write fStack;
property updateRegisters: TShortCut read fRegs write fRegs; property updateRegisters: TShortCut read fRegs write fRegs;
property updateVariables: TShortCut read fVariables write fVariables; property updateVariables: TShortCut read fVariables write fVariables;
property repeatCustomEval: TShortCut read fRepeatCustomEval write fRepeatCustomEval;
public public
procedure assign(source: TPersistent); override; procedure assign(source: TPersistent); override;
end; end;
@ -275,6 +276,7 @@ type
fAutoGetRegisters: boolean; fAutoGetRegisters: boolean;
fAutoGetVariables: boolean; fAutoGetVariables: boolean;
fCommandsHistory: TStringList; fCommandsHistory: TStringList;
fCustomEvalHistory: TStringList;
fIgnoredSignals: TStringList; fIgnoredSignals: TStringList;
fShowGdbOutput: boolean; fShowGdbOutput: boolean;
fShowOutput: boolean; fShowOutput: boolean;
@ -285,6 +287,7 @@ type
fStopAllThreadsOnBreak: boolean; fStopAllThreadsOnBreak: boolean;
procedure setIgnoredSignals(value: TStringList); procedure setIgnoredSignals(value: TStringList);
procedure setCommandsHistory(value: TStringList); procedure setCommandsHistory(value: TStringList);
procedure setCustomEvalHistory(value: TStringList);
procedure setShortcuts(value: TCEDebugShortcuts); procedure setShortcuts(value: TCEDebugShortcuts);
procedure cleanInvalidHistoryEntries; procedure cleanInvalidHistoryEntries;
published published
@ -296,6 +299,7 @@ type
property autoGetVariables: boolean read fAutoGetVariables write fAutoGetVariables; property autoGetVariables: boolean read fAutoGetVariables write fAutoGetVariables;
property autoGetThreads: boolean read fAutoGetThreads write fAutoGetThreads; property autoGetThreads: boolean read fAutoGetThreads write fAutoGetThreads;
property commandsHistory: TStringList read fCommandsHistory write setCommandsHistory; property commandsHistory: TStringList read fCommandsHistory write setCommandsHistory;
property customEvalHistory: TStringList read fCustomEvalHistory write setCustomEvalHistory;
property ignoredSignals: TStringList read fIgnoredSignals write setIgnoredSignals; property ignoredSignals: TStringList read fIgnoredSignals write setIgnoredSignals;
property keepRedirectedStreams: boolean read fKeepRedirectedStreams write fKeepRedirectedStreams default false; property keepRedirectedStreams: boolean read fKeepRedirectedStreams write fKeepRedirectedStreams default false;
property shortcuts: TCEDebugShortcuts read fShortcuts write setShortcuts; property shortcuts: TCEDebugShortcuts read fShortcuts write setShortcuts;
@ -487,6 +491,7 @@ type
fLastFunction: string; fLastFunction: string;
fLastOffset: string; fLastOffset: string;
fLastLine: string; fLastLine: string;
fLastEvalStuff: string;
fCommandProcessed: boolean; fCommandProcessed: boolean;
fDebugeeOptions: TCEDebugeeOptions; fDebugeeOptions: TCEDebugeeOptions;
procedure continueDebugging; procedure continueDebugging;
@ -512,6 +517,7 @@ type
procedure infoVariables; procedure infoVariables;
procedure infoThreads; procedure infoThreads;
procedure infoAsm(const fname: string); procedure infoAsm(const fname: string);
procedure evalStuff(const stuff: string);
procedure sendCustomCommand; procedure sendCustomCommand;
procedure setGpr(reg: TCpuRegister; val: TCpuGprValue); procedure setGpr(reg: TCpuRegister; val: TCpuGprValue);
procedure setFpr(reg: TFpuRegister; val: extended); procedure setFpr(reg: TFpuRegister; val: extended);
@ -623,6 +629,7 @@ begin
fStack := src.fStack; fStack := src.fStack;
fRegs := src.fRegs; fRegs := src.fRegs;
fVariables:= src.fVariables; fVariables:= src.fVariables;
fRepeatCustomEval:=src.fRepeatCustomEval;
end end
else inherited; else inherited;
end; end;
@ -645,12 +652,16 @@ begin
fCommandsHistory.Duplicates:= dupIgnore; fCommandsHistory.Duplicates:= dupIgnore;
fCommandsHistory.Sorted:=true; fCommandsHistory.Sorted:=true;
fShortcuts := TCEDebugShortcuts.Create; fShortcuts := TCEDebugShortcuts.Create;
fCustomEvalHistory := TstringList.Create;
fCustomEvalHistory.Duplicates:= dupIgnore;
fCustomEvalHistory.Sorted:=true;
end; end;
destructor TCEDebugOptionsBase.destroy; destructor TCEDebugOptionsBase.destroy;
begin begin
fIgnoredSignals.Free; fIgnoredSignals.Free;
fCommandsHistory.Free; fCommandsHistory.Free;
fCustomEvalHistory.Free;
fShortcuts.Free; fShortcuts.Free;
inherited; inherited;
end; end;
@ -684,6 +695,11 @@ begin
fCommandsHistory.Assign(value); fCommandsHistory.Assign(value);
end; end;
procedure TCEDebugOptionsBase.setCustomEvalHistory(value: TStringList);
begin
fCustomEvalHistory.Assign(value);
end;
procedure TCEDebugOptionsBase.setShortcuts(value: TCEDebugShortcuts); procedure TCEDebugOptionsBase.setShortcuts(value: TCEDebugShortcuts);
begin begin
fShortcuts.assign(value); fShortcuts.assign(value);
@ -1357,6 +1373,16 @@ begin
itm.Bitmap.Assign(bmp); itm.Bitmap.Assign(bmp);
itm.ImageIndex:= fMenu.GetImageList.Add(bmp, nil); itm.ImageIndex:= fMenu.GetImageList.Add(bmp, nil);
itm := TMenuItem.Create(fMenu);
itm.ShortCut:=fOptions.shortcuts.repeatCustomEval;
itm.Caption:='Repeat last evaluation command';
itm.OnClick:= @executeFromShortcut;
itm.Tag:=9;
fMenu.Add(itm);
btnEval.toBitmap(bmp);
itm.Bitmap.Assign(bmp);
itm.ImageIndex:= fMenu.GetImageList.Add(bmp, nil);
bmp.Free; bmp.Free;
end; end;
@ -1387,6 +1413,7 @@ begin
6: begin showWidget; btnReg.Click; end; 6: begin showWidget; btnReg.Click; end;
7: begin showWidget; btnStack.Click; end; 7: begin showWidget; btnStack.Click; end;
8: begin showWidget; btnVariables.Click; end; 8: begin showWidget; btnVariables.Click; end;
9: evalStuff(fLastEvalStuff);
end; end;
end; end;
{$ENDREGION} {$ENDREGION}
@ -2533,6 +2560,12 @@ begin
gdbCommand(cmd, @gdboutJsonize); gdbCommand(cmd, @gdboutJsonize);
end; end;
procedure TCEGdbWidget.evalStuff(const stuff: string);
begin
fLastEvalStuff := stuff;
gdbCommand('-data-evaluate-expression "' + stuff + '"');
end;
procedure TCEGdbWidget.continueDebugging; procedure TCEGdbWidget.continueDebugging;
begin begin
gdbCommand('-exec-continue --all', @gdboutJsonize); gdbCommand('-exec-continue --all', @gdboutJsonize);
@ -2561,8 +2594,13 @@ begin
exit; exit;
case fEvalKind of case fEvalKind of
gekCustom: gekCustom:
if not InputQuery('Evaluate', 'Expression', e) then begin
e := ''; if fOptions.customEvalHistory.Count = 0 then
fOptions.customEvalHistory.Add('<enter a custom expression to evaluate>');
e := InputComboEx('Evaluate', 'Expression', fOptions.customEvalHistory, true);
if not e.isBlank then
fOptions.customEvalHistory.Add(e);
end;
gekSelectedVar: gekSelectedVar:
if lstVariables.ItemIndex <> -1 then if lstVariables.ItemIndex <> -1 then
e := lstVariables.Items[lstVariables.ItemIndex].Caption; e := lstVariables.Items[lstVariables.ItemIndex].Caption;
@ -2571,7 +2609,7 @@ begin
e := '*' + lstVariables.Items[lstVariables.ItemIndex].Caption; e := '*' + lstVariables.Items[lstVariables.ItemIndex].Caption;
end; end;
if not e.isBlank then if not e.isBlank then
gdbCommand('-data-evaluate-expression "' + e + '"'); evalStuff(e);
end; end;
procedure TCEGdbWidget.btnVariablesClick(Sender: TObject); procedure TCEGdbWidget.btnVariablesClick(Sender: TObject);