IDE: debugfilename, debugsearchpath: use same function as other env vars to resolve macros, trim and find

git-svn-id: trunk@36682 -
This commit is contained in:
mattias 2012-04-09 17:00:35 +00:00
parent 846e04db20
commit f8a61521aa
5 changed files with 94 additions and 67 deletions

View File

@ -148,7 +148,7 @@ begin
then SetComboBoxText(cmbDebuggerType, '(none)',cstCaseInsensitive)
else SetComboBoxText(cmbDebuggerType, FCurDebuggerClass.Caption,cstCaseInsensitive);
txtAdditionalPath.Text:=EnvironmentOptions.DebuggerSearchPath;
txtAdditionalPath.Text:=EnvironmentOptions.GetParsedDebuggerSearchPath;
end;
procedure TDebuggerGeneralOptionsFrame.FetchDebuggerGeneralOptions;

View File

@ -362,8 +362,8 @@ begin
Result := TDebuggerList.Create;
if FileExists(ConfDir + 'gdblist.txt') then
Result.LoadFromFile(ConfDir + 'gdblist.txt');
if (Result.Count = 0) and (EnvironmentOptions.DebuggerFilename <> '') then
Result.Add('gdb from conf', EnvironmentOptions.DebuggerFilename);
if (Result.Count = 0) and (EnvironmentOptions.GetParsedDebuggerFilename <> '') then
Result.Add('gdb from conf', EnvironmentOptions.GetParsedDebuggerFilename);
Debuggers := Result;
end;

View File

