Sfoglia il codice sorgente

+ profiling support for Win32

carl 23 anni fa
parent
commit
65113dcece
4 ha cambiato i file con 44 aggiunte e 22 eliminazioni
  1. 16 7
      compiler/ncgutil.pas
  2. 19 12
      compiler/systems/t_win32.pas
  3. 4 2
      rtl/win32/Makefile
  4. 5 1
      rtl/win32/Makefile.fpc

+ 16 - 7
compiler/ncgutil.pas

@@ -1234,9 +1234,18 @@ function returns in a register and the caller receives it in an other one}
           code, since temp. allocation might occur before - carl
           code, since temp. allocation might occur before - carl
         }
         }
 
 
-        if (cs_profile in aktmoduleswitches) and
-              not(po_assembler in aktprocdef.procoptions) and not(inlined) then
-            cg.g_profilecode(list);
+        if (cs_profile in aktmoduleswitches) 
+         and not(po_assembler in aktprocdef.procoptions) 
+         and not(inlined) then
+          begin
+            { non-win32 can call mcout even in main }
+            if not (target_info.system in [system_i386_win32,system_i386_wdosx])  then
+              cg.g_profilecode(list)
+            else
+            { wdosx, and win32 should not call mcount before monstartup has been called }
+            if not (aktprocdef.proctypeoption=potype_proginit) then
+              cg.g_profilecode(list);
+          end;
 
 
         { for the save all registers we can simply use a pusha,popa which
         { for the save all registers we can simply use a pusha,popa which
           push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
           push edi,esi,ebp,esp(ignored),ebx,edx,ecx,eax }
@@ -1643,9 +1652,6 @@ function returns in a register and the caller receives it in an other one}
            (not inlined) and
            (not inlined) and
            (aktprocdef.proctypeoption=potype_proginit) then
            (aktprocdef.proctypeoption=potype_proginit) then
          begin
          begin
-           {if (target_info.system=system_i386_win32) and
-              (cs_profile in aktmoduleswitches) then
-             cg.a_call_name(list,'__mcleanup');   }
            cg.a_call_name(list,'FPC_DO_EXIT');
            cg.a_call_name(list,'FPC_DO_EXIT');
          end;
          end;
 
 
@@ -1876,7 +1882,10 @@ function returns in a register and the caller receives it in an other one}
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.66  2002-11-30 14:39:15  carl
+  Revision 1.67  2002-11-30 18:44:57  carl
+    + profiling support for Win32
+
+  Revision 1.66  2002/11/30 14:39:15  carl
     * try to fix profiling for win32
     * try to fix profiling for win32
 
 
   Revision 1.65  2002/11/28 23:28:14  florian
   Revision 1.65  2002/11/28 23:28:14  florian

+ 19 - 12
compiler/systems/t_win32.pas

@@ -905,33 +905,37 @@ begin
      HPath:=TStringListItem(HPath.Next);
      HPath:=TStringListItem(HPath.Next);
    end;
    end;
 
 
-  { add objectfiles, start with prt0 always }
+  { add objectfiles, start with prt0 always                  }
+  { profiling of shared libraries is currently not supported }
   LinkRes.Add('INPUT(');
   LinkRes.Add('INPUT(');
   if isdll then
   if isdll then
    LinkRes.AddFileName(GetShortName(FindObjectFile('wdllprt0','')))
    LinkRes.AddFileName(GetShortName(FindObjectFile('wdllprt0','')))
   else
   else
+  if (cs_profile in aktmoduleswitches) then
+   LinkRes.AddFileName(GetShortName(FindObjectFile('gprt0','')))
+  else 
    LinkRes.AddFileName(GetShortName(FindObjectFile('wprt0','')));
    LinkRes.AddFileName(GetShortName(FindObjectFile('wprt0','')));
-  if cs_profile in aktmoduleswitches then
-   LinkRes.AddFileName(GetShortName(FindObjectFile('mcount','')));
   while not ObjectFiles.Empty do
   while not ObjectFiles.Empty do
    begin
    begin
      s:=ObjectFiles.GetFirst;
      s:=ObjectFiles.GetFirst;
      if s<>'' then
      if s<>'' then
       LinkRes.AddFileName(GetShortName(s));
       LinkRes.AddFileName(GetShortName(s));
    end;
    end;
-  { add libaries required for profiling }
-  if cs_profile in aktmoduleswitches then
-   begin
-     LinkRes.Add('-lgmon');
-     LinkRes.Add('-lkernel32');
-     LinkRes.Add('-lmsvcrt');
-   end;
   LinkRes.Add(')');
   LinkRes.Add(')');
 
 
+
   { Write staticlibraries }
   { Write staticlibraries }
-  if not StaticLibFiles.Empty then
+  if (not StaticLibFiles.Empty) or (cs_profile in aktmoduleswitches) then
    begin
    begin
      LinkRes.Add('GROUP(');
      LinkRes.Add('GROUP(');
