#97, add custom command history

This commit is contained in:
Basile Burg 2016-09-22 10:47:02 +02:00
parent 693cef57aa
commit 2a1b430080
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
2 changed files with 57 additions and 29 deletions

View File

@ -39,18 +39,6 @@ inherited CEGdbWidget: TCEGdbWidget
ClientHeight = 28 ClientHeight = 28
ClientWidth = 509 ClientWidth = 509
TabOrder = 0 TabOrder = 0
object Edit1: TEdit
Left = 0
Height = 24
Hint = 'custom GDB command'
Top = 2
Width = 477
Align = alClient
BorderSpacing.Top = 2
BorderSpacing.Bottom = 2
OnKeyUp = Edit1KeyUp
TabOrder = 0
end
object btnSendCom: TSpeedButton object btnSendCom: TSpeedButton
Left = 479 Left = 479
Height = 24 Height = 24
@ -60,6 +48,20 @@ inherited CEGdbWidget: TCEGdbWidget
BorderSpacing.Around = 2 BorderSpacing.Around = 2
OnClick = btnSendComClick OnClick = btnSendComClick
end end
object Edit1: TComboBox
Left = 0
Height = 28
Hint = 'Custom GDB command'
Top = 0
Width = 477
Align = alClient
AutoComplete = True
AutoCompleteText = [cbactEnabled, cbactEndOfLineComplete, cbactSearchAscending]
ItemHeight = 0
MaxLength = 64
OnKeyUp = Edit1KeyUp
TabOrder = 0
end
end end
object stateViewer: TTIPropertyGrid object stateViewer: TTIPropertyGrid
Left = 0 Left = 0

View File