@ -2060,7 +2060,7 @@ begin
//todo: this check depends on the debugger class
if (DebuggerClass <> TProcessDebugger)
and not FileIsExecutable(EnvironmentOptions.DebuggerFilename)
and not FileIsExecutable(EnvironmentOptions.GetParsedDebuggerFilename)
then begin
MessageDlg(lisDebuggerInvalid,
Format(lisTheDebuggerDoesNotExistsOrIsNotExecutableSeeEnviro, ['"',
@ -2078,7 +2078,7 @@ begin
// check if debugger is already created with the right type
if (FDebugger <> nil)
and (not (FDebugger is DebuggerClass)
or (FDebugger.ExternalDebugger <> EnvironmentOptions.DebuggerFilename)
or (FDebugger.ExternalDebugger <> EnvironmentOptions.GetParsedDebuggerFilename)
)
then begin
// the current debugger is the wrong type -> free it
@ -2088,7 +2088,7 @@ begin
// create debugger object
if FDebugger = nil
then SetDebugger(DebuggerClass.Create(EnvironmentOptions.DebuggerFilename));
then SetDebugger(DebuggerClass.Create(EnvironmentOptions.GetParsedDebuggerFilename));
if FDebugger = nil
then begin
@ -2503,7 +2503,7 @@ begin
ABrkPoint := nil;
if WarnIfNoDebugger
and ((FindDebuggerClass(EnvironmentOptions.DebuggerConfig.DebuggerClass)=nil)
or (not FileIsExecutable(EnvironmentOptions.DebuggerFilename)))
or (not FileIsExecutableCached(EnvironmentOptions.GetParsedDebuggerFilename)))
then begin
if IDEQuestionDialog(lisDbgMangNoDebuggerSpecified,
Format(lisDbgMangThereIsNoDebuggerSpecifiedSettingBreakpointsHaveNo, [#13]),
@ -2523,7 +2523,7 @@ begin
ABrkPoint := nil;
if WarnIfNoDebugger
and ((FindDebuggerClass(EnvironmentOptions.DebuggerConfig.DebuggerClass)=nil)
or (not FileIsExecutable(EnvironmentOptions.DebuggerFilename)))
or (not FileIsExecutableCached(EnvironmentOptions.GetParsedDebuggerFilename)))
then begin
if IDEQuestionDialog(lisDbgMangNoDebuggerSpecified,
Format(lisDbgMangThereIsNoDebuggerSpecifiedSettingBreakpointsHaveNo, [#13]),

View File

@ -38,7 +38,7 @@ uses
ShlObj,
{$endif}
Classes, SysUtils, TypInfo, Graphics, Controls, Forms, LCLProc, FileProcs,
Dialogs, LazConfigStorage, Laz2_XMLCfg,
Dialogs, LazConfigStorage, Laz2_XMLCfg, LazUTF8,
// IDEIntf
ProjectIntf, ObjectInspector, IDEWindowIntf, IDEOptionsIntf,
CompOptsIntf, IDEExternToolIntf, IDEDialogs,
@ -189,9 +189,9 @@ type
eopTestBuildDirectory,
eopMakeFilename,
eopFPDocPaths,
eopCompilerMessagesFilename
//eopDebuggerFilename,
//eopDebuggerSearchPath
eopCompilerMessagesFilename,
eopDebuggerFilename,
eopDebuggerSearchPath
);
TEnvOptParseTypes = set of TEnvOptParseType;
@ -201,7 +201,6 @@ type
TEnvironmentOptions = class(TAbstractIDEEnvironmentOptions)
private
FDebuggerResetAfterRun: boolean;
FFilename: string;
FFileAge: longint;
FFileHasChangedOnDisk: boolean;
@ -280,9 +279,8 @@ type
// TODO: store per debuggerclass options
// Maybe these should go to a new TDebuggerOptions class
FDebuggerResetAfterRun: boolean;
FDebuggerConfig: TDebuggerConfigStore;
FDebuggerSearchPath: string;
FDebuggerFilename: string; // per debugger class
FDebuggerFileHistory: TStringList; // per debugger class
FDebuggerProperties: TStringList; // per debugger class
FDebuggerShowStopMessage: Boolean;
@ -337,6 +335,8 @@ type
function GetCompilerFilename: string;
function GetCompilerMessagesFilename: string;
function GetDebuggerEventLogColors(AIndex: TDBGEventType): TDebuggerEventLogColor;
function GetDebuggerFilename: string;
function GetDebuggerSearchPath: string;
function GetFPCSourceDirectory: string;
function GetFPDocPaths: string;
function GetLazarusDirectory: string;
@ -347,9 +347,9 @@ type
procedure SetDebuggerEventLogColors(AIndex: TDBGEventType;
const AValue: TDebuggerEventLogColor);
procedure SetDebuggerSearchPath(const AValue: string);
procedure SetFPDocPaths(AValue: string);
procedure SetFPDocPaths(const AValue: string);
procedure SetMakeFilename(const AValue: string);
procedure SetDebuggerFilename(const AValue: string);
procedure SetDebuggerFilename(AValue: string);
procedure SetFPCSourceDirectory(const AValue: string);
procedure SetLazarusDirectory(const AValue: string);
procedure SetParseValue(o: TEnvOptParseType; const NewValue: string);
@ -381,6 +381,8 @@ type
function GetParsedMakeFilename: string;
function GetParsedCompilerMessagesFilename: string;
function GetParsedFPDocPaths: string;
function GetParsedDebuggerFilename: string;
function GetParsedDebuggerSearchPath: string;
function GetParsedValue(o: TEnvOptParseType): string;
// macros
@ -506,11 +508,11 @@ type
write SetMakeFilename;
property MakeFileHistory: TStringList read FMakeFileHistory
write FMakeFileHistory;
property DebuggerFilename: string read FDebuggerFilename
property DebuggerFilename: string read GetDebuggerFilename
write SetDebuggerFilename;
property DebuggerFileHistory: TStringList read FDebuggerFileHistory
write FDebuggerFileHistory;
property DebuggerSearchPath: string read FDebuggerSearchPath
property DebuggerSearchPath: string read GetDebuggerSearchPath
write SetDebuggerSearchPath;
property DebuggerShowStopMessage: boolean read FDebuggerShowStopMessage
write FDebuggerShowStopMessage;
@ -638,9 +640,9 @@ const
'TestDir', // eopTestBuildDirectory
'Make', // eopMakeFilename
'FPDocPath', // eopFPDocPaths
'CompMsgFile' // eopCompilerMessagesFilename
//'Debugger', // eopDebuggerFilename
//'DebugPath', // eopDebuggerSearchPath
'CompMsgFile', // eopCompilerMessagesFilename
'Debugger', // eopDebuggerFilename
'DebugPath' // eopDebuggerSearchPath
);
function dbgs(o: TEnvOptParseType): string; overload;
@ -837,7 +839,6 @@ begin
DebuggerFilename:='';
FDebuggerFileHistory:=TStringList.Create;
FDebuggerProperties := TStringList.Create;
FDebuggerSearchPath:='';
FDebuggerEventLogColors:=DebuggerDefaultColors;
TestBuildDirectory:=GetDefaultTestBuildDirectory;
@ -1511,7 +1512,7 @@ begin
FDebuggerConfig.Save;
SaveDebuggerPropertiesList;
XMLConfig.SetDeleteValue(Path+'DebuggerFilename/Value',
FDebuggerFilename,'');
DebuggerFilename,'');
XMLConfig.SetDeleteValue(Path+'DebuggerOptions/ShowStopMessage/Value',
FDebuggerShowStopMessage, True);
XMLConfig.SetDeleteValue(Path+'DebuggerOptions/DebuggerResetAfterRun/Value',
@ -1519,7 +1520,7 @@ begin
SaveRecentList(XMLConfig,FDebuggerFileHistory,
Path+'DebuggerFilename/History/');
XMLConfig.SetDeleteValue(Path+'DebuggerSearchPath/Value',
FDebuggerSearchPath,'');
DebuggerSearchPath,'');
XMLConfig.SetDeleteValue(Path+'Debugger/EventLogClearOnRun',
FDebuggerEventLogClearOnRun, True);
XMLConfig.SetDeleteValue(Path+'Debugger/EventLogCheckLineLimit',
@ -1717,7 +1718,20 @@ begin
Result:=GetParsedValue(eopFPDocPaths);
end;
function TEnvironmentOptions.GetParsedDebuggerFilename: string;
begin
Result:=GetParsedValue(eopDebuggerFilename);
end;
function TEnvironmentOptions.GetParsedDebuggerSearchPath: string;
begin
Result:=GetParsedValue(eopDebuggerSearchPath);
end;
function TEnvironmentOptions.GetParsedValue(o: TEnvOptParseType): string;
var
SpacePos: SizeInt;
CurParams: String;
begin
with FParseValues[o] do begin
if (ParseStamp<>CompilerParseStamp)
@ -1750,19 +1764,51 @@ begin
eopCompilerMessagesFilename:
// data file
ParsedValue:=TrimAndExpandFilename(ParsedValue,GetParsedLazarusDirectory);
eopFPDocPaths{,eopDebuggerSearchPath}:
eopFPDocPaths,eopDebuggerSearchPath:
// search path
ParsedValue:=TrimSearchPath(ParsedValue,GetParsedLazarusDirectory,true);
eopCompilerFilename,eopMakeFilename{,eopDebuggerFilename}:
eopCompilerFilename,eopMakeFilename,eopDebuggerFilename:
// program
begin
ParsedValue:=Trim(ParsedValue);
CurParams:='';
if (o in [eopDebuggerFilename]) then begin
// program + params
// examples:
// gdb -v
// "C:\public folder\gdb"
SpacePos:=1;
while (SpacePos<=length(ParsedValue)) do begin
if ParsedValue[SpacePos]='"' then begin
System.Delete(ParsedValue,1,1); // delete startng "
while (SpacePos<=length(ParsedValue))
and (ParsedValue[SpacePos]<>'"') do
inc(SpacePos);
if SpacePos<=length(ParsedValue) then
System.Delete(ParsedValue,1,1); // dleete ending "
end else if ParsedValue[SpacePos]=' ' then
break
else
inc(SpacePos);
end;
CurParams:=copy(ParsedValue,SpacePos,length(ParsedValue));
system.Delete(ParsedValue,SpacePos,length(ParsedValue));
end;
// program
ParsedValue:=TrimFilename(ParsedValue);
if (ParsedValue<>'') and (not FilenameIsAbsolute(ParsedValue)) then
begin
if ExtractFilePath(ParsedValue)='' then
if (ExtractFilePath(ParsedValue)='')
and (not FileExistsCached(GetParsedLazarusDirectory+ParsedValue)) then
ParsedValue:=FindDefaultExecutablePath(ParsedValue)
else
ParsedValue:=GetParsedLazarusDirectory+ParsedValue;
ParsedValue:=TrimFilename(GetParsedLazarusDirectory+ParsedValue);
end;
// append parameters
if CurParams<>'' then begin
if System.Pos(' ',ParsedValue)>0 then
ParsedValue:='"'+ParsedValue+'"';
ParsedValue+=CurParams;
end;
end;
end;
@ -1961,24 +2007,17 @@ end;
procedure TEnvironmentOptions.SetFPCSourceDirectory(const AValue: string);
begin
if FPCSourceDirectory=AValue then exit;
SetParseValue(eopFPCSourceDirectory,AValue);
end;
procedure TEnvironmentOptions.SetCompilerFilename(const AValue: string);
var
NewValue: String;
begin
NewValue:=TrimFilename(AValue);
SetParseValue(eopCompilerFilename,NewValue);
SetParseValue(eopCompilerFilename,TrimFilename(AValue));
end;
procedure TEnvironmentOptions.SetCompilerMessagesFilename(AValue: string);
var
NewValue: String;
begin
NewValue:=TrimFilename(AValue);
SetParseValue(eopCompilerMessagesFilename,NewValue);
SetParseValue(eopCompilerMessagesFilename,TrimFilename(AValue));
end;
function TEnvironmentOptions.GetDebuggerEventLogColors(AIndex: TDBGEventType): TDebuggerEventLogColor;
@ -1986,6 +2025,16 @@ begin
Result := FDebuggerEventLogColors[AIndex];
end;
function TEnvironmentOptions.GetDebuggerFilename: string;
begin
Result:=FParseValues[eopDebuggerFilename].UnparsedValue;
end;
function TEnvironmentOptions.GetDebuggerSearchPath: string;
begin
Result:=FParseValues[eopDebuggerSearchPath].UnparsedValue;
end;
function TEnvironmentOptions.GetCompilerFilename: string;
begin
Result:=FParseValues[eopCompilerFilename].UnparsedValue;
@ -2027,44 +2076,23 @@ begin
end;
procedure TEnvironmentOptions.SetDebuggerSearchPath(const AValue: string);
var
NewValue: String;
begin
NewValue:=TrimSearchPath(AValue,'');
if FDebuggerSearchPath=NewValue then exit;
FDebuggerSearchPath:=NewValue;
SetParseValue(eopDebuggerSearchPath,TrimSearchPath(AValue,''));
end;
procedure TEnvironmentOptions.SetFPDocPaths(AValue: string);
var
NewValue: String;
procedure TEnvironmentOptions.SetFPDocPaths(const AValue: string);
begin
NewValue:=TrimSearchPath(AValue,'');
SetParseValue(eopFPDocPaths,NewValue);
SetParseValue(eopFPDocPaths,TrimSearchPath(AValue,''));
end;
procedure TEnvironmentOptions.SetMakeFilename(const AValue: string);
var
NewValue: String;
begin
NewValue:=TrimFilename(AValue);
SetParseValue(eopMakeFilename,NewValue);
SetParseValue(eopMakeFilename,TrimFilename(AValue));
end;
procedure TEnvironmentOptions.SetDebuggerFilename(const AValue: string);
var
SpacePos: Integer;
procedure TEnvironmentOptions.SetDebuggerFilename(AValue: string);
begin
if FDebuggerFilename=AValue then exit;
FDebuggerFilename:=AValue;
// trim the filename and keep the options after the space (if any)
// TODO: split/find filename with spaces
SpacePos:=1;
while (SpacePos<=length(FDebuggerFilename))
and (FDebuggerFilename[SpacePos]<>' ') do
inc(SpacePos);
FDebuggerFilename:=Trim(copy(FDebuggerFilename,1,SpacePos-1))+
copy(FDebuggerFilename,SpacePos,length(FDebuggerFilename)-SpacePos+1);
SetParseValue(eopDebuggerFilename,UTF8Trim(AValue));
end;
initialization

View File

@ -14375,8 +14375,7 @@ begin
// search file in debug path
if fsfUseDebugPath in Flags then begin
SearchPath:=EnvironmentOptions.DebuggerSearchPath;
GlobalMacroList.SubstituteStr(SearchPath);
SearchPath:=EnvironmentOptions.GetParsedDebuggerSearchPath;
SearchPath:=MergeSearchPaths(Project1.CompilerOptions.GetDebugPath(false),
SearchPath);
SearchPath:=TrimSearchPath(SearchPath,BaseDir);