added a toyi widget for win32 cdb (ms debugging tool)

This commit is contained in:
Basile Burg 2014-11-03 12:39:34 +01:00
parent 1791623aee
commit 5de7c44696
6 changed files with 513 additions and 245 deletions

View File

@ -140,7 +140,7 @@
<PackageName Value="LCL"/>
</Item6>
</RequiredPackages>
<Units Count="28">
<Units Count="29">
<Unit0>
<Filename Value="coedit.lpr"/>
<IsPartOfProject Value="True"/>
@ -317,6 +317,14 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="ce_procinput"/>
</Unit27>
<Unit28>
<Filename Value="..\src\ce_cdbcmd.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="CECdbWidget"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="ce_cdbcmd"/>
</Unit28>
</Units>
</ProjectOptions>
<CompilerOptions>

271
src/ce_cdbcmd.lfm Normal file
View File

@ -0,0 +1,271 @@
inherited CECdbWidget: TCECdbWidget
Left = 1404
Height = 589
Top = 2
Width = 496
Caption = 'CDB commander'
ClientHeight = 589
ClientWidth = 496
inherited Back: TPanel
Height = 589
Width = 496
ClientHeight = 589
ClientWidth = 496
inherited Content: TPanel
Height = 589
Width = 496
ClientHeight = 589
ClientWidth = 496
object txtCdbCmd: TEdit[0]
Left = 4
Height = 23
Hint = 'CDB command field'
Top = 562
Width = 488
Align = alBottom
BorderSpacing.Around = 4
OnKeyPress = txtCdbCmdKeyPress
TabOrder = 0
end
object Panel1: TPanel[1]
Left = 4
Height = 26
Top = 4
Width = 488
Align = alTop
BorderSpacing.Around = 4
BevelOuter = bvNone
ClientHeight = 26
ClientWidth = 488
TabOrder = 1
object btnGo: TSpeedButton
Left = 60
Height = 26
Hint = 'resume execution'
Top = 0
Width = 30
Align = alLeft
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF000000000000000000000000000000000000000024000000330000
002F000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0000000000000000000000000000000000007D41C100C684FF0086
46ED000000290000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0000000024000000330000003300000033008847FF00E4A6FF00BE
80FF008345D90000002100000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00007D41C1008A48FF008847FF008746FF008847FF00D9A1FF00D8
A0FF00BC80FF007C41B900000022FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00008947FF43E8C2FF00D7A0FF00D7A0FF00D59FFF00D09CFF00D0
9CFF00D39FFF00B981FF007E43BDFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00008845FF6FE8D0FF00C899FF00C899FF00C899FF00C797FF00C8
98FF00CA9AFF63E6CDFF008A47FFFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00008946FF99F0E4FF4FE9D5FF51E8D4FF4DE6D1FF94E8D8FF00C3
97FF60E0C7FF00B281FF008B49ACFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00008847B2008946FF008744FF008642FF008847FF82E4D6FF5ADA
C4FF00AD7FFF008947A700000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0000000000000000000000000000000000008847FF7AE4D8FF00AA
7FFF008946CF0000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0000000000000000000000000000000000008847B200AA85FF008A
46E9000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
OnClick = btnGoClick
ShowCaption = False
end
object btnStop: TSpeedButton
Left = 30
Height = 26
Hint = 'stop debugging'
Top = 0
Width = 30
Align = alLeft
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF003941D64C444BD9D2474FDAF0434BD9E94048D7E93E47
D8F0353ED5D2252ED254232BD206FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF004148D74C636CE4E48997FAFF8495FFFF7F90FCFF7D8EFAFF7D8D
F7FF7D8BF2FF5159DDFF222AD173FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF004E56DA4D6C75E4DF96A5FAFF5A74FFFF3250FFFF304FFFFF2C49FEFF2542
FAFF4860F9FF8694F4FF5159DDDC252ED14DFFFFFF00FFFFFF00FFFFFF005E65
DE4B7981E7E59FADFBFF6781FFFF405EFFFF405EFFFF3C59FFFF3755FFFF3350
FFFF2846FDFF4A65FDFF8996F6FF545EDEE52C34D44BFFFFFF00FFFFFF007178
E3D5A2B2FCFF738FFFFF4F70FFFF4F6EFFFF4B69FFFF4664FFFF415EFFFF3C5A
FFFF3755FFFF2C4BFFFF4E67FFFF8493FAFF4048D8D5FFFFFF00FFFFFF007D84
E5F2A6BBFFFF5F7FFFFF5F7EFFFF5A79FFFF5573FFFF506EFFFF4B69FFFF4664
FFFF415EFFFF3B59FFFF314FFFFF8799FFFF4D55DBF2FFFFFF00FFFFFF00858A
E6E9ABBEFFFF6D8DFFFF6989FFFF6583FFFF5F7EFFFF5A79FFFF5574FFFF506F
FFFF4B69FFFF4663FFFF3F5CFFFF8A9BFFFF535BDCE9FFFFFF00FFFFFF008B91
E7EAB1C4FFFF7698FFFF7393FFFF6E8EFFFF6989FFFF6583FFFF5F7EFFFF5A79
FFFF5573FFFF4F6EFFFF4867FFFF90A1FFFF5A62DEEAFFFFFF00FFFFFF009298
E9F2B8CDFFFF7DA0FFFF7C9DFFFF7899FFFF7393FFFF6E8EFFFF6989FFFF6583
FFFF607EFFFF5978FFFF4F70FFFF98AAFFFF636AE0F2FFFFFF00FFFFFF00959A
EAD4BCCDFCFF9CBBFFFF81A5FFFF81A2FFFF7C9EFFFF7899FFFF7493FFFF6F8E
FFFF6989FFFF6080FFFF7893FFFF9EADFBFF656CE0D4FFFFFF00FFFFFF009297
E84AA5ACEFE4C1D1FCFFA0BFFFFF86AAFFFF85A7FFFF81A2FFFF7C9DFFFF7898
FFFF6F90FFFF85A1FFFFACBAFBFF838BE8E46369DF4AFFFFFF00FFFFFF00FFFF
FF009396E849A6ADEEDFC4D4FCFFA3C2FFFF8BAFFFFF89ABFFFF84A7FFFF7EA0
FFFF91AEFFFFB4C3FBFF8C93EADB6D71E04AFFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF009498E84AA9B1F0E4C2D3FCFFC1D6FFFFBDD1FFFFBBCFFFFFB9CE
FFFFB7C8FCFF989FEDFF797EE272FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00999DEA4B9EA3EBD2A0A5ECF09DA2EBE99BA0EBE9989E
EAF09297E9D2868BE6538388E506FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
}
OnClick = btnStopClick
ShowCaption = False
end
object btnStart: TSpeedButton
Left = 0
Height = 26
Hint = 'start debuggin'
Top = 0
Width = 30
Align = alLeft
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
FF00000000000000003300000030000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF0000000000329EDEFF319CDBF10000002D0000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF0000000000329AD8C4329DDEFF2F98D7E90000003300000006000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF0000000000339EDE5A329BDDFF67C6EEFF369FDEFF133D574A000000050000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF000000000000000000319ADBFF83D7F3FF89E4FAFF349CDCFF133951490000
001200000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF0000000000000000003196D7BA57BEEAFFA9F5FFFF7BDEF8FF369CDCFF2772
A17B00000011000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00000000330000003321648F6B42A9E2FFBDF5FEFF81E7FBFF76DBF6FF379B
DCFF276F9E790000001A0000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00389BDCFF48ACE4FF45A9E2FF3FA5E1FFBDF3FDFF7FE4F8FF7AE3FAFF70D9
F5FF42A5E0FF2E81B7990000002200000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF003799DBFF9EF1FDFF80E5F9FF73E0F9FF6FDEF7FF6DDCF7FF6EDDF7FF71E0
F9FF70DFF8FF40A6E0FF358DC8B900000023FFFFFF00FFFFFF00FFFFFF00FFFF
FF003794D6D285DCF5FF89E5F8FF68DAF6FF68DAF6FFB9F0FCFFB8F2FDFFB4F2
FCFFA9F1FDFFABF1FCFF44A9E2FF3890CBBFFFFFFF00FFFFFF00FFFFFF00FFFF
FF003993D2856DC5ECFF9CE8FAFF5FD6F4FF61D7F4FF46B4E6FF3191D8FF3595
DAFF3797DAFF3A99DBFF3E9CDCFF409EDDFFFFFFFF00FFFFFF00FFFFFF00FFFF
FF003E9BDC324CAEE4FFB0EEFBFF66D8F4FF57D3F3FFACEDFBFF63B4E5FF2D77
AB8900000001000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00000000003B9ADAFFACEEFBFF82DDF5FF4CCEF1FF82DFF6FFABE6F8FF3996
D9FF0711182D000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00000000003C94D5D28BDAF3FFACEAF9FF3FCBF0FF45CDF0FFBBF0FBFF6DBA
E7FF3B93D0D90000000E0000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00000000003E93D1876CC5EBFFD7FAFFFFCDF6FDFFC3F3FDFFD2F8FFFFC6F1
FBFF409ADAFF2D67916D0000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF0000000000479CDC3A439ADAFF3F97D9FF3E96D9FF3E96D9FF3E97D9FF4099
DAFF459CDBFF489EDCFF0000000000000000FFFFFF00FFFFFF00
}
OnClick = btnStartClick
ShowCaption = False
end
object btnStep: TSpeedButton
Left = 90
Height = 26
Hint = 'next instruction'
Top = 0
Width = 30
Align = alLeft
Glyph.Data = {
42020000424D4202000000000000420000002800000010000000100000000100
100003000000000200006400000064000000000000000000000000F80000E007
00001F000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAE73EF7B0000000000004D6B9294FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF7B18C6CF7B000000006D6B14A5FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF7B9AD6FBDECF7B00008E7334A5FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF7B18C6F7BD5DEFEF7BAE7355ADFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF7B96B575AD7DEFEF7BCF7B55ADFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF7B14A51CE7CF7B0000EF7B75ADFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF7B1CE7CF7B00000000108496B5FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1084EF7B0000000000003084B6B5FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFF
}
OnClick = btnStepClick
ShowCaption = False
end
object btnDisasm: TSpeedButton
Left = 120
Height = 26
Hint = 'disasm'
Top = 0
Width = 30
Align = alLeft
Glyph.Data = {
42020000424D4202000000000000420000002800000010000000100000000100
100003000000000200006400000064000000000000000000000000F80000E007
00001F0000000000000000000000000000000000000000000000000000000000
00000000FFFFCF7BD39CD39CD39CD39CD39CD39CD39CD39CD39CD39CD39CD39C
D39C3084FFFFD39CDFFFBEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7
DFFFD39CFFFFD39C9EF75DEF5DEF5DEF7DEF9EF79EF79EF77DEF5DEF5DEF5DEF
9EF7D39CFFFFD39C7DEF3CE73CE75DEFEB5A0C632C630C63EB5A5DEF3CE73CE7
7DEFD39CFFFFD39C7DEFFBDEFBDE1CE7DFFFFFFFFFFFFFFFDFFF3CE71CE7FBDE
7DEFD39CFFFFD39C5DEFDBDEDBDE1CE78A52AA52AA52AA52AA528A521CE7FBDE
5DEFD39CFFFFD39C5DEFBAD6BAD6DBDEDFFFFFFFFFFFFFFFFFFFBEF7FBDEDBDE
7DEFD39CFFFFD39C5DEF9AD6BAD6DBDE2842494A494A494A494A28420842BAD6
5DEFD39CFFFFD39C5DEF79CEBAD6DBDEDFFFFFFFFFFFDFFFBEF79EF75DEF79CE
5DEFD39CFFFFD39C7DEF79CEA631C739C739C739C739A63179CE59CE59CE38C6
5DEFD39CFFFFD39C7DEF38C69EF79EF79EF79EF79EF75DEF38C638C638C618C6
7DEFD39CFFFFD39C7DEFF7BDF7BDF7BDF7BDF7BDF7BDF7BDF7BDF7BDF7BDF7BD
7DEFD39CFFFFD39C9EF7B6B5D7BDD7BDD7BDD7BDD7BDD7BDD7BDD7BDD7BDB6B5
9EF7D39CFFFFD39CDFFFFBDEFBDE1CE71CE71CE71CE71CE71CE71CE7FBDEFBDE
DFFFD39CFFFFF39CD39CD39CD39CD39CD39CD39CD39CD39CD39CD39CD39CD39C
D39CF39CFFFF
}
OnClick = btnDisasmClick
ShowCaption = False
end
end
object lstCdbOut: TListView[2]
Left = 4
Height = 524
Hint = 'CDB output'
Top = 34
Width = 488
Align = alClient
AutoWidthLastColumn = True
BorderSpacing.Left = 4
BorderSpacing.Top = 4
BorderSpacing.Right = 4
BorderSpacing.Bottom = 4
Columns = <
item
Caption = 'CDB output'
Width = 484
end>
Font.Height = -11
Font.Name = 'Lucida Console'
ParentFont = False
TabOrder = 2
ViewStyle = vsReport
end
end
end
inherited contextMenu: TPopupMenu
left = 200
top = 8
end
end

