IDE: add option Trash variables (-gt) to compiler options and GUI.

git-svn-id: trunk@42223 -
This commit is contained in:
juha 2013-07-29 07:21:18 +00:00
parent 61c1298df5
commit 0df29b9470
6 changed files with 101 additions and 78 deletions

View File

@ -156,6 +156,7 @@ type
procedure SetUseAnsiStr(const AValue: Boolean);
procedure SetUseExternalDbgSyms(const AValue: Boolean);
procedure SetUseHeaptrc(const AValue: Boolean);
procedure SetTrashVariables(const AValue: Boolean);
procedure SetUseLineInfoUnit(const AValue: Boolean);
procedure SetUseValgrind(const AValue: Boolean);
procedure SetUncertainOpt(const AValue: Boolean);
@ -214,6 +215,7 @@ type
FDebugInfoType: TCompilerDbgSymbolType;
fUseLineInfoUnit: Boolean;
fUseHeaptrc: Boolean;
fTrashVariables: Boolean;
fUseValgrind: Boolean;
fGenGProfCode: Boolean;
fStripSymbols: Boolean;
@ -375,6 +377,7 @@ type
property GenerateDwarf: Boolean read GetGenerateDwarf write SetGenerateDwarf; deprecated 'use DebugInfoType';
property UseLineInfoUnit: Boolean read fUseLineInfoUnit write SetUseLineInfoUnit;
property UseHeaptrc: Boolean read fUseHeaptrc write SetUseHeaptrc;
property TrashVariables: Boolean read fTrashVariables write SetTrashVariables;
property UseValgrind: Boolean read fUseValgrind write SetUseValgrind;
property GenGProfCode: Boolean read fGenGProfCode write SetGenGProfCode;
property StripSymbols: Boolean read fStripSymbols write SetStripSymbols;
@ -827,6 +830,13 @@ begin
IncreaseChangeStamp;
end;
procedure TLazCompilerOptions.SetTrashVariables(const AValue: Boolean);
begin
if fTrashVariables=AValue then exit;
fTrashVariables:=AValue;
IncreaseChangeStamp;
end;
procedure TLazCompilerOptions.SetUseLineInfoUnit(const AValue: Boolean);
begin
if fUseLineInfoUnit=AValue then exit;

View File

@ -248,12 +248,12 @@ var
GenerateDebugInfo:=IsDebug;
UseExternalDbgSyms:=IsDebug;
UseHeaptrc:=IsDebug;
// ToDo: TrashVariables:=IsDebug;
TrashVariables:=IsDebug;
end;
end;
var
DMode, RMode: TProjectBuildMode;
NewMode: TProjectBuildMode;
i: Integer;
begin
i:=BuildModesStringGrid.Row-1;
@ -261,19 +261,20 @@ begin
CurMode:=fBuildModes[i]
else
CurMode:=nil;
// Create Debug DMode
DMode:=fBuildModes.Add(DebugModeName);
AssignAndSetBooleans(DMode, True);
DMode.CompilerOptions.OptimizationLevel:=1; // Optimization
DMode.CompilerOptions.DebugInfoType:=dsDwarf2Set; // Debug
// Create Release DMode
RMode:=fBuildModes.Add(ReleaseModeName);
AssignAndSetBooleans(RMode, False);
RMode.CompilerOptions.OptimizationLevel:=3; // Optimization
RMode.CompilerOptions.DebugInfoType:=dsAuto; // Debug
// Create Debug mode
NewMode:=fBuildModes.Add(DebugModeName);
AssignAndSetBooleans(NewMode, True);
NewMode.CompilerOptions.OptimizationLevel:=1; // Optimization
NewMode.CompilerOptions.DebugInfoType:=dsDwarf2Set; // Debug
fActiveBuildMode:=NewMode; // activate Debug mode
// Create Release mode
NewMode:=fBuildModes.Add(ReleaseModeName);
AssignAndSetBooleans(NewMode, False);
NewMode.CompilerOptions.OptimizationLevel:=3; // Optimization
NewMode.CompilerOptions.DebugInfoType:=dsAuto; // Debug
fActiveBuildMode:=DMode; // activate Debug mode
FillBuildModesGrid; // show
// select identifier
BuildModesStringGrid.Col:=fModeNameCol;

View File

