mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 21:59:16 +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;
|
ShortIdentifier: ShortString;
|
||||||
BestPos: Integer;
|
BestPos: Integer;
|
||||||
ASrcFilename: String;
|
ASrcFilename: String;
|
||||||
|
LinkCode: TCodeBuffer;
|
||||||
|
Link: TSourceLink;
|
||||||
|
i: Integer;
|
||||||
|
CurLine: String;
|
||||||
|
StartPos, EndPos: integer;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
BuildTree(false);
|
BuildTree(false);
|
||||||
@ -1051,7 +1056,47 @@ begin
|
|||||||
BestPos:=0;
|
BestPos:=0;
|
||||||
ShortIdentifier:=UpperCaseStr(copy(Identifier,1,255));
|
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
|
// try to find the function
|
||||||
ProcName:=MangledFunction;
|
ProcName:=MangledFunction;
|
||||||
ProcPos:=1;
|
ProcPos:=1;
|
||||||
@ -1090,12 +1135,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
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;
|
if BestPos<1 then exit;
|
||||||
|
|
||||||
// find jump point
|
// find jump point
|
||||||
|
@ -230,7 +230,7 @@ procedure TQuickFixLinkerUndefinedReference.Execute(const Msg: TIDEMessageLine;
|
|||||||
Identifier:='';
|
Identifier:='';
|
||||||
SourceFilename:='';
|
SourceFilename:='';
|
||||||
SourceLine:=0;
|
SourceLine:=0;
|
||||||
if REMatches(Line1.Msg,'^(.*)\(\.text.*?\): .* `([A-Z0-9_$]+)'':$') then
|
if REMatches(Line1.Msg,'^(.*)\(\.text.*?\): .* `([a-zA-Z0-9_$]+)'':$') then
|
||||||
begin
|
begin
|
||||||
// example: unit1.o(.text+0x1a): In function `SubProc':
|
// example: unit1.o(.text+0x1a): In function `SubProc':
|
||||||
Filename:=REVar(1);
|
Filename:=REVar(1);
|
||||||
@ -249,18 +249,25 @@ procedure TQuickFixLinkerUndefinedReference.Execute(const Msg: TIDEMessageLine;
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
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
|
then begin
|
||||||
// example: unit1.o(.text+0x3a):unit1.pas:48: undefined reference to `DoesNotExist'
|
// example: unit1.o(.text+0x3a):unit1.pas:48: undefined reference to `DoesNotExist'
|
||||||
Filename:=REVar(1);
|
Filename:=REVar(1);
|
||||||
SourceFilename:=REVar(2);
|
SourceFilename:=REVar(2);
|
||||||
SourceLine:=StrToIntDef(REVar(3),0);
|
SourceLine:=StrToIntDef(REVar(3),0);
|
||||||
Identifier:=REVar(4);
|
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
|
end else begin
|
||||||
DebugLn('JumpTo Line1 does not match: "',Line1.Msg,'"');
|
DebugLn('JumpTo Line1 does not match: "',Line1.Msg,'"');
|
||||||
exit;
|
exit;
|
||||||
end;
|
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;
|
CurProject:=LazarusIDE.ActiveProject;
|
||||||
if CurProject=nil then begin
|
if CurProject=nil then begin
|
||||||
Error('no project');
|
Error('no project');
|
||||||
@ -302,15 +309,15 @@ procedure TQuickFixLinkerUndefinedReference.Execute(const Msg: TIDEMessageLine;
|
|||||||
begin
|
begin
|
||||||
inherited Execute(Msg, Step);
|
inherited Execute(Msg, Step);
|
||||||
if Step=imqfoJump then begin
|
if Step=imqfoJump then begin
|
||||||
DebugLn(['TQuickFixLinkerUndefinedReference.Execute ',Msg.Msg,' ',REMatches(Msg.Msg,'^(.*)\(\.text.*?\): .* `([A-Z0-9_$]+)'':$')]);
|
//DebugLn(['TQuickFixLinkerUndefinedReference.Execute ',Msg.Msg]);
|
||||||
if REMatches(Msg.Msg,'^(.*)\(\.text.*?\):.*:([0-9]+): .* `([A-Z0-9_$]+)'':$') then
|
if REMatches(Msg.Msg,'^(.*)\(\.text.*?\):.*:([0-9]+): .* `([a-zA-Z0-9_$]+)''$') then
|
||||||
// example: unit1.o(.text+0x3a):unit1.pas:48: undefined reference to `DoesNotExist'
|
// example: unit1.o(.text+0x3a):unit1.pas:48: undefined reference to `DoesNotExist'
|
||||||
JumpTo(Msg,nil)
|
JumpTo(Msg,nil)
|
||||||
else if (Msg.Position>0) and REMatches(Msg.Msg,'^(.*:[0-9]+)?: .* `(.*)''$') then
|
else if (Msg.Position>0) and REMatches(Msg.Msg,'^(.*:[0-9]+)?: .* `(.*)''$') then
|
||||||
// example: unit1.pas:37: undefined reference to `DoesNotExist'
|
// example: unit1.pas:37: undefined reference to `DoesNotExist'
|
||||||
JumpTo(IDEMessagesWindow[Msg.Position-1],Msg)
|
JumpTo(IDEMessagesWindow[Msg.Position-1],Msg)
|
||||||
else if (Msg.Position<IDEMessagesWindow.LinesCount-1)
|
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':
|
// example: unit1.o(.text+0x1a): In function `SubProc':
|
||||||
JumpTo(Msg,IDEMessagesWindow[Msg.Position+1]);
|
JumpTo(Msg,IDEMessagesWindow[Msg.Position+1]);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user