+     if (cs_profile in aktmoduleswitches) then
+       begin
+         LinkRes.Add('-lgcc');
+         LinkRes.Add('-lmoldname');
+         LinkRes.Add('-lmsvcrt');
+         LinkRes.Add('-lgmon');
+         LinkRes.Add('-lkernel32');
+       end;
      While not StaticLibFiles.Empty do
      While not StaticLibFiles.Empty do
       begin
       begin
         S:=StaticLibFiles.GetFirst;
         S:=StaticLibFiles.GetFirst;
@@ -1613,7 +1617,10 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2002-11-16 18:40:38  carl
+  Revision 1.7  2002-11-30 18:45:28  carl
+    + profiling support for Win32
+
+  Revision 1.6  2002/11/16 18:40:38  carl
     - remove my last stupid commit (Thanks, Peter!)
     - remove my last stupid commit (Thanks, Peter!)
 
 
   Revision 1.5  2002/11/16 14:46:50  carl
   Revision 1.5  2002/11/16 14:46:50  carl

+ 4 - 2
rtl/win32/Makefile

@@ -1,5 +1,5 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 1.1 [2002/11/28]
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/11/30]
 #
 #
 default: all
 default: all
 MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx
 MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx
@@ -235,7 +235,7 @@ GRAPHDIR=$(INC)/graph
 include $(WININC)/makefile.inc
 include $(WININC)/makefile.inc
 WINDOWS_SOURCE_FILES=$(addprefix $(WININC)/,$(addsuffix .inc,$(WINDOWS_FILES)))
 WINDOWS_SOURCE_FILES=$(addprefix $(WININC)/,$(addsuffix .inc,$(WINDOWS_FILES)))
 override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas strings lineinfo heaptrc windows ole2 activex winsock initc dos crt objects graph messages sysutils typinfo math varutils variants cpu mmx charset ucomplex getopts wincrt winmouse winevent sockets printer dynlibs video mouse keyboard types comobj
 override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas strings lineinfo heaptrc windows ole2 activex winsock initc dos crt objects graph messages sysutils typinfo math varutils variants cpu mmx charset ucomplex getopts wincrt winmouse winevent sockets printer dynlibs video mouse keyboard types comobj
-override TARGET_LOADERS+=wprt0 wdllprt0
+override TARGET_LOADERS+=wprt0 wdllprt0 gprt0
 override TARGET_RSTS+=math varutils typinfo
 override TARGET_RSTS+=math varutils typinfo
 override INSTALL_FPCPACKAGE=y
 override INSTALL_FPCPACKAGE=y
 override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC)
 override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC)
@@ -1204,6 +1204,8 @@ SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))
 SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
 SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
 wprt0$(OEXT) : $(PRT0).as
 wprt0$(OEXT) : $(PRT0).as
 	$(AS) -o wprt0$(OEXT) $(PRT0).as
 	$(AS) -o wprt0$(OEXT) $(PRT0).as
+gprt0$(OEXT) : gprt0.as
+	$(AS) -o gprt0$(OEXT) gprt0.as
 wdllprt0$(OEXT) : wdllprt0.as
 wdllprt0$(OEXT) : wdllprt0.as
 	$(AS) -o wdllprt0$(OEXT) wdllprt0.as
 	$(AS) -o wdllprt0$(OEXT) wdllprt0.as
 $(SYSTEMUNIT)$(PPUEXT) : $(SYSTEMUNIT).pp win32.inc $(SYSDEPS)
 $(SYSTEMUNIT)$(PPUEXT) : $(SYSTEMUNIT).pp win32.inc $(SYSDEPS)

+ 5 - 1
rtl/win32/Makefile.fpc

@@ -6,7 +6,7 @@
 main=rtl
 main=rtl
 
 
 [target]
 [target]
-loaders=wprt0 wdllprt0
+loaders=wprt0 wdllprt0 gprt0
 units=$(SYSTEMUNIT) systhrds objpas strings \
 units=$(SYSTEMUNIT) systhrds objpas strings \
       lineinfo heaptrc \
       lineinfo heaptrc \
       windows ole2 activex winsock initc \
       windows ole2 activex winsock initc \
@@ -92,6 +92,10 @@ SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
 
 
 wprt0$(OEXT) : $(PRT0).as
 wprt0$(OEXT) : $(PRT0).as
         $(AS) -o wprt0$(OEXT) $(PRT0).as
         $(AS) -o wprt0$(OEXT) $(PRT0).as
+        
+gprt0$(OEXT) : gprt0.as
+        $(AS) -o gprt0$(OEXT) gprt0.as
+        
 
 
 wdllprt0$(OEXT) : wdllprt0.as
 wdllprt0$(OEXT) : wdllprt0.as
         $(AS) -o wdllprt0$(OEXT) wdllprt0.as
         $(AS) -o wdllprt0$(OEXT) wdllprt0.as