@ -1494,6 +1494,7 @@ begin
GenerateDebugInfo := aXMLConfig.GetValue(p+'Debugging/GenerateDebugInfo/Value', FileVersion >= 11); // Default = True, since version 11 (was False before)
UseLineInfoUnit := aXMLConfig.GetValue(p+'Debugging/UseLineInfoUnit/Value', true);
UseHeaptrc := aXMLConfig.GetValue(p+'Debugging/UseHeaptrc/Value', false);
TrashVariables := aXMLConfig.GetValue(p+'Debugging/TrashVariables/Value', false);
UseValgrind := aXMLConfig.GetValue(p+'Debugging/UseValgrind/Value', false);
if (FileVersion < 11) and (aXMLConfig.GetValue(p+'Debugging/DebugInfoType/Value', '') = '') then begin
@ -1713,6 +1714,7 @@ begin
aXMLConfig.DeletePath(p+'Debugging/GenerateDwarf'); // old deprecated setting
aXMLConfig.SetDeleteValue(p+'Debugging/UseLineInfoUnit/Value', UseLineInfoUnit,true);
aXMLConfig.SetDeleteValue(p+'Debugging/UseHeaptrc/Value', UseHeaptrc,false);
aXMLConfig.SetDeleteValue(p+'Debugging/TrashVariables/Value', TrashVariables,false);
aXMLConfig.SetDeleteValue(p+'Debugging/UseValgrind/Value', UseValgrind,false);
aXMLConfig.SetDeleteValue(p+'Debugging/GenGProfCode/Value', GenGProfCode,false);
aXMLConfig.SetDeleteValue(p+'Debugging/StripSymbols/Value', StripSymbols,false);
@ -2819,6 +2821,10 @@ begin
switches := switches + ' -g-h'; // heaptrc, without -g
end;
{ Trash variables }
if (TrashVariables) then
switches := switches + ' -gt';
{ Generate code gprof }
if (GenGProfCode) then
switches := switches + ' -pg';
@ -3467,6 +3473,7 @@ begin
if Done(Tool.AddDiff('DebugInfoType',DebugInfoTypeStr,CompOpts.DebugInfoTypeStr)) then exit;
if Done(Tool.AddDiff('UseLineInfoUnit',fUseLineInfoUnit,CompOpts.fUseLineInfoUnit)) then exit;
if Done(Tool.AddDiff('UseHeaptrc',fUseHeaptrc,CompOpts.fUseHeaptrc)) then exit;
if Done(Tool.AddDiff('TrashVariables',fTrashVariables,CompOpts.fTrashVariables)) then exit;
if Done(Tool.AddDiff('UseValgrind',fUseValgrind,CompOpts.fUseValgrind)) then exit;
if Done(Tool.AddDiff('GenGProfCode',fGenGProfCode,CompOpts.fGenGProfCode)) then exit;
if Done(Tool.AddDiff('StripSymbols',fStripSymbols,CompOpts.fStripSymbols)) then exit;

View File

