IDE: debugging

git-svn-id: trunk@30037 -
This commit is contained in:
mattias 2011-03-27 15:39:15 +00:00
parent 3601dd2d4d
commit c66ecb7939
3 changed files with 41 additions and 6 deletions

View File

@ -47,6 +47,7 @@ unit DefineTemplates;
{ $Define VerboseDefineCache} { $Define VerboseDefineCache}
{ $Define VerboseFPCSrcScan} { $Define VerboseFPCSrcScan}
{ $Define ShowTriedFiles} { $Define ShowTriedFiles}
{ $Define ShowTriedUnits}
interface interface
@ -838,7 +839,7 @@ type
function GetSourceRules(AutoUpdate: boolean): TFPCSourceRules; function GetSourceRules(AutoUpdate: boolean): TFPCSourceRules;
function GetUnitToSourceTree(AutoUpdate: boolean): TStringToStringTree; // unit name to file name (maybe relative) function GetUnitToSourceTree(AutoUpdate: boolean): TStringToStringTree; // unit name to file name (maybe relative)
function GetSourceDuplicates(AutoUpdate: boolean): TStringToStringTree; // unit to semicolon separated list of files function GetSourceDuplicates(AutoUpdate: boolean): TStringToStringTree; // unit to semicolon separated list of files
function GetUnitSrcFile(const AUnitName: string; function GetUnitSrcFile(const AnUnitName: string;
MustHavePPU: boolean = true; MustHavePPU: boolean = true;
SkipPPUCheckIfNoneExists: boolean = true): string; SkipPPUCheckIfNoneExists: boolean = true): string;
function GetCompiledUnitFile(const AUnitName: string): string; function GetCompiledUnitFile(const AUnitName: string): string;
@ -8793,26 +8794,35 @@ begin
Result:=fSrcDuplicates; Result:=fSrcDuplicates;
end; end;
function TFPCUnitSetCache.GetUnitSrcFile(const AUnitName: string; function TFPCUnitSetCache.GetUnitSrcFile(const AnUnitName: string;
MustHavePPU: boolean; SkipPPUCheckIfNoneExists: boolean): string; MustHavePPU: boolean; SkipPPUCheckIfNoneExists: boolean): string;
var var
Tree: TStringToStringTree; Tree: TStringToStringTree;
ConfigCache: TFPCTargetConfigCache; ConfigCache: TFPCTargetConfigCache;
begin begin
Result:=''; Result:='';
{$IFDEF ShowTriedUnits}
debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" MustHavePPU=',MustHavePPU,' SkipPPUCheckIfNoneExists=',SkipPPUCheckIfNoneExists]);
{$ENDIF}
Tree:=GetUnitToSourceTree(false); Tree:=GetUnitToSourceTree(false);
if MustHavePPU then begin if MustHavePPU then begin
ConfigCache:=GetConfigCache(false); ConfigCache:=GetConfigCache(false);
if (ConfigCache.Units<>nil) if (ConfigCache.Units<>nil)
and (CompareFileExt(ConfigCache.Units[AUnitName],'ppu',false)<>0) and (CompareFileExt(ConfigCache.Units[AnUnitName],'ppu',false)<>0)
then begin then begin
// unit has no ppu in the FPC ppu search path // unit has no ppu in the FPC ppu search path
if ConfigCache.HasPPUs then begin if ConfigCache.HasPPUs then begin
// but there are other ppu files // but there are other ppu files
{$IFDEF ShowTriedUnits}
debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" unit has no ppu file in FPC path, but there are other']);
{$ENDIF}
exit; exit;
end else begin end else begin
// no ppu exists at all // no ppu exists at all
// => the fpc is not installed properly for this target // => the fpc is not installed properly for this target
{$IFDEF ShowTriedUnits}
debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" there are no ppu files for this target']);
{$ENDIF}
if not SkipPPUCheckIfNoneExists then if not SkipPPUCheckIfNoneExists then
exit; exit;
// => search directly in the sources // => search directly in the sources
@ -8821,9 +8831,12 @@ begin
end; end;
end; end;
if Tree<>nil then begin if Tree<>nil then begin
Result:=Tree[AUnitName]; Result:=Tree[AnUnitName];
if Result<>'' then if Result<>'' then
Result:=FPCSourceDirectory+Result; Result:=FPCSourceDirectory+Result;
{$IFDEF ShowTriedUnits}
debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" Result=',Result]);
{$ENDIF}
end; end;
end; end;

