소스 검색

Add new utility function vgppcx64

  This works like gppc386 but for 'valgrind' instead of 'gdb'.
Pierre Muller 1 개월 전
부모
커밋
843cc4b796
3개의 변경된 파일198개의 추가작업 그리고 3개의 파일을 삭제
  1. 21 3
      compiler/utils/Makefile
  2. 2 0
      compiler/utils/Makefile.fpc
  3. 175 0
      compiler/utils/vppcx64.pp

+ 21 - 3
compiler/utils/Makefile

@@ -2071,6 +2071,7 @@ STATICLIBPREFIX=libp
 IMPORTLIBPREFIX=libimp
 IMPORTLIBPREFIX=libimp
 RSTEXT=.rsj
 RSTEXT=.rsj
 EXEDBGEXT=.dbg
 EXEDBGEXT=.dbg
+ALL_EXEEXT=.exe
 ifeq ($(OS_TARGET),go32v1)
 ifeq ($(OS_TARGET),go32v1)
 STATICLIBPREFIX=
 STATICLIBPREFIX=
 SHORTSUFFIX=v1
 SHORTSUFFIX=v1
@@ -2167,6 +2168,7 @@ ifeq ($(OS_TARGET),atari)
 EXEEXT=.ttp
 EXEEXT=.ttp
 SHORTSUFFIX=ata
 SHORTSUFFIX=ata
 endif
 endif
+ALL_EXEEXT+=.ttp
 ifeq ($(OS_TARGET),beos)
 ifeq ($(OS_TARGET),beos)
 BATCHEXT=.sh
 BATCHEXT=.sh
 EXEEXT=
 EXEEXT=
@@ -2193,6 +2195,7 @@ STATICLIBPREFIX=
 SHORTSUFFIX=nw
 SHORTSUFFIX=nw
 IMPORTLIBPREFIX=imp
 IMPORTLIBPREFIX=imp
 endif
 endif
+ALL_EXEEXT+=.nlm
 ifeq ($(OS_TARGET),netwlibc)
 ifeq ($(OS_TARGET),netwlibc)
 EXEEXT=.nlm
 EXEEXT=.nlm
 STATICLIBPREFIX=
 STATICLIBPREFIX=
@@ -2218,6 +2221,7 @@ EXEEXT=.gba
 SHAREDLIBEXT=.so
 SHAREDLIBEXT=.so
 SHORTSUFFIX=gba
 SHORTSUFFIX=gba
 endif
 endif
+ALL_EXEEXT+=.gba
 ifeq ($(OS_TARGET),symbian)
 ifeq ($(OS_TARGET),symbian)
 SHAREDLIBEXT=.dll
 SHAREDLIBEXT=.dll
 SHORTSUFFIX=symbian
 SHORTSUFFIX=symbian
@@ -2231,6 +2235,7 @@ EXEEXT=.dol
 SHAREDLIBEXT=.so
 SHAREDLIBEXT=.so
 SHORTSUFFIX=wii
 SHORTSUFFIX=wii
 endif
 endif
+ALL_EXEEXT+=.dol
 ifeq ($(OS_TARGET),aix)
 ifeq ($(OS_TARGET),aix)
 BATCHEXT=.sh
 BATCHEXT=.sh
 EXEEXT=
 EXEEXT=
@@ -2273,6 +2278,7 @@ OEXT=.rel
 endif
 endif
 SHORTSUFFIX=emb
 SHORTSUFFIX=emb
 endif
 endif
+ALL_EXEEXT+=.bin
 ifeq ($(OS_TARGET),win16)
 ifeq ($(OS_TARGET),win16)
 STATICLIBPREFIX=
 STATICLIBPREFIX=
 STATICLIBEXT=.a
 STATICLIBEXT=.a
@@ -2285,6 +2291,7 @@ endif
 ifeq ($(OS_TARGET),wasip1)
 ifeq ($(OS_TARGET),wasip1)
 EXEEXT=.wasm
 EXEEXT=.wasm
 endif
 endif
+ALL_EXEEXT+=.wasm
 ifeq ($(OS_TARGET),wasip1threads)
 ifeq ($(OS_TARGET),wasip1threads)
 EXEEXT=.wasm
 EXEEXT=.wasm
 endif
 endif
@@ -3122,6 +3129,7 @@ endif
 ifndef CROSSINSTALL
 ifndef CROSSINSTALL
 ifneq ($(TARGET_PROGRAMS),)
 ifneq ($(TARGET_PROGRAMS),)
 override EXEFILES=$(addsuffix $(EXEEXT),$(TARGET_PROGRAMS))
 override EXEFILES=$(addsuffix $(EXEEXT),$(TARGET_PROGRAMS))