223
src/ce_cdbcmd.pas Normal file
View File

@ -0,0 +1,223 @@
unit ce_cdbcmd;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
process, Menus, StdCtrls, ce_widget, ce_project, ce_interfaces, ce_observer,
asyncprocess, ComCtrls, Buttons, ce_common;
type
{ TCECdbWidget }
TCECdbWidget = class(TCEWidget, ICEProjectObserver)
btnGo: TSpeedButton;
btnStep: TSpeedButton;
btnDisasm: TSpeedButton;
btnStop: TSpeedButton;
btnStart: TSpeedButton;
txtCdbCmd: TEdit;
lstCdbOut: TListView;
Panel1: TPanel;
procedure btnDisasmClick(Sender: TObject);
procedure btnGoClick(Sender: TObject);
procedure btnStartClick(Sender: TObject);
procedure btnStepClick(Sender: TObject);
procedure btnStopClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure txtCdbCmdKeyPress(Sender: TObject; var Key: char);
private
fCdbProc: TAsyncProcess;
fProject: TCEProject;
procedure cdbOutput(sender: TObject);
procedure cdbTerminate(sender: TObject);
procedure cdbOutputToGui;
procedure cdbFree;
public
constructor create(aOwner: TComponent); override;
destructor destroy; override;
//
procedure projNew(const aProject: TCEProject);
procedure projClosing(const aProject: TCEProject);
procedure projFocused(const aProject: TCEProject);
procedure projChanged(const aProject: TCEProject);
end;
implementation
{$R *.lfm}
uses
ce_main;
{$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCECdbWidget.create(aOwner: TComponent);
begin
inherited;
Enabled := exeInSysPath('cdb');
if Enabled then
EntitiesConnector.addObserver(self);
end;
destructor TCECdbWidget.destroy;
begin
if Enabled then begin
cdbFree;
EntitiesConnector.removeObserver(self);
end;
inherited;
end;
{$ENDREGION --------------------------------------------------------------------}
{$REGION ICEProjectMonitor -----------------------------------------------------}
procedure TCECdbWidget.projNew(const aProject: TCEProject);
begin
fProject := aProject;
end;
procedure TCECdbWidget.projClosing(const aProject: TCEProject);
begin
fProject := nil;
end;
procedure TCECdbWidget.projFocused(const aProject: TCEProject);
begin
fProject := aProject;
end;
procedure TCECdbWidget.projChanged(const aProject: TCEProject);
begin
fProject := aProject;
end;
{$ENDREGION --------------------------------------------------------------------}
procedure TCECdbWidget.btnStartClick(Sender: TObject);
var
outname: string;
begin
if fProject = nil then exit;
outname := fProject.outputFilename;
if not fileExists(outname) then exit;
//
cdbFree;
fCdbProc := TAsyncProcess.create(nil);
fCdbProc.Executable := 'cdb';
fCdbProc.Parameters.Add('-c');
fCdbProc.Parameters.Add('"l+*;.lines"');
fCdbProc.Parameters.Add(outname);
fCdbProc.CurrentDirectory := extractFilePath(outname);
fCdbProc.Options := [poNoConsole, poStderrToOutPut, poUsePipes];
fCdbProc.OnReadData := @cdbOutput;
fCdbProc.OnTerminate := @cdbTerminate;
//
fCdbProc.Execute;
end;
procedure TCECdbWidget.btnStepClick(Sender: TObject);
const
cmd = 'p'#13#10;
begin
if fCdbProc = nil then exit;
fCdbProc.Input.Write(cmd[1], length(cmd));
end;
procedure TCECdbWidget.btnGoClick(Sender: TObject);
const
cmd = 'g'#13#10;
begin
if fCdbProc = nil then exit;
fCdbProc.Input.Write(cmd[1], length(cmd));
end;
procedure TCECdbWidget.btnDisasmClick(Sender: TObject);
const
cmd = 'u'#13#10;
begin
if fCdbProc = nil then exit;
fCdbProc.Input.Write(cmd[1], length(cmd));
end;
procedure TCECdbWidget.btnStopClick(Sender: TObject);
begin
cdbFree;
end;
procedure TCECdbWidget.Button2Click(Sender: TObject);
begin
end;
procedure TCECdbWidget.txtCdbCmdKeyPress(Sender: TObject; var Key: char);
var
inp: string;
begin
if (fCdbProc = nil) or (key <> #13) then
exit;
//
inp := CEMainForm.expandSymbolicString(txtCdbCmd.Text) + LineEnding;
fCdbProc.Input.Write(inp[1], length(inp));
//
inp := lstCdbOut.Items.Item[lstCdbOut.Items.Count-1].Caption;
inp += CEMainForm.expandSymbolicString(txtCdbCmd.Text);
lstCdbOut.Items.Item[lstCdbOut.Items.Count-1].Caption := inp;
//
txtCdbCmd.Text := '';
end;
procedure TCECdbWidget.cdbOutputToGui;
var
str: TMemoryStream;
lst: TStringList;
cnt: Integer;
sum: Integer;
begin
if fCdbProc = nil then exit;
cnt := 0;
sum := 0;
str := TMemoryStream.Create;
lst := TStringList.Create;
while fCdbProc.Output.NumBytesAvailable <> 0 do
begin
str.Size := str.Size + 1024;
cnt := fCdbProc.Output.Read((str.Memory + sum)^, 1024);
sum += cnt;
end;
str.Size := sum;
lst.LoadFromStream(str);
for cnt := 0 to lst.Count-1 do
lstCdbOut.AddItem(lst.Strings[cnt], nil);
lstCdbOut.Items[lstCdbOut.Items.Count-1].MakeVisible(true);
lst.Free;
str.Free;
end;
procedure TCECdbWidget.cdbOutput(sender: TObject);
begin
cdbOutputToGui;
end;
procedure TCECdbWidget.cdbTerminate(sender: TObject);
begin
cdbOutputToGui;
cdbFree;
end;
procedure TCECdbWidget.cdbFree;
begin
if fCdbProc = nil then
exit;
//
if fCdbProc.Running then
fCdbProc.Terminate(0);
fCdbProc.Free;
fCdbProc := nil;
end;
end.

View File

@ -1,80 +0,0 @@
inherited CEWidget1: TCEWidget1
Left = 874
Height = 589
Top = 248
Width = 499
ClientHeight = 589
ClientWidth = 499
inherited Back: TPanel
Height = 589
Width = 499
ClientHeight = 589
ClientWidth = 499
inherited Content: TPanel
Height = 589
Width = 499
ClientHeight = 589
ClientWidth = 499
object lstGdbOut: TMemo[0]
Left = 4
Height = 524
Top = 61
Width = 491
Align = alClient
BorderSpacing.Around = 4
Font.Height = -12
Font.Name = 'Lucida Console'
ParentFont = False
ReadOnly = True
ScrollBars = ssBoth
TabOrder = 0
end
object Edit1: TEdit[1]
Left = 4
Height = 23
Top = 34
Width = 491
Align = alTop
BorderSpacing.Around = 4
OnKeyPress = Edit1KeyPress
TabOrder = 1
end
object Panel1: TPanel[2]
Left = 4
Height = 26
Top = 4
Width = 491
Align = alTop
BorderSpacing.Around = 4
Caption = 'Panel1'
ClientHeight = 26
ClientWidth = 491
TabOrder = 2
object Button1: TButton
Left = 8
Height = 25
Top = 0
Width = 75
Caption = 'start'
OnClick = Button1Click
TabOrder = 0
end
object Button2: TButton
Left = 88
Height = 25
Top = 0
Width = 75
Caption = 'stop'
OnClick = Button2Click
TabOrder = 1
end
end
end
end
object IdleTimer1: TIdleTimer[2]
Interval = 100
OnTimer = IdleTimer1Timer
left = 211
top = 16
end
end

View File

@ -1,163 +0,0 @@
unit ce_gdbcmd;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, process,
Menus, StdCtrls, ce_widget, ce_project, ce_interfaces, ce_observer, asyncprocess;
type
{ TCEWidget1 }
TCEWidget1 = class(TCEWidget, ICEProjectObserver)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
IdleTimer1: TIdleTimer;
lstGdbOut: TMemo;
Panel1: TPanel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: char);
procedure IdleTimer1Timer(Sender: TObject);
private
fGdbProc: TProcess;
fProject: TCEProject;
procedure gdbReadData(sender: TObject);
public
constructor create(aOwner: TComponent); override;
destructor destroy; override;
//
procedure projNew(const aProject: TCEProject);
procedure projClosing(const aProject: TCEProject);
procedure projFocused(const aProject: TCEProject);
procedure projChanged(const aProject: TCEProject);
end;
implementation
{$R *.lfm}
{$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCEWidget1.create(aOwner: TComponent);
begin
inherited;
//
EntitiesConnector.addObserver(self);
end;
destructor TCEWidget1.destroy;
begin
EntitiesConnector.removeObserver(self);
inherited;
end;
{$ENDREGION --------------------------------------------------------------------}
{$REGION ICEProjectMonitor -----------------------------------------------------}
procedure TCEWidget1.projNew(const aProject: TCEProject);
begin
fProject := aProject;
end;
procedure TCEWidget1.projClosing(const aProject: TCEProject);
begin
fProject := nil;
end;
procedure TCEWidget1.projFocused(const aProject: TCEProject);
begin
fProject := aProject;
end;
procedure TCEWidget1.projChanged(const aProject: TCEProject);
begin
fProject := aProject;
end;
{$ENDREGION --------------------------------------------------------------------}
procedure TCEWidget1.Button1Click(Sender: TObject);
var
outname: string;
begin
if fProject = nil then exit;
outname := fProject.outputFilename;
if not fileExists(outname) then exit;
//
fGdbProc := TProcess.create(nil);
fGdbProc.Executable := 'cdb';
fGdbProc.Parameters.Add('-c');
fGdbProc.Parameters.Add('"l+*;.lines"');
fGdbProc.Parameters.Add(outname);
fGdbProc.CurrentDirectory := extractFilePath(outname);
fGdbProc.Options := fGdbProc.Options + [poStderrToOutPut, poUsePipes];
//fGdbProc.OnReadData := @gdbReadData;
fGdbProc.Execute;
end;
procedure TCEWidget1.Button2Click(Sender: TObject);
begin
if fGdbProc = nil then exit;
fGdbProc.Terminate(0);
fGdbProc.Free;
fGdbProc := nil;
end;
procedure TCEWidget1.Edit1KeyPress(Sender: TObject; var Key: char);
var
inp: string;
begin
if fGdbProc <> nil then
if Key = LineEnding[1] then
begin
inp := Edit1.Text + LineEnding;
fGdbProc.Input.Write( inp[1], length(inp) );
end;
Edit1.Text := '';
end;
procedure TCEWidget1.IdleTimer1Timer(Sender: TObject);
begin
gdbReadData(nil);
end;
procedure TCEWidget1.gdbReadData(sender: TObject);
var
str: TMemoryStream;
lst: TStringList;
cnt: Integer;
sum: Integer;
begin
if fGdbProc = nil then exit;
cnt := 0;
sum := 0;
str := TMemoryStream.Create;
lst := TStringList.Create;
while fGdbProc.Output.NumBytesAvailable <> 0 do
begin
str.Size := str.Size + 1024;
cnt := fGdbProc.Output.Read((str.Memory + sum)^, 1024);
sum += cnt;
end;
// cnt = 0;
str.Size := sum;
lst.LoadFromStream(str);
lstGdbOut.Lines.AddStrings(lst);
lstGdbOut.VertScrollBar.Position := lstGdbOut.Lines.Count * 53;
lst.Free;
str.Free;
end;
end.

View File

@ -11,7 +11,7 @@ uses
ce_common, ce_dmdwrap, ce_project, ce_dcd, ce_plugin, ce_synmemo, ce_widget,
ce_messages, ce_interfaces, ce_editor, ce_projinspect, ce_projconf, ce_search,
ce_staticexplorer, ce_miniexplorer, ce_libman, ce_libmaneditor, ce_customtools,
ce_observer, ce_writableComponent, ce_toolseditor, ce_procinput;
ce_observer, ce_writableComponent, ce_toolseditor, ce_procinput, ce_cdbcmd;
type
@ -190,6 +190,7 @@ type
fFileMru: TMruFileList;
fLibMan: TLibraryManager;
fPrInpWidg: TCEProcInputWidget;
fCdbWidg: TCECdbWidget;
fTools: TCETools;
fRunProc: TAsyncProcess;
@ -465,6 +466,10 @@ begin
fTlsEdWidg:= TCEToolsEditorWidget.create(self);
fPrInpWidg:= TCEProcInputWidget.create(self);
{$IFDEF WIN32}
fCdbWidg := TCECdbWidget.create(self);
{$ENDIF}
fWidgList.addWidget(@fMesgWidg);
fWidgList.addWidget(@fEditWidg);
fWidgList.addWidget(@fProjWidg);
@ -476,6 +481,10 @@ begin
fWidgList.addWidget(@fTlsEdWidg);
fWidgList.addWidget(@fPrInpWidg);
{$IFDEF WIN32}
fWidgList.addWidget(@fCdbWidg);
{$ENDIF}
for widg in fWidgList do
begin
act := TAction.Create(self);