@ -7,16 +7,16 @@ object CompilerDebuggingOptionsFrame: TCompilerDebuggingOptionsFrame
ClientWidth = 701
TabOrder = 0
DesignLeft = 225
DesignTop = 316
DesignTop = 275
object chkDebugGDB: TCheckBox
AnchorSideTop.Control = grpChecks
AnchorSideTop.Side = asrBottom
Left = 6
Height = 21
Top = 122
Top = 112
Width = 689
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 10
BorderSpacing.Top = 6
BorderSpacing.Around = 6
Caption = 'chkDebugGDB'
OnChange = chkDebugGDBChange
@ -29,13 +29,13 @@ object CompilerDebuggingOptionsFrame: TCompilerDebuggingOptionsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 137
Top = 149
Height = 119
Top = 139
Width = 701
Anchors = [akTop, akLeft, akRight]
AutoSize = True
Caption = 'grpInfoForGDB'
ClientHeight = 118
ClientHeight = 100
ClientWidth = 697
TabOrder = 1
object chkUseLineInfoUnit: TCheckBox
@ -46,55 +46,54 @@ object CompilerDebuggingOptionsFrame: TCompilerDebuggingOptionsFrame
AnchorSideRight.Side = asrBottom
Left = 6
Height = 21
Top = 37
Width = 685
Top = 31
Width = 691
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
BorderSpacing.Left = 6
Caption = 'chkUseLineInfoUnit'
TabOrder = 1
end
object chkUseValgrind: TCheckBox
AnchorSideLeft.Control = grpInfoForGDB
AnchorSideLeft.Control = chkUseLineInfoUnit
AnchorSideTop.Control = chkUseLineInfoUnit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = grpInfoForGDB
AnchorSideRight.Side = asrBottom
Left = 6
Height = 21
Top = 64
Width = 685
Top = 55
Width = 691
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
BorderSpacing.Top = 3
Caption = 'chkUseValgrind'
TabOrder = 2
end
object chkUseExternalDbgSyms: TCheckBox
AnchorSideLeft.Control = grpInfoForGDB
AnchorSideLeft.Control = chkUseValgrind
AnchorSideTop.Control = chkUseValgrind
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = grpInfoForGDB
AnchorSideRight.Side = asrBottom
Left = 6
Height = 21
Top = 91
Width = 685
Top = 79
Width = 691
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
BorderSpacing.Top = 3
Caption = 'chkUseExternalDbgSyms'
TabOrder = 3
end
object dropDbgSymbolType: TComboBox
AnchorSideLeft.Control = lblDbgSymbolType
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = lblEmpty
AnchorSideRight.Control = grpInfoForGDB
AnchorSideRight.Side = asrBottom
Left = 122
Height = 25
Top = 6
Width = 569
Top = 3
Width = 572
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
BorderSpacing.Around = 3
ItemHeight = 0
Style = csDropDownList
TabOrder = 0
@ -105,20 +104,12 @@ object CompilerDebuggingOptionsFrame: TCompilerDebuggingOptionsFrame
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 11
Top = 8
Width = 110
BorderSpacing.Around = 6
Caption = 'lblDbgSymbolType'
ParentColor = False
end
object lblEmpty: TLabel
Left = 0
Height = 1
Top = 0
Width = 697
Align = alTop
ParentColor = False
end
end
object grpOtherDebuggingInfo: TGroupBox
AnchorSideLeft.Control = Owner
@ -127,59 +118,73 @@ object CompilerDebuggingOptionsFrame: TCompilerDebuggingOptionsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 106
Top = 291
Height = 130
Top = 263
Width = 701
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 5
Caption = 'grpOtherDebuggingInfo'
ClientHeight = 87
ClientHeight = 111
ClientWidth = 697
TabOrder = 2
object chkUseHeaptrc: TCheckBox
Left = 6
Height = 21
Top = 6
Width = 685
Top = 3
Width = 691
Align = alTop
BorderSpacing.Around = 6
BorderSpacing.Left = 6
BorderSpacing.Top = 3
Caption = 'chkUseHeaptrc'
TabOrder = 0
end
object chkGenGProfCode: TCheckBox
AnchorSideTop.Control = chkUseHeaptrc
AnchorSideLeft.Control = chkTrashVariables
AnchorSideTop.Control = chkTrashVariables
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = grpOtherDebuggingInfo
AnchorSideRight.Side = asrBottom
Left = 6
Height = 21
Top = 33
Width = 685
Top = 51
Width = 691
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
BorderSpacing.Top = 3
Caption = 'chkGenGProfCode'
TabOrder = 1
end
object chkSymbolsStrip: TCheckBox
AnchorSideLeft.Control = chkGenGProfCode
AnchorSideTop.Control = chkGenGProfCode
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = grpOtherDebuggingInfo
AnchorSideRight.Side = asrBottom
Left = 6
Height = 21
Top = 60
Width = 685
Top = 75
Width = 691
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
BorderSpacing.Top = 3
Caption = 'chkSymbolsStrip'
TabOrder = 2
end
object chkTrashVariables: TCheckBox
AnchorSideLeft.Control = chkUseHeaptrc
AnchorSideTop.Control = chkUseHeaptrc
AnchorSideTop.Side = asrBottom
Left = 6
Height = 21
Top = 27
Width = 136
BorderSpacing.Top = 3
Caption = 'chkTrashVariables'
TabOrder = 3
end
end
object grpChecks: TGroupBox
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 106
Height = 100
Top = 0
Width = 701
Align = alTop
@ -189,7 +194,7 @@ object CompilerDebuggingOptionsFrame: TCompilerDebuggingOptionsFrame
ChildSizing.TopBottomSpacing = 6
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 87
ClientHeight = 81
ClientWidth = 697
TabOrder = 3
object chkChecksIO: TCheckBox
@ -207,9 +212,9 @@ object CompilerDebuggingOptionsFrame: TCompilerDebuggingOptionsFrame
AnchorSideTop.Side = asrBottom
Left = 6
Height = 21
Top = 33
Top = 30
Width = 131
BorderSpacing.Top = 6
BorderSpacing.Top = 3
Caption = 'chkChecksRange'
TabOrder = 1
end
@ -219,9 +224,9 @@ object CompilerDebuggingOptionsFrame: TCompilerDebuggingOptionsFrame
AnchorSideTop.Side = asrBottom
Left = 6
Height = 21
Top = 60
Top = 54
Width = 143
BorderSpacing.Top = 6
BorderSpacing.Top = 3
Caption = 'chkChecksOverflow'
TabOrder = 2
end
@ -239,25 +244,21 @@ object CompilerDebuggingOptionsFrame: TCompilerDebuggingOptionsFrame
end
object chkVerifyObjMethodCall: TCheckBox
AnchorSideLeft.Control = chkChecksStack
AnchorSideTop.Control = chkChecksStack
AnchorSideTop.Side = asrBottom
AnchorSideTop.Control = chkChecksRange
Left = 179
Height = 21
Top = 33
Top = 30
Width = 168
BorderSpacing.Top = 6
Caption = 'chkVerifyObjMethodCall'
TabOrder = 4
end
object chkAssertion: TCheckBox
AnchorSideLeft.Control = chkVerifyObjMethodCall
AnchorSideTop.Control = chkVerifyObjMethodCall
AnchorSideTop.Side = asrBottom
AnchorSideTop.Control = chkChecksOverflow
Left = 179
Height = 21
Top = 60
Top = 54
Width = 105
BorderSpacing.Top = 6
Caption = 'chkAssertion'
TabOrder = 5
end

