mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 11:19:23 +02:00
ide: fixed parsing fpc linker error ld.bfd and file:linenumber: msg
This commit is contained in:
parent
26a0f8d7e4
commit
fe4a986145
@ -1505,11 +1505,78 @@ end;
|
|||||||
function TIDEFPCParser.CheckForLinkerErrors(p: PChar): boolean;
|
function TIDEFPCParser.CheckForLinkerErrors(p: PChar): boolean;
|
||||||
const
|
const
|
||||||
patUndefinedSymbol: String = 'Undefined symbols for architecture';
|
patUndefinedSymbol: String = 'Undefined symbols for architecture';
|
||||||
patLD: String = '/usr/bin/ld: ';
|
patLD: String = '/usr/bin/ld';
|
||||||
|
|
||||||
|
function FindLeadingFilename(MinP, FileEndP: PChar; out FileStartP: PChar): boolean;
|
||||||
|
begin
|
||||||
|
FileStartP:=FileEndP;
|
||||||
|
while FileStartP>MinP do
|
||||||
|
begin
|
||||||
|
dec(FileStartP);
|
||||||
|
if FileStartP^=':' then
|
||||||
|
begin
|
||||||
|
if FileStartP[1]=' ' then begin
|
||||||
|
// e.g. "/usr/bin/ld: filename"
|
||||||
|
inc(FileStartP,2);
|
||||||
|
exit(FileStartP<FileEndP);
|
||||||
|
end else if (FileStartP>MinP) and (FileStartP[-1] in ['a'..'z','A'..'Z'])
|
||||||
|
and ((FileStartP-1=MinP)
|
||||||
|
or (FileStartP[-2] in [':',' ']))
|
||||||
|
and (FileStartP[1] in ['/','\']) then
|
||||||
|
begin
|
||||||
|
// e.g C:\filename
|
||||||
|
dec(FileStartP,2);
|
||||||
|
exit(true);
|
||||||
|
end else begin
|
||||||
|
inc(FileStartP);
|
||||||
|
exit(FileStartP<FileEndP);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function FindFileLineNumberMsg(StartP: PChar; out FileStartP, FileEndP: PChar;
|
||||||
|
out LineNumber: Integer; out MsgStartP: PChar): boolean;
|
||||||
|
var
|
||||||
|
CurP: PChar;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
FileStartP:=nil;
|
||||||
|
FileEndP:=nil;
|
||||||
|
LineNumber:=0;
|
||||||
|
MsgStartP:=nil;
|
||||||
|
|
||||||
|
CurP:=StartP;
|
||||||
|
while CurP^<>#0 do
|
||||||
|
begin
|
||||||
|
if (CurP^=':') and (CurP[1] in ['0'..'9']) then
|
||||||
|
begin
|
||||||
|
FileEndP:=CurP;
|
||||||
|
inc(CurP);
|
||||||
|
while (CurP^ in ['0'..'9']) do
|
||||||
|
begin
|
||||||
|
LineNumber:=LineNumber*10+ord(CurP^)-ord('0');
|
||||||
|
if LineNumber>1000000 then break;
|
||||||
|
inc(CurP);
|
||||||
|
end;
|
||||||
|
if (LineNumber>0) and (CurP^=':') and (CurP[1]=' ')
|
||||||
|
and FindLeadingFilename(p,FileEndP,FileStartP) then
|
||||||
|
begin
|
||||||
|
MsgStartP:=CurP+2;
|
||||||
|
exit(true);
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
inc(CurP);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
MsgLine: TMessageLine;
|
MsgLine: TMessageLine;
|
||||||
Urgency: TMessageLineUrgency;
|
Urgency: TMessageLineUrgency;
|
||||||
s: string;
|
s: string;
|
||||||
|
FileStartP, FileEndP, MsgStartP: PChar;
|
||||||
|
LineNumber: Integer;
|
||||||
begin
|
begin
|
||||||
if CompareMem(PChar(patUndefinedSymbol),p,length(patUndefinedSymbol)) then
|
if CompareMem(PChar(patUndefinedSymbol),p,length(patUndefinedSymbol)) then
|
||||||
begin
|
begin
|
||||||
@ -1521,6 +1588,21 @@ begin
|
|||||||
inherited AddMsgLine(MsgLine);
|
inherited AddMsgLine(MsgLine);
|
||||||
exit(true);
|
exit(true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// check for "filename:linenumber: error message"
|
||||||
|
if FindFileLineNumberMsg(p,FileStartP,FileEndP,LineNumber,MsgStartP) then
|
||||||
|
begin
|
||||||
|
MsgLine:=CreateMsgLine;
|
||||||
|
MsgLine.MsgID:=0;
|
||||||
|
MsgLine.SubTool:=SubToolFPCLinker;
|
||||||
|
MsgLine.Urgency:=mluError;
|
||||||
|
MsgLine.Filename:=GetString(FileStartP,FileEndP-FileStartP);
|
||||||
|
MsgLine.Line:=LineNumber;
|
||||||
|
MsgLine.Msg:='linker: '+MsgStartP;
|
||||||
|
inherited AddMsgLine(MsgLine);
|
||||||
|
exit(true);
|
||||||
|
end;
|
||||||
|
|
||||||
if CompareMem(PChar(patLD),p,length(patLD)) then
|
if CompareMem(PChar(patLD),p,length(patLD)) then
|
||||||
begin
|
begin
|
||||||
MsgLine:=CreateMsgLine;
|
MsgLine:=CreateMsgLine;
|
||||||
@ -1540,6 +1622,7 @@ begin
|
|||||||
inherited AddMsgLine(MsgLine);
|
inherited AddMsgLine(MsgLine);
|
||||||
exit(true);
|
exit(true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result:=false;
|
Result:=false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user