+override ALL_EXEFILES+=$(foreach lEXEEXT,$(ALL_EXEEXT),$(addprefix $(TARGETDIRPREFIX),$(addsuffix $(lEXEEXT), $(EXEFILES))))
 override EXEOFILES:=$(addsuffix $(OEXT),$(TARGET_PROGRAMS)) $(addsuffix $(LTOEXT),$(TARGET_PROGRAMS))$(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_PROGRAMS))) $(addprefix $(IMPORTLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_PROGRAMS)))
 override EXEOFILES:=$(addsuffix $(OEXT),$(TARGET_PROGRAMS)) $(addsuffix $(LTOEXT),$(TARGET_PROGRAMS))$(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_PROGRAMS))) $(addprefix $(IMPORTLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_PROGRAMS)))
 override EXEDBGFILES:=$(addsuffix $(EXEDBGEXT),$(TARGET_PROGRAMS))
 override EXEDBGFILES:=$(addsuffix $(EXEDBGEXT),$(TARGET_PROGRAMS))
 override ALLTARGET+=fpc_exes
 override ALLTARGET+=fpc_exes
@@ -3251,6 +3259,10 @@ ifdef INSTALL_CREATEPACKAGEFPC
 ifdef FPCMAKE
 ifdef FPCMAKE
 ifdef PACKAGE_VERSION
 ifdef PACKAGE_VERSION
 ifneq ($(wildcard Makefile.fpc),)
 ifneq ($(wildcard Makefile.fpc),)
+ifdef FPCMAKENEW
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(FPCMAKENEW) -o $(INSTALL_UNITDIR)/Package.fpc -p -T$(CPU_TARGET)-$(OS_TARGET) Makefile.fpc
+else
 	$(FPCMAKE) -p -T$(CPU_TARGET)-$(OS_TARGET) Makefile.fpc
 	$(FPCMAKE) -p -T$(CPU_TARGET)-$(OS_TARGET) Makefile.fpc
 	$(MKDIR) $(INSTALL_UNITDIR)
 	$(MKDIR) $(INSTALL_UNITDIR)
 	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
 	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
@@ -3258,6 +3270,7 @@ endif
 endif
 endif
 endif
 endif
 endif
 endif
+endif
 ifdef INSTALLPPUFILES
 ifdef INSTALLPPUFILES
 	$(MKDIR) $(INSTALL_UNITDIR)
 	$(MKDIR) $(INSTALL_UNITDIR)
 	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
 	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
@@ -3296,6 +3309,7 @@ override CLEANEXEDBGFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEDBGFILES))
 endif
 endif
 ifdef CLEAN_PROGRAMS
 ifdef CLEAN_PROGRAMS
 override CLEANEXEFILES+=$(addprefix $(TARGETDIRPREFIX),$(addsuffix $(EXEEXT), $(CLEAN_PROGRAMS)))
 override CLEANEXEFILES+=$(addprefix $(TARGETDIRPREFIX),$(addsuffix $(EXEEXT), $(CLEAN_PROGRAMS)))
+override ALL_CLEANEXEFILES+=$(foreach lEXEEXT,$(ALL_EXEEXT),$(addprefix $(TARGETDIRPREFIX),$(addsuffix $(lEXEEXT), $(CLEAN_PROGRAMS))))
 override CLEANEXEDBGFILES+=$(addprefix $(TARGETDIRPREFIX),$(addsuffix $(EXEDBGEXT), $(CLEAN_PROGRAMS)))
 override CLEANEXEDBGFILES+=$(addprefix $(TARGETDIRPREFIX),$(addsuffix $(EXEDBGEXT), $(CLEAN_PROGRAMS)))
 endif
 endif
 ifdef CLEAN_UNITS
 ifdef CLEAN_UNITS
@@ -3334,12 +3348,15 @@ ifdef LIB_NAME
 	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
 	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
 endif
 endif
 	-$(DEL) $(FPCMADE) *$(FULL_TARGET).fpm Package.fpc *$(ASMEXT)
 	-$(DEL) $(FPCMADE) *$(FULL_TARGET).fpm Package.fpc *$(ASMEXT)
