|
@@ -82,28 +82,51 @@ end;
|
|
var
|
|
var
|
|
fpcgdbini : text;
|
|
fpcgdbini : text;
|
|
CompilerName : String;
|
|
CompilerName : String;
|
|
|
|
+ FullCompilerName : String;
|
|
|
|
+{$ifdef linux}
|
|
|
|
+ argv0 : pchar;
|
|
|
|
+{$endif}
|
|
Dir,Name,Ext : ShortString;
|
|
Dir,Name,Ext : ShortString;
|
|
GDBError,GDBExitCode,i : longint;
|
|
GDBError,GDBExitCode,i : longint;
|
|
|
|
|
|
begin
|
|
begin
|
|
|
|
|
|
fsplit(paramstr(0),Dir,Name,Ext);
|
|
fsplit(paramstr(0),Dir,Name,Ext);
|
|
|
|
+{$ifdef linux}
|
|
|
|
+ argv0:=argv[0];
|
|
|
|
+ if (argv0 <> '') then
|
|
|
|
+ fsplit(argv0,Dir,Name,Ext);
|
|
|
|
+{$endif}
|
|
if (length(Name)>3) and (UpCase(Name[1])='G') then
|
|
if (length(Name)>3) and (UpCase(Name[1])='G') then
|
|
CompilerName:=Copy(Name,2,255)+Ext
|
|
CompilerName:=Copy(Name,2,255)+Ext
|
|
else
|
|
else
|
|
- CompilerName:=DefaultCompilerName;
|
|
|
|
|
|
+ begin
|
|
|
|
+ if (Name+ext = DefaultCompilerName) then
|
|
|
|
+ begin
|
|
|
|
+ writeln(stderr,'Avoiding infinite recursion with ',Name+Ext,' binary');
|
|
|
|
+ halt(1);
|
|
|
|
+ end;
|
|
|
|
+ CompilerName:=DefaultCompilerName;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ FullCompilerName:=filesearch(CompilerName,Dir+PathSep+GetEnvironmentVariable('PATH'));
|
|
|
|
+
|
|
|
|
+ if FullCompilerName='' then
|
|
|
|
+ begin
|
|
|
|
+ writeln(stderr,'Unable to find ',CompilerName,' binary');
|
|
|
|
+ halt(2);
|
|
|
|
+ end;
|
|
|
|
|
|
- CompilerName:=filesearch(CompilerName,Dir+PathSep+GetEnvironmentVariable('PATH'));
|
|
|
|
|
|
|
|
{ support for info functions directly : used in makefiles }
|
|
{ support for info functions directly : used in makefiles }
|
|
if (paramcount=1) and (pos('-i',Paramstr(1))=1) then
|
|
if (paramcount=1) and (pos('-i',Paramstr(1))=1) then
|
|
begin
|
|
begin
|
|
- Exec(CompilerName,Paramstr(1));
|
|
|
|
|
|
+ Exec(FullCompilerName,Paramstr(1));
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
|
|
{$ifdef EXTDEBUG}
|
|
{$ifdef EXTDEBUG}
|
|
- writeln(stderr,'Using compiler "',CompilerName,'"');
|
|
|
|
|
|
+ writeln(stderr,'Using compiler "',FullCompilerName,'"');
|
|
flush(stderr);
|
|
flush(stderr);
|
|
{$endif}
|
|
{$endif}
|
|
if fsearch(GDBIniTempName,'.')<>'' then
|
|
if fsearch(GDBIniTempName,'.')<>'' then
|
|
@@ -166,6 +189,11 @@ begin
|
|
if GDBExeName='' then
|
|
if GDBExeName='' then
|
|
GDBExeName:=filesearch(GDBAltExeName,Dir+PathSep+GetEnvironmentVariable('PATH'));
|
|
GDBExeName:=filesearch(GDBAltExeName,Dir+PathSep+GetEnvironmentVariable('PATH'));
|
|
|
|
|
|
|
|
+ if GDBExeName='' then
|
|
|
|
+ begin
|
|
|
|
+ writeln('Unable to find ',GDBExeName,' and ',GDBAltExeName);
|
|
|
|
+ halt(3);
|
|
|
|
+ end;
|
|
AdaptToGDB(CompilerName);
|
|
AdaptToGDB(CompilerName);
|
|
AdaptToGDB(GDBIniTempName);
|
|
AdaptToGDB(GDBIniTempName);
|
|
{$ifdef EXTDEBUG}
|
|
{$ifdef EXTDEBUG}
|
|
@@ -173,7 +201,7 @@ begin
|
|
{$ifdef win32}
|
|
{$ifdef win32}
|
|
'--nw '+
|
|
'--nw '+
|
|
{$endif win32}
|
|
{$endif win32}
|
|
- '--nx --command='+GDBIniTempName+' '+CompilerName);
|
|
|
|
|
|
+ '--nx --command='+GDBIniTempName+' '+FullCompilerName);
|
|
flush(stderr);
|
|
flush(stderr);
|
|
{$endif}
|
|
{$endif}
|
|
DosError:=0;
|
|
DosError:=0;
|
|
@@ -181,7 +209,7 @@ begin
|
|
{$ifdef win32}
|
|
{$ifdef win32}
|
|
'--nw '+
|
|
'--nw '+
|
|
{$endif win32}
|
|
{$endif win32}
|
|
- '--nx --command='+GDBIniTempName+' '+CompilerName);
|
|
|
|
|
|
+ '--nx --command='+GDBIniTempName+' '+FullCompilerName);
|
|
GDBError:=DosError;
|
|
GDBError:=DosError;
|
|
GDBExitCode:=DosExitCode;
|
|
GDBExitCode:=DosExitCode;
|
|
if (GDBError<>0) or (GDBExitCode<>0) then
|
|
if (GDBError<>0) or (GDBExitCode<>0) then
|