View File

@ -1041,7 +1041,7 @@ begin
if Result='' then begin if Result='' then begin
// search in unit links // search in unit links
{$IFDEF ShowTriedUnits} {$IFDEF ShowTriedUnits}
DebugLn(['TCTDirectoryCache.FindUnitSourceInCompletePath unit ',AUnitName,' not found in SrcPath="',SrcPath,'" Directory="',Directory,'"']); DebugLn(['TCTDirectoryCache.FindUnitSourceInCompletePath unit ',AUnitName,' not found in SrcPath="',SrcPath,'" Directory="',Directory,'" searchin in unitset ...']);
{$ENDIF} {$ENDIF}
Result:=FindUnitInUnitSet(AUnitName); Result:=FindUnitInUnitSet(AUnitName);
{$IFDEF ShowTriedUnits} {$IFDEF ShowTriedUnits}
@ -1097,6 +1097,7 @@ begin
// search in unit path // search in unit path
UnitPath:=Strings[ctdcsUnitPath]; UnitPath:=Strings[ctdcsUnitPath];
Result:=SearchPascalFileInPath(AnUnitname+'.ppu',CurDir,UnitPath,';',SearchCase); Result:=SearchPascalFileInPath(AnUnitname+'.ppu',CurDir,UnitPath,';',SearchCase);
//debugln(['TCTDirectoryCache.FindCompiledUnitInCompletePath CurDir="',CurDir,'" UnitPath="',UnitPath,'" AnUnitname="',AnUnitname,'" Result=',Result]);
if Result='' then begin if Result='' then begin
// search in unit set // search in unit set
Result:=FindCompiledUnitInUnitSet(AnUnitname); Result:=FindCompiledUnitInUnitSet(AnUnitname);

View File

@ -265,6 +265,9 @@ var
i: Integer; i: Integer;
CfgFileItem: TFPCConfigFileState; CfgFileItem: TFPCConfigFileState;
HasCfgs: Boolean; HasCfgs: Boolean;
SrcCache: TFPCSourceCache;
AFilename: string;
AnUnitName: string;
begin begin
sl.Add('FPC executable:'); sl.Add('FPC executable:');
if UnitSetCache<>nil then begin if UnitSetCache<>nil then begin
@ -289,7 +292,7 @@ begin
end; end;
end; end;
if not HasCfgs then if not HasCfgs then
sl.Add('WARNING: fpc has no config file'); sl.Add('WARNING: fpc has no config file');
sl.Add(''); sl.Add('');
sl.Add('Defines:'); sl.Add('Defines:');
if CfgCache.Defines<>nil then begin if CfgCache.Defines<>nil then begin
@ -308,6 +311,24 @@ begin
sl.Add(CfgCache.Units.AsText); sl.Add(CfgCache.Units.AsText);
end; end;
end; end;
SrcCache:=UnitSetCache.GetSourceCache(false);
if SrcCache<>nil then begin
sl.Add('Sources:');
sl.Add('Directory='+SrcCache.Directory);
if SrcCache.Files<>nil then begin
sl.Add('Files.Count='+dbgs(SrcCache.Files.Count));
for i:=0 to SrcCache.Files.Count-1 do begin
AFilename:=SrcCache.Files[i];
AnUnitName:=ExtractFilenameOnly(AFilename);
if (AnUnitName='classes')
or (AnUnitName='sysutils')
or (AnUnitName='system')
then
sl.Add(AFilename);
end;
end else
sl.Add('Files.Count=0');
end;
end; end;
sl.Add(''); sl.Add('');
end; end;