-	-$(DEL) $(FPCEXTFILE) $(REDIRFILE) script*.res link*.res *_script.res *_link.res
+	-$(DEL) $(FPCEXTFILE) $(REDIRFILE) script*.res link*.res *_script.res *_link.res symbol_order*.fpc
 	-$(DEL) $(PPAS) *_ppas$(BATCHEXT) ppas$(BATCHEXT) ppaslink$(BATCHEXT)
 	-$(DEL) $(PPAS) *_ppas$(BATCHEXT) ppas$(BATCHEXT) ppaslink$(BATCHEXT)
 fpc_cleanall: $(CLEANTARGET)
 fpc_cleanall: $(CLEANTARGET)
 ifdef CLEANEXEFILES
 ifdef CLEANEXEFILES
 	-$(DEL) $(CLEANEXEFILES)
 	-$(DEL) $(CLEANEXEFILES)
 endif
 endif
+ifdef ALL_CLEANEXEFILES
+	-$(DEL) $(ALL_CLEANEXEFILES)
+endif
 ifdef COMPILER_UNITTARGETDIR
 ifdef COMPILER_UNITTARGETDIR
 ifdef CLEANPPUFILES
 ifdef CLEANPPUFILES
 	-$(DEL) $(CLEANPPUFILES)
 	-$(DEL) $(CLEANPPUFILES)
@@ -3361,8 +3378,8 @@ ifneq ($(PPUEXT),.ppu)
 	-$(DEL) *.o *.ppu *.a
 	-$(DEL) *.o *.ppu *.a
 endif
 endif
 	-$(DELTREE) *$(SMARTEXT)
 	-$(DELTREE) *$(SMARTEXT)
-	-$(DEL) fpcmade.* Package.fpc *.fpm
-	-$(DEL) $(FPCEXTFILE) $(REDIRFILE) script*.res link*.res *_script.res *_link.res
+	-$(DEL) fpcmade.* Package*.fpc *.fpm
+	-$(DEL) $(FPCEXTFILE) $(REDIRFILE) script*.res link*.res *_script.res *_link.res symbol_order*.fpc
 	-$(DEL) $(PPAS) *_ppas$(BATCHEXT) ppas$(BATCHEXT) ppaslink$(BATCHEXT)
 	-$(DEL) $(PPAS) *_ppas$(BATCHEXT) ppas$(BATCHEXT) ppaslink$(BATCHEXT)
 ifdef AOUTEXT
 ifdef AOUTEXT
 	-$(DEL) *$(AOUTEXT)
 	-$(DEL) *$(AOUTEXT)
@@ -3539,6 +3556,7 @@ ppumove$(EXEEXT): ppumove.pp ppu$(PPUEXT)
 endif
 endif
 msg2inc$(EXEEXT): $(COMPILER_UNITTARGETDIR) msg2inc.pp
 msg2inc$(EXEEXT): $(COMPILER_UNITTARGETDIR) msg2inc.pp
 gppc386$(EXEEXT): $(COMPILER_UNITTARGETDIR) gppc386.pp
 gppc386$(EXEEXT): $(COMPILER_UNITTARGETDIR) gppc386.pp
+vppcx64$(EXEEXT): $(COMPILER_UNITTARGETDIR) vppcx64.pp
 fpcsubst$(EXEEXT): fpcsubst.pp usubst.pp
 fpcsubst$(EXEEXT): fpcsubst.pp usubst.pp
 fpcmkcfg$(EXEEXT): fpcmkcfg.pp usubst.pp fpccfg.inc fpcfg.inc fpini.inc
 fpcmkcfg$(EXEEXT): fpcmkcfg.pp usubst.pp fpccfg.inc fpcfg.inc fpini.inc
 ifneq ($(DATA2INC),)
 ifneq ($(DATA2INC),)

+ 2 - 0
compiler/utils/Makefile.fpc

@@ -74,6 +74,8 @@ msg2inc$(EXEEXT): $(COMPILER_UNITTARGETDIR) msg2inc.pp
 
 
 gppc386$(EXEEXT): $(COMPILER_UNITTARGETDIR) gppc386.pp
 gppc386$(EXEEXT): $(COMPILER_UNITTARGETDIR) gppc386.pp
 
 
+vppcx64$(EXEEXT): $(COMPILER_UNITTARGETDIR) vppcx64.pp
+
 fpcsubst$(EXEEXT): fpcsubst.pp usubst.pp
 fpcsubst$(EXEEXT): fpcsubst.pp usubst.pp
 
 
 fpcmkcfg$(EXEEXT): fpcmkcfg.pp usubst.pp fpccfg.inc fpcfg.inc fpini.inc
 fpcmkcfg$(EXEEXT): fpcmkcfg.pp usubst.pp fpccfg.inc fpcfg.inc fpini.inc

+ 175 - 0
compiler/utils/vppcx64.pp

