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 VerboseFPCSrcScan}
{ $Define ShowTriedFiles}
{ $Define ShowTriedUnits}
interface
@ -838,7 +839,7 @@ type
function GetSourceRules(AutoUpdate: boolean): TFPCSourceRules;
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 GetUnitSrcFile(const AUnitName: string;
function GetUnitSrcFile(const AnUnitName: string;
MustHavePPU: boolean = true;
SkipPPUCheckIfNoneExists: boolean = true): string;
function GetCompiledUnitFile(const AUnitName: string): string;
@ -8793,26 +8794,35 @@ begin
Result:=fSrcDuplicates;
end;
function TFPCUnitSetCache.GetUnitSrcFile(const AUnitName: string;
function TFPCUnitSetCache.GetUnitSrcFile(const AnUnitName: string;
MustHavePPU: boolean; SkipPPUCheckIfNoneExists: boolean): string;
var
Tree: TStringToStringTree;
ConfigCache: TFPCTargetConfigCache;
begin
Result:='';
{$IFDEF ShowTriedUnits}
debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" MustHavePPU=',MustHavePPU,' SkipPPUCheckIfNoneExists=',SkipPPUCheckIfNoneExists]);
{$ENDIF}
Tree:=GetUnitToSourceTree(false);
if MustHavePPU then begin
ConfigCache:=GetConfigCache(false);
if (ConfigCache.Units<>nil)
and (CompareFileExt(ConfigCache.Units[AUnitName],'ppu',false)<>0)
and (CompareFileExt(ConfigCache.Units[AnUnitName],'ppu',false)<>0)
then begin
// unit has no ppu in the FPC ppu search path
if ConfigCache.HasPPUs then begin
// 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;
end else begin
// no ppu exists at all
// => 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
exit;
// => search directly in the sources
@ -8821,9 +8831,12 @@ begin
end;
end;
if Tree<>nil then begin
Result:=Tree[AUnitName];
Result:=Tree[AnUnitName];
if Result<>'' then
Result:=FPCSourceDirectory+Result;
{$IFDEF ShowTriedUnits}
debugln(['TFPCUnitSetCache.GetUnitSrcFile Unit="',AnUnitName,'" Result=',Result]);
{$ENDIF}
end;
end;

View File

@ -1041,7 +1041,7 @@ begin
if Result='' then begin
// search in unit links
{$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}
Result:=FindUnitInUnitSet(AUnitName);
{$IFDEF ShowTriedUnits}
@ -1097,6 +1097,7 @@ begin
// search in unit path
UnitPath:=Strings[ctdcsUnitPath];
Result:=SearchPascalFileInPath(AnUnitname+'.ppu',CurDir,UnitPath,';',SearchCase);
//debugln(['TCTDirectoryCache.FindCompiledUnitInCompletePath CurDir="',CurDir,'" UnitPath="',UnitPath,'" AnUnitname="',AnUnitname,'" Result=',Result]);
if Result='' then begin
// search in unit set
Result:=FindCompiledUnitInUnitSet(AnUnitname);

View File

@ -265,6 +265,9 @@ var
i: Integer;
CfgFileItem: TFPCConfigFileState;
HasCfgs: Boolean;
SrcCache: TFPCSourceCache;
AFilename: string;
AnUnitName: string;
begin
sl.Add('FPC executable:');
if UnitSetCache<>nil then begin
@ -289,7 +292,7 @@ begin
end;
end;
if not HasCfgs then
sl.Add('WARNING: fpc has no config file');
sl.Add('WARNING: fpc has no config file');
sl.Add('');
sl.Add('Defines:');
if CfgCache.Defines<>nil then begin
@ -308,6 +311,24 @@ begin
sl.Add(CfgCache.Units.AsText);
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;
sl.Add('');
end;