mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-15 11:49:55 +02:00
implemented jumping to some kind of linker undefined reference errors
git-svn-id: trunk@9468 -
This commit is contained in:
parent
cd5bd31851
commit
9fa77ea56b
@ -1043,6 +1043,11 @@ var
|
||||
ShortIdentifier: ShortString;
|
||||
BestPos: Integer;
|
||||
ASrcFilename: String;
|
||||
LinkCode: TCodeBuffer;
|
||||
Link: TSourceLink;
|
||||
i: Integer;
|
||||
CurLine: String;
|
||||
StartPos, EndPos: integer;
|
||||
begin
|
||||
Result:=false;
|
||||
BuildTree(false);
|
||||
@ -1051,7 +1056,47 @@ begin
|
||||
BestPos:=0;
|
||||
ShortIdentifier:=UpperCaseStr(copy(Identifier,1,255));
|
||||
|
||||
if (MangledFunction<>'') then begin
|
||||
if (BestPos<1) and (SourceFilename<>'') then begin
|
||||
// try to find the source (unit or include file)
|
||||
ASrcFilename:=ExtractFileName(SourceFilename);
|
||||
i:=0;
|
||||
while (i<Scanner.LinkCount) do begin
|
||||
Link:=Scanner.Links[i];
|
||||
LinkCode:=TCodeBuffer(Link.Code);
|
||||
if CompareFilenames(ExtractFilename(LinkCode.Filename),ASrcFilename)=0 then
|
||||
begin
|
||||
BestPos:=Link.CleanedPos;
|
||||
if (SourceLine>0) and (SourceLine<=LinkCode.LineCount) then begin
|
||||
// there is a SourceLine => use that
|
||||
NewPos.X:=1;
|
||||
if Identifier<>'' then begin
|
||||
// there is an Identifier => search it in line
|
||||
CurLine:=LinkCode.GetLine(SourceLine-1);
|
||||
EndPos:=1;
|
||||
while (EndPos<=length(CurLine)) do begin
|
||||
BasicCodeTools.ReadRawNextPascalAtom(CurLine,EndPos,StartPos);
|
||||
if (EndPos<=length(CurLine))
|
||||
and (CompareIdentifiers(@CurLine[StartPos],PChar(Identifier))=0)
|
||||
then begin
|
||||
NewPos.X:=StartPos;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
NewPos.Code:=LinkCode;
|
||||
NewPos.Y:=SourceLine;
|
||||
NewTopLine:=NewPos.Y-VisibleEditorLines div 2;
|
||||
if NewTopLine<1 then NewTopLine:=1;
|
||||
Result:=true;
|
||||
exit;
|
||||
end;
|
||||
break;
|
||||
end;
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
if (BestPos<1) and (MangledFunction<>'') then begin
|
||||
// try to find the function
|
||||
ProcName:=MangledFunction;
|
||||
ProcPos:=1;
|
||||
@ -1090,12 +1135,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
if (BestPos<1) and (SourceFilename<>'') then begin
|
||||
// try to find the source (unit or include file)
|
||||
ASrcFilename:=ExtractFileName(SourceFilename);
|
||||
|
||||
end;
|
||||
|
||||
if BestPos<1 then exit;
|
||||
|
||||
// find jump point
|
||||
|
@ -230,7 +230,7 @@ procedure TQuickFixLinkerUndefinedReference.Execute(const Msg: TIDEMessageLine;
|
||||
Identifier:='';
|
||||
SourceFilename:='';
|
||||
SourceLine:=0;
|
||||
if REMatches(Line1.Msg,'^(.*)\(\.text.*?\): .* `([A-Z0-9_$]+)'':$') then
|
||||
if REMatches(Line1.Msg,'^(.*)\(\.text.*?\): .* `([a-zA-Z0-9_$]+)'':$') then
|
||||
begin
|
||||
// example: unit1.o(.text+0x1a): In function `SubProc':
|
||||
Filename:=REVar(1);
|
||||
@ -249,18 +249,25 @@ procedure TQuickFixLinkerUndefinedReference.Execute(const Msg: TIDEMessageLine;
|
||||
exit;
|
||||
end;
|
||||
end
|
||||
else if REMatches(Line1.Msg,'^(.*)\(\.text.*?\):(.*):([0-9]*): .* `([A-Z0-9_$]+)'':$')
|
||||
else if REMatches(Line1.Msg,'^(.*)\(\.text.*?\):(.*):([0-9]*): .* `([a-zA-Z0-9_$]+)'':$')
|
||||
then begin
|
||||
// example: unit1.o(.text+0x3a):unit1.pas:48: undefined reference to `DoesNotExist'
|
||||
Filename:=REVar(1);
|
||||
SourceFilename:=REVar(2);
|
||||
SourceLine:=StrToIntDef(REVar(3),0);
|
||||
Identifier:=REVar(4);
|
||||
end
|
||||
else if REMatches(Line1.Msg,'^(.*):([0-9]+): .* `([a-zA-Z0-9_$]+)''$') then begin
|
||||
// example: unit1.pas:48: undefined reference to `DoesNotExist'
|
||||
Filename:=REVar(1);
|
||||
SourceFilename:=Filename;
|
||||
SourceLine:=StrToIntDef(REVar(2),0);
|
||||
Identifier:=REVar(3);
|
||||
end else begin
|
||||
DebugLn('JumpTo Line1 does not match: "',Line1.Msg,'"');
|
||||
exit;
|
||||
end;
|
||||
DebugLn(['TQuickFixLinkerUndefinedReference.JumpTo Filename="',Filename,'" MangledFunction="',MangledFunction,'" Identifier="',Identifier,'"']);
|
||||
DebugLn(['TQuickFixLinkerUndefinedReference.JumpTo Filename="',Filename,'" MangledFunction="',MangledFunction,'" Identifier="',Identifier,'" SourceFilename="',SourceFilename,'" SourceLine=',SourceLine]);
|
||||
CurProject:=LazarusIDE.ActiveProject;
|
||||
if CurProject=nil then begin
|
||||
Error('no project');
|
||||
@ -302,15 +309,15 @@ procedure TQuickFixLinkerUndefinedReference.Execute(const Msg: TIDEMessageLine;
|
||||
begin
|
||||
inherited Execute(Msg, Step);
|
||||
if Step=imqfoJump then begin
|
||||
DebugLn(['TQuickFixLinkerUndefinedReference.Execute ',Msg.Msg,' ',REMatches(Msg.Msg,'^(.*)\(\.text.*?\): .* `([A-Z0-9_$]+)'':$')]);
|
||||
if REMatches(Msg.Msg,'^(.*)\(\.text.*?\):.*:([0-9]+): .* `([A-Z0-9_$]+)'':$') then
|
||||
//DebugLn(['TQuickFixLinkerUndefinedReference.Execute ',Msg.Msg]);
|
||||
if REMatches(Msg.Msg,'^(.*)\(\.text.*?\):.*:([0-9]+): .* `([a-zA-Z0-9_$]+)''$') then
|
||||
// example: unit1.o(.text+0x3a):unit1.pas:48: undefined reference to `DoesNotExist'
|
||||
JumpTo(Msg,nil)
|
||||
else if (Msg.Position>0) and REMatches(Msg.Msg,'^(.*:[0-9]+)?: .* `(.*)''$') then
|
||||
// example: unit1.pas:37: undefined reference to `DoesNotExist'
|
||||
JumpTo(IDEMessagesWindow[Msg.Position-1],Msg)
|
||||
else if (Msg.Position<IDEMessagesWindow.LinesCount-1)
|
||||
and REMatches(Msg.Msg,'^(.*)\(\.text.*?\): .* `([A-Z0-9_$]+)'':$') then
|
||||
and REMatches(Msg.Msg,'^(.*)\(\.text.*?\): .* `([a-zA-Z0-9_$]+)'':$') then
|
||||
// example: unit1.o(.text+0x1a): In function `SubProc':
|
||||
JumpTo(Msg,IDEMessagesWindow[Msg.Position+1]);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user