@@ -0,0 +1,175 @@
+{
+    Copyright (c) 2000-2002 by Pierre Muller
+
+    This program allows to run the Makefiles
+    with the compiler running inside valgrind
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************}
+
+{$mode objfpc}
+{ Use ansitrings for long PATH variables }
+{$H+}
+program fpc_with_valgrind;
+
+{
+  This program uses several files :
+
+   -- 'valgrind.fpc' is an optional file that can contain optional
+      commmand line parameters for valgrind.
+
+  Use EXTDEBUG conditional to get debug information.
+}
+
+uses
+  sysutils,
+  dos;
+
+const
+{$ifdef Unix}
+  ValgrindPasExeName : String = 'valgrindpas';
+  ValgrindDefaultExeName = 'valgrind';
+  DefaultCompilerName = 'ppcx64';
+  PathSep=':';
+  DirSep = '/';
+{$else}
+  ValgrindPasExeName : String = 'valgrindpas.exe';
+  ValgrindDefaultExeName = 'valgrind.exe';
+  DefaultCompilerName = 'ppcx64.exe';
+  PathSep=';';
+  DirSep = '\';
+{$endif not linux}
+
+  { If you add a valgrind.fpc file in a given directory   }
+  { This executable will read it; this allows you to add  }
+  { specific command line options to valgrind call. PM    }
+  FpcValgrindIniName  : string = 'valgrind.fpc';
+
+{ Dos/Windows Valgrind still need forward slashes }
+procedure AdaptToValgrind(var filename : string);
+var
+  i : longint;
+begin
+  for i:=1 to length(filename) do
+    if filename[i]='\' then
+      filename[i]:='/';
+end;
+
+var
+   all_args : String;
+   ValGrindExeName : String;
+   CompilerName : String;
+   FullCompilerName : String;
+{$ifdef linux}
+   argv0 : pchar;
+{$endif}
+   Dir,Name,Ext,Param : ShortString;
+   ValgrindError,ValgrindExitCode,i : longint;
+   line : string;
+   f : text;
+
+begin
+  all_args:='';
+  if FileExists('.'+DirSep+FpcValgrindIniName) then
+    begin
+      Assign(F,'.'+DirSep+FpcValgrindIniName);
+      while not eof(F) do
+        begin
+          readln(f,line);
+	  all_args:=all_args+' '+line;
+	end;
+    end;
+
+  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])='V') then
+    CompilerName:=Copy(Name,2,255)+Ext
+  else
+    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;
+
+
+  { support for info functions directly : used in makefiles }
+  if (paramcount=1) and (pos('-i',Paramstr(1))=1) then
+    begin
+      Exec(FullCompilerName,Paramstr(1));
+      exit;
+    end;
+
+  {$ifdef EXTDEBUG}
+  writeln(stderr,'Using compiler "',FullCompilerName,'"');
+  flush(stderr);
+  {$endif}
+  { this will not work correctly if there are " or '' inside the command line :( }
+  for i:=1 to Paramcount do
+    begin
+      Param:=Paramstr(i);
+      if pos(' ',Param)>0 then
+        all_args:=all_args+' "'+Param+'"'
+      else
+        all_args:=all_args+' '+Param;
+    end;
+
+  ValgrindExeName:=filesearch(ValgrindPasExeName,Dir+PathSep+GetEnvironmentVariable('PATH'));
+  if ValgrindExeName='' then
+    ValgrindExeName:=filesearch(ValgrindDefaultExeName,Dir+PathSep+GetEnvironmentVariable('PATH'));
+
+  if ValgrindExeName='' then
+    begin
+      writeln('Unable to find ',ValgrindDefaultExeName,' and ',ValgrindPasExeName);
+      halt(3);
+    end;
+  AdaptToValgrind(FullCompilerName);
+  {$ifdef EXTDEBUG}
+  Writeln(stderr,'Starting ',ValgrindExeName+' '+FullCompilerName);
+  flush(stderr);
+  {$endif}
+   DosError:=0;
+   Exec(ValgrindExeName,FullCompilerName+all_args);
+  ValgrindError:=DosError;
+  ValgrindExitCode:=DosExitCode;
+  if (ValgrindError<>0) or (ValgrindExitCode<>0) then
+    begin
+      Writeln('Error running Valgrind');
+      if (ValgrindError<>0) then
+        Writeln('DosError = ',ValgrindError);
+      if (ValgrindExitCode<>0) then
+        Writeln('DosExitCode = ',ValgrindExitCode);
+      if ValgrindExitCode<>0 then
+        RunError(ValgrindExitCode)
+      else
+        RunError(ValgrindError);
+    end;
+end.