codetools: debugging

git-svn-id: trunk@31133 -
This commit is contained in:
mattias 2011-06-08 08:05:52 +00:00
parent 23249c0b48
commit c7374d6077
3 changed files with 31 additions and 5 deletions

View File

@ -460,6 +460,7 @@ type
// 1=CursorPos beyond scanned code
function CleanedPosToCursor(ACleanedPos: integer; var ACursorPos: integer;
var ACode: Pointer): boolean;
function CleanedPosToStr(ACleanedPos: integer): string;
function LastErrorIsInFrontOfCleanedPos(ACleanedPos: integer): boolean;
procedure RaiseLastErrorIfInFrontOfCleanedPos(ACleanedPos: integer);
@ -3714,6 +3715,18 @@ begin
end;
end;
function TLinkScanner.CleanedPosToStr(ACleanedPos: integer): string;
var
p: integer;
ACode: Pointer;
begin
if CleanedPosToCursor(ACleanedPos,p,ACode) then begin
Result:=TSourceLog(ACode).AbsoluteToLineColStr(p);
end else begin
Result:='p='+IntToStr(ACleanedPos)+',y=?,x=?';
end;
end;
function TLinkScanner.WholeRangeIsWritable(CleanStartPos, CleanEndPos: integer;
ErrorOnFail: boolean): boolean;

View File

@ -578,14 +578,17 @@ var
IsDirectChange: boolean;
IntersectionEntry: TSourceChangeCacheEntry;
begin
{$IFDEF VerboseSrcChanger}
DebugLn('TSourceChangeCache.ReplaceEx FrontGap=',dbgs(FrontGap),
' AfterGap=',dbgs(AfterGap),' CleanPos=',dbgs(FromPos),'-',dbgs(ToPos),
' Text="',Text,'"');
' AfterGap=',dbgs(AfterGap),' Text="',Text,'"');
if DirectCode<>nil then
DebugLn(' DirectCode=',DirectCode.Filename,' DirectPos=',dbgs(FromDirectPos),'-',dbgs(ToDirectPos),' Src=(~',dbgstr(copy(DirectCode.Source,FromDirectPos,ToDirectPos-FromDirectPos)),'~)')
else if ToPos>FromPos then
debugln([' DeleteCode=(~',dbgstr(copy(MainScanner.Src,FromPos,ToPos-FromPos)),'~)']);
DebugLn(' DirectCode=',DirectCode.Filename,' DirectPos=',DirectCode.AbsoluteToLineColStr(FromDirectPos),'-',DirectCode.AbsoluteToLineColStr(ToDirectPos),' Src=(~',dbgstr(copy(DirectCode.Source,FromDirectPos,ToDirectPos-FromDirectPos)),'~)')
else begin
debugln([' CleanPos=',MainScanner.CleanedPosToStr(FromPos),'-',MainScanner.CleanedPosToStr(ToPos)]);
if ToPos>FromPos then
debugln([' DeleteCode=(~',dbgstr(copy(MainScanner.Src,FromPos,ToPos-FromPos)),'~)']);
end;
{$ENDIF}
Result:=false;
IsDirectChange:=DirectCode<>nil;

View File

@ -157,6 +157,7 @@ type
procedure AbsoluteToLineCol(Position: integer; out Line, Column: integer);
function LineColIsOutside(Line, Column: integer): boolean;
function LineColIsSpace(Line, Column: integer): boolean;
function AbsoluteToLineColStr(Position: integer): string;
procedure Insert(Pos: integer; const Txt: string);
procedure Delete(Pos, Len: integer);
procedure Replace(Pos, Len: integer; const Txt: string);
@ -796,6 +797,15 @@ begin
if (Column>1) and (p[Column-2]>' ') then exit(false);
end;
function TSourceLog.AbsoluteToLineColStr(Position: integer): string;
var
Line: integer;
Column: integer;
begin
AbsoluteToLineCol(Position,Line,Column);
Result:='p='+IntToStr(Position)+',y='+IntToStr(Line)+',x='+IntToStr(Column);
end;
function TSourceLog.LoadFromFile(const Filename: string): boolean;
var
s: string;