@ -139,6 +139,7 @@ type
property name: string read fFname; property name: string read fFname;
end; end;
// The call stack
TStackItems = class TStackItems = class
strict private strict private
fItems: TCollection; fItems: TCollection;
@ -152,20 +153,26 @@ type
end; end;
// TODO-cGDB: shortcuts // TODO-cGDB: shortcuts
// TODO-cGDB: assembly view
// TODO-cGDB: show locals
TCEDebugOptionsBase = class(TWritableLfmTextComponent) TCEDebugOptionsBase = class(TWritableLfmTextComponent)
private private
fAutoDemangle: boolean; fAutoDemangle: boolean;
fAutoGetCallStack: boolean; fAutoGetCallStack: boolean;
fAutoGetRegisters: boolean; fAutoGetRegisters: boolean;
fAutoGetVariables: boolean; fAutoGetVariables: boolean;
fCommandsHistory: TStringList;
fIgnoredSignals: TStringList; fIgnoredSignals: TStringList;
fShowOutput: boolean; fShowOutput: boolean;
procedure setIgnoredSignals(value: TStringList); procedure setIgnoredSignals(value: TStringList);
procedure setCommandsHistory(value: TStringList);
published published
property autoDemangle: boolean read fAutoDemangle write fAutoDemangle; property autoDemangle: boolean read fAutoDemangle write fAutoDemangle;
property autoGetCallStack: boolean read fAutoGetCallStack write fAutoGetCallStack; property autoGetCallStack: boolean read fAutoGetCallStack write fAutoGetCallStack;
property autoGetRegisters: boolean read fAutoGetRegisters write fAutoGetRegisters; property autoGetRegisters: boolean read fAutoGetRegisters write fAutoGetRegisters;
property autoGetVariables: boolean read fAutoGetVariables write fAutoGetVariables; property autoGetVariables: boolean read fAutoGetVariables write fAutoGetVariables;
property commandsHistory: TStringList read fCommandsHistory write setCommandsHistory;
property ignoredSignals: TStringList read fIgnoredSignals write setIgnoredSignals; property ignoredSignals: TStringList read fIgnoredSignals write setIgnoredSignals;
property showOutput: boolean read fShowOutput write fShowOutput; property showOutput: boolean read fShowOutput write fShowOutput;
public public
@ -198,7 +205,7 @@ type
btnStart: TCEToolButton; btnStart: TCEToolButton;
btnStop: TCEToolButton; btnStop: TCEToolButton;
button4: TCEToolButton; button4: TCEToolButton;
Edit1: TEdit; Edit1: TComboBox;
lstCallStack: TListView; lstCallStack: TListView;
Panel2: TPanel; Panel2: TPanel;
Panel3: TPanel; Panel3: TPanel;
@ -243,6 +250,7 @@ type
procedure gdbCommand(aCommand: string; gdboutProcessor: TNotifyEvent = nil); procedure gdbCommand(aCommand: string; gdboutProcessor: TNotifyEvent = nil);
procedure infoRegs; procedure infoRegs;
procedure infoStack; procedure infoStack;
procedure sendCustomCommand;
// //
procedure projNew(project: ICECommonProject); procedure projNew(project: ICECommonProject);
procedure projChanged(project: ICECommonProject); procedure projChanged(project: ICECommonProject);
@ -281,11 +289,13 @@ begin
fAutoGetVariables:= true; fAutoGetVariables:= true;
fShowOutput:=true; fShowOutput:=true;
fIgnoredSignals := TStringList.Create; fIgnoredSignals := TStringList.Create;
fCommandsHistory := TStringList.Create;
end; end;
destructor TCEDebugOptionsBase.destroy; destructor TCEDebugOptionsBase.destroy;
begin begin
fIgnoredSignals.Free; fIgnoredSignals.Free;
fCommandsHistory.Free;
inherited; inherited;
end; end;
@ -294,6 +304,11 @@ begin
fIgnoredSignals.Assign(value); fIgnoredSignals.Assign(value);
end; end;
procedure TCEDebugOptionsBase.setCommandsHistory(value: TStringList);
begin
fCommandsHistory.Assign(value);
end;
procedure TCEDebugOptionsBase.assign(source: TPersistent); procedure TCEDebugOptionsBase.assign(source: TPersistent);
var var
src: TCEDebugOptionsBase; src: TCEDebugOptionsBase;
@ -307,6 +322,7 @@ begin
fAutoGetVariables:=src.autoGetVariables; fAutoGetVariables:=src.autoGetVariables;
fShowOutput:=src.fShowOutput; fShowOutput:=src.fShowOutput;
fIgnoredSignals.Assign(src.fIgnoredSignals); fIgnoredSignals.Assign(src.fIgnoredSignals);
fCommandsHistory.Assign(src.fCommandsHistory);
end end
else inherited; else inherited;
end; end;
@ -501,13 +517,15 @@ begin
fStackItems := TStackItems.create; fStackItems := TStackItems.create;
fSubj:= TCEDebugObserverSubject.Create; fSubj:= TCEDebugObserverSubject.Create;
fOptions:= TCEDebugOptions.create(self); fOptions:= TCEDebugOptions.create(self);
Edit1.Items.Assign(fOptions.commandsHistory);
// //
// TODO-cGDB: add command history
AssignPng(btnSendCom, 'ACCEPT'); AssignPng(btnSendCom, 'ACCEPT');
end; end;
destructor TCEGdbWidget.destroy; destructor TCEGdbWidget.destroy;
begin begin
fOptions.commandsHistory.Assign(edit1.Items);
fOptions.Free;
fFileLineBrks.Free; fFileLineBrks.Free;
fLog.Free; fLog.Free;
killGdb; killGdb;
@ -717,7 +735,7 @@ begin
end; end;
{$ENDREGION} {$ENDREGION}
{$REGIOn GDB output processors -------------------------------------------------} {$REGION GDB output processors -------------------------------------------------}
procedure parseGdbout(const str: string; var json: TJSONObject); procedure parseGdbout(const str: string; var json: TJSONObject);
procedure parseProperty(node: TJSONObject; r: PStringRange); forward; procedure parseProperty(node: TJSONObject; r: PStringRange); forward;
@ -873,10 +891,8 @@ begin
begin begin
parseCLI(json, rng.popFront); parseCLI(json, rng.popFront);
end; end;
// what would be output in a console by the debugee
// ...
end; end;
// line is not interesting // else line is not interesting
rng.popUntil(#10); rng.popUntil(#10);
if not rng.empty then if not rng.empty then
rng.popFront; rng.popFront;
@ -1123,13 +1139,11 @@ end;
procedure TCEGdbWidget.infoRegs; procedure TCEGdbWidget.infoRegs;
begin begin
// GDBMI output format, "info registers" is for CLI output
gdbCommand('-data-list-register-values d', @gdboutJsonize); gdbCommand('-data-list-register-values d', @gdboutJsonize);
end; end;
procedure TCEGdbWidget.infoStack; procedure TCEGdbWidget.infoStack;
begin begin
// GDBMI output format, "info frame" is for CLI output
gdbCommand('-stack-list-frames', @gdboutJsonize); gdbCommand('-stack-list-frames', @gdboutJsonize);
end; end;
@ -1163,6 +1177,11 @@ begin
infoRegs; infoRegs;
end; end;
procedure TCEGdbWidget.btnStackClick(Sender: TObject);
begin
infoStack;
end;
procedure TCEGdbWidget.btnStopClick(Sender: TObject); procedure TCEGdbWidget.btnStopClick(Sender: TObject);
begin begin
pauseDebugee; pauseDebugee;
@ -1172,22 +1191,29 @@ end;
procedure TCEGdbWidget.btnSendComClick(Sender: TObject); procedure TCEGdbWidget.btnSendComClick(Sender: TObject);
begin begin
gdbCommand(edit1.Text, @gdboutJsonize); sendCustomCommand;
edit1.Text := '';
end;
procedure TCEGdbWidget.btnStackClick(Sender: TObject);
begin
infoStack;
end; end;
procedure TCEGdbWidget.Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); procedure TCEGdbWidget.Edit1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin begin
if Key <> byte(#13) then exit; if Key = byte(#13) then
gdbCommand(edit1.Text, @gdboutJsonize); sendCustomCommand;
end;
procedure TCEGdbWidget.sendCustomCommand;
var
cmd: string;
begin
cmd := edit1.Text;
if cmd.isBlank or cmd.isEmpty then
exit;
gdbCommand(cmd, @gdboutJsonize);
if edit1.Items.IndexOf(cmd) = -1 then
edit1.Items.Add(cmd);
edit1.Text := ''; edit1.Text := '';
end; end;
{$ENDREGION} {$ENDREGION}
initialization initialization
RegisterPropertyEditor(TypeInfo(TCpuRegValue), nil, '', TCpuRegValueEditor); RegisterPropertyEditor(TypeInfo(TCpuRegValue), nil, '', TCpuRegValueEditor);
end. end.