mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 00:59:21 +02:00
parent
a7568024f7
commit
fa76b5032d
@ -1,84 +1,114 @@
|
||||
object HeapTrcViewForm: THeapTrcViewForm
|
||||
Left = 730
|
||||
Height = 298
|
||||
Top = 134
|
||||
Width = 387
|
||||
Left = 399
|
||||
Height = 402
|
||||
Top = 139
|
||||
Width = 447
|
||||
ActiveControl = btnBrowse
|
||||
Caption = 'HeapTrcViewForm'
|
||||
ClientHeight = 298
|
||||
ClientWidth = 387
|
||||
ClientHeight = 402
|
||||
ClientWidth = 447
|
||||
FormStyle = fsStayOnTop
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
LCLVersion = '0.9.27'
|
||||
LCLVersion = '0.9.29'
|
||||
object lblTrcFile: TLabel
|
||||
Left = 16
|
||||
Height = 18
|
||||
Top = 16
|
||||
Width = 44
|
||||
Width = 45
|
||||
Caption = '.trc file'
|
||||
ParentColor = False
|
||||
end
|
||||
object edtTrcFileName: TEdit
|
||||
Left = 72
|
||||
Height = 23
|
||||
Height = 22
|
||||
Top = 16
|
||||
Width = 251
|
||||
Width = 311
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnUpdate: TButton
|
||||
Left = 16
|
||||
Height = 29
|
||||
Height = 20
|
||||
Top = 54
|
||||
Width = 59
|
||||
Width = 70
|
||||
AutoSize = True
|
||||
Caption = 'Update'
|
||||
OnClick = btnUpdateClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object trvTraceInfo: TTreeView
|
||||
Left = 16
|
||||
Height = 191
|
||||
Top = 88
|
||||
Width = 355
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
DefaultItemHeight = 19
|
||||
ReadOnly = True
|
||||
TabOrder = 2
|
||||
OnDblClick = trvTraceInfoDblClick
|
||||
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
|
||||
end
|
||||
object chkStayOnTop: TCheckBox
|
||||
Left = 269
|
||||
Height = 22
|
||||
Left = 335
|
||||
Height = 18
|
||||
Top = 56
|
||||
Width = 98
|
||||
Width = 92
|
||||
Anchors = [akTop, akRight]
|
||||
Caption = 'Stay on top'
|
||||
OnChange = chkStayOnTopChange
|
||||
OnClick = chkStayOnTopClick
|
||||
TabOrder = 3
|
||||
TabOrder = 2
|
||||
end
|
||||
object btnBrowse: TButton
|
||||
Left = 339
|
||||
Left = 399
|
||||
Height = 20
|
||||
Top = 14
|
||||
Width = 32
|
||||
Anchors = [akTop, akRight]
|
||||
Caption = '...'
|
||||
OnClick = btnBrowseClick
|
||||
TabOrder = 4
|
||||
TabOrder = 3
|
||||
end
|
||||
object chkUseRaw: TCheckBox
|
||||
Left = 99
|
||||
Height = 22
|
||||
Height = 18
|
||||
Top = 56
|
||||
Width = 112
|
||||
Width = 107
|
||||
Caption = 'Raw leak data'
|
||||
Checked = True
|
||||
OnChange = chkUseRawChange
|
||||
State = cbChecked
|
||||
TabOrder = 4
|
||||
end
|
||||
object ctrlPanel: TPanel
|
||||
Left = 16
|
||||
Height = 283
|
||||
Top = 96
|
||||
Width = 415
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 283
|
||||
ClientWidth = 415
|
||||
TabOrder = 5
|
||||
object trvTraceInfo: TTreeView
|
||||
Left = 0
|
||||
Height = 197
|
||||
Top = 0
|
||||
Width = 415
|
||||
Align = alClient
|
||||
DefaultItemHeight = 19
|
||||
ReadOnly = True
|
||||
TabOrder = 0
|
||||
OnDblClick = trvTraceInfoDblClick
|
||||
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
|
||||
end
|
||||
object memoSummary: TMemo
|
||||
Left = 0
|
||||
Height = 81
|
||||
Top = 202
|
||||
Width = 415
|
||||
Align = alBottom
|
||||
ReadOnly = True
|
||||
ScrollBars = ssVertical
|
||||
TabOrder = 1
|
||||
end
|
||||
object splitter: TSplitter
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
Height = 5
|
||||
Top = 197
|
||||
Width = 415
|
||||
Align = alBottom
|
||||
ResizeAnchor = akBottom
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,29 +1,36 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('THeapTrcViewForm','FORMDATA',[
|
||||
'TPF0'#16'THeapTrcViewForm'#15'HeapTrcViewForm'#4'Left'#3#218#2#6'Height'#3'*'
|
||||
+#1#3'Top'#3#134#0#5'Width'#3#131#1#13'ActiveControl'#7#9'btnBrowse'#7'Captio'
|
||||
+'n'#6#15'HeapTrcViewForm'#12'ClientHeight'#3'*'#1#11'ClientWidth'#3#131#1#9
|
||||
+'FormStyle'#7#11'fsStayOnTop'#8'OnCreate'#7#10'FormCreate'#9'OnDestroy'#7#11
|
||||
+'FormDestroy'#10'LCLVersion'#6#6'0.9.27'#0#6'TLabel'#10'lblTrcFile'#4'Left'#2
|
||||
+#16#6'Height'#2#18#3'Top'#2#16#5'Width'#2','#7'Caption'#6#9'.trc file'#11'Pa'
|
||||
+'rentColor'#8#0#0#5'TEdit'#14'edtTrcFileName'#4'Left'#2'H'#6'Height'#2#23#3
|
||||
+'Top'#2#16#5'Width'#3#251#0#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8
|
||||
+'TabOrder'#2#0#0#0#7'TButton'#9'btnUpdate'#4'Left'#2#16#6'Height'#2#29#3'Top'
|
||||
+#2'6'#5'Width'#2';'#8'AutoSize'#9#7'Caption'#6#6'Update'#7'OnClick'#7#14'btn'
|
||||
+'UpdateClick'#8'TabOrder'#2#1#0#0#9'TTreeView'#12'trvTraceInfo'#4'Left'#2#16
|
||||
+#6'Height'#3#191#0#3'Top'#2'X'#5'Width'#3'c'#1#7'Anchors'#11#5'akTop'#6'akLe'
|
||||
+'ft'#7'akRight'#8'akBottom'#0#17'DefaultItemHeight'#2#19#8'ReadOnly'#9#8'Tab'
|
||||
+'Order'#2#2#10'OnDblClick'#7#20'trvTraceInfoDblClick'#7'Options'#11#17'tvoAu'
|
||||
+'toItemHeight'#16'tvoHideSelection'#21'tvoKeepCollapsedNodes'#11'tvoReadOnly'
|
||||
+#14'tvoShowButtons'#12'tvoShowLines'#11'tvoShowRoot'#11'tvoToolTips'#0#0#0#9
|
||||
+'TCheckBox'#12'chkStayOnTop'#4'Left'#3#13#1#6'Height'#2#22#3'Top'#2'8'#5'Wid'
|
||||
+'th'#2'b'#7'Anchors'#11#5'akTop'#7'akRight'#0#7'Caption'#6#11'Stay on top'#8
|
||||
+'OnChange'#7#18'chkStayOnTopChange'#7'OnClick'#7#17'chkStayOnTopClick'#8'Tab'
|
||||
+'Order'#2#3#0#0#7'TButton'#9'btnBrowse'#4'Left'#3'S'#1#6'Height'#2#20#3'Top'
|
||||
+#2#14#5'Width'#2' '#7'Anchors'#11#5'akTop'#7'akRight'#0#7'Caption'#6#3'...'#7
|
||||
+'OnClick'#7#14'btnBrowseClick'#8'TabOrder'#2#4#0#0#9'TCheckBox'#9'chkUseRaw'
|
||||
+#4'Left'#2'c'#6'Height'#2#22#3'Top'#2'8'#5'Width'#2'p'#7'Caption'#6#13'Raw l'
|
||||
+'eak data'#7'Checked'#9#8'OnChange'#7#15'chkUseRawChange'#5'State'#7#9'cbChe'
|
||||
+'cked'#8'TabOrder'#2#5#0#0#0
|
||||
'TPF0'#16'THeapTrcViewForm'#15'HeapTrcViewForm'#4'Left'#3#143#1#6'Height'#3
|
||||
+#146#1#3'Top'#3#139#0#5'Width'#3#191#1#13'ActiveControl'#7#9'btnBrowse'#7'Ca'
|
||||
+'ption'#6#15'HeapTrcViewForm'#12'ClientHeight'#3#146#1#11'ClientWidth'#3#191
|
||||
+#1#9'FormStyle'#7#11'fsStayOnTop'#8'OnCreate'#7#10'FormCreate'#9'OnDestroy'#7
|
||||
+#11'FormDestroy'#10'LCLVersion'#6#6'0.9.29'#0#6'TLabel'#10'lblTrcFile'#4'Lef'
|
||||
+'t'#2#16#6'Height'#2#18#3'Top'#2#16#5'Width'#2'-'#7'Caption'#6#9'.trc file'
|
||||
+#11'ParentColor'#8#0#0#5'TEdit'#14'edtTrcFileName'#4'Left'#2'H'#6'Height'#2
|
||||
+#22#3'Top'#2#16#5'Width'#3'7'#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0
|
||||
+#8'TabOrder'#2#0#0#0#7'TButton'#9'btnUpdate'#4'Left'#2#16#6'Height'#2#20#3'T'
|
||||
+'op'#2'6'#5'Width'#2'F'#8'AutoSize'#9#7'Caption'#6#6'Update'#7'OnClick'#7#14
|
||||
+'btnUpdateClick'#8'TabOrder'#2#1#0#0#9'TCheckBox'#12'chkStayOnTop'#4'Left'#3
|
||||
+'O'#1#6'Height'#2#18#3'Top'#2'8'#5'Width'#2'\'#7'Anchors'#11#5'akTop'#7'akRi'
|
||||
+'ght'#0#7'Caption'#6#11'Stay on top'#8'OnChange'#7#18'chkStayOnTopChange'#7
|
||||
+'OnClick'#7#17'chkStayOnTopClick'#8'TabOrder'#2#2#0#0#7'TButton'#9'btnBrowse'
|
||||
+#4'Left'#3#143#1#6'Height'#2#20#3'Top'#2#14#5'Width'#2' '#7'Anchors'#11#5'ak'
|
||||
+'Top'#7'akRight'#0#7'Caption'#6#3'...'#7'OnClick'#7#14'btnBrowseClick'#8'Tab'
|
||||
+'Order'#2#3#0#0#9'TCheckBox'#9'chkUseRaw'#4'Left'#2'c'#6'Height'#2#18#3'Top'
|
||||
+#2'8'#5'Width'#2'k'#7'Caption'#6#13'Raw leak data'#7'Checked'#9#8'OnChange'#7
|
||||
+#15'chkUseRawChange'#5'State'#7#9'cbChecked'#8'TabOrder'#2#4#0#0#6'TPanel'#9
|
||||
+'ctrlPanel'#4'Left'#2#16#6'Height'#3#27#1#3'Top'#2'`'#5'Width'#3#159#1#7'Anc'
|
||||
+'hors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#10'BevelOuter'#7#6'bvN'
|
||||
+'one'#12'ClientHeight'#3#27#1#11'ClientWidth'#3#159#1#8'TabOrder'#2#5#0#9'TT'
|
||||
+'reeView'#12'trvTraceInfo'#4'Left'#2#0#6'Height'#3#197#0#3'Top'#2#0#5'Width'
|
||||
+#3#159#1#5'Align'#7#8'alClient'#17'DefaultItemHeight'#2#19#8'ReadOnly'#9#8'T'
|
||||
+'abOrder'#2#0#10'OnDblClick'#7#20'trvTraceInfoDblClick'#7'Options'#11#17'tvo'
|
||||
+'AutoItemHeight'#16'tvoHideSelection'#21'tvoKeepCollapsedNodes'#11'tvoReadOn'
|
||||
+'ly'#14'tvoShowButtons'#12'tvoShowLines'#11'tvoShowRoot'#11'tvoToolTips'#0#0
|
||||
+#0#5'TMemo'#11'memoSummary'#4'Left'#2#0#6'Height'#2'Q'#3'Top'#3#202#0#5'Widt'
|
||||
+'h'#3#159#1#5'Align'#7#8'alBottom'#8'ReadOnly'#9#10'ScrollBars'#7#10'ssVerti'
|
||||
+'cal'#8'TabOrder'#2#1#0#0#9'TSplitter'#8'splitter'#6'Cursor'#7#8'crVSplit'#4
|
||||
+'Left'#2#0#6'Height'#2#5#3'Top'#3#197#0#5'Width'#3#159#1#5'Align'#7#8'alBott'
|
||||
+'om'#12'ResizeAnchor'#7#8'akBottom'#0#0#0#0
|
||||
]);
|
||||
|
@ -6,7 +6,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, ComCtrls, LeakInfo, LazIDEIntf, MenuIntf, contnrs;
|
||||
StdCtrls, ComCtrls, ExtCtrls, LeakInfo, LazIDEIntf, MenuIntf, contnrs;
|
||||
|
||||
type
|
||||
TJumpProc = procedure (Sender: TObject; const SourceName: string; Line: integer) of object;
|
||||
@ -19,6 +19,9 @@ type
|
||||
chkStayOnTop: TCheckBox;
|
||||
edtTrcFileName: TEdit;
|
||||
lblTrcFile: TLabel;
|
||||
ctrlPanel: TPanel;
|
||||
memoSummary: TMemo;
|
||||
splitter: TSplitter;
|
||||
trvTraceInfo: TTreeView;
|
||||
procedure btnUpdateClick(Sender: TObject);
|
||||
procedure btnBrowseClick(Sender: TObject);
|
||||
@ -66,9 +69,14 @@ implementation
|
||||
const // resorucestring ?
|
||||
StackTraceFormat = 'Leak: %d bytes x %d times'; // number of bytes leaked, leaks count
|
||||
StackTraceFormatSingle = 'Leak: %d bytes'; // number of bytes leaked
|
||||
StackLineFormatWithFile = '%s line: %d; file: %s'; // stack addr, filename (no path), line number
|
||||
StackLineFormatWithFile = '%s file: %s : %d; '; // stack addr, filename (no path), line number
|
||||
StackLineFormat = '%s'; // stack addr
|
||||
|
||||
strTotalMemAlloc = 'Total Mem alloced: %d';
|
||||
strLeakingMemSize = 'Leaking Mem Size: %d';
|
||||
strLeakingBlocksCount = 'Leaking Blocks Count: %d';
|
||||
|
||||
|
||||
procedure ShowHeapTrcViewForm(JumpProc: TJumpProc);
|
||||
begin
|
||||
if not Assigned(HeapTrcViewForm) then HeapTrcViewForm := THeapTrcViewForm.Create(nil);
|
||||
@ -229,6 +237,14 @@ begin
|
||||
try
|
||||
if info.GetLeakInfo(data, fItems) then ItemsToTree
|
||||
else trvTraceInfo.Items.Add(nil, 'Error while parsing trace file');
|
||||
|
||||
memoSummary.Clear;
|
||||
with memoSummary.Lines do begin
|
||||
Add( Format(strTotalMemAlloc, [data.TotalMem]));
|
||||
Add( Format(strLeakingMemSize, [data.LeakedMem]));
|
||||
Add( Format(strLeakingBlocksCount, [data.LeakCount]));
|
||||
end;
|
||||
|
||||
finally
|
||||
info.Free;
|
||||
end;
|
||||
@ -308,7 +324,7 @@ begin
|
||||
if not useRaw or (Result = '') then
|
||||
with Line do
|
||||
if FileName <> ''
|
||||
then Result := Format(StackLineFormatWithFile, ['$'+IntToHex(Addr, sizeof(Pointer)*2), LineNum, ExtractFileName(FileName)])
|
||||
then Result := Format(StackLineFormatWithFile, ['$'+IntToHex(Addr, sizeof(Pointer)*2), ExtractFileName(FileName), LineNum])
|
||||
else Result := Format(StackLineFormat, ['$'+IntToHex(Addr, sizeof(Pointer)*2)]);
|
||||
end;
|
||||
|
||||
|
@ -74,6 +74,9 @@ type
|
||||
fTRCFile : string;
|
||||
Trc : TStringList;
|
||||
TrcIndex : integer;
|
||||
fSummary : string;
|
||||
|
||||
fParsed : Boolean;
|
||||
|
||||
function PosInTrc(const SubStr: string; CaseSensetive: Boolean = false): Boolean;
|
||||
function TrcNumberAfter(var Num: Int64; const AfterSub: string): Boolean;
|
||||
@ -341,7 +344,7 @@ begin
|
||||
TrcIndex := 0;
|
||||
|
||||
DoParseTrc(Traces);
|
||||
LeakData.LeakCount := TraceInfo.Unfreedblocks;
|
||||
LeakData.LeakCount := TraceInfo.UnfreedBlocks;
|
||||
LeakData.LeakedMem := TraceInfo.UnfreedSize;
|
||||
LeakData.TotalMem := TraceInfo.AllocSize;
|
||||
Result := true;
|
||||
@ -354,6 +357,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{ TStackTrace }
|
||||
|
||||
constructor TStackTrace.Create;
|
||||
|
Loading…
Reference in New Issue
Block a user