View File

@ -21,6 +21,7 @@ type
chkSymbolsStrip: TCheckBox;
chkUseExternalDbgSyms: TCheckBox;
chkUseHeaptrc: TCheckBox;
chkTrashVariables: TCheckBox;
chkUseLineInfoUnit: TCheckBox;
chkUseValgrind: TCheckBox;
chkVerifyObjMethodCall: TCheckBox;
@ -29,7 +30,6 @@ type
grpChecks: TGroupBox;
grpOtherDebuggingInfo: TGroupBox;
grpInfoForGDB: TGroupBox;
lblEmpty: TLabel;
lblDbgSymbolType: TLabel;
procedure chkDebugGDBChange(Sender: TObject);
public
@ -108,11 +108,12 @@ begin
dropDbgSymbolType.Items.Add(dlgCOSymbolTypeStabs+ ' (-gs)'); // 3: stabs
dropDbgSymbolType.Items.Add(dlgCOSymbolTypeDwarf3+ ' (-gw3)');
chkUseLineInfoUnit.Caption := dlgLNumsBct + ' (-gl)';
chkUseHeaptrc.Caption := dlgCOHeaptrc + ' (-gh)';
chkUseValgrind.Caption := dlgCOValgrind + ' (-gv)';
chkUseExternalDbgSyms.Caption := dlgExtSymb + ' (-Xg)';
chkUseHeaptrc.Caption := dlgCOHeaptrc + ' (-gh)';
chkTrashVariables.Caption := dlgCOTrashVariables + ' (-gt)';
chkGenGProfCode.Caption := dlgGPROF + ' (-pg)';
chkSymbolsStrip.Caption := dlgCOStrip + ' (-Xs)';
chkUseExternalDbgSyms.Caption := dlgExtSymb + ' (-Xg)';
end;
procedure TCompilerDebuggingOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
@ -129,12 +130,13 @@ begin
chkDebugGDB.Checked := GenerateDebugInfo;
dropDbgSymbolType.ItemIndex := SymbolToIndex(DebugInfoType);
chkUseLineInfoUnit.Checked := UseLineInfoUnit;
chkUseHeaptrc.Checked := UseHeaptrc;
chkUseValgrind.Checked := UseValgrind;
chkUseExternalDbgSyms.Checked := UseExternalDbgSyms;
chkUseHeaptrc.Checked := UseHeaptrc;
chkTrashVariables.Checked := TrashVariables;
chkGenGProfCode.Checked := GenGProfCode;
chkSymbolsStrip.Checked := StripSymbols;
chkSymbolsStrip.Enabled := NeedsLinkerOpts;
chkUseExternalDbgSyms.Checked := UseExternalDbgSyms;
end;
grpInfoForGDB.Enabled := chkDebugGDB.Checked;
end;
@ -153,11 +155,12 @@ begin
GenerateDebugInfo := chkDebugGDB.Checked;
DebugInfoType := IndexToSymbol(dropDbgSymbolType.ItemIndex);
UseLineInfoUnit := chkUseLineInfoUnit.Checked;
UseHeaptrc := chkUseHeaptrc.Checked;
UseValgrind := chkUseValgrind.Checked;
UseExternalDbgSyms := chkUseExternalDbgSyms.Checked;
UseHeaptrc := chkUseHeaptrc.Checked;
TrashVariables := chkTrashVariables.Checked;
GenGProfCode := chkGenGProfCode.Checked;
StripSymbols := chkSymbolsStrip.Checked;
UseExternalDbgSyms := chkUseExternalDbgSyms.Checked;
end;
end;

View File

@ -2065,6 +2065,7 @@ resourcestring
dlgCODBX = 'Generate debugging info for DBX (slows compiling)';
dlgLNumsBct = 'Display line numbers in run-time error backtraces';
dlgCOHeaptrc = 'Use Heaptrc unit (check for mem-leaks)';
dlgCOTrashVariables = 'Trash variables';
dlgCOValgrind = 'Generate code for valgrind';
dlgGPROF = 'Generate code for gprof';
dlgCOStrip = 'Strip symbols from executable';