Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 121658 | Differences between
and this patch

Collapse All | Expand All

(-)src-native-new/src/transport/transportSupport/TransportSupport.mak64 (-16 / +16 lines)
Lines 72-81 Link Here
72
"$(OUTDIR)" :
72
"$(OUTDIR)" :
73
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
73
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
74
74
75
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /I "$(RAC_SDK_HOME)/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\TransportSupport.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
75
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /I "../RACommon" /I "../RASocket" /I "../RASharedMemory" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\TransportSupport.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
76
76
77
LINK32=link.exe
77
LINK32=link.exe
78
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib tptpUtils.lib hcclco.lib hcclsm.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\TransportSupport.pdb" /debug /def:".\TransportSupport.def" /out:"$(OUTDIR)\TransportSupport.dll" /implib:"../../../lib/transportSupport.lib" /libpath:"../../../lib" /libpath:"$(RAC_SDK_HOME)/lib" /machine:IA64
78
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib tptpUtils.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\TransportSupport.pdb" /debug /def:".\TransportSupport.def" /out:"$(OUTDIR)\TransportSupport.dll" /implib:"../../../lib/transportSupport.lib" /libpath:"../../../lib" /machine:IA64
79
LINK32_OBJS= \
79
LINK32_OBJS= \
80
	"$(INTDIR)\TransportOSCalls_linux.obj" \
80
	"$(INTDIR)\TransportOSCalls_linux.obj" \
81
	"$(INTDIR)\TransportOSCalls_win.obj" \
81
	"$(INTDIR)\TransportOSCalls_win.obj" \
Lines 87-94 Link Here
87
	"$(INTDIR)\TransportSupportSharedMemExt.obj" \
87
	"$(INTDIR)\TransportSupportSharedMemExt.obj" \
88
	"$(INTDIR)\TransportSupportSocket.obj" \
88
	"$(INTDIR)\TransportSupportSocket.obj" \
89
	"..\..\..\lib\tptpUtils.lib" \
89
	"..\..\..\lib\tptpUtils.lib" \
90
	"$(RAC_SDK_HOME)\lib\hcclco.lib" \
90
	"..\..\..\lib\hcclco.lib" \
91
	"$(RAC_SDK_HOME)\lib\hcclsm.lib"
91
	"..\..\..\lib\hcclsm.lib"
92
92
93
"$(OUTDIR)\TransportSupport.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
93
"$(OUTDIR)\TransportSupport.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
94
    $(LINK32) @<<
94
    $(LINK32) @<<
Lines 139-148 Link Here
139
"$(INTDIR)" :
139
"$(INTDIR)" :
140
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
140
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
141
141
142
CPP_PROJ=/nologo /MD /W3 /O2 /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /I "$(RAC_SDK_HOME)/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\TransportSupport.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
142
CPP_PROJ=/nologo /MD /W3 /O2 /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /I "../RACommon" /I "../RASocket" /I "../RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\TransportSupport.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
143
143
144
LINK32=link.exe
144
LINK32=link.exe
145
LINK32_FLAGS=advapi32.lib uuid.lib ws2_32.lib tptpUtils.lib hcclco.lib hcclsm.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\TransportSupport.pdb" /def:".\TransportSupport.def" /out:"$(OUTDIR)\TransportSupport.dll" /implib:"../../../lib/transportSupport.lib" /libpath:"../../../lib" /libpath:"$(RAC_SDK_HOME)/lib" /machine:IA64 
145
LINK32_FLAGS=advapi32.lib uuid.lib ws2_32.lib tptpUtils.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\TransportSupport.pdb" /def:".\TransportSupport.def" /out:"$(OUTDIR)\TransportSupport.dll" /implib:"../../../lib/transportSupport.lib" /libpath:"../../../lib" /machine:IA64 
146
LINK32_OBJS= \
146
LINK32_OBJS= \
147
	"$(INTDIR)\TransportOSCalls_linux.obj" \
147
	"$(INTDIR)\TransportOSCalls_linux.obj" \
148
	"$(INTDIR)\TransportOSCalls_win.obj" \
148
	"$(INTDIR)\TransportOSCalls_win.obj" \
Lines 154-161 Link Here
154
	"$(INTDIR)\TransportSupportSharedMemExt.obj" \
154
	"$(INTDIR)\TransportSupportSharedMemExt.obj" \
155
	"$(INTDIR)\TransportSupportSocket.obj" \
155
	"$(INTDIR)\TransportSupportSocket.obj" \
156
	"..\..\..\lib\tptpUtils.lib" \
156
	"..\..\..\lib\tptpUtils.lib" \
157
	"$(RAC_SDK_HOME)\lib\hcclsm.lib" \
157
	"..\..\..\lib\hcclsm.lib" \
158
	"$(RAC_SDK_HOME)\lib\hcclco.lib"
158
	"..\..\..\lib\hcclco.lib"
159
159
160
"$(OUTDIR)\TransportSupport.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
160
"$(OUTDIR)\TransportSupport.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
161
    $(LINK32) @<<
161
    $(LINK32) @<<
Lines 205-214 Link Here
205
"$(OUTDIR)" :
205
"$(OUTDIR)" :
206
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
206
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
207
207
208
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /I "$(RAC_SDK_HOME)/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\TransportSupport.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
208
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /I "../RACommon" /I "../RASocket" /I "../RASharedMemory" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\TransportSupport.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
209
209
210
LINK32=link.exe
210
LINK32=link.exe
211
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib tptpUtils.lib hcclco.lib hcclsm.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\TransportSupport.pdb" /debug /def:".\TransportSupport.def" /out:"$(OUTDIR)\TransportSupport.dll" /implib:"../../../lib/transportSupport.lib" /libpath:"../../../lib" /libpath:"$(RAC_SDK_HOME)/lib" /machine:AMD64
211
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib tptpUtils.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\TransportSupport.pdb" /debug /def:".\TransportSupport.def" /out:"$(OUTDIR)\TransportSupport.dll" /implib:"../../../lib/transportSupport.lib" /libpath:"../../../lib" /machine:AMD64
212
LINK32_OBJS= \
212
LINK32_OBJS= \
213
	"$(INTDIR)\TransportOSCalls_linux.obj" \
213
	"$(INTDIR)\TransportOSCalls_linux.obj" \
214
	"$(INTDIR)\TransportOSCalls_win.obj" \
214
	"$(INTDIR)\TransportOSCalls_win.obj" \
Lines 220-227 Link Here
220
	"$(INTDIR)\TransportSupportSharedMemExt.obj" \
220
	"$(INTDIR)\TransportSupportSharedMemExt.obj" \
221
	"$(INTDIR)\TransportSupportSocket.obj" \
221
	"$(INTDIR)\TransportSupportSocket.obj" \
222
	"..\..\..\lib\tptpUtils.lib" \
222
	"..\..\..\lib\tptpUtils.lib" \
223
	"$(RAC_SDK_HOME)\lib\hcclco.lib" \
223
	"..\..\..\lib\hcclco.lib" \
224
	"$(RAC_SDK_HOME)\lib\hcclsm.lib"
224
	"..\..\..\lib\hcclsm.lib"
225
225
226
"$(OUTDIR)\TransportSupport.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
226
"$(OUTDIR)\TransportSupport.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
227
    $(LINK32) @<<
227
    $(LINK32) @<<
Lines 272-281 Link Here
272
"$(INTDIR)" :
272
"$(INTDIR)" :
273
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
273
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
274
274
275
CPP_PROJ=/nologo /MD /W3 /O2 /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /I "$(RAC_SDK_HOME)/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\TransportSupport.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
275
CPP_PROJ=/nologo /MD /W3 /O2 /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /I "../../../include" /I "../RACommon" /I "../RASocket" /I "../RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\TransportSupport.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
276
276
277
LINK32=link.exe
277
LINK32=link.exe
278
LINK32_FLAGS=advapi32.lib uuid.lib ws2_32.lib tptpUtils.lib hcclco.lib hcclsm.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\TransportSupport.pdb" /def:".\TransportSupport.def" /out:"$(OUTDIR)\TransportSupport.dll" /implib:"../../../lib/transportSupport.lib" /libpath:"../../../lib" /libpath:"$(RAC_SDK_HOME)/lib" /machine:AMD64 
278
LINK32_FLAGS=advapi32.lib uuid.lib ws2_32.lib tptpUtils.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\TransportSupport.pdb" /def:".\TransportSupport.def" /out:"$(OUTDIR)\TransportSupport.dll" /implib:"../../../lib/transportSupport.lib" /libpath:"../../../lib" /machine:AMD64 
279
LINK32_OBJS= \
279
LINK32_OBJS= \
280
	"$(INTDIR)\TransportOSCalls_linux.obj" \
280
	"$(INTDIR)\TransportOSCalls_linux.obj" \
281
	"$(INTDIR)\TransportOSCalls_win.obj" \
281
	"$(INTDIR)\TransportOSCalls_win.obj" \
Lines 287-294 Link Here
287
	"$(INTDIR)\TransportSupportSharedMemExt.obj" \
287
	"$(INTDIR)\TransportSupportSharedMemExt.obj" \
288
	"$(INTDIR)\TransportSupportSocket.obj" \
288
	"$(INTDIR)\TransportSupportSocket.obj" \
289
	"..\..\..\lib\tptpUtils.lib" \
289
	"..\..\..\lib\tptpUtils.lib" \
290
	"$(RAC_SDK_HOME)\lib\hcclsm.lib" \
290
	"..\..\..\lib\hcclsm.lib" \
291
	"$(RAC_SDK_HOME)\lib\hcclco.lib"
291
	"..\..\..\lib\hcclco.lib"
292
292
293
"$(OUTDIR)\TransportSupport.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
293
"$(OUTDIR)\TransportSupport.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
294
    $(LINK32) @<<
294
    $(LINK32) @<<
(-)src-native-new/src/transport/transportSupport/NoRAtransportSupport.dsp (-2 / +2 lines)
Lines 43-49 Link Here
43
# PROP Ignore_Export_Lib 0
43
# PROP Ignore_Export_Lib 0
44
# PROP Target_Dir ""
44
# PROP Target_Dir ""
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /YX /FD /c
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /YX /FD /c
46
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../RACommon" /I "../RASharedMemory" /I "../RASocket" /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /D "ENW" /D "SQLWINT" /YX /FD /c
46
# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../RACommon" /I "../RASocket" /I "../RASharedMemory" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /D "ENW" /D "SQLWINT" /YX /FD /c
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
49
# ADD BASE RSC /l 0x409 /d "NDEBUG"
49
# ADD BASE RSC /l 0x409 /d "NDEBUG"
Lines 70-76 Link Here
70
# PROP Ignore_Export_Lib 0
70
# PROP Ignore_Export_Lib 0
71
# PROP Target_Dir ""
71
# PROP Target_Dir ""
72
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /YX /FD /GZ /c
72
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /YX /FD /GZ /c
73
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../RACommon" /I "../RASharedMemory" /I "../RASocket" /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /D "ENW" /D "SQLWINT" /YX /FD /GZ /c
73
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../RACommon" /I "../RASocket" /I "../RASharedMemory" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TRANSPORTSUPPORT_EXPORTS" /D "ENW" /D "SQLWINT" /YX /FD /GZ /c
74
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
74
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
75
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
75
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
76
# ADD BASE RSC /l 0x409 /d "_DEBUG"
76
# ADD BASE RSC /l 0x409 /d "_DEBUG"
(-)src-native-new/src/transport/RACommon/RACommon.mak64 (-41 / +297 lines)
Lines 1-20 Link Here
1
# Microsoft Developer Studio based NMAKE File, derived from RACommon.dsp
1
# Microsoft Developer Studio Generated NMAKE File, Based on RACommon.dsp
2
!IF "$(CFG)" == ""
2
!IF "$(CFG)" == ""
3
CFG=RACommon - IA64 Release
3
CFG=RACommon - IA64 Debug
4
!MESSAGE No configuration specified. Defaulting to RACommon - IA64 Release.
4
!MESSAGE No configuration specified. Defaulting to RACommon - IA64 Debug.
5
!ENDIF 
5
!ENDIF 
6
6
7
!IF "$(CFG)" != "RACommon - IA64 Debug" && "$(CFG)" != "RACommon - IA64 Release"
7
!IF "$(CFG)" != "RACommon - IA64 Release" && "$(CFG)" != "RACommon - IA64 Debug" && "$(CFG)" != "RACommon - X64 Release" && "$(CFG)" != "RACommon - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
11
!MESSAGE 
12
!MESSAGE NMAKE /f "RACommon.mak64" CFG="RACommon - IA64 Release"
12
!MESSAGE NMAKE /f "RACommon.mak64" CFG="RACommon - IA64 Debug"
13
!MESSAGE 
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
15
!MESSAGE 
16
!MESSAGE "RACommon - IA64 Debug"
17
!MESSAGE "RACommon - IA64 Release"
16
!MESSAGE "RACommon - IA64 Release"
17
!MESSAGE "RACommon - IA64 Debug"
18
!MESSAGE "RACommon - X64 Release"
19
!MESSAGE "RACommon - X64 Debug"
18
!MESSAGE 
20
!MESSAGE 
19
!ERROR An invalid configuration is specified.
21
!ERROR An invalid configuration is specified.
20
!ENDIF 
22
!ENDIF 
Lines 25-88 Link Here
25
NULL=nul
27
NULL=nul
26
!ENDIF 
28
!ENDIF 
27
29
30
!IF  "$(CFG)" == "RACommon - IA64 Release"
31
32
OUTDIR=..\..\..\bin
33
INTDIR=.\Release
34
# Begin Custom Macros
35
OutDir=..\..\..\bin
36
# End Custom Macros
37
38
ALL : "$(OUTDIR)\hcclco.dll"
39
40
41
CLEAN :
42
	-@erase "$(INTDIR)\hcclco.res"
43
	-@erase "$(INTDIR)\java.obj"
44
	-@erase "$(INTDIR)\RAComm.obj"
45
	-@erase "$(INTDIR)\vc60.idb"
46
	-@erase "$(OUTDIR)\hcclco.dll"
47
	-@erase "$(OUTDIR)\..\lib\hcclco.exp"
48
	-@erase "$(OUTDIR)\..\lib\hcclco.lib"
49
50
"$(OUTDIR)" :
51
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
52
53
"$(INTDIR)" :
54
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
55
28
CPP=cl.exe
56
CPP=cl.exe
57
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /Ob0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RACOMMON_EXPORTS" /Fp"$(INTDIR)\RACommon.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
58
59
.c{$(INTDIR)}.obj::
60
   $(CPP) @<<
61
   $(CPP_PROJ) $< 
62
<<
63
64
.cpp{$(INTDIR)}.obj::
65
   $(CPP) @<<
66
   $(CPP_PROJ) $< 
67
<<
68
69
.cxx{$(INTDIR)}.obj::
70
   $(CPP) @<<
71
   $(CPP_PROJ) $< 
72
<<
73
74
.c{$(INTDIR)}.sbr::
75
   $(CPP) @<<
76
   $(CPP_PROJ) $< 
77
<<
78
79
.cpp{$(INTDIR)}.sbr::
80
   $(CPP) @<<
81
   $(CPP_PROJ) $< 
82
<<
83
84
.cxx{$(INTDIR)}.sbr::
85
   $(CPP) @<<
86
   $(CPP_PROJ) $< 
87
<<
88
89
MTL=midl.exe
90
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
29
RSC=rc.exe
91
RSC=rc.exe
92
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcclco.res" /d "NDEBUG" 
30
93
31
!IF  "$(CFG)" == "RACommon - IA64 Debug"
94
LINK32=link.exe
95
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib bufferoverflowU.lib /nologo /version:0.1 /dll /pdb:none /def:".\RACommon.def" /out:"$(OUTDIR)\hcclco.dll" /implib:"$(OUTDIR)\..\lib\hcclco.lib" /machine:IA64
96
LINK32_OBJS= \
97
	"$(INTDIR)\java.obj" \
98
	"$(INTDIR)\RAComm.obj" \
99
	"$(INTDIR)\hcclco.res"
100
101
"$(OUTDIR)\hcclco.dll" : "$(OUTDIR)" $(LINK32_OBJS)
102
    $(LINK32) @<<
103
  $(LINK32_FLAGS) $(LINK32_OBJS)
104
<<
32
105
33
OUTDIR=.\RACommon___IA64Debug
106
!ELSEIF  "$(CFG)" == "RACommon - IA64 Debug"
34
INTDIR=.\RACommon___IA64Debug
35
107
36
ALL : "..\..\..\bin\hcclco.dll"
108
OUTDIR=..\..\..\bin
109
INTDIR=.\Debug
110
# Begin Custom Macros
111
OutDir=..\..\..\bin
112
# End Custom Macros
113
114
ALL : "$(OUTDIR)\hcclco.dll"
37
115
38
116
39
CLEAN :
117
CLEAN :
118
	-@erase "$(INTDIR)\hcclco.res"
119
	-@erase "$(INTDIR)\java.obj"
40
	-@erase "$(INTDIR)\RAComm.obj"
120
	-@erase "$(INTDIR)\RAComm.obj"
41
	-@erase "$(INTDIR)\vc60.idb"
121
	-@erase "$(INTDIR)\vc60.idb"
42
	-@erase "$(INTDIR)\vc60.pdb"
122
	-@erase "$(INTDIR)\vc60.pdb"
43
	-@erase "$(OUTDIR)\hcclco.pdb"
123
	-@erase "$(OUTDIR)\hcclco.dll"
44
	-@erase "..\..\..\bin\hcclco.dll"
124
	-@erase "$(OUTDIR)\..\lib\hcclco.exp"
45
	-@erase "..\..\..\bin\hcclco.ilk"
125
	-@erase "$(OUTDIR)\..\lib\hcclco.ilk"
46
	-@erase "..\..\..\lib\hcclco.exp"
126
	-@erase "$(OUTDIR)\..\lib\hcclco.lib"
47
	-@erase "..\..\..\lib\hcclco.lib"
127
	-@erase "$(OUTDIR)\..\lib\hcclco.pdb"
48
	-@erase "$(OUTDIR)\hcclco.res"
49
128
50
"$(OUTDIR)" :
129
"$(OUTDIR)" :
51
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
130
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
52
131
53
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RACOMMON_EXPORTS" /Fp"$(INTDIR)\RACommon.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
132
"$(INTDIR)" :
54
RSC_PROJ=/l 0x409 /fo"$(OUTDIR)/hcclco.res" /i "../../../include" /d "_DEBUG" 
133
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
55
	
134
135
CPP=cl.exe
136
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RACOMMON_EXPORTS" /Fp"$(INTDIR)\RACommon.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
137
138
.c{$(INTDIR)}.obj::
139
   $(CPP) @<<
140
   $(CPP_PROJ) $< 
141
<<
142
143
.cpp{$(INTDIR)}.obj::
144
   $(CPP) @<<
145
   $(CPP_PROJ) $< 
146
<<
147
148
.cxx{$(INTDIR)}.obj::
149
   $(CPP) @<<
150
   $(CPP_PROJ) $< 
151
<<
152
153
.c{$(INTDIR)}.sbr::
154
   $(CPP) @<<
155
   $(CPP_PROJ) $< 
156
<<
157
158
.cpp{$(INTDIR)}.sbr::
159
   $(CPP) @<<
160
   $(CPP_PROJ) $< 
161
<<
162
163
.cxx{$(INTDIR)}.sbr::
164
   $(CPP) @<<
165
   $(CPP_PROJ) $< 
166
<<
167
168
MTL=midl.exe
169
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
170
RSC=rc.exe
171
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcclco.res" /d "_DEBUG" 
172
56
LINK32=link.exe
173
LINK32=link.exe
57
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib rpcrt4.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcclco.pdb" /debug /def:".\RACommon.def" /out:"../../../bin/hcclco.dll" /implib:"../../../lib/hcclco.lib" /machine:IA64
174
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcclco.pdb" /debug /def:".\RACommon.def" /out:"$(OUTDIR)\hcclco.dll" /implib:"$(OUTDIR)\..\lib\hcclco.lib" /machine:IA64
58
LINK32_OBJS= \
175
LINK32_OBJS= \
176
	"$(INTDIR)\java.obj" \
59
	"$(INTDIR)\RAComm.obj" \
177
	"$(INTDIR)\RAComm.obj" \
60
	"$(OUTDIR)\hcclco.res"
178
	"$(INTDIR)\hcclco.res"
61
179
62
"..\..\..\bin\hcclco.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
180
"$(OUTDIR)\hcclco.dll" : "$(OUTDIR)" $(LINK32_OBJS)
63
    $(LINK32) @<<
181
    $(LINK32) @<<
64
  $(LINK32_FLAGS) $(LINK32_OBJS)
182
  $(LINK32_FLAGS) $(LINK32_OBJS)
65
<<
183
<<
66
184
67
!ELSEIF  "$(CFG)" == "RACommon - IA64 Release"
185
!ELSEIF  "$(CFG)" == "RACommon - X64 Release"
68
186
69
OUTDIR=.\../../../bin
187
OUTDIR=..\..\..\bin
70
INTDIR=.\RACommon___IA64Release
188
INTDIR=.\Release
71
# Begin Custom Macros
189
# Begin Custom Macros
72
OutDir=.\../../../bin
190
OutDir=..\..\..\bin
73
# End Custom Macros
191
# End Custom Macros
74
192
75
ALL : "$(OUTDIR)\hcclco.dll"
193
ALL : "$(OUTDIR)\hcclco.dll"
76
194
77
195
78
CLEAN :
196
CLEAN :
197
	-@erase "$(INTDIR)\hcclco.res"
198
	-@erase "$(INTDIR)\java.obj"
79
	-@erase "$(INTDIR)\RAComm.obj"
199
	-@erase "$(INTDIR)\RAComm.obj"
80
	-@erase "$(INTDIR)\vc60.idb"
200
	-@erase "$(INTDIR)\vc60.idb"
81
	-@erase "$(OUTDIR)\hcclco.dll"
201
	-@erase "$(OUTDIR)\hcclco.dll"
82
	-@erase "$(OUTDIR)\hcclco.ilk"
202
	-@erase "$(OUTDIR)\..\lib\hcclco.exp"
83
	-@erase "..\..\..\lib\hcclco.exp"
203
	-@erase "$(OUTDIR)\..\lib\hcclco.lib"
84
	-@erase "..\..\..\lib\hcclco.lib"
85
	-@erase "$(OUTDIR)\hcclco.res"
86
204
87
"$(OUTDIR)" :
205
"$(OUTDIR)" :
88
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
206
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
Lines 90-110 Link Here
90
"$(INTDIR)" :
208
"$(INTDIR)" :
91
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
209
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
92
210
93
CPP_PROJ=/nologo /MD /W3 /O2 /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RACOMMON_EXPORTS" /Fp"$(INTDIR)\RACommon.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
211
CPP=cl.exe
94
RSC_PROJ=/l 0x409 /fo"$(OUTDIR)/hcclco.res" /i "../../../include" /d "_DEBUG" 
212
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /Ob0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RACOMMON_EXPORTS" /Fp"$(INTDIR)\RACommon.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
213
214
.c{$(INTDIR)}.obj::
215
   $(CPP) @<<
216
   $(CPP_PROJ) $< 
217
<<
218
219
.cpp{$(INTDIR)}.obj::
220
   $(CPP) @<<
221
   $(CPP_PROJ) $< 
222
<<
223
224
.cxx{$(INTDIR)}.obj::
225
   $(CPP) @<<
226
   $(CPP_PROJ) $< 
227
<<
228
229
.c{$(INTDIR)}.sbr::
230
   $(CPP) @<<
231
   $(CPP_PROJ) $< 
232
<<
233
234
.cpp{$(INTDIR)}.sbr::
235
   $(CPP) @<<
236
   $(CPP_PROJ) $< 
237
<<
238
239
.cxx{$(INTDIR)}.sbr::
240
   $(CPP) @<<
241
   $(CPP_PROJ) $< 
242
<<
243
244
MTL=midl.exe
245
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
246
RSC=rc.exe
247
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcclco.res" /d "NDEBUG" 
95
248
96
LINK32=link.exe
249
LINK32=link.exe
97
LINK32_FLAGS=advapi32.lib Uuid.lib rpcrt4.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcclco.pdb" /def:".\RACommon.def" /out:"$(OUTDIR)\hcclco.dll" /implib:"../../../lib/hcclco.lib" /machine:IA64 
250
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib bufferoverflowU.lib /nologo /version:0.1 /dll /pdb:none /def:".\RACommon.def" /out:"$(OUTDIR)\hcclco.dll" /implib:"$(OUTDIR)\..\lib\hcclco.lib" /machine:AMD64
98
LINK32_OBJS= \
251
LINK32_OBJS= \
252
	"$(INTDIR)\java.obj" \
99
	"$(INTDIR)\RAComm.obj" \
253
	"$(INTDIR)\RAComm.obj" \
100
	"$(OUTDIR)\hcclco.res"
254
	"$(INTDIR)\hcclco.res"
101
255
102
"$(OUTDIR)\hcclco.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
256
"$(OUTDIR)\hcclco.dll" : "$(OUTDIR)" $(LINK32_OBJS)
103
    $(LINK32) @<<
257
    $(LINK32) @<<
104
  $(LINK32_FLAGS) $(LINK32_OBJS)
258
  $(LINK32_FLAGS) $(LINK32_OBJS)
105
<<
259
<<
106
260
107
!ENDIF 
261
!ELSEIF  "$(CFG)" == "RACommon - X64 Debug"
262
263
OUTDIR=..\..\..\bin
264
INTDIR=.\Debug
265
# Begin Custom Macros
266
OutDir=..\..\..\bin
267
# End Custom Macros
268
269
ALL : "$(OUTDIR)\hcclco.dll"
270
271
272
CLEAN :
273
	-@erase "$(INTDIR)\hcclco.res"
274
	-@erase "$(INTDIR)\java.obj"
275
	-@erase "$(INTDIR)\RAComm.obj"
276
	-@erase "$(INTDIR)\vc60.idb"
277
	-@erase "$(INTDIR)\vc60.pdb"
278
	-@erase "$(OUTDIR)\hcclco.dll"
279
	-@erase "$(OUTDIR)\..\lib\hcclco.exp"
280
	-@erase "$(OUTDIR)\..\lib\hcclco.ilk"
281
	-@erase "$(OUTDIR)\..\lib\hcclco.lib"
282
	-@erase "$(OUTDIR)\..\lib\hcclco.pdb"
283
284
"$(OUTDIR)" :
285
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
286
287
"$(INTDIR)" :
288
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
289
290
CPP=cl.exe
291
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RACOMMON_EXPORTS" /Fp"$(INTDIR)\RACommon.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
108
292
109
.c{$(INTDIR)}.obj::
293
.c{$(INTDIR)}.obj::
110
   $(CPP) @<<
294
   $(CPP) @<<
Lines 121-134 Link Here
121
   $(CPP_PROJ) $< 
305
   $(CPP_PROJ) $< 
122
<<
306
<<
123
307
124
!IF "$(CFG)" == "RACommon - IA64 Debug" || "$(CFG)" == "RACommon - IA64 Release"
308
.c{$(INTDIR)}.sbr::
125
SOURCE=..\RACommon\RAComm.c
309
   $(CPP) @<<
310
   $(CPP_PROJ) $< 
311
<<
312
313
.cpp{$(INTDIR)}.sbr::
314
   $(CPP) @<<
315
   $(CPP_PROJ) $< 
316
<<
317
318
.cxx{$(INTDIR)}.sbr::
319
   $(CPP) @<<
320
   $(CPP_PROJ) $< 
321
<<
322
323
MTL=midl.exe
324
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
325
RSC=rc.exe
326
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcclco.res" /d "_DEBUG" 
327
328
LINK32=link.exe
329
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcclco.pdb" /debug /def:".\RACommon.def" /out:"$(OUTDIR)\hcclco.dll" /implib:"$(OUTDIR)\..\lib\hcclco.lib" /machine:AMD64
330
LINK32_OBJS= \
331
	"$(INTDIR)\java.obj" \
332
	"$(INTDIR)\RAComm.obj" \
333
	"$(INTDIR)\hcclco.res"
334
335
"$(OUTDIR)\hcclco.dll" : "$(OUTDIR)" $(LINK32_OBJS)
336
    $(LINK32) @<<
337
  $(LINK32_FLAGS) $(LINK32_OBJS)
338
<<
339
340
!ENDIF 
341
342
343
!IF "$(CFG)" == "RACommon - IA64 Release" || "$(CFG)" == "RACommon - IA64 Debug" || "$(CFG)" == "RACommon - X64 Release" || "$(CFG)" == "RACommon - X64 Debug"
344
SOURCE=.\java.c
345
346
"$(INTDIR)\java.obj" : $(SOURCE) "$(INTDIR)"
347
	$(CPP) $(CPP_PROJ) $(SOURCE)
348
349
350
SOURCE=.\RAComm.c
126
351
127
"$(INTDIR)\RAComm.obj" : $(SOURCE) "$(INTDIR)"
352
"$(INTDIR)\RAComm.obj" : $(SOURCE) "$(INTDIR)"
353
	$(CPP) $(CPP_PROJ) $(SOURCE)
354
355
356
SOURCE=.\version.rc
357
358
!IF  "$(CFG)" == "RACommon - IA64 Release"
359
360
361
"$(INTDIR)\hcclco.res" : $(SOURCE) "$(INTDIR)"
362
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcclco.res" /d "NDEBUG" $(SOURCE)
363
364
365
!ELSEIF  "$(CFG)" == "RACommon - IA64 Debug"
366
128
367
368
"$(INTDIR)\hcclco.res" : $(SOURCE) "$(INTDIR)"
369
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcclco.res" /d "_DEBUG" $(SOURCE)
370
371
372
!ELSEIF  "$(CFG)" == "RACommon - X64 Release"
373
374
375
"$(INTDIR)\hcclco.res" : $(SOURCE) "$(INTDIR)"
376
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcclco.res" /d "NDEBUG" $(SOURCE)
377
378
379
!ELSEIF  "$(CFG)" == "RACommon - X64 Debug"
380
381
382
"$(INTDIR)\hcclco.res" : $(SOURCE) "$(INTDIR)"
383
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcclco.res" /d "_DEBUG" $(SOURCE)
384
385
386
!ENDIF 
129
387
130
SOURCE=..\RACommon\version.rc
131
388
132
"$(OUTDIR)\hcclco.res" : $(SOURCE) "$(INTDIR)"
133
	$(RSC) $(RSC_PROJ) $(SOURCE)
134
!ENDIF 
389
!ENDIF 
390
(-)src-native-new/src/transport/RACommon/version.rc (-1 / +1 lines)
Lines 1-4 Link Here
1
#include "tptp/version.h"
1
#include "../../../include/tptp/version.h"
2
//Microsoft Developer Studio generated resource script.
2
//Microsoft Developer Studio generated resource script.
3
//
3
//
4
4
(-)src-native-new/src/transport/RACommon/RACommon.make (-1 / +1 lines)
Lines 44-50 Link Here
44
#   list of additional libraries to be linked with
44
#   list of additional libraries to be linked with
45
#      (separated by blanks)
45
#      (separated by blanks)
46
#-----------------------------------
46
#-----------------------------------
47
LIBS       :=  dl
47
LIBS       :=  dl pthread
48
48
49
#-----------------------------------
49
#-----------------------------------
50
#   list of additional library directories to search from
50
#   list of additional library directories to search from
(-)src-native-new/build/BuildAll.mak64 (-8 / +211 lines)
Lines 38-44 Link Here
38
38
39
!ELSE
39
!ELSE
40
40
41
ALL :	"TPTPLogUtils - IA64 Debug" \
41
ALL :	"RACommon - IA64 Debug" \
42
	"RASocket - IA64 Debug" \
43
	"RASharedMemory - IA64 Debug" \
44
	"RADataTransfer - IA64 Debug" \
45
	"TPTPLogUtils - IA64 Debug" \
42
	"TPTPUtil - IA64 Debug" \
46
	"TPTPUtil - IA64 Debug" \
43
	"tptpConfig - IA64 Debug" \
47
	"tptpConfig - IA64 Debug" \
44
	"processControlUtil - IA64 Debug" \
48
	"processControlUtil - IA64 Debug" \
Lines 62-68 Link Here
62
!ENDIF
66
!ENDIF
63
67
64
!IF "$(RECURSE)" == "1"
68
!IF "$(RECURSE)" == "1"
65
CLEAN :	"TPTPLogUtils - IA64 DebugCLEAN" \
69
CLEAN :	"RACommon - IA64 DebugCLEAN" \
70
	"RASocket - IA64 DebugCLEAN" \
71
	"RASharedMemory - IA64 DebugCLEAN" \
72
	"RADataTransfer - IA64 DebugCLEAN" \
73
	"TPTPLogUtils - IA64 DebugCLEAN" \
66
	"TPTPUtil - IA64 DebugCLEAN" \
74
	"TPTPUtil - IA64 DebugCLEAN" \
67
	"tptpConfig - IA64 DebugCLEAN" \
75
	"tptpConfig - IA64 DebugCLEAN" \
68
	"processControlUtil - IA64 DebugCLEAN" \
76
	"processControlUtil - IA64 DebugCLEAN" \
Lines 96-102 Link Here
96
104
97
!ELSE
105
!ELSE
98
106
99
ALL :	"TPTPLogUtils - IA64 Release" \
107
ALL :	"RACommon - IA64 Release" \
108
	"RASocket - IA64 Release" \
109
	"RASharedMemory - IA64 Release" \
110
	"RADataTransfer - IA64 Release" \
111
	"TPTPLogUtils - IA64 Release" \
100
	"TPTPUtil - IA64 Release" \
112
	"TPTPUtil - IA64 Release" \
101
	"tptpConfig - IA64 Release" \
113
	"tptpConfig - IA64 Release" \
102
	"processControlUtil - IA64 Release" \
114
	"processControlUtil - IA64 Release" \
Lines 120-126 Link Here
120
!ENDIF
132
!ENDIF
121
133
122
!IF "$(RECURSE)" == "1"
134
!IF "$(RECURSE)" == "1"
123
CLEAN :	"TPTPLogUtils - IA64 ReleaseCLEAN" \
135
CLEAN :	"RACommon - IA64 ReleaseCLEAN" \
136
	"RASocket - IA64 ReleaseCLEAN" \
137
	"RASharedMemory - IA64 ReleaseCLEAN" \
138
	"RADataTransfer - IA64 ReleaseCLEAN" \
139
	"TPTPLogUtils - IA64 ReleaseCLEAN" \
124
	"TPTPUtil - IA64 ReleaseCLEAN" \
140
	"TPTPUtil - IA64 ReleaseCLEAN" \
125
	"tptpConfig - IA64 ReleaseCLEAN" \
141
	"tptpConfig - IA64 ReleaseCLEAN" \
126
	"processControlUtil - IA64 ReleaseCLEAN" \
142
	"processControlUtil - IA64 ReleaseCLEAN" \
Lines 153-159 Link Here
153
169
154
!ELSE
170
!ELSE
155
171
156
ALL :	"TPTPLogUtils - X64 Debug" \
172
ALL :	"RACommon - X64 Debug" \
173
	"RASocket - X64 Debug" \
174
	"RASharedMemory - X64 Debug" \
175
	"RADataTransfer - X64 Debug" \
176
	"TPTPLogUtils - X64 Debug" \
157
	"TPTPUtil - X64 Debug" \
177
	"TPTPUtil - X64 Debug" \
158
	"tptpConfig - X64 Debug" \
178
	"tptpConfig - X64 Debug" \
159
	"processControlUtil - X64 Debug" \
179
	"processControlUtil - X64 Debug" \
Lines 177-183 Link Here
177
!ENDIF
197
!ENDIF
178
198
179
!IF "$(RECURSE)" == "1"
199
!IF "$(RECURSE)" == "1"
180
CLEAN :	"TPTPLogUtils - X64 DebugCLEAN" \
200
CLEAN :	"RACommon - X64 DebugCLEAN" \
201
	"RASocket - X64 DebugCLEAN" \
202
	"RASharedMemory - X64 DebugCLEAN" \
203
	"RADataTransfer - X64 DebugCLEAN" \
204
	"TPTPLogUtils - X64 DebugCLEAN" \
181
	"TPTPUtil - X64 DebugCLEAN" \
205
	"TPTPUtil - X64 DebugCLEAN" \
182
	"tptpConfig - X64 DebugCLEAN" \
206
	"tptpConfig - X64 DebugCLEAN" \
183
	"processControlUtil - X64 DebugCLEAN" \
207
	"processControlUtil - X64 DebugCLEAN" \
Lines 211-217 Link Here
211
235
212
!ELSE
236
!ELSE
213
237
214
ALL :	"TPTPLogUtils - X64 Release" \
238
ALL :	"RACommon - X64 Release" \
239
	"RASocket - X64 Release" \
240
	"RASharedMemory - X64 Release" \
241
	"RADataTransfer - X64 Release" \
242
	"TPTPLogUtils - X64 Release" \
215
	"TPTPUtil - X64 Release" \
243
	"TPTPUtil - X64 Release" \
216
	"tptpConfig - X64 Release" \
244
	"tptpConfig - X64 Release" \
217
	"processControlUtil - X64 Release" \
245
	"processControlUtil - X64 Release" \
Lines 235-241 Link Here
235
!ENDIF
263
!ENDIF
236
264
237
!IF "$(RECURSE)" == "1"
265
!IF "$(RECURSE)" == "1"
238
CLEAN :	"TPTPLogUtils - X64 ReleaseCLEAN" \
266
CLEAN :	"RACommon - X64 ReleaseCLEAN" \
267
	"RASocket - X64 ReleaseCLEAN" \
268
	"RASharedMemory - X64 ReleaseCLEAN" \
269
	"RADataTransfer - X64 ReleaseCLEAN" \
270
	"TPTPLogUtils - X64 ReleaseCLEAN" \
239
	"TPTPUtil - X64 ReleaseCLEAN" \
271
	"TPTPUtil - X64 ReleaseCLEAN" \
240
	"tptpConfig - X64 ReleaseCLEAN" \
272
	"tptpConfig - X64 ReleaseCLEAN" \
241
	"processControlUtil - X64 ReleaseCLEAN" \
273
	"processControlUtil - X64 ReleaseCLEAN" \
Lines 269-274 Link Here
269
301
270
!IF  "$(CFG)" == "BuildAll - IA64 Debug"
302
!IF  "$(CFG)" == "BuildAll - IA64 Debug"
271
303
304
"RACommon - IA64 Debug" :
305
	cd "..\src\transport\RACommon"
306
	$(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Debug"
307
	cd "..\..\..\build"
308
309
"RACommon - IA64 DebugCLEAN" :
310
	cd "..\src\transport\RACommon"
311
	$(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Debug" RECURSE=1 CLEAN
312
	cd "..\..\..\build"
313
314
"RASocket - IA64 Debug" :
315
	cd "..\src\transport\RASocket"
316
	$(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Debug"
317
	cd "..\..\..\build"
318
319
"RASocket - IA64 DebugCLEAN" :
320
	cd "..\src\transport\RASocket"
321
	$(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Debug" RECURSE=1 CLEAN
322
	cd "..\..\..\build"
323
324
"RASharedMemory - IA64 Debug" :
325
	cd "..\src\transport\RASharedMemory"
326
	$(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - IA64 Debug"
327
	cd "..\..\..\build"
328
329
"RASharedMemory - IA64 DebugCLEAN" :
330
	cd "..\src\transport\RASharedMemory"
331
	$(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - IA64 Debug" RECURSE=1 CLEAN
332
	cd "..\..\..\build"
333
334
"RADataTransfer - IA64 Debug" :
335
	cd "..\src\transport\RADataTransfer"
336
	$(MAKE) /$(MAKEFLAGS) /F ".\RADataTransfer.mak64" CFG="RADataTransfer - IA64 Debug"
337
	cd "..\..\..\build"
338
339
"RADataTransfer - IA64 DebugCLEAN" :
340
	cd "..\src\transport\RADataTransfer"
341
	$(MAKE) /$(MAKEFLAGS) /F ".\RADataTransfer.mak64" CFG="RADataTransfer - IA64 Debug" RECURSE=1 CLEAN
342
	cd "..\..\..\build"
343
344
!ELSEIF  "$(CFG)" == "BuildAll - IA64 Release"
345
346
"RACommon - IA64 Release" :
347
	cd "..\src\transport\RACommon"
348
	$(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Release"
349
	cd "..\..\..\build"
350
351
"RACommon - IA64 ReleaseCLEAN" :
352
	cd "..\src\transport\RACommon"
353
	$(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Release" RECURSE=1 CLEAN
354
	cd "..\..\..\build"
355
356
"RASocket - IA64 Release" :
357
	cd "..\src\transport\RASocket"
358
	$(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Release"
359
	cd "..\..\..\build"
360
361
"RASocket - IA64 ReleaseCLEAN" :
362
	cd "..\src\transport\RASocket"
363
	$(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Release" RECURSE=1 CLEAN
364
	cd "..\..\..\build"
365
366
"RASharedMemory - IA64 Release" :
367
	cd "..\src\transport\RASharedMemory"
368
	$(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - IA64 Release"
369
	cd "..\..\..\build"
370
371
"RASharedMemory - IA64 ReleaseCLEAN" :
372
	cd "..\src\transport\RASharedMemory"
373
	$(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - IA64 Release" RECURSE=1 CLEAN
374
	cd "..\..\..\build"
375
376
"RADataTransfer - IA64 Release" :
377
	cd "..\src\transport\RADataTransfer"
378
	$(MAKE) /$(MAKEFLAGS) /F ".\RADataTransfer.mak64" CFG="RADataTransfer - IA64 Release"
379
	cd "..\..\..\build"
380
381
"RADataTransfer - IA64 ReleaseCLEAN" :
382
	cd "..\src\transport\RADataTransfer"
383
	$(MAKE) /$(MAKEFLAGS) /F ".\RADataTransfer.mak64" CFG="RADataTransfer - IA64 Release" RECURSE=1 CLEAN
384
	cd "..\..\..\build"
385
386
!ELSEIF  "$(CFG)" == "BuildAll - X64 Debug"
387
388
"RACommon - X64 Debug" :
389
	cd "..\src\transport\RACommon"
390
	$(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Debug"
391
	cd "..\..\..\build"
392
393
"RACommon - X64 DebugCLEAN" :
394
	cd "..\src\transport\RACommon"
395
	$(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Debug" RECURSE=1 CLEAN
396
	cd "..\..\..\build"
397
398
"RASocket - X64 Debug" :
399
	cd "..\src\transport\RASocket"
400
	$(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - X64 Debug"
401
	cd "..\..\..\build"
402
403
"RASocket - X64 DebugCLEAN" :
404
	cd "..\src\transport\RASocket"
405
	$(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - X64 Debug" RECURSE=1 CLEAN
406
	cd "..\..\..\build"
407
408
"RASharedMemory - X64 Debug" :
409
	cd "..\src\transport\RASharedMemory"
410
	$(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - X64 Debug"
411
	cd "..\..\..\build"
412
413
"RASharedMemory - X64 DebugCLEAN" :
414
	cd "..\src\transport\RASharedMemory"
415
	$(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - X64 Debug" RECURSE=1 CLEAN
416
	cd "..\..\..\build"
417
418
"RADataTransfer - X64 Debug" :
419
	cd "..\src\transport\RADataTransfer"
420
	$(MAKE) /$(MAKEFLAGS) /F ".\RADataTransfer.mak64" CFG="RADataTransfer - X64 Debug"
421
	cd "..\..\..\build"
422
423
"RADataTransfer - X64 DebugCLEAN" :
424
	cd "..\src\transport\RADataTransfer"
425
	$(MAKE) /$(MAKEFLAGS) /F ".\RADataTransfer.mak64" CFG="RADataTransfer - X64 Debug" RECURSE=1 CLEAN
426
	cd "..\..\..\build"
427
428
!ELSEIF  "$(CFG)" == "BuildAll - X64 Release"
429
430
"RACommon - X64 Release" :
431
	cd "..\src\transport\RACommon"
432
	$(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Release"
433
	cd "..\..\..\build"
434
435
"RACommon - X64 ReleaseCLEAN" :
436
	cd "..\src\transport\RACommon"
437
	$(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Release" RECURSE=1 CLEAN
438
	cd "..\..\..\build"
439
440
"RASocket - X64 Release" :
441
	cd "..\src\transport\RASocket"
442
	$(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - X64 Release"
443
	cd "..\..\..\build"
444
445
"RASocket - X64 ReleaseCLEAN" :
446
	cd "..\src\transport\RASocket"
447
	$(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - X64 Release" RECURSE=1 CLEAN
448
	cd "..\..\..\build"
449
450
"RASharedMemory - X64 Release" :
451
	cd "..\src\transport\RASharedMemory"
452
	$(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - X64 Release"
453
	cd "..\..\..\build"
454
455
"RASharedMemory - X64 ReleaseCLEAN" :
456
	cd "..\src\transport\RASharedMemory"
457
	$(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - X64 Release" RECURSE=1 CLEAN
458
	cd "..\..\..\build"
459
460
"RADataTransfer - X64 Release" :
461
	cd "..\src\transport\RADataTransfer"
462
	$(MAKE) /$(MAKEFLAGS) /F ".\RADataTransfer.mak64" CFG="RADataTransfer - X64 Release"
463
	cd "..\..\..\build"
464
465
"RADataTransfer - X64 ReleaseCLEAN" :
466
	cd "..\src\transport\RADataTransfer"
467
	$(MAKE) /$(MAKEFLAGS) /F ".\RADataTransfer.mak64" CFG="RADataTransfer - X64 Release" RECURSE=1 CLEAN
468
	cd "..\..\..\build"
469
470
!ENDIF
471
472
473
!IF  "$(CFG)" == "BuildAll - IA64 Debug"
474
272
"agentBase - IA64 Debug" :
475
"agentBase - IA64 Debug" :
273
   cd "..\src\agents\agentBase"
476
   cd "..\src\agents\agentBase"
274
   $(MAKE) /$(MAKEFLAGS) /F ".\AgentBase.mak64" CFG="agentBase - IA64 Debug"
477
   $(MAKE) /$(MAKEFLAGS) /F ".\AgentBase.mak64" CFG="agentBase - IA64 Debug"
(-)src-native-new/build/build_tptp_ac.script (-1 / +37 lines)
Lines 17-23 Link Here
17
17
18
18
19
if [ x$VERSIONNUM = x ]; then export VERSIONNUM=4; fi
19
if [ x$VERSIONNUM = x ]; then export VERSIONNUM=4; fi
20
if [ x$MINORNUM = x ]; then export MINORNUM=3; fi
20
if [ x$MINORNUM = x ]; then export MINORNUM=4; fi
21
if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi
21
if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi
22
22
23
if [ x$XERCESC_HOME = x ]; then export XERCESC_HOME=`pwd`/../../../depends/xerces-c-src_2_6_0; fi
23
if [ x$XERCESC_HOME = x ]; then export XERCESC_HOME=`pwd`/../../../depends/xerces-c-src_2_6_0; fi
Lines 62-67 Link Here
62
62
63
echo "----------------------------------------------"
63
echo "----------------------------------------------"
64
64
65
make -C ../src/transport/RADataTransfer -f RADataTransfer.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nRADataTransfer"
66
67
echo "----------------------------------------------"
68
65
make -C ../src/transport/transportSupport -f TransportSupport.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\ntransportSupport"
69
make -C ../src/transport/transportSupport -f TransportSupport.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\ntransportSupport"
66
70
67
echo "----------------------------------------------"
71
echo "----------------------------------------------"
Lines 122-127 Link Here
122
126
123
echo "----------------------------------------------"
127
echo "----------------------------------------------"
124
128
129
make -C ../src/agents/RABindings -f RABindings.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nRABindings"
130
131
echo "----------------------------------------------"
132
133
make -C ../src/agents/java -f hcjbnd.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nhcjbnd"
134
135
echo "----------------------------------------------"
136
137
make -C ../src/agents/native/java_profiler -f java_profiler.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\njava_profiler"
138
139
echo "----------------------------------------------"
140
141
make -C ../src/agents/perfmon/resutils -f resutils.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nresutils"
142
143
echo "----------------------------------------------"
144
145
make -C ../src/agents/perfmon/rac -f rac.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nrac"
146
147
echo "----------------------------------------------"
148
149
make -C ../src/agents/perfmon/perflin -f perflin.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nperflin"
150
151
echo "----------------------------------------------"
152
153
make -C ../src/agents/perfmon/PerfmonAgent -f PerfmonAgent.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nPerfmonAgent"
154
155
echo "----------------------------------------------"
156
157
make -C ../src/agents/thread -f hcthread.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nhcthread"
158
159
echo "----------------------------------------------"
160
125
if [ "$NUM_FAILURES" = "0" ]; then
161
if [ "$NUM_FAILURES" = "0" ]; then
126
	echo "No failures -- build successful"
162
	echo "No failures -- build successful"
127
else
163
else
(-)src-native-new/build/build_tptp_ac.script64 (-1 / +37 lines)
Lines 17-23 Link Here
17
17
18
18
19
if [ x$VERSIONNUM = x ]; then export VERSIONNUM=4; fi
19
if [ x$VERSIONNUM = x ]; then export VERSIONNUM=4; fi
20
if [ x$MINORNUM = x ]; then export MINORNUM=3; fi
20
if [ x$MINORNUM = x ]; then export MINORNUM=4; fi
21
if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi
21
if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi
22
22
23
if [ x$XERCESC_HOME = x ]; then export XERCESC_HOME=`pwd`/../../../depends/xerces-c-src_2_6_0; fi
23
if [ x$XERCESC_HOME = x ]; then export XERCESC_HOME=`pwd`/../../../depends/xerces-c-src_2_6_0; fi
Lines 71-76 Link Here
71
71
72
echo "----------------------------------------------"
72
echo "----------------------------------------------"
73
73
74
make -C ../src/transport/RADataTransfer -f RADataTransfer.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nRADataTransfer"
75
76
echo "----------------------------------------------"
77
74
make -C ../src/transport/transportSupport -f TransportSupport.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\ntransportSupport"
78
make -C ../src/transport/transportSupport -f TransportSupport.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\ntransportSupport"
75
79
76
echo "----------------------------------------------"
80
echo "----------------------------------------------"
Lines 131-136 Link Here
131
135
132
echo "----------------------------------------------"
136
echo "----------------------------------------------"
133
137
138
make -C ../src/agents/RABindings -f RABindings.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nRABindings"
139
140
echo "----------------------------------------------"
141
142
make -C ../src/agents/java -f hcjbnd.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nhcjbnd"
143
144
echo "----------------------------------------------"
145
146
#make -C ../src/agents/native/java_profiler -f java_profiler.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\njava_profiler"
147
#
148
#echo "----------------------------------------------"
149
150
#make -C ../src/agents/perfmon/resutils -f resutils.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nresutils"
151
#
152
#echo "----------------------------------------------"
153
154
#make -C ../src/agents/perfmon/rac -f rac.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nrac"
155
#
156
#echo "----------------------------------------------"
157
158
#make -C ../src/agents/perfmon/perflin -f perflin.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nperflin"
159
#
160
#echo "----------------------------------------------"
161
162
#make -C ../src/agents/perfmon/PerfmonAgent -f PerfmonAgent.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nPerfmonAgent"
163
#
164
#echo "----------------------------------------------"
165
166
make -C ../src/agents/thread -f hcthread.make $1 || NUM_FAILURES=`expr $NUM_FAILURES + 1` FAILURES="$FAILURES\nhcthread"
167
168
echo "----------------------------------------------"
169
134
if [ "$NUM_FAILURES" != "0" ]; then
170
if [ "$NUM_FAILURES" != "0" ]; then
135
	echo "***************************************************"
171
	echo "***************************************************"
136
	echo "***** $NUM_FAILURES components failed to build correctly! *****"
172
	echo "***** $NUM_FAILURES components failed to build correctly! *****"
(-)src-native-new/build/tptp_ac.dsw (-26 / +53 lines)
Lines 3-9 Link Here
3
3
4
###############################################################################
4
###############################################################################
5
5
6
Project: "ACService"="..\src\ACService\ACService.dsp" - Package Owner=<4>
6
Project: "ACService"=..\src\ACService\ACService.dsp - Package Owner=<4>
7
7
8
Package=<5>
8
Package=<5>
9
{{{
9
{{{
Lines 15-21 Link Here
15
15
16
###############################################################################
16
###############################################################################
17
17
18
Project: "AgentController"="..\src\agentController\AgentController.dsp" - Package Owner=<4>
18
Project: "AgentController"=..\src\agentController\AgentController.dsp - Package Owner=<4>
19
19
20
Package=<5>
20
Package=<5>
21
{{{
21
{{{
Lines 51-57 Link Here
51
51
52
###############################################################################
52
###############################################################################
53
53
54
Project: "BaseTransport"="..\src\transport\BaseTransport\BaseTransport.dsp" - Package Owner=<4>
54
Project: "BaseTransport"=..\src\transport\BaseTransport\BaseTransport.dsp - Package Owner=<4>
55
55
56
Package=<5>
56
Package=<5>
57
{{{
57
{{{
Lines 72-78 Link Here
72
72
73
###############################################################################
73
###############################################################################
74
74
75
Project: "BuildAll"=".\BuildAll.dsp" - Package Owner=<4>
75
Project: "BuildAll"=.\BuildAll.dsp - Package Owner=<4>
76
76
77
Package=<5>
77
Package=<5>
78
{{{
78
{{{
Lines 149-159 Link Here
149
    Begin Project Dependency
149
    Begin Project Dependency
150
    Project_Dep_Name InstService
150
    Project_Dep_Name InstService
151
    End Project Dependency
151
    End Project Dependency
152
    Begin Project Dependency
153
    Project_Dep_Name RADataTransfer
154
    End Project Dependency
152
}}}
155
}}}
153
156
154
###############################################################################
157
###############################################################################
155
158
156
Project: "BuildMost"=".\BuildMost.dsp" - Package Owner=<4>
159
Project: "BuildMost"=.\BuildMost.dsp - Package Owner=<4>
157
160
158
Package=<5>
161
Package=<5>
159
{{{
162
{{{
Lines 221-231 Link Here
221
    Begin Project Dependency
224
    Begin Project Dependency
222
    Project_Dep_Name NoRAtransportSupport
225
    Project_Dep_Name NoRAtransportSupport
223
    End Project Dependency
226
    End Project Dependency
227
    Begin Project Dependency
228
    Project_Dep_Name RACommon
229
    End Project Dependency
230
    Begin Project Dependency
231
    Project_Dep_Name RADataTransfer
232
    End Project Dependency
233
    Begin Project Dependency
234
    Project_Dep_Name RASharedMemory
235
    End Project Dependency
236
    Begin Project Dependency
237
    Project_Dep_Name RASocket
238
    End Project Dependency
224
}}}
239
}}}
225
240
226
###############################################################################
241
###############################################################################
227
242
228
Project: "CmdExtractor"="..\src\CmdExtractor\CmdExtractor.dsp" - Package Owner=<4>
243
Project: "CmdExtractor"=..\src\CmdExtractor\CmdExtractor.dsp - Package Owner=<4>
229
244
230
Package=<5>
245
Package=<5>
231
{{{
246
{{{
Lines 237-243 Link Here
237
252
238
###############################################################################
253
###############################################################################
239
254
240
Project: "CompSupport"="..\src\transport\CompSupport\CompSupport.dsp" - Package Owner=<4>
255
Project: "CompSupport"=..\src\transport\CompSupport\CompSupport.dsp - Package Owner=<4>
241
256
242
Package=<5>
257
Package=<5>
243
{{{
258
{{{
Lines 249-255 Link Here
249
264
250
###############################################################################
265
###############################################################################
251
266
252
Project: "FileTransferAgent"="..\SRC\AGENTS\FileTransferAgent\FileTransferAgent.dsp" - Package Owner=<4>
267
Project: "FileTransferAgent"=..\SRC\AGENTS\FileTransferAgent\FileTransferAgent.dsp - Package Owner=<4>
253
268
254
Package=<5>
269
Package=<5>
255
{{{
270
{{{
Lines 261-267 Link Here
261
276
262
###############################################################################
277
###############################################################################
263
278
264
Project: "InstService"="..\src\InstService\InstService.dsp" - Package Owner=<4>
279
Project: "InstService"=..\src\InstService\InstService.dsp - Package Owner=<4>
265
280
266
Package=<5>
281
Package=<5>
267
{{{
282
{{{
Lines 273-279 Link Here
273
288
274
###############################################################################
289
###############################################################################
275
290
276
Project: "NoRAtransportSupport"="..\src\transport\transportSupport\NoRAtransportSupport.dsp" - Package Owner=<4>
291
Project: "NoRAtransportSupport"=..\src\transport\transportSupport\NoRAtransportSupport.dsp - Package Owner=<4>
277
292
278
Package=<5>
293
Package=<5>
279
{{{
294
{{{
Lines 291-297 Link Here
291
306
292
###############################################################################
307
###############################################################################
293
308
294
Project: "RACommon"="..\src\transport\RACommon\RACommon.dsp" - Package Owner=<4>
309
Project: "RACommon"=..\src\transport\RACommon\RACommon.dsp - Package Owner=<4>
310
311
Package=<5>
312
{{{
313
}}}
314
315
Package=<4>
316
{{{
317
}}}
318
319
###############################################################################
320
321
Project: "RADataTransfer"=..\src\transport\RADataTransfer\RADataTransfer.dsp - Package Owner=<4>
295
322
296
Package=<5>
323
Package=<5>
297
{{{
324
{{{
Lines 303-309 Link Here
303
330
304
###############################################################################
331
###############################################################################
305
332
306
Project: "RASharedMemory"="..\src\transport\RASharedMemory\RASharedMemory.dsp" - Package Owner=<4>
333
Project: "RASharedMemory"=..\src\transport\RASharedMemory\RASharedMemory.dsp - Package Owner=<4>
307
334
308
Package=<5>
335
Package=<5>
309
{{{
336
{{{
Lines 321-327 Link Here
321
348
322
###############################################################################
349
###############################################################################
323
350
324
Project: "RASocket"="..\src\transport\RASocket\RASocket.dsp" - Package Owner=<4>
351
Project: "RASocket"=..\src\transport\RASocket\RASocket.dsp - Package Owner=<4>
325
352
326
Package=<5>
353
Package=<5>
327
{{{
354
{{{
Lines 336-342 Link Here
336
363
337
###############################################################################
364
###############################################################################
338
365
339
Project: "TPTPAgentCompTL"="..\src\transport\TPTPAgentCompTL\TPTPAgentCompTL.dsp" - Package Owner=<4>
366
Project: "TPTPAgentCompTL"=..\src\transport\TPTPAgentCompTL\TPTPAgentCompTL.dsp - Package Owner=<4>
340
367
341
Package=<5>
368
Package=<5>
342
{{{
369
{{{
Lines 366-372 Link Here
366
393
367
###############################################################################
394
###############################################################################
368
395
369
Project: "TPTPClientCompTL"="..\src\transport\TPTPClientCompTL\TPTPClientCompTL.dsp" - Package Owner=<4>
396
Project: "TPTPClientCompTL"=..\src\transport\TPTPClientCompTL\TPTPClientCompTL.dsp - Package Owner=<4>
370
397
371
Package=<5>
398
Package=<5>
372
{{{
399
{{{
Lines 384-390 Link Here
384
411
385
###############################################################################
412
###############################################################################
386
413
387
Project: "TPTPLogUtils"="..\src\shared\TPTPLogUtils\TPTPLogUtils.dsp" - Package Owner=<4>
414
Project: "TPTPLogUtils"=..\src\shared\TPTPLogUtils\TPTPLogUtils.dsp - Package Owner=<4>
388
415
389
Package=<5>
416
Package=<5>
390
{{{
417
{{{
Lines 399-405 Link Here
399
426
400
###############################################################################
427
###############################################################################
401
428
402
Project: "TPTPUtil"="..\src\shared\TPTPUtil\TPTPUtil.dsp" - Package Owner=<4>
429
Project: "TPTPUtil"=..\src\shared\TPTPUtil\TPTPUtil.dsp - Package Owner=<4>
403
430
404
Package=<5>
431
Package=<5>
405
{{{
432
{{{
Lines 411-417 Link Here
411
438
412
###############################################################################
439
###############################################################################
413
440
414
Project: "agentBase"="..\src\agents\agentBase\AgentBase.dsp" - Package Owner=<4>
441
Project: "agentBase"=..\src\agents\agentBase\AgentBase.dsp - Package Owner=<4>
415
442
416
Package=<5>
443
Package=<5>
417
{{{
444
{{{
Lines 438-444 Link Here
438
465
439
###############################################################################
466
###############################################################################
440
467
441
Project: "client"="..\src\client\Client.dsp" - Package Owner=<4>
468
Project: "client"=..\src\client\Client.dsp - Package Owner=<4>
442
469
443
Package=<5>
470
Package=<5>
444
{{{
471
{{{
Lines 453-459 Link Here
453
480
454
###############################################################################
481
###############################################################################
455
482
456
Project: "namedPipeTL"="..\src\transport\namedPipeTL\NamedPipeTL.dsp" - Package Owner=<4>
483
Project: "namedPipeTL"=..\src\transport\namedPipeTL\NamedPipeTL.dsp - Package Owner=<4>
457
484
458
Package=<5>
485
Package=<5>
459
{{{
486
{{{
Lines 471-477 Link Here
471
498
472
###############################################################################
499
###############################################################################
473
500
474
Project: "processControlUtil"="..\src\shared\processControlUtil\ProcessControlUtil.dsp" - Package Owner=<4>
501
Project: "processControlUtil"=..\src\shared\processControlUtil\ProcessControlUtil.dsp - Package Owner=<4>
475
502
476
Package=<5>
503
Package=<5>
477
{{{
504
{{{
Lines 486-492 Link Here
486
513
487
###############################################################################
514
###############################################################################
488
515
489
Project: "sharedMemTL"="..\SRC\TRANSPORT\sharedMemTL\SharedMemTL.dsp" - Package Owner=<4>
516
Project: "sharedMemTL"=..\SRC\TRANSPORT\sharedMemTL\SharedMemTL.dsp - Package Owner=<4>
490
517
491
Package=<5>
518
Package=<5>
492
{{{
519
{{{
Lines 501-507 Link Here
501
528
502
###############################################################################
529
###############################################################################
503
530
504
Project: "socketTL"="..\src\transport\socketTL\SocketTL.dsp" - Package Owner=<4>
531
Project: "socketTL"=..\src\transport\socketTL\SocketTL.dsp - Package Owner=<4>
505
532
506
Package=<5>
533
Package=<5>
507
{{{
534
{{{
Lines 519-525 Link Here
519
546
520
###############################################################################
547
###############################################################################
521
548
522
Project: "tptpConfig"="..\src\shared\tptpConfig\tptpConfig.dsp" - Package Owner=<4>
549
Project: "tptpConfig"=..\src\shared\tptpConfig\tptpConfig.dsp - Package Owner=<4>
523
550
524
Package=<5>
551
Package=<5>
525
{{{
552
{{{
Lines 537-543 Link Here
537
564
538
###############################################################################
565
###############################################################################
539
566
540
Project: "tptpProcessController"="..\src\agents\tptpProcessController\TPTPProcessController.dsp" - Package Owner=<4>
567
Project: "tptpProcessController"=..\src\agents\tptpProcessController\TPTPProcessController.dsp - Package Owner=<4>
541
568
542
Package=<5>
569
Package=<5>
543
{{{
570
{{{
Lines 558-564 Link Here
558
585
559
###############################################################################
586
###############################################################################
560
587
561
Project: "transportSupport"="..\src\transport\transportSupport\TransportSupport.dsp" - Package Owner=<4>
588
Project: "transportSupport"=..\src\transport\transportSupport\TransportSupport.dsp - Package Owner=<4>
562
589
563
Package=<5>
590
Package=<5>
564
{{{
591
{{{
(-)src-native-new/makefile.win_ipf (-3 / +35 lines)
Lines 1-6 Link Here
1
all: agentController
1
all: agentController
2
2
3
agentController:
3
agentController:
4
	set INCLUDE=$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(XERCESC_HOME)\include;$(INCLUDE)
5
	set LIB=$(JAVA_HOME)\lib;$(XERCESC_HOME)\lib;$(LIB)
6
4
	if not exist lib md lib
7
	if not exist lib md lib
5
	cd build
8
	cd build
6
	nmake -f BuildAll.mak64 CFG="BuildAll - IA64 Release"
9
	nmake -f BuildAll.mak64 CFG="BuildAll - IA64 Release"
Lines 12-17 Link Here
12
	nmake -f javaBaseAgent.mak64 CFG="javaBaseAgent - IA64 Release"
15
	nmake -f javaBaseAgent.mak64 CFG="javaBaseAgent - IA64 Release"
13
	cd ..\..
16
	cd ..\..
14
17
18
	cd src\HCLauncher\WinBuild
19
	nmake -f HCLauncher.mak64 CFG="HCLaunch - IA64 Release"
20
	cd ..\..\..
21
22
	cd src\agents\RABindings\WinBuild
23
	nmake -f RABindings.mak64 CFG="RABinding - IA64 Release"
24
	cd ..\..\..\..
25
26
	cd src\agents\java\WinBuild
27
	nmake -f log_agent.mak64 CFG="log_agent - IA64 Release"
28
	cd ..\..\..\..
29
30
	cd src\agents\native\WinBuild
31
	nmake -f heapsnapshots.mak64 CFG="heapsnapshots - IA64 Release"
32
	nmake -f java_profiler.mak64 CFG="java_profiler - IA64 Release"
33
	cd ..\..\..\..
34
35
	cd src\agents\perfmon\WinBuild
36
	nmake -f resutils.mak64 CFG="resutils - IA64 Release"
37
	nmake -f rac.mak64 CFG="rac - IA64 Release"
38
	nmake -f sysperf.mak64 CFG="sysperf - IA64 Release"
39
	nmake -f PerfmonAgent.mak64 CFG="PerfmonAgent - IA64 Release"
40
	cd ..\..\..\..
41
42
	cd src\agents\thread\WinBuild
43
	nmake -f hcthread.mak64 CFG="hcthread - IA64 Release"
44
	cd ..\..\..\..
45
46
15
package:
47
package:
16
	if exist packaging rm -rf packaging
48
	if exist packaging rm -rf packaging
17
	md packaging\bin
49
	md packaging\bin
Lines 22-33 Link Here
22
54
23
	if exist $(CBE_SDK_HOME)\lib\CommonBaseEvent.dll copy /y $(CBE_SDK_HOME)\lib\CommonBaseEvent.dll packaging\bin
55
	if exist $(CBE_SDK_HOME)\lib\CommonBaseEvent.dll copy /y $(CBE_SDK_HOME)\lib\CommonBaseEvent.dll packaging\bin
24
	copy /y bin\*.dll packaging\bin
56
	copy /y bin\*.dll packaging\bin
25
	copy /y $(RAC_SDK_HOME)\bin\*.dll packaging\bin
26
	copy /y $(RAC_SDK_HOME)\bin\*.exe packaging\bin
27
	copy /y bin\readme.txt packaging\bin
57
	copy /y bin\readme.txt packaging\bin
28
	if exist $(XERCESC_HOME)\bin\xerces-c_2_6.dll copy /y $(XERCESC_HOME)\bin\xerces-c_2_6.dll packaging\bin
29
	if exist $(TEMP_LICENSE_HOME)\epl-v10.html copy /y $(TEMP_LICENSE_HOME)\epl-v10.html packaging
58
	if exist $(TEMP_LICENSE_HOME)\epl-v10.html copy /y $(TEMP_LICENSE_HOME)\epl-v10.html packaging
30
	if exist $(TEMP_LICENSE_HOME)\notice.html copy /y $(TEMP_LICENSE_HOME)\notice.html packaging
59
	if exist $(TEMP_LICENSE_HOME)\notice.html copy /y $(TEMP_LICENSE_HOME)\notice.html packaging
60
	if exist $(XERCESC_HOME)\bin\xerces-c_2_6.dll copy /y $(XERCESC_HOME)\bin\xerces-c_2_6.dll packaging\bin
31
	xcopy /y /E config packaging\config
61
	xcopy /y /E config packaging\config
32
	xcopy /y /E agents packaging\agents
62
	xcopy /y /E agents packaging\agents
33
	copy /y about.win.html packaging\about.html
63
	copy /y about.win.html packaging\about.html
Lines 42-47 Link Here
42
	md packaging\bin
72
	md packaging\bin
43
73
44
	copy /y bin\*.exe packaging\bin
74
	copy /y bin\*.exe packaging\bin
75
	copy /y bin\ACServer.exe packaging\bin\RAServer.exe
76
	copy /y bin\ACWinService.exe packaging\bin\RAService.exe
45
77
46
	if exist agntctrl.win_ipf.zip  rm -f agntctrl.win_ipf.zip
78
	if exist agntctrl.win_ipf.zip  rm -f agntctrl.win_ipf.zip
47
	copy /y agntctrl.base.win_ipf.zip agntctrl.win_ipf.zip
79
	copy /y agntctrl.base.win_ipf.zip agntctrl.win_ipf.zip
(-)src-native-new/makefile.win_em64t (-2 / +34 lines)
Lines 1-6 Link Here
1
all: agentController
1
all: agentController
2
2
3
agentController:
3
agentController:
4
	set INCLUDE=$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(XERCESC_HOME)\include;$(INCLUDE)
5
	set LIB=$(JAVA_HOME)\lib;$(XERCESC_HOME)\lib;$(LIB)
6
4
	if not exist lib md lib
7
	if not exist lib md lib
5
	cd build
8
	cd build
6
	nmake -f BuildAll.mak64 CFG="BuildAll - X64 Release"
9
	nmake -f BuildAll.mak64 CFG="BuildAll - X64 Release"
Lines 12-17 Link Here
12
	nmake -f javaBaseAgent.mak64 CFG="javaBaseAgent - X64 Release"
15
	nmake -f javaBaseAgent.mak64 CFG="javaBaseAgent - X64 Release"
13
	cd ..\..
16
	cd ..\..
14
17
18
	cd src\HCLauncher\WinBuild
19
	nmake -f HCLauncher.mak64 CFG="HCLaunch - X64 Release"
20
	cd ..\..\..
21
22
	cd src\agents\RABindings\WinBuild
23
	nmake -f RABindings.mak64 CFG="RABinding - X64 Release"
24
	cd ..\..\..\..
25
26
	cd src\agents\java\WinBuild
27
	nmake -f log_agent.mak64 CFG="log_agent - X64 Release"
28
	cd ..\..\..\..
29
30
	cd src\agents\native\WinBuild
31
	nmake -f heapsnapshots.mak64 CFG="heapsnapshots - X64 Release"
32
	nmake -f java_profiler.mak64 CFG="java_profiler - X64 Release"
33
	cd ..\..\..\..
34
35
	cd src\agents\perfmon\WinBuild
36
	nmake -f resutils.mak64 CFG="resutils - X64 Release"
37
	nmake -f rac.mak64 CFG="rac - X64 Release"
38
	nmake -f sysperf.mak64 CFG="sysperf - X64 Release"
39
	nmake -f PerfmonAgent.mak64 CFG="PerfmonAgent - X64 Release"
40
	cd ..\..\..\..
41
42
	cd src\agents\thread\WinBuild
43
	nmake -f hcthread.mak64 CFG="hcthread - X64 Release"
44
	cd ..\..\..\..
45
46
15
package:
47
package:
16
	if exist packaging rm -rf packaging
48
	if exist packaging rm -rf packaging
17
	md packaging\bin
49
	md packaging\bin
Lines 22-29 Link Here
22
54
23
	if exist $(CBE_SDK_HOME)\lib\CommonBaseEvent.dll copy /y $(CBE_SDK_HOME)\lib\CommonBaseEvent.dll packaging\bin
55
	if exist $(CBE_SDK_HOME)\lib\CommonBaseEvent.dll copy /y $(CBE_SDK_HOME)\lib\CommonBaseEvent.dll packaging\bin
24
	copy /y bin\*.dll packaging\bin
56
	copy /y bin\*.dll packaging\bin
25
	copy /y $(RAC_SDK_HOME)\bin\*.dll packaging\bin
26
	copy /y $(RAC_SDK_HOME)\bin\*.exe packaging\bin
27
	copy /y bin\readme.txt packaging\bin
57
	copy /y bin\readme.txt packaging\bin
28
	if exist $(TEMP_LICENSE_HOME)\epl-v10.html copy /y $(TEMP_LICENSE_HOME)\epl-v10.html packaging
58
	if exist $(TEMP_LICENSE_HOME)\epl-v10.html copy /y $(TEMP_LICENSE_HOME)\epl-v10.html packaging
29
	if exist $(TEMP_LICENSE_HOME)\notice.html copy /y $(TEMP_LICENSE_HOME)\notice.html packaging
59
	if exist $(TEMP_LICENSE_HOME)\notice.html copy /y $(TEMP_LICENSE_HOME)\notice.html packaging
Lines 42-47 Link Here
42
	md packaging\bin
72
	md packaging\bin
43
73
44
	copy /y bin\*.exe packaging\bin
74
	copy /y bin\*.exe packaging\bin
75
	copy /y bin\ACServer.exe packaging\bin\RAServer.exe
76
	copy /y bin\ACWinService.exe packaging\bin\RAService.exe
45
77
46
	if exist agntctrl.win_em64t.zip  rm -f agntctrl.win_em64t.zip
78
	if exist agntctrl.win_em64t.zip  rm -f agntctrl.win_em64t.zip
47
	copy /y agntctrl.base.win_em64t.zip agntctrl.win_em64t.zip
79
	copy /y agntctrl.base.win_em64t.zip agntctrl.win_em64t.zip
(-)src-native-new/makefile.win_ia32 (+30 lines)
Lines 8-16 Link Here
8
	msdev tptp_javaagent.dsw /MAKE "JavaBaseAgent - Win32 Release"
8
	msdev tptp_javaagent.dsw /MAKE "JavaBaseAgent - Win32 Release"
9
	cd ..
9
	cd ..
10
10
11
	cd src\HCLauncher\WinBuild
12
	msdev HCLauncher.dsw /MAKE "HCLaunch - Win32 Release"
13
	cd ..\..\..
14
15
	cd src\agents\RABindings\WinBuild
16
	msdev RABindings.dsw /MAKE "RABinding - Win32 Release"
17
	cd ..\..\..\..
18
19
	cd src\agents\java\WinBuild
20
	msdev WinBuild.dsw /MAKE "log_agent - Win32 Release"
21
	cd ..\..\..\..
22
23
	cd src\agents\native\WinBuild
24
	msdev WinBuild.dsw /MAKE "java_profiler - Win32 Release"
25
	cd ..\..\..\..
26
27
	cd src\agents\perfmon\WinBuild
28
	msdev WinBuild.dsw /MAKE "resutils - Win32 Release"
29
	msdev WinBuild.dsw /MAKE "rac - Win32 Release"
30
	msdev WinBuild.dsw /MAKE "sysperf - Win32 Release"
31
	msdev WinBuild.dsw /MAKE "PerfmonAgent - Win32 Release"
32
	cd ..\..\..\..
33
34
	cd src\agents\thread\WinBuild
35
	msdev hcthread.dsw /MAKE "hcthread - Win32 Release"
36
	cd ..\..\..\..
37
11
package:
38
package:
12
	if exist packaging rm -rf packaging
39
	if exist packaging rm -rf packaging
13
	md packaging\bin
40
	md packaging\bin
41
	md packaging\lib
14
	md packaging\config
42
	md packaging\config
15
	md packaging\agents
43
	md packaging\agents
16
	md packaging\about_files
44
	md packaging\about_files
Lines 35-40 Link Here
35
	md packaging\bin
63
	md packaging\bin
36
64
37
	copy /y bin\*.exe packaging\bin
65
	copy /y bin\*.exe packaging\bin
66
	copy /y bin\ACServer.exe packaging\bin\RAServer.exe
67
	copy /y bin\ACWinService.exe packaging\bin\RAService.exe
38
68
39
	if exist agntctrl.win_ia32.zip  rm -f agntctrl.win_ia32.zip
69
	if exist agntctrl.win_ia32.zip  rm -f agntctrl.win_ia32.zip
40
	copy /y agntctrl.base.win_ia32.zip agntctrl.win_ia32.zip
70
	copy /y agntctrl.base.win_ia32.zip agntctrl.win_ia32.zip
(-)src-native-new/makefile (+9 lines)
Lines 61-66 Link Here
61
	cp -r config packaging
61
	cp -r config packaging
62
	cp -r agents packaging
62
	cp -r agents packaging
63
63
64
	if [ -e packaging/lib/libresutils.a ]; then rm -f packaging/lib/libresutils.a; fi;
65
	if [ -e packaging/lib/libperflin.so ]; then rm -f packaging/lib/libperflin.*; fi;
66
	if [ -e packaging/lib/librac.so ]; then rm -f packaging/lib/librac.*; fi;
67
64
	rm -f agntctrl.base.$(BUILD_PLATFORM).zip
68
	rm -f agntctrl.base.$(BUILD_PLATFORM).zip
65
	cd packaging; \
69
	cd packaging; \
66
	zip -r9y ../agntctrl.base.$(BUILD_PLATFORM).zip *; \
70
	zip -r9y ../agntctrl.base.$(BUILD_PLATFORM).zip *; \
Lines 71-76 Link Here
71
75
72
	cp -d bin/SampleClient bin/TimeCollector bin/tptp* bin/AC* packaging/bin
76
	cp -d bin/SampleClient bin/TimeCollector bin/tptp* bin/AC* packaging/bin
73
	cp -d bin/ChkPass packaging/bin
77
	cp -d bin/ChkPass packaging/bin
78
	if [ -e bin/LinuxAgent ]; then mkdir -p packaging/plugins/org.eclipse.hyades.perfmon.linux/bin; fi;
79
	if [ -e bin/LinuxAgent ]; then mkdir -p packaging/plugins/org.eclipse.hyades.perfmon.linux/lib; fi;
80
	if [ -e bin/LinuxAgent ]; then cp bin/LinuxAgent packaging/plugins/org.eclipse.hyades.perfmon.linux/bin; fi;
81
	if [ -e lib/libperflin.so ]; then cp lib/libperflin.* packaging/plugins/org.eclipse.hyades.perfmon.linux/lib; fi;
82
	if [ -e lib/librac.so ]; then cp lib/librac.* packaging/plugins/org.eclipse.hyades.perfmon.linux/lib; fi;
74
83
75
	cp agntctrl.base.$(BUILD_PLATFORM).zip  agntctrl.$(BUILD_PLATFORM).zip
84
	cp agntctrl.base.$(BUILD_PLATFORM).zip  agntctrl.$(BUILD_PLATFORM).zip
76
	cd packaging; \
85
	cd packaging; \
(-)src-native-new/src/transport/sharedMemTL/SharedMemTL.mak64 (-8 / +8 lines)
Lines 68-78 Link Here
68
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHAREDMEMTL_EXPORTS" /Fp"$(INTDIR)\SharedMemTL.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
68
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHAREDMEMTL_EXPORTS" /Fp"$(INTDIR)\SharedMemTL.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
69
69
70
LINK32=link.exe
70
LINK32=link.exe
71
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib transportSupport.lib tptpUtils.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\SharedMemTL.pdb" /debug /def:".\sharedMemTL.def" /out:"$(OUTDIR)\SharedMemTL.dll" /implib:"../../../lib/sharedMemTL.lib" /libpath:"../../../lib" /machine:IA64
71
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\SharedMemTL.pdb" /debug /def:".\sharedMemTL.def" /out:"$(OUTDIR)\SharedMemTL.dll" /implib:"../../../lib/sharedMemTL.lib" /libpath:"../../../lib" /machine:IA64
72
LINK32_OBJS= \
72
LINK32_OBJS= \
73
	"$(INTDIR)\sharedMemListener.obj" \
73
	"$(INTDIR)\sharedMemListener.obj" \
74
	"$(INTDIR)\sharedMemTL.obj" \
74
	"$(INTDIR)\sharedMemTL.obj" \
75
	"$(RAC_SDK_HOME)\lib\hcclsm.lib" \
75
	"..\..\..\lib\hcclsm.lib" \
76
	"..\..\..\lib\tptpUtils.lib" \
76
	"..\..\..\lib\tptpUtils.lib" \
77
	"..\..\..\lib\transportSupport.lib"
77
	"..\..\..\lib\transportSupport.lib"
78
78
Lines 121-131 Link Here
121
CPP_PROJ=/nologo /MD /W3 /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHAREDMEMTL_EXPORTS" /Fp"$(INTDIR)\SharedMemTL.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
121
CPP_PROJ=/nologo /MD /W3 /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHAREDMEMTL_EXPORTS" /Fp"$(INTDIR)\SharedMemTL.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
122
122
123
LINK32=link.exe
123
LINK32=link.exe
124
LINK32_FLAGS=advapi32.lib uuid.lib transportSupport.lib tptpUtils.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\SharedMemTL.pdb" /def:".\sharedMemTL.def" /out:"$(OUTDIR)\SharedMemTL.dll" /implib:"../../../lib/sharedMemTL.lib" /libpath:"../../../lib" /machine:IA64 
124
LINK32_FLAGS=advapi32.lib uuid.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\SharedMemTL.pdb" /def:".\sharedMemTL.def" /out:"$(OUTDIR)\SharedMemTL.dll" /implib:"../../../lib/sharedMemTL.lib" /libpath:"../../../lib" /machine:IA64 
125
LINK32_OBJS= \
125
LINK32_OBJS= \
126
	"$(INTDIR)\sharedMemListener.obj" \
126
	"$(INTDIR)\sharedMemListener.obj" \
127
	"$(INTDIR)\sharedMemTL.obj" \
127
	"$(INTDIR)\sharedMemTL.obj" \
128
	"$(RAC_SDK_HOME)\lib\hcclsm.lib" \
128
	"..\..\..\lib\hcclsm.lib" \
129
	"..\..\..\lib\tptpUtils.lib" \
129
	"..\..\..\lib\tptpUtils.lib" \
130
	"..\..\..\lib\transportSupport.lib"
130
	"..\..\..\lib\transportSupport.lib"
131
131
Lines 173-183 Link Here
173
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHAREDMEMTL_EXPORTS" /Fp"$(INTDIR)\SharedMemTL.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
173
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHAREDMEMTL_EXPORTS" /Fp"$(INTDIR)\SharedMemTL.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
174
174
175
LINK32=link.exe
175
LINK32=link.exe
176
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib transportSupport.lib tptpUtils.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\SharedMemTL.pdb" /debug /def:".\sharedMemTL.def" /out:"$(OUTDIR)\SharedMemTL.dll" /implib:"../../../lib/sharedMemTL.lib" /libpath:"../../../lib" /machine:AMD64
176
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\SharedMemTL.pdb" /debug /def:".\sharedMemTL.def" /out:"$(OUTDIR)\SharedMemTL.dll" /implib:"../../../lib/sharedMemTL.lib" /libpath:"../../../lib" /machine:AMD64
177
LINK32_OBJS= \
177
LINK32_OBJS= \
178
	"$(INTDIR)\sharedMemListener.obj" \
178
	"$(INTDIR)\sharedMemListener.obj" \
179
	"$(INTDIR)\sharedMemTL.obj" \
179
	"$(INTDIR)\sharedMemTL.obj" \
180
	"$(RAC_SDK_HOME)\lib\hcclsm.lib" \
180
	"..\..\..\lib\hcclsm.lib" \
181
	"..\..\..\lib\tptpUtils.lib" \
181
	"..\..\..\lib\tptpUtils.lib" \
182
	"..\..\..\lib\transportSupport.lib"
182
	"..\..\..\lib\transportSupport.lib"
183
183
Lines 226-236 Link Here
226
CPP_PROJ=/nologo /MD /W3 /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHAREDMEMTL_EXPORTS" /Fp"$(INTDIR)\SharedMemTL.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
226
CPP_PROJ=/nologo /MD /W3 /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHAREDMEMTL_EXPORTS" /Fp"$(INTDIR)\SharedMemTL.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
227
227
228
LINK32=link.exe
228
LINK32=link.exe
229
LINK32_FLAGS=advapi32.lib uuid.lib transportSupport.lib tptpUtils.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\SharedMemTL.pdb" /def:".\sharedMemTL.def" /out:"$(OUTDIR)\SharedMemTL.dll" /implib:"../../../lib/sharedMemTL.lib" /libpath:"../../../lib" /machine:AMD64 
229
LINK32_FLAGS=advapi32.lib uuid.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\SharedMemTL.pdb" /def:".\sharedMemTL.def" /out:"$(OUTDIR)\SharedMemTL.dll" /implib:"../../../lib/sharedMemTL.lib" /libpath:"../../../lib" /machine:AMD64 
230
LINK32_OBJS= \
230
LINK32_OBJS= \
231
	"$(INTDIR)\sharedMemListener.obj" \
231
	"$(INTDIR)\sharedMemListener.obj" \
232
	"$(INTDIR)\sharedMemTL.obj" \
232
	"$(INTDIR)\sharedMemTL.obj" \
233
	"$(RAC_SDK_HOME)\lib\hcclsm.lib" \
233
	"..\..\..\lib\hcclsm.lib" \
234
	"..\..\..\lib\tptpUtils.lib" \
234
	"..\..\..\lib\tptpUtils.lib" \
235
	"..\..\..\lib\transportSupport.lib"
235
	"..\..\..\lib\transportSupport.lib"
236
236
(-)src-native-new/src/transport/RASocket/RASocket.mak64 (-50 / +339 lines)
Lines 1-20 Link Here
1
# Microsoft Developer Studio based NMAKE File, derived from RASocket.dsp
1
# Microsoft Developer Studio Generated NMAKE File, Based on RASocket.dsp
2
!IF "$(CFG)" == ""
2
!IF "$(CFG)" == ""
3
CFG=RASocket - IA64 Release
3
CFG=RASocket - IA64 Debug
4
!MESSAGE No configuration specified. Defaulting to RASocket - IA64 Release.
4
!MESSAGE No configuration specified. Defaulting to RASocket - IA64 Debug.
5
!ENDIF 
5
!ENDIF 
6
6
7
!IF "$(CFG)" != "RASocket - IA64 Debug" && "$(CFG)" != "RASocket - IA64 Release"
7
!IF "$(CFG)" != "RASocket - IA64 Release" && "$(CFG)" != "RASocket - IA64 Debug" && "$(CFG)" != "RASocket - X64 Release" && "$(CFG)" != "RASocket - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
11
!MESSAGE 
12
!MESSAGE NMAKE /f "RASocket.mak64" CFG="RASocket - IA64 Release"
12
!MESSAGE NMAKE /f "RASocket.mak64" CFG="RASocket - IA64 Debug"
13
!MESSAGE 
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
15
!MESSAGE 
16
!MESSAGE "RASocket - IA64 Debug"
17
!MESSAGE "RASocket - IA64 Release"
16
!MESSAGE "RASocket - IA64 Release"
17
!MESSAGE "RASocket - IA64 Debug"
18
!MESSAGE "RASocket - X64 Release"
19
!MESSAGE "RASocket - X64 Debug"
18
!MESSAGE 
20
!MESSAGE 
19
!ERROR An invalid configuration is specified.
21
!ERROR An invalid configuration is specified.
20
!ENDIF 
22
!ENDIF 
Lines 25-45 Link Here
25
NULL=nul
27
NULL=nul
26
!ENDIF 
28
!ENDIF 
27
29
30
!IF  "$(CFG)" == "RASocket - IA64 Release"
31
32
OUTDIR=..\..\..\bin
33
INTDIR=.\Release
34
# Begin Custom Macros
35
OutDir=..\..\..\bin
36
# End Custom Macros
37
38
!IF "$(RECURSE)" == "0" 
39
40
ALL : "$(OUTDIR)\hccls.dll"
41
42
!ELSE 
43
44
ALL : "RACommon - IA64 Release" "$(OUTDIR)\hccls.dll"
45
46
!ENDIF 
47
48
!IF "$(RECURSE)" == "1" 
49
CLEAN :"RACommon - IA64 ReleaseCLEAN" 
50
!ELSE 
51
CLEAN :
52
!ENDIF 
53
	-@erase "$(INTDIR)\hccls.res"
54
	-@erase "$(INTDIR)\RASocket.obj"
55
	-@erase "$(INTDIR)\vc60.idb"
56
	-@erase "$(OUTDIR)\hccls.dll"
57
	-@erase "$(OUTDIR)\..\lib\hccls.exp"
58
	-@erase "$(OUTDIR)\..\lib\hccls.lib"
59
60
"$(OUTDIR)" :
61
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
62
63
"$(INTDIR)" :
64
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
65
28
CPP=cl.exe
66
CPP=cl.exe
67
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /Ob0 /I "..\RACommon" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RASOCKET_EXPORTS" /Fp"$(INTDIR)\RASocket.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
68
69
.c{$(INTDIR)}.obj::
70
   $(CPP) @<<
71
   $(CPP_PROJ) $< 
72
<<
73
74
.cpp{$(INTDIR)}.obj::
75
   $(CPP) @<<
76
   $(CPP_PROJ) $< 
77
<<
78
79
.cxx{$(INTDIR)}.obj::
80
   $(CPP) @<<
81
   $(CPP_PROJ) $< 
82
<<
83
84
.c{$(INTDIR)}.sbr::
85
   $(CPP) @<<
86
   $(CPP_PROJ) $< 
87
<<
88
89
.cpp{$(INTDIR)}.sbr::
90
   $(CPP) @<<
91
   $(CPP_PROJ) $< 
92
<<
93
94
.cxx{$(INTDIR)}.sbr::
95
   $(CPP) @<<
96
   $(CPP_PROJ) $< 
97
<<
98
99
MTL=midl.exe
100
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
29
RSC=rc.exe
101
RSC=rc.exe
102
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hccls.res" /d "NDEBUG" 
103
104
LINK32=link.exe
105
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ws2_32.lib bufferoverflowU.lib /nologo /version:0.1 /dll /pdb:none /def:"..\RASocket\RASocket.def" /out:"$(OUTDIR)\hccls.dll" /implib:"$(OUTDIR)\..\lib\hccls.lib" /machine:IA64
106
LINK32_OBJS= \
107
	"$(INTDIR)\RASocket.obj" \
108
	"$(INTDIR)\hccls.res" \
109
	"$(OUTDIR)\..\lib\hcclco.lib"
30
110
31
!IF  "$(CFG)" == "RASocket - IA64 Debug"
111
"$(OUTDIR)\hccls.dll" : "$(OUTDIR)" $(LINK32_OBJS)
112
    $(LINK32) @<<
113
  $(LINK32_FLAGS) $(LINK32_OBJS)
114
<<
32
115
33
OUTDIR=.\RASocket___IA64Debug
116
!ELSEIF  "$(CFG)" == "RASocket - IA64 Debug"
34
INTDIR=.\RASocket___IA64Debug
117
118
OUTDIR=..\..\..\bin
119
INTDIR=.\Debug
120
# Begin Custom Macros
121
OutDir=..\..\..\bin
122
# End Custom Macros
35
123
36
!IF "$(RECURSE)" == "0" 
124
!IF "$(RECURSE)" == "0" 
37
125
38
ALL : "..\..\..\bin\hccls.dll"
126
ALL : "$(OUTDIR)\hccls.dll"
39
127
40
!ELSE 
128
!ELSE 
41
129
42
ALL : "RACommon - IA64 Debug" "..\..\..\bin\hccls.dll"
130
ALL : "RACommon - IA64 Debug" "$(OUTDIR)\hccls.dll"
43
131
44
!ENDIF 
132
!ENDIF 
45
133
Lines 48-87 Link Here
48
!ELSE 
136
!ELSE 
49
CLEAN :
137
CLEAN :
50
!ENDIF 
138
!ENDIF 
139
	-@erase "$(INTDIR)\hccls.res"
51
	-@erase "$(INTDIR)\RASocket.obj"
140
	-@erase "$(INTDIR)\RASocket.obj"
52
	-@erase "$(INTDIR)\vc60.idb"
141
	-@erase "$(INTDIR)\vc60.idb"
53
	-@erase "$(INTDIR)\vc60.pdb"
142
	-@erase "$(INTDIR)\vc60.pdb"
54
	-@erase "$(OUTDIR)\hccls.pdb"
143
	-@erase "$(OUTDIR)\hccls.dll"
55
	-@erase "..\..\..\bin\hccls.dll"
144
	-@erase "$(OUTDIR)\..\lib\hccls.exp"
56
	-@erase "..\..\..\bin\hccls.ilk"
145
	-@erase "$(OUTDIR)\..\lib\hccls.ilk"
57
	-@erase "..\..\..\lib\hccls.exp"
146
	-@erase "$(OUTDIR)\..\lib\hccls.lib"
58
	-@erase "..\..\..\lib\hccls.lib"
147
	-@erase "$(OUTDIR)\..\lib\hccls.pdb"
59
	-@erase "$(OUTDIR)\hccls.res"
60
148
61
"$(OUTDIR)" :
149
"$(OUTDIR)" :
62
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
150
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
63
151
64
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\RACommon" /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RASOCKET_EXPORTS" /Fp"$(INTDIR)\RASocket.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
152
"$(INTDIR)" :
65
RSC_PROJ=/l 0x409 /fo"$(OUTDIR)/hccls.res" /i "../../../include" /d "_DEBUG" 
153
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
66
	
154
155
CPP=cl.exe
156
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\RACommon" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RASOCKET_EXPORTS" /Fp"$(INTDIR)\RASocket.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
157
158
.c{$(INTDIR)}.obj::
159
   $(CPP) @<<
160
   $(CPP_PROJ) $< 
161
<<
162
163
.cpp{$(INTDIR)}.obj::
164
   $(CPP) @<<
165
   $(CPP_PROJ) $< 
166
<<
167
168
.cxx{$(INTDIR)}.obj::
169
   $(CPP) @<<
170
   $(CPP_PROJ) $< 
171
<<
172
173
.c{$(INTDIR)}.sbr::
174
   $(CPP) @<<
175
   $(CPP_PROJ) $< 
176
<<
177
178
.cpp{$(INTDIR)}.sbr::
179
   $(CPP) @<<
180
   $(CPP_PROJ) $< 
181
<<
182
183
.cxx{$(INTDIR)}.sbr::
184
   $(CPP) @<<
185
   $(CPP_PROJ) $< 
186
<<
187
188
MTL=midl.exe
189
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
190
RSC=rc.exe
191
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hccls.res" /d "_DEBUG" 
192
67
LINK32=link.exe
193
LINK32=link.exe
68
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib hcclco.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hccls.pdb" /debug /def:".\RASocket.def" /out:"../../../bin/hccls.dll" /implib:"../../../lib/hccls.lib" /libpath:"../../../lib" /machine:IA64
194
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ws2_32.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hccls.pdb" /debug /def:"..\RASocket\RASocket.def" /out:"$(OUTDIR)\hccls.dll" /implib:"$(OUTDIR)\..\lib\hccls.lib" /machine:IA64
69
LINK32_OBJS= \
195
LINK32_OBJS= \
70
	"$(INTDIR)\RASocket.obj" \
196
	"$(INTDIR)\RASocket.obj" \
71
	"$(OUTDIR)\hccls.res" \
197
	"$(INTDIR)\hccls.res" \
72
	"..\..\..\lib\hcclco.lib"
198
	"$(OUTDIR)\..\lib\hcclco.lib"
73
199
74
"..\..\..\bin\hccls.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
200
"$(OUTDIR)\hccls.dll" : "$(OUTDIR)" $(LINK32_OBJS)
75
    $(LINK32) @<<
201
    $(LINK32) @<<
76
  $(LINK32_FLAGS) $(LINK32_OBJS)
202
  $(LINK32_FLAGS) $(LINK32_OBJS)
77
<<
203
<<
78
204
79
!ELSEIF  "$(CFG)" == "RASocket - IA64 Release"
205
!ELSEIF  "$(CFG)" == "RASocket - X64 Release"
80
206
81
OUTDIR=.\../../../bin
207
OUTDIR=..\..\..\bin
82
INTDIR=.\RASocket___IA64Release
208
INTDIR=.\Release
83
# Begin Custom Macros
209
# Begin Custom Macros
84
OutDir=.\../../../bin
210
OutDir=..\..\..\bin
85
# End Custom Macros
211
# End Custom Macros
86
212
87
!IF "$(RECURSE)" == "0" 
213
!IF "$(RECURSE)" == "0" 
Lines 90-111 Link Here
90
216
91
!ELSE 
217
!ELSE 
92
218
93
ALL : "RACommon - IA64 Release" "$(OUTDIR)\hccls.dll"
219
ALL : "RACommon - X64 Release" "$(OUTDIR)\hccls.dll"
94
220
95
!ENDIF 
221
!ENDIF 
96
222
97
!IF "$(RECURSE)" == "1" 
223
!IF "$(RECURSE)" == "1" 
98
CLEAN :"RACommon - IA64 ReleaseCLEAN" 
224
CLEAN :"RACommon - X64 ReleaseCLEAN" 
99
!ELSE 
225
!ELSE 
100
CLEAN :
226
CLEAN :
101
!ENDIF 
227
!ENDIF 
228
	-@erase "$(INTDIR)\hccls.res"
102
	-@erase "$(INTDIR)\RASocket.obj"
229
	-@erase "$(INTDIR)\RASocket.obj"
103
	-@erase "$(INTDIR)\vc60.idb"
230
	-@erase "$(INTDIR)\vc60.idb"
104
	-@erase "$(OUTDIR)\hccls.dll"
231
	-@erase "$(OUTDIR)\hccls.dll"
105
	-@erase "$(OUTDIR)\hccls.ilk"
232
	-@erase "$(OUTDIR)\..\lib\hccls.exp"
106
	-@erase "..\..\..\lib\hccls.exp"
233
	-@erase "$(OUTDIR)\..\lib\hccls.lib"
107
	-@erase "..\..\..\lib\hccls.lib"
108
	-@erase "$(OUTDIR)\hccls.res"
109
234
110
"$(OUTDIR)" :
235
"$(OUTDIR)" :
111
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
236
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
Lines 113-135 Link Here
113
"$(INTDIR)" :
238
"$(INTDIR)" :
114
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
239
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
115
240
116
CPP_PROJ=/nologo /MD /W3 /O2 /I "..\RACommon" /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RASOCKET_EXPORTS" /Fp"$(INTDIR)\RASocket.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
241
CPP=cl.exe
117
RSC_PROJ=/l 0x409 /fo"$(OUTDIR)/hccls.res" /i "../../../include" /d "_DEBUG" 
242
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /Ob0 /I "..\RACommon" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RASOCKET_EXPORTS" /Fp"$(INTDIR)\RASocket.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
118
	
243
244
.c{$(INTDIR)}.obj::
245
   $(CPP) @<<
246
   $(CPP_PROJ) $< 
247
<<
248
249
.cpp{$(INTDIR)}.obj::
250
   $(CPP) @<<
251
   $(CPP_PROJ) $< 
252
<<
253
254
.cxx{$(INTDIR)}.obj::
255
   $(CPP) @<<
256
   $(CPP_PROJ) $< 
257
<<
258
259
.c{$(INTDIR)}.sbr::
260
   $(CPP) @<<
261
   $(CPP_PROJ) $< 
262
<<
263
264
.cpp{$(INTDIR)}.sbr::
265
   $(CPP) @<<
266
   $(CPP_PROJ) $< 
267
<<
268
269
.cxx{$(INTDIR)}.sbr::
270
   $(CPP) @<<
271
   $(CPP_PROJ) $< 
272
<<
273
274
MTL=midl.exe
275
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
276
RSC=rc.exe
277
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hccls.res" /d "NDEBUG" 
278
119
LINK32=link.exe
279
LINK32=link.exe
120
LINK32_FLAGS=advapi32.lib Uuid.lib rpcrt4.lib ws2_32.lib hcclco.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hccls.pdb" /def:".\RASocket.def" /out:"$(OUTDIR)\hccls.dll" /implib:"../../../lib/hccls.lib" /libpath:"../../../lib" /machine:IA64 
280
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ws2_32.lib bufferoverflowU.lib /nologo /version:0.1 /dll /pdb:none /def:"..\RASocket\RASocket.def" /out:"$(OUTDIR)\hccls.dll" /implib:"$(OUTDIR)\..\lib\hccls.lib" /machine:AMD64
121
LINK32_OBJS= \
281
LINK32_OBJS= \
122
	"$(INTDIR)\RASocket.obj" \
282
	"$(INTDIR)\RASocket.obj" \
123
	"$(OUTDIR)\hccls.res" \
283
	"$(INTDIR)\hccls.res" \
124
	"..\..\..\lib\hcclco.lib"
284
	"$(OUTDIR)\..\lib\hcclco.lib"
125
285
126
"$(OUTDIR)\hccls.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
286
"$(OUTDIR)\hccls.dll" : "$(OUTDIR)" $(LINK32_OBJS)
127
    $(LINK32) @<<
287
    $(LINK32) @<<
128
  $(LINK32_FLAGS) $(LINK32_OBJS)
288
  $(LINK32_FLAGS) $(LINK32_OBJS)
129
<<
289
<<
130
290
291
!ELSEIF  "$(CFG)" == "RASocket - X64 Debug"
292
293
OUTDIR=..\..\..\bin
294
INTDIR=.\Debug
295
# Begin Custom Macros
296
OutDir=..\..\..\bin
297
# End Custom Macros
298
299
!IF "$(RECURSE)" == "0" 
300
301
ALL : "$(OUTDIR)\hccls.dll"
302
303
!ELSE 
304
305
ALL : "RACommon - X64 Debug" "$(OUTDIR)\hccls.dll"
306
131
!ENDIF 
307
!ENDIF 
132
308
309
!IF "$(RECURSE)" == "1" 
310
CLEAN :"RACommon - X64 DebugCLEAN" 
311
!ELSE 
312
CLEAN :
313
!ENDIF 
314
	-@erase "$(INTDIR)\hccls.res"
315
	-@erase "$(INTDIR)\RASocket.obj"
316
	-@erase "$(INTDIR)\vc60.idb"
317
	-@erase "$(INTDIR)\vc60.pdb"
318
	-@erase "$(OUTDIR)\hccls.dll"
319
	-@erase "$(OUTDIR)\..\lib\hccls.exp"
320
	-@erase "$(OUTDIR)\..\lib\hccls.ilk"
321
	-@erase "$(OUTDIR)\..\lib\hccls.lib"
322
	-@erase "$(OUTDIR)\..\lib\hccls.pdb"
323
324
"$(OUTDIR)" :
325
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
326
327
"$(INTDIR)" :
328
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
329
330
CPP=cl.exe
331
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\RACommon" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RASOCKET_EXPORTS" /Fp"$(INTDIR)\RASocket.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
332
133
.c{$(INTDIR)}.obj::
333
.c{$(INTDIR)}.obj::
134
   $(CPP) @<<
334
   $(CPP) @<<
135
   $(CPP_PROJ) $< 
335
   $(CPP_PROJ) $< 
Lines 145-162 Link Here
145
   $(CPP_PROJ) $< 
345
   $(CPP_PROJ) $< 
146
<<
346
<<
147
347
148
!IF "$(CFG)" == "RASocket - IA64 Debug" || "$(CFG)" == "RASocket - IA64 Release"
348
.c{$(INTDIR)}.sbr::
349
   $(CPP) @<<
350
   $(CPP_PROJ) $< 
351
<<
352
353
.cpp{$(INTDIR)}.sbr::
354
   $(CPP) @<<
355
   $(CPP_PROJ) $< 
356
<<
357
358
.cxx{$(INTDIR)}.sbr::
359
   $(CPP) @<<
360
   $(CPP_PROJ) $< 
361
<<
362
363
MTL=midl.exe
364
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
365
RSC=rc.exe
366
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hccls.res" /d "_DEBUG" 
367
368
LINK32=link.exe
369
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ws2_32.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hccls.pdb" /debug /def:"..\RASocket\RASocket.def" /out:"$(OUTDIR)\hccls.dll" /implib:"$(OUTDIR)\..\lib\hccls.lib" /machine:AMD64
370
LINK32_OBJS= \
371
	"$(INTDIR)\RASocket.obj" \
372
	"$(INTDIR)\hccls.res" \
373
	"$(OUTDIR)\..\lib\hcclco.lib"
374
375
"$(OUTDIR)\hccls.dll" : "$(OUTDIR)" $(LINK32_OBJS)
376
    $(LINK32) @<<
377
  $(LINK32_FLAGS) $(LINK32_OBJS)
378
<<
379
380
!ENDIF 
381
382
383
!IF "$(CFG)" == "RASocket - IA64 Release" || "$(CFG)" == "RASocket - IA64 Debug" || "$(CFG)" == "RASocket - X64 Release" || "$(CFG)" == "RASocket - X64 Debug"
149
SOURCE=..\RASocket\RASocket.c
384
SOURCE=..\RASocket\RASocket.c
150
385
151
"$(INTDIR)\RASocket.obj" : $(SOURCE) "$(INTDIR)"
386
"$(INTDIR)\RASocket.obj" : $(SOURCE) "$(INTDIR)"
387
	$(CPP) $(CPP_PROJ) $(SOURCE)
152
388
153
389
154
SOURCE=..\RASocket\version.rc
390
SOURCE=..\RASocket\version.rc
155
391
156
"$(OUTDIR)\hccls.res" : $(SOURCE) "$(INTDIR)"
392
!IF  "$(CFG)" == "RASocket - IA64 Release"
157
	$(RSC) $(RSC_PROJ) $(SOURCE)
393
394
395
"$(INTDIR)\hccls.res" : $(SOURCE) "$(INTDIR)"
396
	$(RSC) /l 0x409 /fo"$(INTDIR)\hccls.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RASocket" /d "NDEBUG" $(SOURCE)
397
398
399
!ELSEIF  "$(CFG)" == "RASocket - IA64 Debug"
400
401
402
"$(INTDIR)\hccls.res" : $(SOURCE) "$(INTDIR)"
403
	$(RSC) /l 0x409 /fo"$(INTDIR)\hccls.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RASocket" /d "_DEBUG" $(SOURCE)
404
405
406
!ELSEIF  "$(CFG)" == "RASocket - X64 Release"
407
408
409
"$(INTDIR)\hccls.res" : $(SOURCE) "$(INTDIR)"
410
	$(RSC) /l 0x409 /fo"$(INTDIR)\hccls.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RASocket" /d "NDEBUG" $(SOURCE)
411
412
413
!ELSEIF  "$(CFG)" == "RASocket - X64 Debug"
158
414
159
!IF  "$(CFG)" == "RASocket - IA64 Debug"
415
416
"$(INTDIR)\hccls.res" : $(SOURCE) "$(INTDIR)"
417
	$(RSC) /l 0x409 /fo"$(INTDIR)\hccls.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RASocket" /d "_DEBUG" $(SOURCE)
418
419
420
!ENDIF 
421
422
!IF  "$(CFG)" == "RASocket - IA64 Release"
423
424
"RACommon - IA64 Release" : 
425
   cd "..\RACommon"
426
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Release" 
427
   cd "..\RASocket"
428
429
"RACommon - IA64 ReleaseCLEAN" : 
430
   cd "..\RACommon"
431
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Release" RECURSE=1 CLEAN 
432
   cd "..\RASocket"
433
434
!ELSEIF  "$(CFG)" == "RASocket - IA64 Debug"
160
435
161
"RACommon - IA64 Debug" : 
436
"RACommon - IA64 Debug" : 
162
   cd "..\RACommon"
437
   cd "..\RACommon"
Lines 168-185 Link Here
168
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Debug" RECURSE=1 CLEAN 
443
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Debug" RECURSE=1 CLEAN 
169
   cd "..\RASocket"
444
   cd "..\RASocket"
170
445
171
!ELSEIF  "$(CFG)" == "RASocket - IA64 Release"
446
!ELSEIF  "$(CFG)" == "RASocket - X64 Release"
172
447
173
"RACommon - IA64 Release" : 
448
"RACommon - X64 Release" : 
174
   cd "..\RACommon"
449
   cd "..\RACommon"
175
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Release" 
450
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Release" 
176
   cd "..\RASocket"
451
   cd "..\RASocket"
177
452
178
"RACommon - IA64 ReleaseCLEAN" : 
453
"RACommon - X64 ReleaseCLEAN" : 
179
   cd "..\RACommon"
454
   cd "..\RACommon"
180
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Release" RECURSE=1 CLEAN 
455
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Release" RECURSE=1 CLEAN 
456
   cd "..\RASocket"
457
458
!ELSEIF  "$(CFG)" == "RASocket - X64 Debug"
459
460
"RACommon - X64 Debug" : 
461
   cd "..\RACommon"
462
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Debug" 
463
   cd "..\RASocket"
464
465
"RACommon - X64 DebugCLEAN" : 
466
   cd "..\RACommon"
467
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Debug" RECURSE=1 CLEAN 
181
   cd "..\RASocket"
468
   cd "..\RASocket"
182
469
183
!ENDIF 
470
!ENDIF 
184
471
472
185
!ENDIF 
473
!ENDIF 
474
(-)src-native-new/src/transport/RASocket/version.rc (-1 / +1 lines)
Lines 1-4 Link Here
1
#include "tptp/version.h"
1
#include "../../../include/tptp/version.h"
2
//Microsoft Developer Studio generated resource script.
2
//Microsoft Developer Studio generated resource script.
3
//
3
//
4
#include "resource.h"
4
#include "resource.h"
(-)src-native-new/src/transport/RASocket/RASocket.make (-1 / +1 lines)
Lines 44-50 Link Here
44
#   list of additional libraries to be linked with
44
#   list of additional libraries to be linked with
45
#      (separated by blanks)
45
#      (separated by blanks)
46
#-----------------------------------
46
#-----------------------------------
47
LIBS       :=  dl  hcclco
47
LIBS       :=  dl hcclco pthread
48
48
49
#-----------------------------------
49
#-----------------------------------
50
#   list of additional library directories to search from
50
#   list of additional library directories to search from
(-)src-native-new/src/transport/RASharedMemory/RASharedMemory.mak64 (-58 / +403 lines)
Lines 1-20 Link Here
1
# Microsoft Developer Studio based NMAKE File, derived from RASharedMemory.dsp
1
# Microsoft Developer Studio Generated NMAKE File, Based on RASharedMemory.dsp
2
!IF "$(CFG)" == ""
2
!IF "$(CFG)" == ""
3
CFG=RASharedMemory - IA64 Release
3
CFG=RASharedMemory - IA64 Debug
4
!MESSAGE No configuration specified. Defaulting to RASharedMemory - IA64 Release.
4
!MESSAGE No configuration specified. Defaulting to RASharedMemory - IA64 Debug.
5
!ENDIF 
5
!ENDIF 
6
6
7
!IF "$(CFG)" != "RASharedMemory - IA64 Debug" && "$(CFG)" != "RASharedMemory - IA64 Release"
7
!IF "$(CFG)" != "RASharedMemory - IA64 Release" && "$(CFG)" != "RASharedMemory - IA64 Debug" && "$(CFG)" != "RASharedMemory - X64 Release" && "$(CFG)" != "RASharedMemory - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
11
!MESSAGE 
12
!MESSAGE NMAKE /f "RASharedMemory.mak64" CFG="RASharedMemory - IA64 Release"
12
!MESSAGE NMAKE /f "RASharedMemory.mak64" CFG="RASharedMemory - IA64 Debug"
13
!MESSAGE 
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
15
!MESSAGE 
16
!MESSAGE "RASharedMemory - IA64 Debug"
17
!MESSAGE "RASharedMemory - IA64 Release"
16
!MESSAGE "RASharedMemory - IA64 Release"
17
!MESSAGE "RASharedMemory - IA64 Debug"
18
!MESSAGE "RASharedMemory - X64 Release"
19
!MESSAGE "RASharedMemory - X64 Debug"
18
!MESSAGE 
20
!MESSAGE 
19
!ERROR An invalid configuration is specified.
21
!ERROR An invalid configuration is specified.
20
!ENDIF 
22
!ENDIF 
Lines 25-45 Link Here
25
NULL=nul
27
NULL=nul
26
!ENDIF 
28
!ENDIF 
27
29
30
!IF  "$(CFG)" == "RASharedMemory - IA64 Release"
31
32
OUTDIR=..\..\..\bin
33
INTDIR=.\Release
34
# Begin Custom Macros
35
OutDir=..\..\..\bin
36
# End Custom Macros
37
38
!IF "$(RECURSE)" == "0" 
39
40
ALL : "$(OUTDIR)\hcclsm.dll"
41
42
!ELSE 
43
44
ALL : "RASocket - IA64 Release" "RACommon - IA64 Release" "$(OUTDIR)\hcclsm.dll"
45
46
!ENDIF 
47
48
!IF "$(RECURSE)" == "1" 
49
CLEAN :"RACommon - IA64 ReleaseCLEAN" "RASocket - IA64 ReleaseCLEAN" 
50
!ELSE 
51
CLEAN :
52
!ENDIF 
53
	-@erase "$(INTDIR)\hcclsm.res"
54
	-@erase "$(INTDIR)\ossdebug.obj"
55
	-@erase "$(INTDIR)\ossipc.obj"
56
	-@erase "$(INTDIR)\ossipcmemory.obj"
57
	-@erase "$(INTDIR)\ossmemory.obj"
58
	-@erase "$(INTDIR)\ossrambo.obj"
59
	-@erase "$(INTDIR)\ossramboflush.obj"
60
	-@erase "$(INTDIR)\osstime.obj"
61
	-@erase "$(INTDIR)\vc60.idb"
62
	-@erase "$(OUTDIR)\hcclsm.dll"
63
	-@erase "$(OUTDIR)\..\lib\hcclsm.exp"
64
	-@erase "$(OUTDIR)\..\lib\hcclsm.lib"
65
66
"$(OUTDIR)" :
67
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
68
69
"$(INTDIR)" :
70
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
71
28
CPP=cl.exe
72
CPP=cl.exe
73
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /Ob0 /I "..\RACommon" /I "..\RASocket" /I "..\RADataTransfer" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RASHAREDMEMORY_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\RASharedMemory.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
74
75
.c{$(INTDIR)}.obj::
76
   $(CPP) @<<
77
   $(CPP_PROJ) $< 
78
<<
79
80
.cpp{$(INTDIR)}.obj::
81
   $(CPP) @<<
82
   $(CPP_PROJ) $< 
83
<<
84
85
.cxx{$(INTDIR)}.obj::
86
   $(CPP) @<<
87
   $(CPP_PROJ) $< 
88
<<
89
90
.c{$(INTDIR)}.sbr::
91
   $(CPP) @<<
92
   $(CPP_PROJ) $< 
93
<<
94
95
.cpp{$(INTDIR)}.sbr::
96
   $(CPP) @<<
97
   $(CPP_PROJ) $< 
98
<<
99
100
.cxx{$(INTDIR)}.sbr::
101
   $(CPP) @<<
102
   $(CPP_PROJ) $< 
103
<<
104
105
MTL=midl.exe
106
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
29
RSC=rc.exe
107
RSC=rc.exe
108
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcclsm.res" /d "NDEBUG" 
30
109
31
!IF  "$(CFG)" == "RASharedMemory - IA64 Debug"
110
LINK32=link.exe
111
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ws2_32.lib bufferoverflowU.lib /nologo /version:0.1 /dll /pdb:none /def:"..\RASharedMemory\RASharedMemory.def" /out:"$(OUTDIR)\hcclsm.dll" /implib:"$(OUTDIR)\..\lib\hcclsm.lib" /libpath:".\bin" /machine:IA64
112
LINK32_OBJS= \
113
	"$(INTDIR)\ossdebug.obj" \
114
	"$(INTDIR)\ossipc.obj" \
115
	"$(INTDIR)\ossipcmemory.obj" \
116
	"$(INTDIR)\ossmemory.obj" \
117
	"$(INTDIR)\ossrambo.obj" \
118
	"$(INTDIR)\ossramboflush.obj" \
119
	"$(INTDIR)\osstime.obj" \
120
	"$(INTDIR)\hcclsm.res" \
121
	"$(OUTDIR)\..\lib\hcclco.lib" \
122
	"$(OUTDIR)\..\lib\hccls.lib"
123
124
"$(OUTDIR)\hcclsm.dll" : "$(OUTDIR)" $(LINK32_OBJS)
125
    $(LINK32) @<<
126
  $(LINK32_FLAGS) $(LINK32_OBJS)
127
<<
128
129
!ELSEIF  "$(CFG)" == "RASharedMemory - IA64 Debug"
32
130
33
OUTDIR=.\RASharedMemory___IA64Debug
131
OUTDIR=..\..\..\bin
34
INTDIR=.\RASharedMemory___IA64Debug
132
INTDIR=.\Debug
133
# Begin Custom Macros
134
OutDir=..\..\..\bin
135
# End Custom Macros
35
136
36
!IF "$(RECURSE)" == "0" 
137
!IF "$(RECURSE)" == "0" 
37
138
38
ALL : "..\..\..\bin\hcclsm.dll"
139
ALL : "$(OUTDIR)\hcclsm.dll"
39
140
40
!ELSE 
141
!ELSE 
41
142
42
ALL : "RASocket - IA64 Debug" "RACommon - IA64 Debug" "..\..\..\bin\hcclsm.dll"
143
ALL : "RASocket - IA64 Debug" "RACommon - IA64 Debug" "$(OUTDIR)\hcclsm.dll"
43
144
44
!ENDIF 
145
!ENDIF 
45
146
Lines 48-53 Link Here
48
!ELSE 
149
!ELSE 
49
CLEAN :
150
CLEAN :
50
!ENDIF 
151
!ENDIF 
152
	-@erase "$(INTDIR)\hcclsm.res"
51
	-@erase "$(INTDIR)\ossdebug.obj"
153
	-@erase "$(INTDIR)\ossdebug.obj"
52
	-@erase "$(INTDIR)\ossipc.obj"
154
	-@erase "$(INTDIR)\ossipc.obj"
53
	-@erase "$(INTDIR)\ossipcmemory.obj"
155
	-@erase "$(INTDIR)\ossipcmemory.obj"
Lines 57-77 Link Here
57
	-@erase "$(INTDIR)\osstime.obj"
159
	-@erase "$(INTDIR)\osstime.obj"
58
	-@erase "$(INTDIR)\vc60.idb"
160
	-@erase "$(INTDIR)\vc60.idb"
59
	-@erase "$(INTDIR)\vc60.pdb"
161
	-@erase "$(INTDIR)\vc60.pdb"
60
	-@erase "$(OUTDIR)\hcclsm.pdb"
162
	-@erase "$(OUTDIR)\hcclsm.dll"
61
	-@erase "..\..\..\bin\hcclsm.dll"
163
	-@erase "$(OUTDIR)\..\lib\hcclsm.exp"
62
	-@erase "..\..\..\bin\hcclsm.ilk"
164
	-@erase "$(OUTDIR)\..\lib\hcclsm.ilk"
63
	-@erase "..\..\..\lib\hcclsm.exp"
165
	-@erase "$(OUTDIR)\..\lib\hcclsm.lib"
64
	-@erase "..\..\..\lib\hcclsm.lib"
166
	-@erase "$(OUTDIR)\..\lib\hcclsm.pdb"
65
	-@erase "$(OUTDIR)\hcclsm.res"
66
167
67
"$(OUTDIR)" :
168
"$(OUTDIR)" :
68
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
169
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
69
170
70
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\RACommon" /I "..\RASocket" /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RASHAREDMEMORY_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\RASharedMemory.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
171
"$(INTDIR)" :
71
RSC_PROJ=/l 0x409 /fo"$(OUTDIR)/hcclsm.res" /i "../../../include" /d "_DEBUG" 
172
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
72
	
173
174
CPP=cl.exe
175
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\RACommon" /I "..\RASocket" /I "..\RADataTransfer" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RASHAREDMEMORY_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\RASharedMemory.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
176
177
.c{$(INTDIR)}.obj::
178
   $(CPP) @<<
179
   $(CPP_PROJ) $< 
180
<<
181
182
.cpp{$(INTDIR)}.obj::
183
   $(CPP) @<<
184
   $(CPP_PROJ) $< 
185
<<
186
187
.cxx{$(INTDIR)}.obj::
188
   $(CPP) @<<
189
   $(CPP_PROJ) $< 
190
<<
191
192
.c{$(INTDIR)}.sbr::
193
   $(CPP) @<<
194
   $(CPP_PROJ) $< 
195
<<
196
197
.cpp{$(INTDIR)}.sbr::
198
   $(CPP) @<<
199
   $(CPP_PROJ) $< 
200
<<
201
202
.cxx{$(INTDIR)}.sbr::
203
   $(CPP) @<<
204
   $(CPP_PROJ) $< 
205
<<
206
207
MTL=midl.exe
208
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
209
RSC=rc.exe
210
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcclsm.res" /d "_DEBUG" 
211
73
LINK32=link.exe
212
LINK32=link.exe
74
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib hcclco.lib hccls.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcclsm.pdb" /debug /def:".\RASharedMemory.def" /out:"../../../bin/hcclsm.dll" /implib:"../../../lib/hcclsm.lib" /libpath:"../../../lib" /machine:IA64
213
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ws2_32.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcclsm.pdb" /debug /def:"..\RASharedMemory\RASharedMemory.def" /out:"$(OUTDIR)\hcclsm.dll" /implib:"$(OUTDIR)\..\lib\hcclsm.lib" /libpath:".\bin" /machine:IA64
75
LINK32_OBJS= \
214
LINK32_OBJS= \
76
	"$(INTDIR)\ossdebug.obj" \
215
	"$(INTDIR)\ossdebug.obj" \
77
	"$(INTDIR)\ossipc.obj" \
216
	"$(INTDIR)\ossipc.obj" \
Lines 80-100 Link Here
80
	"$(INTDIR)\ossrambo.obj" \
219
	"$(INTDIR)\ossrambo.obj" \
81
	"$(INTDIR)\ossramboflush.obj" \
220
	"$(INTDIR)\ossramboflush.obj" \
82
	"$(INTDIR)\osstime.obj" \
221
	"$(INTDIR)\osstime.obj" \
83
	"$(OUTDIR)\hcclsm.res" \
222
	"$(INTDIR)\hcclsm.res" \
84
	"..\..\..\lib\hcclco.lib" \
223
	"$(OUTDIR)\..\lib\hcclco.lib" \
85
	"..\..\..\lib\hccls.lib"
224
	"$(OUTDIR)\..\lib\hccls.lib"
86
225
87
"..\..\..\bin\hcclsm.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
226
"$(OUTDIR)\hcclsm.dll" : "$(OUTDIR)" $(LINK32_OBJS)
88
    $(LINK32) @<<
227
    $(LINK32) @<<
89
  $(LINK32_FLAGS) $(LINK32_OBJS)
228
  $(LINK32_FLAGS) $(LINK32_OBJS)
90
<<
229
<<
91
230
92
!ELSEIF  "$(CFG)" == "RASharedMemory - IA64 Release"
231
!ELSEIF  "$(CFG)" == "RASharedMemory - X64 Release"
93
232
94
OUTDIR=.\../../../bin
233
OUTDIR=..\..\..\bin
95
INTDIR=.\RASharedMemory___IA64Release
234
INTDIR=.\Release
96
# Begin Custom Macros
235
# Begin Custom Macros
97
OutDir=.\../../../bin
236
OutDir=..\..\..\bin
98
# End Custom Macros
237
# End Custom Macros
99
238
100
!IF "$(RECURSE)" == "0" 
239
!IF "$(RECURSE)" == "0" 
Lines 103-117 Link Here
103
242
104
!ELSE 
243
!ELSE 
105
244
106
ALL : "RASocket - IA64 Release" "RACommon - IA64 Release" "$(OUTDIR)\hcclsm.dll"
245
ALL : "RASocket - X64 Release" "RACommon - X64 Release" "$(OUTDIR)\hcclsm.dll"
107
246
108
!ENDIF 
247
!ENDIF 
109
248
110
!IF "$(RECURSE)" == "1" 
249
!IF "$(RECURSE)" == "1" 
111
CLEAN :"RACommon - IA64 ReleaseCLEAN" "RASocket - IA64 ReleaseCLEAN" 
250
CLEAN :"RACommon - X64 ReleaseCLEAN" "RASocket - X64 ReleaseCLEAN" 
112
!ELSE 
251
!ELSE 
113
CLEAN :
252
CLEAN :
114
!ENDIF 
253
!ENDIF 
254
	-@erase "$(INTDIR)\hcclsm.res"
115
	-@erase "$(INTDIR)\ossdebug.obj"
255
	-@erase "$(INTDIR)\ossdebug.obj"
116
	-@erase "$(INTDIR)\ossipc.obj"
256
	-@erase "$(INTDIR)\ossipc.obj"
117
	-@erase "$(INTDIR)\ossipcmemory.obj"
257
	-@erase "$(INTDIR)\ossipcmemory.obj"
Lines 121-130 Link Here
121
	-@erase "$(INTDIR)\osstime.obj"
261
	-@erase "$(INTDIR)\osstime.obj"
122
	-@erase "$(INTDIR)\vc60.idb"
262
	-@erase "$(INTDIR)\vc60.idb"
123
	-@erase "$(OUTDIR)\hcclsm.dll"
263
	-@erase "$(OUTDIR)\hcclsm.dll"
124
	-@erase "$(OUTDIR)\hcclsm.ilk"
264
	-@erase "$(OUTDIR)\..\lib\hcclsm.exp"
125
	-@erase "..\..\..\lib\hcclsm.exp"
265
	-@erase "$(OUTDIR)\..\lib\hcclsm.lib"
126
	-@erase "..\..\..\lib\hcclsm.lib"
127
	-@erase "$(OUTDIR)\hcclsm.res"
128
266
129
"$(OUTDIR)" :
267
"$(OUTDIR)" :
130
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
268
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
Lines 132-142 Link Here
132
"$(INTDIR)" :
270
"$(INTDIR)" :
133
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
271
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
134
272
135
CPP_PROJ=/nologo /MD /W3 /O2 /I "..\RACommon" /I "..\RASocket" /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RASHAREDMEMORY_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\RASharedMemory.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
273
CPP=cl.exe
136
RSC_PROJ=/l 0x409 /fo"$(OUTDIR)/hcclsm.res" /i "../../../include" /d "_DEBUG" 
274
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /Ob0 /I "..\RACommon" /I "..\RASocket" /I "..\RADataTransfer" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RASHAREDMEMORY_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\RASharedMemory.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
137
	
275
276
.c{$(INTDIR)}.obj::
277
   $(CPP) @<<
278
   $(CPP_PROJ) $< 
279
<<
280
281
.cpp{$(INTDIR)}.obj::
282
   $(CPP) @<<
283
   $(CPP_PROJ) $< 
284
<<
285
286
.cxx{$(INTDIR)}.obj::
287
   $(CPP) @<<
288
   $(CPP_PROJ) $< 
289
<<
290
291
.c{$(INTDIR)}.sbr::
292
   $(CPP) @<<
293
   $(CPP_PROJ) $< 
294
<<
295
296
.cpp{$(INTDIR)}.sbr::
297
   $(CPP) @<<
298
   $(CPP_PROJ) $< 
299
<<
300
301
.cxx{$(INTDIR)}.sbr::
302
   $(CPP) @<<
303
   $(CPP_PROJ) $< 
304
<<
305
306
MTL=midl.exe
307
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
308
RSC=rc.exe
309
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcclsm.res" /d "NDEBUG" 
310
138
LINK32=link.exe
311
LINK32=link.exe
139
LINK32_FLAGS=advapi32.lib uuid.lib ws2_32.lib hcclco.lib hccls.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcclsm.pdb" /def:".\RASharedMemory.def" /out:"$(OUTDIR)\hcclsm.dll" /implib:"../../../lib/hcclsm.lib" /libpath:"../../../lib" /machine:IA64 
312
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ws2_32.lib bufferoverflowU.lib /nologo /version:0.1 /dll /pdb:none /def:"..\RASharedMemory\RASharedMemory.def" /out:"$(OUTDIR)\hcclsm.dll" /implib:"$(OUTDIR)\..\lib\hcclsm.lib" /libpath:".\bin" /machine:AMD64
140
LINK32_OBJS= \
313
LINK32_OBJS= \
141
	"$(INTDIR)\ossdebug.obj" \
314
	"$(INTDIR)\ossdebug.obj" \
142
	"$(INTDIR)\ossipc.obj" \
315
	"$(INTDIR)\ossipc.obj" \
Lines 145-160 Link Here
145
	"$(INTDIR)\ossrambo.obj" \
318
	"$(INTDIR)\ossrambo.obj" \
146
	"$(INTDIR)\ossramboflush.obj" \
319
	"$(INTDIR)\ossramboflush.obj" \
147
	"$(INTDIR)\osstime.obj" \
320
	"$(INTDIR)\osstime.obj" \
148
	"$(OUTDIR)\hcclsm.res" \
321
	"$(INTDIR)\hcclsm.res" \
149
	"..\..\..\lib\hcclco.lib" \
322
	"$(OUTDIR)\..\lib\hcclco.lib" \
150
	"..\..\..\lib\hccls.lib"
323
	"$(OUTDIR)\..\lib\hccls.lib"
151
324
152
"$(OUTDIR)\hcclsm.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
325
"$(OUTDIR)\hcclsm.dll" : "$(OUTDIR)" $(LINK32_OBJS)
153
    $(LINK32) @<<
326
    $(LINK32) @<<
154
  $(LINK32_FLAGS) $(LINK32_OBJS)
327
  $(LINK32_FLAGS) $(LINK32_OBJS)
155
<<
328
<<
156
329
330
!ELSEIF  "$(CFG)" == "RASharedMemory - X64 Debug"
331
332
OUTDIR=..\..\..\bin
333
INTDIR=.\Debug
334
# Begin Custom Macros
335
OutDir=..\..\..\bin
336
# End Custom Macros
337
338
!IF "$(RECURSE)" == "0" 
339
340
ALL : "$(OUTDIR)\hcclsm.dll"
341
342
!ELSE 
343
344
ALL : "RASocket - X64 Debug" "RACommon - X64 Debug" "$(OUTDIR)\hcclsm.dll"
345
346
!ENDIF 
347
348
!IF "$(RECURSE)" == "1" 
349
CLEAN :"RACommon - X64 DebugCLEAN" "RASocket - X64 DebugCLEAN" 
350
!ELSE 
351
CLEAN :
157
!ENDIF 
352
!ENDIF 
353
	-@erase "$(INTDIR)\hcclsm.res"
354
	-@erase "$(INTDIR)\ossdebug.obj"
355
	-@erase "$(INTDIR)\ossipc.obj"
356
	-@erase "$(INTDIR)\ossipcmemory.obj"
357
	-@erase "$(INTDIR)\ossmemory.obj"
358
	-@erase "$(INTDIR)\ossrambo.obj"
359
	-@erase "$(INTDIR)\ossramboflush.obj"
360
	-@erase "$(INTDIR)\osstime.obj"
361
	-@erase "$(INTDIR)\vc60.idb"
362
	-@erase "$(INTDIR)\vc60.pdb"
363
	-@erase "$(OUTDIR)\hcclsm.dll"
364
	-@erase "$(OUTDIR)\..\lib\hcclsm.exp"
365
	-@erase "$(OUTDIR)\..\lib\hcclsm.ilk"
366
	-@erase "$(OUTDIR)\..\lib\hcclsm.lib"
367
	-@erase "$(OUTDIR)\..\lib\hcclsm.pdb"
368
369
"$(OUTDIR)" :
370
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
371
372
"$(INTDIR)" :
373
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
374
375
CPP=cl.exe
376
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\RACommon" /I "..\RASocket" /I "..\RADataTransfer" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RASHAREDMEMORY_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\RASharedMemory.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
158
377
159
.c{$(INTDIR)}.obj::
378
.c{$(INTDIR)}.obj::
160
   $(CPP) @<<
379
   $(CPP) @<<
Lines 171-218 Link Here
171
   $(CPP_PROJ) $< 
390
   $(CPP_PROJ) $< 
172
<<
391
<<
173
392
174
!IF "$(CFG)" == "RASharedMemory - IA64 Debug" || "$(CFG)" == "RASharedMemory - IA64 Release"
393
.c{$(INTDIR)}.sbr::
394
   $(CPP) @<<
395
   $(CPP_PROJ) $< 
396
<<
397
398
.cpp{$(INTDIR)}.sbr::
399
   $(CPP) @<<
400
   $(CPP_PROJ) $< 
401
<<
402
403
.cxx{$(INTDIR)}.sbr::
404
   $(CPP) @<<
405
   $(CPP_PROJ) $< 
406
<<
407
408
MTL=midl.exe
409
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
410
RSC=rc.exe
411
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcclsm.res" /d "_DEBUG" 
412
413
LINK32=link.exe
414
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ws2_32.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcclsm.pdb" /debug /def:"..\RASharedMemory\RASharedMemory.def" /out:"$(OUTDIR)\hcclsm.dll" /implib:"$(OUTDIR)\..\lib\hcclsm.lib" /libpath:".\bin" /machine:AMD64
415
LINK32_OBJS= \
416
	"$(INTDIR)\ossdebug.obj" \
417
	"$(INTDIR)\ossipc.obj" \
418
	"$(INTDIR)\ossipcmemory.obj" \
419
	"$(INTDIR)\ossmemory.obj" \
420
	"$(INTDIR)\ossrambo.obj" \
421
	"$(INTDIR)\ossramboflush.obj" \
422
	"$(INTDIR)\osstime.obj" \
423
	"$(INTDIR)\hcclsm.res" \
424
	"$(OUTDIR)\..\lib\hcclco.lib" \
425
	"$(OUTDIR)\..\lib\hccls.lib"
426
427
"$(OUTDIR)\hcclsm.dll" : "$(OUTDIR)" $(LINK32_OBJS)
428
    $(LINK32) @<<
429
  $(LINK32_FLAGS) $(LINK32_OBJS)
430
<<
431
432
!ENDIF 
433
434
435
!IF "$(CFG)" == "RASharedMemory - IA64 Release" || "$(CFG)" == "RASharedMemory - IA64 Debug" || "$(CFG)" == "RASharedMemory - X64 Release" || "$(CFG)" == "RASharedMemory - X64 Debug"
175
SOURCE=..\RASharedMemory\ossdebug.cpp
436
SOURCE=..\RASharedMemory\ossdebug.cpp
176
437
177
"$(INTDIR)\ossdebug.obj" : $(SOURCE) "$(INTDIR)"
438
"$(INTDIR)\ossdebug.obj" : $(SOURCE) "$(INTDIR)"
439
	$(CPP) $(CPP_PROJ) $(SOURCE)
178
440
179
441
180
SOURCE=..\RASharedMemory\ossipc.cpp
442
SOURCE=..\RASharedMemory\ossipc.cpp
181
443
182
"$(INTDIR)\ossipc.obj" : $(SOURCE) "$(INTDIR)"
444
"$(INTDIR)\ossipc.obj" : $(SOURCE) "$(INTDIR)"
445
	$(CPP) $(CPP_PROJ) $(SOURCE)
183
446
184
447
185
SOURCE=..\RASharedMemory\ossipcmemory.cpp
448
SOURCE=..\RASharedMemory\ossipcmemory.cpp
186
449
187
"$(INTDIR)\ossipcmemory.obj" : $(SOURCE) "$(INTDIR)"
450
"$(INTDIR)\ossipcmemory.obj" : $(SOURCE) "$(INTDIR)"
451
	$(CPP) $(CPP_PROJ) $(SOURCE)
188
452
189
453
190
SOURCE=..\RASharedMemory\ossmemory.cpp
454
SOURCE=..\RASharedMemory\ossmemory.cpp
191
455
192
"$(INTDIR)\ossmemory.obj" : $(SOURCE) "$(INTDIR)"
456
"$(INTDIR)\ossmemory.obj" : $(SOURCE) "$(INTDIR)"
457
	$(CPP) $(CPP_PROJ) $(SOURCE)
193
458
194
459
195
SOURCE=..\RASharedMemory\ossrambo.cpp
460
SOURCE=..\RASharedMemory\ossrambo.cpp
196
461
197
"$(INTDIR)\ossrambo.obj" : $(SOURCE) "$(INTDIR)"
462
"$(INTDIR)\ossrambo.obj" : $(SOURCE) "$(INTDIR)"
463
	$(CPP) $(CPP_PROJ) $(SOURCE)
198
464
199
465
200
SOURCE=..\RASharedMemory\ossramboflush.cpp
466
SOURCE=..\RASharedMemory\ossramboflush.cpp
201
467
202
"$(INTDIR)\ossramboflush.obj" : $(SOURCE) "$(INTDIR)"
468
"$(INTDIR)\ossramboflush.obj" : $(SOURCE) "$(INTDIR)"
469
	$(CPP) $(CPP_PROJ) $(SOURCE)
203
470
204
471
205
SOURCE=..\RASharedMemory\osstime.cpp
472
SOURCE=..\RASharedMemory\osstime.cpp
206
473
207
"$(INTDIR)\osstime.obj" : $(SOURCE) "$(INTDIR)"
474
"$(INTDIR)\osstime.obj" : $(SOURCE) "$(INTDIR)"
475
	$(CPP) $(CPP_PROJ) $(SOURCE)
208
476
209
477
210
SOURCE=..\RASharedMemory\version.rc
478
SOURCE=..\RASharedMemory\version.rc
211
479
212
"$(OUTDIR)\hcclsm.res" : $(SOURCE) "$(INTDIR)"
480
!IF  "$(CFG)" == "RASharedMemory - IA64 Release"
213
	$(RSC) $(RSC_PROJ) $(SOURCE)
481
482
483
"$(INTDIR)\hcclsm.res" : $(SOURCE) "$(INTDIR)"
484
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcclsm.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RASharedMemory" /d "NDEBUG" $(SOURCE)
485
486
487
!ELSEIF  "$(CFG)" == "RASharedMemory - IA64 Debug"
488
489
490
"$(INTDIR)\hcclsm.res" : $(SOURCE) "$(INTDIR)"
491
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcclsm.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RASharedMemory" /d "_DEBUG" $(SOURCE)
492
493
494
!ELSEIF  "$(CFG)" == "RASharedMemory - X64 Release"
495
496
497
"$(INTDIR)\hcclsm.res" : $(SOURCE) "$(INTDIR)"
498
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcclsm.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RASharedMemory" /d "NDEBUG" $(SOURCE)
499
500
501
!ELSEIF  "$(CFG)" == "RASharedMemory - X64 Debug"
214
502
215
!IF  "$(CFG)" == "RASharedMemory - IA64 Debug"
503
504
"$(INTDIR)\hcclsm.res" : $(SOURCE) "$(INTDIR)"
505
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcclsm.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RASharedMemory" /d "_DEBUG" $(SOURCE)
506
507
508
!ENDIF 
509
510
!IF  "$(CFG)" == "RASharedMemory - IA64 Release"
511
512
"RACommon - IA64 Release" : 
513
   cd "..\RACommon"
514
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Release" 
515
   cd "..\RASharedMemory"
516
517
"RACommon - IA64 ReleaseCLEAN" : 
518
   cd "..\RACommon"
519
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Release" RECURSE=1 CLEAN 
520
   cd "..\RASharedMemory"
521
522
!ELSEIF  "$(CFG)" == "RASharedMemory - IA64 Debug"
216
523
217
"RACommon - IA64 Debug" : 
524
"RACommon - IA64 Debug" : 
218
   cd "..\RACommon"
525
   cd "..\RACommon"
Lines 224-244 Link Here
224
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Debug" RECURSE=1 CLEAN 
531
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Debug" RECURSE=1 CLEAN 
225
   cd "..\RASharedMemory"
532
   cd "..\RASharedMemory"
226
533
227
!ELSEIF  "$(CFG)" == "RASharedMemory - IA64 Release"
534
!ELSEIF  "$(CFG)" == "RASharedMemory - X64 Release"
228
535
229
"RACommon - IA64 Release" : 
536
"RACommon - X64 Release" : 
230
   cd "..\RACommon"
537
   cd "..\RACommon"
231
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Release" 
538
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Release" 
232
   cd "..\RASharedMemory"
539
   cd "..\RASharedMemory"
233
540
234
"RACommon - IA64 ReleaseCLEAN" : 
541
"RACommon - X64 ReleaseCLEAN" : 
235
   cd "..\RACommon"
542
   cd "..\RACommon"
236
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Release" RECURSE=1 CLEAN 
543
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Release" RECURSE=1 CLEAN 
544
   cd "..\RASharedMemory"
545
546
!ELSEIF  "$(CFG)" == "RASharedMemory - X64 Debug"
547
548
"RACommon - X64 Debug" : 
549
   cd "..\RACommon"
550
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Debug" 
551
   cd "..\RASharedMemory"
552
553
"RACommon - X64 DebugCLEAN" : 
554
   cd "..\RACommon"
555
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Debug" RECURSE=1 CLEAN 
237
   cd "..\RASharedMemory"
556
   cd "..\RASharedMemory"
238
557
239
!ENDIF 
558
!ENDIF 
240
559
241
!IF  "$(CFG)" == "RASharedMemory - IA64 Debug"
560
!IF  "$(CFG)" == "RASharedMemory - IA64 Release"
561
562
"RASocket - IA64 Release" : 
563
   cd "..\RASocket"
564
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Release" 
565
   cd "..\RASharedMemory"
566
567
"RASocket - IA64 ReleaseCLEAN" : 
568
   cd "..\RASocket"
569
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Release" RECURSE=1 CLEAN 
570
   cd "..\RASharedMemory"
571
572
!ELSEIF  "$(CFG)" == "RASharedMemory - IA64 Debug"
242
573
243
"RASocket - IA64 Debug" : 
574
"RASocket - IA64 Debug" : 
244
   cd "..\RASocket"
575
   cd "..\RASocket"
Lines 250-267 Link Here
250
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Debug" RECURSE=1 CLEAN 
581
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Debug" RECURSE=1 CLEAN 
251
   cd "..\RASharedMemory"
582
   cd "..\RASharedMemory"
252
583
253
!ELSEIF  "$(CFG)" == "RASharedMemory - IA64 Release"
584
!ELSEIF  "$(CFG)" == "RASharedMemory - X64 Release"
254
585
255
"RASocket - IA64 Release" : 
586
"RASocket - X64 Release" : 
256
   cd "..\RASocket"
587
   cd "..\RASocket"
257
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Release" 
588
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - X64 Release" 
258
   cd "..\RASharedMemory"
589
   cd "..\RASharedMemory"
259
590
260
"RASocket - IA64 ReleaseCLEAN" : 
591
"RASocket - X64 ReleaseCLEAN" : 
261
   cd "..\RASocket"
592
   cd "..\RASocket"
262
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Release" RECURSE=1 CLEAN 
593
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - X64 Release" RECURSE=1 CLEAN 
594
   cd "..\RASharedMemory"
595
596
!ELSEIF  "$(CFG)" == "RASharedMemory - X64 Debug"
597
598
"RASocket - X64 Debug" : 
599
   cd "..\RASocket"
600
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - X64 Debug" 
601
   cd "..\RASharedMemory"
602
603
"RASocket - X64 DebugCLEAN" : 
604
   cd "..\RASocket"
605
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - X64 Debug" RECURSE=1 CLEAN 
263
   cd "..\RASharedMemory"
606
   cd "..\RASharedMemory"
264
607
265
!ENDIF 
608
!ENDIF 
266
609
610
267
!ENDIF 
611
!ENDIF 
612
(-)src-native-new/src/transport/RASharedMemory/version.rc (-1 / +1 lines)
Lines 1-4 Link Here
1
#include "tptp/version.h"
1
#include "../../../include/tptp/version.h"
2
//Microsoft Developer Studio generated resource script.
2
//Microsoft Developer Studio generated resource script.
3
//
3
//
4
#include "resource.h"
4
#include "resource.h"
(-)src-native-new/src/transport/RASharedMemory/RASharedMemory.make (-1 / +1 lines)
Lines 44-50 Link Here
44
#   list of additional libraries to be linked with
44
#   list of additional libraries to be linked with
45
#      (separated by blanks)
45
#      (separated by blanks)
46
#-----------------------------------
46
#-----------------------------------
47
LIBS       :=  dl  hcclco  hccls
47
LIBS       :=  dl hcclco hccls pthread
48
48
49
#-----------------------------------
49
#-----------------------------------
50
#   list of additional library directories to search from
50
#   list of additional library directories to search from
(-)src-native-new/src/agents/native/heapsnapshots/AbstractHeapSnapshotManager.h (+35 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: AbstractHeapSnapshotManager.h,v 1.3 2005/02/25 22:17:34 hleung Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef ABSTRACT_HEAP_SNAPSHOT_MANAGER_H
14
#define ABSTRACT_HEAP_SNAPSHOT_MANAGER_H
15
16
#include <jvmpi.h>
17
#include "HeapSnapshotManager.h"
18
#include "SnapshotAgentInterface.h"
19
#include "SnapshotFiller.h"
20
21
class AbstractHeapSnapshotManager : public HeapSnapshotManager {
22
 public:
23
  AbstractHeapSnapshotManager(SnapshotFiller* filler, SnapshotAgentInterface* agent, JVMPI_Interface* jvmpi);
24
 protected:
25
   SnapshotFiller& filler() const;
26
   SnapshotAgentInterface& agent() const;
27
   JVMPI_Interface& jvmpi() const;
28
29
 private:
30
   SnapshotFiller*         _filler;
31
   SnapshotAgentInterface* _agent;
32
   JVMPI_Interface*        _jvmpi;
33
};
34
35
#endif /* ABSTRACT_HEAP_SNAPSHOT_MANAGER_H */
(-)src-native-new/src/agents/perfmon/PerfmonAgent/resource.h (+20 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: resource.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifdef APSTUDIO_INVOKED
14
#ifndef APSTUDIO_READONLY_SYMBOLS
15
#define _APS_NEXT_RESOURCE_VALUE        101
16
#define _APS_NEXT_COMMAND_VALUE         40001
17
#define _APS_NEXT_CONTROL_VALUE         1000
18
#define _APS_NEXT_SYMED_VALUE           101
19
#endif
20
#endif
(-)src-native-new/src/agents/native/java_profiler/hash.h (+441 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: hash.h,v 1.8 2006/04/06 15:48:10 samwai Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef __HASH_H__
14
#define __HASH_H__ 1
15
16
#ifdef __linux__
17
  #define _inline inline
18
#endif
19
20
#include <jvmpi.h>
21
#include "performance.h"
22
#include "segmentedValue.h"
23
#include "stack.h"
24
#include "RABindings.h"
25
#include "filters.h"
26
27
28
#ifdef __cplusplus
29
 extern "C" {
30
#endif
31
32
/******************************
33
 * Symbol table types and methods
34
 ******************************/
35
#define CLASS_HASH_TABLE_SIZE    4999	/* The number of 1st level entries in the CLASS hashtable */
36
#define METHOD_HASH_TABLE_SIZE   10007	/* The number of 1st level entries in the METHOD hashtable */
37
#define OBJECT_HASH_TABLE_SIZE   20011	/* The number of 1st level entries in the OBJECT Thashtable */
38
#define THREAD_HASH_TABLE_SIZE   101	/* The number of 1st level entries in the THREAD hashtable */
39
#define HEAP_HASH_TABLE_SIZE   20011
40
41
#define ThreadLocalStorage ThreadPrivateStorage
42
43
/* Macros to access the data variants of the symbol table */
44
#define CLASS_ENTRY(hashEntry) ((ClassEntry *)hashEntry->entry)
45
#define METHOD_ENTRY(hashEntry) ((MethodEntry *)hashEntry->entry)
46
#define OBJECT_ENTRY(hashEntry) ((ObjectEntry *)hashEntry->entry)
47
#define THREAD_ENTRY(hashEntry) ((ThreadLocalStorage *)hashEntry->entry)
48
#define HEAP_ENTRY(hashEntry) ((HeapEntry *)hashEntry->entry)
49
50
/* The various types that will be stored in the various hashtables */
51
enum EntryType {Class_t, Method_t, Object_t, Thread_t, Heap_t};
52
53
54
/* these are the various types of keys that can be used in the hash tables */ 
55
typedef struct objectHashKey {
56
	jobjectID id; 
57
} ObjectHashKey; 
58
59
typedef ObjectHashKey ClassHashKey; 
60
61
typedef struct methodHashKey {
62
	jmethodID id; 
63
} MethodHashKey; 
64
65
typedef struct threadHashKey {
66
	JNIEnv *id; 
67
} ThreadHashKey; 
68
69
70
/* an entry in the hash table */ 
71
typedef struct hashEntry
72
{
73
 void* id;					/* The hash key (ObjectHashKey*, MethodHashKey*, ThreadHashKey* */
74
 unsigned int printed:1;    /* Indicates that this symbol has been referenced */
75
 unsigned int deleted:1;    /* Indicates that this symbol is deleted */
76
 volatile unsigned int toBeFreed;	/* Indicates that this symbol is pending deletion */
77
 void *entry;               /* A pointer to the actual entry data */
78
 volatile struct hashEntry *next;	/* Hash table collision chain pointer */
79
 struct hashEntry *free;
80
} HashEntry;
81
82
/* RKD:  Added HashBucket to implement lockless hashtable */
83
typedef struct hashBucket
84
{
85
  volatile int  count;			  /* Use count for the chain */
86
  volatile HashEntry *activeQ;    /* First HashEntry in the active chain */
87
  volatile HashEntry *deleteQ;    /* First HashEntry in the delete chain */
88
}HashBucket;
89
90
/* The original depth of the local stack that mirrors the JVM stack */
91
#define ORIGINAL_STACK_SIZE  40	
92
93
/* Increment the local stack by this amount to avoid stack overflow */
94
#define STACK_INCREMENT_SIZE 20	
95
96
/* The size of the ThreadLocalStorage buffer for IO */
97
#define ORIGINAL_MESSAGE_BUFFER_SIZE 1024
98
99
/* For pre-aggregation: A stack frame to accumulate time-data along unique call chains */
100
typedef struct _StackFrame
101
{
102
	HashEntry *methodHashEntry;
103
104
	timestamp_t baseTime;
105
	timestamp_t baseCPUTime;
106
	timestamp_t minTime;
107
	timestamp_t maxTime;
108
109
	timestamp_t filteredMethodsBaseTime;
110
	timestamp_t filteredMethodsBaseCPUTime;
111
112
	struct _StackFrame * calledList;
113
	struct _StackFrame * next;
114
	struct _StackFrame * caller;
115
	unsigned int numCalls;
116
} StackFrame;
117
118
/* A single entry on the stack */
119
typedef struct
120
{
121
 SegmentedValue_t ticket;
122
 HashEntry *objectHashEntry;
123
 Uint64 cpuTime;
124
 timestamp_t timestamp;
125
 HashEntry *methodHashEntry;
126
 unsigned int currentBoundaryDepth;
127
 unsigned int printed:1;		/* Whether this entry was printed */
128
 unsigned int trigger:1;		/* Whether this entry was a trigger */
129
 unsigned int entryEventSeen:1;	/* Whether this stack frame is the begining of the trace */
130
 unsigned int realFrame:1;		/* pre-agg: a flag, true when this is a "real" frame, false when it represents a filtered-out function */
131
 struct ThreadPrivateStorage *tps;
132
 Uint64  cumulative_overhead;          /* the total tracing overhead of this invocation */
133
 Uint64  cumulative_cpu_overhead;	   /* the total tracing overhead of this invocation (cpu time) */ 
134
 StackFrame* stackFrame;		/* pre-agg: the frame in the unique call chain database for this active frame */
135
 timestamp_t baseTime;			/* pre-agg: time so far in this active frame */
136
 timestamp_t cumulativeTime;	/* pre-agg: time so far in this active frame plus its children */
137
 timestamp_t lastEntryTime;		/* pre-agg: the last time this frame was entered, e.g. when the last call to a child returned. */
138
 timestamp_t baseCPUTime;		/* pre-agg: CPU time so far in this active frame */
139
 timestamp_t lastEntryCPUTime;	/* pre-agg: the last CPU time this frame was entered, e.g. when the last call to a child returned. */
140
} StackEntry;
141
142
typedef int (*HashIteratorFunction)(HashEntry * hashEntry, void *parm);
143
144
typedef struct hashtable
145
{
146
#ifdef _DEBUG							/* Various hashtable metrics for debugging */
147
 unsigned long findSymbolCount;
148
 unsigned long findSymbolFound;
149
 unsigned long findSymbolNotFound;
150
 unsigned long hashHitCount;
151
 unsigned long hashMissCount;
152
 unsigned long hashMissLength;
153
 unsigned long createCount;
154
 unsigned long deleteCount;
155
 unsigned long moveCount;
156
#endif
157
 unsigned long size;
158
 unsigned long entryCount;
159
 enum EntryType type;
160
 HashBucket *entries;
161
 int (*compare)(void *, void *);		/* compares two hash keys in a hash entry; return 0 iff keys are equal */ 
162
 unsigned long (*hash)(void *);			/* hash a key  */ 
163
 void (*assign)(void *,void*);           /* assign the value of the second key to the first */ 
164
} Hashtable;
165
166
167
typedef  struct ThreadPrivateStorage
168
{
169
 unsigned int threadStartEventSeen : 1;		/* Whether this thread recieved a THREAD_START or was synthetically created  - 170752 - long not supported on 390 */
170
 unsigned int threadStackKnown : 1;			/* Whether the stack has been materialized previously */
171
 unsigned int scrubbingHeap:1;			
172
 unsigned int disableEventsForThisThread:1; /* Disables events for this thread */
173
 unsigned int mode:1;						/* Determines the behaviour of the event handlers. (i.e. A handler may behave differently depending on the mode of this thread) */
174
 jobjectID threadId;						/* The thread ID */
175
 unsigned long staticThreadId;				/* The thread static ID */
176
 unsigned long currentStackSize;			/* The size of the stack memory segment */
177
 unsigned long tos;							/* The current depth of the stack */
178
 unsigned int boundaryDepth;				/* The current boundary depth for this thread */
179
 SegmentedValue_t ticket;					/* The ticket counter for this thread */
180
 char *buffer;								/* The storage buffer pointer */
181
#ifdef __OS400__
182
 char *buffer2;							    /* buffer for etoa scratch space on as400 */ 
183
#endif
184
 char *threadName;							/* The name of the thread */
185
 char *groupName;							/* The name of the thread group */
186
 char *parentName;							/* The nmae of the parent thread */
187
 JNIEnv *env;
188
 StackEntry *stackEntry;
189
 SegmentedValue_t collation;
190
 jobjectID monitorObj;						/* used when performing monitor dumps */ 
191
 unsigned long ownerThread;					/* used when performing monitor dumps */ 
192
 void *agent_extension_slot;				/* a void* usable by an agent extension */
193
 StackFrame* calledList;					/* pre-aggregation: the list of top-level frames called from this thread */
194
 timestamp_t last_cpu_timestamp;			/* pre-aggregation: the CPU time of the most recent event on this thread */
195
} ThreadPrivateStorage;
196
197
198
typedef struct {
199
    char *field_name;                   /* name of field */
200
    char *field_signature;	            /* signature of field */
201
	unsigned long fieldId;
202
} PI_Field;
203
204
205
typedef struct classEntry
206
{
207
 unsigned int traceFlag:1;	    /* Indicates whether this entry has passed the filter tests */
208
 unsigned int arrayClass:1;     /* Indicates whether this class represents a primitive array */
209
 jobjectID classId;				/* The class ID */
210
 unsigned long static_id;		/* an id that does not change wrt class unloads */
211
 jint numInterfaces;			/* Number of interfaces this class implements */
212
 jint numMethods;				/* Number of methods this class contains */
213
 jint numStaticFields;			/* The number of static fields in this class */
214
 jint numInstanceFields;		/* The number of fields that each instance has */
215
 HashEntry *classObject;		/* Pointer to the object which is the class object for this class */
216
 HashEntry *superClassEntry;	/* Ptr to superclass class hash tbl entry, if any */
217
 char * className;				/* The class name */
218
 char * sourceName;				/* The source file name */
219
 char *classLoaderName;			/* The name of the class loader */
220
 char *superClassName;			/* The name of the super class */
221
 char *nameOfInterfaces;		/* The name of interfaces implemented (separated by a comma). */
222
 PI_Field *statics;				/* Array of statics */
223
 PI_Field *instances;			/* Array of instances */
224
 JVMPI_Method *methods;			/* Array of methods */
225
 timestamp_t timestamp;         /* capture the time of the class_load event */
226
 SegmentedValue_t collation;    /* capture the collation value of the class_load event */
227
} ClassEntry;
228
229
230
typedef struct methodEntry
231
{
232
 unsigned int traceFlag:1;		/* Indicates whether this method is being traced (TraceModeStartFilter) */
233
 unsigned int trigger:1;		/* Indicates whether this method is a trigger (TraceModeStartTrigger) */
234
 unsigned int detailsComplete:1;/* Indicates if the following fields are filled */
235
 unsigned int isNative:1;
236
 unsigned int isAbstract:1;
237
 unsigned int isStatic:1;
238
 unsigned int isSynchronized:1;
239
 unsigned int isPublic:1;
240
 unsigned int isPrivate:1;
241
 unsigned int isProtected:1;
242
 unsigned long static_id;		/* The un-changing id for this method */
243
 unsigned long methodCount;		/* A counter for coverage purposes */
244
 HashEntry * classHashEntry;	/* A pointer back to the hashtable entry for the containing class */
245
 char *exceptions; 
246
 JVMPI_Method methodData;		/* A copy of the JVMPI method data structure */
247
 SegmentedValue_t collation;    /* capture the collation value of the event */
248
} MethodEntry;
249
250
251
typedef struct objectEntry
252
{
253
 unsigned int traceFlag:1;	    /* Indicates whether this object is being traced */
254
 unsigned int foundInHeap:1;	/* Indicates whether this object was found in the heap while scrubbing */
255
 unsigned int notFoundInHeap:4; /* Indicates number of times object was not found in heap */
256
 unsigned int classObject:1;	/* Is this object a class object? */
257
 unsigned int allocationSeen:1; /* Was the allocation event seen for this object */
258
 unsigned int heapDumpIndex:8;	/* The heap dump where this object was first seen at (256 posibilities)*/
259
 unsigned int is_array:1;		/* JVMPI_NORMAL_OBJECT, ... (up to 16 posibilities) */
260
 unsigned int unusedBits:15;    /* UNUSED BITS */
261
 HashEntry *classHashEntry;		/* The class definition for this object */
262
 HashEntry *classHashEntry2;	/* The class definition for which this is a class object (only if classObject==1) */
263
 jsize size;					/* size in number of bytes */ /* fix 89008: change from jint */
264
 unsigned long static_id;		/* an id that does not change wrt garbage collection */
265
 SegmentedValue_t collation;    /* capture the collation value of the OBJ_ALLOC event */
266
} ObjectEntry;
267
268
269
/** INITIALIZE_SYMBOL_TABLE  ***************************************************
270
  * Setup the hashtables.  Since the buckets are statically declared, they will
271
  * already be null-ed.
272
  */
273
void jvmpiAgent_InitializeSymbolTable();
274
275
void jvmpiAgent_SetTracingFlagsOnPrimitives();
276
 
277
278
/** FIND_SYMBOL  **************************************************************
279
  * Find an entry in the symbol table based upon its Id.
280
  * @param       id  - the id provided by the JVMPI_Event
281
  * @param entryType - the type to look up be it Class/Method/Object/Thread
282
  * @returns         - the address of a HashEntry struct containing the result
283
  *                    of the lookup
284
  */
285
HashEntry * jvmpiAgent_FindObjectSymbolFast(jobjectID id);
286
HashEntry * jvmpiAgent_FindObjectSymbol(jobjectID id);
287
HashEntry * jvmpiAgent_FindThreadSymbol(JNIEnv * id);
288
HashEntry * jvmpiAgent_FindClassSymbol(jobjectID id);
289
HashEntry * jvmpiAgent_FindMethodSymbol(jmethodID id);
290
291
/* Bug Number 73480 */
292
#ifdef __OS400__
293
void insertClassOptSymbol(HashEntry *hashEntry) ;
294
#endif
295
296
/** FindObjectSymbolWithAllocateAndPrint
297
 *
298
 * Look up object in the VM if it doesn't exist in the hash table and make sure it is printed 
299
 * to the trace. 
300
 *
301
 * args - 
302
 *	env_id - thread which to associate with the object allocation (if it has yet to be printed)
303
 *  object_id - the object we are looking for 
304
 * 
305
 * returns - 
306
 *	the hash entry corresponding to the given object 
307
 */ 
308
HashEntry*
309
jvmpiAgent_FindObjectSymbolWithAllocateAndPrint(JNIEnv *env_id, jobjectID object_id);
310
311
/** FIND_OBJECT_SYMBOL_WITH_ALLOCATE  **************************************
312
  * Find a symbol in Object hashtable and create an entry if it does not exist.
313
  */
314
HashEntry * jvmpiAgent_FindObjectSymbolWithAllocate(jobjectID id,
315
													JNIEnv *env_id);
316
317
/** DELETE_SYMBOL  **************************************************************
318
  * Remove an entry in the symbol table and free the memory associated with the
319
  * entry.
320
  * @param   hashEntry - the entry in the table to delete.
321
  */
322
void jvmpiAgent_DeleteSymbol(HashEntry *hashEntry,
323
							 enum EntryType type);
324
325
/** MOVE_SYMBOL  ****************************************************************
326
  * Change the id of an element in the symbol table.
327
  * @param  hashEntry - the current entry in the table.
328
  * @param      id    - the current symbol id 
329
  * @param      newId - the new symbol Id.
330
  */
331
void jvmpiAgent_MoveSymbol(HashEntry *hashEntry,
332
						   enum EntryType type,
333
						   void *id, void* newId);
334
335
/** CREATE_THREAD_SYMBOL  *****************************************************
336
  *
337
  */
338
HashEntry * jvmpiAgent_CreateThreadSymbol(JNIEnv* id);
339
340
/** CREATE_CLASS_SYMBOL  ******************************************************
341
  *
342
  */
343
HashEntry * jvmpiAgent_CreateClassSymbol(JVMPI_Event *event, ThreadLocalStorage *tps, Filter *filterInfo);
344
345
/** CREATE_OBJECT_SYMBOL  *****************************************************
346
  *
347
  */
348
HashEntry * jvmpiAgent_CreateObjectSymbol(JVMPI_Event *event,
349
                                          BOOL allocatedOnTracedStackframe,
350
                                          BOOL allocationEventSeen);
351
352
void jvmpiAgent_clearAllPrintFlags();
353
354
void jvmpiAgent_resetTraceFlags();
355
356
void jvmpiAgent_analyseHeap(JVMPI_Event *event, char* heapDefName);
357
358
/* unsigned long jvmpiAgent_analyseMonitorDump(JVMPI_Event *event, jobjectID monitorObj)
359
360
  Determines the owner thread of the monitor represented
361
  by monitorObj by analysing the monitor dump.
362
363
  args -
364
	event - the monitor dump event as reported by JVMPI
365
	monitorObj - the monitor for which we wish to determine the owner thread 
366
367
  returns
368
	the id of the thread that owns the given monitor 
369
*/
370
371
unsigned long jvmpiAgent_analyseMonitorDump(JVMPI_Event *event, jobjectID monitorObj);
372
373
void jvmpiAgent_markHeap(JVMPI_Event *event);
374
375
HashEntry *jvmpiAgent_getPrimativeClassEntry(jint arrayType);
376
377
378
void jvmpiAgent_ForAll(enum EntryType type,  HashIteratorFunction fn, void *parm);
379
380
/** CREATE_STACK  *************************************************************
381
  *
382
  */
383
HashEntry * jvmpiAgent_CreateStack(JNIEnv * env_id);
384
385
/** DESTROY_STACK  ************************************************************
386
  *
387
  */
388
void jvmpiAgent_DestroyStack(JNIEnv *env_id);
389
390
/** PUSH  *********************************************************************
391
  */
392
StackEntry * jvmpiAgent_Push(ThreadPrivateStorage *tps,
393
							 JNIEnv *env_id,
394
							 HashEntry *methodHashEntry,
395
							 HashEntry *objectHashEntry,
396
			     timestamp_t timestamp, 
397
				 timestamp_t cpu_timestamp);
398
399
/** POP  **********************************************************************
400
  *
401
  */
402
void jvmpiAgent_Pop(ThreadPrivateStorage *tps);
403
404
/** PEEK  *********************************************************************
405
  *
406
  */
407
StackEntry * jvmpiAgent_Peek(ThreadPrivateStorage *tps,
408
							 int offset);
409
410
411
/* Pre-Aggregation: Create a stack frame */
412
void jvmpiAgent_CreateStackFrame(ThreadPrivateStorage * tps, 
413
								 HashEntry *methodHashEntry, 
414
								 StackEntry* caller);
415
416
/* Pre-Aggregation: Adjust a filtered-out method's stack frame to the parent */
417
void jvmpiAgent_AdjustStackFrame(ThreadPrivateStorage * tps);
418
419
/* Pre-Aggregation: Roll up a stack entry's data into its frame and its caller */
420
void jvmpiAgent_agPop(StackEntry* entry);
421
422
unsigned long jvmpiAgent_TOS(ThreadPrivateStorage *tps);
423
424
unsigned long jvmpiAgent_StackDepth(ThreadPrivateStorage *tps);
425
426
/** createPrimitiveTypes() 
427
  * 
428
  * Used to generate the primitive types in the hashtable. 
429
  */ 
430
void createPrimitiveTypes(); 
431
432
#ifdef _DEBUG
433
 unsigned int jvmpiAgent_getHashTableEntryCount(enum EntryType entryType);
434
 void jvmpiAgent_DumpHashTableStatistics();
435
#endif
436
437
#ifdef __cplusplus
438
 }
439
#endif
440
441
#endif
(-)src-native-new/src/agents/native/java_profiler/resource.h (+22 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: resource.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
/* Next default values for new objects */
14
15
#ifdef APSTUDIO_INVOKED
16
#ifndef APSTUDIO_READONLY_SYMBOLS
17
#define _APS_NEXT_RESOURCE_VALUE        101
18
#define _APS_NEXT_COMMAND_VALUE         40001
19
#define _APS_NEXT_CONTROL_VALUE         1000
20
#define _APS_NEXT_SYMED_VALUE           101
21
#endif
22
#endif
(-)src-native-new/src/agents/native/WinBuild/java_profiler.mak64 (+842 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on java_profiler.dsp
2
!IF "$(CFG)" == ""
3
CFG=java_profiler - IA64 Debug
4
!MESSAGE No configuration specified. Defaulting to java_profiler - IA64 Debug.
5
!ENDIF 
6
7
!IF "$(CFG)" != "java_profiler - IA64 Release" && "$(CFG)" != "java_profiler - IA64 Debug" && "$(CFG)" != "java_profiler - X64 Release" && "$(CFG)" != "java_profiler - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "java_profiler.mak64" CFG="java_profiler - IA64 Debug"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "java_profiler - IA64 Release"
17
!MESSAGE "java_profiler - IA64 Debug"
18
!MESSAGE "java_profiler - X64 Release"
19
!MESSAGE "java_profiler - X64 Debug"
20
!MESSAGE 
21
!ERROR An invalid configuration is specified.
22
!ENDIF 
23
24
!IF "$(OS)" == "Windows_NT"
25
NULL=
26
!ELSE 
27
NULL=nul
28
!ENDIF 
29
30
CPP=cl.exe
31
MTL=midl.exe
32
RSC=rc.exe
33
34
!IF  "$(CFG)" == "java_profiler - IA64 Release"
35
36
OUTDIR=..\..\..\..\bin
37
INTDIR=.\Release
38
# Begin Custom Macros
39
OutDir=..\..\..\..\bin
40
# End Custom Macros
41
42
!IF "$(RECURSE)" == "0" 
43
44
ALL : "$(OUTDIR)\piAgent.dll"
45
46
!ELSE 
47
48
ALL : "heapsnapshots - IA64 Release" "$(OUTDIR)\piAgent.dll"
49
50
!ENDIF 
51
52
!IF "$(RECURSE)" == "1" 
53
CLEAN :"heapsnapshots - IA64 ReleaseCLEAN" 
54
!ELSE 
55
CLEAN :
56
!ENDIF 
57
	-@erase "$(INTDIR)\agentDebug.obj"
58
	-@erase "$(INTDIR)\filters.obj"
59
	-@erase "$(INTDIR)\hash.obj"
60
	-@erase "$(INTDIR)\JvmpiWriter.obj"
61
	-@erase "$(INTDIR)\options.obj"
62
	-@erase "$(INTDIR)\performance.obj"
63
	-@erase "$(INTDIR)\piagent.res"
64
	-@erase "$(INTDIR)\print.obj"
65
	-@erase "$(INTDIR)\segmentedValue.obj"
66
	-@erase "$(INTDIR)\stack.obj"
67
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager_C.obj"
68
	-@erase "$(INTDIR)\utility.obj"
69
	-@erase "$(INTDIR)\vc60.idb"
70
	-@erase "$(OUTDIR)\piAgent.dll"
71
	-@erase "$(OUTDIR)\..\lib\piAgent.exp"
72
	-@erase "$(OUTDIR)\..\lib\piAgent.lib"
73
	-@erase ".\Release\piAgent.map"
74
75
"$(OUTDIR)" :
76
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
77
78
"$(INTDIR)" :
79
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
80
81
CPP_PROJ=/nologo /MT /W3 /O2 /Ob2 /I "$(JAVA_HOME)\include" /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /I "..\..\..\transport\RASocket" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JAVA_PROFILER_EXPORTS" /D "_INTEL" /Fp"$(INTDIR)\java_profiler.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
82
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
83
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\piagent.res" /d "NDEBUG" 
84
85
LINK32=link.exe
86
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib ws2_32.lib bufferoverflowU.lib /nologo /version:0.1 /dll /pdb:none /map:"$(INTDIR)\piAgent.map" /out:"$(OUTDIR)\piAgent.dll" /implib:"$(OUTDIR)\..\lib\piAgent.lib" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
87
LINK32_OBJS= \
88
	"$(INTDIR)\agentDebug.obj" \
89
	"$(INTDIR)\filters.obj" \
90
	"$(INTDIR)\hash.obj" \
91
	"$(INTDIR)\JvmpiWriter.obj" \
92
	"$(INTDIR)\options.obj" \
93
	"$(INTDIR)\performance.obj" \
94
	"$(INTDIR)\print.obj" \
95
	"$(INTDIR)\segmentedValue.obj" \
96
	"$(INTDIR)\stack.obj" \
97
	"$(INTDIR)\StatelessHeapSnapshotManager_C.obj" \
98
	"$(INTDIR)\utility.obj" \
99
	"$(INTDIR)\piagent.res" \
100
	"$(OUTDIR)\..\lib\hcclco.lib" \
101
	"$(OUTDIR)\..\lib\hccldt.lib" \
102
	"$(OUTDIR)\..\lib\hccls.lib" \
103
	"$(OUTDIR)\..\lib\hcbnd.lib" \
104
	"$(OUTDIR)\..\lib\hcclsm.lib" \
105
	"$(OUTDIR)\..\lib\heapsnapshots.lib"
106
107
"$(OUTDIR)\piAgent.dll" : "$(OUTDIR)" $(LINK32_OBJS)
108
    $(LINK32) @<<
109
  $(LINK32_FLAGS) $(LINK32_OBJS)
110
<<
111
112
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
113
114
OUTDIR=..\..\..\..\bin
115
INTDIR=.\Debug
116
# Begin Custom Macros
117
OutDir=..\..\..\..\bin
118
# End Custom Macros
119
120
!IF "$(RECURSE)" == "0" 
121
122
ALL : "$(OUTDIR)\piAgent.dll"
123
124
!ELSE 
125
126
ALL : "heapsnapshots - IA64 Debug" "$(OUTDIR)\piAgent.dll"
127
128
!ENDIF 
129
130
!IF "$(RECURSE)" == "1" 
131
CLEAN :"heapsnapshots - IA64 DebugCLEAN" 
132
!ELSE 
133
CLEAN :
134
!ENDIF 
135
	-@erase "$(INTDIR)\agentDebug.obj"
136
	-@erase "$(INTDIR)\agentDebug.sbr"
137
	-@erase "$(INTDIR)\filters.obj"
138
	-@erase "$(INTDIR)\filters.sbr"
139
	-@erase "$(INTDIR)\hash.obj"
140
	-@erase "$(INTDIR)\hash.sbr"
141
	-@erase "$(INTDIR)\JvmpiWriter.obj"
142
	-@erase "$(INTDIR)\JvmpiWriter.sbr"
143
	-@erase "$(INTDIR)\options.obj"
144
	-@erase "$(INTDIR)\options.sbr"
145
	-@erase "$(INTDIR)\performance.obj"
146
	-@erase "$(INTDIR)\performance.sbr"
147
	-@erase "$(INTDIR)\piagent.res"
148
	-@erase "$(INTDIR)\print.obj"
149
	-@erase "$(INTDIR)\print.sbr"
150
	-@erase "$(INTDIR)\segmentedValue.obj"
151
	-@erase "$(INTDIR)\segmentedValue.sbr"
152
	-@erase "$(INTDIR)\stack.obj"
153
	-@erase "$(INTDIR)\stack.sbr"
154
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager_C.obj"
155
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager_C.sbr"
156
	-@erase "$(INTDIR)\utility.obj"
157
	-@erase "$(INTDIR)\utility.sbr"
158
	-@erase "$(INTDIR)\vc60.idb"
159
	-@erase "$(INTDIR)\vc60.pdb"
160
	-@erase "$(OUTDIR)\piAgent.dll"
161
	-@erase "$(OUTDIR)\..\lib\piAgent.exp"
162
	-@erase "$(OUTDIR)\..\lib\piAgent.ilk"
163
	-@erase "$(OUTDIR)\..\lib\piAgent.lib"
164
	-@erase "$(OUTDIR)\..\lib\piAgent.pdb"
165
166
"$(OUTDIR)" :
167
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
168
169
"$(INTDIR)" :
170
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
171
172
CPP_PROJ=/nologo /MTd /W3 /Gm /Zi /Od /I "$(JAVA_HOME)\include" /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /I "..\..\..\transport\RASocket" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JAVA_PROFILER_EXPORTS" /D "_INTEL" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\java_profiler.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
173
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
174
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\piagent.res" /d "_DEBUG" 
175
176
LINK32=link.exe
177
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib ws2_32.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\piAgent.pdb" /debug /out:"$(OUTDIR)\piAgent.dll" /implib:"$(OUTDIR)\..\lib\piAgent.lib" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
178
LINK32_OBJS= \
179
	"$(INTDIR)\agentDebug.obj" \
180
	"$(INTDIR)\filters.obj" \
181
	"$(INTDIR)\hash.obj" \
182
	"$(INTDIR)\JvmpiWriter.obj" \
183
	"$(INTDIR)\options.obj" \
184
	"$(INTDIR)\performance.obj" \
185
	"$(INTDIR)\print.obj" \
186
	"$(INTDIR)\segmentedValue.obj" \
187
	"$(INTDIR)\stack.obj" \
188
	"$(INTDIR)\StatelessHeapSnapshotManager_C.obj" \
189
	"$(INTDIR)\utility.obj" \
190
	"$(INTDIR)\piagent.res" \
191
	"$(OUTDIR)\..\lib\hcclco.lib" \
192
	"$(OUTDIR)\..\lib\hccldt.lib" \
193
	"$(OUTDIR)\..\lib\hccls.lib" \
194
	"$(OUTDIR)\..\lib\hcbnd.lib" \
195
	"$(OUTDIR)\..\lib\hcclsm.lib" \
196
	"$(OUTDIR)\..\lib\heapsnapshots.lib"
197
198
"$(OUTDIR)\piAgent.dll" : "$(OUTDIR)" $(LINK32_OBJS)
199
    $(LINK32) @<<
200
  $(LINK32_FLAGS) $(LINK32_OBJS)
201
<<
202
203
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
204
205
OUTDIR=..\..\..\..\bin
206
INTDIR=.\Release
207
# Begin Custom Macros
208
OutDir=..\..\..\..\bin
209
# End Custom Macros
210
211
!IF "$(RECURSE)" == "0" 
212
213
ALL : "$(OUTDIR)\piAgent.dll"
214
215
!ELSE 
216
217
ALL : "heapsnapshots - X64 Release" "$(OUTDIR)\piAgent.dll"
218
219
!ENDIF 
220
221
!IF "$(RECURSE)" == "1" 
222
CLEAN :"heapsnapshots - X64 ReleaseCLEAN" 
223
!ELSE 
224
CLEAN :
225
!ENDIF 
226
	-@erase "$(INTDIR)\agentDebug.obj"
227
	-@erase "$(INTDIR)\filters.obj"
228
	-@erase "$(INTDIR)\hash.obj"
229
	-@erase "$(INTDIR)\JvmpiWriter.obj"
230
	-@erase "$(INTDIR)\options.obj"
231
	-@erase "$(INTDIR)\performance.obj"
232
	-@erase "$(INTDIR)\piagent.res"
233
	-@erase "$(INTDIR)\print.obj"
234
	-@erase "$(INTDIR)\segmentedValue.obj"
235
	-@erase "$(INTDIR)\stack.obj"
236
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager_C.obj"
237
	-@erase "$(INTDIR)\utility.obj"
238
	-@erase "$(INTDIR)\vc60.idb"
239
	-@erase "$(OUTDIR)\piAgent.dll"
240
	-@erase "$(OUTDIR)\..\lib\piAgent.exp"
241
	-@erase "$(OUTDIR)\..\lib\piAgent.lib"
242
	-@erase ".\Release\piAgent.map"
243
244
"$(OUTDIR)" :
245
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
246
247
"$(INTDIR)" :
248
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
249
250
CPP_PROJ=/nologo /MT /W3 /O2 /Ob2 /I "$(JAVA_HOME)\include" /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /I "..\..\..\transport\RASocket" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JAVA_PROFILER_EXPORTS" /D "_INTEL" /Fp"$(INTDIR)\java_profiler.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
251
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
252
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\piagent.res" /d "NDEBUG" 
253
254
LINK32=link.exe
255
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib ws2_32.lib bufferoverflowU.lib /nologo /version:0.1 /dll /pdb:none /map:"$(INTDIR)\piAgent.map" /out:"$(OUTDIR)\piAgent.dll" /implib:"$(OUTDIR)\..\lib\piAgent.lib" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
256
LINK32_OBJS= \
257
	"$(INTDIR)\agentDebug.obj" \
258
	"$(INTDIR)\filters.obj" \
259
	"$(INTDIR)\hash.obj" \
260
	"$(INTDIR)\JvmpiWriter.obj" \
261
	"$(INTDIR)\options.obj" \
262
	"$(INTDIR)\performance.obj" \
263
	"$(INTDIR)\print.obj" \
264
	"$(INTDIR)\segmentedValue.obj" \
265
	"$(INTDIR)\stack.obj" \
266
	"$(INTDIR)\StatelessHeapSnapshotManager_C.obj" \
267
	"$(INTDIR)\utility.obj" \
268
	"$(INTDIR)\piagent.res" \
269
	"$(OUTDIR)\..\lib\hcclco.lib" \
270
	"$(OUTDIR)\..\lib\hccldt.lib" \
271
	"$(OUTDIR)\..\lib\hccls.lib" \
272
	"$(OUTDIR)\..\lib\hcbnd.lib" \
273
	"$(OUTDIR)\..\lib\hcclsm.lib" \
274
	"$(OUTDIR)\..\lib\heapsnapshots.lib"
275
276
"$(OUTDIR)\piAgent.dll" : "$(OUTDIR)" $(LINK32_OBJS)
277
    $(LINK32) @<<
278
  $(LINK32_FLAGS) $(LINK32_OBJS)
279
<<
280
281
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
282
283
OUTDIR=..\..\..\..\bin
284
INTDIR=.\Debug
285
# Begin Custom Macros
286
OutDir=..\..\..\..\bin
287
# End Custom Macros
288
289
!IF "$(RECURSE)" == "0" 
290
291
ALL : "$(OUTDIR)\piAgent.dll"
292
293
!ELSE 
294
295
ALL : "heapsnapshots - X64 Debug" "$(OUTDIR)\piAgent.dll"
296
297
!ENDIF 
298
299
!IF "$(RECURSE)" == "1" 
300
CLEAN :"heapsnapshots - X64 DebugCLEAN" 
301
!ELSE 
302
CLEAN :
303
!ENDIF 
304
	-@erase "$(INTDIR)\agentDebug.obj"
305
	-@erase "$(INTDIR)\agentDebug.sbr"
306
	-@erase "$(INTDIR)\filters.obj"
307
	-@erase "$(INTDIR)\filters.sbr"
308
	-@erase "$(INTDIR)\hash.obj"
309
	-@erase "$(INTDIR)\hash.sbr"
310
	-@erase "$(INTDIR)\JvmpiWriter.obj"
311
	-@erase "$(INTDIR)\JvmpiWriter.sbr"
312
	-@erase "$(INTDIR)\options.obj"
313
	-@erase "$(INTDIR)\options.sbr"
314
	-@erase "$(INTDIR)\performance.obj"
315
	-@erase "$(INTDIR)\performance.sbr"
316
	-@erase "$(INTDIR)\piagent.res"
317
	-@erase "$(INTDIR)\print.obj"
318
	-@erase "$(INTDIR)\print.sbr"
319
	-@erase "$(INTDIR)\segmentedValue.obj"
320
	-@erase "$(INTDIR)\segmentedValue.sbr"
321
	-@erase "$(INTDIR)\stack.obj"
322
	-@erase "$(INTDIR)\stack.sbr"
323
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager_C.obj"
324
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager_C.sbr"
325
	-@erase "$(INTDIR)\utility.obj"
326
	-@erase "$(INTDIR)\utility.sbr"
327
	-@erase "$(INTDIR)\vc60.idb"
328
	-@erase "$(INTDIR)\vc60.pdb"
329
	-@erase "$(OUTDIR)\piAgent.dll"
330
	-@erase "$(OUTDIR)\..\lib\piAgent.exp"
331
	-@erase "$(OUTDIR)\..\lib\piAgent.ilk"
332
	-@erase "$(OUTDIR)\..\lib\piAgent.lib"
333
	-@erase "$(OUTDIR)\..\lib\piAgent.pdb"
334
335
"$(OUTDIR)" :
336
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
337
338
"$(INTDIR)" :
339
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
340
341
CPP_PROJ=/nologo /MTd /W3 /Gm /Zi /Od /I "$(JAVA_HOME)\include" /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /I "..\..\..\transport\RASocket" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JAVA_PROFILER_EXPORTS" /D "_INTEL" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\java_profiler.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
342
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
343
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\piagent.res" /d "_DEBUG" 
344
345
LINK32=link.exe
346
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib ws2_32.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\piAgent.pdb" /debug /out:"$(OUTDIR)\piAgent.dll" /implib:"$(OUTDIR)\..\lib\piAgent.lib" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
347
LINK32_OBJS= \
348
	"$(INTDIR)\agentDebug.obj" \
349
	"$(INTDIR)\filters.obj" \
350
	"$(INTDIR)\hash.obj" \
351
	"$(INTDIR)\JvmpiWriter.obj" \
352
	"$(INTDIR)\options.obj" \
353
	"$(INTDIR)\performance.obj" \
354
	"$(INTDIR)\print.obj" \
355
	"$(INTDIR)\segmentedValue.obj" \
356
	"$(INTDIR)\stack.obj" \
357
	"$(INTDIR)\StatelessHeapSnapshotManager_C.obj" \
358
	"$(INTDIR)\utility.obj" \
359
	"$(INTDIR)\piagent.res" \
360
	"$(OUTDIR)\..\lib\hcclco.lib" \
361
	"$(OUTDIR)\..\lib\hccldt.lib" \
362
	"$(OUTDIR)\..\lib\hccls.lib" \
363
	"$(OUTDIR)\..\lib\hcbnd.lib" \
364
	"$(OUTDIR)\..\lib\hcclsm.lib" \
365
	"$(OUTDIR)\..\lib\heapsnapshots.lib"
366
367
"$(OUTDIR)\piAgent.dll" : "$(OUTDIR)" $(LINK32_OBJS)
368
    $(LINK32) @<<
369
  $(LINK32_FLAGS) $(LINK32_OBJS)
370
<<
371
372
!ENDIF 
373
374
.c{$(INTDIR)}.obj::
375
   $(CPP) @<<
376
   $(CPP_PROJ) $< 
377
<<
378
379
.cpp{$(INTDIR)}.obj::
380
   $(CPP) @<<
381
   $(CPP_PROJ) $< 
382
<<
383
384
.cxx{$(INTDIR)}.obj::
385
   $(CPP) @<<
386
   $(CPP_PROJ) $< 
387
<<
388
389
.c{$(INTDIR)}.sbr::
390
   $(CPP) @<<
391
   $(CPP_PROJ) $< 
392
<<
393
394
.cpp{$(INTDIR)}.sbr::
395
   $(CPP) @<<
396
   $(CPP_PROJ) $< 
397
<<
398
399
.cxx{$(INTDIR)}.sbr::
400
   $(CPP) @<<
401
   $(CPP_PROJ) $< 
402
<<
403
404
405
!IF "$(CFG)" == "java_profiler - IA64 Release" || "$(CFG)" == "java_profiler - IA64 Debug" || "$(CFG)" == "java_profiler - X64 Release" || "$(CFG)" == "java_profiler - X64 Debug"
406
SOURCE=..\java_profiler\agentDebug.c
407
408
!IF  "$(CFG)" == "java_profiler - IA64 Release"
409
410
411
"$(INTDIR)\agentDebug.obj" : $(SOURCE) "$(INTDIR)"
412
	$(CPP) $(CPP_PROJ) $(SOURCE)
413
414
415
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
416
417
418
"$(INTDIR)\agentDebug.obj"	"$(INTDIR)\agentDebug.sbr" : $(SOURCE) "$(INTDIR)"
419
	$(CPP) $(CPP_PROJ) $(SOURCE)
420
421
422
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
423
424
425
"$(INTDIR)\agentDebug.obj" : $(SOURCE) "$(INTDIR)"
426
	$(CPP) $(CPP_PROJ) $(SOURCE)
427
428
429
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
430
431
432
"$(INTDIR)\agentDebug.obj"	"$(INTDIR)\agentDebug.sbr" : $(SOURCE) "$(INTDIR)"
433
	$(CPP) $(CPP_PROJ) $(SOURCE)
434
435
436
!ENDIF 
437
438
SOURCE=..\java_profiler\filters.c
439
440
!IF  "$(CFG)" == "java_profiler - IA64 Release"
441
442
443
"$(INTDIR)\filters.obj" : $(SOURCE) "$(INTDIR)"
444
	$(CPP) $(CPP_PROJ) $(SOURCE)
445
446
447
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
448
449
450
"$(INTDIR)\filters.obj"	"$(INTDIR)\filters.sbr" : $(SOURCE) "$(INTDIR)"
451
	$(CPP) $(CPP_PROJ) $(SOURCE)
452
453
454
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
455
456
457
"$(INTDIR)\filters.obj" : $(SOURCE) "$(INTDIR)"
458
	$(CPP) $(CPP_PROJ) $(SOURCE)
459
460
461
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
462
463
464
"$(INTDIR)\filters.obj"	"$(INTDIR)\filters.sbr" : $(SOURCE) "$(INTDIR)"
465
	$(CPP) $(CPP_PROJ) $(SOURCE)
466
467
468
!ENDIF 
469
470
SOURCE=..\java_profiler\hash.c
471
472
!IF  "$(CFG)" == "java_profiler - IA64 Release"
473
474
475
"$(INTDIR)\hash.obj" : $(SOURCE) "$(INTDIR)"
476
	$(CPP) $(CPP_PROJ) $(SOURCE)
477
478
479
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
480
481
482
"$(INTDIR)\hash.obj"	"$(INTDIR)\hash.sbr" : $(SOURCE) "$(INTDIR)"
483
	$(CPP) $(CPP_PROJ) $(SOURCE)
484
485
486
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
487
488
489
"$(INTDIR)\hash.obj" : $(SOURCE) "$(INTDIR)"
490
	$(CPP) $(CPP_PROJ) $(SOURCE)
491
492
493
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
494
495
496
"$(INTDIR)\hash.obj"	"$(INTDIR)\hash.sbr" : $(SOURCE) "$(INTDIR)"
497
	$(CPP) $(CPP_PROJ) $(SOURCE)
498
499
500
!ENDIF 
501
502
SOURCE=..\java_profiler\JvmpiWriter.c
503
504
!IF  "$(CFG)" == "java_profiler - IA64 Release"
505
506
507
"$(INTDIR)\JvmpiWriter.obj" : $(SOURCE) "$(INTDIR)"
508
	$(CPP) $(CPP_PROJ) $(SOURCE)
509
510
511
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
512
513
514
"$(INTDIR)\JvmpiWriter.obj"	"$(INTDIR)\JvmpiWriter.sbr" : $(SOURCE) "$(INTDIR)"
515
	$(CPP) $(CPP_PROJ) $(SOURCE)
516
517
518
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
519
520
521
"$(INTDIR)\JvmpiWriter.obj" : $(SOURCE) "$(INTDIR)"
522
	$(CPP) $(CPP_PROJ) $(SOURCE)
523
524
525
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
526
527
528
"$(INTDIR)\JvmpiWriter.obj"	"$(INTDIR)\JvmpiWriter.sbr" : $(SOURCE) "$(INTDIR)"
529
	$(CPP) $(CPP_PROJ) $(SOURCE)
530
531
532
!ENDIF 
533
534
SOURCE=..\java_profiler\options.c
535
536
!IF  "$(CFG)" == "java_profiler - IA64 Release"
537
538
539
"$(INTDIR)\options.obj" : $(SOURCE) "$(INTDIR)"
540
	$(CPP) $(CPP_PROJ) $(SOURCE)
541
542
543
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
544
545
546
"$(INTDIR)\options.obj"	"$(INTDIR)\options.sbr" : $(SOURCE) "$(INTDIR)"
547
	$(CPP) $(CPP_PROJ) $(SOURCE)
548
549
550
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
551
552
553
"$(INTDIR)\options.obj" : $(SOURCE) "$(INTDIR)"
554
	$(CPP) $(CPP_PROJ) $(SOURCE)
555
556
557
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
558
559
560
"$(INTDIR)\options.obj"	"$(INTDIR)\options.sbr" : $(SOURCE) "$(INTDIR)"
561
	$(CPP) $(CPP_PROJ) $(SOURCE)
562
563
564
!ENDIF 
565
566
SOURCE=..\java_profiler\performance.c
567
568
!IF  "$(CFG)" == "java_profiler - IA64 Release"
569
570
571
"$(INTDIR)\performance.obj" : $(SOURCE) "$(INTDIR)"
572
	$(CPP) $(CPP_PROJ) $(SOURCE)
573
574
575
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
576
577
578
"$(INTDIR)\performance.obj"	"$(INTDIR)\performance.sbr" : $(SOURCE) "$(INTDIR)"
579
	$(CPP) $(CPP_PROJ) $(SOURCE)
580
581
582
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
583
584
585
"$(INTDIR)\performance.obj" : $(SOURCE) "$(INTDIR)"
586
	$(CPP) $(CPP_PROJ) $(SOURCE)
587
588
589
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
590
591
592
"$(INTDIR)\performance.obj"	"$(INTDIR)\performance.sbr" : $(SOURCE) "$(INTDIR)"
593
	$(CPP) $(CPP_PROJ) $(SOURCE)
594
595
596
!ENDIF 
597
598
SOURCE=..\java_profiler\print.c
599
600
!IF  "$(CFG)" == "java_profiler - IA64 Release"
601
602
603
"$(INTDIR)\print.obj" : $(SOURCE) "$(INTDIR)"
604
	$(CPP) $(CPP_PROJ) $(SOURCE)
605
606
607
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
608
609
610
"$(INTDIR)\print.obj"	"$(INTDIR)\print.sbr" : $(SOURCE) "$(INTDIR)"
611
	$(CPP) $(CPP_PROJ) $(SOURCE)
612
613
614
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
615
616
617
"$(INTDIR)\print.obj" : $(SOURCE) "$(INTDIR)"
618
	$(CPP) $(CPP_PROJ) $(SOURCE)
619
620
621
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
622
623
624
"$(INTDIR)\print.obj"	"$(INTDIR)\print.sbr" : $(SOURCE) "$(INTDIR)"
625
	$(CPP) $(CPP_PROJ) $(SOURCE)
626
627
628
!ENDIF 
629
630
SOURCE=..\java_profiler\segmentedValue.c
631
632
!IF  "$(CFG)" == "java_profiler - IA64 Release"
633
634
635
"$(INTDIR)\segmentedValue.obj" : $(SOURCE) "$(INTDIR)"
636
	$(CPP) $(CPP_PROJ) $(SOURCE)
637
638
639
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
640
641
642
"$(INTDIR)\segmentedValue.obj"	"$(INTDIR)\segmentedValue.sbr" : $(SOURCE) "$(INTDIR)"
643
	$(CPP) $(CPP_PROJ) $(SOURCE)
644
645
646
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
647
648
649
"$(INTDIR)\segmentedValue.obj" : $(SOURCE) "$(INTDIR)"
650
	$(CPP) $(CPP_PROJ) $(SOURCE)
651
652
653
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
654
655
656
"$(INTDIR)\segmentedValue.obj"	"$(INTDIR)\segmentedValue.sbr" : $(SOURCE) "$(INTDIR)"
657
	$(CPP) $(CPP_PROJ) $(SOURCE)
658
659
660
!ENDIF 
661
662
SOURCE=..\java_profiler\stack.c
663
664
!IF  "$(CFG)" == "java_profiler - IA64 Release"
665
666
667
"$(INTDIR)\stack.obj" : $(SOURCE) "$(INTDIR)"
668
	$(CPP) $(CPP_PROJ) $(SOURCE)
669
670
671
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
672
673
674
"$(INTDIR)\stack.obj"	"$(INTDIR)\stack.sbr" : $(SOURCE) "$(INTDIR)"
675
	$(CPP) $(CPP_PROJ) $(SOURCE)
676
677
678
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
679
680
681
"$(INTDIR)\stack.obj" : $(SOURCE) "$(INTDIR)"
682
	$(CPP) $(CPP_PROJ) $(SOURCE)
683
684
685
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
686
687
688
"$(INTDIR)\stack.obj"	"$(INTDIR)\stack.sbr" : $(SOURCE) "$(INTDIR)"
689
	$(CPP) $(CPP_PROJ) $(SOURCE)
690
691
692
!ENDIF 
693
694
SOURCE=..\java_profiler\StatelessHeapSnapshotManager_C.cpp
695
696
!IF  "$(CFG)" == "java_profiler - IA64 Release"
697
698
699
"$(INTDIR)\StatelessHeapSnapshotManager_C.obj" : $(SOURCE) "$(INTDIR)"
700
	$(CPP) $(CPP_PROJ) $(SOURCE)
701
702
703
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
704
705
706
"$(INTDIR)\StatelessHeapSnapshotManager_C.obj"	"$(INTDIR)\StatelessHeapSnapshotManager_C.sbr" : $(SOURCE) "$(INTDIR)"
707
	$(CPP) $(CPP_PROJ) $(SOURCE)
708
709
710
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
711
712
713
"$(INTDIR)\StatelessHeapSnapshotManager_C.obj" : $(SOURCE) "$(INTDIR)"
714
	$(CPP) $(CPP_PROJ) $(SOURCE)
715
716
717
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
718
719
720
"$(INTDIR)\StatelessHeapSnapshotManager_C.obj"	"$(INTDIR)\StatelessHeapSnapshotManager_C.sbr" : $(SOURCE) "$(INTDIR)"
721
	$(CPP) $(CPP_PROJ) $(SOURCE)
722
723
724
!ENDIF 
725
726
SOURCE=..\java_profiler\utility.c
727
728
!IF  "$(CFG)" == "java_profiler - IA64 Release"
729
730
731
"$(INTDIR)\utility.obj" : $(SOURCE) "$(INTDIR)"
732
	$(CPP) $(CPP_PROJ) $(SOURCE)
733
734
735
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
736
737
738
"$(INTDIR)\utility.obj"	"$(INTDIR)\utility.sbr" : $(SOURCE) "$(INTDIR)"
739
	$(CPP) $(CPP_PROJ) $(SOURCE)
740
741
742
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
743
744
745
"$(INTDIR)\utility.obj" : $(SOURCE) "$(INTDIR)"
746
	$(CPP) $(CPP_PROJ) $(SOURCE)
747
748
749
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
750
751
752
"$(INTDIR)\utility.obj"	"$(INTDIR)\utility.sbr" : $(SOURCE) "$(INTDIR)"
753
	$(CPP) $(CPP_PROJ) $(SOURCE)
754
755
756
!ENDIF 
757
758
SOURCE=..\java_profiler\version.rc
759
760
!IF  "$(CFG)" == "java_profiler - IA64 Release"
761
762
763
"$(INTDIR)\piagent.res" : $(SOURCE) "$(INTDIR)"
764
	$(RSC) /l 0x409 /fo"$(INTDIR)\piagent.res" /i "..\java_profiler" /d "NDEBUG" $(SOURCE)
765
766
767
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
768
769
770
"$(INTDIR)\piagent.res" : $(SOURCE) "$(INTDIR)"
771
	$(RSC) /l 0x409 /fo"$(INTDIR)\piagent.res" /i "..\java_profiler" /d "_DEBUG" $(SOURCE)
772
773
774
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
775
776
777
"$(INTDIR)\piagent.res" : $(SOURCE) "$(INTDIR)"
778
	$(RSC) /l 0x409 /fo"$(INTDIR)\piagent.res" /i "..\java_profiler" /d "NDEBUG" $(SOURCE)
779
780
781
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
782
783
784
"$(INTDIR)\piagent.res" : $(SOURCE) "$(INTDIR)"
785
	$(RSC) /l 0x409 /fo"$(INTDIR)\piagent.res" /i "..\java_profiler" /d "_DEBUG" $(SOURCE)
786
787
788
!ENDIF 
789
790
!IF  "$(CFG)" == "java_profiler - IA64 Release"
791
792
"heapsnapshots - IA64 Release" : 
793
   cd "."
794
   $(MAKE) /$(MAKEFLAGS) /F .\heapsnapshots.mak64 CFG="heapsnapshots - IA64 Release" 
795
   cd "."
796
797
"heapsnapshots - IA64 ReleaseCLEAN" : 
798
   cd "."
799
   $(MAKE) /$(MAKEFLAGS) /F .\heapsnapshots.mak64 CFG="heapsnapshots - IA64 Release" RECURSE=1 CLEAN 
800
   cd "."
801
802
!ELSEIF  "$(CFG)" == "java_profiler - IA64 Debug"
803
804
"heapsnapshots - IA64 Debug" : 
805
   cd "."
806
   $(MAKE) /$(MAKEFLAGS) /F .\heapsnapshots.mak64 CFG="heapsnapshots - IA64 Debug" 
807
   cd "."
808
809
"heapsnapshots - IA64 DebugCLEAN" : 
810
   cd "."
811
   $(MAKE) /$(MAKEFLAGS) /F .\heapsnapshots.mak64 CFG="heapsnapshots - IA64 Debug" RECURSE=1 CLEAN 
812
   cd "."
813
814
!ELSEIF  "$(CFG)" == "java_profiler - X64 Release"
815
816
"heapsnapshots - X64 Release" : 
817
   cd "."
818
   $(MAKE) /$(MAKEFLAGS) /F .\heapsnapshots.mak64 CFG="heapsnapshots - X64 Release" 
819
   cd "."
820
821
"heapsnapshots - X64 ReleaseCLEAN" : 
822
   cd "."
823
   $(MAKE) /$(MAKEFLAGS) /F .\heapsnapshots.mak64 CFG="heapsnapshots - X64 Release" RECURSE=1 CLEAN 
824
   cd "."
825
826
!ELSEIF  "$(CFG)" == "java_profiler - X64 Debug"
827
828
"heapsnapshots - X64 Debug" : 
829
   cd "."
830
   $(MAKE) /$(MAKEFLAGS) /F .\heapsnapshots.mak64 CFG="heapsnapshots - X64 Debug" 
831
   cd "."
832
833
"heapsnapshots - X64 DebugCLEAN" : 
834
   cd "."
835
   $(MAKE) /$(MAKEFLAGS) /F .\heapsnapshots.mak64 CFG="heapsnapshots - X64 Debug" RECURSE=1 CLEAN 
836
   cd "."
837
838
!ENDIF 
839
840
841
!ENDIF 
842
(-)src-native-new/src/agents/perfmon/sysperf/resource.h (+20 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: resource.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifdef APSTUDIO_INVOKED
14
#ifndef APSTUDIO_READONLY_SYMBOLS
15
#define _APS_NEXT_RESOURCE_VALUE        101
16
#define _APS_NEXT_COMMAND_VALUE         40001
17
#define _APS_NEXT_CONTROL_VALUE         1000
18
#define _APS_NEXT_SYMED_VALUE           101
19
#endif
20
#endif
(-)src-native-new/src/agents/native/java_profiler/hash.c (+3017 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: hash.c,v 1.6 2006/05/16 18:50:16 samwai Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include <stdlib.h>
14
#include <string.h>
15
#include <assert.h>
16
#ifdef __OS400__
17
  /* no malloc.h needed */
18
#elif MVS
19
  /* no malloc.h needed */
20
#else
21
  #include <malloc.h>
22
#endif
23
#include "hash.h"
24
#include "RADataTransfer.h"
25
#include "RAComm.h"
26
#include "JvmpiWriter.h"
27
#include "print.h"
28
#include "options.h"
29
#include "utility.h"
30
31
#if defined(__OS400__) || defined(__powerpc64__) || defined(_WIN64) /*ts. bug 120479*/
32
static ra_critsec_t _lock; /* 232010 */
33
#endif
34
35
/* The Hashtables for each of the types */
36
static Hashtable _classHashtable;
37
static Hashtable _methodHashtable;
38
static Hashtable _objectHashtable;
39
static Hashtable _threadHashtable;
40
41
/* The Hashtable entries */
42
static HashBucket _classEntries[CLASS_HASH_TABLE_SIZE];
43
static HashBucket _methodEntries[METHOD_HASH_TABLE_SIZE];
44
static HashBucket _objectEntries[OBJECT_HASH_TABLE_SIZE];
45
static HashBucket _threadEntries[THREAD_HASH_TABLE_SIZE];
46
47
/* The classhashEntries for each of the primatives */
48
static HashEntry *_booleanClass;
49
static HashEntry *_byteClass;
50
static HashEntry *_charClass;
51
static HashEntry *_shortClass;
52
static HashEntry *_intClass;
53
static HashEntry *_longClass;
54
static HashEntry *_floatClass;
55
static HashEntry *_doubleClass;
56
57
58
static unsigned long _staticIdCount = 1;
59
static unsigned long _fieldIdCount = 0;
60
extern GenerationInfo_t _heapDumpInfo;
61
62
#define DUMP_READ(buf, current, size) memcpy(buf, *current, size); *current+= size
63
64
#define SIZEOF_U1 1
65
#define SIZEOF_U2 2
66
#define SIZEOF_U4 4
67
68
/* The following variables are constantly used when class/method detail option is set.  Therefore their values are cached. */
69
static jclass javaClass, methodClass, modifierClass;
70
static jmethodID forNameID, getDeclaredMethodID, getModifiersID, isPublicID, isProtectedID, isPrivateID;
71
static jmethodID isStaticID, isNativeID, isSynchronizedID, isAbstractID, getExceptionTypesID, getNameID;
72
static jmethodID getClassLoaderID, getClassID, getSuperclassID, getInterfacesID;
73
74
static int isCachedVarsSet = 0;
75
unsigned const int MAX_EXCEPTION_LENGTH = 250, MAX_PARAM = 40, MAX_PARAM_NAME = 200;
76
char *exceptionNames, *parameters, *tmpStorage, **param;
77
78
int _requestClassObj = 0; /* used to flag when a object_alloc is being performed on a class object */ 
79
80
81
jobjectArray findParamType(JVMPI_Event *event, char *methodSignature, int *exceptionOccurred);
82
void swapDelimiters (char *name);
83
84
85
86
/** HASH_FUNCTION  *************************************************************
87
  * Find the bucket this id will belong in.
88
  */
89
static _inline unsigned long hash_function(Hashtable *table, jint id)
90
{
91
 return (unsigned long)id % table->size;
92
}
93
94
static _inline unsigned long object_hash_function(void *id)
95
{
96
  return ((unsigned long)((ObjectHashKey*) id)->id) % OBJECT_HASH_TABLE_SIZE;
97
}
98
static _inline unsigned long class_hash_function(void *id)
99
{
100
  return ((unsigned long)((ClassHashKey*) id)->id) % CLASS_HASH_TABLE_SIZE;
101
}
102
static _inline unsigned long method_hash_function(void *id)
103
{
104
  return ((unsigned long)((MethodHashKey*) id)->id) % METHOD_HASH_TABLE_SIZE;
105
}
106
static _inline unsigned long thread_hash_function(void *id)
107
{
108
  return ((unsigned long)((ThreadHashKey *) id)->id) % THREAD_HASH_TABLE_SIZE;
109
}
110
111
int objectKeyCompare(void *id1, void *id2) {
112
	ObjectHashKey *k1; 
113
	ObjectHashKey *k2; 
114
	k1 = (ObjectHashKey *) id1; 
115
	k2 = (ObjectHashKey *) id2; 
116
	return !(k1->id == k2->id); /* return 0 iff keys equal */ 
117
}
118
119
int classKeyCompare(void *id1, void *id2) {
120
	return objectKeyCompare(id1,id2); /* class keys are just object keys */ 
121
}
122
123
int methodKeyCompare(void *id1, void *id2) {
124
	MethodHashKey *k1; 
125
	MethodHashKey *k2; 
126
	k1 = (MethodHashKey *) id1; 
127
	k2 = (MethodHashKey *) id2; 
128
	return !(k1->id == k2->id); /* return 0 iff keys equal */ 
129
}
130
131
int threadKeyCompare(void *id1, void *id2) {
132
	ThreadHashKey *k1; 
133
	ThreadHashKey *k2; 
134
	k1 = (ThreadHashKey *) id1; 
135
	k2 = (ThreadHashKey *) id2; 
136
	return !(k1->id == k2->id); /* return 0 iff keys equal */ 
137
}
138
139
void threadKeyAssign(void *id1, void *id2) {
140
	((ThreadHashKey *)id1)->id = ((ThreadHashKey *)id2)->id; 
141
}
142
143
void objectKeyAssign(void *id1, void *id2) {
144
	((ObjectHashKey *)id1)->id = ((ObjectHashKey *)id2)->id; 
145
}
146
147
void classKeyAssign(void *id1, void *id2) {
148
	((ClassHashKey *)id1)->id = ((ClassHashKey *)id2)->id; 
149
}
150
151
void methodKeyAssign(void *id1, void *id2) {
152
	((MethodHashKey *)id1)->id = ((MethodHashKey *)id2)->id; 
153
}
154
155
/** CREATE_SYMBOL  *************************************************************
156
  *
157
  */
158
static HashEntry * jvmpiAgent_CreateSymbol(void *id)
159
{
160
 /* Create a new hash entry and then insert it into the hash table */
161
 HashEntry * hashEntry = (HashEntry *)jvmpiAgent_Calloc(sizeof(HashEntry));
162
 hashEntry->id=id;
163
 hashEntry->printed=0;
164
 hashEntry->deleted= 0;
165
 hashEntry->toBeFreed=0;
166
 hashEntry->next=NULL;
167
 return hashEntry;
168
}
169
170
171
/** FREE_SYMBOL  ***************************************************************
172
  *
173
  */
174
void freeSymbol(HashEntry *hashEntry, enum EntryType entryType)
175
{
176
 /* Free up all the fields */
177
 switch(entryType)
178
 {
179
  int i;
180
  case Class_t:
181
	
182
	  if(CLASS_ENTRY(hashEntry)->className) free(CLASS_ENTRY(hashEntry)->className);
183
	  if(CLASS_ENTRY(hashEntry)->sourceName) free(CLASS_ENTRY(hashEntry)->sourceName);
184
	  if(CLASS_ENTRY(hashEntry)->methods) free(CLASS_ENTRY(hashEntry)->methods);
185
	  /* Free PR */
186
	  if (CLASS_ENTRY(hashEntry)->statics)
187
	  {
188
		/*clean up static array */
189
		for (i=0; i<CLASS_ENTRY(hashEntry)->numStaticFields; i++)
190
		{
191
         if (CLASS_ENTRY(hashEntry)->statics[i].field_name)
192
         {
193
            free(CLASS_ENTRY(hashEntry)->statics[i].field_name);
194
            CLASS_ENTRY(hashEntry)->statics[i].field_name = NULL;
195
         }
196
         if (CLASS_ENTRY(hashEntry)->statics[i].field_signature)
197
         {
198
            free(CLASS_ENTRY(hashEntry)->statics[i].field_signature);
199
            CLASS_ENTRY(hashEntry)->statics[i].field_signature = NULL;
200
         }
201
		}
202
		free(CLASS_ENTRY(hashEntry)->statics);
203
		CLASS_ENTRY(hashEntry)->statics = NULL;
204
	 }
205
206
	 if (CLASS_ENTRY(hashEntry)->instances)
207
	 {
208
		 /* clean up instance array */
209
		for (i=0; i<CLASS_ENTRY(hashEntry)->numInstanceFields; i++)
210
		{
211
         if (CLASS_ENTRY(hashEntry)->instances[i].field_name)
212
         {
213
            free(CLASS_ENTRY(hashEntry)->instances[i].field_name);
214
           CLASS_ENTRY(hashEntry)->instances[i].field_name = NULL;
215
         }
216
         if (CLASS_ENTRY(hashEntry)->instances[i].field_signature)
217
         {
218
            free(CLASS_ENTRY(hashEntry)->instances[i].field_signature);
219
            CLASS_ENTRY(hashEntry)->instances[i].field_signature = NULL;
220
         }
221
		}
222
		free(CLASS_ENTRY(hashEntry)->instances);
223
		CLASS_ENTRY(hashEntry)->instances = NULL;
224
	}
225
	/*  free PR */
226
	 break;
227
  case Object_t:
228
	  /* 46046 RJD - object may be a class object, in which case we need to null
229
	     the classObject entry in the corresponding classHashEntry. */
230
	  if (OBJECT_ENTRY(hashEntry)->classObject == 1) {
231
		  if (OBJECT_ENTRY(hashEntry)->classHashEntry2 != NULL) {
232
			  CLASS_ENTRY(OBJECT_ENTRY(hashEntry)->classHashEntry2)->classObject = NULL;
233
		  }
234
	  }
235
	  break;
236
  case Method_t:
237
  case Thread_t:
238
  case Heap_t:
239
	break;
240
  default:
241
	return;
242
 }
243
 free(hashEntry->id); 
244
 free(hashEntry->entry);
245
 hashEntry->entry=NULL;
246
 free(hashEntry);
247
 hashEntry=NULL;
248
}
249
250
251
/** GET_BUCKET  ****************************************************************
252
  * Find the bucket in the table that this id belongs in.  Increment the use
253
  * count of this bucket by 1.
254
  */
255
HashBucket *getBucket(Hashtable *table, void* id, int* idx ) {
256
	HashBucket* bucket;
257
	int oldCnt;
258
	*idx=table->hash(id);
259
	bucket= &table->entries[*idx];
260
	oldCnt = bucket->count;
261
262
	while(!ra_atomicCAS((int*)&bucket->count, (int*)&oldCnt, (int)(oldCnt+1)));
263
	return bucket;
264
}
265
266
static _inline HashBucket *getObjectBucket(jobjectID id) {
267
  ObjectHashKey k;
268
  int idx; 
269
  k.id = id; 
270
  idx=_objectHashtable.hash((void *)&k); 
271
  return &_objectHashtable.entries[idx];
272
}
273
static _inline HashBucket *getMethodBucket(jmethodID id) {
274
  MethodHashKey k; 
275
  int idx; 
276
  k.id = id;
277
  idx=_methodHashtable.hash((void*)&k); 
278
  return &_methodHashtable.entries[idx];
279
}
280
static _inline HashBucket *getClassBucket(jobjectID id) {
281
  ClassHashKey k; 
282
  int idx; 
283
  k.id = id; 
284
  idx=_classHashtable.hash((void*)&k); 
285
  return &_classHashtable.entries[idx];
286
}
287
static _inline HashBucket *getThreadBucket(JNIEnv* id) {
288
  ThreadHashKey k; 
289
  int idx; 
290
  k.id = id; 
291
  idx=_threadHashtable.hash((void*)&k); 
292
  return &_threadHashtable.entries[idx];
293
}
294
295
HashBucket* getBucketAtIndex(Hashtable *table, int idx) {
296
	int oldCnt;
297
	HashBucket *bucket;
298
	bucket= &table->entries[idx];
299
	oldCnt = bucket->count;
300
	while(!ra_atomicCAS((int*)&bucket->count, (int*)&oldCnt, (int)(oldCnt+1)));
301
	return bucket;
302
}
303
304
305
/** RELEASE_BUCKET  ************************************************************
306
  * If the current count of this bucket is 1, walk the deleteQ chain and remove
307
  * the buckets.  Decrement the use count of this bucket by 1.
308
  */
309
void releaseBucket(Hashtable *table, HashBucket *bucket, int idx, BOOL freeMemory) {
310
	volatile HashEntry *scanQ = NULL;
311
	int newCnt, oldCnt = bucket->count;
312
	do {
313
		newCnt = oldCnt - 1;
314
		if ( newCnt == 0 ) {
315
			/* cut-off deleteQ:
316
			 * instantiate the deleteQ and make sure that activeQ anchor
317
			 * is not a part of the instantiated deleteQ.  Then deleteQ
318
			 * can be safely cut-off
319
			 */
320
			HashEntry *old_del_q = (HashEntry *)bucket->deleteQ;
321
			while ( old_del_q != NULL )  {
322
				/* make sure anchor pointer is not part of the logically
323
				 * deleted chain and it will point to valid element
324
				 */
325
				for ( scanQ = (HashEntry*)bucket->activeQ; ((scanQ != NULL) && scanQ->toBeFreed); scanQ = (HashEntry*)bucket->activeQ) {
326
					/* if csmac failed, somebody else added a new element
327
					 * Either element is valid or it modified deleteQ anchor
328
					 */
329
#if defined(__OS400__) || defined(__powerpc64__) || defined(_WIN64) /*ts. bug 120479*/
330
					ra_mutexEnter(&_lock);
331
					if (bucket->activeQ == scanQ) {
332
						bucket->activeQ = scanQ->next;
333
					} else {
334
						scanQ = bucket->activeQ; 
335
						ra_mutexExit(&_lock);
336
						break; 
337
					}
338
					ra_mutexExit(&_lock);
339
#else
340
					if ( !ra_atomicCAS( (int *)&bucket->activeQ, (int *)&scanQ, (int)scanQ->next) ) {
341
						break;
342
					}
343
#endif
344
				}
345
346
				/* todo: jy: may be we should save away the scanQ then
347
				 * assign to endq after for loop , then for loop
348
				 * can check for scanNext==endq.  initially endq can
349
				 * be NULL  :: performance issue
350
				 */
351
352
				/* traverse the activeQ from the element next to the scanQ
353
				 * until the end of the chain is reached, and cut-off the
354
				 * logically deleted elements from the active chain
355
				 */
356
				if (scanQ != NULL)	{
357
					volatile HashEntry *scanNext;
358
					for (scanNext = scanQ->next; scanNext != NULL; scanNext = scanQ->next) {
359
						if (scanNext->toBeFreed) {
360
							scanQ->next = scanNext->next;
361
						}
362
						else {
363
							scanQ = scanNext;
364
						}
365
					}
366
				}
367
368
				/* cut-off the delete chain */
369
#if defined(__OS400__) || defined(__powerpc64__) || defined(_WIN64) /*ts. bug 120479*/
370
				ra_mutexEnter(&_lock);
371
				if (bucket->deleteQ == old_del_q) {
372
                    bucket->deleteQ = 0; 
373
					ra_mutexExit(&_lock);
374
					break;
375
				} else {
376
					old_del_q = bucket->deleteQ; 
377
				}
378
				
379
				ra_mutexExit(&_lock);
380
#else
381
				if ( ra_atomicCAS((int*)&bucket->deleteQ, (int *)&old_del_q, 0) ) {
382
					break;
383
				}
384
#endif
385
			} /* end of cut-off delete chain */
386
387
			/* if deleteQ is cut-off successfully,
388
			 *  scanQ = safe element to start traversing
389
			 *    any elements previous to this element does not belong to cut-off delete chain
390
			 *    all elements on the cut-off chain is guaranteed not accessed by anybody
391
			 *  old_del_q = anchor of cut-off delete chain
392
			 */
393
394
			/* free the hash elements on the cut-off chain */
395
			while(old_del_q != NULL) {
396
				scanQ = old_del_q;
397
				old_del_q = scanQ->free;
398
				if(freeMemory) {
399
					freeSymbol((HashEntry*)scanQ, table->type);
400
				}
401
			} /* end of processing */
402
		} /* end of if ( newCnt == 0 ) */
403
404
	}while( !ra_atomicCAS((int*)&bucket->count, (int*)&oldCnt, (int)newCnt));
405
}
406
407
HashEntry *createPrimativeHashEntry(jint type) {
408
	ClassEntry *entry;
409
    Filter *tracing;
410
	ObjectHashKey *k; 
411
	HashEntry *hashEntry; 
412
413
	k = (ObjectHashKey *)jvmpiAgent_Calloc(sizeof(ObjectHashKey)); 
414
	k->id = (jobjectID)type; 
415
416
	/* Create a new hash entry and then insert it into the hash table */
417
	hashEntry = jvmpiAgent_CreateSymbol((void*)k);
418
419
	/* Allocate and copy the event data into the symbol table structure */
420
	hashEntry->entry  = (ClassEntry*)jvmpiAgent_Calloc(sizeof(ClassEntry));
421
	entry = CLASS_ENTRY(hashEntry);
422
423
	/* The class_id is zero  */
424
	entry->classId=0;
425
426
	/* We don't trace primative classes */
427
	entry->traceFlag = 0;
428
429
	/* This is an array class */
430
	entry->arrayClass = 0;
431
432
#ifdef __OS400__ /* 239987 starts */
433
#pragma convert(819)
434
#endif
435
	switch(type) { /* 235601 - change strdup to STRDUP */
436
        case JVMPI_BOOLEAN:	    STRDUP(entry->className, "boolean"); tracing=jvmpiAgent_getFilter("boolean", "");   break;
437
		case JVMPI_BYTE:		STRDUP(entry->className, "byte");    tracing=jvmpiAgent_getFilter("byte", "");      break;
438
		case JVMPI_CHAR:		STRDUP(entry->className, "char");    tracing=jvmpiAgent_getFilter("char", "");      break;
439
		case JVMPI_SHORT:		STRDUP(entry->className, "short");   tracing=jvmpiAgent_getFilter("short", "");     break;
440
		case JVMPI_INT:			STRDUP(entry->className, "int");     tracing=jvmpiAgent_getFilter("int", "");       break;
441
		case JVMPI_LONG:		STRDUP(entry->className, "long");    tracing=jvmpiAgent_getFilter("long", "");      break;
442
		case JVMPI_FLOAT:		STRDUP(entry->className, "float");   tracing=jvmpiAgent_getFilter("float", "");     break;
443
		case JVMPI_DOUBLE:	    STRDUP(entry->className, "double");  tracing=jvmpiAgent_getFilter("double", "");    break;
444
	}
445
#ifdef __OS400__
446
#pragma convert(0)
447
#endif /* 239987 ends */
448
	entry->static_id=_staticIdCount++;
449
450
	STRDUP(entry->sourceName, ""); /* 235601 */
451
	entry->numInterfaces=0;
452
	entry->numMethods=0;
453
	entry->numStaticFields=0;
454
	entry->superClassEntry=NULL;
455
456
	entry->classObject=NULL;
457
    entry->arrayClass=1;
458
459
	/* Set the class detail fields */
460
	entry->classLoaderName= "";
461
	entry->superClassName = "";
462
	entry->nameOfInterfaces = "";
463
464
    /* Indicate whether we are tracing this type */
465
    entry -> traceFlag = jvmpiAgent_getClassFilterMode(tracing);
466
467
	TIMESTAMP_ZERO(&entry->timestamp);
468
469
	/*##MW There is a race condition between the increment and the copy that must be fixed */
470
	jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
471
	jvmpiAgent_copySegmentedValue(&entry->collation, &_jvmpiAgent_collation);
472
	return hashEntry;
473
}
474
475
476
HashEntry *jvmpiAgent_getPrimativeClassEntry(jint arrayType) {
477
	switch(arrayType) {
478
		case JVMPI_BOOLEAN: return _booleanClass;
479
		case JVMPI_BYTE:	return _byteClass;
480
		case JVMPI_CHAR:	return _charClass;
481
		case JVMPI_SHORT:	return _shortClass;
482
		case JVMPI_INT:		return _intClass;
483
		case JVMPI_LONG:	return _longClass;
484
		case JVMPI_FLOAT:	return _floatClass;
485
		case JVMPI_DOUBLE: return _doubleClass;
486
	}
487
	return NULL;
488
}
489
490
/** INITIALIZE_SYMBOL_TABLE  ***************************************************
491
  * Setup the hashtables.  Since the buckets are statically declared, they will
492
  * already be null-ed.
493
  */
494
void jvmpiAgent_InitializeSymbolTable()
495
{
496
#if defined(__OS400__) || defined(__powerpc64__) || defined(_WIN64) /*ts. bug 120479*/
497
 ra_mutexCreate(&_lock); /* 232010 */
498
#endif
499
500
 _classHashtable.size=CLASS_HASH_TABLE_SIZE;
501
 _classHashtable.entries = _classEntries;
502
 _classHashtable.entryCount=0;
503
 _classHashtable.type=Class_t;
504
 _classHashtable.hash = class_hash_function; 
505
 _classHashtable.compare = classKeyCompare; 
506
 _classHashtable.assign = classKeyAssign; 
507
 _methodHashtable.size=METHOD_HASH_TABLE_SIZE;
508
 _methodHashtable.entries = _methodEntries;
509
 _methodHashtable.entryCount=0;
510
 _methodHashtable.type=Method_t;
511
 _methodHashtable.hash = method_hash_function; 
512
 _methodHashtable.compare = methodKeyCompare; 
513
 _methodHashtable.assign = methodKeyAssign; 
514
 _objectHashtable.size=OBJECT_HASH_TABLE_SIZE;
515
 _objectHashtable.entries = _objectEntries;
516
 _objectHashtable.entryCount=0;
517
 _objectHashtable.type=Object_t;
518
 _objectHashtable.hash = object_hash_function; 
519
 _objectHashtable.compare = objectKeyCompare; 
520
 _objectHashtable.assign = objectKeyAssign; 
521
 _threadHashtable.size=THREAD_HASH_TABLE_SIZE;
522
 _threadHashtable.entries = _threadEntries;
523
 _threadHashtable.entryCount=0;
524
 _threadHashtable.type=Thread_t;
525
 _threadHashtable.hash = thread_hash_function; 
526
 _threadHashtable.compare = threadKeyCompare; 
527
 _threadHashtable.assign = threadKeyAssign; 
528
529
 createPrimitiveTypes(); 
530
}
531
532
533
void createPrimitiveTypes() {
534
535
 /* Create the primative types as classes */
536
 _booleanClass=createPrimativeHashEntry(JVMPI_BOOLEAN);
537
 _byteClass=createPrimativeHashEntry(JVMPI_BYTE);
538
 _charClass=createPrimativeHashEntry(JVMPI_CHAR);
539
 _shortClass=createPrimativeHashEntry(JVMPI_SHORT);
540
 _intClass=createPrimativeHashEntry(JVMPI_INT);
541
 _longClass=createPrimativeHashEntry(JVMPI_LONG);
542
 _floatClass=createPrimativeHashEntry(JVMPI_FLOAT);
543
 _doubleClass=createPrimativeHashEntry(JVMPI_DOUBLE);
544
545
}
546
547
548
/** SET_TRACING_FLAGS_ON_PRIMITIVES  ***************************************************
549
  * After the filter process, set the tracing flags on the primitive class entries
550
  *
551
  * Prerequisite: Must be invoked after the primitive arrays are created
552
  */
553
void jvmpiAgent_SetTracingFlagsOnPrimitives() {
554
#ifdef __OS400__
555
#pragma convert(819) 
556
#endif
557
558
	Filter *tracing = 0;
559
	tracing = jvmpiAgent_getFilter("boolean", "");  CLASS_ENTRY(_booleanClass)->traceFlag=jvmpiAgent_getClassFilterMode(tracing);
560
	tracing = jvmpiAgent_getFilter("byte", "");     CLASS_ENTRY(_byteClass)->traceFlag=jvmpiAgent_getClassFilterMode(tracing);
561
	tracing = jvmpiAgent_getFilter("char", "");     CLASS_ENTRY(_charClass)->traceFlag=jvmpiAgent_getClassFilterMode(tracing);
562
	tracing = jvmpiAgent_getFilter("short", "");    CLASS_ENTRY(_shortClass)->traceFlag=jvmpiAgent_getClassFilterMode(tracing);
563
	tracing = jvmpiAgent_getFilter("int", "");      CLASS_ENTRY(_intClass)->traceFlag=jvmpiAgent_getClassFilterMode(tracing);
564
	tracing = jvmpiAgent_getFilter("long", "");     CLASS_ENTRY(_longClass)->traceFlag=jvmpiAgent_getClassFilterMode(tracing);
565
	tracing = jvmpiAgent_getFilter("float", "");    CLASS_ENTRY(_floatClass)->traceFlag=jvmpiAgent_getClassFilterMode(tracing);
566
	tracing = jvmpiAgent_getFilter("double", "");   CLASS_ENTRY(_doubleClass)->traceFlag=jvmpiAgent_getClassFilterMode(tracing);
567
#ifdef __OS400__
568
#pragma convert(0) 
569
#endif
570
571
}
572
573
574
/** INSERT_SYMBOL  ************************************************************
575
  *
576
  */
577
static HashEntry * insertSymbol(Hashtable *table,
578
								HashEntry * hashEntry) {
579
	int index;
580
	HashBucket *bucket=getBucket(table, hashEntry->id, &index);
581
582
	/* Add the cell to the start of the chain */
583
	HashEntry *oldEntry = (HashEntry *)bucket->activeQ;
584
	hashEntry->next = oldEntry;
585
#if defined(__OS400__) || defined(__powerpc64__) || defined(_WIN64) /*ts. bug 120479*/
586
	ra_mutexEnter(&_lock);
587
	bucket->activeQ = hashEntry; /* 232010 */
588
	ra_mutexExit(&_lock);
589
#else
590
	while (!ra_atomicCAS( (int *)&bucket->activeQ, (int *)&oldEntry, (int)hashEntry)) {
591
		hashEntry->next = oldEntry;
592
	}
593
#endif
594
595
	table->entryCount++;
596
#ifdef _DEBUG
597
	table->createCount++;
598
#endif
599
	releaseBucket(table, bucket, index, TRUE);
600
	return hashEntry;
601
}
602
603
604
/** REMOVE_SYMBOL  **************************************************************
605
  * Do the actual work of setting hash pointers when a deletion is taking place.
606
  * @param   hashEntry - the entry in the table to delete.
607
  */
608
static void removeSymbol(Hashtable *table, HashEntry *hashEntry, BOOL freeMemory) {
609
	int index;
610
	HashBucket *bucket=getBucket(table, hashEntry->id, &index);
611
	int oldStatus = 0;
612
	
613
	if(ra_atomicCAS((int *)&(hashEntry->toBeFreed), (int *)&oldStatus, 1)) {
614
		/* Add the cell to the delete chain */
615
		HashEntry* oldEntry = (HashEntry*)bucket->deleteQ;
616
617
		hashEntry->free = oldEntry;
618
#if defined(__OS400__) || defined(__powerpc64__) || defined(_WIN64) /*ts. bug 120479*/
619
		ra_mutexEnter(&_lock);
620
		bucket->deleteQ = hashEntry; /* 232010 */
621
		ra_mutexExit(&_lock);
622
#else
623
		while(!ra_atomicCAS((int*)&bucket->deleteQ, (int*)&oldEntry, (int)hashEntry))  {
624
			hashEntry->free = oldEntry;
625
		}
626
#endif
627
	}
628
#ifdef _DEBUG
629
	table->deleteCount++;
630
#endif
631
	table->entryCount--;
632
	releaseBucket(table, bucket, index, freeMemory);
633
}
634
635
636
static int resetPrintedFlag(HashEntry *hashEntry, void * parm)
637
{
638
 hashEntry->printed = 0;
639
 return 0;
640
}
641
642
643
/** RESET_CLASS_TRACE_FLAG  ****************************************************
644
  *
645
  */
646
static int resetClassTraceFlag(HashEntry *hashEntry, void * parm)  {
647
	int i;
648
	Filter *filterInfo;
649
	ClassEntry *classEntry=CLASS_ENTRY(hashEntry);
650
651
	filterInfo=jvmpiAgent_getFilter(classEntry->className, "");
652
    classEntry -> traceFlag = jvmpiAgent_getClassFilterMode(filterInfo);
653
654
655
	/* Iterate through the methods and set the filter as well. */
656
	for(i=0; i<classEntry->numMethods; i++) {
657
		MethodEntry *methodEntry=METHOD_ENTRY(((HashEntry**)(classEntry->methods))[i]);
658
659
		filterInfo=jvmpiAgent_getFilter(classEntry->className, methodEntry->methodData.method_name);
660
		methodEntry->traceFlag=jvmpiAgent_checkMethodFilters(methodEntry->methodData.method_name, filterInfo);
661
		methodEntry->trigger=jvmpiAgent_checkTrigger(classEntry->className, methodEntry->methodData.method_name);
662
	}
663
	return 0;
664
}
665
666
667
/** RESET_OBJECT_TRACE_FLAG  ***************************************************
668
  *
669
  */
670
static int resetObjectTraceFlag(HashEntry *hashEntry, void * parm)  {
671
	ObjectEntry *objectEntry=OBJECT_ENTRY(hashEntry);
672
673
	if(objectEntry->classHashEntry) {
674
		objectEntry->traceFlag=CLASS_ENTRY(objectEntry->classHashEntry)->traceFlag;
675
	}
676
	return 0;
677
}
678
679
680
/** CREATE_METHOD_SYMBOL  ******************************************************
681
  * Allocates an entry in the symbol table for the method and sets the entry data
682
  * to point to the owning class.
683
  */
684
static HashEntry * jvmpiAgent_CreateMethodSymbol(JVMPI_Method *method, HashEntry *classHashEntry)  {
685
	HashEntry *methodHashEntry;
686
	MethodEntry *methodEntry;
687
	MethodHashKey *k; 
688
	k = (MethodHashKey *)jvmpiAgent_Calloc(sizeof(MethodHashKey)); 
689
	k->id=method->method_id; 
690
	methodHashEntry = jvmpiAgent_CreateSymbol((void *)k);
691
692
	/* Allocate and copy the event data into the symbol table structure */
693
	methodHashEntry->entry = (MethodEntry*)(jvmpiAgent_Calloc(sizeof(MethodEntry)));
694
	methodEntry = METHOD_ENTRY(methodHashEntry);
695
	methodEntry->classHashEntry = classHashEntry;  /* Set a pointer back to the containing class */
696
	methodEntry->methodCount = 0;
697
	methodEntry->static_id = ++_staticIdCount;
698
699
	/* Is this method a trigger */
700
	methodEntry->trigger=jvmpiAgent_checkTrigger(CLASS_ENTRY(classHashEntry)->className, method->method_name);
701
702
	/*##MW There is a race condition between the increment and the copy that must be fixed */
703
	jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
704
	jvmpiAgent_copySegmentedValue(&methodEntry->collation, &_jvmpiAgent_collation);
705
706
	{
707
		JVMPI_Method * methodData    = &methodEntry->methodData;
708
		STRDUP(methodData->method_name, method->method_name); /* 235601 */
709
		STRDUP(methodData->method_signature, method->method_signature); /* 235601 */
710
		methodData->start_lineno     = method->start_lineno;
711
		methodData->end_lineno       = method->end_lineno;
712
		methodData->method_id        = method->method_id;
713
	}
714
715
	/* Is this method being traced? */
716
	methodEntry->traceFlag=jvmpiAgent_checkMethodFilters(method->method_name, jvmpiAgent_getFilter(CLASS_ENTRY(classHashEntry)->className, method->method_name));
717
	insertSymbol(&_methodHashtable, methodHashEntry);
718
	return methodHashEntry;
719
}
720
721
722
723
724
725
/** CLEAR_ALL_REFERENCES  ******************************************************
726
  * Walk all the hashtables and set the printed bit to 0.
727
*/
728
void jvmpiAgent_clearAllPrintFlags()  {
729
	jvmpiAgent_ForAll(Class_t, resetPrintedFlag, 0);
730
	jvmpiAgent_ForAll(Object_t, resetPrintedFlag, 0);
731
	jvmpiAgent_ForAll(Method_t, resetPrintedFlag, 0);
732
	jvmpiAgent_ForAll(Thread_t, resetPrintedFlag, 0);
733
}
734
735
736
/** RESET_TRACE_FLAGS  *********************************************************
737
  *  Walks through the hashtables and sets the traceFlag on each of the elements.
738
  */
739
void jvmpiAgent_resetTraceFlags() {
740
	/* RKD:  First we walk the class hashtable as this will set the traceflags for
741
	         the classes and the methods within the classes based upon the filter
742
			 criteria.  Next we walk the object hashtable and set the object trace
743
			 flag based upon the class traceflag.
744
	*/
745
	jvmpiAgent_ForAll(Class_t, resetClassTraceFlag, 0);
746
	jvmpiAgent_ForAll(Object_t, resetObjectTraceFlag, 0);
747
}
748
749
void jvmpiAgent_ForAll(enum EntryType entryType, HashIteratorFunction fn, void *parm) {
750
	unsigned int i;
751
	Hashtable *table;
752
	switch(entryType)  {
753
	case Class_t:  table=&_classHashtable; break;
754
	case Method_t: table=&_methodHashtable; break;
755
	case Object_t: table=&_objectHashtable; break;
756
	case Thread_t: table=&_threadHashtable; break;
757
	default: return;
758
	}
759
760
	/* Iterate through the table */
761
	for (i = 0; i < table->size; i++) {
762
		volatile HashEntry *p, *next;
763
		HashBucket *bucket;
764
765
		/* grab the current bucket */
766
		bucket=getBucketAtIndex(table, i);
767
768
		/* Walk through the collision chain */
769
		for (p = bucket->activeQ; p != NULL; p = next) {
770
			next=p->next;
771
			if (fn((HashEntry*)p,parm))  {
772
				return; /* Quit if the user function returns true */
773
			}
774
		}
775
		/* release the bucket */
776
		releaseBucket(table, bucket, i, TRUE);
777
	}
778
}
779
780
/** FindObjectSymbolWithAllocateAndPrint
781
 *
782
 * Look up object in the VM if it doesn't exist in the hash table and make sure it is printed
783
 * to the trace.
784
 *
785
 * args -
786
 *	env_id - thread which to associate with the object allocation (if it has yet to be printed)
787
 *  object_id - the object we are looking for
788
 *
789
 * returns -
790
 *	the hash entry corresponding to the given object
791
 */
792
793
HashEntry*
794
jvmpiAgent_FindObjectSymbolWithAllocateAndPrint(JNIEnv *env_id, jobjectID object_id) {
795
796
	HashEntry *hashEntry = 0;
797
	
798
	hashEntry = jvmpiAgent_FindObjectSymbol(object_id);
799
800
	/* if the hash entry for the object exists, make sure it is printed */
801
	if (hashEntry)
802
	{
803
		if (!hashEntry->printed)
804
		{
805
			jvmpiAgent_printObjAllocElement(hashEntry, env_id, 0);
806
		}
807
808
	}
809
	/* otherwise, lookup the object in the VM, and then ensure that it is printed */
810
	else {	
811
		_jvmpiAgent_jvmpiInterface->DisableGC();	
812
		REQUEST_EVENT2(JVMPI_EVENT_OBJECT_ALLOC, object_id);
813
		_jvmpiAgent_jvmpiInterface->EnableGC();
814
		hashEntry = jvmpiAgent_FindObjectSymbol(object_id);
815
		if (hashEntry) {	
816
			if (!hashEntry->printed)
817
			{
818
				jvmpiAgent_printObjAllocElement(hashEntry, env_id, 0);
819
			}
820
		}
821
822
	}
823
824
825
	return hashEntry;
826
827
}
828
829
830
/** FIND_OBJECT_SYMBOL_WITHOUT_LOCKING  **************************************
831
  * Find a symbol in Object hashtable and create an entry if it does not exist.
832
  * YOU MUST ALREADY HOLD THE LOCK ON THE HASHTABLE.
833
  */
834
HashEntry*
835
jvmpiAgent_FindObjectSymbolWithAllocate(jobjectID id,
836
										JNIEnv *env_id)
837
{
838
 HashEntry *hashEntry = jvmpiAgent_FindObjectSymbol(id);
839
 if (hashEntry)
840
 {
841
  if (!hashEntry->printed)
842
  {
843
   jvmpiAgent_printObjAllocElement(hashEntry, env_id, 0);
844
  }
845
 }
846
 return hashEntry;
847
}
848
849
850
/** FIND_SYMBOL  **************************************************************
851
  * Find an entry in a hashtable based upon its id.
852
  * @param       id  - the id provided by the JVMPI_Event
853
  * @param entryType - the type to look up be it Class/Method/Object/Thread
854
  * @returns     >0  - the address of a HashEntry struct containing the result
855
  *                    of the lookup.
856
  *               0  - id is not in the table.
857
  */
858
static _inline HashEntry * jvmpiAgent_FindSymbol(void* id, Hashtable* table, HashBucket* bucket)  {
859
	volatile HashEntry *p;
860
#ifdef _DEBUG
861
	unsigned long pathLength = 1;
862
#endif
863
864
	/* Try to locate the entry in the hash bucket chain */
865
#ifdef _DEBUG
866
	table->findSymbolCount++;
867
#endif
868
	for(p = bucket->activeQ; p != NULL; p = p->next)  {
869
		if (table->compare(p->id,id)==0 && !p->deleted && !p->toBeFreed) {
870
#ifdef _DEBUG
871
			table->findSymbolFound++;
872
			if (pathLength == 1) {
873
				table->hashHitCount++;
874
			}
875
			else {
876
				table->hashMissCount++;
877
				table->hashMissLength += pathLength;
878
			}
879
#endif
880
			return (HashEntry*)p;
881
		}
882
#ifdef _DEBUG
883
		pathLength++;
884
#endif
885
	}
886
 /* Entry not found */
887
#ifdef _DEBUG
888
	table->findSymbolNotFound++;
889
#endif
890
	return 0;
891
}
892
893
HashEntry * jvmpiAgent_FindObjectSymbolFast(jobjectID id) {
894
  if (id == 0) {
895
    /* Only a thread can have a 0 id value so there is no point
896
       looking up 0 id values in the other hash tables
897
    */
898
    return NULL;
899
  }
900
  else {
901
	ObjectHashKey k; 
902
    HashBucket* bucket=getObjectBucket(id);
903
	k.id = id; 
904
    return jvmpiAgent_FindSymbol((void*)&k, &_objectHashtable, bucket);
905
  }
906
}
907
HashEntry * jvmpiAgent_FindObjectSymbol(jobjectID id) {
908
  if (id == 0) {
909
    /* Only a thread can have a 0 id value so there is no point
910
       looking up 0 id values in the other hash tables
911
    */
912
    return NULL;
913
  }
914
  else {
915
    ObjectHashKey k; 
916
    HashEntry* entry;
917
	HashBucket* bucket; 
918
    int index;
919
	k.id=id; 
920
    bucket=getBucket(&_objectHashtable, (void*)&k, &index);
921
    entry = jvmpiAgent_FindSymbol((void*)&k, &_objectHashtable, bucket);
922
    releaseBucket(&_objectHashtable, bucket, index, TRUE);
923
    return entry;
924
  }
925
}
926
HashEntry * jvmpiAgent_FindThreadSymbol(JNIEnv *id) {
927
  ThreadHashKey k; 
928
  HashBucket* bucket=getThreadBucket(id);
929
  k.id = id; 
930
  return jvmpiAgent_FindSymbol((void*)&k, &_threadHashtable, bucket);
931
}
932
HashEntry * jvmpiAgent_FindClassSymbol(jobjectID id) {
933
  if (id == 0) {
934
    /* Only a thread can have a 0 id value so there is no point
935
       looking up 0 id values in the other hash tables
936
    */
937
    return NULL;
938
  }
939
  else {
940
    ClassHashKey k; 
941
    HashBucket* bucket=getClassBucket(id);
942
	k.id=id; 
943
    return jvmpiAgent_FindSymbol((void*)&k, &_classHashtable, bucket);
944
  }
945
}
946
HashEntry * jvmpiAgent_FindMethodSymbol(jmethodID id) {
947
  if (id == 0) {
948
    /* Only a thread can have a 0 id value so there is no point
949
       looking up 0 id values in the other hash tables
950
    */
951
    return NULL;
952
  }
953
  else {
954
	MethodHashKey k; 
955
    HashBucket* bucket=getMethodBucket(id);
956
	k.id=id; 
957
    return jvmpiAgent_FindSymbol((void *)&k, &_methodHashtable, bucket);
958
  }
959
}
960
961
/* Bug Number 73480 */
962
#ifdef __OS400__
963
void insertClassOptSymbol(HashEntry *hashEntry) 
964
{
965
	insertSymbol(&_classHashtable, hashEntry);
966
}
967
#endif
968
969
/** MOVE_SYMBOL  ****************************************************************
970
  * Change the id of an element in the symbol table.
971
  * @param  hashEntry - the current entry in the table.
972
  * @param      id    - the old hashEntry->id 
973
  * @param      newId - the new symbol Id.
974
  */
975
void jvmpiAgent_MoveSymbol(HashEntry *hashEntry, enum EntryType entryType, void* id, 
976
						   void* newId) {
977
	unsigned long oldIndex;
978
	unsigned long newIndex;
979
	Hashtable *table;
980
981
	switch(entryType) {
982
	case Class_t:  table=&_classHashtable; break;
983
	case Method_t: table=&_methodHashtable; break;
984
	case Object_t: table=&_objectHashtable; break;
985
	case Thread_t: table=&_threadHashtable; break;
986
	default: return;
987
	}
988
989
	oldIndex = table->hash(id);
990
	newIndex = table->hash(newId);
991
#ifdef _DEBUG
992
	table->moveCount++;
993
#endif
994
	if (oldIndex != newIndex) {
995
		removeSymbol(table, hashEntry, FALSE);
996
		table->assign(id,newId);
997
                hashEntry->toBeFreed=0; /* 8735 */
998
                hashEntry->next=NULL;   /* 8735 */
999
		insertSymbol(table, hashEntry);
1000
	}
1001
	else  {
1002
		table->assign(id,newId);
1003
	}
1004
}
1005
1006
1007
1008
1009
1010
/** DELETE_SYMBOL  **************************************************************
1011
  * Remove an entry in the symbol table and free the memory associated with the
1012
  * entry.
1013
  * @param   hashEntry - the entry in the table to delete.
1014
  */
1015
void jvmpiAgent_DeleteSymbol(HashEntry *hashEntry, enum EntryType entryType)
1016
{
1017
 if(!hashEntry)
1018
 {
1019
   return;
1020
 }
1021
 switch(entryType)
1022
 {
1023
  case Class_t:
1024
	  removeSymbol(&_classHashtable, hashEntry, TRUE);
1025
	  break;
1026
  case Method_t:
1027
	  removeSymbol(&_methodHashtable, hashEntry, TRUE);
1028
	  break;
1029
  case Object_t:
1030
	  removeSymbol(&_objectHashtable, hashEntry, TRUE);
1031
	  /* Remove the duplicate copy of the object in the heap hashtable */
1032
	  {
1033
		/* RKD:  We need to save the id for later
1034
		HashEntry *heapEntry=jvmpiAgent_FindSymbol(hashEntry->id, Heap_t);
1035
		jvmpiAgent_DeleteSymbol(heapEntry, Heap_t);
1036
		*/
1037
1038
	  }
1039
	  break;
1040
  case Thread_t:
1041
	  removeSymbol(&_threadHashtable, hashEntry, TRUE);
1042
	  break;
1043
  default:
1044
	  return;
1045
 }
1046
}
1047
1048
/** CREAT_THREAD_SYMBOL  *******************************************************
1049
  *
1050
  */
1051
HashEntry * jvmpiAgent_CreateThreadSymbol(JNIEnv *id)
1052
{
1053
 ThreadHashKey *k; 
1054
 HashEntry *entry;
1055
 k = (ThreadHashKey *)jvmpiAgent_Calloc(sizeof(ThreadHashKey)); 
1056
 k->id = id; 
1057
 entry=jvmpiAgent_CreateSymbol((void *)k);
1058
 insertSymbol(&_threadHashtable,entry);
1059
 return entry;
1060
1061
}
1062
1063
/*************************************************************************************/
1064
/* PR Heap Dump walk through */
1065
1066
/* CR:  Is this really needed..If there isn't a function that already does this there should be */
1067
HashEntry * dumpGetObject(jobjectID object_id)
1068
{
1069
	HashEntry *objectHashEntry = 0;
1070
1071
	/* RKD:  We always look in the object table for our class object first. */
1072
	objectHashEntry = jvmpiAgent_FindObjectSymbol(object_id);
1073
	if (!objectHashEntry && object_id != 0) {
1074
		REQUEST_EVENT2(JVMPI_EVENT_OBJECT_ALLOC, object_id); /* 232010 */
1075
		objectHashEntry = jvmpiAgent_FindObjectSymbol(object_id);
1076
	}
1077
	return objectHashEntry;
1078
}
1079
1080
1081
unsigned char prof_dump_read_u1(unsigned char **current)
1082
{
1083
    unsigned char u1;
1084
    DUMP_READ(&u1, current, 1);
1085
    return u1;
1086
}
1087
1088
unsigned short prof_dump_read_u2(unsigned char **current)
1089
{
1090
    unsigned short u2;
1091
    DUMP_READ(&u2, current, 2);
1092
    return ntohs(u2);
1093
}
1094
1095
unsigned long prof_dump_read_u4(unsigned char **current)
1096
{
1097
    jint u4;
1098
    DUMP_READ(&u4, current, 4);
1099
    return ntohl(u4);
1100
}
1101
1102
jobject prof_dump_read_ref(unsigned char **current) 
1103
{
1104
	jobject ref; 
1105
	DUMP_READ(&ref,current,sizeof(jobject)); 
1106
	return ref; 
1107
}
1108
1109
1110
jobjectID prof_dump_read_id(unsigned char **current)
1111
{
1112
    jobjectID p;
1113
	DUMP_READ(&p, current, sizeof(jobjectID));
1114
    return p;
1115
}
1116
1117
void *prof_dump_read_ptr(unsigned char **current) 
1118
{
1119
	void *p; 
1120
#ifdef __OS400__
1121
/* On AS/400 pointers are 16-byte aligned within the buffer. 
1122
   Forward to the next 16 byte boundary if we currently aren't on one */ 
1123
	unsigned int i = (unsigned int) *current;
1124
	i &= 0x0000000f;  /* grab lowest 4 bits of i */
1125
	if (i > 0) {  
1126
		*current = *current + (16 - i);  /* align the pointer */ 
1127
	}
1128
#endif
1129
	DUMP_READ(&p, current, sizeof(void *));
1130
    return p;
1131
}
1132
1133
void outputObjReference(ThreadLocalStorage *tps,
1134
                        HashEntry *objectHashEntry,
1135
                        HashEntry *referencedObjectHashEntry,
1136
						HashEntry *currentFieldClass,
1137
                        int fieldIndex,
1138
                        BOOL isArray) {
1139
1140
	HashEntry *referencedClassHashEntry, *classHashEntry;
1141
1142
1143
	referencedClassHashEntry = OBJECT_ENTRY(referencedObjectHashEntry)->classHashEntry;
1144
	classHashEntry=OBJECT_ENTRY(objectHashEntry)->classHashEntry;
1145
1146
	/* If we don't know the class at either end of the reference we will abandon outputing the
1147
	   reference.  This may result in missing information.  If need be, we can output it by
1148
	   default by just placing the checks for filters inside this test.
1149
	*/
1150
	if(!referencedClassHashEntry || !classHashEntry) {
1151
		return;
1152
	}
1153
1154
	/* ## REMOVE */
1155
	_jvmpiAgent_Options.objRefMode = Filter4Owner;
1156
1157
1158
	/* If the object reference mode if "RespectFilter" we only print the reference
1159
	   is we are tracing both ends of the refernce
1160
	*/
1161
	if (_jvmpiAgent_Options.objRefMode == RespectFilter)
1162
	{
1163
		if (!(CLASS_ENTRY(referencedClassHashEntry)->traceFlag && CLASS_ENTRY(classHashEntry)->traceFlag))
1164
		{
1165
			return;
1166
		}
1167
	}
1168
	/* If the object reference mode if "Filter4Owner", we print the reference if we
1169
	   are tracing either end.  This provides a "one deep" reference graph for all
1170
	   traced classes.
1171
	*/
1172
	else if (_jvmpiAgent_Options.objRefMode == Filter4Owner)
1173
	{
1174
	  if (!(CLASS_ENTRY(classHashEntry)->traceFlag || CLASS_ENTRY(referencedClassHashEntry)->traceFlag))
1175
	  {
1176
		return;
1177
	  }
1178
	}
1179
1180
	/* If either end is not already printed do so */
1181
	if(!referencedObjectHashEntry->printed)
1182
	{
1183
		jvmpiAgent_printObjAllocElement(referencedObjectHashEntry, tps->env, 0);
1184
	}
1185
	if(!objectHashEntry->printed)
1186
	{
1187
	   jvmpiAgent_printObjAllocElement(objectHashEntry, tps->env, 0);
1188
1189
	}
1190
1191
	/* If either end is a class object ensure the defining class is printed */
1192
	if(OBJECT_ENTRY(referencedObjectHashEntry)->classObject)
1193
	{
1194
		jvmpiAgent_outputClassDeclaration(OBJECT_ENTRY(referencedObjectHashEntry)->classHashEntry2, tps);
1195
	}
1196
	if(OBJECT_ENTRY(objectHashEntry)->classObject)
1197
	{
1198
		jvmpiAgent_outputClassDeclaration(OBJECT_ENTRY(objectHashEntry)->classHashEntry2, tps);
1199
1200
	}
1201
1202
	if(isArray)
1203
	{
1204
	   jvmpiAgent_printObjectArrayReferenceElement(tps, OBJECT_ENTRY(objectHashEntry)->static_id, fieldIndex,  OBJECT_ENTRY(referencedObjectHashEntry)->static_id, OBJECT_ENTRY(referencedObjectHashEntry)->heapDumpIndex);
1205
	}
1206
	else
1207
	{
1208
	   jvmpiAgent_printObjectInstanceReferenceElement(tps, OBJECT_ENTRY(objectHashEntry)->static_id, fieldIndex,  OBJECT_ENTRY(referencedObjectHashEntry)->static_id,  OBJECT_ENTRY(referencedObjectHashEntry)->heapDumpIndex, CLASS_ENTRY(currentFieldClass)->instances[fieldIndex].fieldId);
1209
	}
1210
1211
1212
}
1213
1214
void outputPrimativeArray(ThreadLocalStorage *tps,
1215
                          HashEntry *objectHashEntry) {
1216
1217
1218
    /* If the array is not already printed do so */
1219
	if(!objectHashEntry->printed)
1220
	{
1221
		jvmpiAgent_printObjAllocElement(objectHashEntry, tps->env, 0);
1222
	}
1223
}
1224
1225
1226
1227
void outputStaticObjReference(ThreadLocalStorage *tps,
1228
                        HashEntry *objectHashEntry,
1229
                        HashEntry *referencedObjectHashEntry,
1230
						HashEntry *staticReferenceClass,
1231
                        int fieldIndex,
1232
                        BOOL isArray) {
1233
	HashEntry *referencedClassHashEntry;
1234
1235
	referencedClassHashEntry = OBJECT_ENTRY(referencedObjectHashEntry)->classHashEntry;
1236
1237
	/* ## REMOVE */
1238
	_jvmpiAgent_Options.objRefMode = Filter4Owner;
1239
1240
1241
	/* If the object reference mode if "RespectFilter" we only print the reference
1242
	   is we are tracing both ends of the refernce
1243
	*/
1244
	if (_jvmpiAgent_Options.objRefMode == RespectFilter)
1245
	{
1246
		if (!(CLASS_ENTRY(referencedClassHashEntry)->traceFlag && CLASS_ENTRY(staticReferenceClass)->traceFlag))
1247
		{
1248
			return;
1249
		}
1250
	}
1251
	/* If the object reference mode if "Filter4Owner", we print the reference if we
1252
	   are tracing either end.  This provides a "one deep" reference graph for all
1253
	   traced classes.
1254
	*/
1255
	else if (_jvmpiAgent_Options.objRefMode == Filter4Owner)
1256
	{
1257
	  if (!(CLASS_ENTRY(staticReferenceClass)->traceFlag || CLASS_ENTRY(referencedClassHashEntry)->traceFlag))
1258
	  {
1259
		return;
1260
	  }
1261
	}
1262
1263
	/* If either end is not already printed do so */
1264
	if(!referencedObjectHashEntry->printed)
1265
	{
1266
		jvmpiAgent_printObjAllocElement(referencedObjectHashEntry, tps->env,0);
1267
	}
1268
	if(OBJECT_ENTRY(referencedObjectHashEntry)->classObject)
1269
	{
1270
		jvmpiAgent_outputClassDeclaration(OBJECT_ENTRY(referencedObjectHashEntry)->classHashEntry2, tps);
1271
	}
1272
1273
	if(!staticReferenceClass->printed) {
1274
		jvmpiAgent_outputClassDeclaration(staticReferenceClass, tps);
1275
	}
1276
1277
	jvmpiAgent_printObjectInstanceReferenceElement(tps, OBJECT_ENTRY(objectHashEntry)->static_id, fieldIndex, OBJECT_ENTRY(referencedObjectHashEntry)->static_id,  OBJECT_ENTRY(referencedObjectHashEntry)->heapDumpIndex,  CLASS_ENTRY(staticReferenceClass)->statics[fieldIndex].fieldId);
1278
1279
}
1280
1281
1282
static int scrubObject(HashEntry *hashEntry, void * parm)  {
1283
	ObjectEntry *objectEntry=OBJECT_ENTRY(hashEntry);
1284
	if(!objectEntry->foundInHeap) {
1285
1286
		/* RJD We need to count the number of times an object has not been found in the heap. 
1287
		   This problem arises from the fact that when doing a heap dump, after the VM has
1288
		   created the heap dump and reported it to the profiler, other VM threads
1289
		   may continue running. That is, we can potentially be scrubbing the heap concurrently
1290
		   while objects are being created. This results in a situation where we may find a 
1291
		   particular object in the hash table, but not in the heap (because it was created 
1292
		   after the heap dump had been constructed by the VM). Removing the object just
1293
		   because it wasn't found in the heap may be premature. During a second heap dump, 
1294
		   however, the object should be present in the heap. Hence, it should be safe to
1295
		   free objects that have not been found in the heap twice. bugzilla_57475 */ 
1296
1297
		objectEntry->notFoundInHeap++; 
1298
1299
		if (objectEntry->notFoundInHeap > 1) {
1300
1301
			/* We will only print object free for objects which we have already declared
1302
			   within the trace and if we have been asked to print object free's
1303
			*/
1304
			if (hashEntry->printed && _jvmpiAgent_Options.gc!=GcNone) {
1305
				jvmpiAgent_printObjFreeElement((ThreadPrivateStorage*)(parm), hashEntry);
1306
			}
1307
1308
			/* Remove the object from the object hashtable */
1309
			jvmpiAgent_DeleteSymbol(hashEntry, Object_t);
1310
		}
1311
	}
1312
	else {
1313
		objectEntry->foundInHeap=0;  
1314
	}
1315
	return 0;
1316
}
1317
1318
1319
/* This function is used dump Level 0 to store all the object and type in the Heap Hash table for comparition
1320
*/
1321
void jvmpiAgent_markHeap(JVMPI_Event *event) {
1322
	ThreadLocalStorage *tps=jvmpiAgent_getThreadLocalStorage(0);
1323
	unsigned char* cursor = (unsigned char*)event->u.heap_dump.begin;
1324
	unsigned char type;
1325
	jobjectID oid;
1326
1327
    /* It appears some JVM's may give us a NULL start address.  Starting walking memory
1328
       at NULL wouldn't be good
1329
    */
1330
    if(!cursor) {
1331
        return;
1332
    }
1333
1334
	while (cursor < (unsigned char*)event->u.heap_dump.end) {
1335
		HashEntry *objectHashEntry = 0;
1336
		
1337
		type = prof_dump_read_u1(&cursor); 
1338
		oid = prof_dump_read_id(&cursor); 
1339
1340
		/* If this is a normal mark of the heap we behave one way, if this is a scrub of the heap due to a
1341
		   runGC request we do it another way.
1342
		*/
1343
		if(!tps->scrubbingHeap) {
1344
			objectHashEntry = dumpGetObject(oid);
1345
			if(objectHashEntry) /* The defect number is 175135. */ {
1346
				OBJECT_ENTRY(objectHashEntry)->heapDumpIndex=_heapDumpInfo.index;
1347
			}
1348
		}
1349
		else {
1350
			HashEntry *objectHashEntry=jvmpiAgent_FindObjectSymbol(oid);
1351
			if(objectHashEntry) {
1352
				OBJECT_ENTRY(objectHashEntry)->foundInHeap = 1;
1353
			}
1354
		}
1355
1356
	} /* end while */
1357
1358
1359
    /* If we are scrubbing we should generate all the necessary free events before returning to the JVM */
1360
    if(tps->scrubbingHeap) {
1361
        /* Iterate through the object table and find objects which we didn't get free's for */
1362
        jvmpiAgent_ForAll(Object_t, scrubObject, tps);
1363
    }
1364
1365
}
1366
1367
/* unsigned long jvmpiAgent_analyseMonitorDump(JVMPI_Event *event, jobjectID monitorObj)
1368
1369
  Determines the owner thread of the monitor represented
1370
  by monitorObj by analysing the monitor dump.
1371
1372
  args -
1373
	event - the monitor dump event as reported by JVMPI
1374
	monitorObj - the monitor for which we wish to determine the owner thread 
1375
1376
  returns
1377
	the id of the thread that owns the given monitor 
1378
*/
1379
1380
unsigned long jvmpiAgent_analyseMonitorDump(JVMPI_Event *event, jobjectID monitorObj)  {	
1381
1382
	ThreadLocalStorage *tps=jvmpiAgent_getThreadLocalStorage(event->env_id);
1383
	unsigned char *current; 
1384
	JNIEnv *ownerThread = 0; /* owner thread */ 
1385
1386
	current=(unsigned char*)event->u.monitor_dump.begin;
1387
1388
	if (current == 0) {
1389
		/* bad data from the JVM */ 
1390
		return 0;
1391
	}
1392
	
1393
	while (current < (unsigned char*)event->u.monitor_dump.end) {
1394
		unsigned char tag = prof_dump_read_u1(&current);
1395
		switch (tag)
1396
		{
1397
		case JVMPI_MONITOR_JAVA:
1398
		/*
1399
			jobjectID 	 object ID
1400
			JNIEnv * 	 owner thread
1401
			u4 			 entry count
1402
			u4 			 number of threads waiting to enter
1403
			[JNIEnv *]* 	threads waiting to enter
1404
			u4 			 number of threads waiting to be notified
1405
			[JNIEnv *]* 	threads waiting to be notified 
1406
		*/ 
1407
			{
1408
			jobjectID obj_id;
1409
			unsigned int numThreads; 
1410
			JNIEnv *thread_env; 
1411
			
1412
			obj_id = prof_dump_read_id(&current); /* object ID */ 
1413
			thread_env =  (JNIEnv *)prof_dump_read_ptr(&current); /* owner thread */ 
1414
1415
			if (obj_id == monitorObj) { 
1416
				ownerThread = thread_env; 
1417
				/* we found the owner thread; no need to walk the rest of the dump */ /* <- this is no longer true */
1418
				/*goto END_MONITORS_ANALYSE;*/
1419
			}
1420
1421
			if (thread_env==tps->env) {
1422
				HashEntry *objectHashEntry;
1423
				/* lookup monitor object, ensuring that it exists in the trace */
1424
				objectHashEntry = jvmpiAgent_FindObjectSymbolWithAllocateAndPrint(event->env_id,obj_id);
1425
				if (objectHashEntry) {
1426
					jvmpiAgent_printMonitorStillOwnedElement(objectHashEntry,event);
1427
				}
1428
			}
1429
1430
			/* we don't care what's in the rest of this record */ 
1431
			current += SIZEOF_U4; /* entry count */ 
1432
			numThreads = prof_dump_read_u4(&current); /* number of threads waiting to enter */ 
1433
			current += numThreads * sizeof(void *); /* threads waiting to enter */ 
1434
			numThreads = prof_dump_read_u4(&current); /* number of threads waiting to be notified */ 
1435
			current += numThreads * sizeof(void *); /* threads waiting to be notified */ 
1436
			
1437
			break;
1438
			}
1439
		case JVMPI_MONITOR_RAW:
1440
		/*	 char * 	 raw monitor name
1441
			 JVMPI_RawMonitor 	raw monitor ID
1442
			 JNIEnv * 	owner thread
1443
			 u4 	entry count
1444
			 u4 	number of threads waiting to enter
1445
			 [JNIEnv *]* 	threads waiting to enter
1446
			 u4 	number of threads waiting to be notified
1447
			 [JNIEnv *]* 	threads waiting to be notified
1448
		 */ 
1449
			{
1450
			unsigned int numThreads; 
1451
1452
			prof_dump_read_ptr(&current); /* raw monitor name */ 
1453
			prof_dump_read_id(&current); /* raw monitor ID */ 
1454
			prof_dump_read_ptr(&current); /* owner thread */ 
1455
			current += SIZEOF_U4;  /* entry count */ 
1456
			numThreads = prof_dump_read_u4(&current); /* number of threads waiting to enter */
1457
			current += numThreads * sizeof(void *); /* threads waiting to enter */ 
1458
			numThreads = prof_dump_read_u4(&current); /* number of threads waiting to be notified */ 
1459
			current += numThreads * sizeof(void *); /* threads waiting to be notified */ 
1460
1461
			break;
1462
			}
1463
1464
		default:
1465
			break;
1466
		}
1467
	}
1468
/*END_MONITORS_ANALYSE:*/
1469
1470
	if (ownerThread != 0) {
1471
		/* We found the owner thread. Now translate the JNIEnv * to the id printed 
1472
		   the trace. */ 
1473
		HashEntry *entry = jvmpiAgent_FindThreadSymbol(ownerThread);
1474
		if (entry != 0) {
1475
			if (jvmpiAgent_isPrintStaticId()) {
1476
				return THREAD_ENTRY(entry)->staticThreadId; 
1477
			}
1478
			else {
1479
				return (unsigned long)ownerThread; 
1480
			}
1481
		}
1482
	}
1483
	return 0; 
1484
}
1485
1486
1487
1488
/* This function is used to store all the new object and there references into the heap hash table
1489
*/
1490
/* RKD:  I am disabling the optimizer for this function as it causes the heapdump to blow
1491
         up on windows.  This appears to only occur with my compiler, remove when checking
1492
		 in V5 code
1493
*/
1494
#ifdef _WIN32
1495
#pragma optimize ( "", off )
1496
#endif
1497
void jvmpiAgent_analyseHeap(JVMPI_Event *event, char* heapDefName)
1498
{
1499
	unsigned char *current;
1500
	ThreadLocalStorage *tps=jvmpiAgent_getThreadLocalStorage(0);
1501
	jvmpiAgent_printHDStartElement(tps, heapDefName);
1502
	current=(unsigned char*)event->u.heap_dump.begin;
1503
	
1504
	/* RKD:  Cannot process heap if we get bad info.  We need to tell the user this is bad. */
1505
	if(current == 0 || (unsigned char*)event->u.heap_dump.end == 0) {
1506
		sendErrorMessage(RA_SEVERE,"0","Heap dump failed because bad data passed from JVM.");
1507
		return;	
1508
	}
1509
1510
    while (current < (unsigned char*)event->u.heap_dump.end)
1511
	{
1512
		HashEntry *tmpHash; /* For GC_ROOT */
1513
		unsigned long id;  /* For GC_ROOT */
1514
1515
		int size = 0;
1516
	    unsigned char tag;
1517
		int in;
1518
		int out;
1519
1520
		tag = prof_dump_read_u1(&current);
1521
		size += sizeof(unsigned char);
1522
1523
START_SWITCH:
1524
		switch (tag)
1525
		{
1526
			case JVMPI_GC_ROOT_UNKNOWN :
1527
				{/* jobjectID            object */
1528
					jobjectID obj_id = prof_dump_read_id(&current);/* object */
1529
1530
					tmpHash = jvmpiAgent_FindObjectSymbol(obj_id);
1531
					if(tmpHash != NULL)
1532
					{
1533
						id = OBJECT_ENTRY(tmpHash)->static_id;
1534
1535
						if (!tmpHash->printed) {
1536
							jvmpiAgent_printObjAllocElement(tmpHash,tps->env,0); 
1537
						}
1538
1539
						jvmpiAgent_printGcRootElement(event, id, "UNKNOWN");
1540
1541
					}
1542
					break;
1543
				 }
1544
			case JVMPI_GC_ROOT_JNI_GLOBAL:
1545
				{/*jobjectID        object
1546
                   jobject          JNI global reference */
1547
					jobjectID obj_id = prof_dump_read_id(&current); /* object  */
1548
					prof_dump_read_ref(&current);/* JNI global reference */
1549
1550
					tmpHash = jvmpiAgent_FindObjectSymbol(obj_id);
1551
					if(tmpHash != NULL)
1552
					{
1553
						id = OBJECT_ENTRY(tmpHash)->static_id;
1554
					
1555
						if (!tmpHash->printed) {
1556
							jvmpiAgent_printObjAllocElement(tmpHash,tps->env,0); 
1557
						}
1558
						jvmpiAgent_printGcRootElement(event, id, "JNI_GLOBAL");
1559
					}
1560
					break;
1561
				}
1562
			case JVMPI_GC_ROOT_JNI_LOCAL:
1563
				{/*jobjectID       object
1564
                   JNIEnv *        thread
1565
                   u4              frame # in stack trace (-1 for empty) */
1566
				    jobjectID obj_id = prof_dump_read_id(&current);
1567
					JNIEnv *env = (JNIEnv *)prof_dump_read_ptr(&current);
1568
					int depth = prof_dump_read_u4(&current);
1569
1570
					tmpHash = jvmpiAgent_FindObjectSymbol(obj_id);
1571
					if(tmpHash != NULL)
1572
					{
1573
						id = OBJECT_ENTRY(tmpHash)->static_id;
1574
						
1575
						if (!tmpHash->printed) {
1576
							jvmpiAgent_printObjAllocElement(tmpHash,tps->env,0); 
1577
						}
1578
						jvmpiAgent_printGcRootElement(event, id, "JNI_LOCAL");
1579
					}
1580
					break;
1581
				}
1582
			case JVMPI_GC_ROOT_JAVA_FRAME:
1583
				{/*jobjectID          object
1584
                   JNIEnv *           thread
1585
                   u4                 frame # in stack trace (-1 for empty) */
1586
				    jobjectID obj_id = prof_dump_read_id(&current);
1587
					JNIEnv *env = (JNIEnv *)prof_dump_read_ptr(&current);
1588
					int depth = prof_dump_read_u4(&current);
1589
1590
					tmpHash = jvmpiAgent_FindObjectSymbol(obj_id);
1591
					if(tmpHash != NULL)
1592
					{
1593
						id = OBJECT_ENTRY(tmpHash)->static_id;
1594
						
1595
						if (!tmpHash->printed) {
1596
							jvmpiAgent_printObjAllocElement(tmpHash,tps->env,0); 
1597
						}
1598
						jvmpiAgent_printGcRootElement(event, id, "JAVA_FRAME");
1599
					}
1600
					break;
1601
				}
1602
			case JVMPI_GC_ROOT_NATIVE_STACK :
1603
				{/*jobjectID             object
1604
                   JNIEnv *              thread */
1605
					jobjectID obj_id;
1606
					JNIEnv *JNIEnvPtr;
1607
					obj_id = prof_dump_read_id(&current);/* object */
1608
                    JNIEnvPtr = (JNIEnv *) prof_dump_read_ptr(&current);/* thread*/
1609
1610
					tmpHash = jvmpiAgent_FindObjectSymbol(obj_id);
1611
					if(tmpHash != NULL)
1612
					{
1613
						id = OBJECT_ENTRY(tmpHash)->static_id;
1614
						
1615
						if (!tmpHash->printed) {
1616
							jvmpiAgent_printObjAllocElement(tmpHash,tps->env,0); 
1617
						}
1618
						jvmpiAgent_printGcRootElement(event, id, "NATIVE_STACK");
1619
					}
1620
					break;
1621
				}
1622
			case JVMPI_GC_ROOT_STICKY_CLASS :
1623
				{/*jobjectID              class object */
1624
                    jobjectID class_id = prof_dump_read_id(&current);/* class object */
1625
1626
					tmpHash = jvmpiAgent_FindClassSymbol(class_id);
1627
					if(tmpHash != NULL)
1628
					{
1629
						id = CLASS_ENTRY(tmpHash)->static_id;
1630
						if (!tmpHash->printed) {
1631
							jvmpiAgent_outputClassDeclaration(tmpHash,tps); 
1632
						}
1633
						jvmpiAgent_printGcRootElement(event, id, "STICKY_CLASS");
1634
					}
1635
					break;
1636
				}
1637
			case JVMPI_GC_ROOT_THREAD_BLOCK:
1638
				{/*jobjectID               thread object
1639
                   JNIEnv *                thread */
1640
				    jobjectID h_ID = prof_dump_read_id(&current);/* thread object */
1641
					JNIEnv *env_ID = (JNIEnv *)prof_dump_read_ptr(&current);/* thread */
1642
					/* Thread blocks are commented out in the corresponding print.c code 
1643
					   Hence, commenting out here as well. 
1644
					tmpHash = jvmpiAgent_FindThreadSymbol(env_ID);
1645
					if(tmpHash != NULL)
1646
					{
1647
						id = THREAD_ENTRY(tmpHash)->staticThreadId;
1648
1649
						jvmpiAgent_printGcRootElement(event, id, "THREAD_BLOCK");
1650
					} */ 
1651
					break;
1652
				}
1653
			case JVMPI_GC_ROOT_MONITOR_USED:
1654
				{/* jobjectID                object */
1655
					jobjectID obj_Id = prof_dump_read_id(&current);/* object */
1656
1657
					tmpHash = jvmpiAgent_FindObjectSymbol(obj_Id);
1658
					if(tmpHash != NULL)
1659
					{
1660
						id = OBJECT_ENTRY(tmpHash)->static_id;
1661
						
1662
						if (!tmpHash->printed) {
1663
							jvmpiAgent_printObjAllocElement(tmpHash,tps->env,0); 
1664
						}
1665
						jvmpiAgent_printGcRootElement(event, id, "MONITOR_USED");
1666
					}
1667
					break;
1668
				}
1669
			case JVMPI_GC_CLASS_DUMP  :
1670
				{/*jobjectID          class
1671
                   jobjectID          super
1672
                   jobjectID          class loader
1673
				   jobjectID          signers
1674
                   jobjectID          protection domain
1675
                   jobjectID          class name (a String object, may be NULL)
1676
                   void *             reserved
1677
                   u4                 instance size (in bytes)
1678
                   [jobjectID]*       interfaces
1679
                   u2                 size of constant pool
1680
                   [u2,               constant pool index,
1681
                    ty,               type,
1682
                    vl]*              value
1683
                   [vl]*              static field values */
1684
					/*jint ty; */
1685
					int i;
1686
				    jobjectID class_name;
1687
					void *resv2;
1688
					unsigned int size;
1689
				    jobjectID class_id;
1690
					jobjectID loader_id;
1691
					jobjectID signers_id;
1692
					jobjectID domain_id;
1693
					unsigned short size_of_constant_pool;
1694
					HashEntry *classHashEntry, *objectHashEntry;
1695
					class_id = prof_dump_read_id(&current); /* class */
1696
1697
					/* Resolve the class object */
1698
					_requestClassObj = 1;  /* specify that we're requesting a class object */
1699
				    objectHashEntry = dumpGetObject(class_id);
1700
					_requestClassObj = 0; 
1701
1702
					/* If we found the class object and we don't have the class it represents yet we better resolve it */
1703
					if(objectHashEntry) {
1704
						classHashEntry=OBJECT_ENTRY(objectHashEntry)->classHashEntry2;
1705
						
1706
						if(!classHashEntry && class_id != 0) {
1707
							REQUEST_EVENT2(JVMPI_EVENT_CLASS_LOAD, class_id);
1708
							OBJECT_ENTRY(objectHashEntry)->classHashEntry2 = jvmpiAgent_FindClassSymbol(class_id);
1709
							OBJECT_ENTRY(objectHashEntry)->classObject = 1; 
1710
						}
1711
1712
					}
1713
1714
					/* It does occasionally happen that sun's JDK will assign a class id of zero
1715
					 * to a normal object.  This will cause objectHashEntry to be NULL.  
1716
					 This block of code handles this case. Note that we cannot recover from this
1717
					 error since walking the rest of the heap dump correctly requires that
1718
					 we know the details of the class. */
1719
1720
					if (!objectHashEntry) {
1721
						sendErrorMessage(RA_SEVERE,"0","Heap dump failed because an unknown class could not be resolved.");
1722
						return; 
1723
					}
1724
				
1725
					classHashEntry=OBJECT_ENTRY(objectHashEntry)->classHashEntry2;
1726
1727
1728
					/* Store ref to superclass to use on obj instance dumps.
1729
					 * You cannot just store the superclass id and defer the class
1730
					 * load because later move events can invalidate the association
1731
					 * between this class id and it's class object.  */
1732
					{
1733
						jobjectID super_id;
1734
						HashEntry *superclassHashEntry;
1735
1736
						super_id = prof_dump_read_id(&current);
1737
						superclassHashEntry = jvmpiAgent_FindClassSymbol(super_id);
1738
						/* RJD: make sure that we're not requesting a class load event
1739
						   for a null id */
1740
						if (!superclassHashEntry && super_id != 0) {
1741
							REQUEST_EVENT2(JVMPI_EVENT_CLASS_LOAD, super_id);  /*232010 */
1742
							superclassHashEntry = jvmpiAgent_FindClassSymbol(super_id);
1743
						}
1744
						CLASS_ENTRY(classHashEntry)->superClassEntry = superclassHashEntry;
1745
					}
1746
1747
					loader_id = prof_dump_read_id(&current); /*class loader */
1748
1749
1750
					signers_id = prof_dump_read_id(&current); /*signers */
1751
					domain_id = prof_dump_read_id(&current); /*protection domain */
1752
					class_name = prof_dump_read_id(&current); /*class name (a String object, may be NULL) */
1753
1754
				    resv2 = prof_dump_read_ptr(&current);  /* reserved */
1755
				    size = prof_dump_read_u4(&current); /*instance size (in bytes) */
1756
1757
					for (i=0; i<CLASS_ENTRY(classHashEntry)->numInterfaces; i++)
1758
					{
1759
						jobjectID iref = prof_dump_read_id(&current); /*walk through the the interface  */
1760
					}
1761
1762
					size_of_constant_pool = prof_dump_read_u2(&current); /*size of constant pool  */
1763
1764
					for (i = 0; i < size_of_constant_pool; i++)
1765
					{
1766
						unsigned short index;
1767
						unsigned char ty;
1768
						index = prof_dump_read_u2(&current);/* constant pool index */
1769
						ty = prof_dump_read_u1(&current);/* type */
1770
					
1771
						switch(ty)
1772
						{
1773
							case JVMPI_CLASS:
1774
							case JVMPI_NORMAL_OBJECT:  
1775
								prof_dump_read_id(&current);
1776
								break;
1777
							case JVMPI_BOOLEAN:
1778
							case JVMPI_BYTE:
1779
								prof_dump_read_u1(&current);
1780
								break;
1781
							case JVMPI_CHAR:
1782
							case JVMPI_SHORT:
1783
								prof_dump_read_u2(&current);
1784
								break;
1785
							case JVMPI_INT:
1786
							case JVMPI_FLOAT:
1787
								prof_dump_read_u4(&current);
1788
								break;
1789
							case JVMPI_LONG:
1790
							case JVMPI_DOUBLE:
1791
								prof_dump_read_u4(&current);
1792
								prof_dump_read_u4(&current);
1793
								break;
1794
							default:
1795
								printf("Wrong type\n");
1796
								fflush(stdout); 
1797
						} 
1798
						
1799
						 
1800
					}
1801
#ifdef __OS400__
1802
#pragma convert(819)
1803
#endif 
1804
					for(i = 0; i<CLASS_ENTRY(classHashEntry)->numStaticFields; i++) /* walk through static field values */
1805
					{
1806
						jobjectID instanceFieldValue;
1807
						char prim = CLASS_ENTRY(classHashEntry)->statics[i].field_signature[0];
1808
						if(event->u.heap_dump.dump_level==JVMPI_DUMP_LEVEL_2)
1809
						{
1810
							switch(prim)
1811
							{
1812
								case 'Z':
1813
								case 'B':
1814
									prof_dump_read_u1(&current);
1815
									break;
1816
								case 'C':
1817
								case 'S':
1818
									prof_dump_read_u2(&current);
1819
									break;
1820
								case 'I':
1821
								case 'F':
1822
									prof_dump_read_u4(&current);
1823
									break;
1824
								case 'J':
1825
								case 'D':
1826
									prof_dump_read_u4(&current);
1827
									prof_dump_read_u4(&current);
1828
									break;
1829
								case 'L':
1830
								case '[':
1831
									instanceFieldValue=prof_dump_read_id(&current);
1832
							}
1833
						}
1834
						else
1835
						{
1836
							if(prim=='L' || prim=='[')
1837
							{
1838
#ifdef __OS400__
1839
#pragma convert(0)
1840
#endif 
1841
								instanceFieldValue=prof_dump_read_id(&current);
1842
1843
								/* RKD: Static fields */
1844
								if (instanceFieldValue)
1845
								{
1846
									HashEntry *objectHashEntry4Ref;
1847
1848
1849
									objectHashEntry4Ref = dumpGetObject(instanceFieldValue);
1850
									if(!objectHashEntry4Ref)
1851
									{
1852
										continue; /* The defect number is 174350.*/
1853
									}
1854
1855
									/* Is this the first heap dump that we saw this object in? */
1856
/* Changed for bug 46787
1857
									if(OBJECT_ENTRY(objectHashEntry4Ref)->heapDumpIndex <  _heapDumpInfo.index) {
1858
*/
1859
									if(OBJECT_ENTRY(objectHashEntry4Ref)->heapDumpIndex == 0) {
1860
										OBJECT_ENTRY(objectHashEntry4Ref)->heapDumpIndex =  _heapDumpInfo.index;
1861
									}
1862
1863
									/* Forward this reference to be printed if either end of the
1864
									   reference is new for this analysis
1865
									*/
1866
/* Added for bug 46787 */
1867
										outputStaticObjReference(tps, CLASS_ENTRY(classHashEntry)->classObject, objectHashEntry4Ref, classHashEntry, i, FALSE);
1868
/* Removed for bug 46787
1869
									if(OBJECT_ENTRY(objectHashEntry4Ref)->heapDumpIndex==_heapDumpInfo.index)
1870
									{
1871
										outputStaticObjReference(tps, CLASS_ENTRY(classHashEntry)->classObject, objectHashEntry4Ref, classHashEntry, i, FALSE);
1872
									}
1873
*/
1874
								}
1875
							}
1876
						}
1877
					}/* for */
1878
					break;
1879
				}
1880
1881
			case JVMPI_GC_INSTANCE_DUMP:
1882
				{/*jobjectID            object
1883
                   jobjectID            class
1884
                   u4                   number of bytes that follow
1885
                   [vl]*                instance field values (class, followed by super, super's super ...)*/
1886
1887
					HashEntry *debugClassHashEntry=0, *classHashEntry = 0;
1888
					HashEntry *objectHashEntry = 0;
1889
					unsigned int i;
1890
					jobjectID obj_id = prof_dump_read_id(&current);
1891
					jobjectID class_id = prof_dump_read_id(&current);
1892
					int superClass = 0;
1893
					unsigned long valbytes = prof_dump_read_u4(&current);
1894
					HashEntry *heapHashEntry = 0;
1895
1896
					/* Determine where the end of this instance is in case we need to
1897
					   panic we can recover
1898
					*/
1899
					unsigned char* endAddr=current+valbytes;
1900
1901
					/* RKD:  Moved the find for the objecthashEntry up here as this should
1902
					         resolve the classHashEntry simutaneously.
1903
					*/
1904
1905
					/* Force the class to be resolved */
1906
					_requestClassObj = 1; /* specify that we're requesting a class object */ 
1907
					objectHashEntry=dumpGetObject(class_id);
1908
					_requestClassObj = 0; 
1909
1910
					/* If we found the class object and we don't have the class it represents yet we better resolve it */
1911
					if(objectHashEntry) {
1912
						classHashEntry=OBJECT_ENTRY(objectHashEntry)->classHashEntry2;
1913
						if(!classHashEntry && class_id != 0) {
1914
							REQUEST_EVENT2(JVMPI_EVENT_CLASS_LOAD, class_id); /* 232010 */
1915
							OBJECT_ENTRY(objectHashEntry)->classHashEntry2 = jvmpiAgent_FindClassSymbol (class_id);
1916
							OBJECT_ENTRY(objectHashEntry)->classObject = 1; 
1917
						}
1918
					}
1919
1920
					/* Find the object in the object allocation table */
1921
					objectHashEntry = dumpGetObject(obj_id);
1922
1923
					/* If we can't find this object abort finding it's references */
1924
					if(!objectHashEntry) {
1925
						current=endAddr;
1926
						break;
1927
					}
1928
1929
					/* RKD:  Idealy we would use the reference already established but
1930
					         this causes problems as the array types we established
1931
							 are not as detailed as the contents in the heap.  For
1932
					         example if a class_id is zero when requested the class
1933
					         will not be in the heap
1934
					*/
1935
					classHashEntry=OBJECT_ENTRY(objectHashEntry)->classHashEntry;
1936
1937
					if(!classHashEntry) {
1938
						current=endAddr;
1939
						break;
1940
					}
1941
1942
		
1943
/* Changed for bug 46787
1944
					if(OBJECT_ENTRY(objectHashEntry)->heapDumpIndex <  _heapDumpInfo.index) {
1945
*/
1946
					if(OBJECT_ENTRY(objectHashEntry)->heapDumpIndex == 0) {
1947
						OBJECT_ENTRY(objectHashEntry)->heapDumpIndex =  _heapDumpInfo.index;
1948
					}
1949
1950
					while (classHashEntry)
1951
					{
1952
						for (i=0; i< (unsigned int)CLASS_ENTRY(classHashEntry)->numInstanceFields; i++)
1953
						{
1954
							jobjectID instanceFieldValue;
1955
							char prim = CLASS_ENTRY(classHashEntry)->instances[i].field_signature[0];
1956
							/* Grab this instance  */
1957
#ifdef __OS400__
1958
#pragma convert(819)
1959
#endif 
1960
							if(event->u.heap_dump.dump_level==JVMPI_DUMP_LEVEL_2)
1961
							{
1962
								switch(prim) {
1963
								case 'Z':
1964
								case 'B':
1965
									prof_dump_read_u1(&current);
1966
									break;
1967
								case 'C':
1968
								case 'S':
1969
									prof_dump_read_u2(&current);
1970
									break;
1971
								case 'I':
1972
								case 'F':
1973
									prof_dump_read_u4(&current);
1974
									break;
1975
								case 'J':
1976
								case 'D':
1977
									prof_dump_read_u4(&current);
1978
									prof_dump_read_u4(&current);
1979
									break;
1980
								case 'L':
1981
								case '[':
1982
									instanceFieldValue=prof_dump_read_id(&current);
1983
								}
1984
							}
1985
							else
1986
							{
1987
								if(prim=='L' || prim=='[')
1988
								{
1989
									instanceFieldValue=prof_dump_read_id(&current);
1990
								}
1991
							}
1992
1993
							if (prim == 'L' || prim == '[')
1994
							{
1995
#ifdef __OS400__
1996
#pragma convert(0)
1997
#endif 
1998
							    if (instanceFieldValue)
1999
								{
2000
2001
									HashEntry *objectHashEntry4Ref;
2002
2003
									objectHashEntry4Ref = dumpGetObject(instanceFieldValue);
2004
									if(!objectHashEntry4Ref)
2005
									{
2006
										continue; /* The defect number is 174350.*/
2007
									}
2008
2009
/* Changed for bug 46787
2010
									if(OBJECT_ENTRY(objectHashEntry4Ref)->heapDumpIndex <  _heapDumpInfo.index) {
2011
*/
2012
									if(OBJECT_ENTRY(objectHashEntry4Ref)->heapDumpIndex == 0) {
2013
										OBJECT_ENTRY(objectHashEntry4Ref)->heapDumpIndex =  _heapDumpInfo.index;
2014
									}
2015
2016
									/* Forward this reference to be printed if either end of the
2017
									   reference is new for this analysis
2018
									*/
2019
/* Added for bug 46787 */
2020
									outputObjReference(tps, objectHashEntry, objectHashEntry4Ref, classHashEntry, i, FALSE);
2021
/* Removed for bug 46787
2022
									if(OBJECT_ENTRY(objectHashEntry4Ref)->heapDumpIndex==_heapDumpInfo.index || OBJECT_ENTRY(objectHashEntry)->heapDumpIndex==_heapDumpInfo.index)
2023
									{
2024
										outputObjReference(tps, objectHashEntry, objectHashEntry4Ref, classHashEntry, i, FALSE);
2025
									}
2026
*/
2027
								}
2028
							}
2029
2030
						} /* for */
2031
						classHashEntry = CLASS_ENTRY(classHashEntry)->superClassEntry;
2032
					} /* while */
2033
2034
					current=endAddr;
2035
					break;
2036
				}
2037
2038
			case JVMPI_GC_OBJ_ARRAY_DUMP :
2039
				{/*jobjectID             array object
2040
                   u4                    number of elements
2041
                   jobjectID             element class ID (may be NULL in the Java 2 SDK)
2042
                   [jobjectID]*          elements */
2043
					unsigned int i;
2044
					jobjectID objRef = 0;
2045
					HashEntry *objectHashEntry = 0;
2046
2047
					HashEntry *classHashEntry=NULL;
2048
					HashEntry *heapHashEntry=NULL;
2049
2050
				    jobjectID objArray_id = prof_dump_read_id(&current);
2051
					unsigned long num_elements = prof_dump_read_u4(&current);
2052
					jobjectID class_id = prof_dump_read_id(&current);
2053
2054
2055
					/* RKD:  Moved the locate object up here and then use the objects type first
2056
					         we will ignore the class_id in the dump.  By rights, locating the
2057
							 object will also locate the class object as well.
2058
					*/
2059
2060
					/* Locate the array object */
2061
					objectHashEntry = dumpGetObject(objArray_id);
2062
2063
2064
2065
					/* If we can't find the array object just skip this object array */
2066
					if(!objectHashEntry) {
2067
						current+=num_elements * sizeof(jobjectID);
2068
						break;
2069
					}
2070
2071
					classHashEntry=OBJECT_ENTRY(objectHashEntry)->classHashEntry;
2072
2073
					/* If we have no type information just skip this object array */
2074
					if(!classHashEntry) {
2075
						current+=num_elements * sizeof(jobjectID);
2076
						break;
2077
					}
2078
2079
/* Changed for bug 46787
2080
					if(OBJECT_ENTRY(objectHashEntry)->heapDumpIndex <  _heapDumpInfo.index) {
2081
*/
2082
					if(OBJECT_ENTRY(objectHashEntry)->heapDumpIndex == 0) {
2083
						OBJECT_ENTRY(objectHashEntry)->heapDumpIndex =  _heapDumpInfo.index;
2084
					}
2085
2086
					/* Load all the array element pointers into the heap table */
2087
					for (i = 0; i < num_elements; i++)
2088
					{
2089
2090
						/* Get the array element */
2091
						objRef = prof_dump_read_id(&current);
2092
2093
						/* RKD:  We could save all the references to determine if they change
2094
						   between heap analysis but this is not the present goal.
2095
						heapEntry->objRef_id[i] = 0;
2096
						*/
2097
2098
2099
						/* Inspect the array element (ie. ensure non-NULL)*/
2100
2101
						if(objRef)
2102
						{
2103
							HashEntry *objectHashEntry4Ref = 0;
2104
/* Removed for bug 46787
2105
							HashEntry *referencedObjectHeapEntry = 0;
2106
*/
2107
2108
							/* Lookup/Load the endpoint of this reference into the object Hashtable*/
2109
							objectHashEntry4Ref = dumpGetObject(objRef);
2110
2111
							/* If we don't have the endpoint abort this reference */
2112
							if(!objectHashEntry4Ref)
2113
							{
2114
								continue;
2115
							}
2116
2117
/* Removed for bug 46787
2118
							if(OBJECT_ENTRY(objectHashEntry4Ref)->heapDumpIndex <  _heapDumpInfo.index) {
2119
*/
2120
							if(OBJECT_ENTRY(objectHashEntry4Ref)->heapDumpIndex == 0) {
2121
								OBJECT_ENTRY(objectHashEntry4Ref)->heapDumpIndex =  _heapDumpInfo.index;
2122
							}
2123
2124
							/* Forward this reference to be printed if either end of the
2125
							   reference is new for this analysis
2126
							*/
2127
2128
/* Added for bug 46787 */
2129
							outputObjReference(tps, objectHashEntry, objectHashEntry4Ref, classHashEntry, i, TRUE);
2130
/* Removed for bug 46787
2131
							if(OBJECT_ENTRY(objectHashEntry4Ref)->heapDumpIndex==_heapDumpInfo.index || OBJECT_ENTRY(referencedObjectHeapEntry)->heapDumpIndex==_heapDumpInfo.index)
2132
							{
2133
								outputObjReference(tps, objectHashEntry, objectHashEntry4Ref, classHashEntry, i, TRUE);
2134
							}
2135
*/
2136
						}
2137
					}/* for */
2138
					break;
2139
				}
2140
			case JVMPI_GC_PRIM_ARRAY_DUMP:
2141
				{/*jobjectID            array object
2142
                   u4                   number of elements
2143
                   ty                   element type
2144
                   [vl]*                elements */
2145
				    unsigned int num_elements;
2146
				    unsigned char ty;
2147
                    HashEntry *objectHashEntry=NULL;
2148
                    HashEntry *classHashEntry=NULL;
2149
				    jobjectID obj_id = prof_dump_read_id(&current);
2150
2151
					in = sizeof(void *);
2152
					out = sizeof(void *) + sizeof(unsigned long);
2153
					size += out;
2154
					num_elements = prof_dump_read_u4(&current); /* number of elements */
2155
					size += sizeof(unsigned long);
2156
					ty = prof_dump_read_u1(&current);/* element type */
2157
					size += sizeof(unsigned char);
2158
2159
                    objectHashEntry = dumpGetObject(obj_id);
2160
2161
                    if(objectHashEntry) {
2162
/* Removed for bug 46787
2163
						if(OBJECT_ENTRY(objectHashEntry)->heapDumpIndex <  _heapDumpInfo.index) {
2164
*/
2165
                        if(OBJECT_ENTRY(objectHashEntry)->heapDumpIndex == 0) {
2166
						    OBJECT_ENTRY(objectHashEntry)->heapDumpIndex =  _heapDumpInfo.index;
2167
					    }
2168
2169
					    outputPrimativeArray(tps, objectHashEntry);
2170
                    }
2171
2172
2173
					if(event->u.heap_dump.dump_level == JVMPI_DUMP_LEVEL_2) /* elements */
2174
					{
2175
					  switch (ty)
2176
					  {
2177
						case JVMPI_BYTE:
2178
						case JVMPI_BOOLEAN:
2179
							in = num_elements * 1;
2180
							out = in;
2181
							size += out;
2182
							current+=in;
2183
							break;
2184
						case JVMPI_SHORT:
2185
						case JVMPI_CHAR:
2186
							in = num_elements * 2;
2187
							out = in;
2188
							size += out;
2189
							current+=in;
2190
							break;
2191
						case JVMPI_FLOAT:
2192
						case JVMPI_INT:
2193
							in = num_elements * 4;
2194
							out = in;
2195
							size += out;
2196
							current+=in;
2197
							break;
2198
						case JVMPI_DOUBLE:
2199
						case JVMPI_LONG:
2200
							in = num_elements * 8;
2201
							out = in;
2202
							size += out;
2203
							current+=in;
2204
							break;
2205
					  }
2206
					}
2207
					break;
2208
				}
2209
			default:
2210
				{
2211
					break;
2212
				}
2213
			}
2214
	}
2215
2216
}
2217
#ifdef _WIN32
2218
#pragma optimize ( "", on )
2219
#endif
2220
/* PR */
2221
/*************************************************************************************/
2222
2223
2224
/* Allocates an entry in the symbol table for the object
2225
   ##RKD:  Must hold the write lock before invoking
2226
*/
2227
HashEntry * jvmpiAgent_CreateObjectSymbol(JVMPI_Event *event,
2228
                                          BOOL allocatedOnTracedStackframe,
2229
                                          BOOL allocationEventSeen)
2230
{
2231
 HashEntry *classHashEntry;
2232
 HashEntry *objectHashEntry;
2233
 ObjectEntry *objectEntry;
2234
 ObjectHashKey *k; 
2235
2236
 /* ##RKD:  We know these when we are called, should hand as params.  Also
2237
            if the class_id is zero this is an array object and we dont set
2238
			the classHashEntry pointer as we don't know the class type.
2239
 */
2240
 if(event->u.obj_alloc.class_id) {
2241
	 classHashEntry=jvmpiAgent_FindClassSymbol(event->u.obj_alloc.class_id);
2242
 }
2243
 else {
2244
     classHashEntry=jvmpiAgent_getPrimativeClassEntry(event->u.obj_alloc.is_array);
2245
 }
2246
2247
 k = (ObjectHashKey *)jvmpiAgent_Calloc(sizeof(ObjectHashKey)); 
2248
 k->id = event->u.obj_alloc.obj_id; 
2249
 objectHashEntry = jvmpiAgent_CreateSymbol((void*)k);
2250
2251
 /* Allocate and copy the event data into the symbol table structure */
2252
 objectHashEntry->entry = (ObjectEntry*)jvmpiAgent_Calloc(sizeof(ObjectEntry));
2253
 objectEntry = OBJECT_ENTRY(objectHashEntry);
2254
2255
 /* RKD: Indicate if this object is being traced or not based upon it's class object.  We don't
2256
    trace arrays.
2257
 */
2258
 if(classHashEntry) {
2259
	objectEntry->traceFlag=CLASS_ENTRY(classHashEntry)->traceFlag;
2260
 }
2261
2262
 /* Initially this class is not a class object, the classLoad event may change these later */
2263
 objectEntry->classObject=0;
2264
 objectEntry->classHashEntry2=NULL;
2265
2266
 objectEntry->heapDumpIndex=0;
2267
2268
 objectEntry->classHashEntry = classHashEntry;      /* Set a pointer back to the containing class */
2269
 objectEntry->is_array = (event->u.obj_alloc.is_array==JVMPI_NORMAL_OBJECT?0:1) ;        /* JVMPI_NORMAL_OBJECT, ... */
2270
 objectEntry->size =     event->u.obj_alloc.size;            /* size in number of bytes */
2271
 objectEntry->static_id = ++_staticIdCount;
2272
2273
 /*##MW There is a race condition between the increment and the copy that must be fixed */
2274
 jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
2275
 jvmpiAgent_copySegmentedValue(&objectEntry->collation, &_jvmpiAgent_collation);
2276
2277
 insertSymbol(&_objectHashtable, objectHashEntry);
2278
2279
 return objectHashEntry;
2280
}
2281
2282
2283
/* Allocates an entry in the symbol table for the class */
2284
HashEntry * jvmpiAgent_CreateClassSymbol(JVMPI_Event *event, ThreadLocalStorage *tps, Filter *filterInfo) {
2285
	int i, exceptionOccurred=0;
2286
	HashEntry *hashEntry;
2287
	ClassEntry *classEntry;
2288
	HashEntry *classObjectEntry;
2289
	ClassHashKey *k; 
2290
2291
    jstring currClassName;
2292
	jobject currentClass;
2293
	jclass javaClazz;
2294
2295
2296
	/* RKD:  Look for our class object.  This should always be there except with java.lang.Class */
2297
	classObjectEntry=jvmpiAgent_FindObjectSymbol(event->u.class_load.class_id);
2298
2299
	/* AM: This block of code will ensure that a class symbol is not created more than once for the same class */
2300
	if (hashEntry = jvmpiAgent_FindClassSymbol (event->u.class_load.class_id))
2301
	{
2302
		/* In case the stored class symbol did not have a resolved classObjectEntry, then try to
2303
		 * resolve now */
2304
		
2305
		if (!CLASS_ENTRY(hashEntry)->classObject)
2306
		{
2307
			if (classObjectEntry)
2308
			{ CLASS_ENTRY(hashEntry)->classObject = classObjectEntry; }
2309
			else
2310
			{
2311
				/* Try and request our class object */
2312
				REQUEST_EVENT2(JVMPI_EVENT_OBJECT_ALLOC, event->u.class_load.class_id); /* 232010 */
2313
				CLASS_ENTRY(hashEntry)->classObject = jvmpiAgent_FindObjectSymbol(event->u.class_load.class_id);
2314
			}
2315
		}
2316
2317
		return hashEntry;
2318
	}
2319
2320
	k = (ClassHashKey *)jvmpiAgent_Calloc(sizeof(ClassHashKey)); 
2321
	k->id=event->u.class_load.class_id; 
2322
	hashEntry = jvmpiAgent_CreateSymbol((void *)k);
2323
2324
	/* Allocate and copy the event data into the symbol table structure */
2325
	hashEntry->entry  = (ClassEntry*)jvmpiAgent_Calloc(sizeof(ClassEntry));
2326
	classEntry = CLASS_ENTRY(hashEntry);
2327
2328
2329
	/* Lookup the filter information for this class */
2330
    classEntry->traceFlag = jvmpiAgent_getClassFilterMode(filterInfo);
2331
2332
	/* This is not a primitive array class */
2333
	classEntry->arrayClass = 0;
2334
2335
	/* 235601 begins */
2336
	classEntry->className = "";
2337
	classEntry->sourceName = "";
2338
    classEntry->classLoaderName = "";
2339
    classEntry->nameOfInterfaces = "";
2340
	if(event->u.class_load.class_name) {
2341
		STRDUP(classEntry->className, event->u.class_load.class_name);
2342
	}
2343
	if(event->u.class_load.source_name) {
2344
		STRDUP(classEntry->sourceName, event->u.class_load.source_name);
2345
	}
2346
   else {
2347
      /* create blank source name */
2348
	   STRDUP(classEntry->sourceName, "");
2349
   }
2350
	/* 235601 ends */
2351
2352
	classEntry->numInterfaces = event->u.class_load.num_interfaces;
2353
	classEntry->numMethods    = event->u.class_load.num_methods;
2354
	classEntry->numStaticFields   = event->u.class_load.num_static_fields;
2355
2356
	if (classEntry->numStaticFields > 0) {
2357
		/* Create and fill the static field array */
2358
		classEntry->statics = (PI_Field *) jvmpiAgent_Calloc(sizeof(PI_Field) * classEntry->numStaticFields);
2359
		for (i=0; i<classEntry->numStaticFields; i++) {
2360
            STRDUP(classEntry->statics[i].field_name , event->u.class_load.statics[i].field_name);
2361
			STRDUP(classEntry->statics[i].field_signature, event->u.class_load.statics[i].field_signature);
2362
			classEntry->statics[i].fieldId = ++_fieldIdCount;
2363
		}
2364
	}
2365
2366
	classEntry->numInstanceFields = event->u.class_load.num_instance_fields;
2367
	if (classEntry->numInstanceFields > 0)  {
2368
		/* Create and fill the instance field array */
2369
		classEntry->instances = (PI_Field *) jvmpiAgent_Calloc(sizeof(PI_Field) * classEntry->numInstanceFields);
2370
		for (i=0; i<classEntry->numInstanceFields; i++) {
2371
			STRDUP(classEntry->instances[i].field_name, event->u.class_load.instances[i].field_name);
2372
			STRDUP(classEntry->instances[i].field_signature, event->u.class_load.instances[i].field_signature);
2373
			classEntry->instances[i].fieldId = ++_fieldIdCount;
2374
		}
2375
	}
2376
2377
	classEntry->classId = event->u.class_load.class_id;
2378
2379
	/*##MW There is a race condition between the increment and the copy that must be fixed */
2380
	jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
2381
	jvmpiAgent_copySegmentedValue(&classEntry->collation, &_jvmpiAgent_collation);
2382
2383
2384
	/* Get the class object of the current class only if the proper option is set */
2385
	if (_jvmpiAgent_Options.classLoadDetails || _jvmpiAgent_Options.methodDetails)
2386
	{
2387
		char *clazzName = classEntry->className;
2388
		
2389
		/* Disable events on the current thread */
2390
		tps->disableEventsForThisThread=1;
2391
2392
		/* Change the delimiter if IBMs JDK is being used */
2393
		if (_setPathDelimiter == '/')
2394
		{ swapDelimiters(clazzName); }
2395
		
2396
		/* Clear any previous exceptions that may have occurred previously */
2397
		CLEAR_EXCEPTIONS(event->env_id);
2398
2399
		currClassName = CREATE_JSTRING(event->env_id, classEntry->className);
2400
		currentClass = 0;
2401
2402
2403
		/* Set the required variables that will need to be cached */
2404
		if (!isCachedVarsSet)
2405
		{
2406
			isCachedVarsSet = 1;
2407
2408
			/* Variables common to both class and method detail */			
2409
			if (javaClazz = FIND_CLASS(event->env_id, "java/lang/Class")) {
2410
				javaClass = (jclass)(ENV(event->env_id)->NewGlobalRef(ENVPARM(event->env_id) javaClazz));
2411
				forNameID = GET_SMETHODID(event->env_id, javaClass, "forName", "(Ljava/lang/String;)Ljava/lang/Class;");
2412
				getNameID = GET_METHODID(event->env_id, javaClass, "getName", "()Ljava/lang/String;");
2413
			}
2414
2415
			/* Variables specific to method detail */
2416
			if (_jvmpiAgent_Options.methodDetails && javaClass)
2417
			{
2418
2419
				if (javaClazz = (jclass)FIND_CLASS(event->env_id, "java/lang/reflect/Method"))
2420
				{
2421
					methodClass = (jclass)(ENV(event->env_id)->NewGlobalRef(ENVPARM(event->env_id) javaClazz));
2422
					getModifiersID = GET_METHODID(event->env_id, methodClass, "getModifiers", "()I");
2423
					getExceptionTypesID = GET_METHODID(event->env_id, methodClass, "getExceptionTypes", "()[Ljava/lang/Class;");
2424
				}
2425
				
2426
				getDeclaredMethodID = GET_METHODID(event->env_id, javaClass, "getDeclaredMethod", "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;");				
2427
				exceptionNames = (char *) malloc (MAX_EXCEPTION_LENGTH);
2428
				parameters = (char *) malloc (MAX_PARAM_NAME);
2429
				tmpStorage = (char *) malloc (MAX_PARAM_NAME);
2430
				param = (char **) malloc (sizeof (char *) * MAX_PARAM);
2431
				
2432
				if (javaClazz = (jclass)FIND_CLASS(event->env_id, "java/lang/reflect/Modifier"))
2433
				{
2434
					modifierClass = (jclass)(ENV(event->env_id)->NewGlobalRef(ENVPARM(event->env_id) javaClazz));
2435
					isPublicID = GET_SMETHODID(event->env_id, modifierClass, "isPublic", "(I)Z");
2436
					isProtectedID = GET_SMETHODID(event->env_id, modifierClass, "isProtected", "(I)Z");
2437
					isPrivateID = GET_SMETHODID(event->env_id, modifierClass, "isPrivate", "(I)Z");
2438
					isAbstractID = GET_SMETHODID(event->env_id, modifierClass, "isAbstract", "(I)Z");
2439
					isNativeID = GET_SMETHODID(event->env_id, modifierClass, "isNative", "(I)Z");
2440
					isSynchronizedID = GET_SMETHODID(event->env_id, modifierClass, "isSynchronized", "(I)Z");
2441
					isStaticID = GET_SMETHODID(event->env_id, modifierClass, "isStatic", "(I)Z");					
2442
				}
2443
			}
2444
2445
			/* Variables specific to the class detail */
2446
			if (_jvmpiAgent_Options.classLoadDetails && javaClass)
2447
			{
2448
				getClassLoaderID = GET_METHODID(event->env_id, javaClass, "getClassLoader", "()Ljava/lang/ClassLoader;");
2449
				getClassID = GET_METHODID(event->env_id, javaClass, "getClass", "()Ljava/lang/Class;");
2450
				getSuperclassID = GET_METHODID(event->env_id, javaClass, "getSuperclass", "()Ljava/lang/Class;");
2451
				getInterfacesID = GET_METHODID(event->env_id, javaClass, "getInterfaces", "()[Ljava/lang/Class;");
2452
			}
2453
2454
2455
			/* Set isCachedVarsSet to 2 if any one of the required variables were not successfully initialized */
2456
			if (!javaClass || !forNameID || !getNameID || (_jvmpiAgent_Options.methodDetails && (!methodClass || !getDeclaredMethodID || !getModifiersID || !modifierClass ||
2457
				!isPublicID || !isProtectedID || !isPrivateID || !isAbstractID || !getExceptionTypesID)) || (_jvmpiAgent_Options.classLoadDetails && (!getClassLoaderID || !getClassID || !getSuperclassID || !getInterfacesID)))
2458
			{ isCachedVarsSet = 2; }
2459
		}
2460
2461
		
2462
		/* Make sure that javaClass and foNameMethodID were retrieved properly */
2463
		/* NOTE: This section of the code needs to be fixed.  Because if the default class loader is changed, then some classes will not be found */
2464
		if (isCachedVarsSet) {
2465
			currentClass = CALL_OBJ_SMETHOD1(event->env_id, javaClass, forNameID, currClassName);		
2466
		}
2467
2468
		/* Enable events on the current thread */
2469
		tps->disableEventsForThisThread=0;
2470
2471
	}
2472
2473
	/* For each method, create a new hash entry and add it to the method array. */
2474
	if(event->u.class_load.num_methods>0) {
2475
		JVMPI_Method *methods;
2476
		HashEntry **methodEntry;
2477
		int i;
2478
		classEntry->methods = (JVMPI_Method*)jvmpiAgent_Calloc(event->u.class_load.num_methods * sizeof(HashEntry *));
2479
		methods = event->u.class_load.methods;
2480
		methodEntry = (HashEntry **)classEntry->methods;
2481
		for (i=0; i < event->u.class_load.num_methods; i++) {
2482
			methodEntry[i] = jvmpiAgent_CreateMethodSymbol(methods, hashEntry);
2483
2484
2485
			/* A.M: Find out the detailed properties of the method if the proper option is set.
2486
			 * The properties: visibility, isNative, isAbstract, isStatic, isSynchronized, and the
2487
			 * possible exceptions that can be thrown by the method. */
2488
			if (_jvmpiAgent_Options.methodDetails)
2489
			{
2490
				jobject jcurrentMethod = 0;
2491
				jstring jmethodName = 0;
2492
				jobjectArray jparamType = 0;
2493
2494
				jint jmethodModifier = 0;
2495
2496
				jobject jmethodExceptions, currentException;
2497
				jobjectArray methodExceptions;
2498
				jsize arrayLength, counter;
2499
				jstring jexceptionName;
2500
				char *exceptionName;
2501
2502
				/* Disable events on the current thread */
2503
				tps->disableEventsForThisThread=1;
2504
2505
2506
				/* Initialize the desired fields of the method detail */
2507
				METHOD_ENTRY(methodEntry[i])->isNative = 0;
2508
				METHOD_ENTRY(methodEntry[i])->isAbstract = 0;
2509
				METHOD_ENTRY(methodEntry[i])->isStatic = 0;
2510
				METHOD_ENTRY(methodEntry[i])->isSynchronized = 0;
2511
				METHOD_ENTRY(methodEntry[i])->isPrivate = 0;
2512
				METHOD_ENTRY(methodEntry[i])->isProtected = 0;
2513
				METHOD_ENTRY(methodEntry[i])->isPublic = 0;
2514
				METHOD_ENTRY(methodEntry[i])->exceptions = NULL;
2515
2516
				
2517
				/* Skip the method detail if in case the current class could not be found, the required variables were not cached or the class name starts with '<' */
2518
				if (!currentClass || !isCachedVarsSet || isCachedVarsSet == 2 || METHOD_ENTRY(methodEntry[i])->methodData.method_name[0] == '<')
2519
				{ goto SKIP_METHOD_DETAIL; }
2520
2521
2522
				/* Allocate Space */
2523
				exceptionNames[0] = '\0';
2524
2525
				/* Get the java representation of the method name for the current method */
2526
				jmethodName = CREATE_JSTRING(event->env_id, METHOD_ENTRY(methodEntry[i])->methodData.method_name);
2527
2528
				/* Find the parameter type of the current method */
2529
				jparamType = findParamType (event, METHOD_ENTRY(methodEntry[i])->methodData.method_signature, &exceptionOccurred);
2530
2531
				/* An Exception has occured while attempting to get the param type of the current method */
2532
				if (jparamType == (int)NULL && exceptionOccurred) {
2533
					CLEAR_EXCEPTIONS(event->env_id);
2534
					goto SKIP_METHOD_DETAIL;
2535
				}
2536
2537
				if (jmethodName)
2538
				{ jcurrentMethod = CALL_OBJ_METHOD2(event->env_id, currentClass, getDeclaredMethodID, jmethodName, jparamType); }
2539
				
2540
				if (CHECK_EXCEPTION(event->env_id)) {
2541
					CLEAR_EXCEPTIONS(event->env_id);
2542
					goto SKIP_METHOD_DETAIL;
2543
				}
2544
2545
2546
				/* Get the method modifier */
2547
				if (jcurrentMethod)
2548
					{ jmethodModifier = ENV(event->env_id)->CallIntMethod(ENVPARM(event->env_id) jcurrentMethod, getModifiersID); }
2549
2550
			
2551
				/* Note: The following seven JNI calls can be avoided by analyzing the modifier using the 'log' function
2552
				 * with base two */
2553
2554
				/* Find the visibility of the method */				
2555
				if (jmethodModifier)
2556
				{
2557
					if(ENV(event->env_id)->CallStaticBooleanMethod(ENVPARM(event->env_id) modifierClass, isPublicID, jmethodModifier))
2558
						{ METHOD_ENTRY(methodEntry[i])->isPublic=1;}
2559
					else if(ENV(event->env_id)->CallStaticBooleanMethod(ENVPARM(event->env_id) modifierClass, isPrivateID, jmethodModifier))
2560
						{ METHOD_ENTRY(methodEntry[i])->isPrivate=1; }
2561
					else if (ENV(event->env_id)->CallStaticBooleanMethod(ENVPARM(event->env_id) modifierClass, isProtectedID, jmethodModifier))
2562
						{ METHOD_ENTRY(methodEntry[i])->isProtected=1; }
2563
				}
2564
2565
2566
				/* Attempt to find if the method is native, abstract, static and/or synchronized */
2567
				METHOD_ENTRY(methodEntry[i])->isNative = (ENV(event->env_id)->CallStaticBooleanMethod(ENVPARM(event->env_id) modifierClass, isNativeID, jmethodModifier) ? 1 : 0);
2568
				METHOD_ENTRY(methodEntry[i])->isAbstract = (ENV(event->env_id)->CallStaticBooleanMethod(ENVPARM(event->env_id) modifierClass, isAbstractID, jmethodModifier) ? 1 : 0);
2569
				METHOD_ENTRY(methodEntry[i])->isStatic = (ENV(event->env_id)->CallStaticBooleanMethod(ENVPARM(event->env_id) modifierClass, isStaticID, jmethodModifier) ? 1 : 0);
2570
				METHOD_ENTRY(methodEntry[i])->isSynchronized = (ENV(event->env_id)->CallStaticBooleanMethod(ENVPARM(event->env_id) modifierClass, isSynchronizedID, jmethodModifier) ? 1 : 0);
2571
2572
2573
				/* Find the possible exceptions that the method can throw */
2574
				if (jcurrentMethod)
2575
				{
2576
					jmethodExceptions = CALL_OBJ_METHOD0(event->env_id, jcurrentMethod, getExceptionTypesID);
2577
					if (jmethodExceptions)
2578
					{
2579
						methodExceptions = (jobjectArray) jmethodExceptions;
2580
						arrayLength = GET_ARRAY_SIZE(event->env_id, methodExceptions);
2581
2582
						/* Step through the exceptions */
2583
						for (counter = 0; counter < arrayLength; counter++)
2584
						{
2585
							currentException = GET_ARRAY_ELEM(event->env_id, methodExceptions, counter);
2586
							
2587
							jexceptionName = CALL_OBJ_METHOD0(event->env_id, currentException, getNameID);
2588
							exceptionName = (char*)CONVERT_TO_UTF(event->env_id, jexceptionName);
2589
							if (strlen(exceptionNames) + strlen(exceptionName) >= MAX_EXCEPTION_LENGTH)
2590
								break;
2591
							if (strlen(exceptionNames) != 0)
2592
								strcat (exceptionNames, ",");
2593
							strcat (exceptionNames, exceptionName);
2594
							RELEASE_UTF_CHARS(event->env_id, jexceptionName, exceptionName);
2595
						}
2596
						STRDUP(METHOD_ENTRY(methodEntry[i])->exceptions, exceptionNames);
2597
					}
2598
				}
2599
			}
2600
			
2601
SKIP_METHOD_DETAIL:
2602
			/* Enable events on the current thread */
2603
			tps->disableEventsForThisThread=0;
2604
			methods++; /* Skip to the next method */
2605
		}
2606
	}
2607
	else {
2608
		classEntry->methods=NULL;
2609
	}
2610
	classEntry->static_id = ++_staticIdCount;
2611
	jvmpiAgent_getCurrentTime(&classEntry->timestamp);
2612
2613
	insertSymbol(&_classHashtable, hashEntry);
2614
2615
	if(!classObjectEntry) {
2616
		/* Try and request our class object */
2617
		REQUEST_EVENT2(JVMPI_EVENT_OBJECT_ALLOC, event->u.class_load.class_id); /* 232010 */
2618
		classObjectEntry=jvmpiAgent_FindObjectSymbol(event->u.class_load.class_id);
2619
	}
2620
2621
	/* If there is a class obejct for this class we need to make sure it knows it is a class object and
2622
	   set the bidirectional reference between the two.
2623
	*/
2624
	if(classObjectEntry) {
2625
		classEntry->classObject=classObjectEntry;
2626
		OBJECT_ENTRY(classObjectEntry)->classObject=1;
2627
		OBJECT_ENTRY(classObjectEntry)->classHashEntry2=hashEntry;
2628
	}
2629
	else {
2630
		classEntry->classObject=0;
2631
	}
2632
2633
2634
	/* A.M: If the class load detail option is set, then find the class loader, the
2635
	 * super class, and the interfaces implemented by this class entry.
2636
	 * Note: This should be the last block of code (Because 'return' is used in case that
2637
	 * an exception occurs) */
2638
	if (_jvmpiAgent_Options.classLoadDetails)
2639
	{
2640
		char *className, *classLoaderName, *currInterface, *interfaceNames;
2641
		jobject jclassLoader = (int)NULL, jSuperClass, jsuperClassName, jinterfaceName, obj = (int)NULL;
2642
		jobjectArray interfacesArray;
2643
		jsize count, index;
2644
		unsigned const int MAX_CHARS = 250;
2645
		int currLength = 0, counter = 0;
2646
2647
2648
		/* Disable events on the current thread */
2649
		tps->disableEventsForThisThread=1;
2650
2651
		/* Initialize the appropriate fields */
2652
		classEntry->classLoaderName = "";
2653
		classEntry->superClassName = "";
2654
		classEntry->nameOfInterfaces = "";
2655
2656
		
2657
		/* Skip class detail if the required variables could not be initialized or the currentClass was set properly */
2658
		if (!isCachedVarsSet || isCachedVarsSet == 2 || !currentClass)
2659
			{ goto SKIP_CLASS_DETAIL; }
2660
2661
		/* Allocate 250 characters for all the interface names */
2662
		interfaceNames = (char *) calloc(MAX_CHARS, 1);
2663
		className = classEntry->className;
2664
2665
		/* Get the class loader of this class entry (Equivalent to this.getClassLoader().getClass().getName()) */
2666
		jclassLoader = CALL_OBJ_METHOD0(event->env_id, currentClass, getClassLoaderID);
2667
2668
		/* Get the name of the class loader */
2669
		if (jclassLoader && !CHECK_EXCEPTION(event->env_id))
2670
		{
2671
			obj = CALL_OBJ_METHOD0(event->env_id, jclassLoader, getClassID);
2672
				
2673
			if (obj)
2674
			{
2675
				jobject tempObj;
2676
				tempObj = CALL_OBJ_METHOD0(event->env_id, obj, getNameID);
2677
				classLoaderName = (char*)CONVERT_TO_UTF(event->env_id, tempObj);
2678
				classEntry->classLoaderName = classLoaderName;
2679
			}
2680
2681
		}
2682
		/* The previous JNI call may throw a SecurityException */
2683
		else if (CHECK_EXCEPTION(event->env_id))
2684
			{ CLEAR_EXCEPTIONS(event->env_id); }
2685
		
2686
2687
2688
		/* Get the super class */
2689
		jSuperClass = CALL_OBJ_METHOD0(event->env_id, currentClass, getSuperclassID);
2690
		
2691
		if (jSuperClass)
2692
		{
2693
			if (jsuperClassName = CALL_OBJ_METHOD0(event->env_id, jSuperClass, getNameID))
2694
				{ classEntry->superClassName = (char*)CONVERT_TO_UTF(event->env_id, jsuperClassName); }
2695
		}
2696
2697
2698
		/* Get the implemented interfaces */
2699
		interfacesArray = (jobjectArray)CALL_OBJ_METHOD0(event->env_id, currentClass, getInterfacesID);
2700
2701
		if (interfacesArray)
2702
		{
2703
			count = GET_ARRAY_SIZE(event->env_id, interfacesArray);
2704
			for (index = 0; index < count; index++)
2705
			{
2706
				/* Retreive the name of each element */
2707
				if (obj = GET_ARRAY_ELEM(event->env_id, interfacesArray, index))
2708
				{
2709
					jinterfaceName = CALL_OBJ_METHOD0(event->env_id, obj, getNameID);
2710
			
2711
					/* Convert to UTF-8, and print the string.  Flush the buffer afterwards */
2712
					currInterface = (char*)CONVERT_TO_UTF(event->env_id, jinterfaceName);
2713
2714
					if ((currLength + strlen(currInterface) + 2) > MAX_CHARS)
2715
						{ break; }
2716
					else
2717
					{
2718
						if (strlen(interfaceNames) != 0)
2719
							strcat (interfaceNames, ",");
2720
						strcat (interfaceNames, currInterface);
2721
					}
2722
					RELEASE_UTF_CHARS(event->env_id, jinterfaceName, currInterface);
2723
				}
2724
				classEntry->nameOfInterfaces = interfaceNames;
2725
			}
2726
		}
2727
	}
2728
2729
SKIP_CLASS_DETAIL:
2730
	/* Enable events on the current thread */
2731
	tps->disableEventsForThisThread=0;
2732
2733
	return hashEntry;
2734
}
2735
2736
/**
2737
 * The following helper function is used to determine the parameter types of a method based on
2738
 * its specified signature.
2739
 *
2740
 * Prerequisite: 'methodSignature' is a valid string (i.e. It contains a null terminator).
2741
 *				 'methodSignature' is in the expected form of a method signature (i.e. (param)return).
2742
 *
2743
 * @param methodSignature - The signature of the method
2744
 * @param event			  - The event leading to the invokation of this function
2745
 * @param exceptionOccured- Nonzero if an exception did occured while attempting to find the parameter type
2746
 * @return jobject - A Class[] representing the parameter types of the method
2747
 */
2748
2749
jobjectArray findParamType(JVMPI_Event *event, char *methodSignature, int *exceptionOccurred)
2750
{
2751
	char successiveChar;
2752
	unsigned int index, paramIndex, tmpStorageIndex, counter;
2753
2754
	jobjectArray jlangClassArray;
2755
	jstring currClassName;
2756
	jobject current_Class;
2757
2758
2759
	/* Extract the prameter from the signature */
2760
	for (index = 0; methodSignature[index] != ')' && index < strlen(methodSignature); index++);
2761
	
2762
	strncpy (parameters, methodSignature + 1, index);
2763
	parameters[index - 1] = '\0';
2764
2765
2766
	/* Store the individual parameters in the string array 'param' */
2767
	if (!parameters || strlen(parameters) == 0)
2768
	{
2769
		return (int)NULL;
2770
	}
2771
2772
	
2773
	index = 0, paramIndex = 0, tmpStorageIndex = 0, counter = 0;
2774
2775
2776
	while (parameters[index] != '\0')
2777
	{
2778
		param[paramIndex] = (char *) malloc (MAX_PARAM_NAME);
2779
		switch (parameters[index])
2780
		{
2781
			/* Boolean */
2782
			case 'Z':
2783
				param[paramIndex] = ">java/lang/Boolean";
2784
				paramIndex++;
2785
				break;
2786
			/* Byte */
2787
			case 'B':
2788
				param[paramIndex] = ">java/lang/Byte";
2789
				paramIndex++;
2790
				break;
2791
			/* Char */
2792
			case 'C':
2793
				param[paramIndex] = ">java/lang/Character";
2794
				paramIndex++;
2795
				break;
2796
			/* Short */
2797
			case 'S':
2798
				param[paramIndex] = ">java/lang/Short";
2799
				paramIndex++;
2800
				break;
2801
			/* Int */
2802
			case 'I':
2803
				param[paramIndex] = ">java/lang/Integer";
2804
				paramIndex++;
2805
				break;
2806
			/* Long */
2807
			case 'J':
2808
				param[paramIndex] = ">java/lang/Long";
2809
				paramIndex++;
2810
				break;
2811
			/* Float */
2812
			case 'F':
2813
				param[paramIndex] = ">java/lang/Float";
2814
				paramIndex++;
2815
				break;
2816
			/* Double */
2817
			case 'D':
2818
				param[paramIndex] = ">java/lang/Double";
2819
				paramIndex++;
2820
				break;
2821
			/* Complex Object */
2822
			case 'L':
2823
				counter = 0;
2824
				for (tmpStorageIndex = ++index; parameters[tmpStorageIndex] != ';'; tmpStorageIndex++)
2825
				{
2826
					/* Change the delimiter */
2827
					if (parameters[tmpStorageIndex] == '/')
2828
						tmpStorage[counter] = '.';
2829
					else
2830
						tmpStorage[counter] = parameters[tmpStorageIndex];
2831
					counter++;
2832
					index++;
2833
				}
2834
				tmpStorage[counter] = '\0';
2835
				strcpy (param[paramIndex], tmpStorage);
2836
				paramIndex++;
2837
				break;
2838
			/* Arrays */
2839
			case '[':
2840
2841
				/* Multi-dimensional array */
2842
				counter = 0;
2843
				while (parameters[index] == '[')
2844
				{
2845
					tmpStorage[counter] = parameters[index];
2846
					index++; counter++;
2847
				}
2848
2849
2850
				successiveChar = parameters[index];
2851
2852
				/* Primitive Array */
2853
				if (successiveChar == 'Z' || successiveChar == 'B' || successiveChar == 'C' || successiveChar == 'S' ||
2854
					successiveChar == 'I' || successiveChar == 'J' || successiveChar == 'F' || successiveChar == 'D')
2855
				{
2856
					tmpStorage[counter] = successiveChar; tmpStorage[counter + 1] = '\0';
2857
				}
2858
				/* Complex Array */
2859
				else
2860
				{
2861
					for (tmpStorageIndex = index; parameters[tmpStorageIndex] != ';'; tmpStorageIndex++)
2862
					{
2863
						/* Change the delimiter */
2864
						if (parameters[tmpStorageIndex] == '/')
2865
							tmpStorage[counter] = '.';
2866
						else
2867
							tmpStorage[counter] = parameters[tmpStorageIndex];
2868
2869
						counter++;
2870
						index++;
2871
					}
2872
					tmpStorage[counter] = parameters[tmpStorageIndex];
2873
					tmpStorage[counter + 1] = '\0';
2874
				}
2875
2876
				strcpy (param[paramIndex], tmpStorage);
2877
				paramIndex++;
2878
		}
2879
		index++;
2880
2881
	}
2882
2883
	/* Create the java class array and its elements */
2884
	jlangClassArray = NEW_ARRAY(event->env_id, paramIndex, javaClass, (int)NULL);
2885
	
2886
	/* Begin Creating the classes and adding them to the jlangClassArray */
2887
	for (index = 0; index < paramIndex; index++)
2888
	{
2889
		current_Class = 0;
2890
2891
		/* If the parameter name begins with '>', then it is a primitive type */
2892
		if	(param[index][0] == '>')
2893
		{
2894
			jclass currClass;
2895
			jfieldID fieldID;
2896
2897
			if (currClass = FIND_CLASS(event->env_id, param[index] + 1))
2898
				if (fieldID = GET_SFIELDID(event->env_id, currClass, "TYPE", "Ljava/lang/Class;"))
2899
					current_Class = GET_SFIELD(event->env_id, currClass, fieldID);
2900
			
2901
		}
2902
2903
		/* The parameter is a complex type */
2904
		else
2905
		{
2906
			/* Get the class representation of the current parameter */
2907
			currClassName = CREATE_JSTRING(event->env_id, param[index]);
2908
			current_Class = CALL_OBJ_SMETHOD1(event->env_id, javaClass, forNameID, currClassName);
2909
		}
2910
2911
		/* Add the found class representation to the class array */
2912
		if (current_Class)
2913
		{	ADD_TO_ARRAY(event->env_id, jlangClassArray, index, current_Class); }
2914
		else
2915
		{	/* Something has gone wrong.  Abort */
2916
			*exceptionOccurred = 1; jlangClassArray = 0; break;
2917
		}
2918
	}
2919
2920
2921
	return jlangClassArray;
2922
2923
}
2924
2925
2926
/* Used to swap the delimiter of 'name' from '.' to '\' or vice-versa */
2927
void swapDelimiters (char *name)
2928
{
2929
	int i;
2930
	for (i = 0; i < (int)strlen (name); i++)
2931
	{
2932
		if (name[i] == '.')
2933
			name[i] = '/';
2934
		else if (name[i] == '/')
2935
			name[i] = '.';
2936
	}
2937
}
2938
2939
2940
#ifdef _DEBUG
2941
2942
unsigned int jvmpiAgent_getHashTableEntryCount(enum EntryType entryType)
2943
{
2944
 switch(entryType)
2945
 {
2946
  case Class_t:  return _classHashtable.entryCount; break;
2947
  case Method_t: return _methodHashtable.entryCount; break;
2948
  case Object_t: return _objectHashtable.entryCount; break;
2949
  case Thread_t: return _threadHashtable.entryCount; break;
2950
  default: return 0;
2951
 }
2952
2953
}
2954
2955
void jvmpiAgent_DumpHashTableStatistics()
2956
{
2957
2958
 int j;
2959
 FILE * f;
2960
 f = fopen("heapStatistics.txt", "w");
2961
 for(j=0; j<4; j++)
2962
 {
2963
  unsigned int i;
2964
  Hashtable *table;
2965
  int emptyChains = 0;
2966
  int totalEntries = 0;
2967
  int longestChain = 0;
2968
  int averageChain = 0;
2969
  switch(j)
2970
  {
2971
   case 0:table=&_classHashtable; fprintf(f,"\nCLASS "); break;
2972
   case 1:table=&_methodHashtable; fprintf(f,"\nMETHOD "); break;
2973
   case 2:table=&_objectHashtable; fprintf(f,"\nOBJECT "); break;
2974
   case 3:table=&_threadHashtable; fprintf(f,"\nTHREAD "); break;
2975
  }
2976
  for (i = 0; i < table->size; i++)
2977
  {
2978
   if (table->entries[i].activeQ == NULL)
2979
   {
2980
    emptyChains++;
2981
   }
2982
   else
2983
   {
2984
    int depth = 0;
2985
    volatile HashEntry *p;
2986
    for (p = table->entries[i].activeQ; p != NULL; p = p->next)
2987
	{
2988
     depth++;
2989
     totalEntries++;
2990
    }
2991
    if (depth > longestChain)
2992
	{
2993
     longestChain = depth;
2994
	}
2995
   }
2996
  }
2997
  fprintf(f,"Hash Table Statistics\n\n");
2998
  fprintf(f,"Hash Table Size = %d\n", table->size);
2999
  fprintf(f,"Empty chains = %d\n", emptyChains);
3000
  fprintf(f,"Total entries = %d\n", totalEntries);
3001
  fprintf(f,"Average chain depth = %f\n", totalEntries/(double)table->size);
3002
  fprintf(f,"Longest chain depth = %d\n", longestChain);
3003
  fprintf(f,"Total number of Symbol Lookups = %d\n", table->findSymbolCount);
3004
  fprintf(f,"Number of successful symbol lookups = %d\n", table->findSymbolFound);
3005
  fprintf(f,"Number of unsuccessful symbol lookups = %d\n", table->findSymbolNotFound);
3006
  fprintf(f,"Number of hash hits = %d (%f%%)\n", table->hashHitCount, table->hashHitCount/(double)table->findSymbolCount * 100);
3007
  fprintf(f,"Number of hash misses = %d (%f%%)\n", table->hashMissCount, table->hashMissCount/(double)table->findSymbolCount * 100);
3008
  fprintf(f,"Average miss length = %f\n", (table)->hashMissCount ? table->hashMissLength/(double)table->hashMissCount: (double)0);
3009
  fprintf(f,"Total Created Symbols = %d\n", table->createCount);
3010
  fprintf(f,"Total Deleted Symbols = %d\n", table->deleteCount);
3011
  fprintf(f,"Total Moved Symbols = %d\n", table->moveCount);
3012
  fprintf(f,"\n\n");
3013
 }
3014
 fclose(f);
3015
}
3016
#endif
3017
(-)src-native-new/src/agents/thread/hcthread.def (+9 lines)
Added Link Here
1
LIBRARY hcthread
2
DESCRIPTION "Externalized Thread Analyzer API"
3
EXPORTS
4
	Java_org_eclipse_hyades_logging_jvm_threadanalysis_ThreadDumpAgentImpl_init0 @1
5
	Java_org_eclipse_hyades_logging_jvm_threadanalysis_ThreadDumpAgentImpl_dumpThreads0 @2
6
	Java_org_eclipse_hyades_logging_jvm_threadanalysis_ThreadDumpAgentImpl_deregister0 @3
7
	init @4
8
	dump @5
9
	deregister @6
(-)src-native-new/src/agents/java/WinBuild/log_agent.mak64 (+396 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on log_agent.dsp
2
!IF "$(CFG)" == ""
3
CFG=log_agent - IA64 Debug
4
!MESSAGE No configuration specified. Defaulting to log_agent - IA64 Debug.
5
!ENDIF 
6
7
!IF "$(CFG)" != "log_agent - IA64 Release" && "$(CFG)" != "log_agent - IA64 Debug" && "$(CFG)" != "log_agent - X64 Release" && "$(CFG)" != "log_agent - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "log_agent.mak64" CFG="log_agent - IA64 Debug"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "log_agent - IA64 Release"
17
!MESSAGE "log_agent - IA64 Debug"
18
!MESSAGE "log_agent - X64 Release"
19
!MESSAGE "log_agent - X64 Debug"
20
!MESSAGE 
21
!ERROR An invalid configuration is specified.
22
!ENDIF 
23
24
!IF "$(OS)" == "Windows_NT"
25
NULL=
26
!ELSE 
27
NULL=nul
28
!ENDIF 
29
30
!IF  "$(CFG)" == "log_agent - IA64 Release"
31
32
OUTDIR=..\..\..\..\bin
33
INTDIR=.\Release
34
# Begin Custom Macros
35
OutDir=..\..\..\..\bin
36
# End Custom Macros
37
38
ALL : "$(OUTDIR)\hcjbnd.dll"
39
40
41
CLEAN :
42
	-@erase "$(INTDIR)\hcjbnd.obj"
43
	-@erase "$(INTDIR)\hcjbnd.res"
44
	-@erase "$(INTDIR)\vc60.idb"
45
	-@erase "$(OUTDIR)\hcjbnd.dll"
46
	-@erase "$(OUTDIR)\..\lib\hcjbnd.exp"
47
	-@erase "$(OUTDIR)\..\lib\hcjbnd.lib"
48
	-@erase ".\Release\hcjbnd.map"
49
50
"$(OUTDIR)" :
51
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
52
53
"$(INTDIR)" :
54
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
55
56
CPP=cl.exe
57
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /Ob0 /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LOG_AGENT_EXPORTS" /Fp"$(INTDIR)\log_agent.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
58
59
.c{$(INTDIR)}.obj::
60
   $(CPP) @<<
61
   $(CPP_PROJ) $< 
62
<<
63
64
.cpp{$(INTDIR)}.obj::
65
   $(CPP) @<<
66
   $(CPP_PROJ) $< 
67
<<
68
69
.cxx{$(INTDIR)}.obj::
70
   $(CPP) @<<
71
   $(CPP_PROJ) $< 
72
<<
73
74
.c{$(INTDIR)}.sbr::
75
   $(CPP) @<<
76
   $(CPP_PROJ) $< 
77
<<
78
79
.cpp{$(INTDIR)}.sbr::
80
   $(CPP) @<<
81
   $(CPP_PROJ) $< 
82
<<
83
84
.cxx{$(INTDIR)}.sbr::
85
   $(CPP) @<<
86
   $(CPP_PROJ) $< 
87
<<
88
89
MTL=midl.exe
90
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
91
RSC=rc.exe
92
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcjbnd.res" /d "NDEBUG" 
93
94
LINK32=link.exe
95
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib /nologo /version:0.1 /dll /incremental:no /pdb:"$(OUTDIR)\hcjbnd.pdb" /map:"$(INTDIR)\hcjbnd.map" /def:"..\hcjbnd.def" /out:"$(OUTDIR)\hcjbnd.dll" /implib:"$(OUTDIR)\..\lib\hcjbnd.lib" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
96
LINK32_OBJS= \
97
	"$(OUTDIR)\..\lib\hcclco.lib" \
98
	"$(OUTDIR)\..\lib\hccls.lib" \
99
	"$(OUTDIR)\..\lib\hcclsm.lib" \
100
	"$(OUTDIR)\..\lib\hccldt.lib" \
101
	"$(OUTDIR)\..\lib\hcbnd.lib" \
102
	"$(INTDIR)\hcjbnd.obj" \
103
	"$(INTDIR)\hcjbnd.res"
104
105
"$(OUTDIR)\hcjbnd.dll" : "$(OUTDIR)" $(LINK32_OBJS)
106
    $(LINK32) @<<
107
  $(LINK32_FLAGS) $(LINK32_OBJS)
108
<<
109
110
!ELSEIF  "$(CFG)" == "log_agent - IA64 Debug"
111
112
OUTDIR=..\..\..\..\bin
113
INTDIR=.\Debug
114
# Begin Custom Macros
115
OutDir=..\..\..\..\bin
116
# End Custom Macros
117
118
ALL : "$(OUTDIR)\hcjbnd.dll"
119
120
121
CLEAN :
122
	-@erase "$(INTDIR)\hcjbnd.obj"
123
	-@erase "$(INTDIR)\hcjbnd.res"
124
	-@erase "$(INTDIR)\vc60.idb"
125
	-@erase "$(INTDIR)\vc60.pdb"
126
	-@erase "$(OUTDIR)\hcjbnd.dll"
127
	-@erase "$(OUTDIR)\..\lib\hcjbnd.exp"
128
	-@erase "$(OUTDIR)\..\lib\hcjbnd.ilk"
129
	-@erase "$(OUTDIR)\..\lib\hcjbnd.lib"
130
	-@erase "$(OUTDIR)\..\lib\hcjbnd.pdb"
131
132
"$(OUTDIR)" :
133
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
134
135
"$(INTDIR)" :
136
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
137
138
CPP=cl.exe
139
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LOG_AGENT_EXPORTS" /Fp"$(INTDIR)\log_agent.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
140
141
.c{$(INTDIR)}.obj::
142
   $(CPP) @<<
143
   $(CPP_PROJ) $< 
144
<<
145
146
.cpp{$(INTDIR)}.obj::
147
   $(CPP) @<<
148
   $(CPP_PROJ) $< 
149
<<
150
151
.cxx{$(INTDIR)}.obj::
152
   $(CPP) @<<
153
   $(CPP_PROJ) $< 
154
<<
155
156
.c{$(INTDIR)}.sbr::
157
   $(CPP) @<<
158
   $(CPP_PROJ) $< 
159
<<
160
161
.cpp{$(INTDIR)}.sbr::
162
   $(CPP) @<<
163
   $(CPP_PROJ) $< 
164
<<
165
166
.cxx{$(INTDIR)}.sbr::
167
   $(CPP) @<<
168
   $(CPP_PROJ) $< 
169
<<
170
171
MTL=midl.exe
172
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
173
RSC=rc.exe
174
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcjbnd.res" /d "_DEBUG" 
175
176
LINK32=link.exe
177
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcjbnd.pdb" /debug /def:"..\hcjbnd.def" /out:"$(OUTDIR)\hcjbnd.dll" /implib:"$(OUTDIR)\..\lib\hcjbnd.lib" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
178
LINK32_OBJS= \
179
	"$(OUTDIR)\..\lib\hcclco.lib" \
180
	"$(OUTDIR)\..\lib\hccls.lib" \
181
	"$(OUTDIR)\..\lib\hcclsm.lib" \
182
	"$(OUTDIR)\..\lib\hccldt.lib" \
183
	"$(OUTDIR)\..\lib\hcbnd.lib" \
184
	"$(INTDIR)\hcjbnd.obj" \
185
	"$(INTDIR)\hcjbnd.res"
186
187
"$(OUTDIR)\hcjbnd.dll" : "$(OUTDIR)" $(LINK32_OBJS)
188
    $(LINK32) @<<
189
  $(LINK32_FLAGS) $(LINK32_OBJS)
190
<<
191
192
!ELSEIF  "$(CFG)" == "log_agent - X64 Release"
193
194
OUTDIR=..\..\..\..\bin
195
INTDIR=.\Release
196
# Begin Custom Macros
197
OutDir=..\..\..\..\bin
198
# End Custom Macros
199
200
ALL : "$(OUTDIR)\hcjbnd.dll"
201
202
203
CLEAN :
204
	-@erase "$(INTDIR)\hcjbnd.obj"
205
	-@erase "$(INTDIR)\hcjbnd.res"
206
	-@erase "$(INTDIR)\vc60.idb"
207
	-@erase "$(OUTDIR)\hcjbnd.dll"
208
	-@erase "$(OUTDIR)\..\lib\hcjbnd.exp"
209
	-@erase "$(OUTDIR)\..\lib\hcjbnd.lib"
210
	-@erase ".\Release\hcjbnd.map"
211
212
"$(OUTDIR)" :
213
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
214
215
"$(INTDIR)" :
216
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
217
218
CPP=cl.exe
219
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /Ob0 /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LOG_AGENT_EXPORTS" /Fp"$(INTDIR)\log_agent.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
220
221
.c{$(INTDIR)}.obj::
222
   $(CPP) @<<
223
   $(CPP_PROJ) $< 
224
<<
225
226
.cpp{$(INTDIR)}.obj::
227
   $(CPP) @<<
228
   $(CPP_PROJ) $< 
229
<<
230
231
.cxx{$(INTDIR)}.obj::
232
   $(CPP) @<<
233
   $(CPP_PROJ) $< 
234
<<
235
236
.c{$(INTDIR)}.sbr::
237
   $(CPP) @<<
238
   $(CPP_PROJ) $< 
239
<<
240
241
.cpp{$(INTDIR)}.sbr::
242
   $(CPP) @<<
243
   $(CPP_PROJ) $< 
244
<<
245
246
.cxx{$(INTDIR)}.sbr::
247
   $(CPP) @<<
248
   $(CPP_PROJ) $< 
249
<<
250
251
MTL=midl.exe
252
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
253
RSC=rc.exe
254
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcjbnd.res" /d "NDEBUG" 
255
256
LINK32=link.exe
257
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib /nologo /version:0.1 /dll /incremental:no /pdb:"$(OUTDIR)\hcjbnd.pdb" /map:"$(INTDIR)\hcjbnd.map" /def:"..\hcjbnd.def" /out:"$(OUTDIR)\hcjbnd.dll" /implib:"$(OUTDIR)\..\lib\hcjbnd.lib" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
258
LINK32_OBJS= \
259
	"$(OUTDIR)\..\lib\hcclco.lib" \
260
	"$(OUTDIR)\..\lib\hccls.lib" \
261
	"$(OUTDIR)\..\lib\hcclsm.lib" \
262
	"$(OUTDIR)\..\lib\hccldt.lib" \
263
	"$(OUTDIR)\..\lib\hcbnd.lib" \
264
	"$(INTDIR)\hcjbnd.obj" \
265
	"$(INTDIR)\hcjbnd.res"
266
267
"$(OUTDIR)\hcjbnd.dll" : "$(OUTDIR)" $(LINK32_OBJS)
268
    $(LINK32) @<<
269
  $(LINK32_FLAGS) $(LINK32_OBJS)
270
<<
271
272
!ELSEIF  "$(CFG)" == "log_agent - X64 Debug"
273
274
OUTDIR=..\..\..\..\bin
275
INTDIR=.\Debug
276
# Begin Custom Macros
277
OutDir=..\..\..\..\bin
278
# End Custom Macros
279
280
ALL : "$(OUTDIR)\hcjbnd.dll"
281
282
283
CLEAN :
284
	-@erase "$(INTDIR)\hcjbnd.obj"
285
	-@erase "$(INTDIR)\hcjbnd.res"
286
	-@erase "$(INTDIR)\vc60.idb"
287
	-@erase "$(INTDIR)\vc60.pdb"
288
	-@erase "$(OUTDIR)\hcjbnd.dll"
289
	-@erase "$(OUTDIR)\..\lib\hcjbnd.exp"
290
	-@erase "$(OUTDIR)\..\lib\hcjbnd.ilk"
291
	-@erase "$(OUTDIR)\..\lib\hcjbnd.lib"
292
	-@erase "$(OUTDIR)\..\lib\hcjbnd.pdb"
293
294
"$(OUTDIR)" :
295
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
296
297
"$(INTDIR)" :
298
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
299
300
CPP=cl.exe
301
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LOG_AGENT_EXPORTS" /Fp"$(INTDIR)\log_agent.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
302
303
.c{$(INTDIR)}.obj::
304
   $(CPP) @<<
305
   $(CPP_PROJ) $< 
306
<<
307
308
.cpp{$(INTDIR)}.obj::
309
   $(CPP) @<<
310
   $(CPP_PROJ) $< 
311
<<
312
313
.cxx{$(INTDIR)}.obj::
314
   $(CPP) @<<
315
   $(CPP_PROJ) $< 
316
<<
317
318
.c{$(INTDIR)}.sbr::
319
   $(CPP) @<<
320
   $(CPP_PROJ) $< 
321
<<
322
323
.cpp{$(INTDIR)}.sbr::
324
   $(CPP) @<<
325
   $(CPP_PROJ) $< 
326
<<
327
328
.cxx{$(INTDIR)}.sbr::
329
   $(CPP) @<<
330
   $(CPP_PROJ) $< 
331
<<
332
333
MTL=midl.exe
334
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
335
RSC=rc.exe
336
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcjbnd.res" /d "_DEBUG" 
337
338
LINK32=link.exe
339
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcjbnd.pdb" /debug /def:"..\hcjbnd.def" /out:"$(OUTDIR)\hcjbnd.dll" /implib:"$(OUTDIR)\..\lib\hcjbnd.lib" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
340
LINK32_OBJS= \
341
	"$(OUTDIR)\..\lib\hcclco.lib" \
342
	"$(OUTDIR)\..\lib\hccls.lib" \
343
	"$(OUTDIR)\..\lib\hcclsm.lib" \
344
	"$(OUTDIR)\..\lib\hccldt.lib" \
345
	"$(OUTDIR)\..\lib\hcbnd.lib" \
346
	"$(INTDIR)\hcjbnd.obj" \
347
	"$(INTDIR)\hcjbnd.res"
348
349
"$(OUTDIR)\hcjbnd.dll" : "$(OUTDIR)" $(LINK32_OBJS)
350
    $(LINK32) @<<
351
  $(LINK32_FLAGS) $(LINK32_OBJS)
352
<<
353
354
!ENDIF 
355
356
357
!IF "$(CFG)" == "log_agent - IA64 Release" || "$(CFG)" == "log_agent - IA64 Debug" || "$(CFG)" == "log_agent - X64 Release" || "$(CFG)" == "log_agent - X64 Debug"
358
SOURCE=..\hcjbnd.c
359
360
"$(INTDIR)\hcjbnd.obj" : $(SOURCE) "$(INTDIR)"
361
	$(CPP) $(CPP_PROJ) $(SOURCE)
362
363
364
SOURCE=..\version.rc
365
366
!IF  "$(CFG)" == "log_agent - IA64 Release"
367
368
369
"$(INTDIR)\hcjbnd.res" : $(SOURCE) "$(INTDIR)"
370
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcjbnd.res" /d "NDEBUG" $(SOURCE)
371
372
373
!ELSEIF  "$(CFG)" == "log_agent - IA64 Debug"
374
375
376
"$(INTDIR)\hcjbnd.res" : $(SOURCE) "$(INTDIR)"
377
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcjbnd.res" /d "_DEBUG" $(SOURCE)
378
!ELSEIF  "$(CFG)" == "log_agent - X64 Release"
379
380
381
"$(INTDIR)\hcjbnd.res" : $(SOURCE) "$(INTDIR)"
382
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcjbnd.res" /d "NDEBUG" $(SOURCE)
383
384
385
!ELSEIF  "$(CFG)" == "log_agent - X64 Debug"
386
387
388
"$(INTDIR)\hcjbnd.res" : $(SOURCE) "$(INTDIR)"
389
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcjbnd.res" /d "_DEBUG" $(SOURCE)
390
391
392
!ENDIF 
393
394
395
!ENDIF 
396
(-)src-native-new/src/agents/thread/WinBuild/hcthread.mak (+203 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on hcthread.dsp
2
!IF "$(CFG)" == ""
3
CFG=hcthread - Win32 Debug
4
!MESSAGE No configuration specified. Defaulting to hcthread - Win32 Debug.
5
!ENDIF 
6
7
!IF "$(CFG)" != "hcthread - Win32 Release" && "$(CFG)" != "hcthread - Win32 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "hcthread.mak" CFG="hcthread - Win32 Debug"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "hcthread - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
17
!MESSAGE "hcthread - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
18
!MESSAGE 
19
!ERROR An invalid configuration is specified.
20
!ENDIF 
21
22
!IF "$(OS)" == "Windows_NT"
23
NULL=
24
!ELSE 
25
NULL=nul
26
!ENDIF 
27
28
!IF  "$(CFG)" == "hcthread - Win32 Release"
29
30
OUTDIR=.\bin
31
INTDIR=.\Release
32
# Begin Custom Macros
33
OutDir=.\bin
34
# End Custom Macros
35
36
ALL : "$(OUTDIR)\hcthread.dll"
37
38
39
CLEAN :
40
	-@erase "$(INTDIR)\hcthread.obj"
41
	-@erase "$(INTDIR)\vc60.idb"
42
	-@erase "$(OUTDIR)\hcthread.dll"
43
	-@erase "$(OUTDIR)\hcthread.exp"
44
	-@erase "$(OUTDIR)\hcthread.lib"
45
46
"$(OUTDIR)" :
47
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
48
49
"$(INTDIR)" :
50
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
51
52
CPP=cl.exe
53
CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "..\..\framework\RABindings" /I "..\..\framework\RACommon" /I "..\..\framework\RASocket" /I "..\..\framework\RADataTransfer" /I "..\..\framework\RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCTHREAD_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
54
55
.c{$(INTDIR)}.obj::
56
   $(CPP) @<<
57
   $(CPP_PROJ) $< 
58
<<
59
60
.cpp{$(INTDIR)}.obj::
61
   $(CPP) @<<
62
   $(CPP_PROJ) $< 
63
<<
64
65
.cxx{$(INTDIR)}.obj::
66
   $(CPP) @<<
67
   $(CPP_PROJ) $< 
68
<<
69
70
.c{$(INTDIR)}.sbr::
71
   $(CPP) @<<
72
   $(CPP_PROJ) $< 
73
<<
74
75
.cpp{$(INTDIR)}.sbr::
76
   $(CPP) @<<
77
   $(CPP_PROJ) $< 
78
<<
79
80
.cxx{$(INTDIR)}.sbr::
81
   $(CPP) @<<
82
   $(CPP_PROJ) $< 
83
<<
84
85
MTL=midl.exe
86
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
87
RSC=rc.exe
88
BSC32=bscmake.exe
89
BSC32_FLAGS=/nologo /o"$(OUTDIR)\hcthread.bsc" 
90
BSC32_SBRS= \
91
	
92
LINK32=link.exe
93
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hcbnd.lib hcclco.lib hccldt.lib hcclsm.lib hccls.lib jvm.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\hcthread.pdb" /machine:I386 /def:".\hcthread.def" /out:"$(OUTDIR)\hcthread.dll" /implib:"$(OUTDIR)\hcthread.lib" /libpath:"..\..\framework\WinBuild\bin" 
94
DEF_FILE= \
95
	".\hcthread.def"
96
LINK32_OBJS= \
97
	"$(INTDIR)\hcthread.obj"
98
99
"$(OUTDIR)\hcthread.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
100
    $(LINK32) @<<
101
  $(LINK32_FLAGS) $(LINK32_OBJS)
102
<<
103
104
!ELSEIF  "$(CFG)" == "hcthread - Win32 Debug"
105
106
OUTDIR=.\bin
107
INTDIR=.\Debug
108
# Begin Custom Macros
109
OutDir=.\bin
110
# End Custom Macros
111
112
ALL : "$(OUTDIR)\hcthread.dll"
113
114
115
CLEAN :
116
	-@erase "$(INTDIR)\hcthread.obj"
117
	-@erase "$(INTDIR)\vc60.idb"
118
	-@erase "$(INTDIR)\vc60.pdb"
119
	-@erase "$(OUTDIR)\hcthread.dll"
120
	-@erase "$(OUTDIR)\hcthread.exp"
121
	-@erase "$(OUTDIR)\hcthread.ilk"
122
	-@erase "$(OUTDIR)\hcthread.lib"
123
	-@erase "$(OUTDIR)\hcthread.pdb"
124
125
"$(OUTDIR)" :
126
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
127
128
"$(INTDIR)" :
129
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
130
131
CPP=cl.exe
132
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\framework\RABindings" /I "..\..\framework\RACommon" /I "..\..\framework\RASocket" /I "..\..\framework\RADataTransfer" /I "..\..\framework\RASharedMemory" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCTHREAD_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
133
134
.c{$(INTDIR)}.obj::
135
   $(CPP) @<<
136
   $(CPP_PROJ) $< 
137
<<
138
139
.cpp{$(INTDIR)}.obj::
140
   $(CPP) @<<
141
   $(CPP_PROJ) $< 
142
<<
143
144
.cxx{$(INTDIR)}.obj::
145
   $(CPP) @<<
146
   $(CPP_PROJ) $< 
147
<<
148
149
.c{$(INTDIR)}.sbr::
150
   $(CPP) @<<
151
   $(CPP_PROJ) $< 
152
<<
153
154
.cpp{$(INTDIR)}.sbr::
155
   $(CPP) @<<
156
   $(CPP_PROJ) $< 
157
<<
158
159
.cxx{$(INTDIR)}.sbr::
160
   $(CPP) @<<
161
   $(CPP_PROJ) $< 
162
<<
163
164
MTL=midl.exe
165
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
166
RSC=rc.exe
167
BSC32=bscmake.exe
168
BSC32_FLAGS=/nologo /o"$(OUTDIR)\hcthread.bsc" 
169
BSC32_SBRS= \
170
	
171
LINK32=link.exe
172
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hcbnd.lib hcclco.lib hccldt.lib hcclsm.lib hccls.lib jvm.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcthread.pdb" /debug /machine:I386 /def:".\hcthread.def" /out:"$(OUTDIR)\hcthread.dll" /implib:"$(OUTDIR)\hcthread.lib" /pdbtype:sept /libpath:"..\..\framework\WinBuild\bin" 
173
DEF_FILE= \
174
	".\hcthread.def"
175
LINK32_OBJS= \
176
	"$(INTDIR)\hcthread.obj"
177
178
"$(OUTDIR)\hcthread.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
179
    $(LINK32) @<<
180
  $(LINK32_FLAGS) $(LINK32_OBJS)
181
<<
182
183
!ENDIF 
184
185
186
!IF "$(NO_EXTERNAL_DEPS)" != "1"
187
!IF EXISTS("hcthread.dep")
188
!INCLUDE "hcthread.dep"
189
!ELSE 
190
!MESSAGE Warning: cannot find "hcthread.dep"
191
!ENDIF 
192
!ENDIF 
193
194
195
!IF "$(CFG)" == "hcthread - Win32 Release" || "$(CFG)" == "hcthread - Win32 Debug"
196
SOURCE=.\hcthread.c
197
198
"$(INTDIR)\hcthread.obj" : $(SOURCE) "$(INTDIR)"
199
200
201
202
!ENDIF 
203
(-)src-native-new/src/agents/thread/WinBuild/hcthread.mak64 (+349 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on hcthread.dsp
2
!IF "$(CFG)" == ""
3
CFG=hcthread - IA64 Debug
4
!MESSAGE No configuration specified. Defaulting to hcthread - IA64 Debug.
5
!ENDIF 
6
7
!IF "$(CFG)" != "hcthread - IA64 Release" && "$(CFG)" != "hcthread - IA64 Debug" && "$(CFG)" != "hcthread - X64 Release" && "$(CFG)" != "hcthread - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "hcthread.mak64" CFG="hcthread - IA64 Debug"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "hcthread - IA64 Release"
17
!MESSAGE "hcthread - IA64 Debug"
18
!MESSAGE "hcthread - X64 Release"
19
!MESSAGE "hcthread - X64 Debug"
20
!MESSAGE 
21
!ERROR An invalid configuration is specified.
22
!ENDIF 
23
24
!IF "$(OS)" == "Windows_NT"
25
NULL=
26
!ELSE 
27
NULL=nul
28
!ENDIF 
29
30
!IF  "$(CFG)" == "hcthread - IA64 Release"
31
32
OUTDIR=..\..\..\..\bin
33
INTDIR=.\Release
34
# Begin Custom Macros
35
OutDir=..\..\..\..\bin
36
# End Custom Macros
37
38
ALL : "$(OUTDIR)\hcthread.dll"
39
40
41
CLEAN :
42
	-@erase "$(INTDIR)\hcthread.obj"
43
	-@erase "$(INTDIR)\vc60.idb"
44
	-@erase "$(OUTDIR)\hcthread.dll"
45
	-@erase "$(OUTDIR)\..\lib\hcthread.exp"
46
	-@erase "$(OUTDIR)\..\lib\hcthread.lib"
47
48
"$(OUTDIR)" :
49
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
50
51
"$(INTDIR)" :
52
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
53
54
CPP=cl.exe
55
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCTHREAD_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
56
57
.c{$(INTDIR)}.obj::
58
   $(CPP) @<<
59
   $(CPP_PROJ) $< 
60
<<
61
62
.cpp{$(INTDIR)}.obj::
63
   $(CPP) @<<
64
   $(CPP_PROJ) $< 
65
<<
66
67
.cxx{$(INTDIR)}.obj::
68
   $(CPP) @<<
69
   $(CPP_PROJ) $< 
70
<<
71
72
.c{$(INTDIR)}.sbr::
73
   $(CPP) @<<
74
   $(CPP_PROJ) $< 
75
<<
76
77
.cpp{$(INTDIR)}.sbr::
78
   $(CPP) @<<
79
   $(CPP_PROJ) $< 
80
<<
81
82
.cxx{$(INTDIR)}.sbr::
83
   $(CPP) @<<
84
   $(CPP_PROJ) $< 
85
<<
86
87
MTL=midl.exe
88
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
89
RSC=rc.exe
90
91
LINK32=link.exe
92
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\hcthread.pdb" /def:"..\hcthread.def" /out:"$(OUTDIR)\hcthread.dll" /implib:"$(OUTDIR)\..\lib\hcthread.lib" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
93
LINK32_OBJS= \
94
	"$(INTDIR)\hcthread.obj" \
95
	"$(OUTDIR)\..\lib\hcclco.lib" \
96
	"$(OUTDIR)\..\lib\hccls.lib" \
97
	"$(OUTDIR)\..\lib\hcclsm.lib" \
98
	"$(OUTDIR)\..\lib\hccldt.lib" \
99
	"$(OUTDIR)\..\lib\hcbnd.lib"
100
101
"$(OUTDIR)\hcthread.dll" : "$(OUTDIR)" $(LINK32_OBJS)
102
    $(LINK32) @<<
103
  $(LINK32_FLAGS) $(LINK32_OBJS)
104
<<
105
106
!ELSEIF  "$(CFG)" == "hcthread - IA64 Debug"
107
108
OUTDIR=..\..\..\..\bin
109
INTDIR=.\Debug
110
# Begin Custom Macros
111
OutDir=..\..\..\..\bin
112
# End Custom Macros
113
114
ALL : "$(OUTDIR)\hcthread.dll"
115
116
117
CLEAN :
118
	-@erase "$(INTDIR)\hcthread.obj"
119
	-@erase "$(INTDIR)\vc60.idb"
120
	-@erase "$(INTDIR)\vc60.pdb"
121
	-@erase "$(OUTDIR)\hcthread.dll"
122
	-@erase "$(OUTDIR)\..\lib\hcthread.exp"
123
	-@erase "$(OUTDIR)\..\lib\hcthread.ilk"
124
	-@erase "$(OUTDIR)\..\lib\hcthread.lib"
125
	-@erase "$(OUTDIR)\..\lib\hcthread.pdb"
126
127
"$(OUTDIR)" :
128
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
129
130
"$(INTDIR)" :
131
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
132
133
CPP=cl.exe
134
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCTHREAD_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
135
136
.c{$(INTDIR)}.obj::
137
   $(CPP) @<<
138
   $(CPP_PROJ) $< 
139
<<
140
141
.cpp{$(INTDIR)}.obj::
142
   $(CPP) @<<
143
   $(CPP_PROJ) $< 
144
<<
145
146
.cxx{$(INTDIR)}.obj::
147
   $(CPP) @<<
148
   $(CPP_PROJ) $< 
149
<<
150
151
.c{$(INTDIR)}.sbr::
152
   $(CPP) @<<
153
   $(CPP_PROJ) $< 
154
<<
155
156
.cpp{$(INTDIR)}.sbr::
157
   $(CPP) @<<
158
   $(CPP_PROJ) $< 
159
<<
160
161
.cxx{$(INTDIR)}.sbr::
162
   $(CPP) @<<
163
   $(CPP_PROJ) $< 
164
<<
165
166
MTL=midl.exe
167
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
168
RSC=rc.exe
169
170
LINK32=link.exe
171
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcthread.pdb" /debug /def:"..\hcthread.def" /out:"$(OUTDIR)\hcthread.dll" /implib:"$(OUTDIR)\..\lib\hcthread.lib" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
172
LINK32_OBJS= \
173
	"$(INTDIR)\hcthread.obj" \
174
	"$(OUTDIR)\..\lib\hcclco.lib" \
175
	"$(OUTDIR)\..\lib\hccls.lib" \
176
	"$(OUTDIR)\..\lib\hcclsm.lib" \
177
	"$(OUTDIR)\..\lib\hccldt.lib" \
178
	"$(OUTDIR)\..\lib\hcbnd.lib"
179
180
"$(OUTDIR)\hcthread.dll" : "$(OUTDIR)" $(LINK32_OBJS)
181
    $(LINK32) @<<
182
  $(LINK32_FLAGS) $(LINK32_OBJS)
183
<<
184
185
!ELSEIF  "$(CFG)" == "hcthread - X64 Release"
186
187
OUTDIR=..\..\..\..\bin
188
INTDIR=.\Release
189
# Begin Custom Macros
190
OutDir=..\..\..\..\bin
191
# End Custom Macros
192
193
ALL : "$(OUTDIR)\hcthread.dll"
194
195
196
CLEAN :
197
	-@erase "$(INTDIR)\hcthread.obj"
198
	-@erase "$(INTDIR)\vc60.idb"
199
	-@erase "$(OUTDIR)\hcthread.dll"
200
	-@erase "$(OUTDIR)\..\lib\hcthread.exp"
201
	-@erase "$(OUTDIR)\..\lib\hcthread.lib"
202
203
"$(OUTDIR)" :
204
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
205
206
"$(INTDIR)" :
207
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
208
209
CPP=cl.exe
210
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCTHREAD_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
211
212
.c{$(INTDIR)}.obj::
213
   $(CPP) @<<
214
   $(CPP_PROJ) $< 
215
<<
216
217
.cpp{$(INTDIR)}.obj::
218
   $(CPP) @<<
219
   $(CPP_PROJ) $< 
220
<<
221
222
.cxx{$(INTDIR)}.obj::
223
   $(CPP) @<<
224
   $(CPP_PROJ) $< 
225
<<
226
227
.c{$(INTDIR)}.sbr::
228
   $(CPP) @<<
229
   $(CPP_PROJ) $< 
230
<<
231
232
.cpp{$(INTDIR)}.sbr::
233
   $(CPP) @<<
234
   $(CPP_PROJ) $< 
235
<<
236
237
.cxx{$(INTDIR)}.sbr::
238
   $(CPP) @<<
239
   $(CPP_PROJ) $< 
240
<<
241
242
MTL=midl.exe
243
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
244
RSC=rc.exe
245
246
LINK32=link.exe
247
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\hcthread.pdb" /def:"..\hcthread.def" /out:"$(OUTDIR)\hcthread.dll" /implib:"$(OUTDIR)\..\lib\hcthread.lib" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
248
LINK32_OBJS= \
249
	"$(INTDIR)\hcthread.obj" \
250
	"$(OUTDIR)\..\lib\hcclco.lib" \
251
	"$(OUTDIR)\..\lib\hccls.lib" \
252
	"$(OUTDIR)\..\lib\hcclsm.lib" \
253
	"$(OUTDIR)\..\lib\hccldt.lib" \
254
	"$(OUTDIR)\..\lib\hcbnd.lib"
255
256
"$(OUTDIR)\hcthread.dll" : "$(OUTDIR)" $(LINK32_OBJS)
257
    $(LINK32) @<<
258
  $(LINK32_FLAGS) $(LINK32_OBJS)
259
<<
260
261
!ELSEIF  "$(CFG)" == "hcthread - X64 Debug"
262
263
OUTDIR=..\..\..\..\bin
264
INTDIR=.\Debug
265
# Begin Custom Macros
266
OutDir=..\..\..\..\bin
267
# End Custom Macros
268
269
ALL : "$(OUTDIR)\hcthread.dll"
270
271
272
CLEAN :
273
	-@erase "$(INTDIR)\hcthread.obj"
274
	-@erase "$(INTDIR)\vc60.idb"
275
	-@erase "$(INTDIR)\vc60.pdb"
276
	-@erase "$(OUTDIR)\hcthread.dll"
277
	-@erase "$(OUTDIR)\..\lib\hcthread.exp"
278
	-@erase "$(OUTDIR)\..\lib\hcthread.ilk"
279
	-@erase "$(OUTDIR)\..\lib\hcthread.lib"
280
	-@erase "$(OUTDIR)\..\lib\hcthread.pdb"
281
282
"$(OUTDIR)" :
283
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
284
285
"$(INTDIR)" :
286
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
287
288
CPP=cl.exe
289
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCTHREAD_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
290
291
.c{$(INTDIR)}.obj::
292
   $(CPP) @<<
293
   $(CPP_PROJ) $< 
294
<<
295
296
.cpp{$(INTDIR)}.obj::
297
   $(CPP) @<<
298
   $(CPP_PROJ) $< 
299
<<
300
301
.cxx{$(INTDIR)}.obj::
302
   $(CPP) @<<
303
   $(CPP_PROJ) $< 
304
<<
305
306
.c{$(INTDIR)}.sbr::
307
   $(CPP) @<<
308
   $(CPP_PROJ) $< 
309
<<
310
311
.cpp{$(INTDIR)}.sbr::
312
   $(CPP) @<<
313
   $(CPP_PROJ) $< 
314
<<
315
316
.cxx{$(INTDIR)}.sbr::
317
   $(CPP) @<<
318
   $(CPP_PROJ) $< 
319
<<
320
321
MTL=midl.exe
322
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
323
RSC=rc.exe
324
325
LINK32=link.exe
326
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcthread.pdb" /debug /def:"..\hcthread.def" /out:"$(OUTDIR)\hcthread.dll" /implib:"$(OUTDIR)\..\lib\hcthread.lib" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
327
LINK32_OBJS= \
328
	"$(INTDIR)\hcthread.obj" \
329
	"$(OUTDIR)\..\lib\hcclco.lib" \
330
	"$(OUTDIR)\..\lib\hccls.lib" \
331
	"$(OUTDIR)\..\lib\hcclsm.lib" \
332
	"$(OUTDIR)\..\lib\hccldt.lib" \
333
	"$(OUTDIR)\..\lib\hcbnd.lib"
334
335
"$(OUTDIR)\hcthread.dll" : "$(OUTDIR)" $(LINK32_OBJS)
336
    $(LINK32) @<<
337
  $(LINK32_FLAGS) $(LINK32_OBJS)
338
<<
339
340
!ENDIF 
341
342
343
!IF "$(CFG)" == "hcthread - IA64 Release" || "$(CFG)" == "hcthread - IA64 Debug" || "$(CFG)" == "hcthread - X64 Release" || "$(CFG)" == "hcthread - X64 Debug"
344
SOURCE=..\hcthread.c
345
346
"$(INTDIR)\hcthread.obj" : $(SOURCE) "$(INTDIR)"
347
	$(CPP) $(CPP_PROJ) $(SOURCE)
348
349
!ENDIF 
(-)src-native-new/src/HCLauncher/launcher_md.h (+68 lines)
Added Link Here
1
/**********************************************************************
2
Copyright (c) 2005, 2006 IBM Corporation and others.
3
All rights reserved.   This program and the accompanying materials
4
are made available under the terms of the Eclipse Public License v1.0
5
which accompanies this distribution, and is available at
6
http://www.eclipse.org/legal/epl-v10.html
7
$Id: launcher_md.h,v 1.3 2006/04/24 13:29:37 samwai Exp $
8
 
9
Contributors:
10
    IBM Corporation - initial implementation
11
**********************************************************************/
12
13
14
/* MACRO's to simplify the JNI code. */
15
#if defined __cplusplus && defined _HPUX
16
	#define ENV(e) e
17
	#define ENVPARM(e)
18
#else
19
	#define ENV(e) (*e)
20
	#define ENVPARM(e) e,
21
#endif
22
23
24
#ifdef _WIN32
25
	#include <winsock2.h> /* Bug 134924 */
26
	#include <windows.h>
27
	#include <io.h>
28
	#include <process.h>
29
#else
30
	#ifdef __OS400__
31
		#include "launcher_os400.h"
32
	#endif
33
	#include <errno.h>
34
	#include <signal.h>
35
	#include <unistd.h>
36
	#include <sys/wait.h>
37
	extern char **environ;
38
#endif
39
40
41
/*
42
 * Platform-dependent functions
43
 */
44
#ifdef _WIN32
45
PID hc_launchProcess_WIN32(char *exe, char *args, char *location, char *env, RA_HANDLE consoleChild[]);
46
47
#elif MVS
48
PID hc_launchProcess_MVS(char *exe, char *args, char *location, char *env, RA_HANDLE consoleChild[]);
49
50
#elif __OS400__
51
PID hc_launchProcess_OS400(char *exe, char *args, char *location, char *env, RA_HANDLE consoleChild[]);
52
53
#else
54
PID hc_launchProcess_UNIX(char *exe, char *args, char *location, char *env, RA_HANDLE consoleChild[]);
55
56
#endif
57
58
59
/*
60
 * Common functions
61
 */
62
void* hc_getEnvironment();
63
int hc_getEnvironmentVariable(void *env, int offset, char **name, char **value );
64
int hc_getProcessStatus(PID pid);
65
void  hc_killProcess(int pid);
66
PID   hc_launchProcess(char *exe, char *args, char *location, char *env, RA_HANDLE consoleChild[]);
67
int   hc_readFile(RA_HANDLE fd, char* buffer, int count);
68
int   hc_writeFileChar(RA_HANDLE fd, char c);
(-)src-native-new/src/agents/perfmon/resutils/mutex.c (+172 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: mutex.c,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
/***********************************************************************
14
 *
15
 * File: Mutex.c
16
 * Overview: The following code provides a wrapper to the Win32 
17
 *                                API routines for mutex operations. Implicit in the 
18
 *                               routines is that the Mutex struct has been allocated.
19
 *                               This is to ensure data is thread specific, and not
20
 *                               simply local to functions.
21
 ***********************************************************************/
22
23
#include "system.h"
24
25
/***********************************************************************
26
 * Function: XMutexCreate
27
 * Purpose: Creates a mutex variable. The user sees the mutex
28
 *                               as a pointer to a Mutex structure. The function calls 
29
 *                               the O/S and initialises the Mutex structure.
30
 * Parameters: Mutex *, a pointer to Mutex struct. Defined in 
31
 *                                        Mutex.h.
32
 * Returns: int, MUTEX_SUCCESS on successful creation, 
33
 *                              MUTEX_FAILURE otherwise.
34
 ***********************************************************************/
35
int XMutexCreate(XMutex *mutex)
36
{
37
#ifdef WIN32
38
#ifdef MUTEX_HANDLE
39
    mutex->handle = CreateMutex(NULL, FALSE, NULL); /* default security, not claimed, no name */
40
41
    if (! mutex->handle) 
42
    {
43
      return XMUTEX_ERROR_CREATE;
44
    }
45
#else
46
	InitializeCriticalSection(&mutex->cs);
47
#endif
48
#endif
49
#if defined(LINUX) || defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
50
  if (pthread_mutex_init(&mutex->mutex, NULL) != 0)
51
  {
52
    return FAILURE;
53
  }
54
#endif
55
56
    return SUCCESS;
57
}
58
                
59
60
/***********************************************************************
61
 * Function: XMutexClaim
62
 * Purpose: This function attempts to exclusively claim the mutex
63
 *                               if it is not sucessful it will block the calling thread. Once
64
 *                               the mutex is available again this thread may be scheduled
65
 *                               and hence allowed to claim it.
66
 * Parameters: Mutex *, a pointer to a Mutex struct.
67
 * Returns: int, MUTEX_SUCCESS on successful claim,
68
 *                              MUTEX_FAILURE on otherwise.
69
 ***********************************************************************/
70
int XMutexClaim(XMutex *mutex)
71
{
72
#ifdef WIN32
73
#ifdef MUTEX_HANDLE
74
    DWORD result;
75
76
    result = WaitForSingleObject(mutex->handle, INFINITE); /* no timed wait */
77
78
    if (result != WAIT_OBJECT_0) 
79
    {
80
      return XMUTEX_ERROR_CLAIM;
81
    }
82
#else
83
	EnterCriticalSection(&mutex->cs);
84
#endif
85
#endif
86
#if defined(LINUX) || defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
87
  if (pthread_mutex_lock(&mutex->mutex) != 0)
88
  {
89
    return FAILURE;
90
  }
91
#endif
92
93
    return SUCCESS;
94
}
95
96
/***********************************************************************
97
 * Function: XMutexRelease
98
 * Purpose: Allows the thread that has claimed a mutex to release
99
 *                               it. The thread must have successfully called MutexClaim
100
 *                              before calling this function.
101
 * Parameters: Mutex *, pointer to a Mutex struct.
102
 * Returns: int, MUTEX_SUCCESS is successful release,
103
 *                              MUTEX_FAILURE otherwise.
104
 ***********************************************************************/
105
int XMutexRelease(XMutex *mutex)
106
{
107
#ifdef WIN32
108
#ifdef MUTEX_HANDLE
109
  BOOL released;
110
    
111
  released = ReleaseMutex(mutex->handle);  /* release the mutex */
112
113
  if (released != TRUE) 
114
  {
115
    return XMUTEX_ERROR_RELEASE;
116
  }
117
#else
118
  LeaveCriticalSection(&mutex->cs);
119
#endif
120
#endif
121
#if defined(LINUX) || defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
122
  if (pthread_mutex_unlock(&mutex->mutex) != 0)
123
  {
124
    return FAILURE;
125
  }
126
#endif
127
  return SUCCESS;
128
}
129
130
/***********************************************************************
131
 * Function: XMutexDelete
132
 * Purpose: Notifies the O/S that the thread is no longer using 
133
 *                               the mutex. Note that all threads using this mutex 
134
 *                               must call this routine before the O/S deallocates
135
 *                               the associated resources. Once called this routine
136
 *                               will set event.deleted to TRUE.
137
 * Parameters: Mutex *, pointer to a Mutex struct.
138
 * Returns: int, MUTEX_SUCCESS if successful deletion,
139
 *                              MUTEX_FAILURE otherwise.
140
 ***********************************************************************/
141
int XMutexDelete(XMutex *mutex)
142
{
143
#ifdef WIN32
144
#ifdef MUTEX_HANDLE
145
    BOOL closed;
146
   
147
    /* decrement the number of references to kernel object, 
148
    *  and free mutex struct, setting mutex to NULL */
149
    
150
    closed = CloseHandle(mutex->handle); 
151
152
    if (! closed)
153
    {
154
      return XMUTEX_ERROR_DELETE;
155
    } 
156
#else
157
	DeleteCriticalSection(&mutex->cs);
158
#endif
159
#endif
160
#if defined(LINUX) || defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
161
  if (pthread_mutex_destroy(&mutex->mutex) != 0)
162
  {
163
    return FAILURE;
164
  }
165
#endif
166
167
    return SUCCESS;
168
}
169
170
/***********************************************************************
171
 * EOF
172
 ***********************************************************************/
(-)src-native-new/src/agents/RABindings/resource.h (+28 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: resource.h,v 1.4 2006/04/06 15:48:14 samwai Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
//{{NO_DEPENDENCIES}}
14
// Microsoft Developer Studio generated include file.
15
// Used by version.rc
16
//
17
18
19
// Next default values for new objects
20
//
21
#ifdef APSTUDIO_INVOKED
22
#ifndef APSTUDIO_READONLY_SYMBOLS
23
#define _APS_NEXT_RESOURCE_VALUE        101
24
#define _APS_NEXT_COMMAND_VALUE         40001
25
#define _APS_NEXT_CONTROL_VALUE         1000
26
#define _APS_NEXT_SYMED_VALUE           101
27
#endif
28
#endif
(-)src-native-new/src/transport/RADataTransfer/RADataTransfer.def (+8 lines)
Added Link Here
1
LIBRARY hccldt
2
DESCRIPTION "Enriched transport for all IBM Remote Agent Architecture communication layer services."
3
EXPORTS
4
	ra_allocateMessageBlock		@1
5
	ra_freeMessageBlock			@2
6
	ra_writeMessageBlock		@3
7
	
8
(-)src-native-new/src/HCLauncher/launcher_md.c (+703 lines)
Added Link Here
1
/**********************************************************************
2
Copyright (c) 2005, 2007 IBM Corporation and others.
3
All rights reserved.   This program and the accompanying materials
4
are made available under the terms of the Eclipse Public License v1.0
5
which accompanies this distribution, and is available at
6
http://www.eclipse.org/legal/epl-v10.html
7
$Id: launcher_md.c,v 1.5 2007/02/28 16:24:39 samwai Exp $
8
 
9
Contributors:
10
    IBM Corporation - initial implementation
11
**********************************************************************/
12
#ifdef MVS
13
#define _SHR_ENVIRON 1
14
#endif
15
#include "launcher_common.h"
16
17
#ifdef _DEBUG
18
extern FILE *trcFile;
19
#endif
20
21
/*
22
 * Generic launch function
23
 */
24
PID hc_launchProcess(char *exe, char *args, char *location, char *env, RA_HANDLE consoleChild[]) {
25
	int i; /* loop counter */
26
	PID pid; /* process ID of the launched process */
27
28
	if((exe == NULL) /*|| (location == NULL)*/)
29
		return -1;
30
31
#ifdef _WIN32
32
	pid = hc_launchProcess_WIN32(exe, args, location, env, consoleChild);
33
#elif MVS
34
	pid = hc_launchProcess_MVS(exe, args, location, env, consoleChild);
35
#elif __OS400__
36
	pid = hc_launchProcess_OS400(exe, args, location, env, consoleChild);
37
#else
38
	pid = hc_launchProcess_UNIX(exe, args, location, env, consoleChild);
39
#endif
40
41
	/* Close all the handles we no longer need in this address space */
42
	for(i = 0; i < 3; i++) {
43
		if(consoleChild[i]) {
44
			CLOSE_RA_HANDLE(consoleChild[i]);
45
		}
46
	}
47
	return pid;
48
}
49
50
51
/*
52
 * Windows launcher
53
 */
54
#ifdef _WIN32
55
PID hc_launchProcess_WIN32(char *exe, char *cmdline, char *location, char *env, RA_HANDLE consoleChild[]) {
56
	STARTUPINFO si;
57
	PROCESS_INFORMATION pi;
58
	DWORD error;
59
60
	/* Setup the STARTUP_INFO struct */
61
	ZeroMemory(&si,sizeof(si));
62
	si.cb=sizeof(si);
63
	if(consoleChild[0]) {
64
		si.dwFlags=STARTF_USESTDHANDLES;
65
		si.hStdInput=consoleChild[0];
66
	}
67
	if((consoleChild[1])) {
68
		si.dwFlags=STARTF_USESTDHANDLES;
69
		si.hStdOutput=consoleChild[1];
70
	}
71
	if(consoleChild[2]) {
72
		si.dwFlags=STARTF_USESTDHANDLES;
73
		si.hStdError=consoleChild[2];
74
	}
75
76
	//hc_logServiceMessage(__FILE__, __LINE__, RA_WARNING, "Attempting to launch process : %s  %s in location %s", exe->data, args->data, launchLocation);
77
	if(CreateProcess(exe,							/* Application to run */
78
					 cmdline,						/* The command line args */
79
					 NULL,							/* Default process security */
80
					 NULL,							/* Default thread security */
81
					 TRUE,							/* Inherit handles between children */
82
					 (consoleChild[0] || consoleChild[1] || consoleChild[2]) ? DETACHED_PROCESS|CREATE_NEW_PROCESS_GROUP|CREATE_SEPARATE_WOW_VDM : CREATE_NEW_CONSOLE,
83
					 env,							/* Environment */
84
					 location,						/* Where to run the child */
85
					 &si,							/* Startup info */
86
					 &pi)==0) {						/* Process info */
87
88
		error=GetLastError();
89
		//hc_logServiceMessage(__FILE__, __LINE__, RA_SEVERE, "Launching process failed, platform specific error is %d. Path=%s Process command line = %s", error, application->path.data,  cmdline);
90
		/* Set the process id to be zero as the process did not launch */
91
		pi.dwProcessId = -1;
92
		return pi.dwProcessId;
93
	}
94
95
	//hc_logServiceMessage(__FILE__, __LINE__, RA_WARNING, "Process launched: PID=%d", pi.dwProcessId);
96
	CloseHandle(pi.hThread);
97
	CloseHandle(pi.hProcess);
98
	ra_free(cmdline); /* Bug 103601 */
99
100
	return (PID)pi.dwProcessId;
101
}
102
#endif
103
104
105
/*
106
 * MVS launcher
107
 */
108
#ifdef MVS
109
PID hc_launchProcess_MVS(char *exe, char *cmdline, char *location, char *env, RA_HANDLE consoleChild[]) {
110
	PID childPID = 0;
111
	char *parsedArgs[MAX_ARGS];
112
	char *environment[MAX_ENV+1];
113
	int fd_map[3];
114
	int *fdmap;
115
	int fdcount = 3;
116
	char *current, *next;
117
	int i, count;
118
	char blank;
119
120
#ifdef MVS
121
#pragma convlit(suspend)
122
#endif
123
	blank = ' ';
124
#ifdef MVS
125
#pragma convlit(resume)
126
#endif
127
128
	if((cmdline == NULL) || (env == NULL)) {
129
		return -1;
130
	}
131
132
	current = cmdline;
133
134
	/* 178427 begin */
135
	/* Move past any leading blanks */
136
	while (*current == blank) {
137
		current++;
138
	}
139
140
	/* Parse out the args */
141
	for(i = 0; (next = (char*)strchr(current, blank)) != NULL; i++) {
142
		/* If this is a quoted arg we need to remove the quote and skip to the next quote */
143
		if(current[0]=='\"') {
144
			current++;
145
			next=(char*)strchr(current, '\"');
146
			if(next) {
147
				*next='\0';
148
			}
149
		}
150
		else {
151
			*next='\0';
152
		}
153
154
		#ifdef _DEBUG                   
155
		#pragma convlit(suspend)
156
		fprintf(trcFile, "hc_launchProcess: command arg=<%s>\n", current); 
157
		fflush(trcFile);        
158
		#pragma convlit(resume)
159
		#endif
160
161
		parsedArgs[i]=current;
162
163
		/* move past blanks */
164
		do {
165
			next++;
166
		} while (*next == blank);
167
		current=next;
168
	}
169
170
	/* check if there is another argument */
171
	if (strlen(current) > 0) {  /* 178427 - handles case of blank at end of cmd line */
172
		if(current[0]=='\"') { /* If this is a quoted arg we need to remove the quote and skip to the next quote */
173
			current++;
174
			next=(char*)strchr(current, '\"');
175
			if(next) {
176
				*next='\0';
177
			}
178
		}
179
180
		#ifdef _DEBUG                    
181
		#pragma convlit(suspend)
182
		fprintf(trcFile, "hc_launchProcess: command arg=<%s>\n", current); 
183
		fflush(trcFile);        
184
		#pragma convlit(resume)
185
		#endif
186
187
		parsedArgs[i]=current;
188
		/*	End the list of arguments */
189
		parsedArgs[i+1]=NULL;
190
	}
191
	else {
192
		/* else end the list of arguments */
193
		parsedArgs[i]=NULL;
194
	}
195
196
	/* 178427 end */
197
	/* Load the environment array */
198
	i=count=0;
199
	do {
200
		#ifdef _DEBUG                    
201
		#pragma convlit(suspend)
202
		fprintf(trcFile, "hc_launchProcess: i=%d  count=%d  env var=<%s>\n", i, count, &env[i]); 
203
		fflush(trcFile);        
204
		#pragma convlit(resume)
205
		#endif
206
207
		environment[count]=&env[i];
208
		i+=strlen(&env[i])+1;
209
		count++;
210
	} while(env[i]!='\0' && count<MAX_ENV);
211
212
	/* We have imposed a limit on the number of environment variables */
213
	if(count==MAX_ENV) {
214
215
		#ifdef _DEBUG                    
216
		#pragma convlit(suspend)
217
		fprintf(trcFile, "hc_launchProcess: Launching process failed, too many environment variables.  count=%d  but Maximum=%d\n", count, MAX_ENV); 
218
		fflush(trcFile);        
219
		#pragma convlit(resume)
220
		#endif
221
222
		exit(-1);
223
	}
224
	else {
225
		/* End the list of environment variables */
226
		environment[count]=NULL;
227
	}
228
229
   /* Set up file descriptor map for child process */
230
	if (consoleChild) {
231
		if ((fd_map[0]=dup(consoleChild[0])) < 0) {  /* child stdin is read end of pipe */
232
			//hc_logServiceMessage(__FILE__, __LINE__, RA_SEVERE, "Creating stdin for process failed.  Platform specific error is %d", errno);
233
		}
234
		if ((fd_map[1]=dup(consoleChild[1])) < 0) {  /* child stdout is write end of pipe */
235
			//hc_logServiceMessage(__FILE__, __LINE__, RA_SEVERE, "Creating stdout for process failed.  Platform specific error is %d", errno);
236
		}
237
		if ((fd_map[2]=dup(consoleChild[2])) < 0) {  /* child stderr is write end of pipe */
238
			//hc_logServiceMessage(__FILE__, __LINE__, RA_SEVERE, "Creating stderr for process failed.  Platform specific error is %d", errno);
239
		}
240
		fdmap = fd_map;
241
	}
242
	else {
243
		fdcount = 0;
244
		fdmap = NULL;
245
	}
246
247
	/* Change directory if one was specified */
248
	if (location != NULL) {
249
		#ifdef _DEBUG                    
250
		#pragma convlit(suspend)
251
		fprintf(trcFile, "hc_launchProcess: location=<%s>\n", location); 
252
		fflush(trcFile);        
253
		#pragma convlit(resume)
254
		#endif	
255
256
		if(chdir(location)) {
257
258
			#ifdef _DEBUG
259
			#pragma convlit(suspend)
260
			fprintf(trcFile, "hc_launchProcess: chdir to %s failed with error %d %s - returning 0 pid\n", location, errno, strerror(errno)); 
261
			fflush(trcFile);        
262
			#pragma convlit(resume)
263
			#endif
264
265
			childPID = 0;
266
			return childPID;
267
		}
268
	}
269
270
	/* Spawn the new process */
271
	if((childPID = spawnp(parsedArgs[0], fdcount, fdmap, NULL, parsedArgs, environment))<0) {
272
		#ifdef _DEBUG
273
		#pragma convlit(suspend)
274
		fprintf(trcFile, "hc_launchProcess: spawn failed with error %d %s - path=<%s>\n", errno, strerror(errno), parsedArgs[0]); 
275
		fflush(trcFile);        
276
		#pragma convlit(resume)
277
		#endif
278
279
		childPID = -1;  /* 179338 */
280
	}
281
282
	return childPID;
283
}
284
#endif
285
286
287
/*
288
 * OS/400 launcher
289
 */
290
#ifdef __OS400__
291
 /* Please refer to launcher_os400.c */
292
#endif
293
294
295
/*
296
 * UNIX launcher
297
 */
298
#if !defined (_WIN32) && !defined (MVS) && !defined (__OS400__)
299
PID hc_launchProcess_UNIX(char *exe, char *cmdline, char *location, char *env, RA_HANDLE consoleChild[]) {
300
301
	PID childPID = 0;
302
303
	childPID = fork();
304
305
	if(childPID == 0) {   /* Child process */
306
		char *parsedArgs[MAX_ARGS];
307
		char *environment[MAX_ENV+1];
308
		char *current, *next;
309
		int i, count;
310
		current=cmdline;
311
312
	     /* Move past any leading blanks */
313
		while (*current == ' ') {
314
			current++;
315
		}
316
317
		/* Parse out the args */
318
		for(i=0; (next=(char*)strchr(current, ' '))!=NULL; i++) {
319
			if(current[0]=='\"') { /* If this is a quoted arg we need to remove the quote and skip to the next quote */
320
				current++;
321
				next=(char*)strchr(current, '\"');
322
				if(next) {
323
					*next='\0';
324
				}
325
			}
326
			else {
327
				*next='\0';
328
			}
329
330
			parsedArgs[i]=current;
331
332
			do { /* move past blanks */
333
				next++;
334
			} while (*next == ' ');
335
			current=next;
336
		}
337
338
		/* check if there is another argument */
339
		if (strlen(current) > 0) { /* handles case of blank at end of cmd line */
340
			if(current[0]=='\"') { /* If this is a quoted arg we need to remove the quote and skip to the next quote */
341
				current++;
342
				next=(char*)strchr(current, '\"');
343
				if(next) {
344
					*next='\0';
345
				}
346
			}
347
			parsedArgs[i]=current;
348
			parsedArgs[i+1]='\0';
349
		}
350
351
		else { /* Else end the list of arguments */
352
			parsedArgs[i]='\0';
353
		}
354
355
		/* Load the environment array */
356
		i=count=0;
357
		do{
358
			environment[count]=&env[i];
359
			i+=strlen(&env[i])+1;
360
			count++;
361
		} while(env[i]!='\0' && count<MAX_ENV);
362
363
		if(count==MAX_ENV) {
364
			printf("Launching process failed, too many environment variables.  Maximum=%d\n", MAX_ENV);
365
			return (-1);
366
		}
367
		else {
368
			environment[count]='\0';
369
		}
370
371
		/* Change directory to the specified location if it exists */
372
        if(location) {
373
		    if(chdir(location)) {
374
			    printf("Launching process failed, cannot set location.  Platform specific error is %d. Location=%s\n", errno, location);
375
			    return (-1);
376
		    }
377
        }
378
379
		/* Setup the console */
380
		if(dup2(consoleChild[0], STDIN_FILENO) < 0) {
381
			printf("Creating stdin for process failed.  Platform specific error is %d\n", errno);
382
		}
383
		if(dup2(STDOUT_FILENO, consoleChild[1]) < 0) {
384
			printf("Creating stdout for process failed.  Platform specific error is %d\n", errno);
385
		}
386
		if(dup2(STDERR_FILENO, consoleChild[2]) < 0) {
387
			printf("Creating stderr for process failed.  Platform specific error is %d\n", errno);
388
		}
389
390
		/* Exec the target process */
391
		if(execve(parsedArgs[0], parsedArgs, environment)<0) {
392
			printf("Launching process failed, platform specific error is %d. Process command line = %s\n", errno, cmdline);
393
			return (-1);	/* exec failed */
394
		}
395
	}
396
	else { /* parent process */
397
		return childPID;
398
	}
399
}
400
#endif
401
402
403
/*******************************************************************************
404
 *                                                                             *
405
 * Environment                                                                 *
406
 *                                                                             *
407
 ******************************************************************************/
408
409
410
/*
411
 * Get the current system environment
412
 */
413
void* hc_getEnvironment() {
414
415
#ifdef _WIN32
416
	return GetEnvironmentStrings(); /* Return a string of environment variables */
417
#else
418
419
	#ifdef _DEBUG
420
	#ifdef MVS                    
421
	#pragma convlit(suspend)
422
	#endif
423
	fprintf(trcFile, "hc_getEnvironment: environ=%p\n", environ); 
424
	fflush(trcFile);
425
	#ifdef MVS        
426
	#pragma convlit(resume)
427
	#endif
428
	#endif
429
430
	return (void*)environ;
431
#endif
432
}
433
434
/*
435
 * Get the environment variable at the specified offset in the specified environment 
436
 * and returns the offset of the next environment variable.
437
 * Input:
438
 *    env    - environment  
439
 *    offset - offset of variable in the environment
440
 *
441
 * Output:
442
 *    envvarName  - ptr to environment variable name
443
 *    envvarValue - ptr to environment variable value
444
 *
445
 * Returns - offset of next environment variable in the specified environment 
446
 *         - -1 if no more environment variables
447
 */
448
449
int hc_getEnvironmentVariable(void *env, int offset, char **envvarName, char **envvarValue) {
450
	int nextOffset, nameLen, valueLen;
451
	char *tmp;
452
	char *envvar;
453
454
#ifdef _WIN32
455
	char *sysEnv = (char *)env;
456
457
	#ifdef _DEBUG
458
	fprintf(trcFile, "hc_getEnvironmentVariable: offset=%d  sysEnv=%p\n", offset, sysEnv); 
459
	fflush(trcFile);
460
	#endif
461
462
	envvar = sysEnv+offset;
463
464
	#ifdef _DEBUG
465
	fprintf(trcFile, "hc_getEnvironmentVariable: envvar = <%s>\n", envvar); 
466
	fflush(trcFile);
467
	#endif
468
469
	/* Get the name-value pairs - look for = */
470
	tmp = strchr(envvar, '=');
471
472
	/* If we don't have an = then return the whole string for the name and an empty string for the value */
473
	if (tmp == NULL) {
474
		nameLen = strlen(envvar);
475
		valueLen = 0;
476
	}
477
478
	/* Check if the first character is = (on Windows this is the case for some variables) */
479
	else if (tmp-envvar == 0) {
480
		/* check if there is another =                              
481
		 * If there is another = Then use that one                    
482
		 * If there isn't another = then use the whole string for the name and make the value an empty string 
483
		 */
484
		tmp = strchr(envvar+1, '=');
485
486
		if (tmp == NULL) {
487
			nameLen = strlen(envvar);
488
			valueLen = 0;
489
		}
490
		else {
491
			nameLen = tmp-envvar;
492
			valueLen = strlen(tmp)-1;
493
		}
494
495
	}
496
	else {
497
		nameLen = tmp-envvar;
498
		valueLen = strlen(tmp)-1;
499
	}
500
501
	*envvarName = (char *)malloc(nameLen+1);
502
	*envvarValue = (char *)malloc(valueLen+1);
503
	memcpy(*envvarName, envvar, nameLen);
504
	*(*envvarName+nameLen) = '\0';
505
	if ((tmp == NULL) || (valueLen == 0)) { /* Bug 68899 */
506
		**envvarValue = '\0';
507
	}
508
	else {
509
		strcpy(*envvarValue, tmp+1);
510
	}
511
512
513
	#ifdef _DEBUG
514
	fprintf(trcFile, "hc_getEnvironmentVariable: envvarName=%p <%s> envvarValue=%p <%s>\n", *envvarName, *envvarName, *envvarValue, *envvarValue); 
515
	fflush(trcFile);
516
	#endif
517
518
	/* Get offset to next environment variable */
519
	nextOffset = offset + strlen(envvar) + 1;
520
521
	if (sysEnv[nextOffset] == '\0') {
522
		nextOffset = -1;
523
	}
524
525
#else  /* Non-Windows Platforms */
526
	char *n_envvarName; /* native encoded name */
527
	char *n_envvarValue; /* native encoded value */
528
	char **sysEnv = (char **)env;
529
	size_t rc_n;
530
	size_t rc_v;
531
532
#ifdef MVS                    
533
	#pragma convlit(suspend)
534
#endif
535
536
	#ifdef _DEBUG
537
	fprintf(trcFile, "hc_getEnvironmentVariable: offset=%d  sysEnv=%p\n", offset, sysEnv); 
538
	fflush(trcFile);
539
	#endif
540
541
	envvar = sysEnv[offset];
542
543
	#ifdef _DEBUG
544
	fprintf(trcFile, "hc_getEnvironmentVariable: envvar = <%s>\n", envvar); 
545
	fflush(trcFile);
546
	#endif
547
548
	/* Get the name-value pairs - look for = */
549
	tmp = strchr(envvar, '=');
550
551
	/* If we don't have an = then return the whole string for the name and an empty string for the value */
552
	if (tmp == NULL) {
553
		nameLen = strlen(envvar);
554
		valueLen = 0;
555
	}
556
	else {
557
		nameLen = tmp-envvar;
558
		valueLen = strlen(tmp)-1;
559
	}
560
561
	n_envvarName = (char *)malloc(nameLen+1);
562
	n_envvarValue = (char *)malloc(valueLen+1);
563
	memcpy(n_envvarName, envvar, nameLen);
564
	*(n_envvarName+nameLen) = '\0';
565
	if ((tmp == NULL) || (valueLen == 0)) { /* Bug 68899 */
566
		*n_envvarValue = '\0';
567
	}
568
	else {
569
		strcpy(n_envvarValue, tmp+1);
570
	}
571
572
	#ifdef _DEBUG
573
	fprintf(trcFile, "hc_getEnvironmentVariable: envvarName=%p <%s> envvarValue=%p <%s>\n", n_envvarName, n_envvarName, n_envvarValue, n_envvarValue); 
574
	fflush(trcFile);
575
	#endif
576
577
	/* Convert the string from native to UTF-8 */
578
	rc_n = native2unicode(envvarName, n_envvarName, nameLen + 1);
579
	rc_v = native2unicode(envvarValue, n_envvarValue, valueLen + 1);
580
581
	free(n_envvarName);
582
	free(n_envvarValue);
583
584
	/* Get offset to next environment variable */
585
	nextOffset = offset + 1;
586
587
	/* If we are at the end of the environment variable array then signal it by returning -1 */
588
	if (sysEnv[nextOffset] == NULL) {
589
		nextOffset = -1;
590
	}
591
592
	if((rc_n == 0) || (rc_v == 0)) {
593
		*envvarName = NULL;
594
		*envvarValue = NULL;
595
	}
596
#endif
597
598
	return nextOffset;
599
600
}
601
602
/*******************************************************************************
603
 *                                                                             *
604
 * Process handling                                                            *
605
 *                                                                             *
606
 ******************************************************************************/
607
608
/*
609
 * Get the process state
610
 * Please refer to IExecutionComponent definition
611
 */
612
int hc_getProcessStatus(PID pid) {
613
#ifdef _WIN32
614
	HANDLE hProcess;
615
	DWORD exitCode;
616
617
	hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
618
	if (hProcess) {
619
		GetExitCodeProcess(hProcess, &exitCode);
620
		CloseHandle(hProcess); 
621
	}
622
	else {
623
		return org_eclipse_hyades_execution_core_IExecutionComponent_DEAD;
624
	}
625
626
	if(exitCode == STILL_ACTIVE) {
627
		return org_eclipse_hyades_execution_core_IExecutionComponent_READY;
628
	}
629
	else {
630
		return org_eclipse_hyades_execution_core_IExecutionComponent_DEAD;
631
	}
632
#else
633
	int status = 0;
634
635
	pid = waitpid(pid, &status, WNOHANG | WUNTRACED);
636
	if(pid == 0) {
637
		return org_eclipse_hyades_execution_core_IExecutionComponent_READY;
638
	}
639
	else {
640
		return org_eclipse_hyades_execution_core_IExecutionComponent_DEAD;
641
	}
642
#endif
643
}
644
645
/*
646
 * Kill the process specified by the process id
647
 */
648
void hc_killProcess(int pid) {
649
#ifdef _WIN32
650
	HANDLE hProcess;
651
652
	hProcess=OpenProcess(PROCESS_TERMINATE, FALSE, pid);
653
	if(hProcess!=NULL) {
654
		TerminateProcess(hProcess, 0);
655
	}
656
#else
657
	kill(pid, SIGKILL);
658
#endif
659
660
	return;
661
}
662
663
664
/*******************************************************************************
665
 *                                                                             *
666
 * File I/O                                                                    *
667
 *                                                                             *
668
 ******************************************************************************/
669
670
/*
671
 * Read data from file descriptor
672
 */
673
int hc_readFile(RA_HANDLE fd, char* buffer, int count) {
674
	int rc;
675
#ifdef _WIN32
676
	ReadFile(fd, buffer, count, &rc, NULL);
677
#else
678
	rc = read(fd, buffer, count);
679
#endif
680
	return rc;
681
}
682
683
684
/*
685
 * Write a single character to the file descriptor
686
 */
687
int hc_writeFileChar(RA_HANDLE fd, char c) {
688
	int rc;
689
#ifdef _WIN32
690
	WriteFile(fd, &c, 1, &rc, NULL);
691
#elif defined (__OS400__)
692
	rc = write(fd, as400_atoe(&c), 1);
693
#elif defined (MVS)
694
	char c2[2];
695
	c2[0] = c;
696
	c2[1] = '\0';
697
	__atoe(c2);
698
	rc = write(fd, c2, 1);
699
#else
700
	rc = write(fd, &c, 1);
701
#endif
702
	return rc;
703
}
(-)src-native-new/src/agents/native/java_profiler/java_profiler.make (+130 lines)
Added Link Here
1
2
################################################################################
3
#                                       
4
#  makefile:  java_profiler project  
5
#                                       
6
# $Id
7
################################################################################
8
9
10
#-----------------------------------
11
#
12
#   Customizable section
13
#
14
#   - The TARGETREALNAME variable specifies the name of the library file
15
#     that will be generated, this includes a base (TARGETLIB) plus	a 
16
#     version number plus a minor number plus a release number
17
#   - The TARGETSONAME variable specifies a file name that has just the
18
#     library name plus the major version number
19
#   - The TARGETLIB variable specifies the base library name
20
#   - The TARGETSONAME and TARGETLIB are generated as symbolic links
21
#     when the library is built
22
#
23
#-----------------------------------
24
TARGET         :=  libpiAgent
25
TARGETDIR      :=  ../../../../lib
26
27
if [ x$VERSIONNUM = x ]; then export VERSIONNUM=0; fi
28
if [ x$MINORNUM = x ]; then export MINORNUM=0; fi
29
if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi
30
31
TARGETLIB      :=  $(TARGET).so
32
TARGETSONAME   :=  $(TARGETLIB).$(VERSIONNUM)
33
TARGETREALNAME :=  $(TARGETSONAME).$(MINORNUM).$(RELEASENUM)
34
35
36
#-----------------------------------
37
#   list of additional INCLUDE directories to search headers from
38
#      (separated by blanks)
39
#-----------------------------------
40
INCLUDEDIRS    :=  .  ../../../../include $(JAVA_HOME)/include $(JAVA_HOME)/include/linux ../../RABindings ../../../transport/RACommon ../../../transport/RASocket ../../../transport/RASharedMemory ../../../transport/RADataTransfer
41
42
43
#-----------------------------------
44
#   list of additional libraries to be linked with
45
#      (separated by blanks)
46
#-----------------------------------
47
LIBS       :=  dl hcbnd
48
49
#-----------------------------------
50
#   list of additional library directories to search from
51
#      (separated by blanks)
52
#-----------------------------------
53
LIBDIRS    :=  ../../../../lib
54
55
56
#-----------------------------------
57
#
58
#   Compiler options
59
#
60
#      -g       produce debug info
61
#      -Wall    enable all types of warnings
62
#      -O3      highest level of code optimization
63
#      -fPIC    generate position-independent code (PIC).
64
#               This is required for building shared library.
65
#      -c       compile only
66
#
67
#   Linking options
68
#
69
#       -Wl       pass options to linker
70
#       -shared   produce shared library
71
#       -L        add the given directory to the search path for libraries
72
#
73
#-----------------------------------
74
75
DEFINES    := -DSQLUNIX -DSQLLinux -DENW -DREENTRANT -D_REENTRANT -DCONFIG_X86_CMPXCHG
76
77
CFLAGS     :=  $(C_FLAGS) $(DEBUGABLE) -Wall $(OPTIMIZABLE) -fPIC $(addprefix -I,$(INCLUDEDIRS))  -D_LINUX_X86  $(DEFINES)
78
79
CXXFLAGS   :=  $(CFLAGS)
80
81
LINKOPTS   :=  $(L_FLAGS) $(DEBUGABLE) -shared -Wl,-soname,$(TARGETSONAME) -o $(TARGETDIR)/$(TARGETREALNAME) $(addprefix -L,$(LIBDIRS))
82
83
84
#-----------------------------------
85
#   general commands and options
86
#-----------------------------------
87
88
CC          :=  gcc
89
CXX         :=  $(CC)
90
91
#SOURCE     :=  $(wildcard *.c)  $(wildcard *.cpp)
92
SOURCE     :=  $(wildcard *.c) $(wildcard *.cpp) $(wildcard ../heapsnapshots/*.c) $(wildcard ../heapsnapshots/*.cpp)
93
94
OBJS       :=  $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
95
96
REMOVEFILE :=  rm -f
97
CREATELINK :=  ln -sf
98
99
100
#-----------------------------------
101
#   "make" rules
102
#-----------------------------------
103
104
.PHONY : default everything objs clean veryclean rebuild $(TARGET)
105
106
107
default : $(TARGET)
108
109
110
objs : $(OBJS)
111
112
113
clean :
114
	$(REMOVEFILE) *.o
115
116
117
veryclean: clean
118
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETLIB)
119
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETSONAME)
120
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETREALNAME)
121
122
123
rebuild: veryclean everything
124
125
126
$(TARGET) : $(OBJS)
127
	$(CC) $(LINKOPTS) $(OBJS) $(addprefix -l,$(LIBS))
128
	$(CREATELINK) $(TARGETREALNAME)  $(TARGETDIR)/$(TARGETSONAME)
129
	$(CREATELINK) $(TARGETSONAME)    $(TARGETDIR)/$(TARGETLIB)
130
(-)src-native-new/src/transport/RADataTransfer/RADataTransfer.make (+129 lines)
Added Link Here
1
2
################################################################################
3
#                                       
4
#  makefile:  RADataTransfer project  
5
#                                       
6
# $Id
7
################################################################################
8
9
10
#-----------------------------------
11
#
12
#   Customizable section
13
#
14
#   - The TARGETREALNAME variable specifies the name of the library file
15
#     that will be generated, this includes a base (TARGETLIB) plus	a 
16
#     version number plus a minor number plus a release number
17
#   - The TARGETSONAME variable specifies a file name that has just the
18
#     library name plus the major version number
19
#   - The TARGETLIB variable specifies the base library name
20
#   - The TARGETSONAME and TARGETLIB are generated as symbolic links
21
#     when the library is built
22
#
23
#-----------------------------------
24
TARGET         :=  libhccldt
25
TARGETDIR      :=  ../../../lib
26
27
if [ x$VERSIONNUM = x ]; then export VERSIONNUM=0; fi
28
if [ x$MINORNUM = x ]; then export MINORNUM=0; fi
29
if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi
30
31
TARGETLIB      :=  $(TARGET).so
32
TARGETSONAME   :=  $(TARGETLIB).$(VERSIONNUM)
33
TARGETREALNAME :=  $(TARGETSONAME).$(MINORNUM).$(RELEASENUM)
34
35
36
#-----------------------------------
37
#   list of additional INCLUDE directories to search headers from
38
#      (separated by blanks)
39
#-----------------------------------
40
INCLUDEDIRS    :=  .  ../../../include $(JAVA_HOME)/include $(JAVA_HOME)/include/linux ../RACommon ../RASocket ../RASharedMemory
41
42
43
#-----------------------------------
44
#   list of additional libraries to be linked with
45
#      (separated by blanks)
46
#-----------------------------------
47
LIBS       :=  dl hcclco hccls hcclsm pthread
48
49
#-----------------------------------
50
#   list of additional library directories to search from
51
#      (separated by blanks)
52
#-----------------------------------
53
LIBDIRS    :=  ../../../lib
54
55
56
#-----------------------------------
57
#
58
#   Compiler options
59
#
60
#      -g       produce debug info
61
#      -Wall    enable all types of warnings
62
#      -O3      highest level of code optimization
63
#      -fPIC    generate position-independent code (PIC).
64
#               This is required for building shared library.
65
#      -c       compile only
66
#
67
#   Linking options
68
#
69
#       -Wl       pass options to linker
70
#       -shared   produce shared library
71
#       -L        add the given directory to the search path for libraries
72
#
73
#-----------------------------------
74
75
DEFINES    := -DSQLUNIX -DSQLLinux -DENW -DREENTRANT -D_REENTRANT -DCONFIG_X86_CMPXCHG
76
77
CFLAGS     :=  $(C_FLAGS) $(DEBUGABLE) -Wall $(OPTIMIZABLE) -fPIC $(addprefix -I,$(INCLUDEDIRS))  -D_LINUX_X86  $(DEFINES)
78
79
CXXFLAGS   :=  $(CFLAGS)
80
81
LINKOPTS   :=  $(L_FLAGS) $(DEBUGABLE) -shared -Wl,-soname,$(TARGETSONAME) -o $(TARGETDIR)/$(TARGETREALNAME) $(addprefix -L,$(LIBDIRS))
82
83
84
#-----------------------------------
85
#   general commands and options
86
#-----------------------------------
87
88
CC          :=  gcc
89
CXX         :=  $(CC)
90
91
SOURCE     :=  $(wildcard *.c)  $(wildcard *.cpp)
92
93
OBJS       :=  $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
94
95
REMOVEFILE :=  rm -f
96
CREATELINK :=  ln -sf
97
98
99
#-----------------------------------
100
#   "make" rules
101
#-----------------------------------
102
103
.PHONY : default everything objs clean veryclean rebuild $(TARGET)
104
105
106
default : $(TARGET)
107
108
109
objs : $(OBJS)
110
111
112
clean :
113
	$(REMOVEFILE) *.o
114
115
116
veryclean: clean
117
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETLIB)
118
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETSONAME)
119
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETREALNAME)
120
121
122
rebuild: veryclean everything
123
124
125
$(TARGET) : $(OBJS)
126
	$(CC) $(LINKOPTS) $(OBJS) $(addprefix -l,$(LIBS))
127
	$(CREATELINK) $(TARGETREALNAME)  $(TARGETDIR)/$(TARGETSONAME)
128
	$(CREATELINK) $(TARGETSONAME)    $(TARGETDIR)/$(TARGETLIB)
129
(-)src-native-new/src/agents/native/WinBuild/java_profiler.dsp (+219 lines)
Added Link Here
1
# Microsoft Developer Studio Project File - Name="java_profiler" - Package Owner=<4>
2
# Microsoft Developer Studio Generated Build File, Format Version 6.00
3
# ** DO NOT EDIT **
4
5
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
6
7
CFG=java_profiler - Win32 Debug
8
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9
!MESSAGE use the Export Makefile command and run
10
!MESSAGE 
11
!MESSAGE NMAKE /f "java_profiler.mak".
12
!MESSAGE 
13
!MESSAGE You can specify a configuration when running NMAKE
14
!MESSAGE by defining the macro CFG on the command line. For example:
15
!MESSAGE 
16
!MESSAGE NMAKE /f "java_profiler.mak" CFG="java_profiler - Win32 Debug"
17
!MESSAGE 
18
!MESSAGE Possible choices for configuration are:
19
!MESSAGE 
20
!MESSAGE "java_profiler - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
21
!MESSAGE "java_profiler - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
22
!MESSAGE 
23
24
# Begin Project
25
# PROP AllowPerConfigDependencies 0
26
# PROP Scc_ProjName "java_profiler"
27
# PROP Scc_LocalPath ".."
28
CPP=cl.exe
29
MTL=midl.exe
30
RSC=rc.exe
31
32
!IF  "$(CFG)" == "java_profiler - Win32 Release"
33
34
# PROP BASE Use_MFC 0
35
# PROP BASE Use_Debug_Libraries 0
36
# PROP BASE Output_Dir "Release"
37
# PROP BASE Intermediate_Dir "Release"
38
# PROP BASE Target_Dir ""
39
# PROP Use_MFC 0
40
# PROP Use_Debug_Libraries 0
41
# PROP Output_Dir "bin"
42
# PROP Intermediate_Dir "Release"
43
# PROP Ignore_Export_Lib 0
44
# PROP Target_Dir ""
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JAVA_PROFILER_EXPORTS" /YX /FD /c
46
# ADD CPP /nologo /MT /W3 /GX /O2 /Ob2 /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /I "..\..\..\transport\RASocket" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JAVA_PROFILER_EXPORTS" /D "_INTEL" /YX /FD /c
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
49
# ADD BASE RSC /l 0x409 /d "NDEBUG"
50
# ADD RSC /l 0x409 /fo"Release/piagent.res" /d "NDEBUG"
51
BSC32=bscmake.exe
52
# ADD BASE BSC32 /nologo
53
# ADD BSC32 /nologo
54
LINK32=link.exe
55
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
56
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib rpcrt4.lib ws2_32.lib hcclco.lib hccldt.lib hccls.lib hcbnd.lib hcclsm.lib /nologo /version:0.1 /dll /pdb:none /map /machine:I386 /out:"..\..\..\..\bin\piAgent.dll" /libpath:"..\..\..\..\lib"
57
58
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
59
60
# PROP BASE Use_MFC 0
61
# PROP BASE Use_Debug_Libraries 1
62
# PROP BASE Output_Dir "Debug"
63
# PROP BASE Intermediate_Dir "Debug"
64
# PROP BASE Target_Dir ""
65
# PROP Use_MFC 0
66
# PROP Use_Debug_Libraries 1
67
# PROP Output_Dir "bin"
68
# PROP Intermediate_Dir "Debug"
69
# PROP Ignore_Export_Lib 0
70
# PROP Target_Dir ""
71
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JAVA_PROFILER_EXPORTS" /YX /FD /GZ /c
72
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /I "..\..\..\transport\RASocket" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JAVA_PROFILER_EXPORTS" /D "_INTEL" /FR /YX /FD /GZ /c
73
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
74
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
75
# ADD BASE RSC /l 0x409 /d "_DEBUG"
76
# ADD RSC /l 0x409 /fo"Debug/piagent.res" /d "_DEBUG"
77
BSC32=bscmake.exe
78
# ADD BASE BSC32 /nologo
79
# ADD BSC32 /nologo
80
LINK32=link.exe
81
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
82
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib rpcrt4.lib ws2_32.lib hcclco.lib hccldt.lib hccls.lib hcbnd.lib hcclsm.lib /nologo /dll /debug /machine:I386 /out:"..\..\..\..\bin\piAgent.dll" /pdbtype:sept /libpath:"..\..\..\..\lib"
83
84
!ENDIF 
85
86
# Begin Target
87
88
# Name "java_profiler - Win32 Release"
89
# Name "java_profiler - Win32 Debug"
90
# Begin Group "Source Files"
91
92
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
93
# Begin Source File
94
95
SOURCE=..\java_profiler\agentDebug.c
96
# End Source File
97
# Begin Source File
98
99
SOURCE=..\java_profiler\filters.c
100
# End Source File
101
# Begin Source File
102
103
SOURCE=..\java_profiler\hash.c
104
# End Source File
105
# Begin Source File
106
107
SOURCE=..\java_profiler\JvmpiWriter.c
108
# End Source File
109
# Begin Source File
110
111
SOURCE=..\java_profiler\options.c
112
# End Source File
113
# Begin Source File
114
115
SOURCE=..\java_profiler\performance.c
116
# End Source File
117
# Begin Source File
118
119
SOURCE=..\java_profiler\print.c
120
# End Source File
121
# Begin Source File
122
123
SOURCE=..\java_profiler\segmentedValue.c
124
# End Source File
125
# Begin Source File
126
127
SOURCE=..\java_profiler\stack.c
128
# End Source File
129
# Begin Source File
130
131
SOURCE=..\java_profiler\StatelessHeapSnapshotManager_C.cpp
132
# End Source File
133
# Begin Source File
134
135
SOURCE=..\java_profiler\utility.c
136
# End Source File
137
# End Group
138
# Begin Group "Header Files"
139
140
# PROP Default_Filter "h;hpp;hxx;hm;inl"
141
# Begin Source File
142
143
SOURCE=..\java_profiler\agentDebug.h
144
# End Source File
145
# Begin Source File
146
147
SOURCE=..\java_profiler\binary_print.h
148
# End Source File
149
# Begin Source File
150
151
SOURCE=..\java_profiler\eventmask.h
152
# End Source File
153
# Begin Source File
154
155
SOURCE=..\java_profiler\filters.h
156
# End Source File
157
# Begin Source File
158
159
SOURCE=..\java_profiler\hash.h
160
# End Source File
161
# Begin Source File
162
163
SOURCE=..\java_profiler\JVMPIException.h
164
# End Source File
165
# Begin Source File
166
167
SOURCE=..\java_profiler\JvmpiWriter.h
168
# End Source File
169
# Begin Source File
170
171
SOURCE=..\java_profiler\options.h
172
# End Source File
173
# Begin Source File
174
175
SOURCE=..\java_profiler\performance.h
176
# End Source File
177
# Begin Source File
178
179
SOURCE=..\java_profiler\piAgentExtension.h
180
# End Source File
181
# Begin Source File
182
183
SOURCE=..\java_profiler\print.h
184
# End Source File
185
# Begin Source File
186
187
SOURCE=..\java_profiler\resource.h
188
# End Source File
189
# Begin Source File
190
191
SOURCE=..\java_profiler\segmentedValue.h
192
# End Source File
193
# Begin Source File
194
195
SOURCE=..\java_profiler\stack.h
196
# End Source File
197
# Begin Source File
198
199
SOURCE=..\java_profiler\StatelessHeapSnapshotManager_C.h
200
# End Source File
201
# Begin Source File
202
203
SOURCE=..\java_profiler\strings.h
204
# End Source File
205
# Begin Source File
206
207
SOURCE=..\java_profiler\utility.h
208
# End Source File
209
# End Group
210
# Begin Group "Resource Files"
211
212
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
213
# Begin Source File
214
215
SOURCE=..\java_profiler\version.rc
216
# End Source File
217
# End Group
218
# End Target
219
# End Project
(-)src-native-new/src/agents/native/heapsnapshots/LBTimestamp.h (+74 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: LBTimestamp.h,v 1.2 2005/02/25 22:17:34 hleung Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef LBTIMESTAMP_H
14
#define LBTIMESTAMP_H
15
16
#ifdef WIN32
17
#include <time.h>
18
typedef clock_t LBCLOCK_t;
19
20
static void getClock(LBCLOCK_t *pclock) {
21
  *pclock = clock();
22
}
23
static unsigned int clockDiffInMilliseconds(const LBCLOCK_t *start) {
24
  LBCLOCK_t end;
25
  getClock(&end);
26
  return (unsigned int)(1000*((double)(end-*start))/CLOCKS_PER_SEC);
27
}
28
static double clockDiffInFractionalMilliseconds(const LBCLOCK_t *start) {
29
  LBCLOCK_t end;
30
  getClock(&end);
31
  return (1000000.0*((double)(end-*start))/CLOCKS_PER_SEC);
32
}
33
static unsigned int clockDiffInMicroseconds(const LBCLOCK_t *start) {
34
  LBCLOCK_t end;
35
  getClock(&end);
36
  return (unsigned int)(1000000*((double)(end-*start))/CLOCKS_PER_SEC);
37
}
38
39
#else
40
#include <sys/time.h>
41
typedef struct timeval LBCLOCK_t;
42
43
# define timersub(a, b, result)						      \
44
  do {									      \
45
    (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;			      \
46
    (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;			      \
47
    if ((result)->tv_usec < 0) {					      \
48
      --(result)->tv_sec;						      \
49
      (result)->tv_usec += 1000000;					      \
50
    }									      \
51
  } while (0)
52
53
static void getClock(LBCLOCK_t *pclock) {
54
  gettimeofday(pclock, NULL);
55
}
56
static double clockDiffInFractionalMilliseconds(const LBCLOCK_t *start) {
57
  LBCLOCK_t end, interval;
58
  getClock(&end);
59
  timersub(&end, start, &interval);
60
  return interval.tv_sec*1e3 + interval.tv_usec/1e3;
61
}
62
static unsigned int clockDiffInMilliseconds(const LBCLOCK_t *start) {
63
  return (unsigned int) clockDiffInFractionalMilliseconds(start);
64
}
65
static unsigned int clockDiffInMicroseconds(const LBCLOCK_t *start) {
66
  LBCLOCK_t end, interval;
67
  getClock(&end);
68
  timersub(&end, start, &interval);
69
  return (unsigned int) (interval.tv_sec/1e6 + interval.tv_usec);
70
}
71
72
#endif
73
74
#endif /* LBTIMESTAMP_H */
(-)src-native-new/src/agents/thread/hcthread.make (+129 lines)
Added Link Here
1
2
################################################################################
3
#                                       
4
#  makefile:  hcthread project  
5
#                                       
6
# $Id
7
################################################################################
8
9
10
#-----------------------------------
11
#
12
#   Customizable section
13
#
14
#   - The TARGETREALNAME variable specifies the name of the library file
15
#     that will be generated, this includes a base (TARGETLIB) plus	a 
16
#     version number plus a minor number plus a release number
17
#   - The TARGETSONAME variable specifies a file name that has just the
18
#     library name plus the major version number
19
#   - The TARGETLIB variable specifies the base library name
20
#   - The TARGETSONAME and TARGETLIB are generated as symbolic links
21
#     when the library is built
22
#
23
#-----------------------------------
24
TARGET         :=  libhcthread
25
TARGETDIR      :=  ../../../lib
26
27
if [ x$VERSIONNUM = x ]; then export VERSIONNUM=0; fi
28
if [ x$MINORNUM = x ]; then export MINORNUM=0; fi
29
if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi
30
31
TARGETLIB      :=  $(TARGET).so
32
TARGETSONAME   :=  $(TARGETLIB).$(VERSIONNUM)
33
TARGETREALNAME :=  $(TARGETSONAME).$(MINORNUM).$(RELEASENUM)
34
35
36
#-----------------------------------
37
#   list of additional INCLUDE directories to search headers from
38
#      (separated by blanks)
39
#-----------------------------------
40
INCLUDEDIRS    :=  .  ../../../include $(JAVA_HOME)/include $(JAVA_HOME)/include/linux ../RABindings ../../transport/RACommon ../../transport/RASocket ../../transport/RASharedMemory ../../transport/RADataTransfer
41
42
43
#-----------------------------------
44
#   list of additional libraries to be linked with
45
#      (separated by blanks)
46
#-----------------------------------
47
LIBS       :=  dl hcbnd pthread
48
49
#-----------------------------------
50
#   list of additional library directories to search from
51
#      (separated by blanks)
52
#-----------------------------------
53
LIBDIRS    :=  ../../../lib
54
55
56
#-----------------------------------
57
#
58
#   Compiler options
59
#
60
#      -g       produce debug info
61
#      -Wall    enable all types of warnings
62
#      -O3      highest level of code optimization
63
#      -fPIC    generate position-independent code (PIC).
64
#               This is required for building shared library.
65
#      -c       compile only
66
#
67
#   Linking options
68
#
69
#       -Wl       pass options to linker
70
#       -shared   produce shared library
71
#       -L        add the given directory to the search path for libraries
72
#
73
#-----------------------------------
74
75
DEFINES    := -DSQLUNIX -DSQLLinux -DENW -DREENTRANT -D_REENTRANT -DCONFIG_X86_CMPXCHG
76
77
CFLAGS     :=  $(C_FLAGS) $(DEBUGABLE) -Wall $(OPTIMIZABLE) -fPIC $(addprefix -I,$(INCLUDEDIRS))  -D_LINUX_X86  $(DEFINES)
78
79
CXXFLAGS   :=  $(CFLAGS)
80
81
LINKOPTS   :=  $(L_FLAGS) $(DEBUGABLE) -shared -Wl,-soname,$(TARGETSONAME) -o $(TARGETDIR)/$(TARGETREALNAME) $(addprefix -L,$(LIBDIRS))
82
83
84
#-----------------------------------
85
#   general commands and options
86
#-----------------------------------
87
88
CC          :=  gcc
89
CXX         :=  $(CC)
90
91
SOURCE     :=  $(wildcard *.c)  $(wildcard *.cpp)
92
93
OBJS       :=  $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
94
95
REMOVEFILE :=  rm -f
96
CREATELINK :=  ln -sf
97
98
99
#-----------------------------------
100
#   "make" rules
101
#-----------------------------------
102
103
.PHONY : default everything objs clean veryclean rebuild $(TARGET)
104
105
106
default : $(TARGET)
107
108
109
objs : $(OBJS)
110
111
112
clean :
113
	$(REMOVEFILE) *.o
114
115
116
veryclean: clean
117
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETLIB)
118
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETSONAME)
119
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETREALNAME)
120
121
122
rebuild: veryclean everything
123
124
125
$(TARGET) : $(OBJS)
126
	$(CC) $(LINKOPTS) $(OBJS) $(addprefix -l,$(LIBS))
127
	$(CREATELINK) $(TARGETREALNAME)  $(TARGETDIR)/$(TARGETSONAME)
128
	$(CREATELINK) $(TARGETSONAME)    $(TARGETDIR)/$(TARGETLIB)
129
(-)src-native-new/src/agents/perfmon/rac/rac.make (+129 lines)
Added Link Here
1
2
################################################################################
3
#                                       
4
#  makefile:  rac project  
5
#                                       
6
# $Id
7
################################################################################
8
9
10
#-----------------------------------
11
#
12
#   Customizable section
13
#
14
#   - The TARGETREALNAME variable specifies the name of the library file
15
#     that will be generated, this includes a base (TARGETLIB) plus	a 
16
#     version number plus a minor number plus a release number
17
#   - The TARGETSONAME variable specifies a file name that has just the
18
#     library name plus the major version number
19
#   - The TARGETLIB variable specifies the base library name
20
#   - The TARGETSONAME and TARGETLIB are generated as symbolic links
21
#     when the library is built
22
#
23
#-----------------------------------
24
TARGET         :=  librac
25
TARGETDIR      :=  ../../../../lib
26
27
if [ x$VERSIONNUM = x ]; then export VERSIONNUM=0; fi
28
if [ x$MINORNUM = x ]; then export MINORNUM=0; fi
29
if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi
30
31
TARGETLIB      :=  $(TARGET).so
32
TARGETSONAME   :=  $(TARGETLIB).$(VERSIONNUM)
33
TARGETREALNAME :=  $(TARGETSONAME).$(MINORNUM).$(RELEASENUM)
34
35
36
#-----------------------------------
37
#   list of additional INCLUDE directories to search headers from
38
#      (separated by blanks)
39
#-----------------------------------
40
INCLUDEDIRS    :=  . ../resutils  ../../../../include $(JAVA_HOME)/include $(JAVA_HOME)/include/linux ../../RABindings ../../../transport/RACommon ../../../transport/RASocket ../../../transport/RASharedMemory ../../../transport/RADataTransfer
41
42
43
#-----------------------------------
44
#   list of additional libraries to be linked with
45
#      (separated by blanks)
46
#-----------------------------------
47
LIBS       :=  dl resutils
48
49
#-----------------------------------
50
#   list of additional library directories to search from
51
#      (separated by blanks)
52
#-----------------------------------
53
LIBDIRS    :=  ../../../../lib
54
55
56
#-----------------------------------
57
#
58
#   Compiler options
59
#
60
#      -g       produce debug info
61
#      -Wall    enable all types of warnings
62
#      -O3      highest level of code optimization
63
#      -fPIC    generate position-independent code (PIC).
64
#               This is required for building shared library.
65
#      -c       compile only
66
#
67
#   Linking options
68
#
69
#       -Wl       pass options to linker
70
#       -shared   produce shared library
71
#       -L        add the given directory to the search path for libraries
72
#
73
#-----------------------------------
74
75
DEFINES    := -DLINUX
76
77
CFLAGS     :=  $(C_FLAGS) $(DEBUGABLE) -Wall $(OPTIMIZABLE) -fPIC $(addprefix -I,$(INCLUDEDIRS))  -D_LINUX_X86  $(DEFINES)
78
79
CXXFLAGS   :=  $(CFLAGS)
80
81
LINKOPTS   :=  $(L_FLAGS) $(DEBUGABLE) -shared -Wl,-soname,$(TARGETSONAME) -o $(TARGETDIR)/$(TARGETREALNAME) $(addprefix -L,$(LIBDIRS))
82
83
84
#-----------------------------------
85
#   general commands and options
86
#-----------------------------------
87
88
CC          :=  gcc
89
CXX         :=  $(CC)
90
91
SOURCE     :=  $(wildcard *.c) $(wildcard *.cpp)
92
93
OBJS       :=  $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
94
95
REMOVEFILE :=  rm -f
96
CREATELINK :=  ln -sf
97
98
99
#-----------------------------------
100
#   "make" rules
101
#-----------------------------------
102
103
.PHONY : default everything objs clean veryclean rebuild $(TARGET)
104
105
106
default : $(TARGET)
107
108
109
objs : $(OBJS)
110
111
112
clean :
113
	$(REMOVEFILE) *.o
114
115
116
veryclean: clean
117
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETLIB)
118
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETSONAME)
119
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETREALNAME)
120
121
122
rebuild: veryclean everything
123
124
125
$(TARGET) : $(OBJS)
126
	$(CC) $(LINKOPTS) $(OBJS) $(addprefix -l,$(LIBS))
127
	$(CREATELINK) $(TARGETREALNAME)  $(TARGETDIR)/$(TARGETSONAME)
128
	$(CREATELINK) $(TARGETSONAME)    $(TARGETDIR)/$(TARGETLIB)
129
(-)src-native-new/src/agents/perfmon/rac/resource.h (+20 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: resource.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifdef APSTUDIO_INVOKED
14
#ifndef APSTUDIO_READONLY_SYMBOLS
15
#define _APS_NEXT_RESOURCE_VALUE        101
16
#define _APS_NEXT_COMMAND_VALUE         40001
17
#define _APS_NEXT_CONTROL_VALUE         1000
18
#define _APS_NEXT_SYMED_VALUE           101
19
#endif
20
#endif
(-)src-native-new/src/agents/perfmon/WinBuild/sysperf.mak (+231 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on sysperf.dsp
2
!IF "$(CFG)" == ""
3
CFG=sysperf - Win32 Release
4
!MESSAGE No configuration specified. Defaulting to sysperf - Win32 Release.
5
!ENDIF 
6
7
!IF "$(CFG)" != "sysperf - Win32 Release" && "$(CFG)" != "sysperf - Win32 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "sysperf.mak" CFG="sysperf - Win32 Release"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "sysperf - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
17
!MESSAGE "sysperf - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
18
!MESSAGE 
19
!ERROR An invalid configuration is specified.
20
!ENDIF 
21
22
!IF "$(OS)" == "Windows_NT"
23
NULL=
24
!ELSE 
25
NULL=nul
26
!ENDIF 
27
28
!IF  "$(CFG)" == "sysperf - Win32 Release"
29
30
OUTDIR=.\bin
31
INTDIR=.\Release
32
# Begin Custom Macros
33
OutDir=.\bin
34
# End Custom Macros
35
36
ALL : "$(OUTDIR)\sysperf.dll"
37
38
39
CLEAN :
40
	-@erase "$(INTDIR)\perfcalc.obj"
41
	-@erase "$(INTDIR)\perfcontrol.obj"
42
	-@erase "$(INTDIR)\vc60.idb"
43
	-@erase "$(INTDIR)\version.res"
44
	-@erase "$(OUTDIR)\sysperf.dll"
45
	-@erase "$(OUTDIR)\sysperf.exp"
46
	-@erase "$(OUTDIR)\sysperf.lib"
47
48
"$(OUTDIR)" :
49
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
50
51
"$(INTDIR)" :
52
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
53
54
CPP=cl.exe
55
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "..\resutils" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYSPERF_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
56
57
.c{$(INTDIR)}.obj::
58
   $(CPP) @<<
59
   $(CPP_PROJ) $< 
60
<<
61
62
.cpp{$(INTDIR)}.obj::
63
   $(CPP) @<<
64
   $(CPP_PROJ) $< 
65
<<
66
67
.cxx{$(INTDIR)}.obj::
68
   $(CPP) @<<
69
   $(CPP_PROJ) $< 
70
<<
71
72
.c{$(INTDIR)}.sbr::
73
   $(CPP) @<<
74
   $(CPP_PROJ) $< 
75
<<
76
77
.cpp{$(INTDIR)}.sbr::
78
   $(CPP) @<<
79
   $(CPP_PROJ) $< 
80
<<
81
82
.cxx{$(INTDIR)}.sbr::
83
   $(CPP) @<<
84
   $(CPP_PROJ) $< 
85
<<
86
87
MTL=midl.exe
88
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
89
RSC=rc.exe
90
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
91
BSC32=bscmake.exe
92
BSC32_FLAGS=/nologo /o"$(OUTDIR)\sysperf.bsc" 
93
BSC32_SBRS= \
94
	
95
LINK32=link.exe
96
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib rac.lib mpr.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\sysperf.pdb" /machine:I386 /out:"$(OUTDIR)\sysperf.dll" /implib:"$(OUTDIR)\sysperf.lib" /libpath:"./bin" 
97
LINK32_OBJS= \
98
	"$(INTDIR)\perfcalc.obj" \
99
	"$(INTDIR)\perfcontrol.obj" \
100
	"$(INTDIR)\version.res"
101
102
"$(OUTDIR)\sysperf.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
103
    $(LINK32) @<<
104
  $(LINK32_FLAGS) $(LINK32_OBJS)
105
<<
106
107
!ELSEIF  "$(CFG)" == "sysperf - Win32 Debug"
108
109
OUTDIR=.\bin
110
INTDIR=.\Debug
111
# Begin Custom Macros
112
OutDir=.\bin
113
# End Custom Macros
114
115
ALL : "$(OUTDIR)\sysperf.dll"
116
117
118
CLEAN :
119
	-@erase "$(INTDIR)\perfcalc.obj"
120
	-@erase "$(INTDIR)\perfcontrol.obj"
121
	-@erase "$(INTDIR)\vc60.idb"
122
	-@erase "$(INTDIR)\version.res"
123
	-@erase "$(OUTDIR)\sysperf.dll"
124
	-@erase "$(OUTDIR)\sysperf.exp"
125
	-@erase "$(OUTDIR)\sysperf.lib"
126
127
"$(OUTDIR)" :
128
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
129
130
"$(INTDIR)" :
131
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
132
133
CPP=cl.exe
134
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "..\resutils" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYSPERF_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
135
136
.c{$(INTDIR)}.obj::
137
   $(CPP) @<<
138
   $(CPP_PROJ) $< 
139
<<
140
141
.cpp{$(INTDIR)}.obj::
142
   $(CPP) @<<
143
   $(CPP_PROJ) $< 
144
<<
145
146
.cxx{$(INTDIR)}.obj::
147
   $(CPP) @<<
148
   $(CPP_PROJ) $< 
149
<<
150
151
.c{$(INTDIR)}.sbr::
152
   $(CPP) @<<
153
   $(CPP_PROJ) $< 
154
<<
155
156
.cpp{$(INTDIR)}.sbr::
157
   $(CPP) @<<
158
   $(CPP_PROJ) $< 
159
<<
160
161
.cxx{$(INTDIR)}.sbr::
162
   $(CPP) @<<
163
   $(CPP_PROJ) $< 
164
<<
165
166
MTL=midl.exe
167
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
168
RSC=rc.exe
169
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
170
BSC32=bscmake.exe
171
BSC32_FLAGS=/nologo /o"$(OUTDIR)\sysperf.bsc" 
172
BSC32_SBRS= \
173
	
174
LINK32=link.exe
175
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib rac.lib mpr.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\sysperf.pdb" /machine:I386 /out:"$(OUTDIR)\sysperf.dll" /implib:"$(OUTDIR)\sysperf.lib" /libpath:"./bin" 
176
LINK32_OBJS= \
177
	"$(INTDIR)\perfcalc.obj" \
178
	"$(INTDIR)\perfcontrol.obj" \
179
	"$(INTDIR)\version.res"
180
181
"$(OUTDIR)\sysperf.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
182
    $(LINK32) @<<
183
  $(LINK32_FLAGS) $(LINK32_OBJS)
184
<<
185
186
!ENDIF 
187
188
189
!IF "$(NO_EXTERNAL_DEPS)" != "1"
190
!IF EXISTS("sysperf.dep")
191
!INCLUDE "sysperf.dep"
192
!ELSE 
193
!MESSAGE Warning: cannot find "sysperf.dep"
194
!ENDIF 
195
!ENDIF 
196
197
198
!IF "$(CFG)" == "sysperf - Win32 Release" || "$(CFG)" == "sysperf - Win32 Debug"
199
SOURCE=..\sysperf\perfcalc.c
200
201
"$(INTDIR)\perfcalc.obj" : $(SOURCE) "$(INTDIR)"
202
	$(CPP) $(CPP_PROJ) $(SOURCE)
203
204
205
SOURCE=..\sysperf\perfcontrol.c
206
207
"$(INTDIR)\perfcontrol.obj" : $(SOURCE) "$(INTDIR)"
208
	$(CPP) $(CPP_PROJ) $(SOURCE)
209
210
211
SOURCE=..\sysperf\version.rc
212
213
!IF  "$(CFG)" == "sysperf - Win32 Release"
214
215
216
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
217
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "\TPTP-4.2.0-200512011334C\workspace\org.eclipse.tptp.platform.agentcontroller\src-native\collection\collectors\perfmon\sysperf" /d "NDEBUG" $(SOURCE)
218
219
220
!ELSEIF  "$(CFG)" == "sysperf - Win32 Debug"
221
222
223
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
224
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "\TPTP-4.2.0-200512011334C\workspace\org.eclipse.tptp.platform.agentcontroller\src-native\collection\collectors\perfmon\sysperf" /d "NDEBUG" $(SOURCE)
225
226
227
!ENDIF 
228
229
230
!ENDIF 
231
(-)src-native-new/src/agents/perfmon/WinBuild/sysperf.mak64 (+384 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on sysperf.dsp
2
!IF "$(CFG)" == ""
3
CFG=sysperf - IA64 Release
4
!MESSAGE No configuration specified. Defaulting to sysperf - IA64 Release.
5
!ENDIF 
6
7
!IF "$(CFG)" != "sysperf - IA64 Release" && "$(CFG)" != "sysperf - IA64 Debug" && "$(CFG)" != "sysperf - X64 Release" && "$(CFG)" != "sysperf - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "sysperf.mak64" CFG="sysperf - IA64 Release"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "sysperf - IA64 Release"
17
!MESSAGE "sysperf - IA64 Debug"
18
!MESSAGE "sysperf - X64 Release"
19
!MESSAGE "sysperf - X64 Debug"
20
!MESSAGE 
21
!ERROR An invalid configuration is specified.
22
!ENDIF 
23
24
!IF "$(OS)" == "Windows_NT"
25
NULL=
26
!ELSE 
27
NULL=nul
28
!ENDIF 
29
30
!IF  "$(CFG)" == "sysperf - IA64 Release"
31
32
OUTDIR=..\..\..\..\bin
33
INTDIR=.\Release
34
# Begin Custom Macros
35
OutDir=..\..\..\..\bin
36
# End Custom Macros
37
38
ALL : "$(OUTDIR)\sysperf.dll"
39
40
41
CLEAN :
42
	-@erase "$(INTDIR)\perfcalc.obj"
43
	-@erase "$(INTDIR)\perfcontrol.obj"
44
	-@erase "$(INTDIR)\vc60.idb"
45
	-@erase "$(INTDIR)\version.res"
46
	-@erase "$(OUTDIR)\sysperf.dll"
47
	-@erase "$(OUTDIR)\..\lib\sysperf.exp"
48
	-@erase "$(OUTDIR)\..\lib\sysperf.lib"
49
50
"$(OUTDIR)" :
51
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
52
53
"$(INTDIR)" :
54
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
55
56
CPP=cl.exe
57
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /I "..\resutils" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYSPERF_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
58
59
.c{$(INTDIR)}.obj::
60
   $(CPP) @<<
61
   $(CPP_PROJ) $< 
62
<<
63
64
.cpp{$(INTDIR)}.obj::
65
   $(CPP) @<<
66
   $(CPP_PROJ) $< 
67
<<
68
69
.cxx{$(INTDIR)}.obj::
70
   $(CPP) @<<
71
   $(CPP_PROJ) $< 
72
<<
73
74
.c{$(INTDIR)}.sbr::
75
   $(CPP) @<<
76
   $(CPP_PROJ) $< 
77
<<
78
79
.cpp{$(INTDIR)}.sbr::
80
   $(CPP) @<<
81
   $(CPP_PROJ) $< 
82
<<
83
84
.cxx{$(INTDIR)}.sbr::
85
   $(CPP) @<<
86
   $(CPP_PROJ) $< 
87
<<
88
89
MTL=midl.exe
90
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
91
RSC=rc.exe
92
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
93
94
LINK32=link.exe
95
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib resutils.lib rac.lib mpr.lib bufferoverflowU.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\sysperf.pdb" /out:"$(OUTDIR)\sysperf.dll" /implib:"$(OUTDIR)\..\lib\sysperf.lib" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
96
LINK32_OBJS= \
97
	"$(INTDIR)\perfcalc.obj" \
98
	"$(INTDIR)\perfcontrol.obj" \
99
	"$(INTDIR)\version.res"
100
101
"$(OUTDIR)\sysperf.dll" : "$(OUTDIR)" $(LINK32_OBJS)
102
    $(LINK32) @<<
103
  $(LINK32_FLAGS) $(LINK32_OBJS)
104
<<
105
106
!ELSEIF  "$(CFG)" == "sysperf - IA64 Debug"
107
108
OUTDIR=..\..\..\..\bin
109
INTDIR=.\Debug
110
# Begin Custom Macros
111
OutDir=..\..\..\..\bin
112
# End Custom Macros
113
114
ALL : "$(OUTDIR)\sysperf.dll"
115
116
117
CLEAN :
118
	-@erase "$(INTDIR)\perfcalc.obj"
119
	-@erase "$(INTDIR)\perfcontrol.obj"
120
	-@erase "$(INTDIR)\vc60.idb"
121
	-@erase "$(INTDIR)\version.res"
122
	-@erase "$(OUTDIR)\sysperf.dll"
123
	-@erase "$(OUTDIR)\..\lib\sysperf.exp"
124
	-@erase "$(OUTDIR)\..\lib\sysperf.lib"
125
126
"$(OUTDIR)" :
127
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
128
129
"$(INTDIR)" :
130
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
131
132
CPP=cl.exe
133
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /I "..\resutils" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYSPERF_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
134
135
.c{$(INTDIR)}.obj::
136
   $(CPP) @<<
137
   $(CPP_PROJ) $< 
138
<<
139
140
.cpp{$(INTDIR)}.obj::
141
   $(CPP) @<<
142
   $(CPP_PROJ) $< 
143
<<
144
145
.cxx{$(INTDIR)}.obj::
146
   $(CPP) @<<
147
   $(CPP_PROJ) $< 
148
<<
149
150
.c{$(INTDIR)}.sbr::
151
   $(CPP) @<<
152
   $(CPP_PROJ) $< 
153
<<
154
155
.cpp{$(INTDIR)}.sbr::
156
   $(CPP) @<<
157
   $(CPP_PROJ) $< 
158
<<
159
160
.cxx{$(INTDIR)}.sbr::
161
   $(CPP) @<<
162
   $(CPP_PROJ) $< 
163
<<
164
165
MTL=midl.exe
166
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
167
RSC=rc.exe
168
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
169
170
LINK32=link.exe
171
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib resutils.lib rac.lib mpr.lib bufferoverflowU.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\sysperf.pdb" /out:"$(OUTDIR)\sysperf.dll" /implib:"$(OUTDIR)\..\lib\sysperf.lib" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
172
LINK32_OBJS= \
173
	"$(INTDIR)\perfcalc.obj" \
174
	"$(INTDIR)\perfcontrol.obj" \
175
	"$(INTDIR)\version.res"
176
177
"$(OUTDIR)\sysperf.dll" : "$(OUTDIR)" $(LINK32_OBJS)
178
    $(LINK32) @<<
179
  $(LINK32_FLAGS) $(LINK32_OBJS)
180
<<
181
182
!ELSEIF  "$(CFG)" == "sysperf - X64 Release"
183
184
OUTDIR=..\..\..\..\bin
185
INTDIR=.\Release
186
# Begin Custom Macros
187
OutDir=..\..\..\..\bin
188
# End Custom Macros
189
190
ALL : "$(OUTDIR)\sysperf.dll"
191
192
193
CLEAN :
194
	-@erase "$(INTDIR)\perfcalc.obj"
195
	-@erase "$(INTDIR)\perfcontrol.obj"
196
	-@erase "$(INTDIR)\vc60.idb"
197
	-@erase "$(INTDIR)\version.res"
198
	-@erase "$(OUTDIR)\sysperf.dll"
199
	-@erase "$(OUTDIR)\..\lib\sysperf.exp"
200
	-@erase "$(OUTDIR)\..\lib\sysperf.lib"
201
202
"$(OUTDIR)" :
203
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
204
205
"$(INTDIR)" :
206
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
207
208
CPP=cl.exe
209
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /I "..\resutils" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYSPERF_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
210
211
.c{$(INTDIR)}.obj::
212
   $(CPP) @<<
213
   $(CPP_PROJ) $< 
214
<<
215
216
.cpp{$(INTDIR)}.obj::
217
   $(CPP) @<<
218
   $(CPP_PROJ) $< 
219
<<
220
221
.cxx{$(INTDIR)}.obj::
222
   $(CPP) @<<
223
   $(CPP_PROJ) $< 
224
<<
225
226
.c{$(INTDIR)}.sbr::
227
   $(CPP) @<<
228
   $(CPP_PROJ) $< 
229
<<
230
231
.cpp{$(INTDIR)}.sbr::
232
   $(CPP) @<<
233
   $(CPP_PROJ) $< 
234
<<
235
236
.cxx{$(INTDIR)}.sbr::
237
   $(CPP) @<<
238
   $(CPP_PROJ) $< 
239
<<
240
241
MTL=midl.exe
242
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
243
RSC=rc.exe
244
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
245
246
LINK32=link.exe
247
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib resutils.lib rac.lib mpr.lib bufferoverflowU.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\sysperf.pdb" /out:"$(OUTDIR)\sysperf.dll" /implib:"$(OUTDIR)\..\lib\sysperf.lib" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
248
LINK32_OBJS= \
249
	"$(INTDIR)\perfcalc.obj" \
250
	"$(INTDIR)\perfcontrol.obj" \
251
	"$(INTDIR)\version.res"
252
253
"$(OUTDIR)\sysperf.dll" : "$(OUTDIR)" $(LINK32_OBJS)
254
    $(LINK32) @<<
255
  $(LINK32_FLAGS) $(LINK32_OBJS)
256
<<
257
258
!ELSEIF  "$(CFG)" == "sysperf - X64 Debug"
259
260
OUTDIR=..\..\..\..\bin
261
INTDIR=.\Debug
262
# Begin Custom Macros
263
OutDir=..\..\..\..\bin
264
# End Custom Macros
265
266
ALL : "$(OUTDIR)\sysperf.dll"
267
268
269
CLEAN :
270
	-@erase "$(INTDIR)\perfcalc.obj"
271
	-@erase "$(INTDIR)\perfcontrol.obj"
272
	-@erase "$(INTDIR)\vc60.idb"
273
	-@erase "$(INTDIR)\version.res"
274
	-@erase "$(OUTDIR)\sysperf.dll"
275
	-@erase "$(OUTDIR)\..\lib\sysperf.exp"
276
	-@erase "$(OUTDIR)\..\lib\sysperf.lib"
277
278
"$(OUTDIR)" :
279
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
280
281
"$(INTDIR)" :
282
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
283
284
CPP=cl.exe
285
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /I "..\resutils" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYSPERF_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
286
287
.c{$(INTDIR)}.obj::
288
   $(CPP) @<<
289
   $(CPP_PROJ) $< 
290
<<
291
292
.cpp{$(INTDIR)}.obj::
293
   $(CPP) @<<
294
   $(CPP_PROJ) $< 
295
<<
296
297
.cxx{$(INTDIR)}.obj::
298
   $(CPP) @<<
299
   $(CPP_PROJ) $< 
300
<<
301
302
.c{$(INTDIR)}.sbr::
303
   $(CPP) @<<
304
   $(CPP_PROJ) $< 
305
<<
306
307
.cpp{$(INTDIR)}.sbr::
308
   $(CPP) @<<
309
   $(CPP_PROJ) $< 
310
<<
311
312
.cxx{$(INTDIR)}.sbr::
313
   $(CPP) @<<
314
   $(CPP_PROJ) $< 
315
<<
316
317
MTL=midl.exe
318
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
319
RSC=rc.exe
320
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
321
322
LINK32=link.exe
323
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib resutils.lib rac.lib mpr.lib bufferoverflowU.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\sysperf.pdb" /out:"$(OUTDIR)\sysperf.dll" /implib:"$(OUTDIR)\..\lib\sysperf.lib" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
324
LINK32_OBJS= \
325
	"$(INTDIR)\perfcalc.obj" \
326
	"$(INTDIR)\perfcontrol.obj" \
327
	"$(INTDIR)\version.res"
328
329
"$(OUTDIR)\sysperf.dll" : "$(OUTDIR)" $(LINK32_OBJS)
330
    $(LINK32) @<<
331
  $(LINK32_FLAGS) $(LINK32_OBJS)
332
<<
333
334
!ENDIF 
335
336
337
!IF "$(CFG)" == "sysperf - IA64 Release" || "$(CFG)" == "sysperf - IA64 Debug" || "$(CFG)" == "sysperf - X64 Release" || "$(CFG)" == "sysperf - X64 Debug"
338
SOURCE=..\sysperf\perfcalc.c
339
340
"$(INTDIR)\perfcalc.obj" : $(SOURCE) "$(INTDIR)"
341
	$(CPP) $(CPP_PROJ) $(SOURCE)
342
343
344
SOURCE=..\sysperf\perfcontrol.c
345
346
"$(INTDIR)\perfcontrol.obj" : $(SOURCE) "$(INTDIR)"
347
	$(CPP) $(CPP_PROJ) $(SOURCE)
348
349
350
SOURCE=..\sysperf\version.rc
351
352
!IF  "$(CFG)" == "sysperf - IA64 Release"
353
354
355
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
356
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" $(SOURCE)
357
358
359
!ELSEIF  "$(CFG)" == "sysperf - IA64 Debug"
360
361
362
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
363
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" $(SOURCE)
364
365
366
!ELSEIF  "$(CFG)" == "sysperf - X64 Release"
367
368
369
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
370
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" $(SOURCE)
371
372
373
!ELSEIF  "$(CFG)" == "sysperf - X64 Debug"
374
375
376
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
377
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" $(SOURCE)
378
379
380
!ENDIF 
381
382
383
!ENDIF 
384
(-)src-native-new/src/transport/RADataTransfer/resource.h (+28 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: resource.h,v 1.4 2006/04/06 15:48:13 samwai Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
//{{NO_DEPENDENCIES}}
14
// Microsoft Developer Studio generated include file.
15
// Used by version.rc
16
//
17
18
19
// Next default values for new objects
20
//
21
#ifdef APSTUDIO_INVOKED
22
#ifndef APSTUDIO_READONLY_SYMBOLS
23
#define _APS_NEXT_RESOURCE_VALUE        101
24
#define _APS_NEXT_COMMAND_VALUE         40001
25
#define _APS_NEXT_CONTROL_VALUE         1000
26
#define _APS_NEXT_SYMED_VALUE           101
27
#endif
28
#endif
(-)src-native-new/src/agents/perfmon/sysperf/perfconstants.h (+23 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 Scapa Technologies Limited and others
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
14
15
16
#ifndef __PERFCONSTANTS_H__
17
#define __PERFCONSTANTS_H__
18
19
static char* PERFMON_KEY_HOST = "PERFMON_REG_HOST";
20
static char* PERFMON_USERNAME = "PERFMON_USERNAME";
21
static char* PERFMON_PASSWORD = "PERFMON_PASSWORD";
22
23
#endif
(-)src-native-new/src/agents/java/resource.h (+28 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: resource.h,v 1.4 2006/04/06 15:48:11 samwai Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
//{{NO_DEPENDENCIES}}
14
// Microsoft Developer Studio generated include file.
15
// Used by version.rc
16
//
17
18
19
// Next default values for new objects
20
//
21
#ifdef APSTUDIO_INVOKED
22
#ifndef APSTUDIO_READONLY_SYMBOLS
23
#define _APS_NEXT_RESOURCE_VALUE        101
24
#define _APS_NEXT_COMMAND_VALUE         40001
25
#define _APS_NEXT_CONTROL_VALUE         1000
26
#define _APS_NEXT_SYMED_VALUE           101
27
#endif
28
#endif
(-)src-native-new/src/agents/native/java_profiler/piAgent.exp (+21 lines)
Added Link Here
1
#! libpiAgent.so exports
2
JVM_OnLoad
3
Java_com_ibm_etools_logging_tracing_agent_Callback_JVMPICatch0
4
Java_com_ibm_etools_logging_tracing_agent_Callback_JVMPIThrow0
5
Java_com_ibm_etools_logging_tracing_agent_Callback_JVMPICoverage0
6
Java_org_eclipse_hyades_collection_profiler_Profiler_initialize0
7
Java_org_eclipse_hyades_collection_profiler_Profiler_setMode0
8
Java_org_eclipse_hyades_collection_profiler_Profiler_startProfiling0
9
Java_org_eclipse_hyades_collection_profiler_Profiler_stopProfiling0
10
Java_org_eclipse_hyades_collection_profiler_Profiler_markHeap0
11
Java_org_eclipse_hyades_collection_profiler_Profiler_analyzeHeap0
12
Java_org_eclipse_hyades_collection_profiler_Profiler_optimizedHeapDump0
13
Java_org_eclipse_hyades_collection_profiler_Profiler_stopOptimizedHeapInfoSnapshot0
14
Java_org_eclipse_hyades_collection_profiler_Profiler_disableGC0
15
Java_org_eclipse_hyades_collection_profiler_Profiler_enableGC0
16
Java_org_eclipse_hyades_collection_profiler_Profiler_runGC0
17
Java_org_eclipse_hyades_collection_profiler_Profiler_release0
18
Java_org_eclipse_hyades_collection_profiler_Profiler_emitXMLFragment0
19
Java_org_eclipse_hyades_collection_profiler_Profiler_getCurrentTime0
20
Java_org_eclipse_hyades_collection_profiler_Profiler_getCurrentThreadCpuTime0
21
(-)src-native-new/src/agents/perfmon/PerfmonAgent/resinterface.h (+62 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: resinterface.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
//////////////////////////////////////////////////////////////
14
//	The function definitions for the resourceDLL
15
//////////////////////////////////////////////////////////////
16
//
17
//	The four function defintions to be implemented by the custom
18
//	resource DLL.
19
//
20
//////////////////////////////////////////////////////////////
21
#ifndef __RES_INTERFACE__H__
22
#define __RES_INTERFACE__H__
23
24
#include "hashtable.h"
25
#include "system.h"
26
27
//
28
//	The startup method - called once to initialize the resource data
29
//	returning errorcode
30
//
31
typedef int		(*LPSTARTUP)	(HashTable*, HashTable*, HashTable*);
32
33
//
34
//	The shutdown method - called once when the agent is stopped
35
//	and also returns errorcode
36
//
37
typedef int		(*LPSHUTDOWN)	();
38
39
//
40
//	Get the tree data : returns a char** of the tree strings with each stirngs of the form 
41
//		parent ID \0 ID \0 name \0 help \0 suffix \0
42
//	where int* returns the number of strings in the array. 
43
//
44
//	The first hashTable is the request hash
45
//	The second hashTable is the variable hash
46
typedef char**	(*LPGETTREE)	(int*);
47
48
//
49
//	Get resource results : char** returns strings of the form
50
//		ID \0 value \0
51
//	where int* is the number of returned results
52
//
53
//	The first hashTable is the filter hash
54
//	The second hashTable is the variable hash	
55
typedef char**	(*LPGETRESULTS)	(int*);
56
57
typedef void	(*LPDUMPMEMORY)	();
58
59
typedef char* (*LPGETAGENTNAME) ();
60
61
#endif
62
(-)src-native-new/src/HCLauncher/launcher_common.h (+59 lines)
Added Link Here
1
/**********************************************************************
2
Copyright (c) 2005 IBM Corporation and others.
3
All rights reserved.   This program and the accompanying materials
4
are made available under the terms of the Eclipse Public License v1.0
5
which accompanies this distribution, and is available at
6
http://www.eclipse.org/legal/epl-v10.html
7
$Id: launcher_common.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 
9
Contributors:
10
    IBM Corporation - initial implementation
11
**********************************************************************/
12
13
#ifndef _LAUNCHER_H_
14
#define _LAUNCHER_H_
15
16
#define MAX_ARGS 64
17
#define MAX_ENV 512
18
19
#include "RAComm.h"
20
#include "hclaunch.h"
21
#include "launcher_md.h"
22
#include "launcher_error.h"
23
#include <stdio.h>
24
25
26
/*
27
 * The structure that contains information regarding a console connection
28
 */
29
typedef struct {
30
	RA_HANDLE remote;
31
	RA_HANDLE in;
32
	RA_HANDLE out;
33
	RA_HANDLE err;
34
} RemoteConsole_t;
35
36
37
/* Copyright */
38
static char *kCBIBMCopyright="(c) Copyright IBM Corporation 2000,2001";
39
40
/** START_PROCESS ***************************************************
41
  * This function lauches a process on the current OS.  Using the
42
  * specified executable and arguments it checks the server configuration
43
  * to determine if the specified process is allowed to be launched, and
44
  * if so, creates the specified environment for the process before it
45
  * is launched.
46
  * @param               exe - the alias name of the process to launch.
47
  * @param              args - the arguments for the process.
48
  * @param          location - the directory to launch the process in.
49
  * @param   remoteCOnsoleIP - the IP address of the remote console.
50
  * @param remoteConsolePort - the port of the remote console.
51
  * @param  finalEnvironment -the hc_array_t structure to recieve the process environment.
52
  */
53
PID hc_startProcess(char *exe,
54
					char *cmdline,
55
					char *location,
56
					char *env,
57
					RemoteConsole_t *console);
58
59
#endif
(-)src-native-new/src/agents/native/WinBuild/heapsnapshots.dsp (+124 lines)
Added Link Here
1
# Microsoft Developer Studio Project File - Name="heapsnapshots" - Package Owner=<4>
2
# Microsoft Developer Studio Generated Build File, Format Version 6.00
3
# ** DO NOT EDIT **
4
5
# TARGTYPE "Win32 (x86) Static Library" 0x0104
6
7
CFG=heapsnapshots - Win32 Debug
8
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9
!MESSAGE use the Export Makefile command and run
10
!MESSAGE 
11
!MESSAGE NMAKE /f "heapsnapshots.mak".
12
!MESSAGE 
13
!MESSAGE You can specify a configuration when running NMAKE
14
!MESSAGE by defining the macro CFG on the command line. For example:
15
!MESSAGE 
16
!MESSAGE NMAKE /f "heapsnapshots.mak" CFG="heapsnapshots - Win32 Debug"
17
!MESSAGE 
18
!MESSAGE Possible choices for configuration are:
19
!MESSAGE 
20
!MESSAGE "heapsnapshots - Win32 Release" (based on "Win32 (x86) Static Library")
21
!MESSAGE "heapsnapshots - Win32 Debug" (based on "Win32 (x86) Static Library")
22
!MESSAGE 
23
24
# Begin Project
25
# PROP AllowPerConfigDependencies 0
26
# PROP Scc_ProjName "heapsnapshots"
27
# PROP Scc_LocalPath ".."
28
CPP=cl.exe
29
RSC=rc.exe
30
31
!IF  "$(CFG)" == "heapsnapshots - Win32 Release"
32
33
# PROP BASE Use_MFC 0
34
# PROP BASE Use_Debug_Libraries 0
35
# PROP BASE Output_Dir "heapsnapshots___Win32_Release"
36
# PROP BASE Intermediate_Dir "heapsnapshots___Win32_Release"
37
# PROP BASE Target_Dir ""
38
# PROP Use_MFC 0
39
# PROP Use_Debug_Libraries 0
40
# PROP Output_Dir "bin"
41
# PROP Intermediate_Dir "Release"
42
# PROP Target_Dir ""
43
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
44
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
45
# ADD BASE RSC /l 0x409 /d "NDEBUG"
46
# ADD RSC /l 0x409 /d "NDEBUG"
47
BSC32=bscmake.exe
48
# ADD BASE BSC32 /nologo
49
# ADD BSC32 /nologo
50
LIB32=link.exe -lib
51
# ADD BASE LIB32 /nologo
52
# ADD LIB32 /nologo
53
54
!ELSEIF  "$(CFG)" == "heapsnapshots - Win32 Debug"
55
56
# PROP BASE Use_MFC 0
57
# PROP BASE Use_Debug_Libraries 1
58
# PROP BASE Output_Dir "heapsnapshots___Win32_Debug"
59
# PROP BASE Intermediate_Dir "heapsnapshots___Win32_Debug"
60
# PROP BASE Target_Dir ""
61
# PROP Use_MFC 0
62
# PROP Use_Debug_Libraries 1
63
# PROP Output_Dir "bin"
64
# PROP Intermediate_Dir "Debug"
65
# PROP Target_Dir ""
66
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
67
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
68
# ADD BASE RSC /l 0x409 /d "_DEBUG"
69
# ADD RSC /l 0x409 /d "_DEBUG"
70
BSC32=bscmake.exe
71
# ADD BASE BSC32 /nologo
72
# ADD BSC32 /nologo
73
LIB32=link.exe -lib
74
# ADD BASE LIB32 /nologo
75
# ADD LIB32 /nologo
76
77
!ENDIF 
78
79
# Begin Target
80
81
# Name "heapsnapshots - Win32 Release"
82
# Name "heapsnapshots - Win32 Debug"
83
# Begin Group "Source Files"
84
85
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
86
# Begin Source File
87
88
SOURCE=..\heapsnapshots\AbstractHeapSnapshotManager.cpp
89
# End Source File
90
# Begin Source File
91
92
SOURCE=..\heapsnapshots\StatelessHeapSnapshotManager.cpp
93
# End Source File
94
# End Group
95
# Begin Group "Header Files"
96
97
# PROP Default_Filter "h;hpp;hxx;hm;inl"
98
# Begin Source File
99
100
SOURCE=..\heapsnapshots\AbstractHeapSnapshotManager.h
101
# End Source File
102
# Begin Source File
103
104
SOURCE=..\heapsnapshots\HeapSnapshotManager.h
105
# End Source File
106
# Begin Source File
107
108
SOURCE=..\heapsnapshots\LBTimestamp.h
109
# End Source File
110
# Begin Source File
111
112
SOURCE=..\heapsnapshots\SnapshotAgentInterface.h
113
# End Source File
114
# Begin Source File
115
116
SOURCE=..\heapsnapshots\SnapshotFiller.h
117
# End Source File
118
# Begin Source File
119
120
SOURCE=..\heapsnapshots\StatelessHeapSnapshotManager.h
121
# End Source File
122
# End Group
123
# End Target
124
# End Project
(-)src-native-new/src/agents/native/java_profiler/piAgentExtension.h (+235 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: piAgentExtension.h,v 1.3 2005/10/15 22:07:51 bduncan Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
/* 
14
 * This file contains typedefs and a structure definition for
15
 * agent extensions to use.
16
 *
17
18
How to write an agent extension to extend the Hyades piAgent:
19
20
Your source should #include "piAgentExtension.h" from
21
o.e.h.datacollectors/collection/collectors/native/java_profiler because
22
that's where the structures and typedefs below appear.
23
24
You use the Agent Controller's plugin/config system to tell
25
the main piAgent that it should load your extension. Here's how:
26
27
In the RASERVER_HOME directory, there is a subdirectory "plugins."
28
Make a new subdirectory of "plugins" using a name that won't collide
29
with others - something like "com.sample.myAgentExtension" using your
30
company's domain name.
31
32
Make a subdirectory of your plugin directory called "config."
33
34
Put a file in your "config" directory called "pluginconfig.xml."
35
36
Put something like this in your pluginconfig.xml file:
37
38
<?xml version="1.0" encoding="UTF-8"?>
39
<PluginConfiguration requires="org.eclipse.hyades.datacollection">
40
	<Agent configuration="default" name="Java Profiling Agent" extends="default">
41
		<Option name="piAgentExtension" 
42
			    type="libraryName" 
43
			    value="%RASERVER_HOME%\plugins\com.sample.myAgentExtension\lib\myLib.dll"
44
		/>
45
	</Agent>
46
</PluginConfiguration>
47
48
The only thing in this example that you should fill in is the value of 
49
the Option that has the name "piAgentExtension" and the type "libraryName."
50
All the other element and attribute names have to exactly as shown. You can
51
add other Option lines and the options you put there will be accessible to 
52
your agent using ra_getDefaultConfiguration().
53
54
Your agent extension library has to export a function called
55
"agent_extension_init" using standard C calling conventions, and it has
56
to have this signature:  JNIEXPORT void
57
agent_extension_init(AgentExtensionInitArgs_t *args);
58
59
That function will be called by the main piAgent during the processing
60
of the JVM_OnLoad function, which is called by JVMPI when it wants to
61
let the JVMPI agent initialize itself.
62
63
These are the meanings of the values in the AgentExtensionInitArgs
64
structure:
65
66
int api_version
67
	Holds the number '1' today.
68
69
	Will increase if there are additions to the args struct.
70
71
	Use this in the future to test for additional functionality
72
	provided by the base piAgent beyond what's described here.
73
74
const char* options
75
	The option string that followed "-XrunpiAgent:" on the Java command line.
76
	
77
	The option string passed will be a null string (ie: properly terminated 
78
	string of length 0) if there are no options (specified with or without a 
79
	colon).
80
81
JavaVM jvm
82
	The JavaVM* pointer obtained during JVM_OnLoad.
83
84
JVMPI_Interface jvmpi_interface
85
	The JVMPI_Interface* pointer obtained during JVM_OnLoad.
86
87
RA_AGENT_HANDLE agent_handle
88
	The RAC agent handle obtained by piAgent from ra_initializeBindings.
89
	Use this when calling RAC functions that take a handle argument.
90
91
SetCommandHandlerFunction set_command_handler
92
	Call this function to register your handler for incoming RAC commands.
93
94
SetEventHandlerFunction set_event_handler
95
	Call this function to register your handler for JVMPI events.
96
97
event_enable_safety_flag
98
	This flag is true if it's safe to call set_event_handler()
99
	from the extension's agent_extension_init function. See
100
	below about when it's safe to call set_event_handler.
101
	
102
The "args" structure will not be preserved after your init function
103
returns, so copy anything you want from it into your own storage.
104
105
REGISTERING FOR JVMPI EVENTS
106
107
Your JVMPI event handler functions must have this signature:
108
void myEventHandler(JVMPI_Event *event);
109
110
You register an event handler by calling through the set_event_handler
111
function pointer:
112
	(args->set_event_handler)(event_number, my_handler_function);
113
114
It's not always safe to call set_event_handler. It can only be called
115
at a time when a JVMPI agent is permitted to call the JVMPI function
116
EnableEvent.
117
118
If args->enable_event_safety_flag is true (nonzero), then it is
119
safe to call set_event_handler from inside your agent_extension_init 
120
function.
121
122
If args->enable_event_safety_flag is false (zero), or from outside your
123
agent_extension_init function, the agent extension is responsible for
124
making sure it's safe to call EnableEvent. The surest way to do this is
125
to create a new thread, attach that thread to the JVM, make the enable_event
126
call, then detach the thread and let it die.
127
128
RECEIVING EVENTS
129
130
When you register a handler for a JVMPI event and the event occurs, the
131
JVMPI_Event struct pointer you get is exactly as it came from JVMPI.
132
Your handler is called before the one in the main piAgent (if any). If
133
you want to call JNI or JVMPI functions from your handler, call them
134
directly using the pointers you got in agent_extension_init.
135
136
REGISTERING FOR AND RECEIVING RAC COMMANDS
137
138
Your RAC command handler function must have this signature:
139
	void myCommandHandler(ra_command_t *command);
140
141
Use the set_command_handler function to register your handler.
142
After you register it, your handler will be called for all RAC commands
143
that the piAgent gets.
144
145
The command struct you receive is exactly the same as the piAgent sees.
146
Your command processor runs before the one in the main piAgent. It is
147
not safe to change the contents of the command struct.
148
149
EXAMPLE
150
151
Below is a small but complete sample of an agent extension using most of
152
the features described here.
153
*/
154
155
#if 0
156
----------------- begin agent extension example; see above ---------------
157
#include "piAgentExtension.h"
158
159
/*
160
 * This example agent extension exercises some of the features of the
161
 * piAgent extensibility architecture:
162
 *
163
 * It writes a line to stderr when the agent_extension_init function gets called.
164
 * It registers handlers for two JVMPI events (INIT_DONE and CLASS_LOAD).
165
 * It registers a handler for RAC commands.
166
 *
167
 * The event handler for INIT_DONE just reports that it occurred.
168
 *
169
 * The event handler for CLASS_LOAD maintains count of how
170
 * many classes were loaded and reports the count every
171
 * time a new class loads.
172
 *
173
 * The event handler for RAC commands reports the type of the command received.
174
 */
175
176
void example_init_done_handler(JVMPI_Event *event)
177
{
178
	fprintf(stderr, "(Agent extension received init_done event)\n");
179
}
180
181
void example_class_load_handler(JVMPI_Event *event)
182
{
183
	/* add one to the class load count */
184
	class_load_count++;
185
	fprintf(stderr, "(Load class %s, %d so far)\n", 
186
			event->u.class_load.class_name, 
187
			class_load_count);
188
}
189
190
void example_command_handler(ra_command_t *command)
191
{
192
	fprintf(stderr, "(Received RAC command, type %d)\n", command->tag);
193
}
194
195
JNIEXPORT void agent_extension_init(AgentExtensionInitArgs *args)
196
{
197
	fprintf(stderr, "(agent_extension_init called.)\n");
198
	(*args->set_command_handler)(example_command_handler);
199
	(*args->set_event_handler)(JVMPI_EVENT_JVM_INIT_DONE, example_init_done_handler);
200
	(*args->set_event_handler)(JVMPI_EVENT_CLASS_LOAD, example_class_load_handler);
201
}
202
----------------------- end agent extension example ---------------
203
#endif
204
205
/*
206
 * This is the real start of this header file.
207
 * Everything above is a comment.
208
 */
209
210
#include "RAComm.h"
211
#include "jni.h"
212
#include "jvmpi.h"
213
#include "RABindings.h"
214
215
/* Typedefs for sub-agent handler functions and the setters for them */
216
typedef void (*AgentExtensionEventHandler)(JVMPI_Event *event, void **sub_agent_slot);
217
typedef void (*SetEventHandlerFunction)(jint event_type, AgentExtensionEventHandler fn);
218
typedef void (*AgentExtensionCommandHandler)(ra_command_t *command);
219
typedef void (*SetCommandHandlerFunction)(AgentExtensionCommandHandler fn);
220
221
/* agent extension initialization argument structure */
222
223
typedef struct {
224
	int api_version;
225
	const char *options;
226
	JavaVM *jvm;
227
	JVMPI_Interface *jvmpi_interface;
228
	RA_AGENT_HANDLE agent_handle;
229
	SetCommandHandlerFunction set_command_handler;
230
	SetEventHandlerFunction set_event_handler;
231
	char event_enable_safety_flag;
232
} AgentExtensionInitArgs;
233
234
typedef void (*AgentExtensionInitFunction)(AgentExtensionInitArgs *args);
235
(-)src-native-new/src/agents/native/heapsnapshots/StatelessHeapSnapshotManager.cpp (+525 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: StatelessHeapSnapshotManager.cpp,v 1.6 2005/09/09 21:33:11 apratt Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include <stdlib.h> // free
14
#include <string.h>
15
16
#include "StatelessHeapSnapshotManager.h"
17
#include "LBTimestamp.h"
18
19
static const char* CORRUPT_HEAP_DUMP   = "heap dump that the JVM gave us is corrupt!";
20
static const char* BOGUS_CONSTANT_POOL = "JVMPI bogus class constant pool";
21
22
StatelessHeapSnapshotManager::StatelessHeapSnapshotManager(SnapshotFiller*         filler,
23
							   SnapshotAgentInterface* agent,
24
							   JVMPI_Interface*        jvmpi,
25
							   bool					   optHeapDebug,
26
							   FILE *				   debugOut)
27
  : AbstractHeapSnapshotManager(filler, agent, jvmpi)
28
{
29
	_optHeapDebug = optHeapDebug;
30
	_debugOut = debugOut;
31
}
32
char StatelessHeapSnapshotManager::isStateless() const
33
{
34
  return 1;
35
}
36
37
void StatelessHeapSnapshotManager::handleHeapSnapshot(JNIEnv*      env,
38
						      int          dump_level,
39
						      char*        begin,
40
						      char*        end,
41
						      HeapDumpMode heapDumpMode)
42
{
43
  // 1. for timing...
44
  LBCLOCK_t now;
45
  getClock(&now);
46
47
  // 2. need certain class information that isn't in the heap snapshot
48
  if(!getClassInfos(begin, end)) return;
49
50
  if(agent().shouldIReportHeapSnapshotDuration()) {
51
    agent().status("part 1 (milliseconds):",
52
		   clockDiffInMilliseconds(&now));
53
  }
54
  getClock(&now);
55
56
  // 3. add a generation begin marker
57
  filler().FillJvmpiSnapshot(begin, end);
58
  // 4. done, report timing
59
  if(agent().shouldIReportHeapSnapshotDuration()) {
60
    agent().status("part 2 (milliseconds):",
61
		   clockDiffInMilliseconds(&now));
62
  }
63
}
64
65
#define DUMP_READ(buf, current, size) memcpy(buf, *current, size); *current+= size
66
67
void *StatelessHeapSnapshotManager::prof_dump_read_ptr(char **current) const
68
{
69
	void *p; 
70
#ifdef __OS400__
71
/* On AS/400 pointers are 16-byte aligned within the buffer. 
72
   Forward to the next 16 byte boundary if we currently aren't on one */ 
73
	unsigned int i = (unsigned int) *current;
74
	i &= 0x0000000f;  /* grab lowest 4 bits of i */
75
	if (i > 0) {  
76
		*current = *current + (16 - i);  /* align the pointer */ 
77
	}
78
#endif
79
	DUMP_READ(&p, current, sizeof(void *));
80
    return p;
81
}
82
	
83
#ifdef __OS400__
84
void StatelessHeapSnapshotManager::parseClassDump(unsigned int object_dump_len, 
85
		char *object_dump_data, int numInterfaces, int numStaticReferenceFields,
86
		unsigned int *instanceSize, jobjectID** classRefs) const
87
{
88
	
89
	char*     cursor;
90
	jobjectID cls;
91
	*instanceSize = 0;
92
	*classRefs = NULL;
93
	if ((object_dump_len = 0) ||
94
		(object_dump_data[0] != JVMPI_GC_CLASS_DUMP))
95
		return;
96
		
97
	cursor = object_dump_data + 1;
98
	cls = agent().dump_read_jobjectID(cursor);
99
	cursor += sizeof(jobjectID); /* class id */
100
101
	if(cls == NULL) {
102
	    // something funky happened, and we have to bail out
103
	    agent().error(CORRUPT_HEAP_DUMP);
104
	    return;
105
	}
106
107
	  cursor += sizeof(jobjectID); /* super class Id */
108
	  cursor += sizeof(jobjectID); /* class loader Id */
109
	  cursor += sizeof(jobjectID); /* signers Id */
110
	  cursor += 2*sizeof(jobjectID); /* protection domain , class name */
111
	  prof_dump_read_ptr(&cursor);  /* resv2 */
112
	  *instanceSize = agent().swap32(agent().dump_read_u4(cursor)); /* instance size */
113
	  cursor += sizeof(unsigned int);
114
115
	  int i;
116
	  for(i=0; i<numInterfaces; i++) {
117
	    //jobjectID iref = agent().dump_read_jobjectID(cursor);
118
	    cursor += sizeof(jobjectID); /* All the ids of numInterfacees */
119
	  }
120
121
	  // CONSTANT POOL
122
	  unsigned short constPoolSize = agent().swap16(agent().dump_read_u2(cursor));
123
	  /* size of constant pool */
124
	  cursor += 2;
125
126
	  for (i=0; i<constPoolSize; i++) {
127
	    //unsigned short constPoolIndex = agent().swap16(agent().dump_read_u2(cursor));
128
	    cursor += 2;
129
130
	    char constPoolType = agent().dump_read_u1(cursor);
131
	    cursor += 1;
132
133
	    /* skip over the constant; how much depends on its type */
134
	    switch(constPoolType) {
135
	    case JVMPI_BOOLEAN:
136
	    case JVMPI_BYTE:
137
	      cursor += 1; break;
138
	    case JVMPI_CHAR:
139
	    case JVMPI_SHORT:
140
	      cursor += 2; break;
141
	    case JVMPI_FLOAT:
142
	    case JVMPI_INT:
143
	      cursor += 4; break;
144
	    case JVMPI_CLASS:
145
		case JVMPI_NORMAL_OBJECT :
146
	      {
147
		// this is a reference case
148
		//jobjectID constPoolValue = agent().dump_read_jobjectID(cursor);
149
		cursor += sizeof(jobjectID);
150
		break;
151
	      }
152
	    case JVMPI_LONG:
153
	    case JVMPI_DOUBLE:
154
	      cursor += 8; break;
155
	    default:
156
	      agent().error(BOGUS_CONSTANT_POOL); break;
157
	    }
158
	  }
159
160
	  // STATIC FIELDS
161
	  int j;
162
	  int objIdSize = sizeof(jobjectID);
163
	  jobjectID *buildClassRefs = (jobjectID *)malloc(objIdSize * (numStaticReferenceFields));
164
	  *classRefs = buildClassRefs;
165
      for (i=0; i<numStaticReferenceFields; i++) {
166
		buildClassRefs[i] = agent().dump_read_jobjectID(cursor);
167
	    cursor += sizeof(jobjectID);
168
      }	
169
}
170
#endif
171
172
/*
173
	Anandi 1 April 2005: The OS400 jvm does not include all the classes
174
    in the dump. Only the user ones seem to be included. 
175
	1. Added code to explicitly request jvmpi to dump classes and class 
176
	objects (to dump static class references) whenever getClassInfos 
177
	comes across an instance or an object array whose class has not 
178
	been seen till then. 
179
	2. Changed FillClassInfo (only for OS400) to write out all the class
180
	details, including static class references. What this implies is that the
181
	classInfos store ALL the class related data in OS400 optHeap files and
182
	the parser must build the classes from these. These heaps may include
183
	the normal JVMPI_GC_CLASS_DUMP for some classes, the parser should ignore
184
	these.
185
 */
186
char StatelessHeapSnapshotManager::getClassInfos(char* begin, char* end) const
187
{
188
  char*     cursor = begin;
189
  char  poisonPill = 0; // found terminal error?
190
191
  if (_optHeapDebug) {
192
    fprintf(_debugOut, "In getClassInfos.\n");
193
	fflush(_debugOut);
194
  }
195
  
196
  while (cursor < end && !poisonPill) {
197
198
      if(!agent().stillAlive() || !agent().stillTracing()) {
199
	poisonPill = 1;
200
	break;
201
      }
202
203
      // the type of current entry in the bit bucket
204
      unsigned char type = agent().dump_read_u1(cursor);
205
      cursor += sizeof(char);
206
207
      switch (type) { // big switch statement
208
      case JVMPI_GC_ROOT_UNKNOWN:
209
	cursor += sizeof(jobjectID);
210
	break;
211
212
      case JVMPI_GC_ROOT_JNI_GLOBAL:
213
	cursor += sizeof(jobjectID);
214
	cursor += sizeof(jobject);
215
	break;
216
217
      case JVMPI_GC_ROOT_JNI_LOCAL:
218
	cursor += sizeof(jobjectID);
219
	prof_dump_read_ptr(&cursor);
220
//	cursor += sizeof(JNIEnv*);
221
	cursor += sizeof(int);
222
	break;
223
224
      case  JVMPI_GC_ROOT_JAVA_FRAME:
225
	cursor += sizeof(jobjectID);
226
	prof_dump_read_ptr(&cursor);
227
//	cursor += sizeof(JNIEnv*);
228
	cursor += sizeof(int);
229
	break;
230
231
      case JVMPI_GC_ROOT_NATIVE_STACK:
232
	cursor += sizeof(jobjectID);
233
	prof_dump_read_ptr(&cursor);
234
//	cursor += sizeof(JNIEnv*);
235
	break;
236
237
      case JVMPI_GC_ROOT_STICKY_CLASS:
238
	cursor += sizeof(jobjectID);
239
	break;
240
241
      case JVMPI_GC_ROOT_THREAD_BLOCK:
242
	cursor += sizeof(jobjectID);
243
	prof_dump_read_ptr(&cursor);
244
//	cursor += sizeof (JNIEnv*);
245
	break;
246
247
      case JVMPI_GC_ROOT_MONITOR_USED:
248
	cursor += sizeof(jobjectID);
249
	break;
250
251
      case JVMPI_GC_CLASS_DUMP:
252
	{
253
	  jobjectID cls = agent().dump_read_jobjectID(cursor);
254
	  cursor += sizeof(jobjectID); /* class id */
255
256
	  if(cls == NULL) {
257
	    // something funky happened, and we have to bail out
258
	    agent().error(CORRUPT_HEAP_DUMP);
259
	    poisonPill = 1;
260
	    if (_optHeapDebug) {
261
	    	fprintf(_debugOut, "In getClassInfo NULL class id.\n");
262
	    	fflush(_debugOut);
263
		}
264
	    break;
265
	  }
266
267
	  cursor += sizeof(jobjectID); /* super class Id */
268
	  cursor += sizeof(jobjectID); /* class loader Id */
269
	  cursor += sizeof(jobjectID); /* signers Id */
270
	  cursor += 2*sizeof(jobjectID); /* protection domain , class name */
271
	  prof_dump_read_ptr(&cursor);  /* resv2 */
272
	  unsigned int instanceSize = agent().swap32(agent().dump_read_u4(cursor)); /* instance size */
273
	  cursor += sizeof(unsigned int);
274
275
	  int numInterfaces, numStaticReferenceFields;
276
	  char* className;
277
	  char className_freeMe;
278
279
	  if (_optHeapDebug) {
280
	    fprintf(_debugOut, "In getClassInfo 0x%x.\n", cls);
281
	    fflush(_debugOut);
282
	  }
283
284
#ifdef __OS400__
285
	  /* 96108: Anandi On AS400, with jvm 1.4, objects are showing up
286
         before classes. Which, because we create classInfos from objects
287
         causes this to return status = 1 for such classes.
288
	     Handle this by calling FillClassInfo only when status =0
289
       */
290
	  char getClassInfoStatus = agent().getClassInfo(cls, &className, &className_freeMe, &numInterfaces, &numStaticReferenceFields);
291
	  if (getClassInfoStatus !=0 && getClassInfoStatus !=1) {
292
	    agent().error(CORRUPT_HEAP_DUMP);
293
	    fprintf(stderr, "agent().getClassInfo non 0 or 1 return.\n");
294
	    poisonPill = 1;
295
	    break;
296
	  }
297
#else
298
	  if(agent().getClassInfo(cls, &className, &className_freeMe, &numInterfaces, &numStaticReferenceFields)) {
299
	    agent().error(CORRUPT_HEAP_DUMP);
300
	    fprintf(stderr, "agent().getClassInfo non 0 or 1 return.\n");
301
	    poisonPill = 1;
302
	    break;
303
	  }
304
#endif
305
306
	  int i;
307
	  for(i=0; i<numInterfaces; i++) {
308
	    //jobjectID iref = agent().dump_read_jobjectID(cursor);
309
	    cursor += sizeof(jobjectID); /* All the ids of numInterfacees */
310
	  }
311
312
	  // CONSTANT POOL
313
	  unsigned short constPoolSize = agent().swap16(agent().dump_read_u2(cursor));
314
	  /* size of constant pool */
315
	  cursor += 2;
316
317
	  for (i=0; i<constPoolSize; i++) {
318
	    //unsigned short constPoolIndex = agent().swap16(agent().dump_read_u2(cursor));
319
	    cursor += 2;
320
321
	    char constPoolType = agent().dump_read_u1(cursor);
322
	    cursor += 1;
323
324
	    /* skip over the constant; how much depends on its type */
325
	    switch(constPoolType) {
326
	    case JVMPI_BOOLEAN:
327
	    case JVMPI_BYTE:
328
	      cursor += 1; break;
329
	    case JVMPI_CHAR:
330
	    case JVMPI_SHORT:
331
	      cursor += 2; break;
332
	    case JVMPI_FLOAT:
333
	    case JVMPI_INT:
334
	      cursor += 4; break;
335
	    case JVMPI_CLASS:
336
		case JVMPI_NORMAL_OBJECT :
337
	      {
338
		// this is a reference case
339
		//jobjectID constPoolValue = agent().dump_read_jobjectID(cursor);
340
		cursor += sizeof(jobjectID);
341
		break;
342
	      }
343
	    case JVMPI_LONG:
344
	    case JVMPI_DOUBLE:
345
	      cursor += 8; break;
346
	    default:
347
	      agent().error(BOGUS_CONSTANT_POOL); break;
348
	    }
349
	  }
350
351
	  // STATIC FIELDS
352
	  int j;
353
#ifdef __OS400__
354
	  // dump the classRefs here, including the null refs
355
	  int objIdSize = sizeof(jobjectID);
356
	  jobjectID *classRefs = (jobjectID *)malloc(objIdSize * (numStaticReferenceFields));
357
	  for (j=0; j<numStaticReferenceFields; j++) {
358
		classRefs[j] = agent().dump_read_jobjectID(cursor);
359
	    cursor += sizeof(jobjectID);
360
      }	
361
#else
362
	  for (j=0; j<numStaticReferenceFields; j++) {
363
	    cursor += sizeof(jobjectID);
364
	  }
365
#endif
366
367
#ifdef __OS400__
368
	  if (getClassInfoStatus !=1) {
369
#endif
370
	  filler().FillClassInfo(cls,
371
				 className,
372
				 numStaticReferenceFields,
373
				 numInterfaces,
374
#ifdef __OS400__
375
				 instanceSize, classRefs);
376
	  free(classRefs);
377
#else
378
				 instanceSize);
379
#endif
380
#ifdef __OS400__
381
	  }
382
#endif
383
384
	  if(className_freeMe) {
385
	    free(className);
386
	  }
387
388
	  break;
389
	}
390
391
     case JVMPI_GC_INSTANCE_DUMP:
392
     {
393
394
#ifdef __OS400__
395
/* Bug Number 73480 */
396
	  int numInterfaces, numStaticReferenceFields;
397
	  char* className;
398
	  char className_freeMe = 0;
399
 	  unsigned int instanceSize = 0;
400
 	  unsigned int object_dump_len = 0;
401
 	  char *object_dump_data = NULL;
402
 	  jobjectID* classRefs = NULL;
403
#endif
404
405
      cursor += sizeof(jobjectID);  /* object */
406
#ifdef __OS400__
407
/* Bug Number 73480 */
408
	  jobjectID cls = agent().dump_read_jobjectID(cursor);
409
#endif
410
	  cursor += sizeof(jobjectID); /* class id */
411
412
#ifdef __OS400__
413
/* Bug Number 73480 */
414
	  int status =  agent().getOS400ClassInfo(cls, &className, &className_freeMe, 
415
	  		&numInterfaces, &numStaticReferenceFields, &object_dump_len, &object_dump_data
416
			) ;
417
418
	  if(status < 0) {
419
	    agent().error(CORRUPT_HEAP_DUMP);
420
	    poisonPill = 1;
421
	    break;
422
	  }
423
424
	  if ( status == 0 ) {
425
	      parseClassDump(object_dump_len, object_dump_data, numInterfaces, 
426
	      	numStaticReferenceFields, &instanceSize, &classRefs);
427
	      filler().FillClassInfo(cls,
428
			 className,
429
			 numStaticReferenceFields,
430
			 numInterfaces,
431
			 instanceSize, classRefs);
432
		  free(classRefs);
433
	  }
434
435
  	  if(className_freeMe) {
436
	    free(className);
437
		free(object_dump_data);
438
	  }
439
#endif
440
       unsigned int remainingBytes =  agent().swap32(agent().dump_read_u4(cursor));
441
       cursor += sizeof(unsigned int);
442
       cursor += remainingBytes;
443
       break;
444
     }
445
446
     case JVMPI_GC_OBJ_ARRAY_DUMP:
447
     {
448
#ifdef __OS400__
449
/* Bug Number 73480 */
450
 	  int numInterfaces, numStaticReferenceFields;
451
	  char* className;
452
	  char className_freeMe = 0;
453
 	  unsigned int instanceSize = 0;
454
 	  unsigned int object_dump_len = 0;
455
 	  char *object_dump_data = NULL;
456
 	  jobjectID *classRefs = NULL;
457
#endif
458
       cursor += sizeof(jobjectID);
459
       int numElem = agent().swap32(agent().dump_read_u4(cursor));
460
       cursor += sizeof(int);
461
#ifdef __OS400__
462
/* Bug Number 73480 */
463
	  jobjectID cls = agent().dump_read_jobjectID(cursor);
464
#endif
465
       cursor += sizeof(jobjectID);
466
#ifdef __OS400__
467
/* Bug Number 73480 */
468
	  int status =  agent().getOS400ClassInfo(cls, &className, &className_freeMe, 
469
	  		&numInterfaces, &numStaticReferenceFields, &object_dump_len, &object_dump_data
470
			) ;
471
472
	  if(status < 0) {
473
	    agent().error(CORRUPT_HEAP_DUMP);
474
	    poisonPill = 1;
475
	    break;
476
	  }
477
478
	  if ( status == 0 ) {
479
	      parseClassDump(object_dump_len, object_dump_data, numInterfaces, 
480
			numStaticReferenceFields, &instanceSize, &classRefs);
481
	      filler().FillClassInfo(cls,
482
			 className,
483
			 numStaticReferenceFields,
484
			 numInterfaces,
485
			 instanceSize, classRefs);
486
		  free(classRefs);
487
	  }
488
489
  	  if(className_freeMe) {
490
	    free(className);
491
		free(object_dump_data);
492
	  }
493
#endif
494
       for (int i=0; i<numElem; i++) {
495
	 cursor += sizeof(jobjectID);
496
       }
497
       break;
498
     }
499
500
     case JVMPI_GC_PRIM_ARRAY_DUMP:
501
       cursor += sizeof(jobjectID);
502
       cursor += sizeof(int);
503
       cursor += sizeof(char);
504
       break;
505
506
      default:
507
	// some error in the trace, or in our processing of it
508
	poisonPill = 1;
509
	if (_optHeapDebug) {
510
	    fprintf(_debugOut, 
511
		"Possible parse error in getClassInfos. Unknown heap dump record type %d.\n",
512
		type);
513
		fflush(_debugOut);
514
	}
515
	break;
516
      } //switch
517
   } // while
518
519
  // return whether finished without error
520
  if (_optHeapDebug) {
521
    fprintf(_debugOut, "End getClassInfos: poisonPill %d\n", poisonPill);
522
    fflush(_debugOut);
523
  }
524
  return poisonPill==0;
525
}
(-)src-native-new/src/HCLauncher/launcher_common.c (+53 lines)
Added Link Here
1
/**********************************************************************
2
Copyright (c) 2005 IBM Corporation and others.
3
All rights reserved.   This program and the accompanying materials
4
are made available under the terms of the Eclipse Public License v1.0
5
which accompanies this distribution, and is available at
6
http://www.eclipse.org/legal/epl-v10.html
7
$Id: launcher_common.c,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 
9
Contributors:
10
    IBM Corporation - initial implementation
11
**********************************************************************/
12
13
#include "launcher_common.h"
14
15
16
/** START_PROCESS ***************************************************
17
  * This function lauches a process on the current OS.  Using the
18
  * specified execuatble and arguments it checks the server configuration
19
  * to determine if the specified process is allowed to be launched, and
20
  * if so, creates the specified environment for the process before it
21
  * is launched
22
  */
23
PID hc_startProcess(char *exe, char *cmdline, char *location, char *env, RemoteConsole_t *console) {
24
	PID childPID;
25
	RA_HANDLE consoleChild[3];
26
27
	/* Set the console to be NULL initially */
28
	console->in = RA_HANDLE_NULL;
29
	console->out = RA_HANDLE_NULL;
30
	console->err = RA_HANDLE_NULL;
31
	consoleChild[0] = RA_HANDLE_NULL; /* in */
32
	consoleChild[1] = RA_HANDLE_NULL; /* out */
33
	consoleChild[2] = RA_HANDLE_NULL; /* err */
34
35
	/* When a process is launched through this mechanism we would like to
36
	   capture the remote console information to be transported to the remote
37
	   monitor.
38
	*/
39
	if(!ra_createPipe(&consoleChild[0], &console->in)) {
40
		printf("Error creating stdin pipe\n");
41
	}
42
	if(!ra_createPipe(&console->out, &consoleChild[1])) {
43
		printf("Error creating stdout pipe\n");
44
	}
45
	if(!ra_createPipe(&console->err, &consoleChild[2])) {
46
		printf("Error creating stderr pipe\n");
47
	}
48
49
	/* Launch the process */
50
	childPID = hc_launchProcess(exe, cmdline, location, env, consoleChild);
51
52
	return childPID;
53
}
(-)src-native-new/src/agents/perfmon/resutils/clock.c (+196 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: clock.c,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
/***********************************************************************
14
 *
15
 * File: Event.c
16
 * Overview: The following code provides a simple clock interface,
17
 *                               refer to Clock.h for definitions of Clock struct and return
18
 *                               types. Note that the Clock struct is explicitly allocated
19
 *                               by user.
20
 *
21
 ***********************************************************************/
22
23
#include "system.h"
24
25
/***********************************************************************
26
 * Function: ClockMillis
27
 * Purpose: return milliseconds since arbitrary start point
28
 * Parameters: 
29
 * Returns:
30
 ***********************************************************************/
31
32
static int ClockMillis(XINT64 *d)
33
{
34
#ifdef WIN32
35
36
  GetSystemTimeAsFileTime((LPFILETIME)d);
37
38
  (*d) = (((*d) + 5000) / 10000);
39
#endif
40
#if defined(SOLARIS) || defined(LINUX) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386) 
41
  struct timeval tv;
42
43
  if (gettimeofday(&tv, NULL) < 0)
44
  {
45
    return XCLOCK_ERROR_UNKNOWN;
46
  }
47
48
  *d = (tv.tv_sec * 1000) + ((tv.tv_usec + 500) / 1000);
49
//  (*d) = ((((XINT64)(tv.tv_sec) * 1000) + (((XINT64)(tv.tv_usec) + 500) / 1000)));
50
  
51
#endif
52
53
  return SUCCESS;
54
}
55
56
int XClockMillis(XINT64 *d) {
57
58
#ifdef WIN32
59
  LARGE_INTEGER time;
60
  FILETIME ftime;
61
  LPFILETIME fileTime = &ftime;
62
63
  GetSystemTimeAsFileTime(fileTime);
64
65
//  (*d) = (((*d) + 5000) / 10000);
66
67
  time.LowPart = fileTime->dwLowDateTime; time.HighPart = fileTime->dwHighDateTime;
68
  *d = (time.QuadPart / 10000L) - 11644473600000L;
69
70
#else
71
72
  struct timeb t;
73
  ftime(&t);
74
  *d = ((XINT64)(t.time))*1000 + t.millitm;
75
76
#endif
77
78
  return SUCCESS;
79
}
80
/***********************************************************************
81
 * Function: SC_ClockCreate
82
 * Purpose: Initialises Clock struct with the time of the call. This
83
 *                               is when the clock was created.
84
 * Parameters: Clock *, a pointer to a Clock struct.
85
 * Returns: int, CLOCK_SUCCESS as the routine cannot fail.
86
 ***********************************************************************/
87
88
int XClockCreate(XClock *clock)
89
{
90
  int okay;
91
92
  if ((okay = ClockMillis(&clock->initial)) != SUCCESS)
93
  {
94
    return okay;
95
  }
96
97
  return SUCCESS;
98
}
99
100
/***********************************************************************
101
 * Function: XClockDelete
102
 * Purpose: Invalidates the clock struct.
103
 * Parameters: Clock *, a pointer to a Clock struct.
104
 * Returns: int, CLOCK_SUCCESS as the routine cannot fail.
105
 ***********************************************************************/
106
107
int XClockDelete(XClock *clock)
108
{
109
  return SUCCESS;
110
}
111
112
/***********************************************************************
113
 * Function: ClockAdjust
114
 * Purpose: Adjusts clock initial
115
 * Parameters: Clock *, a pointer to a Clock struct.
116
 * Returns: int, CLOCK_SUCCESS as the routine cannot fail.
117
 ***********************************************************************/
118
119
int XClockAdjust(XClock *clock, XINT64 adj)
120
{
121
  clock->initial = clock->initial + adj;
122
123
  return SUCCESS;
124
}
125
126
/***********************************************************************
127
 * Function: ClockRead
128
 * Purpose: Returns the number of clock ticks in ticks that have 
129
 *          passed since creation (modulo adjustment).
130
 * Parameters: Clock *, a pointer to a Clock struct.
131
 * Returns: int, CLOCK_SUCCESS, function cannot fail.
132
 ***********************************************************************/
133
134
int XClockRead(XClock *clock, XINT64 *ticks)
135
{
136
  int okay;
137
  XINT64 current;
138
139
  if ((okay = ClockMillis(&current)) != SUCCESS)
140
  {
141
    return okay;
142
  }
143
144
  *ticks = current - clock->initial;
145
  
146
  return SUCCESS;
147
}
148
149
/***********************************************************************
150
 * Function: XClockWait
151
 * Purpose: suspend calling thread until (at least) until on the clock
152
 * Parameters: Clock *, a pointer to a Clock struct.
153
 * Returns: int, CLOCK_SUCCESS, function cannot fail.
154
 ***********************************************************************/
155
156
int XClockWait(XClock *clock, XINT64 until)
157
{
158
  int okay;
159
  XINT64 current;
160
161
  if ((okay = ClockMillis(&current)) != SUCCESS)
162
  {
163
    return okay;
164
  }
165
166
  current = current - clock->initial;
167
168
  if (until > current)
169
  {
170
      long period = (long) (until - current);
171
172
#ifdef XCLOCK_PRECISION
173
      long doirep = period % (XCLOCK_PRECISION);
174
175
      period = period - doirep;
176
177
      if ((long)(XRandomUniform() * (XCLOCK_PRECISION)) < doirep)
178
      {
179
          period = period + (XCLOCK_PRECISION);
180
      }
181
#endif
182
183
#ifdef WIN32
184
    (void)Sleep(period * 1);
185
#endif
186
#if defined(SOLARIS) || defined(LINUX) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
187
    (void)usleep(period * 1000);
188
#endif
189
  }
190
191
  return SUCCESS;
192
}
193
194
/***********************************************************************
195
 * EOF
196
 ***********************************************************************/
(-)src-native-new/src/HCLauncher/hclaunch.exp (+9 lines)
Added Link Here
1
#!libhclaunch.so exports
2
JNI_OnLoad
3
Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_startProcess0
4
Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_killProcess0
5
Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_writeToProcess0
6
Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_readFromProcessOutput0
7
Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_readFromProcessError0
8
Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_getProcessStatus0
9
Java_org_eclipse_hyades_execution_core_impl_ExecutionEnvironmentImpl_getNativeSystemEnvironment0
(-)src-native-new/src/agents/RABindings/RABindings.h (+202 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: RABindings.h,v 1.4 2005/04/26 19:37:30 samwai Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef _RABINDINGS_H_
14
#define _RABINDINGS_H_
15
16
17
#include "RAComm.h"
18
#include "RASocket.h"
19
20
#if defined __cplusplus
21
extern "C" {
22
#endif
23
24
/*  The various log message severities. */
25
enum _RA_ERROR_LEVEL {RA_DEBUG, RA_INFORMATION, RA_WARNING, RA_SEVERE, RA_MAX_ERROR_LEVEL};
26
typedef enum _RA_ERROR_LEVEL RA_ERROR_LEVEL;
27
28
29
/* The default agent configuration information provided by the RAC is kept in a list */
30
typedef struct _agentConfigListEntry {
31
	ra_agentConfigEntry_t entry;
32
	struct _agentConfigListEntry *next;
33
	struct _agentConfigListEntry *previous;
34
}ra_agentConfigListEntry_t;
35
36
typedef struct {
37
	ra_agentConfigListEntry_t *head;
38
	ra_agentConfigListEntry_t *tail;
39
}ra_agentConfigList_t;
40
41
42
/* A handle for an agent that is used to hang all the agents information off of. */
43
typedef struct {
44
	BOOL finalized;
45
	BOOL registered;
46
	RA_HANDLE pipefd;
47
	TID    tid;
48
	ra_commandHandler_t  commandHandler;
49
	PID processID;
50
	ra_string_t agentUUID;
51
	ra_string_t processUUID;
52
	ra_string_t nodeUUID;
53
	ra_string_t agentType;
54
	ra_string_t agentName;
55
	ra_agentConfigList_t defaultConfiguration;
56
#ifdef _WIN32
57
	HANDLE tHandle;		/* thread handle of the pipe server */ 
58
#endif 
59
}ra_agenthandle_t;
60
61
typedef ra_agenthandle_t* RA_AGENT_HANDLE;
62
63
/** INITIALIZE_BINDINGS  ***********************************************
64
  * Initialization routine for the agent bindings, must be called first
65
  * by te agent before running any of the other functions specified in this
66
  * header file.
67
  * @param       name - the name of the agent.
68
  * @param       type - the type of the agent
69
  * @param    handler - the callback routine for all incomming messages.
70
  * @param standalone - determines whether this agent should communicate with the RAC
71
  *                     if standalone is TRUE the RAC is never used.
72
  * @returns  the new handle that is used to manage the agent.
73
  */
74
extern RA_AGENT_HANDLE ra_initializeBindings(const char *name,
75
                                             const char *type,
76
                                             ra_commandHandler_t handler,
77
                                             BOOL standalone);
78
79
/** FINALIZE_BINDINGS  *********************************************************
80
  * Cleans up all the resources that were allocated during the agents
81
  * interaction with the bindings. Once this is called the handle is
82
  * no longer valid.
83
  * @param  handle - a handle returned by ra_initializeBindings.
84
  */
85
extern void ra_finalizeBindings(RA_AGENT_HANDLE handle);
86
87
/** START_LISTENER  ************************************************************
88
  * Start the message processor.
89
  * @param   handle - a handle returned by ra_initializeBindings
90
  * @param    block - whether to  block until the agent is successfuly
91
  *                   attached to a remote client.
92
  * @returns    NULL  call failed, call ra_getLastError() to determine failure
93
  *		    otherwise the address of the thread number the server message processor is
94
  *	                  listening on
95
  *
96
  */
97
extern TID *ra_startListener(RA_AGENT_HANDLE handle,
98
                             char block);
99
100
101
/** STOP_LISTENER  *************************************************************
102
  * Stops the message processor
103
  * @param  handle - a handle returned by ra_initializeBindings
104
  */
105
extern void ra_stopListener(RA_AGENT_HANDLE handle);
106
107
/** SEND_MESSAGE  **************************************************************
108
  * Send the message to the RAC on this node.  It will
109
  * then be forwarded by the server to the client.
110
  * @param  handle - a handle returned by ra_initializeBindings
111
  * @param   message - the message structure to send.
112
  * @returns the number of bytes sent to the RAC.
113
  */
114
extern int ra_sendMessage(RA_AGENT_HANDLE handle,
115
                          ra_message_t *message);
116
117
/** GET_PROCESS_ID  ************************************************************
118
  * Multiplatform convenience method to retrieve the current process
119
  * id.
120
  * @returns the PID of the curren process
121
  */
122
extern PID ra_getProcessId();
123
124
/** GET_NODE_UUID  *************************************************************
125
  * Retrieves the UUID of the node which this agent is running on.
126
  * Calling this function before ra_startListener has undefined
127
  * behaviour.
128
  */
129
extern const char* ra_getNodeUUID(RA_AGENT_HANDLE handle);
130
131
/** GET_PROCESS_ID  ************************************************************
132
  * Retrieves the UUID of the process which this agent is running in.
133
  * Calling this function before ra_startListener results in undefined
134
  * behaviour.
135
  */
136
extern const char* ra_getProcessUUID(RA_AGENT_HANDLE handle);
137
138
/** GET_AGENT_UUID  ************************************************************
139
  * Retrieves the agent's UUID.
140
  */
141
extern const char* ra_getAgentUUID(RA_AGENT_HANDLE handle);
142
143
/** GET_DEFAULT_CONFIGURATION  *************************************************
144
  * Retrieves a list of the options provided by the RAC as a default configuration
145
  * of the agent.  The configuration will only be available after the agent
146
  * has successfuly registered with the RAC.
147
  * @param  handle - a handle returned by ra_initializeBindings
148
  * @returns   the agent's default configuration list if the agent has registered
149
  *            with the RAC.  NULL otherwise.
150
  */
151
extern ra_agentConfigList_t* ra_getDefaultConfiguration(RA_AGENT_HANDLE handle);
152
153
/** GET_PROCESS_COMMAND_LINE  ******************************************
154
  */
155
extern char* ra_getProcessCommandLine();
156
157
158
/** LOG_ERROR_MESSAGE  **************************************************
159
  *
160
  */
161
extern void ra_logErrorMessage(RA_AGENT_HANDLE handle,
162
							   RA_ERROR_LEVEL  severity,
163
							   const char *messageId,
164
							   const char *message);
165
166
/* Bug 74367 */
167
extern int ra_logErrorMessage_return(RA_AGENT_HANDLE handle, RA_ERROR_LEVEL  severity, const char *messageId, const char *message);
168
169
170
/** REQUEST_PEER_MONITOR  ******************************************************
171
  * Requests a remote client to start monitoring this agent by asking the agent
172
  * controller to find the client currently monitoring a peer agent.
173
  * THIS IS NOT CURRENTLY SUPPORTED.  DO NOT USE!!!!!!!
174
  */
175
extern int ra_requestPeerMonitor(RA_AGENT_HANDLE handle, ra_ipaddr_t *peerAddress, PID peerPID, ra_string_t *peerAgent, unsigned long timeout);
176
extern int ra_requestPeerMonitor_p(RA_AGENT_HANDLE handle, ra_ipaddr_t *peerAddress, int port, PID peerPID, ra_string_t *peerAgent, unsigned long timeout); /* Bug 77768 */
177
178
/** REQUEST_PEER_MONITOR  ******************************************************
179
  * Requests a remote client to start monitoring this agent by asking the agent
180
  * controller to find the client currently monitoring a peer agent. The timeout
181
  * is currently not supported.
182
  */
183
extern int ra_requestPeerMonitor2(RA_AGENT_HANDLE handle, ra_ipaddr_t *peerAddress, ra_string_t *peerAgentUUID, unsigned long timeout);
184
extern int ra_requestPeerMonitor2_p(RA_AGENT_HANDLE handle, ra_ipaddr_t *peerAddress, int port, ra_string_t *peerAgentUUID, unsigned long timeout); /* Bug 77768 */
185
186
187
extern BOOL ra_initializeVMLock();
188
extern void ra_setVMLock();
189
extern void ra_releaseVMLock();
190
extern void ra_testVMLock();
191
extern BOOL ra_getVMLockState();
192
193
/*
194
 * Return the Option values specified in the config file
195
 */
196
extern void ra_getPropertyValues(RA_AGENT_HANDLE handle, char* name, char* type);
197
198
#if defined __cplusplus
199
}
200
#endif
201
202
#endif
(-)src-native-new/src/agents/native/heapsnapshots/AbstractHeapSnapshotManager.cpp (+44 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: AbstractHeapSnapshotManager.cpp,v 1.3 2005/02/25 22:17:34 hleung Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include "AbstractHeapSnapshotManager.h"
14
15
16
#ifdef IBM_OE
17
#pragma convlit(suspend)
18
#endif //IBM_OE
19
20
#ifdef IBM_OE
21
#pragma convlit(resume)
22
#endif //IBM_OE
23
24
25
AbstractHeapSnapshotManager::AbstractHeapSnapshotManager(SnapshotFiller*         filler,
26
							 SnapshotAgentInterface* agent,
27
							 JVMPI_Interface*        jvmpi)
28
{
29
  _filler = filler;
30
  _agent  = agent;
31
  _jvmpi  = jvmpi;
32
}
33
SnapshotFiller& AbstractHeapSnapshotManager::filler() const
34
{
35
  return *_filler;
36
}
37
SnapshotAgentInterface& AbstractHeapSnapshotManager::agent() const
38
{
39
  return *_agent;
40
}
41
JVMPI_Interface& AbstractHeapSnapshotManager::jvmpi() const
42
{
43
  return *_jvmpi;
44
}
(-)src-native-new/src/agents/perfmon/WinBuild/rac.mak (+221 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on rac.dsp
2
!IF "$(CFG)" == ""
3
CFG=rac - Win32 Release
4
!MESSAGE No configuration specified. Defaulting to rac - Win32 Release.
5
!ENDIF 
6
7
!IF "$(CFG)" != "rac - Win32 Release" && "$(CFG)" != "rac - Win32 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "rac.mak" CFG="rac - Win32 Release"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "rac - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
17
!MESSAGE "rac - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
18
!MESSAGE 
19
!ERROR An invalid configuration is specified.
20
!ENDIF 
21
22
!IF "$(OS)" == "Windows_NT"
23
NULL=
24
!ELSE 
25
NULL=nul
26
!ENDIF 
27
28
!IF  "$(CFG)" == "rac - Win32 Release"
29
30
OUTDIR=.\bin
31
INTDIR=.\Release
32
# Begin Custom Macros
33
OutDir=.\bin
34
# End Custom Macros
35
36
ALL : "$(OUTDIR)\rac.dll"
37
38
39
CLEAN :
40
	-@erase "$(INTDIR)\rac.obj"
41
	-@erase "$(INTDIR)\vc60.idb"
42
	-@erase "$(INTDIR)\version.res"
43
	-@erase "$(OUTDIR)\rac.dll"
44
	-@erase "$(OUTDIR)\rac.exp"
45
	-@erase "$(OUTDIR)\rac.lib"
46
47
"$(OUTDIR)" :
48
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
49
50
"$(INTDIR)" :
51
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
52
53
CPP=cl.exe
54
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "../resutils" /I "../../../framework/RABindings" /I "../../../framework/RACommon" /I "../../../framework/RASocket" /I "../../../framework/RADataTransfer" /I "../../../framework/RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAC_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
55
56
.c{$(INTDIR)}.obj::
57
   $(CPP) @<<
58
   $(CPP_PROJ) $< 
59
<<
60
61
.cpp{$(INTDIR)}.obj::
62
   $(CPP) @<<
63
   $(CPP_PROJ) $< 
64
<<
65
66
.cxx{$(INTDIR)}.obj::
67
   $(CPP) @<<
68
   $(CPP_PROJ) $< 
69
<<
70
71
.c{$(INTDIR)}.sbr::
72
   $(CPP) @<<
73
   $(CPP_PROJ) $< 
74
<<
75
76
.cpp{$(INTDIR)}.sbr::
77
   $(CPP) @<<
78
   $(CPP_PROJ) $< 
79
<<
80
81
.cxx{$(INTDIR)}.sbr::
82
   $(CPP) @<<
83
   $(CPP_PROJ) $< 
84
<<
85
86
MTL=midl.exe
87
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
88
RSC=rc.exe
89
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
90
BSC32=bscmake.exe
91
BSC32_FLAGS=/nologo /o"$(OUTDIR)\rac.bsc" 
92
BSC32_SBRS= \
93
	
94
LINK32=link.exe
95
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\rac.pdb" /machine:I386 /out:"$(OUTDIR)\rac.dll" /implib:"$(OUTDIR)\rac.lib" /libpath:"bin" 
96
LINK32_OBJS= \
97
	"$(INTDIR)\rac.obj" \
98
	"$(INTDIR)\version.res"
99
100
"$(OUTDIR)\rac.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
101
    $(LINK32) @<<
102
  $(LINK32_FLAGS) $(LINK32_OBJS)
103
<<
104
105
!ELSEIF  "$(CFG)" == "rac - Win32 Debug"
106
107
OUTDIR=.\bin
108
INTDIR=.\Debug
109
# Begin Custom Macros
110
OutDir=.\bin
111
# End Custom Macros
112
113
ALL : "$(OUTDIR)\rac.dll"
114
115
116
CLEAN :
117
	-@erase "$(INTDIR)\rac.obj"
118
	-@erase "$(INTDIR)\vc60.idb"
119
	-@erase "$(INTDIR)\version.res"
120
	-@erase "$(OUTDIR)\rac.dll"
121
	-@erase "$(OUTDIR)\rac.exp"
122
	-@erase "$(OUTDIR)\rac.lib"
123
124
"$(OUTDIR)" :
125
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
126
127
"$(INTDIR)" :
128
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
129
130
CPP=cl.exe
131
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "../resutils" /I "../../../framework/RABindings" /I "../../../framework/RACommon" /I "../../../framework/RASocket" /I "../../../framework/RADataTransfer" /I "../../../framework/RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAC_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
132
133
.c{$(INTDIR)}.obj::
134
   $(CPP) @<<
135
   $(CPP_PROJ) $< 
136
<<
137
138
.cpp{$(INTDIR)}.obj::
139
   $(CPP) @<<
140
   $(CPP_PROJ) $< 
141
<<
142
143
.cxx{$(INTDIR)}.obj::
144
   $(CPP) @<<
145
   $(CPP_PROJ) $< 
146
<<
147
148
.c{$(INTDIR)}.sbr::
149
   $(CPP) @<<
150
   $(CPP_PROJ) $< 
151
<<
152
153
.cpp{$(INTDIR)}.sbr::
154
   $(CPP) @<<
155
   $(CPP_PROJ) $< 
156
<<
157
158
.cxx{$(INTDIR)}.sbr::
159
   $(CPP) @<<
160
   $(CPP_PROJ) $< 
161
<<
162
163
MTL=midl.exe
164
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
165
RSC=rc.exe
166
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
167
BSC32=bscmake.exe
168
BSC32_FLAGS=/nologo /o"$(OUTDIR)\rac.bsc" 
169
BSC32_SBRS= \
170
	
171
LINK32=link.exe
172
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\rac.pdb" /machine:I386 /out:"$(OUTDIR)\rac.dll" /implib:"$(OUTDIR)\rac.lib" /libpath:"bin" 
173
LINK32_OBJS= \
174
	"$(INTDIR)\rac.obj" \
175
	"$(INTDIR)\version.res"
176
177
"$(OUTDIR)\rac.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
178
    $(LINK32) @<<
179
  $(LINK32_FLAGS) $(LINK32_OBJS)
180
<<
181
182
!ENDIF 
183
184
185
!IF "$(NO_EXTERNAL_DEPS)" != "1"
186
!IF EXISTS("rac.dep")
187
!INCLUDE "rac.dep"
188
!ELSE 
189
!MESSAGE Warning: cannot find "rac.dep"
190
!ENDIF 
191
!ENDIF 
192
193
194
!IF "$(CFG)" == "rac - Win32 Release" || "$(CFG)" == "rac - Win32 Debug"
195
SOURCE=..\rac\rac.c
196
197
"$(INTDIR)\rac.obj" : $(SOURCE) "$(INTDIR)"
198
	$(CPP) $(CPP_PROJ) $(SOURCE)
199
200
201
SOURCE=..\rac\version.rc
202
203
!IF  "$(CFG)" == "rac - Win32 Release"
204
205
206
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
207
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "\perfmon\rac" /d "NDEBUG" $(SOURCE)
208
209
210
!ELSEIF  "$(CFG)" == "rac - Win32 Debug"
211
212
213
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
214
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "\perfmon\rac" /d "NDEBUG" $(SOURCE)
215
216
217
!ENDIF 
218
219
220
!ENDIF 
221
(-)src-native-new/src/agents/RABindings/RABindings.c (+1402 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: RABindings.c,v 1.12 2006/10/30 19:10:00 samwai Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include <stdio.h>
14
#include <time.h>
15
#ifndef __OS400__
16
	#include <sys/timeb.h>
17
#endif
18
#include <sys/types.h>
19
20
/** Platform specifics */
21
#ifdef _WIN32								/* _WIN32 */
22
  #define TIMEB  struct _timeb
23
  #define FTIME(param)  _ftime(param)
24
#else										/* not Win32 */
25
  #include <sys/socket.h>
26
  #include <netinet/in.h>
27
  #include <netdb.h>
28
  #include <unistd.h>
29
  #include <pthread.h>
30
  #include <errno.h>
31
  #ifdef _HPUX
32
		#include <stdlib.h> /* for atexit() */
33
		#include <ctype.h> /* for isdigit() */
34
  #endif
35
  #define TIMEB	struct timeb
36
  #define FTIME(param)  ftime(param)
37
#endif
38
										/* endif */
39
#include "lock3.h"
40
#include "RAError.h"
41
#include "RASocket.h"
42
#include "RABindings.h"
43
44
#define AGENT_START_PORT 10004
45
#define MESSAGE_BUFFER_INCREMENT  1024
46
#define MAX_AGENT 512 /* maximum number of agents allowed */
47
48
/**
49
  * Globals
50
  */
51
#ifdef _WIN32
52
static HANDLE _vmLock=NULL;
53
#else
54
static pthread_mutex_t  _vmLock_mutex;
55
static pthread_cond_t   _vmLock_cond;
56
#endif
57
static BOOL   _pendingVMLock;
58
59
static BOOL _serverInitialized=FALSE;
60
61
62
static unsigned long _usageCount=0;
63
64
#ifdef _DEBUG
65
static FILE *dbgFile=NULL;
66
#endif
67
68
/** LinuxThreads follows the so-called "one-to-one" model: each thread is actually
69
    a separate process in the kernel. The kernel scheduler takes care of scheduling
70
    the threads, just like it schedules regular processes. The threads are created
71
    with the Linux clone() system call, which is a generalization of fork() allowing
72
    the new process to share the memory space, file descriptors, and signal handlers
73
    of the parent.  In the end this maps to a different result when calling getpid()
74
    when in different threads.  Providing startListener is invoked on the main thread
75
    of the process I will cache the process ID here and retrieve it using
76
    ra_getCurrentProcessId()
77
  */
78
#if defined __linux__ || defined _HPUX
79
static PID _pid;
80
#endif
81
82
/**
83
  * Function prototypes
84
  */
85
static BOOL processControlMessage(RA_AGENT_HANDLE handle,
86
                                  ra_message_t *message); 
87
88
static int readConnection(RA_HANDLE connection,
89
                          unsigned char *buffer,
90
                          int offset,
91
                          int length,
92
                          unsigned int *bytesRead);
93
94
static void messageLoop(RA_AGENT_HANDLE agentHandle, int timeout); /* APAR PK01709: Configurable named pipe timeout */
95
96
static BOOL validateRecvBuffer(unsigned char *buffer,
97
                               int length);
98
99
static ra_uint_t errorRecoveryScan(unsigned char *buffer,
100
                                   int length);
101
102
static ra_uint_t getMessageLengthfromValidBuffer(unsigned char *buffer);
103
104
static void sendAgentInactive(RA_AGENT_HANDLE handle);
105
106
void pipeServerCleanup(void *arg);
107
108
109
void *PipeServer(void *args);
110
#ifdef _WIN32
111
DWORD WINAPI win32pipeServerProxy(LPVOID args);
112
#endif
113
114
/* List and function to store agents for cleaning up */
115
int agentHandleCount = 0;
116
RA_AGENT_HANDLE agentHandleList[MAX_AGENT];
117
static void addHandle(RA_AGENT_HANDLE handle);
118
static void removeAllHandles();
119
static void removeHandle(RA_AGENT_HANDLE handle);
120
121
/** INITIALIZE_BINDINGS  ***********************************************
122
  * Initialization routine for the agent bindings, must be called first
123
  * by te agent before running any of the other functions specified in this
124
  * header file.
125
  * @param       name - the name of the agent.
126
  * @param       type - the type of the agent
127
  * @param    handler - the callback routine for all incomming messages.
128
  * @param standalone - determines whether this agent should communicate with the RAC
129
  *                     if standalone is TRUE the RAC is never used.
130
  * @returns  the new handle that is used to manage the agent.
131
  */
132
RA_AGENT_HANDLE ra_initializeBindings(const char *name,
133
                                      const char *type,
134
                                      ra_commandHandler_t handler,
135
                                      BOOL standalone) {
136
137
	/* Allocate the handle */
138
	RA_AGENT_HANDLE handle=(RA_AGENT_HANDLE)ra_malloc(sizeof(ra_agenthandle_t));
139
	BZERO(handle, sizeof(ra_agenthandle_t));
140
141
	/* At this point we are neither registered with the RAC nor are our bindings finalized */
142
	handle->registered=handle->finalized=FALSE;
143
	handle->pipefd = -1; /* 46651 */
144
145
	/* Setup the command handler */
146
	handle->commandHandler=handler;
147
148
	/* Generate a UUID for this agent */
149
	ra_generateUUID(&handle->agentUUID);
150
151
	/* Create the agent name/type */
152
	ra_createRASTRING(&handle->agentName, name);
153
	ra_createRASTRING(&handle->agentType, type);
154
155
	/* We won't know this information until we register with the RAC */
156
	handle->nodeUUID.length=0;
157
	handle->nodeUUID.data=NULL;
158
	handle->processUUID.length=0;
159
	handle->processUUID.data=NULL;
160
161
	/* TO_DO:  Determine node UUID in standalone mode for now..generate anew every time */
162
	if(!handle->nodeUUID.length) {
163
		ra_generateUUID(&handle->nodeUUID);
164
	}
165
166
	if(standalone && !handle->processUUID.length) {
167
		ra_generateUUID(&handle->processUUID);
168
	}
169
170
171
	/* The first agent needs to start the RAC watcher as well as cache the process ID on Linux */
172
	if(!_serverInitialized) {
173
		atexit(removeAllHandles);
174
/* BEGIN: 235649 */
175
#if defined __linux__ || defined _HPUX
176
		/* Save the process ID for later retrieval */
177
		if(!_pid) {
178
			_pid=getpid();
179
		}
180
#endif
181
/* END: 235649 */
182
		_serverInitialized=TRUE;
183
	}
184
185
186
	/* Copy the process ID into the storage structure */
187
	handle->processID=ra_getProcessId();
188
189
190
	/* Set the default configuration to be empty */
191
	handle->defaultConfiguration.head=handle->defaultConfiguration.tail=NULL;
192
193
	_usageCount++;
194
195
	return handle;
196
}
197
198
/** FINALIZE_BINDINGS  *********************************************************
199
  * Cleans up all the resources that were allocated during the agents
200
  * interaction with the bindings. Once this is called the handle is
201
  * no longer valid.
202
  * @param  handle - a handle returned by ra_initializeBindings.
203
  */
204
extern void ra_finalizeBindings(RA_AGENT_HANDLE handle) {
205
	ra_destroyRASTRING(&handle->agentUUID);
206
	ra_destroyRASTRING(&handle->nodeUUID);
207
	ra_destroyRASTRING(&handle->processUUID);
208
	ra_destroyRASTRING(&handle->agentName);
209
	ra_destroyRASTRING(&handle->agentType);
210
	_usageCount--;
211
}
212
213
214
/** START_LISTENER  ************************************************************
215
  * Start the message processor.
216
  * @param   handle - a handle returned by ra_initializeBindings
217
  * @param    block - whether to  block until the agent is successfuly
218
  *                   attached to a remote client.
219
  * @returns    NULL  call failed, call ra_getLastError() to determine failure
220
  *		    otherwise the address of the thread number the server message processor is
221
  *	                  listening on
222
  *
223
  */
224
TID *ra_startListener(RA_AGENT_HANDLE handle,
225
                      char lock) {
226
227
	/* Add the handler code when exiting */
228
	addHandle(handle);
229
230
	/* Create our named pipe */
231
	handle->pipefd=ra_createNamedPipe(handle->agentUUID.data);
232
233
	/* Run the server on a separate thread and return the tid */
234
#ifdef _WIN32
235
	handle->tHandle = CreateThread(NULL,					/* default security attributes */
236
				 0,						/* same stack size as current thread */
237
				 win32pipeServerProxy,	/* Thread entry point */
238
				 (LPVOID)handle,		/* params */
239
				 0,						/* start executing immediately */
240
				 &(handle->tid));		/* the thread ID */
241
#else
242
	errno=0;
243
	if(pthread_create(&(handle->tid),
244
					  NULL,
245
					  PipeServer,
246
					  handle)!=0) {
247
		/* bug 64225 begin */
248
		int thrdCreateLoopIndex = 1;
249
		int createRC = -1;
250
251
		/* Loop a finite number of times trying to create the thread if the operation
252
		 * fails with errno=EAGAIN
253
		 */
254
		while ( createRC != 0 && errno == EAGAIN && thrdCreateLoopIndex < 8 ) {
255
			#ifdef _DEBUG
256
			fprintf(dbgFile, "ra_startListener: EAGAIN failure creating PipeServer thread %d times\n", thrdCreateLoopIndex);
257
			fflush(dbgFile);
258
			#endif
259
			sleep(1);
260
			createRC = pthread_create(&(handle->tid),
261
					  NULL,
262
					  PipeServer,
263
					  handle);
264
			thrdCreateLoopIndex++;
265
266
		}
267
268
		/* If a thread still can't be created then quit */
269
		if (createRC != 0) {
270
			ra_setLastError(THREAD_CREATE_FAILED, errno);
271
			#ifdef _DEBUG
272
			fprintf(dbgFile, "ra_startListener: Failure creating PipeServer thread - errno=%d >%s\n", errno, strerror(errno));
273
			fflush(dbgFile);
274
			#endif
275
			return (TID*)(-1);
276
		}
277
		/* bug 64225 end */
278
	}
279
#endif
280
281
/*	jvmpiAgent_initializeLock(handle); */
282
	ra_initializeVMLock();
283
284
285
	/* If we are told to block until JVMPI_RESUME_VM */
286
	if(lock) {
287
		ra_setVMLock();
288
		ra_testVMLock();
289
290
/*
291
		jvmpiAgent_getWriteLock(handle);
292
293
		/* Don't return until specified
294
		jvmpiAgent_getWriteLock(handle);
295
		jvmpiAgent_releaseWriteLock(handle);
296
*/
297
	}
298
	return &handle->tid;
299
}
300
301
/** STOP_LISTENER  *************************************************************
302
  * Stops the message processor
303
  * @param  handle - a handle returned by ra_initializeBindings
304
  */
305
void ra_stopListener(RA_AGENT_HANDLE handle) {
306
307
#ifndef _WIN32
308
	void *status;
309
#endif
310
	/* Set that this handle is no longer valid.  The PipeServer created in initializeBindings
311
	 * will then exit and cleanup the remainder of this agents info.
312
	 */
313
314
	/* AS/400 need to call this because the thread_cleanup_push() isn't working as expected.
315
	 *	We may need to revisit this thread issue on the AS/400
316
	 */
317
#ifdef _DEBUG
318
	fprintf(dbgFile, "ra_stopListener: about to stop listener thread\n");
319
	fflush(dbgFile);
320
#endif
321
322
	handle->finalized=TRUE;
323
#if defined _WIN32
324
	/* we need to do this on Windows so that the PipeServer doesn't block on any 
325
	   calls dealing with the agent's pipe  -- we do this on other platforms when
326
	   pipeServerCleanup is called */ 
327
	ra_closeNamedPipe(handle->pipefd); 
328
	WaitForSingleObject(handle->tHandle, INFINITE);
329
	CloseHandle(handle->tHandle); 
330
#endif
331
#if defined _WIN32 || defined __OS400__ /* 238529 */
332
	pipeServerCleanup(handle);
333
#endif
334
335
336
	/* On posix we need to cancel the message processing thread so
337
	 * it can cleanup its resources.
338
    * 227339 - we need to wait until the message processing thread
339
    * ends to ensure the cleanup happens
340
	 */
341
#ifndef _WIN32
342
	pthread_cancel(handle->tid);
343
	pthread_join(handle->tid, &status);
344
#endif
345
346
}
347
348
/** SEND_MESSAGE  **************************************************************
349
  * Send the message to the RAC on this node.  It will
350
  * then be forwarded by the server to the client.
351
  * @param  handle - a handle returned by ra_initializeBindings
352
  * @param   message - the message structure to send.
353
  * @returns the number of bytes sent to the RAC.
354
  */
355
int ra_sendMessage(RA_AGENT_HANDLE handle,
356
                   ra_message_t *message) {
357
	int byte=0, length=0;
358
	char readyBuffer[MESSAGE_BUFFER_INCREMENT];
359
	char *buffer=NULL;
360
	int result;
361
	int paddingGuess = 64; /* we have to guess the number of padding byes for all RASTRING */	
362
	RA_HANDLE racConnection = -1; /* 46651 */
363
	int retryAttempts = 600; /* Bug 146962 */ /* number of times to retry our connection to the master pipe */ 
364
365
	/* Reconnect the server pipe */
366
	while ( (result=ra_openNamedPipe(RA_MASTER_ADDRESS)) < 0 && !handle->finalized && retryAttempts-- > 0) {
367
		SLEEP(100); /* sleep before connect reattempt so as not to create tightly spinning loop
368
					   that consumes CPU */ 
369
	}
370
371
	if (result < 0) {
372
		return 0;
373
	}
374
375
	racConnection = result; 
376
	/* Get the length here as we could overflow, otherwise use the static buffer */
377
	length=ra_determineMessageLength(message);
378
379
	#ifdef _DEBUG
380
	fprintf(dbgFile, "ra_sendMessage: about to write message of length %d\n", length);
381
	fflush(dbgFile);
382
	#endif
383
384
	if(length>MESSAGE_BUFFER_INCREMENT) {
385
		length=length*sizeof(char) + paddingGuess;
386
		buffer=(char*)ra_malloc(length); /* allocate with the extra padding bytes */			
387
	}
388
	else {
389
		buffer=readyBuffer;
390
		length = MESSAGE_BUFFER_INCREMENT;
391
	}
392
393
	#ifdef _DEBUG
394
	fprintf(dbgFile, "ra_sendMessage: about to write message to buffer %x  with length %d\n", buffer, length);
395
	fflush(dbgFile);
396
	#endif
397
398
	/* Write the message to the buffer */
399
	length=ra_writeMessageToBuffer((unsigned char *)buffer, length, message);
400
401
	#ifdef _DEBUG
402
	fprintf(dbgFile, "ra_sendMessage: about to write message of length %d to named pipe\n", length);
403
	fflush(dbgFile);
404
	#endif
405
406
	/* Send to the RAC */
407
	if(racConnection >= 0) { /* 46651 */
408
		result=ra_writeToNamedPipe(racConnection, buffer, 0, length, &byte);
409
		ra_closeNamedPipe(racConnection);
410
		#ifdef _DEBUG
411
		fprintf(dbgFile, "ra_sendMessage: wrote %d bytes to named pipe - result=%d\n", byte, result);
412
		fflush(dbgFile);
413
		#endif
414
	}
415
416
	return byte;
417
}
418
419
/** GET_PROCESS_ID **************************************************
420
  * Multiplatform convenience method to retrieve the current process
421
  * id.
422
  * @returns the PID of the curren process
423
  */
424
PID ra_getProcessId() {
425
#ifdef _WIN32
426
	return GetCurrentProcessId();
427
#elif defined __linux__ || defined _HPUX
428
	return _pid;
429
#else
430
	return getpid();
431
#endif
432
}
433
434
/** GET_NODE_UUID  *****************************************************
435
  * Retrieves the UUID of the node which this agent is running on.
436
  * Calling this function before ra_startListener results in undefined
437
  * behaviour.
438
  */
439
const char* ra_getNodeUUID(RA_AGENT_HANDLE storage) {
440
	if(storage->registered) {
441
		return storage->nodeUUID.data;
442
	}
443
	return NULL;
444
}
445
446
/** GET_PROCESS_ID  ****************************************************
447
  * Retrieves the UUID of the process which this agent is running in.
448
  * Calling this function before ra_startListener results in undefined
449
  * behaviour.
450
  */
451
const char* ra_getProcessUUID(RA_AGENT_HANDLE storage) {
452
	if(storage->registered) {
453
		return storage->processUUID.data;
454
	}
455
	return NULL;
456
}
457
458
/** GET_AGENT_UUID  ************************************************************
459
  * Retrieves the agent's UUID.
460
  */
461
const char* ra_getAgentUUID(RA_AGENT_HANDLE storage) {
462
	return storage->agentUUID.data;
463
}
464
465
/** GET_DEFAULT_CONFIGURATION  *************************************************
466
  * Retrieves a list of the options provided by the RAC as a default configuration
467
  * of the agent.  The configuration will only be available after the agent
468
  * has successfuly registered with the RAC.
469
  * @param  handle - a handle returned by ra_initializeBindings
470
  * @returns   the agent's default configuration list if the agent has registered
471
  *            with the RAC.  NULL otherwise.
472
  */
473
ra_agentConfigList_t* ra_getDefaultConfiguration(RA_AGENT_HANDLE handle) {
474
	if(!handle->registered) {
475
		return NULL;
476
	}
477
	return &handle->defaultConfiguration;
478
}
479
480
481
/** GET_PROCESS_COMMAND_LINE  ******************************************
482
  */
483
char* ra_getProcessCommandLine() {
484
#ifdef _WIN32
485
	char *temp;
486
	char * cmdLine=GetCommandLine();
487
	temp=cmdLine;
488
	while ((temp=strchr(temp, '\"'))!=NULL) {
489
		*temp=' ';
490
	}
491
	return cmdLine;
492
#else
493
	return NULL;
494
#endif
495
}
496
497
/** LOG_ERROR_MESSAGE  **************************************************
498
  *
499
  */
500
/* Bug 74367 */
501
int ra_logErrorMessage_return(RA_AGENT_HANDLE storage, RA_ERROR_LEVEL  severity, const char *messageId, const char *message) {
502
	int byteSent = 0;
503
	ra_message_t *errorMessage=ra_createMessage(RA_CONTROL_MESSAGE, 0);
504
	ra_command_t *errorCommand=ra_addCommandToMessage(errorMessage, NULL);
505
	errorCommand->tag=RA_ERROR_STRING;
506
	errorCommand->info.error_string.context=0;
507
	errorCommand->info.error_string.processId=ra_getProcessId();
508
	ra_copyRASTRING(&errorCommand->info.error_string.agent, &storage->agentName);
509
	errorCommand->info.error_string.severity=severity;
510
	ra_createRASTRING(&errorCommand->info.error_string.messageId, messageId);
511
	ra_createRASTRING(&errorCommand->info.error_string.message, message);
512
	byteSent = ra_sendMessage(storage, errorMessage);
513
	ra_destroyMessage(errorMessage, TRUE);
514
	return byteSent;
515
}
516
517
void ra_logErrorMessage(RA_AGENT_HANDLE storage, RA_ERROR_LEVEL  severity, const char *messageId, const char *message) {
518
	ra_logErrorMessage_return(storage, severity, messageId, message);
519
}
520
521
522
/** REQUEST_PEER_MONITOR  ******************************************************
523
  * Requests a remote client to start monitoring this agent by asking the agent
524
  * controller to find the client currently monitoring a peer agent.
525
  * THIS IS NOT CURRENTLY SUPPORTED.  DO NOT USE!!!!!!!
526
  */
527
extern int ra_requestPeerMonitor(RA_AGENT_HANDLE storage, ra_ipaddr_t *peerAddress, PID peerPID, ra_string_t *peerAgent, unsigned long timeout) {
528
	return ra_requestPeerMonitor_p(storage, peerAddress, 10002, peerPID, peerAgent, timeout);
529
}
530
531
extern int ra_requestPeerMonitor_p(RA_AGENT_HANDLE storage, ra_ipaddr_t *peerAddress, int peerPort, PID peerPID, ra_string_t *peerAgent, unsigned long timeout) {
532
533
	ra_message_t *attachRequestMessage=ra_createMessage(RA_CONTROL_MESSAGE, 0);
534
	ra_command_t *command=ra_addCommandToMessage(attachRequestMessage, NULL);
535
536
	if(peerPort == RA_CTL_PORT_NUM_SERVER) {
537
		command->tag=RA_AGENT_REQUEST_MONITOR;
538
		command->info.agent_request_monitor.context=0;
539
		command->info.agent_request_monitor.processId=ra_getProcessId();
540
		ra_copyRASTRING(&command->info.agent_request_monitor.agent, &storage->agentName);
541
		ra_createRASTRING(&command->info.agent_request_monitor.node, NULL);	/* This will be filled in by the RAC */
542
543
		/* Peer info */
544
		ra_createRASTRING3(&command->info.agent_request_monitor.peerNode, (const char*)peerAddress->addr, peerAddress->addrLength);
545
		command->info.agent_request_monitor.peerProcessId=peerPID;
546
		ra_copyRASTRING(&command->info.agent_request_monitor.peerAgent, peerAgent);
547
	}
548
	/* Bug 77768 */
549
	else {
550
		command->tag=RA_AGENT_REQUEST_MONITOR_PORT;
551
		command->info.agent_request_monitor_port.context=0;
552
		command->info.agent_request_monitor_port.processId=ra_getProcessId();
553
		ra_copyRASTRING(&command->info.agent_request_monitor_port.agent, &storage->agentName);
554
		ra_createRASTRING(&command->info.agent_request_monitor_port.node, NULL);	/* This will be filled in by the RAC */
555
556
		/* Peer info */
557
		ra_createRASTRING3(&command->info.agent_request_monitor_port.peerNode, (const char*)peerAddress->addr, peerAddress->addrLength);
558
		command->info.agent_request_monitor_port.peerProcessId=peerPID;
559
		ra_copyRASTRING(&command->info.agent_request_monitor_port.peerAgent, peerAgent);
560
		command->info.agent_request_monitor_port.port = 0;
561
		command->info.agent_request_monitor_port.peerPort = peerPort;
562
	}
563
564
	ra_sendMessage(storage, attachRequestMessage);
565
	ra_destroyMessage(attachRequestMessage, TRUE);
566
	return 0;
567
}
568
569
/** REQUEST_PEER_MONITOR  ******************************************************
570
  * Requests a remote client to start monitoring this agent by asking the agent
571
  * controller to find the client currently monitoring a peer agent.
572
  */
573
extern int ra_requestPeerMonitor2(RA_AGENT_HANDLE handle, ra_ipaddr_t *peerAddress, ra_string_t *peerAgentUUID, unsigned long timeout) {
574
	return ra_requestPeerMonitor2_p(handle, peerAddress, 10002, peerAgentUUID, timeout);
575
}
576
577
extern int ra_requestPeerMonitor2_p(RA_AGENT_HANDLE handle, ra_ipaddr_t *peerAddress, int peerPort, ra_string_t *peerAgentUUID, unsigned long timeout) {
578
579
	ra_message_t *attachRequestMessage=ra_createMessage(RA_CONTROL_MESSAGE, 0);
580
	ra_command_t *command=ra_addCommandToMessage(attachRequestMessage, NULL);
581
582
	if(peerPort == RA_CTL_PORT_NUM_SERVER) {
583
		command->tag=RA_AGENT_REQUEST_MONITOR;
584
		command->info.agent_request_monitor.context=0;
585
		command->info.agent_request_monitor.processId=ra_getProcessId();
586
		ra_copyRASTRING(&command->info.agent_request_monitor.agent, &handle->agentName);
587
		ra_createRASTRING(&command->info.agent_request_monitor.node, NULL);	/* This will be filled in by the RAC */
588
589
		/* Peer info */
590
		ra_createRASTRING3(&command->info.agent_request_monitor.peerNode, (const char*)peerAddress->addr, peerAddress->addrLength);
591
		command->info.agent_request_monitor.peerProcessId=0;
592
		ra_copyRASTRING(&command->info.agent_request_monitor.peerAgent, peerAgentUUID);
593
	}
594
	/* Bug 77768 */
595
	else {
596
		command->tag=RA_AGENT_REQUEST_MONITOR_PORT;
597
		command->info.agent_request_monitor_port.context=0;
598
		command->info.agent_request_monitor_port.processId=ra_getProcessId();
599
		ra_copyRASTRING(&command->info.agent_request_monitor_port.agent, &handle->agentName);
600
		ra_createRASTRING(&command->info.agent_request_monitor_port.node, NULL);	/* This will be filled in by the RAC */
601
602
		/* Peer info */
603
		ra_createRASTRING3(&command->info.agent_request_monitor_port.peerNode, (const char*)peerAddress->addr, peerAddress->addrLength);
604
		command->info.agent_request_monitor_port.peerProcessId=0;
605
		ra_copyRASTRING(&command->info.agent_request_monitor_port.peerAgent, peerAgentUUID);
606
		command->info.agent_request_monitor_port.port = 0;
607
		command->info.agent_request_monitor_port.peerPort = peerPort;
608
	}
609
610
	ra_sendMessage(handle, attachRequestMessage);
611
	ra_destroyMessage(attachRequestMessage, TRUE);
612
	return 0;
613
}
614
615
616
617
/** PROCESS_CONTROL_MESSAGE  ****************************************
618
  * Called by processMessage for JVMPI_CTL_MSG messages.
619
  * Breaks the message up into individual commands and forwards each
620
  * command to the registered _jvmpicomm_notify_message method.
621
  */
622
static BOOL processControlMessage(RA_AGENT_HANDLE handle,
623
								  ra_message_t *message) { 
624
	ra_command_list_node_t *current;
625
	ra_command_t connectedCommand;
626
	/* Process each command in turn */
627
	current=message->commands.head;
628
629
	while(current != NULL ) {
630
		/* Intercept the configuration information */
631
		if(current->command->tag==RA_AGENT_CONFIGURATION) {
632
			unsigned int i;
633
			ra_agentConfigListEntry_t *iterator;
634
635
			#ifdef _DEBUG
636
			fprintf(dbgFile, "processControlMessage: about to process RA_AGENT_CONFIGURATION\n");
637
			fflush(dbgFile);
638
			#endif
639
640
			/* Cleanup any configuration data from a previous handshake with the RAC */
641
			ra_destroyRASTRING(&handle->nodeUUID);
642
			ra_destroyRASTRING(&handle->processUUID);
643
			/* ra_destroyRASTRING(&handle->nodeUUID); */ 
644
			iterator=handle->defaultConfiguration.head;
645
			while(iterator) {
646
				ra_agentConfigListEntry_t *current;
647
				current=iterator;
648
				ra_destroyRASTRING(&current->entry.type);
649
				ra_destroyRASTRING(&current->entry.name);
650
				ra_destroyRASTRING(&current->entry.value);
651
				iterator=current->next;
652
				ra_free(current);
653
			}
654
			handle->defaultConfiguration.head=handle->defaultConfiguration.tail=NULL;
655
656
657
			/* Copy the binding information */
658
			ra_copyRASTRING(&handle->nodeUUID, &current->command->info.agent_configuration.nodeUUID);
659
			ra_copyRASTRING(&handle->processUUID, &current->command->info.agent_configuration.processUUID);
660
661
			/* Loop through the configuration and create a default configuration for the agent */
662
			#ifdef _DEBUG
663
			fprintf(dbgFile, "processControlMessage: Loop through the configuration and create a default configuration for the agent\n");
664
			fflush(dbgFile);
665
			#endif
666
			for(i=0; i<current->command->info.agent_configuration.configuration.length; i++) {
667
				ra_agentConfigListEntry_t  *copy;
668
				ra_agentConfigEntry_t *entry;
669
670
				entry=((ra_agentConfigEntry_t*)(current->command->info.agent_configuration.configuration.data[i]));
671
				copy=(ra_agentConfigListEntry_t*)ra_malloc(sizeof(ra_agentConfigListEntry_t));
672
				ra_copyRASTRING(&copy->entry.type, &entry->type);
673
				ra_copyRASTRING(&copy->entry.name, &entry->name);
674
				ra_copyRASTRING(&copy->entry.value, &entry->value);
675
676
				#ifdef _DEBUG
677
				fprintf(dbgFile, "processControlMessage:type=%s\n", copy->entry.type.data);
678
				fprintf(dbgFile, "processControlMessage:name=%s\n", copy->entry.name.data);
679
				fprintf(dbgFile, "processControlMessage:value=%s\n", copy->entry.value.data);
680
				fflush(dbgFile);
681
				#endif
682
				/* Insert into the list */
683
				copy->next=NULL;
684
				copy->previous=handle->defaultConfiguration.tail;
685
				handle->defaultConfiguration.tail=copy;
686
687
				/* If this not the first entry we must set the link in the previous tail */
688
				if(copy->previous) {
689
					copy->previous->next=copy;
690
				}
691
				else {
692
					handle->defaultConfiguration.head=copy;
693
				}
694
			}
695
			/* bugzilla 71840 start */ 
696
			#ifdef _DEBUG
697
			fprintf(dbgFile, "processControlMessage: let agent process RA_AGENT_CONTROLER_AVAILABLE\n");
698
			fflush(dbgFile);
699
			#endif
700
701
			/* Inform the agent we are connected */
702
			handle->registered=TRUE;
703
			connectedCommand.tag=RA_AGENT_CONTROLER_AVAILABLE;
704
			ra_copyRASTRING(&(connectedCommand.info.agentName), &handle->agentName);
705
			(handle->commandHandler)(&connectedCommand);
706
		
707
			#ifdef _DEBUG
708
			fprintf(dbgFile, "processControlMessage: after handling RA_AGENT_CONTROLER_AVAILABLE command\n");
709
			fflush(dbgFile);
710
			#endif
711
712
			ra_destroyRASTRING((ra_string_t*)&connectedCommand.info.agentName);
713
			/* bugzilla 71840 end */ 
714
			
715
716
		}
717
		else if(current->command->tag==RA_AGENT_CONTROLER_UNAVAILABLE) {
718
			return FALSE;
719
		}
720
		else {
721
722
			#ifdef _DEBUG
723
			fprintf(dbgFile, "procesControlMessage: about to pass command %d to command handler\n", current->command->tag);
724
			fflush(dbgFile);
725
			#endif
726
727
			/* Call the user defined message handler */
728
			if(handle->commandHandler) {
729
				(*handle->commandHandler)(current->command);
730
			}
731
		}
732
		current=current->next;
733
	}
734
735
	return TRUE;
736
}
737
738
739
void pipeServerCleanup(void *arg) {
740
	RA_AGENT_HANDLE handle=(RA_AGENT_HANDLE)arg;
741
	
742
	sendAgentInactive(handle); 
743
744
	removeHandle(handle);
745
#ifndef _WIN32
746
	/* done already prior to calling pipeServerCleanup() on Windows. */ 
747
	ra_closeNamedPipe(handle->pipefd);
748
#endif 
749
	ra_destroyNamedPipe(handle->agentUUID.data);
750
	removeHandle(handle);
751
	ra_free(handle);
752
}
753
754
755
/** PIPE_SERVER  ***************************************************************
756
  * This is the message loop for communications with the RAC.
757
  */
758
void *PipeServer(void *args) {
759
	RA_HANDLE handshakeConnection;
760
761
	RA_AGENT_HANDLE handle;
762
	/* APAR PK01709: Configurable named pipe timeout */
763
	int pipe_timeout = 1000; /* 1 second default timeout for opening master named pipe */
764
	char *pipe_timeout_name = "RA_IO_IDLE_TIME";
765
	char *pipe_timeout_value;
766
	unsigned int i;
767
	int rc;
768
	BOOL isValidTimeout = TRUE;
769
770
	/* Determine the pipe timeout */
771
#ifdef _WIN32
772
	pipe_timeout_value = (char*)malloc(sizeof(char) * 32);
773
	BZERO(pipe_timeout_value, 32);
774
	rc = GetEnvironmentVariable(pipe_timeout_name, pipe_timeout_value, 32);
775
	if(rc == 0) {
776
		/* Failed to retrieve the env var */
777
		pipe_timeout = 1000;
778
	}
779
	else if(rc == 16) {
780
		/* Env var string too long */
781
		pipe_timeout = 1000;
782
	}
783
	else {
784
		/* Check to see if it is all digit */
785
		for(i = 0; isValidTimeout && (i < strlen(pipe_timeout_value)); i++) {
786
			if(!isdigit(pipe_timeout_value[i])) {
787
				isValidTimeout = FALSE;
788
			}
789
		}
790
		if(isValidTimeout) {
791
			pipe_timeout = atoi(pipe_timeout_value);
792
		}
793
	}
794
	free(pipe_timeout_value);
795
#else
796
	/*printf("DEBUG: Timeout initially set to %d ms\n", pipe_timeout);*/
797
	pipe_timeout_value = (char*)getenv(pipe_timeout_name);
798
	if(pipe_timeout_value == NULL) {
799
		/* Failed to retrieve the env var */
800
	/*printf("DEBUG: Error retrieving timeout environment, leaving it as %d ms\n", pipe_timeout);*/
801
		pipe_timeout = 1000;
802
	}
803
	else {
804
	/*printf("DEBUG: Timeout environment variable %s set to: %s\n", pipe_timeout_name, pipe_timeout_value);*/
805
		/* Check to see if it is all digit */
806
		for(i = 0; isValidTimeout && (i < strlen(pipe_timeout_value)); i++) {
807
			if(!isdigit(pipe_timeout_value[i])) {
808
				isValidTimeout = FALSE;
809
			}
810
		}
811
		if(isValidTimeout) {
812
			pipe_timeout = atoi(pipe_timeout_value);
813
		}
814
		else {
815
			/*printf("DEBUG: Environment string cannot be converted to an integer value\n");*/
816
		}
817
	}
818
	/*printf("DEBUG: New pipe timeout set to %d ms\n", pipe_timeout);*/
819
#endif
820
821
	handle=((RA_AGENT_HANDLE)args);
822
823
	/* On posix we need to push a cleanup handler to ensure we destroy our message
824
	 * processing thread correctly
825
	 */
826
#ifndef _WIN32
827
	pthread_cleanup_push(pipeServerCleanup, handle);
828
#endif
829
830
	#ifdef _DEBUG
831
	dbgFile = fopen("hcbnd.dbg", "a");
832
	fprintf(dbgFile, "==========================PipeServer: starting server===================\n");
833
	fflush(dbgFile);
834
	#endif
835
836
outer:
837
	/* Loop as long as our handle is not finalized */
838
	while(!handle->finalized) {
839
		BOOL firstConnectTial=TRUE;
840
		ra_message_t *bindingMessage;
841
		ra_command_t *bindingCommand;
842
		unsigned char buffer[1024];
843
		int bytesWrote;
844
		unsigned int length;
845
		int result;
846
		BOOL sleepPrinted = FALSE; /* APAR PK01709: Configurable named pipe timeout */
847
		ra_command_t connectedCommand;
848
849
		/* Handshake with the RAC */
850
		firstConnectTial=TRUE;
851
		#ifdef _DEBUG
852
		fprintf(dbgFile, "PiprServer: Try to connect to RAC master named pipe\n");
853
		fflush(dbgFile);
854
		#endif
855
		do {
856
			handshakeConnection=ra_openNamedPipe(RA_MASTER_ADDRESS);
857
			if((int)handshakeConnection < 0) { /* 46651 */
858
				if(firstConnectTial) {
859
					/* Inform the agent that the RAC is not available */
860
					handle->registered=FALSE;
861
					connectedCommand.tag=RA_AGENT_CONTROLER_UNAVAILABLE;
862
					ra_copyRASTRING(&connectedCommand.info.agentName, &handle->agentName);
863
					(handle->commandHandler)(&connectedCommand);
864
					ra_destroyRASTRING((ra_string_t*)&connectedCommand.info.agentName);
865
					firstConnectTial=FALSE;
866
				}
867
				/* APAR PK01709: Configurable named pipe timeout */
868
				if(!sleepPrinted) {
869
#if defined(MVS)
870
					fprintf(stdout, "Agent Controller is not active: will wait in a %d ms loop\n", pipe_timeout);
871
					fflush(stdout);
872
#else
873
					printf("Agent Controller is not active: will wait in a %d ms loop\n", pipe_timeout);
874
#endif
875
					sleepPrinted = TRUE;
876
					#ifdef _DEBUG
877
					fprintf(dbgFile, "PipeServer: Agent Controller is not active: will wait in a %d ms loop\n", pipe_timeout);
878
					fflush(dbgFile);
879
					#endif
880
				}
881
				SLEEP(pipe_timeout);
882
			}
883
			if(handle->finalized){
884
				goto outer;
885
			}
886
		}while((int)handshakeConnection < 0); /* 46651 */ /* Bug 66383 */
887
		#ifdef _DEBUG
888
		fprintf(dbgFile, "PipeServer: Connected to RAC master named pipe\n");
889
		fflush(dbgFile);
890
		#endif
891
892
		#ifdef _DEBUG
893
		fprintf(dbgFile, "PipeServer: Trying to sent agent registration to the RAC\n");
894
		fflush(dbgFile);
895
		#endif
896
897
		/* Create our Binding message */
898
		bindingMessage=ra_createMessage(RA_CONTROL_MESSAGE, 1);
899
		bindingCommand=ra_addCommandToMessage(bindingMessage, NULL);
900
		bindingCommand->tag=RA_AGENT_SCOPING_INFORMATION;
901
		ra_copyRASTRING(&bindingCommand->info.agent_scoping_information.agent, &handle->agentName);
902
		ra_copyRASTRING(&bindingCommand->info.agent_scoping_information.agentUUID, &handle->agentUUID);
903
		ra_copyRASTRING(&bindingCommand->info.agent_scoping_information.nodeUUID, &handle->nodeUUID);
904
		ra_copyRASTRING(&bindingCommand->info.agent_scoping_information.agentType, &handle->agentType);
905
		ra_copyRASTRING(&bindingCommand->info.agent_scoping_information.processUUID, &handle->processUUID);
906
		bindingCommand->info.agent_scoping_information.processId=ra_getProcessId();
907
/* BEGIN:  235649 */
908
#if defined __linux__
909
		bindingCommand->info.agent_scoping_information.messageProcessId=getpid();
910
#endif
911
/* END: 235649 */
912
		bindingCommand->info.agent_scoping_information.context=0;
913
914
		/* We are handshaking, send our agent binding information */
915
		ra_determineMessageLength(bindingMessage); /* Bug 129050 */
916
		length=ra_writeMessageToBuffer(buffer, 1024, bindingMessage);
917
918
		/* RKD:  Need to check our return code here */
919
		result=ra_writeToNamedPipe(handshakeConnection, (char*)buffer, 0, length, &bytesWrote);
920
		ra_destroyMessage(bindingMessage, TRUE);
921
922
		/* Finish the handshake */
923
		ra_closeNamedPipe(handshakeConnection);
924
925
		#ifdef _DEBUG
926
		fprintf(dbgFile, "PipeServer: Successfully sent agent registration to the RAC\n");
927
		fflush(dbgFile);
928
		#endif
929
930
		/* APAR PK01709: Configurable named pipe timeout */
931
		#ifdef _DEBUG
932
		fprintf(dbgFile, "PipeServer: Waiting for Agent Named Pipe %s\n", handle->agentUUID.data);
933
		fflush(dbgFile);
934
		#endif
935
		while(!(ra_connectToNamedPipe(&handle->pipefd, handle->agentUUID.data)) && !handle->finalized) {
936
#if defined(MVS)
937
			fprintf(stdout, "Agent named pipe is not active: will wait in a %d ms loop\n", pipe_timeout);
938
			fflush(stdout);
939
#else
940
			printf("Agent named pipe is not active: will wait in a %d ms loop\n", pipe_timeout);
941
#endif
942
#ifdef _DEBUG
943
			fprintf(dbgFile, "Agent Named Pipe is not active: will wait in a %d ms loop\n", pipe_timeout);
944
			fflush(dbgFile);
945
#endif
946
			SLEEP(pipe_timeout);
947
		}
948
		#ifdef _DEBUG
949
		fprintf(dbgFile, "PipeServer: Agent Named Pipe %s has connected, fd = %d\n", handle->agentUUID.data, handle->pipefd);
950
		fflush(dbgFile);
951
		#endif
952
953
		/* Read our configuration info from the RAC. */
954
		messageLoop(handle, pipe_timeout); /* APAR PK01709: Configurable named pipe timeout */
955
956
		ra_disconnectFromNamedPipe(handle->pipefd); /* Bug 159179 */
957
		#ifdef _DEBUG
958
		fprintf(dbgFile, "PipeServer: disconnecting and closing named pipe %d\n", handle->pipefd);
959
		fflush(dbgFile);
960
		#endif
961
962
		#ifdef _DEBUG
963
		fprintf(dbgFile, "PipeServer: messageLoop has been broken due to RAC connection lost\n");
964
		fflush(dbgFile);
965
		#endif
966
	}
967
968
	/* Perform the thread cleanup */
969
#ifndef _WIN32
970
	pthread_cleanup_pop(1);
971
#endif
972
973
#ifdef _DEBUG
974
	fclose(dbgFile);
975
#endif
976
977
	return NULL;
978
}
979
980
981
#ifdef _WIN32
982
DWORD WINAPI win32pipeServerProxy(LPVOID args) {
983
	DWORD returnVal=0;
984
	PipeServer(args);
985
	return returnVal;
986
}
987
#endif
988
989
990
static void messageLoop(RA_AGENT_HANDLE agentHandle, int timeout) { /* APAR PK01709: Configurable named pipe timeout */
991
	int result;
992
	unsigned int bytesRead;
993
	unsigned char request[MESSAGE_BUFFER_INCREMENT];
994
	ra_message_t *message;
995
	unsigned char *correctBuffer;
996
	ra_uint_t messageLength, offset;
997
	BOOL sleepPrinted = FALSE; /* APAR PK01709: Configurable named pipe timeout */
998
	ra_command_t connectedCommand;
999
1000
	/* Initialize our variables */
1001
	message=NULL;
1002
	offset=0;
1003
1004
	while(!agentHandle->finalized) {
1005
		#ifdef _DEBUG
1006
		fprintf(dbgFile, "messageLoop: About to read from Agent Named Pipe %s, fd = %d\n", agentHandle->agentUUID.data, agentHandle->pipefd);
1007
		fflush(dbgFile);
1008
		#endif
1009
1010
		result = readConnection(agentHandle->pipefd, request, offset, MESSAGE_BUFFER_INCREMENT, &bytesRead);
1011
1012
		/* Inform the agent we are connected */
1013
		agentHandle->registered = TRUE;
1014
		connectedCommand.tag = RA_AGENT_CONTROLER_AVAILABLE;
1015
		ra_copyRASTRING(&(connectedCommand.info.agentName), &agentHandle->agentName);
1016
		(agentHandle->commandHandler)(&connectedCommand);
1017
		ra_destroyRASTRING((ra_string_t*)&connectedCommand.info.agentName);
1018
1019
		/* The connection is going down.  We need to break the loop */
1020
		if(result <= 0) {
1021
			/* Close the message pump */
1022
			#ifdef _DEBUG
1023
			fprintf(dbgFile, "messageLoop: readConnection on fd = %d failed, recheck RAC status, errno = %d\n", agentHandle->pipefd, ra_getLastErrorMinor());
1024
			fflush(dbgFile);
1025
			#endif
1026
			return; /* Let PipeServer to check for RAC connection */
1027
		}
1028
1029
		/* Increment bytesRead in case the master buffer contained a message fragment - 223065 */
1030
		bytesRead+=offset;
1031
1032
		#ifdef _DEBUG
1033
		fprintf(dbgFile, "messageLoop: fd = %d, bytesRead=%d  offset=%d\n", agentHandle->pipefd, bytesRead, offset);
1034
		fflush(dbgFile);
1035
		#endif
1036
1037
	    /* We assume the master buffer will not be fragmented due to an error later */
1038
		offset=0;
1039
1040
	    /* Validate the header of this message.  If it is invalid go into
1041
		   error recovery mode.  If it is valid then find out how long this
1042
		   message is.
1043
		*/
1044
	    correctBuffer=request;
1045
validate:
1046
	    if(validateRecvBuffer(correctBuffer, bytesRead)) {
1047
			BOOL agentControllerStillActive;
1048
			messageLength=getMessageLengthfromValidBuffer(correctBuffer);
1049
1050
			#ifdef _DEBUG
1051
			fprintf(dbgFile, "messageLoop: fd = %d, messageLength=%d  bytesRead=%d\n", agentHandle->pipefd, messageLength, bytesRead);
1052
			fflush(dbgFile);
1053
			#endif
1054
1055
			/* Are we missing part of the message because of overflow in the buffer */
1056
			if(messageLength>bytesRead) {
1057
				unsigned char *temp=(unsigned char*)ra_malloc(messageLength);
1058
				unsigned int currentLength=bytesRead;
1059
1060
				/* Save the data we have so far. */
1061
				memcpy(temp, correctBuffer, currentLength);
1062
				
1063
				while(currentLength < messageLength) {
1064
					result = readConnection(agentHandle->pipefd, temp, currentLength, messageLength, &bytesRead);
1065
1066
					/* If we have lost a connection before a message is complete we should abandon */
1067
					if(result <= 0) {
1068
						#ifdef _DEBUG
1069
						fprintf(dbgFile, "messageLoop: readConnection on fd = %d failed, recheck RAC status, errno = %d\n", agentHandle->pipefd, ra_getLastErrorMinor());
1070
						fflush(dbgFile);
1071
						#endif
1072
						return; /* Let PipeServer to check for RAC connection */
1073
					}
1074
					currentLength += bytesRead;
1075
1076
					#ifdef _DEBUG
1077
					fprintf(dbgFile, "messageLoop: fd = %d, currentLength = %d\n", agentHandle->pipefd, currentLength);
1078
					fflush(dbgFile);
1079
					#endif
1080
				}
1081
1082
				message=ra_readMessageFromBuffer(temp, (unsigned long)messageLength);
1083
1084
				#ifdef _DEBUG
1085
				fprintf(dbgFile, "messageLoop: fd = %d, after reading message from buffer 1: length=%d\n", agentHandle->pipefd, message->length);
1086
				fflush(dbgFile);
1087
				#endif
1088
1089
				/* Forward to the handler  */
1090
				agentControllerStillActive=processControlMessage(agentHandle, message); 
1091
				
1092
				#ifdef _DEBUG
1093
				fprintf(dbgFile, "messageLoop: fd = %d, after processing control message\n", agentHandle->pipefd);
1094
				fflush(dbgFile);
1095
				#endif
1096
1097
				ra_destroyMessage(message, TRUE);
1098
				ra_free(temp);
1099
1100
				if(!agentControllerStillActive) {
1101
					#ifdef _DEBUG
1102
					fprintf(dbgFile, "messageLoop: fd = %d, Agent Controller is not active, exiting message loop\n", agentHandle->pipefd);
1103
					fflush(dbgFile);
1104
					#endif
1105
					return;
1106
				}
1107
			}
1108
			else {
1109
				/* We have the entire message, but do we have more then one message */
1110
				message=ra_readMessageFromBuffer(correctBuffer, (unsigned long)(bytesRead));
1111
1112
				#ifdef _DEBUG
1113
				fprintf(dbgFile, "messageLoop: fd = %d, after reading message from buffer 2: length=%d\n", agentHandle->pipefd, message->length);
1114
				fflush(dbgFile);
1115
				#endif
1116
1117
				/* Forward to the handler */
1118
				agentControllerStillActive=processControlMessage(agentHandle, message);  
1119
1120
				bytesRead=bytesRead-message->length;
1121
				
1122
				#ifdef _DEBUG
1123
				fprintf(dbgFile, "messageLoop: fd = %d, after processing control message - bytesRead = %d\n", agentHandle->pipefd, bytesRead);
1124
				fflush(dbgFile);
1125
				#endif
1126
1127
				memcpy(correctBuffer, correctBuffer+message->length, bytesRead);
1128
				ra_destroyMessage(message, TRUE);
1129
1130
				if(!agentControllerStillActive) {
1131
					#ifdef _DEBUG
1132
					fprintf(dbgFile, "messageLoop: fd = %d, Agent Controller is not active, exiting message loop\n", agentHandle->pipefd);
1133
					fflush(dbgFile);
1134
					#endif
1135
					return; /* Let PipeServer to check for RAC connection */
1136
				}
1137
1138
				#ifdef _DEBUG
1139
				fprintf(dbgFile, "messageLoop: fd = %d, go back to validate remainder of message data\n", agentHandle->pipefd);
1140
				fflush(dbgFile);
1141
				#endif
1142
1143
				goto validate;
1144
			}
1145
		}
1146
		else {
1147
			#ifdef _DEBUG
1148
			fprintf(dbgFile, "messageLoop: fd = %d, invalid buffer processing.\n", agentHandle->pipefd);
1149
			fflush(dbgFile);
1150
			#endif
1151
1152
			bytesRead=errorRecoveryScan(correctBuffer, bytesRead);
1153
1154
			#ifdef _DEBUG
1155
			fprintf(dbgFile, "messageLoop: fd = %d, bytesRead after errorRecoveryScan = %d\n", agentHandle->pipefd, bytesRead);
1156
			fflush(dbgFile);
1157
			#endif
1158
1159
			/* If we have enough left that constitutes a header continue processing */
1160
			if(bytesRead>=24) {
1161
				goto validate;
1162
			}
1163
			else {
1164
				/* We need to read some more data.  Keep what we have so far */
1165
				if(correctBuffer!=request) {
1166
					memcpy(request, correctBuffer, bytesRead);
1167
				}
1168
				offset=bytesRead;
1169
			}
1170
			#ifdef _DEBUG
1171
			fprintf(dbgFile, "messageLoop: fd = %d, go back to read some more data\n", agentHandle->pipefd);
1172
			fflush(dbgFile);
1173
			#endif
1174
		}
1175
	}
1176
1177
#ifdef _DEBUG
1178
	fprintf(dbgFile, "messageLoop: fd = %d, connection with RAC has been broken\n", agentHandle->pipefd);
1179
	fflush(dbgFile);
1180
#endif
1181
1182
	return;
1183
}
1184
1185
/** READ_CONNECTIION  **********************************************************
1186
  * Generic read function for all platforms for both sockets and pipes.
1187
  * @returns  0 - connection closed gracefully
1188
  */
1189
static int readConnection(RA_HANDLE connection,
1190
						  unsigned char *buffer,
1191
						  int offset,
1192
						  int length,
1193
						  unsigned int *bytesRead) {
1194
#if defined _HPUX || defined __OS400__
1195
	return ra_readFromNamedPipe(connection, (char*)buffer, offset, length, (int*)bytesRead);
1196
#else
1197
	return ra_readFromNamedPipe(connection, buffer, offset, length, bytesRead);
1198
#endif
1199
}
1200
1201
1202
/** VALIDATE_RECV_BUFFER  *****************************************************
1203
  * This is a simple test to ensure a message starts with the majic number
1204
  * and that it at least contains enough information that we can determine
1205
  * the message length.
1206
  */
1207
static BOOL validateRecvBuffer(unsigned char *buffer, int length) {
1208
	/* Do we have a full header? */
1209
	if(length<24) {
1210
		return FALSE;
1211
	}
1212
1213
	/* Compare against the majic number 0x82656780 */
1214
	if(buffer[0]!=0x82 || buffer[1]!=0x65 || buffer[2]!=0x67 || buffer[3]!=0x80) {
1215
		return FALSE;
1216
	}
1217
	return TRUE;
1218
1219
}
1220
1221
1222
/** ERROR_RECOVERY_SCAN  *****************************************************
1223
  * When we get a bad message flow we go into recovery mode, searching for the
1224
  * next occurance of the majic number in the stream.  The buffer is then
1225
  * compressed and number of valid remaining bytes is returned.
1226
  */
1227
static ra_uint_t errorRecoveryScan(unsigned char *buffer, int length) {
1228
	int offset;
1229
	/* If there isn't enough bytes to check the majic number return zero */
1230
	if(length<4) {
1231
		return length;
1232
	}
1233
	/* Search for the next occurance of the majic number */
1234
	for(offset=0; offset<length-3; offset++) {
1235
		if(buffer[offset]==0x82 && buffer[offset+1]==0x65 && buffer[offset+2]==0x67 && buffer[offset+3]==0x80) {
1236
			memcpy(buffer, buffer+offset, length-offset);
1237
			return length-offset;
1238
		}
1239
	}
1240
	/* If we didn't find the magic number we need to save the last 3 bytes and return */
1241
	memcpy(buffer, buffer+offset, length-offset);
1242
	return length-offset;
1243
1244
}
1245
1246
1247
/** GET_MESSAGE_LENGTH_FROM_VALID_BUFFER  *************************************
1248
  * This simply extracts the message length from a message buffer that has
1249
  * previously been validated successfuly.
1250
  */
1251
static ra_uint_t getMessageLengthfromValidBuffer(unsigned char *buffer) {
1252
	return ((buffer[16]<<24)
1253
					  |(ra_uint_t)(buffer[17]<<16)
1254
					  |(ra_uint_t)(buffer[18]<<8)
1255
					  | buffer[19]);
1256
}
1257
1258
1259
1260
1261
1262
BOOL ra_initializeVMLock() {
1263
#ifdef _WIN32
1264
	_vmLock=CreateEvent(NULL,
1265
					 TRUE,
1266
					 TRUE,
1267
					 NULL);
1268
	if(_vmLock==NULL)
1269
		return FALSE;
1270
#else
1271
	pthread_mutex_init(&_vmLock_mutex, NULL);
1272
	pthread_cond_init(&_vmLock_cond, NULL);
1273
#endif
1274
	_pendingVMLock=FALSE;
1275
	return TRUE;
1276
}
1277
1278
void ra_setVMLock() {
1279
#ifdef _WIN32
1280
	ResetEvent(_vmLock);
1281
#else
1282
	pthread_mutex_lock(&_vmLock_mutex);
1283
#endif
1284
	_pendingVMLock=TRUE;
1285
#ifndef _WIN32
1286
	pthread_mutex_unlock(&_vmLock_mutex);
1287
#endif
1288
}
1289
1290
void ra_releaseVMLock() {
1291
#ifndef _WIN32
1292
	pthread_mutex_lock(&_vmLock_mutex);
1293
#endif
1294
	_pendingVMLock=FALSE;
1295
#ifdef _WIN32
1296
	SetEvent(_vmLock);
1297
#else
1298
	pthread_mutex_unlock(&_vmLock_mutex);
1299
	pthread_cond_broadcast(&_vmLock_cond);
1300
#endif
1301
}
1302
1303
void ra_testVMLock() {
1304
#ifndef _WIN32
1305
	pthread_mutex_lock(&_vmLock_mutex);
1306
#endif
1307
	if(_pendingVMLock) {
1308
#ifdef _WIN32
1309
		WaitForSingleObject(_vmLock, INFINITE);
1310
#else
1311
		pthread_cond_wait(&_vmLock_cond, &_vmLock_mutex);
1312
#endif
1313
	}
1314
#ifndef _WIN32
1315
	pthread_mutex_unlock(&_vmLock_mutex);
1316
#endif
1317
1318
}
1319
1320
BOOL ra_getVMLockState() {
1321
	if(_pendingVMLock)
1322
		return TRUE;
1323
	else
1324
		return FALSE;
1325
}
1326
1327
static void addHandle(RA_AGENT_HANDLE handle) {
1328
	agentHandleList[agentHandleCount++] = handle;
1329
}
1330
1331
static void removeAllHandles() {
1332
	int i;
1333
	for(i = 0; i < agentHandleCount; i++) {
1334
		if(agentHandleList[i] != NULL) {
1335
			#ifdef _DEBUG
1336
			if (dbgFile != NULL) {
1337
				fprintf(dbgFile, "removeAllHandles: about to stop listener thread\n");
1338
				fflush(dbgFile);
1339
			}
1340
			#endif
1341
			ra_stopListener(agentHandleList[i]);
1342
			/* Getting a SIGSEV on Red Hat when exiting workbench, disable the finalize for now. */
1343
/*			ra_finalizeBindings(agentHandleList[i]);*/
1344
		}
1345
	}
1346
}
1347
1348
1349
static void removeHandle(RA_AGENT_HANDLE handle) {
1350
	int i;
1351
	for(i = 0; i < agentHandleCount; i++) {
1352
		if(agentHandleList[i] == handle) {
1353
			agentHandleList[i]=NULL;
1354
			return;
1355
		}
1356
	}
1357
}
1358
1359
1360
static void sendAgentInactive(RA_AGENT_HANDLE handle) {
1361
	ra_message_t *message;
1362
	ra_command_t *command;
1363
1364
	message=ra_createMessage(RA_CONTROL_MESSAGE, 0);
1365
	command=ra_addCommandToMessage(message, NULL);
1366
1367
1368
	/* Set the agent information */
1369
	command->tag=RA_AGENT_INACTIVE;
1370
	command->info.agent_inactive.processId = ra_getProcessId();
1371
	ra_createRASTRING(&command->info.agent_inactive.processUUID, ra_getProcessUUID(handle));
1372
	ra_copyRASTRING(&command->info.agent_inactive.agent, &handle->agentName);
1373
	ra_createRASTRING(&command->info.agent_inactive.agentUUID, ra_getAgentUUID(handle));
1374
	ra_copyRASTRING(&command->info.agent_inactive.agentType, &handle->agentType);
1375
1376
	/* Inform server we are exiting */
1377
	ra_sendMessage(handle, message);
1378
1379
	/* Clean up the allocated memory */
1380
	ra_destroyMessage(message, TRUE);
1381
1382
}
1383
1384
void ra_getPropertyValues(RA_AGENT_HANDLE handle, char* name, char* type) {
1385
	ra_message_t *message;
1386
	ra_command_t *command;
1387
1388
	message = ra_createMessage(RA_CONTROL_MESSAGE, 0);
1389
	command = ra_addCommandToMessage(message, NULL);
1390
1391
	command->tag = RA_GET_PROPERTY_LIST;
1392
	command->info.query_property_list.context = 0;
1393
	ra_createRASTRING(&command->info.query_property_list.name, name);
1394
	ra_createRASTRING(&command->info.query_property_list.type, type);
1395
	ra_createRASTRING(&command->info.query_property_list.agentUUID, ra_getAgentUUID(handle));
1396
1397
	ra_sendMessage(handle, message);
1398
1399
	ra_destroyMessage(message, TRUE);
1400
1401
	return;
1402
}
(-)src-native-new/src/agents/java/WinBuild/log_agent.mak (+229 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on log_agent.dsp
2
!IF "$(CFG)" == ""
3
CFG=log_agent - Win32 Debug
4
!MESSAGE No configuration specified. Defaulting to log_agent - Win32 Debug.
5
!ENDIF 
6
7
!IF "$(CFG)" != "log_agent - Win32 Release" && "$(CFG)" != "log_agent - Win32 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "log_agent.mak" CFG="log_agent - Win32 Debug"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "log_agent - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
17
!MESSAGE "log_agent - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
18
!MESSAGE 
19
!ERROR An invalid configuration is specified.
20
!ENDIF 
21
22
!IF "$(OS)" == "Windows_NT"
23
NULL=
24
!ELSE 
25
NULL=nul
26
!ENDIF 
27
28
!IF  "$(CFG)" == "log_agent - Win32 Release"
29
30
OUTDIR=..\..\..\bin
31
INTDIR=.\Release
32
# Begin Custom Macros
33
OutDir=..\..\..\bin
34
# End Custom Macros
35
36
ALL : "$(OUTDIR)\hcjbnd.dll"
37
38
39
CLEAN :
40
	-@erase "$(INTDIR)\hcjbnd.obj"
41
	-@erase "$(INTDIR)\hcjbnd.res"
42
	-@erase "$(INTDIR)\vc60.idb"
43
	-@erase "$(OUTDIR)\hcjbnd.dll"
44
	-@erase "$(OUTDIR)\hcjbnd.exp"
45
	-@erase "$(OUTDIR)\hcjbnd.lib"
46
	-@erase ".\Release\hcjbnd.map"
47
48
"$(OUTDIR)" :
49
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
50
51
"$(INTDIR)" :
52
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
53
54
CPP=cl.exe
55
CPP_PROJ=/nologo /MT /W3 /GX /O2 /Ob0 /I "..\..\framework\RABindings" /I "..\..\framework\RACommon" /I "..\..\framework\RASocket" /I "..\..\framework\RADataTransfer" /I "..\..\framework\RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LOG_AGENT_EXPORTS" /Fp"$(INTDIR)\log_agent.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
56
57
.c{$(INTDIR)}.obj::
58
   $(CPP) @<<
59
   $(CPP_PROJ) $< 
60
<<
61
62
.cpp{$(INTDIR)}.obj::
63
   $(CPP) @<<
64
   $(CPP_PROJ) $< 
65
<<
66
67
.cxx{$(INTDIR)}.obj::
68
   $(CPP) @<<
69
   $(CPP_PROJ) $< 
70
<<
71
72
.c{$(INTDIR)}.sbr::
73
   $(CPP) @<<
74
   $(CPP_PROJ) $< 
75
<<
76
77
.cpp{$(INTDIR)}.sbr::
78
   $(CPP) @<<
79
   $(CPP_PROJ) $< 
80
<<
81
82
.cxx{$(INTDIR)}.sbr::
83
   $(CPP) @<<
84
   $(CPP_PROJ) $< 
85
<<
86
87
MTL=midl.exe
88
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
89
RSC=rc.exe
90
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcjbnd.res" /d "NDEBUG" 
91
BSC32=bscmake.exe
92
BSC32_FLAGS=/nologo /o"$(OUTDIR)\log_agent.bsc" 
93
BSC32_SBRS= \
94
	
95
LINK32=link.exe
96
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hcclco.lib hccldt.lib hccls.lib hcbnd.lib hcclsm.lib /nologo /version:0.1 /dll /incremental:no /pdb:"$(OUTDIR)\hcjbnd.pdb" /map:"$(INTDIR)\hcjbnd.map" /machine:I386 /def:"..\hcjbnd.def" /out:"$(OUTDIR)\hcjbnd.dll" /implib:"$(OUTDIR)\hcjbnd.lib" /libpath:"..\..\..\lib" 
97
DEF_FILE= \
98
	"..\hcjbnd.def"
99
LINK32_OBJS= \
100
	"$(INTDIR)\hcjbnd.obj" \
101
	"$(INTDIR)\hcjbnd.res"
102
103
"$(OUTDIR)\hcjbnd.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
104
    $(LINK32) @<<
105
  $(LINK32_FLAGS) $(LINK32_OBJS)
106
<<
107
108
!ELSEIF  "$(CFG)" == "log_agent - Win32 Debug"
109
110
OUTDIR=..\..\..\bin
111
INTDIR=.\Debug
112
# Begin Custom Macros
113
OutDir=..\..\..\bin
114
# End Custom Macros
115
116
ALL : "$(OUTDIR)\hcjbnd.dll"
117
118
119
CLEAN :
120
	-@erase "$(INTDIR)\hcjbnd.obj"
121
	-@erase "$(INTDIR)\hcjbnd.res"
122
	-@erase "$(INTDIR)\vc60.idb"
123
	-@erase "$(INTDIR)\vc60.pdb"
124
	-@erase "$(OUTDIR)\hcjbnd.dll"
125
	-@erase "$(OUTDIR)\hcjbnd.exp"
126
	-@erase "$(OUTDIR)\hcjbnd.ilk"
127
	-@erase "$(OUTDIR)\hcjbnd.lib"
128
	-@erase "$(OUTDIR)\hcjbnd.pdb"
129
130
"$(OUTDIR)" :
131
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
132
133
"$(INTDIR)" :
134
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
135
136
CPP=cl.exe
137
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\framework\RABindings" /I "..\..\framework\RACommon" /I "..\..\framework\RASocket" /I "..\..\framework\RADataTransfer" /I "..\..\framework\RASharedMemory" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LOG_AGENT_EXPORTS" /Fp"$(INTDIR)\log_agent.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
138
139
.c{$(INTDIR)}.obj::
140
   $(CPP) @<<
141
   $(CPP_PROJ) $< 
142
<<
143
144
.cpp{$(INTDIR)}.obj::
145
   $(CPP) @<<
146
   $(CPP_PROJ) $< 
147
<<
148
149
.cxx{$(INTDIR)}.obj::
150
   $(CPP) @<<
151
   $(CPP_PROJ) $< 
152
<<
153
154
.c{$(INTDIR)}.sbr::
155
   $(CPP) @<<
156
   $(CPP_PROJ) $< 
157
<<
158
159
.cpp{$(INTDIR)}.sbr::
160
   $(CPP) @<<
161
   $(CPP_PROJ) $< 
162
<<
163
164
.cxx{$(INTDIR)}.sbr::
165
   $(CPP) @<<
166
   $(CPP_PROJ) $< 
167
<<
168
169
MTL=midl.exe
170
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
171
RSC=rc.exe
172
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcjbnd.res" /d "_DEBUG" 
173
BSC32=bscmake.exe
174
BSC32_FLAGS=/nologo /o"$(OUTDIR)\log_agent.bsc" 
175
BSC32_SBRS= \
176
	
177
LINK32=link.exe
178
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hcclco.lib hccldt.lib hccls.lib hcbnd.lib hcclsm.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcjbnd.pdb" /debug /machine:I386 /def:"..\hcjbnd.def" /out:"$(OUTDIR)\hcjbnd.dll" /implib:"$(OUTDIR)\hcjbnd.lib" /pdbtype:sept /libpath:"..\..\..\lib" 
179
DEF_FILE= \
180
	"..\hcjbnd.def"
181
LINK32_OBJS= \
182
	"$(INTDIR)\hcjbnd.obj" \
183
	"$(INTDIR)\hcjbnd.res"
184
185
"$(OUTDIR)\hcjbnd.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
186
    $(LINK32) @<<
187
  $(LINK32_FLAGS) $(LINK32_OBJS)
188
<<
189
190
!ENDIF 
191
192
193
!IF "$(NO_EXTERNAL_DEPS)" != "1"
194
!IF EXISTS("log_agent.dep")
195
!INCLUDE "log_agent.dep"
196
!ELSE 
197
!MESSAGE Warning: cannot find "log_agent.dep"
198
!ENDIF 
199
!ENDIF 
200
201
202
!IF "$(CFG)" == "log_agent - Win32 Release" || "$(CFG)" == "log_agent - Win32 Debug"
203
SOURCE=..\hcjbnd.c
204
205
"$(INTDIR)\hcjbnd.obj" : $(SOURCE) "$(INTDIR)"
206
	$(CPP) $(CPP_PROJ) $(SOURCE)
207
208
209
SOURCE=..\version.rc
210
211
!IF  "$(CFG)" == "log_agent - Win32 Release"
212
213
214
"$(INTDIR)\hcjbnd.res" : $(SOURCE) "$(INTDIR)"
215
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcjbnd.res" /i "\eclipse\workspace\org.eclipse.hyades.datacollection\collection\collectors\java" /d "NDEBUG" $(SOURCE)
216
217
218
!ELSEIF  "$(CFG)" == "log_agent - Win32 Debug"
219
220
221
"$(INTDIR)\hcjbnd.res" : $(SOURCE) "$(INTDIR)"
222
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcjbnd.res" /i "\eclipse\workspace\org.eclipse.hyades.datacollection\collection\collectors\java" /d "_DEBUG" $(SOURCE)
223
224
225
!ENDIF 
226
227
228
!ENDIF 
229
(-)src-native-new/src/transport/RADataTransfer/hccldt.exp (+4 lines)
Added Link Here
1
#! libracldt.so exports
2
ra_allocateMessageBlock
3
ra_freeMessageBlock
4
ra_writeMessageBlock
(-)src-native-new/src/agents/perfmon/sysperf/perfcalc.h (+61 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: perfcalc.h,v 1.5 2006/05/23 16:21:26 gchristelis Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
14
#ifndef __PERFCALC_H__
15
#define __PERFCALC_H__
16
17
//#include <winsock2.h> /* Bug 134924 */
18
#include <windows.h>
19
20
void createValueTables();
21
void freeValueTables();
22
23
void getPERF_COUNTER_RAWCOUNT			(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr);
24
void getPERF_RAW_FRACTION				(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2);
25
void getPERF_COUNTER_COUNTER			(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData);
26
void getPERF_COUNTER_BULK_COUNT			(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData);
27
void getPERF_100NSEC_TIMER				(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData);
28
void getPERF_100NSEC_TIMER_INV			(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData);
29
void getPERF_ELAPSED_TIME				(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData, PPERF_OBJECT_TYPE PerfObj);
30
void getPERF_COUNTER_LARGE_RAWCOUNT		(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr);
31
void getPERF_COUNTER_LARGE_RAWCOUNT_HEX (char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr);
32
void getPERF_AVERAGE_TIMER				(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2,PPERF_DATA_BLOCK PerfData);
33
void getPERF_AVERAGE_BULK				(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2);
34
void getPERF_COUNTER_LARGE_QUEUELEN_TYPE(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData);
35
void getPERF_COUNTER_NODATA				(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr);
36
void getPERF_SAMPLE_FRACTION			(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2);
37
void getPERF_SAMPLE_COUNTER				(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2); 
38
void getPERF_COUNTER_DELTA				(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr);
39
void getPERF_COUNTER_LARGE_DELTA		(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr);
40
void getPERF_100NSEC_MULTI_TIMER		(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2, PPERF_DATA_BLOCK PerfData);
41
void getPERF_100NSEC_MULTI_TIMER_INV	(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2, PPERF_DATA_BLOCK PerfData);
42
void getPERF_COUNTER_RAWCOUNT_HEX		(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr);
43
void getPERF_COUNTER_TIMER				(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData);
44
void getPERF_COUNTER_TIMER_INV			(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData);
45
void getPERF_COUNTER_MULTI_TIMER		(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2, PPERF_DATA_BLOCK PerfData);
46
void getPERF_COUNTER_MULTI_TIMER_INV	(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2, PPERF_DATA_BLOCK PerfData);
47
void getPERF_COUNTER_QUEUELEN_TYPE		(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData);
48
void getPERF_OBJ_TIME_TIMER				(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData);
49
void getPERF_PRECISION_100NS_TIMER		(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2, PPERF_DATA_BLOCK PerfData);
50
void getPERF_PRECISION_OBJECT_TIMER		(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2, PPERF_DATA_BLOCK PerfData);
51
void getPERF_PRECISION_SYSTEM_TIMER		(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2, PPERF_DATA_BLOCK PerfData);
52
void getPERF_COUNTER_100NS_QUEUELEN_TYPE(char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData);
53
54
55
56
57
58
59
60
61
#endif __PERFCALC_H__
(-)src-native-new/src/transport/RADataTransfer/RADataTransfer.dsp (+123 lines)
Added Link Here
1
# Microsoft Developer Studio Project File - Name="RADataTransfer" - Package Owner=<4>
2
# Microsoft Developer Studio Generated Build File, Format Version 6.00
3
# ** DO NOT EDIT **
4
5
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
6
7
CFG=RADataTransfer - Win32 Debug
8
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9
!MESSAGE use the Export Makefile command and run
10
!MESSAGE 
11
!MESSAGE NMAKE /f "RADataTransfer.mak".
12
!MESSAGE 
13
!MESSAGE You can specify a configuration when running NMAKE
14
!MESSAGE by defining the macro CFG on the command line. For example:
15
!MESSAGE 
16
!MESSAGE NMAKE /f "RADataTransfer.mak" CFG="RADataTransfer - Win32 Debug"
17
!MESSAGE 
18
!MESSAGE Possible choices for configuration are:
19
!MESSAGE 
20
!MESSAGE "RADataTransfer - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
21
!MESSAGE "RADataTransfer - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
22
!MESSAGE 
23
24
# Begin Project
25
# PROP AllowPerConfigDependencies 0
26
# PROP Scc_ProjName ""
27
# PROP Scc_LocalPath ""
28
CPP=cl.exe
29
MTL=midl.exe
30
RSC=rc.exe
31
32
!IF  "$(CFG)" == "RADataTransfer - Win32 Release"
33
34
# PROP BASE Use_MFC 0
35
# PROP BASE Use_Debug_Libraries 0
36
# PROP BASE Output_Dir "RADataTransfer___Win32_Release"
37
# PROP BASE Intermediate_Dir "RADataTransfer___Win32_Release"
38
# PROP BASE Target_Dir ""
39
# PROP Use_MFC 0
40
# PROP Use_Debug_Libraries 0
41
# PROP Output_Dir "../../../bin"
42
# PROP Intermediate_Dir "Release"
43
# PROP Ignore_Export_Lib 0
44
# PROP Target_Dir ""
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RADATATRANSFER_EXPORTS" /YX /FD /c
46
# ADD CPP /nologo /MT /W3 /GX /O2 /Ob0 /I "..\RACommon" /I "..\RASharedMemory" /I "..\RASocket" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RADATATRANSFER_EXPORTS" /D "ENW" /D "SQLWINT" /YX /FD /c
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
49
# ADD BASE RSC /l 0x409 /d "NDEBUG"
50
# ADD RSC /l 0x409 /fo"Release/hccldt.res" /d "NDEBUG"
51
BSC32=bscmake.exe
52
# ADD BASE BSC32 /nologo
53
# ADD BSC32 /nologo
54
LINK32=link.exe
55
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
56
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hcclco.lib hccls.lib hcclsm.lib /nologo /version:0.1 /dll /pdb:none /machine:I386 /out:"../../../bin/hccldt.dll" /libpath:"../../../lib" /implib:"../../../lib/hccldt.lib"
57
58
!ELSEIF  "$(CFG)" == "RADataTransfer - Win32 Debug"
59
60
# PROP BASE Use_MFC 0
61
# PROP BASE Use_Debug_Libraries 1
62
# PROP BASE Output_Dir "RADataTransfer___Win32_Debug"
63
# PROP BASE Intermediate_Dir "RADataTransfer___Win32_Debug"
64
# PROP BASE Target_Dir ""
65
# PROP Use_MFC 0
66
# PROP Use_Debug_Libraries 1
67
# PROP Output_Dir "../../../bin"
68
# PROP Intermediate_Dir "Debug"
69
# PROP Ignore_Export_Lib 0
70
# PROP Target_Dir ""
71
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RADATATRANSFER_EXPORTS" /YX /FD /GZ /c
72
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\RACommon" /I "..\RASharedMemory" /I "..\RASocket" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RADATATRANSFER_EXPORTS" /D "ENW" /D "SQLWINT" /YX /FD /GZ /c
73
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
74
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
75
# ADD BASE RSC /l 0x409 /d "_DEBUG"
76
# ADD RSC /l 0x409 /fo"Debug/hccldt.res" /d "_DEBUG"
77
BSC32=bscmake.exe
78
# ADD BASE BSC32 /nologo
79
# ADD BSC32 /nologo
80
LINK32=link.exe
81
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
82
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hcclco.lib hccls.lib hcclsm.lib /nologo /dll /debug /machine:I386 /out:"../../../bin/hccldt.dll" /pdbtype:sept /libpath:"../../../lib" /implib:"../../../lib/hccldt.lib"
83
84
!ENDIF 
85
86
# Begin Target
87
88
# Name "RADataTransfer - Win32 Release"
89
# Name "RADataTransfer - Win32 Debug"
90
# Begin Group "Source Files"
91
92
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
93
# Begin Source File
94
95
SOURCE=..\RADataTransfer\RADataTransfer.c
96
# End Source File
97
# Begin Source File
98
99
SOURCE=..\RADataTransfer\RADataTransfer.def
100
# End Source File
101
# End Group
102
# Begin Group "Header Files"
103
104
# PROP Default_Filter "h;hpp;hxx;hm;inl"
105
# Begin Source File
106
107
SOURCE=..\RADataTransfer\RADataTransfer.h
108
# End Source File
109
# Begin Source File
110
111
SOURCE=..\RADataTransfer\resource.h
112
# End Source File
113
# End Group
114
# Begin Group "Resource Files"
115
116
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
117
# Begin Source File
118
119
SOURCE=..\RADataTransfer\version.rc
120
# End Source File
121
# End Group
122
# End Target
123
# End Project
(-)src-native-new/src/HCLauncher/resource.h (+28 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: resource.h,v 1.4 2006/04/06 15:48:12 samwai Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
//{{NO_DEPENDENCIES}}
14
// Microsoft Developer Studio generated include file.
15
// Used by version.rc
16
//
17
18
19
// Next default values for new objects
20
//
21
#ifdef APSTUDIO_INVOKED
22
#ifndef APSTUDIO_READONLY_SYMBOLS
23
#define _APS_NEXT_RESOURCE_VALUE        101
24
#define _APS_NEXT_COMMAND_VALUE         40001
25
#define _APS_NEXT_CONTROL_VALUE         1000
26
#define _APS_NEXT_SYMED_VALUE           101
27
#endif
28
#endif
(-)src-native-new/src/agents/perfmon/WinBuild/resutils.dsp (+136 lines)
Added Link Here
1
# Microsoft Developer Studio Project File - Name="resutils" - Package Owner=<4>
2
# Microsoft Developer Studio Generated Build File, Format Version 6.00
3
# ** DO NOT EDIT **
4
5
# TARGTYPE "Win32 (x86) Static Library" 0x0104
6
7
CFG=resutils - Win32 Release
8
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9
!MESSAGE use the Export Makefile command and run
10
!MESSAGE 
11
!MESSAGE NMAKE /f "resutils.mak".
12
!MESSAGE 
13
!MESSAGE You can specify a configuration when running NMAKE
14
!MESSAGE by defining the macro CFG on the command line. For example:
15
!MESSAGE 
16
!MESSAGE NMAKE /f "resutils.mak" CFG="resutils - Win32 Release"
17
!MESSAGE 
18
!MESSAGE Possible choices for configuration are:
19
!MESSAGE 
20
!MESSAGE "resutils - Win32 Release" (based on "Win32 (x86) Static Library")
21
!MESSAGE "resutils - Win32 Debug" (based on "Win32 (x86) Static Library")
22
!MESSAGE 
23
24
# Begin Project
25
# PROP AllowPerConfigDependencies 0
26
# PROP Scc_ProjName ""
27
# PROP Scc_LocalPath ""
28
CPP=cl.exe
29
RSC=rc.exe
30
31
!IF  "$(CFG)" == "resutils - Win32 Release"
32
33
# PROP BASE Use_MFC 0
34
# PROP BASE Use_Debug_Libraries 0
35
# PROP BASE Output_Dir "resutils___Win32_Release"
36
# PROP BASE Intermediate_Dir "resutils___Win32_Release"
37
# PROP BASE Target_Dir ""
38
# PROP Use_MFC 0
39
# PROP Use_Debug_Libraries 0
40
# PROP Output_Dir "..\..\..\..\lib"
41
# PROP Intermediate_Dir "Release"
42
# PROP Target_Dir ""
43
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
44
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
45
# ADD BASE RSC /l 0x409 /d "NDEBUG"
46
# ADD RSC /l 0x409 /d "NDEBUG"
47
BSC32=bscmake.exe
48
# ADD BASE BSC32 /nologo
49
# ADD BSC32 /nologo
50
LIB32=link.exe -lib
51
# ADD BASE LIB32 /nologo
52
# ADD LIB32 /nologo
53
54
!ELSEIF  "$(CFG)" == "resutils - Win32 Debug"
55
56
# PROP BASE Use_MFC 0
57
# PROP BASE Use_Debug_Libraries 0
58
# PROP BASE Output_Dir "resutils___Win32_Debug"
59
# PROP BASE Intermediate_Dir "resutils___Win32_Debug"
60
# PROP BASE Target_Dir ""
61
# PROP Use_MFC 0
62
# PROP Use_Debug_Libraries 0
63
# PROP Output_Dir "..\..\..\..\lib"
64
# PROP Intermediate_Dir "Debug"
65
# PROP Target_Dir ""
66
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
67
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
68
# ADD BASE RSC /l 0x409 /d "NDEBUG"
69
# ADD RSC /l 0x409 /d "NDEBUG"
70
BSC32=bscmake.exe
71
# ADD BASE BSC32 /nologo
72
# ADD BSC32 /nologo
73
LIB32=link.exe -lib
74
# ADD BASE LIB32 /nologo
75
# ADD LIB32 /nologo
76
77
!ENDIF 
78
79
# Begin Target
80
81
# Name "resutils - Win32 Release"
82
# Name "resutils - Win32 Debug"
83
# Begin Group "Source Files"
84
85
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
86
# Begin Source File
87
88
SOURCE=..\resutils\clock.c
89
# End Source File
90
# Begin Source File
91
92
SOURCE=..\resutils\hashtable.c
93
# End Source File
94
# Begin Source File
95
96
SOURCE=..\resutils\library.c
97
# End Source File
98
# Begin Source File
99
100
SOURCE=..\resutils\mutex.c
101
# End Source File
102
# Begin Source File
103
104
SOURCE=..\resutils\random.c
105
# End Source File
106
# Begin Source File
107
108
SOURCE=..\resutils\streq.c
109
# End Source File
110
# Begin Source File
111
112
SOURCE=..\resutils\thread.c
113
# End Source File
114
# End Group
115
# Begin Group "Header Files"
116
117
# PROP Default_Filter "h;hpp;hxx;hm;inl"
118
# Begin Source File
119
120
SOURCE=..\resutils\DataCollectionInterface.h
121
# End Source File
122
# Begin Source File
123
124
SOURCE=..\resutils\DataTransferInterface.h
125
# End Source File
126
# Begin Source File
127
128
SOURCE=..\resutils\hashtable.h
129
# End Source File
130
# Begin Source File
131
132
SOURCE=..\resutils\system.h
133
# End Source File
134
# End Group
135
# End Target
136
# End Project
(-)src-native-new/src/agents/perfmon/resutils/resutils.make (+118 lines)
Added Link Here
1
2
################################################################################
3
#                                       
4
#  makefile:  resutils project  
5
#                                       
6
# $Id
7
################################################################################
8
9
10
#-----------------------------------
11
#
12
#   Customizable section
13
#
14
#   - The TARGETREALNAME variable specifies the name of the library file
15
#     that will be generated, this includes a base (TARGETLIB) plus	a 
16
#     version number plus a minor number plus a release number
17
#   - The TARGETSONAME variable specifies a file name that has just the
18
#     library name plus the major version number
19
#   - The TARGETLIB variable specifies the base library name
20
#   - The TARGETSONAME and TARGETLIB are generated as symbolic links
21
#     when the library is built
22
#
23
#-----------------------------------
24
TARGET         :=  libresutils
25
TARGETDIR      :=  ../../../../lib
26
27
TARGETLIB      :=  $(TARGET).a
28
29
30
#-----------------------------------
31
#   list of additional INCLUDE directories to search headers from
32
#      (separated by blanks)
33
#-----------------------------------
34
INCLUDEDIRS    :=  . ../resutils  ../../../../include
35
36
37
#-----------------------------------
38
#   list of additional libraries to be linked with
39
#      (separated by blanks)
40
#-----------------------------------
41
LIBS       :=  dl
42
43
#-----------------------------------
44
#   list of additional library directories to search from
45
#      (separated by blanks)
46
#-----------------------------------
47
LIBDIRS    :=  ../../../../lib
48
49
50
#-----------------------------------
51
#
52
#   Compiler options
53
#
54
#      -g       produce debug info
55
#      -Wall    enable all types of warnings
56
#      -O3      highest level of code optimization
57
#      -fPIC    generate position-independent code (PIC).
58
#               This is required for building shared library.
59
#      -c       compile only
60
#
61
#   Linking options
62
#
63
#       -Wl       pass options to linker
64
#       -shared   produce shared library
65
#       -L        add the given directory to the search path for libraries
66
#
67
#-----------------------------------
68
69
DEFINES    := -DLINUX
70
71
CFLAGS     :=  $(C_FLAGS) $(DEBUGABLE) -Wall $(OPTIMIZABLE) -fPIC $(addprefix -I,$(INCLUDEDIRS))  -D_LINUX_X86  $(DEFINES)
72
73
CXXFLAGS   :=  $(CFLAGS)
74
75
ARFLAGS		:=	-rs $(TARGETDIR)/$(TARGETLIB)
76
77
#-----------------------------------
78
#   general commands and options
79
#-----------------------------------
80
81
CC          :=  gcc
82
CXX         :=  $(CC)
83
AR			:=	ar
84
85
SOURCE     :=  $(wildcard *.c) $(wildcard *.cpp) $(wildcard ../resutils/*.c) $(wildcard ../resutils/*.cpp)
86
87
OBJS       :=  $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
88
89
REMOVEFILE :=  rm -f
90
CREATELINK :=  ln -sf
91
92
93
#-----------------------------------
94
#   "make" rules
95
#-----------------------------------
96
97
.PHONY : default everything objs clean veryclean rebuild $(TARGET)
98
99
100
default : $(TARGET)
101
102
103
objs : $(OBJS)
104
105
106
clean :
107
	$(REMOVEFILE) *.o
108
109
110
veryclean: clean
111
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETLIB)
112
113
114
rebuild: veryclean everything
115
116
117
$(TARGET) : $(OBJS)
118
	$(AR) $(ARFLAGS) $(OBJS)
(-)src-native-new/src/HCLauncher/hclaunch.def (+10 lines)
Added Link Here
1
LIBRARY hclaunch
2
DESCRIPTION
3
EXPORTS
4
	Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_startProcess0                    @1
5
	Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_killProcess0                     @2
6
	Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_writeToProcess0                  @3
7
	Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_readFromProcessOutput0           @4
8
	Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_readFromProcessError0            @5
9
	Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_getProcessStatus0                @6
10
	Java_org_eclipse_hyades_execution_core_impl_ExecutionEnvironmentImpl_getNativeSystemEnvironment0 @7
(-)src-native-new/src/agents/perfmon/sysperf/perfcalc.c (+784 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: perfcalc.c,v 1.6 2006/05/23 16:21:25 gchristelis Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
#include <windows.h>
14
#include "perfcalc.h"
15
#include <stdio.h>
16
#include <stdlib.h>
17
#include <math.h>
18
#include "hashtable.h"
19
#include "perfconstants.h"
20
21
static HashTable* XHasht;
22
static HashTable* YHasht;
23
static HashTable* BHasht;
24
25
static ACCURACY = 1;
26
27
double round(double num,int numplaces)
28
{
29
	num = num * pow(10,numplaces);
30
	num = (double)((int) (num / 1));
31
	num = num / pow(10,numplaces); 
32
	return num;
33
}
34
35
void createValueTables()
36
{
37
	XHasht = tableCreate();
38
	YHasht = tableCreate();
39
	BHasht = tableCreate();
40
}
41
42
void freeValueTables()
43
{
44
	tableDelete(XHasht);
45
	tableDelete(YHasht);
46
	tableDelete(BHasht);
47
}
48
49
void getPERF_100NSEC_MULTI_TIMER (char* output, char* key, PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr,PPERF_COUNTER_DEFINITION PerfCntr2 ,PPERF_DATA_BLOCK PerfData)
50
{
51
	XINT64 X1,Y1,X0,Y0,B1;
52
	double result;
53
	XDOUBLE tmp1, tmp2;
54
55
	// Get Previous Data
56
	X0 = (XINT64) tableGet(XHasht,key);
57
	Y0 = (XINT64) tableGet(YHasht,key);
58
59
	Y1 = PerfData->PerfTime100nSec.QuadPart;
60
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
61
	B1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr2->CounterOffset);
62
63
	tmp1 = (XDOUBLE)(X1 - X0);
64
	tmp2 = (XDOUBLE)(Y1 - Y0);
65
66
	result = 100*(tmp1/tmp2)/B1;
67
68
	result = round(result,ACCURACY);
69
70
	sprintf(output,"%f",result);
71
72
	tablePut(XHasht, key, (XINT64) X1);
73
	tablePut(YHasht, key, (XINT64) Y1);
74
}
75
76
void getPERF_100NSEC_MULTI_TIMER_INV (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2, PPERF_DATA_BLOCK PerfData)
77
{
78
	XINT64 X1,Y1,X0,Y0,B1;
79
	double result;
80
	XDOUBLE tmp1, tmp2;
81
82
	// Get Previous Data
83
	X0 = (XINT64) tableGet(XHasht,key);
84
	Y0 = (XINT64) tableGet(YHasht,key);
85
86
	Y1 = PerfData->PerfTime100nSec.QuadPart;
87
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
88
	B1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr2->CounterOffset);
89
90
	tmp1 = (XDOUBLE)(X1 - X0);
91
	tmp2 = (XDOUBLE)(Y1 - Y0);
92
93
	result = 100*(B1 - (tmp1/tmp2))/B1;
94
95
	result = round(result,ACCURACY);
96
97
	sprintf(output,"%f",result);
98
99
	tablePut(XHasht, key, (XINT64) X1);
100
	tablePut(YHasht, key, (XINT64) Y1);
101
}
102
103
void getPERF_100NSEC_TIMER (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData)
104
{
105
	
106
	XINT64 X1,Y1,X0,Y0;
107
	double result;
108
	XDOUBLE tmp1, tmp2;
109
110
	X0 = (XINT64) tableGet(XHasht,key);
111
	Y0 = (XINT64) tableGet(YHasht,key);
112
113
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
114
115
	Y1 = PerfData->PerfTime100nSec.QuadPart;
116
117
	tmp1 = (XDOUBLE)(X1-X0);
118
	tmp2 = (XDOUBLE)(Y1-Y0);
119
120
	result = (double) (100*(tmp1/tmp2));
121
122
	result = round(result,ACCURACY);
123
124
	sprintf(output,"%f",result);
125
126
	tablePut(XHasht,key,X1);
127
	tablePut(YHasht,key,Y1);
128
}
129
130
void getPERF_100NSEC_TIMER_INV (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData )
131
{
132
	XINT64 X1,Y1,X0,Y0;
133
	double result;
134
	XDOUBLE tmp1, tmp2;
135
136
	X0 = (XINT64) tableGet(XHasht,key);
137
	Y0 = (XINT64) tableGet(YHasht,key);
138
139
	Y1 = PerfData->PerfTime100nSec.QuadPart;
140
141
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
142
143
	tmp1 = (XDOUBLE)(X1-X0);
144
	tmp2 = (XDOUBLE)(Y1-Y0);
145
146
	result = (double) (100 * (1 - (tmp1/tmp2) ));
147
148
	result = round(result,ACCURACY);
149
150
	sprintf(output,"%f",result);
151
152
	tablePut(XHasht,key,X1);
153
	tablePut(YHasht,key,Y1);
154
}
155
156
void getPERF_AVERAGE_BULK (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2) 
157
{
158
	DWORD X1,B1,X0,B0;
159
	double result;
160
	XDOUBLE tmp1, tmp2;
161
162
	X0 = (DWORD) tableGet(XHasht,key);
163
	B0 = (DWORD) tableGet(BHasht,key);
164
	
165
	X1 = *(DWORD*)((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
166
167
	B1 = *(DWORD*) ((PBYTE)PtrToCntr + PerfCntr2->CounterOffset);
168
	
169
	tmp2 = (XDOUBLE) (B1 - B0);
170
	if (tmp2 == 0)
171
	{
172
		result = 0;
173
	}
174
	else
175
	{
176
		tmp1 = (XDOUBLE) (X1 - X0);
177
		result = (double)(tmp1/tmp2);
178
	}
179
180
	result = round(result,ACCURACY);
181
182
	sprintf(output,"%f",result);
183
184
	tablePut(XHasht,key,X1);
185
	tablePut(BHasht,key,B1);
186
}
187
188
void getPERF_AVERAGE_TIMER (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2,PPERF_DATA_BLOCK PerfData) 
189
{
190
	DWORD X1,B1,X0,B0;
191
	XINT64 TB;
192
	double result;
193
	XDOUBLE tmp1, tmp2;
194
	
195
	// Get Previous Data
196
	X0 = (DWORD) tableGet(XHasht,key);
197
	B0 = (DWORD) tableGet(BHasht,key);
198
199
	// Get PerfFreq...
200
	TB = PerfData->PerfFreq.QuadPart;
201
202
	X1 = *(DWORD*)((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
203
204
	B1 = *(DWORD*) ((PBYTE)PtrToCntr + PerfCntr2->CounterOffset);
205
	
206
	tmp2 = (XDOUBLE) (B1 - B0);
207
208
	if (tmp2 == 0)
209
	{
210
		result = 0;
211
	}
212
	else
213
	{
214
		tmp1 = (XDOUBLE) (X1-X0);
215
		result = (double)((tmp1/TB)/(tmp2));
216
	}
217
218
	result = round(result,ACCURACY);
219
220
	sprintf(output,"%f",result);
221
222
	tablePut(XHasht, key, (XINT64) X1);
223
	tablePut(BHasht, key, (XINT64) B1);
224
}
225
226
void getPERF_COUNTER_BULK_COUNT (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData) 
227
{
228
	XINT64 X1,X0,TB,Y1,Y0;
229
	double result;
230
	XDOUBLE tmp1, tmp2;
231
232
	X0 = (XINT64) tableGet(XHasht,key);
233
	Y0 = (XINT64) tableGet(YHasht,key);
234
235
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
236
	TB = PerfData->PerfFreq.QuadPart;
237
	Y1 = PerfData->PerfTime.QuadPart;
238
239
	tmp1 = (XDOUBLE) (X1 - X0);
240
	tmp2 = (XDOUBLE) (Y1 - Y0);
241
242
	result = (double) (tmp1/(tmp2/TB));
243
244
	sprintf(output,"%f",result);
245
246
	tablePut(XHasht,key,(XINT64) X1);
247
	tablePut(YHasht,key,(XINT64) Y1);
248
}
249
250
void getPERF_COUNTER_COUNTER (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData) 
251
{
252
	XINT64 TB, Y1,Y0;
253
	double result;
254
	DWORD X1, X0;
255
	XDOUBLE tmp1, tmp2;
256
257
	X0 = (DWORD)  tableGet(XHasht,key);
258
	Y0 = (XINT64) tableGet(YHasht,key);
259
260
	X1 = *(DWORD*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
261
	Y1 = PerfData->PerfTime.QuadPart;
262
	TB = PerfData->PerfFreq.QuadPart;
263
264
	tmp1 = (XDOUBLE)(X1-X0);
265
	tmp2 = (XDOUBLE)(Y1-Y0);
266
	
267
	result = (double) (tmp1/(tmp2/TB));
268
269
	result = round(result,ACCURACY);
270
271
	sprintf(output,"%f",result);
272
273
	tablePut(XHasht,key,(XINT64) X1);
274
	tablePut(YHasht,key,(XINT64) Y1);
275
}
276
277
void getPERF_COUNTER_DELTA (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr) 
278
{
279
	DWORD X1,X0;
280
	double result;
281
282
	// Get Previous Data
283
	X0 = (DWORD) tableGet(XHasht,key);
284
285
	X1 = *(DWORD*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
286
287
	result = (double) (X1-X0);
288
289
	result = round(result,ACCURACY);
290
291
	sprintf(output,"%f",result);
292
293
	tablePut(XHasht, key, (XINT64) X1);
294
}
295
296
void getPERF_COUNTER_LARGE_DELTA (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr) 
297
{
298
	XINT64 X1,X0;
299
	double result;
300
301
	// Get Previous Data
302
	X0 = (XINT64) tableGet(XHasht,key);
303
304
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
305
306
	result = (double) (X1-X0);
307
308
	result = round(result,ACCURACY);
309
310
	sprintf(output,"%f",result);
311
312
	tablePut(XHasht, key, (XINT64) X1);
313
}
314
315
void getPERF_COUNTER_LARGE_QUEUELEN_TYPE (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData)
316
{
317
	XINT64 X1,Y1;
318
	XDOUBLE tmp1, tmp2;
319
	XINT64 X0, Y0;
320
	double result;
321
322
	X0 = (XINT64) tableGet(XHasht,key);
323
	Y0 = (XINT64) tableGet(YHasht,key);
324
325
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
326
	Y1 = PerfData->PerfTime.QuadPart;
327
328
	tmp1 = (XDOUBLE)(X1 - X0);
329
	tmp2 = (XDOUBLE)(Y1 - Y0);
330
331
	result = (double) (tmp1/tmp2);
332
333
	result = round(result,ACCURACY);
334
335
	sprintf(output,"%f",result);
336
337
	tablePut(XHasht,key,X0);
338
	tablePut(YHasht,key,Y0);
339
}
340
341
void getPERF_COUNTER_LARGE_RAWCOUNT (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr)
342
{
343
	double result;
344
	XINT64 tmp;
345
346
	tmp = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
347
348
	result = (double) tmp;
349
350
	result = round(result,ACCURACY);
351
352
	sprintf(output,"%f",result);
353
}
354
355
void getPERF_COUNTER_LARGE_RAWCOUNT_HEX (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr) 
356
{
357
	double result;
358
	XINT64 tmp;
359
360
	tmp = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
361
362
	result = (double) tmp;
363
364
	result = round(result,ACCURACY);
365
366
	sprintf(output,"%f",result);
367
}
368
369
void getPERF_COUNTER_MULTI_TIMER (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_COUNTER_DEFINITION PerfCntr2, PPERF_DATA_BLOCK PerfData) 
370
{
371
	XINT64 X1,X0,Y1,Y0,TB,B1;
372
	XDOUBLE tmp1, tmp2;
373
	double result;
374
375
	// Get Previous Data
376
	X0 = (XINT64) tableGet(XHasht,key);
377
	Y0 = (XINT64) tableGet(YHasht,key);
378
	
379
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
380
	B1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr2->CounterOffset);
381
382
	Y1 = PerfData->PerfTime.QuadPart;
383
	TB = PerfData->PerfFreq.QuadPart;
384
385
	tmp1 = (XDOUBLE) (X1 - X0);
386
	tmp2 = (XDOUBLE) (Y1 - Y0);
387
388
	result = (double)(100*(tmp1/(tmp2/TB))/B1);
389
390
	result = round(result,ACCURACY);
391
392
	sprintf(output,"%I64Ld",result);
393
394
395
	tablePut(XHasht, key, X1);
396
	tablePut(YHasht, key, Y1);
397
}
398
399
void getPERF_COUNTER_MULTI_TIMER_INV (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr,PPERF_COUNTER_DEFINITION PerfCntr2, PPERF_DATA_BLOCK PerfData) 
400
{
401
	XINT64 X1,X0,Y1,Y0,TB,B1;
402
	XDOUBLE tmp1, tmp2;
403
	double result;
404
405
	// Get Previous Data
406
	X0 = (XINT64) tableGet(XHasht,key);
407
	Y0 = (XINT64) tableGet(YHasht,key);
408
	
409
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
410
	B1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr2->CounterOffset);
411
412
	Y1 = PerfData->PerfTime.QuadPart;
413
	TB = PerfData->PerfFreq.QuadPart;
414
415
	tmp1 = (XDOUBLE) (X1 - X0);
416
	tmp2 = (XDOUBLE) (Y1 - Y0);
417
418
	result = (double)(100*(1-(tmp1/(tmp2/TB)))/B1);
419
420
	result = round(result,ACCURACY);
421
422
	sprintf(output,"%I64Ld",result);
423
424
	tablePut(XHasht, key, X1);
425
	tablePut(YHasht, key, Y1);
426
}
427
428
429
void getPERF_COUNTER_NODATA (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr) 
430
{
431
	sprintf(output,"0");
432
}
433
434
435
void getPERF_COUNTER_QUEUELEN_TYPE (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData) 
436
{
437
	XINT64 Y1,X1,X0,Y0;
438
	double result;
439
	XDOUBLE tmp1, tmp2;
440
441
	// Get Previous Data
442
	X0 = (XINT64) tableGet(XHasht,key);
443
	Y0 = (XINT64) tableGet(YHasht,key);
444
		
445
	X1 = *(DWORD*)((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
446
	Y1 = PerfData->PerfTime.QuadPart;
447
448
	tmp1 = (XDOUBLE) (X1 - X0);
449
	tmp2 = (XDOUBLE) (Y1 - Y0);
450
451
	result = (double) (tmp1/tmp2);
452
453
	result = round(result,ACCURACY);
454
455
	sprintf(output,"%f",result);
456
457
	tablePut(XHasht, key, (XINT64) X1);
458
	tablePut(YHasht, key, (XINT64) Y1);
459
}
460
461
void getPERF_COUNTER_RAWCOUNT (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr) 
462
{
463
	double result;
464
	DWORD tmp;
465
466
	tmp = *(DWORD*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
467
468
	result = tmp;
469
470
	result = round(result,ACCURACY);
471
472
	sprintf(output,"%f",result);
473
}
474
475
476
void getPERF_COUNTER_RAWCOUNT_HEX (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr) 
477
{
478
	double result;
479
	DWORD tmp;
480
481
	tmp = *(DWORD*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
482
483
	result = tmp;
484
485
	result = round(result,ACCURACY);
486
487
	sprintf(output,"%f",result);
488
}
489
490
void getPERF_COUNTER_TEXT (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr) 
491
{
492
//	DWORD len;
493
//	wchar_t* result;
494
495
//	len = *(DWORD*)((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
496
	//TODO STILL
497
}
498
499
void getPERF_COUNTER_TIMER (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData) 
500
{
501
	XINT64 Y1, TB, X1,X0,Y0;
502
	double result;
503
	XDOUBLE tmp1,tmp2;
504
505
	// Get Previous Data
506
	X0 = (XINT64) tableGet(XHasht,key);
507
	Y0 = (XINT64) tableGet(YHasht,key);
508
509
	X1 = *(DWORD*)((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
510
	Y1 = PerfData->PerfTime.QuadPart;
511
	TB = PerfData->PerfFreq.QuadPart;
512
513
	tmp1 = (XDOUBLE) (X1 - X0);
514
	tmp2 = (XDOUBLE) (Y1 - Y0);
515
516
	result = (double) (100*(tmp1/tmp2));
517
518
	result = round(result,ACCURACY);
519
520
	sprintf(output,"%f",result);
521
522
	tablePut(XHasht, key, X1);
523
	tablePut(YHasht, key, Y1);
524
}
525
526
void getPERF_COUNTER_TIMER_INV (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData) 
527
{
528
	XINT64 Y1, TB, X1,X0,Y0;
529
	double result;
530
	XDOUBLE tmp1,tmp2;
531
532
	// Get Previous Data
533
	X0 = (XINT64) tableGet(XHasht,key);
534
	Y0 = (XINT64) tableGet(YHasht,key);
535
536
	X1 = *(DWORD*)((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
537
	Y1 = PerfData->PerfTime.QuadPart;
538
	TB = PerfData->PerfFreq.QuadPart;
539
540
	tmp1 = (XDOUBLE) (X1 - X0);
541
	tmp2 = (XDOUBLE) (Y1 - Y0);
542
543
	result = (double) (100*(1-(tmp1/tmp2)));
544
545
	result = round(result,ACCURACY);
546
547
	sprintf(output,"%f",result);
548
549
	tablePut(XHasht, key, X1);
550
	tablePut(YHasht, key, Y1);
551
}
552
553
void getPERF_ELAPSED_TIME (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr, PPERF_DATA_BLOCK PerfData, PPERF_OBJECT_TYPE PerfObj) 
554
{
555
	XINT64 X1, Y1, TB;
556
	double result;
557
558
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
559
560
	Y1 = PerfObj->PerfTime.QuadPart;
561
562
	TB = PerfObj->PerfFreq.QuadPart;
563
564
	result = (double) ((XDOUBLE)(Y1-X1))/((XDOUBLE) TB);
565
566
	result = round(result,ACCURACY);
567
568
	sprintf(output,"%f",result);
569
}
570
571
void getPERF_RAW_FRACTION (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr,PPERF_COUNTER_DEFINITION PerfCntr2)
572
{
573
	DWORD X1, B1;
574
	double result;
575
576
	X1 = *(DWORD*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
577
578
	B1 = *(DWORD*) ((PBYTE)PtrToCntr + PerfCntr2->CounterOffset);
579
580
	if (B1 > 0)
581
	{
582
		result = 100*(((double) X1) / ((double) B1));
583
	
584
		result = round(result,ACCURACY);
585
586
		sprintf(output,"%f%c",result,'\0');		
587
	}
588
}
589
590
void getPERF_SAMPLE_COUNTER (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr,PPERF_COUNTER_DEFINITION PerfCntr2) 
591
{
592
	DWORD X1, B1, X0, B0;
593
	XDOUBLE tmp1, tmp2;
594
	double result;
595
596
	X0 = (DWORD) tableGet(XHasht,key);
597
	B0 = (DWORD) tableGet(BHasht,key);
598
599
	X1 = *(DWORD*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
600
601
	B1 = *(DWORD*) ((PBYTE)PtrToCntr + PerfCntr2->CounterOffset);
602
603
	tmp2 = (XDOUBLE)(B1 - B0);
604
605
	if ((B1 > 0) && (tmp2 !=0))
606
	{
607
		tmp1 = (XDOUBLE)(X1 - X0);
608
		result = (double)(tmp1/tmp2);
609
	}
610
	else
611
	{
612
		result = 0;
613
	}
614
615
	result = round(result,ACCURACY);
616
	sprintf(output,"%f",result);		
617
618
	tablePut(XHasht,key,(XINT64) X1);
619
	tablePut(BHasht,key,(XINT64) B1);
620
}
621
622
void getPERF_SAMPLE_FRACTION (char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr,PPERF_COUNTER_DEFINITION PerfCntr2) 
623
{
624
	DWORD X1, B1, X0, B0;
625
	XDOUBLE tmp1, tmp2;
626
	double result;
627
628
	X0 = (DWORD) tableGet(XHasht,key);
629
	B0 = (DWORD) tableGet(BHasht,key);
630
631
	X1 = *(DWORD*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
632
633
	B1 = *(DWORD*) ((PBYTE)PtrToCntr + PerfCntr2->CounterOffset);
634
635
	tmp2 = (XDOUBLE)(B1 - B0);
636
	if ((B1 > 0) && (tmp2 !=0))
637
	{
638
		tmp1 = (XDOUBLE)(X1 - X0);
639
		result = (double)(100*tmp1/tmp2);
640
	}
641
	else
642
	{
643
		result = 0;
644
	}
645
646
	result = round(result,ACCURACY);
647
648
	sprintf(output,"%f",result);		
649
650
	tablePut(XHasht,key,(XINT64) X1);
651
	tablePut(BHasht,key,(XINT64) B1);
652
}
653
654
void getPERF_OBJ_TIME_TIMER(char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr,PPERF_DATA_BLOCK PerfData)
655
{
656
	double result;
657
	XDOUBLE tmp1, tmp2;
658
	XINT64 X1, X0, Y1, Y0;
659
660
	X0 = (XINT64) tableGet(XHasht,key);
661
	Y0 = (XINT64) tableGet(YHasht,key);
662
663
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
664
	Y1 = PerfData->PerfTime.QuadPart;
665
666
	tmp1 = (XDOUBLE) (X1 - X0);
667
	tmp2 = (XDOUBLE) (Y1 - Y0);
668
669
	result = (double) (tmp1/tmp2);
670
671
	result = round(result,ACCURACY);
672
673
	sprintf(output,"%f",result);		
674
675
	tablePut(XHasht,key,(XINT64) X1);
676
	tablePut(YHasht,key,(XINT64) Y1);
677
}
678
679
void getPERF_PRECISION_100NS_TIMER(char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr,PPERF_COUNTER_DEFINITION PerfCntr2,PPERF_DATA_BLOCK PerfData)
680
{
681
	double result;
682
	XDOUBLE tmp1, tmp2;
683
	XINT64 X1, X0, Y1, Y0;
684
685
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
686
	// Precision stored time in next counter
687
	Y1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr2->CounterOffset);
688
689
	X0 = (XINT64) tableGet(XHasht,key);
690
	Y0 = (XINT64) tableGet(YHasht,key);
691
692
	tmp1 = (XDOUBLE) (X1 - X0);
693
	tmp2 = (XDOUBLE) (Y1 - Y0);
694
695
	result = (double) (100*tmp1/tmp2);
696
697
	result = round(result,ACCURACY);
698
699
	sprintf(output,"%f",result);		
700
701
	tablePut(XHasht,key,(XINT64) X1);
702
	tablePut(YHasht,key,(XINT64) Y1);
703
}
704
705
// THIS IN PARTICULAR HAS NOT BEEN TESTED - I AM NOT 100% SURE YET.
706
void getPERF_PRECISION_OBJECT_TIMER(char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr,PPERF_COUNTER_DEFINITION PerfCntr2, PPERF_COUNTER_DEFINITION PerfCntr,PPERF_DATA_BLOCK PerfData)
707
{
708
	double result;
709
	XDOUBLE tmp1, tmp2;
710
	XINT64 X1, X0, Y1, Y0, TB;
711
	TB = 1;
712
713
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
714
	Y1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr2->CounterOffset);
715
	TB = PerfData->PerfFreq.QuadPart;
716
717
	X0 = (XINT64) tableGet(XHasht,key);
718
	Y0 = (XINT64) tableGet(YHasht,key);
719
720
	tmp1 = (XDOUBLE) (X1 - X0);
721
	tmp2 = (XDOUBLE) (Y1 - Y0);
722
723
	result = (double) ((TB*tmp1)/tmp2);
724
725
	result = round(result,ACCURACY);
726
727
	sprintf(output,"%f",result);		
728
729
	tablePut(XHasht,key,(XINT64) X1);
730
	tablePut(YHasht,key,(XINT64) Y1);
731
}
732
733
void getPERF_PRECISION_SYSTEM_TIMER(char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr,PPERF_COUNTER_DEFINITION PerfCntr2, PPERF_COUNTER_DEFINITION PerfCntr,PPERF_DATA_BLOCK PerfData)
734
{
735
	double result;
736
	XDOUBLE tmp1, tmp2;
737
	XINT64 X1, X0, Y1, Y0;
738
739
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
740
	Y1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr2->CounterOffset);
741
	
742
	X0 = (XINT64) tableGet(XHasht,key);
743
	Y0 = (XINT64) tableGet(YHasht,key);
744
745
	tmp1 = (XDOUBLE) (X1 - X0);
746
	tmp2 = (XDOUBLE) (Y1 - Y0);
747
748
	result = (double) (100*tmp1/tmp2);
749
750
	result = round(result,ACCURACY);
751
752
	sprintf(output,"%f",result);		
753
754
	tablePut(XHasht,key,(XINT64) X1);
755
	tablePut(YHasht,key,(XINT64) Y1);
756
}
757
758
void getPERF_COUNTER_100NS_QUEUELEN_TYPE(char* output, char* key,PPERF_COUNTER_BLOCK PtrToCntr, PPERF_COUNTER_DEFINITION PerfCntr,PPERF_DATA_BLOCK PerfData)
759
{
760
	double result;
761
	XDOUBLE tmp1, tmp2;
762
	XINT64 X1, X0, Y1, Y0;
763
764
	X1 = *(XINT64*) ((PBYTE)PtrToCntr + PerfCntr->CounterOffset);
765
	Y1 = PerfData->PerfTime100nSec.QuadPart;
766
767
	X0 = (XINT64) tableGet(XHasht,key);
768
	Y0 = (XINT64) tableGet(YHasht,key);
769
770
	tmp1 = (XDOUBLE) (X1 - X0);
771
	tmp2 = (XDOUBLE) (Y1 - Y0);
772
	
773
	// The MSDN Docs say this should be tmp2/tmp1 but the results that generates are not at all plausible...
774
	// These results also match perfmon.
775
776
	result = (double) (tmp1/tmp2);
777
778
	result = round(result,ACCURACY);
779
780
	sprintf(output,"%f",result);		
781
782
	tablePut(XHasht,key,(XINT64) X1);
783
	tablePut(YHasht,key,(XINT64) Y1);
784
}
(-)src-native-new/src/agents/perfmon/resutils/thread.c (+285 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: thread.c,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
/***********************************************************************
14
 *
15
 * File: Threads.c
16
 * Overview: The following code provides a wrapper to the Win32 
17
 *                                API routines for threads.Here we have Thread 
18
 *                                struct, defined in thread.h, allocated and partially
19
 *                                initialised by the caller.
20
 ***********************************************************************/
21
22
#include "system.h"
23
24
#ifdef PTHREAD_INIT_NEEDED
25
void pthread_init(void);
26
#endif
27
28
#ifdef WIN32
29
static unsigned WINAPI ThreadWrapper(void *);
30
#endif
31
#if defined(LINUX) | defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
32
static void *ThreadWrapper(void *);
33
#endif
34
35
/***********************************************************************
36
 * Function: XThreadStartup
37
 * Purpose: This function calls any necessary thread startup procedures 
38
 * Parameters: none
39
 * Returns: int SUCCESS
40
 ***********************************************************************/
41
42
int XThreadStartup()
43
{
44
#ifdef PTHREAD_INIT_NEEDED 
45
  pthread_init();
46
#endif
47
  return SUCCESS;
48
}
49
50
int XThreadMakeAbortable()
51
{
52
#if defined(LINUX) | defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
53
  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
54
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
55
#endif
56
  return SUCCESS;
57
}
58
59
/***********************************************************************
60
 * Function: XThreadCreate
61
 * Purpose: This function creates a thread running the routine
62
 *                               provided as an argument.
63
 * Parameters: ThreadRoutine *, a pointer to a thread start routine;
64
 *                                        void *, a pointer to an argument to the routine and
65
 *                                        Thread *, a pointer to a Thread struct.
66
 * Returns: int, THREAD_SUCCESS if successful creation,
67
 *                              THREAD_FAILURE otherwise.
68
 ***********************************************************************/
69
/* Here ThreadRoutine is of type THREAD_START_ROUTINE 
70
 * e.g. DWORD WINAPI ThreadStartFunc(LPVOID lpThreadParameter). */
71
72
int XThreadCreate(XThreadFunction *function, void *argument, XThread *thread)
73
{
74
#ifdef WIN32
75
  thread->function = function;
76
  thread->argument = argument;
77
78
  /* 
79
   * use this if the threads make c runtime library calls 
80
   */
81
82
  thread->handle = (HANDLE)_beginthreadex(NULL,  XTHREAD_STACKSZ, ThreadWrapper, (void *)thread, 0, &(thread->id));
83
84
  /* use this if the threads only make call to Win 32 API 
85
   * thread->handle = CreateThread(NULL, 0, function, argument, thread->flags, &(thread->id)); 
86
   */
87
88
  if (! thread->handle)
89
  {
90
    return XTHREAD_ERROR_CREATE;
91
  }
92
#endif
93
#if defined(LINUX) | defined(SOLARIS) || defined(USS) || defined(HPUX) || defined(AIX) || defined(LINUX_S390) || defined(SOLARIS_I386) 
94
//  thread->function = function;
95
//  thread->argument = argument;
96
//
97
//  if (pthread_create(&thread->pthread, NULL, ThreadWrapper, (void *)thread) != 0)
98
//  {
99
//    return FAILURE;
100
//  }
101
//#endif
102
//#if defined(AIX)
103
  pthread_attr_t attr;
104
  pthread_attr_init(&attr);
105
#if defined(LINUX) | defined(SOLARIS) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
106
  pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_JOINABLE);
107
#endif  
108
#if defined(AIX)
109
  pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_UNDETACHED);
110
#endif
111
112
  thread->function = function;
113
  thread->argument = argument;
114
115
  if (pthread_create(&thread->pthread, &attr, ThreadWrapper, (void *)thread) != 0)
116
  {
117
    pthread_attr_destroy(&attr);
118
    return FAILURE;
119
  }
120
121
  pthread_attr_destroy(&attr);
122
#endif
123
124
  return SUCCESS;
125
}
126
127
/***********************************************************************
128
 * Function: XThreadExit
129
 * Purpose: The routine causes a thread to exit normally. The 
130
 *                               thread will not terminate until all references to the 
131
 *                               kernel thread object are closed.
132
 * Parameters: unsigned int (=UINT), the exit code for the thread.
133
 * Returns: void, this function does not return.
134
 ***********************************************************************/
135
void XThreadExit(unsigned int code)
136
{
137
#ifdef WIN32
138
  /* has same effect as returning from entry procedure, both call ExitThread(). */
139
  _endthreadex(code);
140
  /*
141
    ExitThread(code); */
142
#endif
143
#if defined(LINUX) | defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
144
  pthread_exit((void*)&code);
145
#endif
146
}
147
148
/***********************************************************************
149
 * Function: XThreadWait
150
 * Purpose:  The routine causes the calling thread to block until
151
 *                                the specified thread has terminated. The terminated
152
 *                                thread's Thread struct is invalidated.
153
 * Parameters: Thread *, pointer to Thread struct; unisigned int *
154
 *                                        (=LPDWORD), pointer to exit code of thread.
155
 * Returns: int, THREAD_SUCCESS if specified thread terminates 
156
 *                              with correct exit code, THREAD_FAILURE otherwise.
157
 ***********************************************************************/
158
/* Thread kernel objects are signalled on termination */
159
/* is LPDWORD the same as unsigned int* ??? */
160
int XThreadWait(XThread *thread, unsigned int *code)
161
{
162
#ifdef WIN32
163
  BOOL terminated;
164
  DWORD result;
165
166
  result = WaitForSingleObject(thread->handle, INFINITE); /* unbounded wait */
167
  
168
  if (result == WAIT_OBJECT_0)      /* signalled (=thread terminated) */
169
  {        
170
    terminated = GetExitCodeThread(thread->handle, code); /* find out the exit code of thread */
171
    /* terminated = TRUE as signalled implies */
172
    (void) CloseHandle(thread->handle);
173
    ZeroMemory(thread, sizeof(XThread)); /* invalidate Thread struct */
174
  }
175
  else
176
  {
177
    return XTHREAD_ERROR_WAIT;
178
  }
179
#endif
180
#if defined(LINUX) | defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
181
  int okay;
182
183
  if ((okay = pthread_join(thread->pthread, (void **)&code)) != 0)
184
  {
185
    return FAILURE;
186
  }
187
#endif
188
                
189
  return SUCCESS;
190
}
191
192
/***********************************************************************
193
 * Function: XThreadAbort
194
 * Purpose: Forcefully terminates a specified thread. The thread's
195
 *                               Thread struct is invalidated.
196
 * Parameters: Thread *, pointer to Thread struct.
197
 * Returns: int, THREAD_SUCCESS if successful termination,
198
 *                              THREAD_FAILURE otherwise.
199
 ***********************************************************************/
200
int XThreadAbort(XThread *thread)
201
{
202
#ifdef WIN32
203
  BOOL terminated;
204
  DWORD exitcode = 0;
205
206
  terminated = TerminateThread(thread->handle, exitcode);
207
  
208
  if (terminated)
209
  {
210
    (void) CloseHandle(thread->handle);
211
    ZeroMemory(thread, sizeof(XThread)); /* invalidate Thread struct */
212
  }
213
  else
214
  {
215
    return XTHREAD_ERROR_ABORT;
216
  }
217
#endif
218
#if defined(LINUX) | defined(SOLARIS) || defined(USS) || defined(HPUX) || defined(AIX) || defined(LINUX_S390) || defined(SOLARIS_I386)
219
220
  if (pthread_cancel(thread->pthread) != 0)
221
  {
222
    return FAILURE;
223
  }
224
225
#endif
226
227
  return SUCCESS;
228
}
229
230
/***********************************************************************
231
 * Function: XThreadGetIdentifier
232
 * Purpose: gets the thread identifier of the calling thread
233
 * Parameters: 
234
 * Returns: int, PROCESS_SUCCESS if set is successful,
235
 *                              PROCESS_FAILURE otherwise.
236
 ***********************************************************************/
237
int XThreadGetIdentifier(int *tid)
238
{
239
#ifdef WIN32
240
  *tid = GetCurrentThreadId();
241
#endif
242
#if defined(LINUX) | defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
243
  *tid = (int)getpid();
244
#endif
245
246
  return SUCCESS;
247
}
248
249
#ifdef WIN32
250
/***********************************************************************
251
 * Function: ThreadWrapper
252
 * Purpose: wrapper around our thread function to abstract windows
253
 *          _beginthreadex/_endthreadex threads - yuk yuk yuk ;-)
254
 * Parameters: void *argument which is (void *) cast of the thread
255
 * Returns: unsigned WINAPI SUCCESS if it returns at all ...
256
 ***********************************************************************/
257
258
static unsigned WINAPI ThreadWrapper(void *argument)
259
{
260
  ((XThread *)argument)->function(((XThread *)argument)->argument);
261
        
262
  _endthreadex(EXIT_SUCCESS);
263
  return EXIT_SUCCESS;
264
}
265
#endif
266
#if defined(LINUX) || defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
267
/***********************************************************************
268
 * Function: ThreadWrapper
269
 * Purpose: wrapper around our thread function to abstract specifics
270
 * Parameters: void *argument which is (void *) cast of the thread
271
 * Returns: (void *)NULL, if at all ...
272
 ***********************************************************************/
273
274
static void *ThreadWrapper(void *argument)
275
{
276
  (*((XThread *)argument)->function)(((XThread *)argument)->argument);
277
  
278
  return NULL;
279
}
280
#endif
281
282
/***********************************************************************
283
 * EOF
284
 ***********************************************************************/
285
(-)src-native-new/src/agents/perfmon/perflin/perflin.h (+198 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 Scapa Technologies Limited and others
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
14
#ifndef __PERFLIN__H__
15
#define __PERFLIN__H__
16
17
#include "system.h"
18
#include "hashtable.h"
19
#include "DataCollectionInterface.h"
20
#include <sys/sysinfo.h>
21
22
#define STAT_CPU "10000"
23
#define STAT_CPU1 "C10001"
24
#define STAT_CPU2 "C10002"
25
#define STAT_CPU3 "C10003"
26
#define STAT_CPU4 "C10004"
27
#define STAT_CPU5 "C12305"
28
#define STAT_CPU6 "C12306"
29
#define STAT_CPU7 "C12307"
30
#define STAT_OTHER "10005"
31
#define STAT_SWAP1 "C10006"
32
#define STAT_SWAP2 "C10007"
33
#define STAT_PAGE1 "C10008"
34
#define STAT_PAGE2 "C10009"
35
#define STAT_INTR "C10010"
36
#define STAT_CTXT "C10011"
37
#define STAT_BTIME "C10012"
38
#define STAT_PROC "C10013"
39
#define STAT_TOTAL "10014"
40
#define STAT_CPU_TOTAL "10015"
41
#define STAT_CPU1_TOTAL "C10016"
42
#define STAT_CPU2_TOTAL "C10017"
43
#define STAT_CPU3_TOTAL "C10018"
44
#define STAT_CPU4_TOTAL "C10019"
45
#define STAT_CPU5_TOTAL "C12320"
46
#define STAT_CPU6_TOTAL "C12321"
47
#define STAT_CPU7_TOTAL "C12322"
48
#define STAT_CPU0_TOTAL "C11020"
49
#define STAT_CPU0 "C11021"
50
#define STAT_TOTAL_PROC "C11022"
51
52
#define STAT_PARENT "10020"
53
#define STAT_DISK "10021"
54
#define STAT_NOINFO "C10022"
55
#define STAT_READ_IO "C10023"
56
#define STAT_READ_BLKS "C10024"
57
#define STAT_WRITE_IO "C10025"
58
#define STAT_WRITE_BLKS "C10026"
59
60
#define MEM_PARENT "10130"
61
#define MEM_TOTAL "C10030"
62
#define MEM_FREE "C10031"
63
#define MEM_USED "C10032"
64
#define	MEM_BUFFERS "C10033"
65
#define	MEM_CACHED "C10034"
66
#define	MEM_SWAPT "C10035"
67
#define MEM_SWAPF "C10036"
68
#define MEM_SWAPU "C10037"
69
#define MEM_PERC "C10038"
70
#define MEM_SPERC "C10039"
71
72
#define PROC_MAIN "10050"
73
#define PROC_PARENT "10040"
74
#define PROC_CPU "10041"
75
#define PROC_CPU_BOTH "C10042"
76
#define PROC_CPU_TIME "C10043"
77
#define PROC_CPU_UTIME "C10044"
78
#define PROC_CPU_STIME "C10045"
79
#define PROC_CPU_CTIME "C10046"
80
#define PROC_CPU_CUTIME "C10047"
81
#define PROC_CPU_CSTIME "C10048"
82
#define PROC_VSIZE "C10049"
83
84
#define PROC_OTHER "10055"
85
#define PROC_OTHER_PID "C10056"
86
#define PROC_OTHER_PPID "C10057"
87
#define PROC_OTHER_PROCESSOR "C10058"
88
89
#define PROC_MEM "10059"
90
#define PROC_MEM_RSS "C10060"
91
#define PROC_MEM_NSWAP "C10061"
92
#define PROC_MEM_CNSWAP "C10062"
93
#define PROC_MEM_SIZE "C10063"
94
#define	PROC_MEM_RESIDENT "C10064"
95
#define	PROC_MEM_SHARE "C10065"
96
#define	PROC_MEM_TRS "C10066"
97
#define	PROC_MEM_DRS "C10067"
98
#define	PROC_MEM_LRS "C10068"
99
#define PROC_MEM_DT "C10069"
100
#define PROC_MEM_SWAP "C10070"
101
#define PROC_MEM_CMINFLT "C10071"
102
#define PROC_MEM_MINFLT "C10072"
103
#define PROC_MEM_MAJFLT "C10073"
104
#define PROC_MEM_CMAJFLT "C10074"
105
#define PROC_MEM_PERC "C10075"
106
107
#define NET_INTERFACE "10080"
108
#define NET_RBYTES "C10081"
109
#define NET_RPACKETS "C10082"
110
#define NET_RERRS "C10083"
111
#define NET_RDROP "C10084"
112
#define NET_RFIFO "C10085"
113
#define NET_RFRAME "C10086"
114
#define NET_RCOMPRESSED "C10087"
115
#define NET_RMULTICAST "C10088"
116
#define NET_TBYTES "C10089"
117
#define NET_TPACKETS "C10090"
118
#define NET_TERRS "C10091"
119
#define NET_TDROP "C10092"
120
#define NET_TFIFO "C10093"
121
#define NET_TCOLLISIONS "C10094"
122
#define NET_TCARRIER "C10095"
123
#define NET_TCOMPRESSED "C10096"
124
125
#define PART_PARENT "10100"
126
#define PART_PART "10101"
127
#define PART_PERCU "C10102" 
128
#define PART_PERCF "C10103" 
129
#define PART_TOTAL_SIZE "C10104" 
130
#define PART_FREE_SIZE "C10105"
131
#define PART_AVAIL_SIZE "C10106" 
132
#define PART_USED_SIZE "C10107" 
133
#define PART_TOTAL_BLKS "C10108" 
134
#define PART_FREE_BLKS "C10109" 
135
#define PART_AVAIL_BLKS "C10110" 
136
#define PART_USED_BLKS "C10111" 
137
#define PART_OPTIMAL "C10112" 
138
#define PART_TOTAL_NODES "C10113" 
139
#define PART_TOTAL_FREE "C10114" 
140
#define PART_TOTAL_USED "C10115" 
141
#define PART_TOTAL_MAXLEN "C10116" 
142
143
#define SWAP_PARENT "10150"
144
#define SWAP_PART "10151"
145
#define SWAP_TOTAL "C10152"
146
#define SWAP_USED "C10153"
147
#define SWAP_FREE "C10154"
148
#define SWAP_PUSED "C10155"
149
#define SWAP_PFREE "C10156"
150
151
#define NEW_DISK_PARENT "20000"
152
#define NEW_DISK_READNO "C20001"
153
#define NEW_DISK_READMERGE "C20002"
154
#define NEW_DISK_READSECTORS "C20003"
155
#define NEW_DISK_READMILLI "C20004"
156
#define NEW_DISK_WRITENO "C20005"
157
#define NEW_DISK_WRITEMERGE "C20006"
158
#define NEW_DISK_WRITESECTORS "C20007"
159
#define NEW_DISK_WRITEMILLI "C20008"
160
#define NEW_DISK_IOCOUNT "C20009"
161
#define NEW_DISK_IOMILLI "C20010"
162
#define NEW_DISK_WEIGHTED "C20011"
163
164
#define LWP_MAIN "30000"
165
166
#define NDEBUG !DEBUG
167
168
#define BUFFSIZE 1024
169
170
#ifndef NUM_SNAPSHOTS
171
	#define NUM_SNAPSHOTS 2
172
#endif
173
174
// General Stat Methods
175
void getStatInfo(char* pid);
176
void getStatResults();
177
178
// Memory Information Methods
179
void getMemInfoResults();
180
void getMemInfoTree(char* parentid);
181
182
// Process Information Methods
183
void getProcessesResults();
184
void getProcessesTree(char* parentid);
185
void addProcessMemResults(char* pid,long size,long resident,long share,long trs,long drs,long lrs,long dr);
186
void addProcessMemTree(char* parentid);
187
188
// Network Information Method
189
void getNetInfoTree(char* parentid);
190
void getNetInfoResults();
191
192
void getMountTree(char* parentid);
193
void getMountResults();
194
195
void getSwapTree(char* parentid);
196
void getSwapResults();
197
198
#endif
(-)src-native-new/src/HCLauncher/WinBuild/HCLauncher.mak64 (+444 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on HCLauncher.dsp
2
!IF "$(CFG)" == ""
3
CFG=HCLaunch - IA64 Debug
4
!MESSAGE No configuration specified. Defaulting to HCLaunch - IA64 Debug.
5
!ENDIF 
6
7
!IF "$(CFG)" != "HCLaunch - IA64 Release" && "$(CFG)" != "HCLaunch - IA64 Debug" && "$(CFG)" != "HCLaunch - X64 Release" && "$(CFG)" != "HCLaunch - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "HCLauncher.mak64" CFG="HCLaunch - IA64 Debug"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "HCLaunch - IA64 Release"
17
!MESSAGE "HCLaunch - IA64 Debug"
18
!MESSAGE "HCLaunch - X64 Release"
19
!MESSAGE "HCLaunch - X64 Debug"
20
!MESSAGE 
21
!ERROR An invalid configuration is specified.
22
!ENDIF 
23
24
!IF "$(OS)" == "Windows_NT"
25
NULL=
26
!ELSE 
27
NULL=nul
28
!ENDIF 
29
30
!IF  "$(CFG)" == "HCLaunch - IA64 Release"
31
32
OUTDIR=..\..\..\bin
33
INTDIR=.\Release
34
# Begin Custom Macros
35
OutDir=..\..\..\bin
36
# End Custom Macros
37
38
ALL : "$(OUTDIR)\hclaunch.dll"
39
40
41
CLEAN :
42
	-@erase "$(INTDIR)\hclaunch.obj"
43
	-@erase "$(INTDIR)\hclaunch.res"
44
	-@erase "$(INTDIR)\java.obj"
45
	-@erase "$(INTDIR)\launcher_common.obj"
46
	-@erase "$(INTDIR)\launcher_md.obj"
47
	-@erase "$(INTDIR)\launcher_os400.obj"
48
	-@erase "$(INTDIR)\RAComm.obj"
49
	-@erase "$(INTDIR)\vc60.idb"
50
	-@erase "$(OUTDIR)\hclaunch.dll"
51
	-@erase "$(OUTDIR)\..\lib\hclaunch.exp"
52
	-@erase "$(OUTDIR)\..\lib\hclaunch.lib"
53
54
"$(OUTDIR)" :
55
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
56
57
"$(INTDIR)" :
58
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
59
60
CPP=cl.exe
61
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /I "..\..\transport\RACommon" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCLaunch_EXPORTS" /Fp"$(INTDIR)\HCLauncher.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
62
63
.c{$(INTDIR)}.obj::
64
   $(CPP) @<<
65
   $(CPP_PROJ) $< 
66
<<
67
68
.cpp{$(INTDIR)}.obj::
69
   $(CPP) @<<
70
   $(CPP_PROJ) $< 
71
<<
72
73
.cxx{$(INTDIR)}.obj::
74
   $(CPP) @<<
75
   $(CPP_PROJ) $< 
76
<<
77
78
.c{$(INTDIR)}.sbr::
79
   $(CPP) @<<
80
   $(CPP_PROJ) $< 
81
<<
82
83
.cpp{$(INTDIR)}.sbr::
84
   $(CPP) @<<
85
   $(CPP_PROJ) $< 
86
<<
87
88
.cxx{$(INTDIR)}.sbr::
89
   $(CPP) @<<
90
   $(CPP_PROJ) $< 
91
<<
92
93
MTL=midl.exe
94
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
95
RSC=rc.exe
96
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hclaunch.res" /d "NDEBUG" 
97
BSC32=bscmake.exe
98
BSC32_FLAGS=/nologo /o"$(OUTDIR)\HCLauncher.bsc" 
99
BSC32_SBRS= \
100
	
101
LINK32=link.exe
102
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib rpcrt4.lib bufferoverflowU.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\hclaunch.pdb" /machine:IA64 /out:"$(OUTDIR)\hclaunch.dll" /implib:"$(OUTDIR)\..\lib\hclaunch.lib" 
103
LINK32_OBJS= \
104
	"$(INTDIR)\hclaunch.obj" \
105
	"$(INTDIR)\launcher_common.obj" \
106
	"$(INTDIR)\launcher_md.obj" \
107
	"$(INTDIR)\launcher_os400.obj" \
108
	"$(INTDIR)\hclaunch.res" \
109
	"$(INTDIR)\java.obj" \
110
	"$(INTDIR)\RAComm.obj"
111
112
"$(OUTDIR)\hclaunch.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
113
    $(LINK32) @<<
114
  $(LINK32_FLAGS) $(LINK32_OBJS)
115
<<
116
117
!ELSEIF  "$(CFG)" == "HCLaunch - X64 Release"
118
119
OUTDIR=..\..\..\bin
120
INTDIR=.\Release
121
# Begin Custom Macros
122
OutDir=..\..\..\bin
123
# End Custom Macros
124
125
ALL : "$(OUTDIR)\hclaunch.dll"
126
127
128
CLEAN :
129
	-@erase "$(INTDIR)\hclaunch.obj"
130
	-@erase "$(INTDIR)\hclaunch.res"
131
	-@erase "$(INTDIR)\java.obj"
132
	-@erase "$(INTDIR)\launcher_common.obj"
133
	-@erase "$(INTDIR)\launcher_md.obj"
134
	-@erase "$(INTDIR)\launcher_os400.obj"
135
	-@erase "$(INTDIR)\RAComm.obj"
136
	-@erase "$(INTDIR)\vc60.idb"
137
	-@erase "$(OUTDIR)\hclaunch.dll"
138
	-@erase "$(OUTDIR)\..\lib\hclaunch.exp"
139
	-@erase "$(OUTDIR)\..\lib\hclaunch.lib"
140
141
"$(OUTDIR)" :
142
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
143
144
"$(INTDIR)" :
145
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
146
147
CPP=cl.exe
148
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /I "..\..\transport\RACommon" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCLaunch_EXPORTS" /Fp"$(INTDIR)\HCLauncher.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
149
150
.c{$(INTDIR)}.obj::
151
   $(CPP) @<<
152
   $(CPP_PROJ) $< 
153
<<
154
155
.cpp{$(INTDIR)}.obj::
156
   $(CPP) @<<
157
   $(CPP_PROJ) $< 
158
<<
159
160
.cxx{$(INTDIR)}.obj::
161
   $(CPP) @<<
162
   $(CPP_PROJ) $< 
163
<<
164
165
.c{$(INTDIR)}.sbr::
166
   $(CPP) @<<
167
   $(CPP_PROJ) $< 
168
<<
169
170
.cpp{$(INTDIR)}.sbr::
171
   $(CPP) @<<
172
   $(CPP_PROJ) $< 
173
<<
174
175
.cxx{$(INTDIR)}.sbr::
176
   $(CPP) @<<
177
   $(CPP_PROJ) $< 
178
<<
179
180
MTL=midl.exe
181
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
182
RSC=rc.exe
183
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hclaunch.res" /d "NDEBUG" 
184
BSC32=bscmake.exe
185
BSC32_FLAGS=/nologo /o"$(OUTDIR)\HCLauncher.bsc" 
186
BSC32_SBRS= \
187
	
188
LINK32=link.exe
189
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib rpcrt4.lib bufferoverflowU.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\hclaunch.pdb" /machine:AMD64 /out:"$(OUTDIR)\hclaunch.dll" /implib:"$(OUTDIR)\..\lib\hclaunch.lib" 
190
LINK32_OBJS= \
191
	"$(INTDIR)\hclaunch.obj" \
192
	"$(INTDIR)\launcher_common.obj" \
193
	"$(INTDIR)\launcher_md.obj" \
194
	"$(INTDIR)\launcher_os400.obj" \
195
	"$(INTDIR)\hclaunch.res" \
196
	"$(INTDIR)\java.obj" \
197
	"$(INTDIR)\RAComm.obj"
198
199
"$(OUTDIR)\hclaunch.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
200
    $(LINK32) @<<
201
  $(LINK32_FLAGS) $(LINK32_OBJS)
202
<<
203
204
!ELSEIF  "$(CFG)" == "HCLaunch - IA64 Debug"
205
206
OUTDIR=..\..\..\bin
207
INTDIR=.\Debug
208
# Begin Custom Macros
209
OutDir=..\..\..\bin
210
# End Custom Macros
211
212
ALL : "$(OUTDIR)\hclaunch.dll"
213
214
215
CLEAN :
216
	-@erase "$(INTDIR)\hclaunch.obj"
217
	-@erase "$(INTDIR)\hclaunch.res"
218
	-@erase "$(INTDIR)\java.obj"
219
	-@erase "$(INTDIR)\launcher_common.obj"
220
	-@erase "$(INTDIR)\launcher_md.obj"
221
	-@erase "$(INTDIR)\launcher_os400.obj"
222
	-@erase "$(INTDIR)\RAComm.obj"
223
	-@erase "$(INTDIR)\vc60.idb"
224
	-@erase "$(INTDIR)\vc60.pdb"
225
	-@erase "$(OUTDIR)\hclaunch.dll"
226
	-@erase "$(OUTDIR)\..\lib\hclaunch.exp"
227
	-@erase "$(OUTDIR)\..\lib\hclaunch.ilk"
228
	-@erase "$(OUTDIR)\..\lib\hclaunch.lib"
229
	-@erase "$(OUTDIR)\..\lib\hclaunch.pdb"
230
231
"$(OUTDIR)" :
232
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
233
234
"$(INTDIR)" :
235
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
236
237
CPP=cl.exe
238
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\..\transport\RACommon" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCLaunch_EXPORTS" /Fp"$(INTDIR)\HCLauncher.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
239
240
.c{$(INTDIR)}.obj::
241
   $(CPP) @<<
242
   $(CPP_PROJ) $< 
243
<<
244
245
.cpp{$(INTDIR)}.obj::
246
   $(CPP) @<<
247
   $(CPP_PROJ) $< 
248
<<
249
250
.cxx{$(INTDIR)}.obj::
251
   $(CPP) @<<
252
   $(CPP_PROJ) $< 
253
<<
254
255
.c{$(INTDIR)}.sbr::
256
   $(CPP) @<<
257
   $(CPP_PROJ) $< 
258
<<
259
260
.cpp{$(INTDIR)}.sbr::
261
   $(CPP) @<<
262
   $(CPP_PROJ) $< 
263
<<
264
265
.cxx{$(INTDIR)}.sbr::
266
   $(CPP) @<<
267
   $(CPP_PROJ) $< 
268
<<
269
270
MTL=midl.exe
271
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
272
RSC=rc.exe
273
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hclaunch.res" /d "_DEBUG" 
274
BSC32=bscmake.exe
275
BSC32_FLAGS=/nologo /o"$(OUTDIR)\HCLauncher.bsc" 
276
BSC32_SBRS= \
277
	
278
LINK32=link.exe
279
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib rpcrt4.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hclaunch.pdb" /debug /machine:IA64 /out:"$(OUTDIR)\hclaunch.dll" /implib:"$(OUTDIR)\..\lib\hclaunch.lib" 
280
LINK32_OBJS= \
281
	"$(INTDIR)\hclaunch.obj" \
282
	"$(INTDIR)\launcher_common.obj" \
283
	"$(INTDIR)\launcher_md.obj" \
284
	"$(INTDIR)\launcher_os400.obj" \
285
	"$(INTDIR)\hclaunch.res" \
286
	"$(INTDIR)\java.obj" \
287
	"$(INTDIR)\RAComm.obj"
288
289
"$(OUTDIR)\hclaunch.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
290
    $(LINK32) @<<
291
  $(LINK32_FLAGS) $(LINK32_OBJS)
292
<<
293
294
!ELSEIF  "$(CFG)" == "HCLaunch - X64 Debug"
295
296
OUTDIR=..\..\..\bin
297
INTDIR=.\Debug
298
# Begin Custom Macros
299
OutDir=..\..\..\bin
300
# End Custom Macros
301
302
ALL : "$(OUTDIR)\hclaunch.dll"
303
304
305
CLEAN :
306
	-@erase "$(INTDIR)\hclaunch.obj"
307
	-@erase "$(INTDIR)\hclaunch.res"
308
	-@erase "$(INTDIR)\java.obj"
309
	-@erase "$(INTDIR)\launcher_common.obj"
310
	-@erase "$(INTDIR)\launcher_md.obj"
311
	-@erase "$(INTDIR)\launcher_os400.obj"
312
	-@erase "$(INTDIR)\RAComm.obj"
313
	-@erase "$(INTDIR)\vc60.idb"
314
	-@erase "$(INTDIR)\vc60.pdb"
315
	-@erase "$(OUTDIR)\hclaunch.dll"
316
	-@erase "$(OUTDIR)\..\lib\hclaunch.exp"
317
	-@erase "$(OUTDIR)\..\lib\hclaunch.ilk"
318
	-@erase "$(OUTDIR)\..\lib\hclaunch.lib"
319
	-@erase "$(OUTDIR)\..\lib\hclaunch.pdb"
320
321
"$(OUTDIR)" :
322
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
323
324
"$(INTDIR)" :
325
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
326
327
CPP=cl.exe
328
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\..\transport\RACommon" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCLaunch_EXPORTS" /Fp"$(INTDIR)\HCLauncher.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
329
330
.c{$(INTDIR)}.obj::
331
   $(CPP) @<<
332
   $(CPP_PROJ) $< 
333
<<
334
335
.cpp{$(INTDIR)}.obj::
336
   $(CPP) @<<
337
   $(CPP_PROJ) $< 
338
<<
339
340
.cxx{$(INTDIR)}.obj::
341
   $(CPP) @<<
342
   $(CPP_PROJ) $< 
343
<<
344
345
.c{$(INTDIR)}.sbr::
346
   $(CPP) @<<
347
   $(CPP_PROJ) $< 
348
<<
349
350
.cpp{$(INTDIR)}.sbr::
351
   $(CPP) @<<
352
   $(CPP_PROJ) $< 
353
<<
354
355
.cxx{$(INTDIR)}.sbr::
356
   $(CPP) @<<
357
   $(CPP_PROJ) $< 
358
<<
359
360
MTL=midl.exe
361
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
362
RSC=rc.exe
363
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hclaunch.res" /d "_DEBUG" 
364
BSC32=bscmake.exe
365
BSC32_FLAGS=/nologo /o"$(OUTDIR)\HCLauncher.bsc" 
366
BSC32_SBRS= \
367
	
368
LINK32=link.exe
369
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib rpcrt4.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hclaunch.pdb" /debug /machine:AMD64 /out:"$(OUTDIR)\hclaunch.dll" /implib:"$(OUTDIR)\..\lib\hclaunch.lib" 
370
LINK32_OBJS= \
371
	"$(INTDIR)\hclaunch.obj" \
372
	"$(INTDIR)\launcher_common.obj" \
373
	"$(INTDIR)\launcher_md.obj" \
374
	"$(INTDIR)\launcher_os400.obj" \
375
	"$(INTDIR)\hclaunch.res" \
376
	"$(INTDIR)\java.obj" \
377
	"$(INTDIR)\RAComm.obj"
378
379
"$(OUTDIR)\hclaunch.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
380
    $(LINK32) @<<
381
  $(LINK32_FLAGS) $(LINK32_OBJS)
382
<<
383
384
385
!ENDIF 
386
387
!IF "$(CFG)" == "HCLaunch - IA64 Release" || "$(CFG)" == "HCLaunch - IA64 Debug" || "$(CFG)" == "HCLaunch - X64 Release" || "$(CFG)" == "HCLaunch - X64 Debug"
388
SOURCE=..\hclaunch.c
389
390
"$(INTDIR)\hclaunch.obj" : $(SOURCE) "$(INTDIR)"
391
	$(CPP) $(CPP_PROJ) $(SOURCE)
392
393
394
SOURCE=..\..\transport\RACommon\java.c
395
396
"$(INTDIR)\java.obj" : $(SOURCE) "$(INTDIR)"
397
	$(CPP) $(CPP_PROJ) $(SOURCE)
398
399
400
SOURCE=..\launcher_common.c
401
402
"$(INTDIR)\launcher_common.obj" : $(SOURCE) "$(INTDIR)"
403
	$(CPP) $(CPP_PROJ) $(SOURCE)
404
405
406
SOURCE=..\launcher_md.c
407
408
"$(INTDIR)\launcher_md.obj" : $(SOURCE) "$(INTDIR)"
409
	$(CPP) $(CPP_PROJ) $(SOURCE)
410
411
412
SOURCE=..\launcher_os400.c
413
414
"$(INTDIR)\launcher_os400.obj" : $(SOURCE) "$(INTDIR)"
415
	$(CPP) $(CPP_PROJ) $(SOURCE)
416
417
418
SOURCE=..\..\transport\RACommon\RAComm.c
419
420
"$(INTDIR)\RAComm.obj" : $(SOURCE) "$(INTDIR)"
421
	$(CPP) $(CPP_PROJ) $(SOURCE)
422
423
424
SOURCE=..\version.rc
425
426
!IF  "$(CFG)" == "HCLaunch - IA64 Release" ||  "$(CFG)" == "HCLaunch - X64 Release"
427
428
429
"$(INTDIR)\hclaunch.res" : $(SOURCE) "$(INTDIR)"
430
	$(RSC) /l 0x409 /fo"$(INTDIR)\hclaunch.res"  /d "NDEBUG" $(SOURCE)
431
432
433
!ELSEIF  "$(CFG)" == "HCLaunch - IA64 Debug" ||  "$(CFG)" == "HCLaunch - X64 Debug"
434
435
436
"$(INTDIR)\hclaunch.res" : $(SOURCE) "$(INTDIR)"
437
	$(RSC) /l 0x409 /fo"$(INTDIR)\hclaunch.res"  /d "_DEBUG" $(SOURCE)
438
439
440
!ENDIF 
441
442
443
!ENDIF 
444
(-)src-native-new/src/agents/perfmon/perflin/perflin.c (+2191 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 Scapa Technologies Limited and others
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
14
#include <stdio.h>
15
#include <stdlib.h>
16
#include <ctype.h>
17
#include <string.h>
18
#include <strings.h>
19
#include <assert.h>
20
#include <errno.h>
21
#include <malloc.h>
22
#include <dirent.h>
23
#include <limits.h>
24
#include <sys/types.h>
25
#include <sys/vfs.h>
26
#include <sys/ioctl.h>
27
#include "perflin.h"
28
29
#include <fcntl.h>
30
#include <mntent.h>
31
#include <sys/unistd.h>
32
#include <sys/dir.h>
33
#include <sys/sysinfo.h>
34
#include <unistd.h>
35
36
static int VERBOSE = FALSE;
37
static int pageSize = 0;
38
39
static int buflen = 8;
40
static char* buff = NULL;
41
42
static int cpuCount = 1;
43
44
static HashTable* treeHash;
45
static HashTable* filtersHash;
46
static HashTable* variablesHash;
47
static HashTable* previousValues; // Used to cache previous results 
48
static HashTable* processHash;
49
static HashTable* currentValues;
50
51
static HashTable* counterSeen;
52
53
static char** results = NULL;
54
static int max = 0;
55
static int size = 0;
56
57
static char* agent_type = "LinuxAgent";
58
59
/*************************************************************************************/
60
61
void crash(char* error)
62
{
63
	printf("Error - crash in ");
64
	printf("%s\n",error);
65
	exit(1);
66
}
67
68
void addToArray(char* string)
69
{
70
	if (results == NULL || max == 0)
71
	{
72
		max = 128;
73
		size = 0;
74
		results = malloc(sizeof(char*)*(max));
75
	}
76
77
	if (size+1 == max)
78
	{
79
		max = (max)*2;
80
		results = realloc(results, sizeof(char*)*(max));	
81
	}
82
83
	results[size] = string;
84
	size = size + 1;
85
}
86
87
void addToResultsArray(char* id, char* result)
88
{
89
	// Format the id-result string and add to the tree,no need ot free resultstring here - done in PerfmonAgent
90
  	char* resultString = malloc(sizeof(char)*(1+strlen(id)+strlen(result)+3));
91
	sprintf(resultString,"%s%c%s%c",id,'\0',result,'\0');
92
	addToArray(resultString);
93
}
94
95
void addToTreeArray(char* pid, char* id, char* name, char* desc, char* suffix)
96
{
97
	// Format the tree string and add it to the getTree results array 'array'
98
  	char* treeString = malloc(sizeof(char)*(1+strlen(id)+strlen(pid)+strlen(name)+strlen(desc)+strlen(suffix)+10));
99
	if (strchr(id,'C') == NULL)
100
		sprintf(treeString,"%s%c%s%c%s%c%s%c%s%c%d%c",pid,'\0',id,'\0',name,'\0',desc,'\0',suffix,'\0',0,'\0');
101
	else
102
		sprintf(treeString,"%s%c%s%c%s%c%s%c%s%c%d%c",pid,'\0',id,'\0',name,'\0',desc,'\0',suffix,'\0',1,'\0');
103
		
104
	addToArray(treeString);
105
}
106
107
void addDoubleCounter(double number, char* id, char* resultString)
108
{
109
		sprintf(resultString, "%lf%c",number,'\0');
110
		addToResultsArray(id, resultString);
111
}
112
113
void addLongCounter(long number, char* id, char* resultString)
114
{
115
		sprintf(resultString, "%lu%c",number,'\0');
116
		addToResultsArray(id, resultString);
117
}
118
119
void addUnsignedCounter(long number, char* id, char* resultString)
120
{
121
	sprintf(resultString, "%lu%c",number, '\0');
122
	addToResultsArray(id, resultString);
123
}
124
125
void getLinuxTree() 
126
{
127
	if (VERBOSE == TRUE) printf("*** in getLinuxTree\n");
128
129
  	getStatInfo("");
130
  	getMemInfoTree("");
131
	getProcessesTree("");
132
	getNetInfoTree("");
133
	getMountTree("");
134
	getSwapTree("");
135
136
	if (VERBOSE == TRUE) printf("*** out getLinuxTree\n");
137
}
138
139
void getLinuxResults()
140
{
141
	if (VERBOSE == TRUE) printf("*** in getLinuxResults\n");
142
143
	getStatResults();
144
	getMemInfoResults();
145
146
	// If we have some filters requested
147
	if (tableGet(filtersHash, PROC_MAIN) != (XINT64) NULL)
148
		getProcessesResults();
149
150
	getNetInfoResults();	
151
	getMountResults();
152
	getSwapResults();
153
	if (VERBOSE == TRUE) printf("*** out getLinuxResults\n");
154
}
155
156
void expandBuffer()
157
{
158
	buflen = buflen*2;
159
	buff = realloc(buff, sizeof(char)*buflen);
160
}
161
162
int readFromFile(char* filename)
163
{
164
	static int file;
165
	if ((file = open(filename, O_RDONLY, 0)) != -1) 
166
	{
167
		memset(buff,'\0',buflen-1);
168
	   	buff[buflen - 1] = '\0';  /* ensure null termination in buffer */
169
170
		while (read(file, buff, buflen - 1) == (buflen - 1))
171
		{
172
			expandBuffer();
173
		   	buff[buflen - 1] = '\0'; /* Bug 121258 - we must still ensure null termination of the expanded buffer */
174
			lseek(file,0,SEEK_SET);
175
		}
176
	   	close(file);
177
	   	return TRUE;
178
	}
179
	else
180
		printf("Unable to open file %s\n",filename);
181
	return FALSE;
182
}
183
184
int readSwapInfo()
185
{
186
  return readFromFile("/proc/swaps");
187
}
188
189
int readNetDevInfo()
190
{
191
	return readFromFile("/proc/net/dev");
192
}
193
194
int readNetWirelessInfo()
195
{
196
	return readFromFile("proc/stat");
197
}
198
199
int readStatInfo() 
200
{
201
	return readFromFile("/proc/stat");
202
} 
203
204
int readMemInfo() 
205
{
206
	return readFromFile("/proc/meminfo");
207
} 
208
209
int readProcInfo(char * fileName) 
210
{
211
	return readFromFile(fileName);
212
}
213
214
void getSwapTree(char* parentid)
215
{
216
	if (VERBOSE == TRUE) printf("*** in getSwapTree\n");
217
218
	if (readSwapInfo())
219
	{
220
		char* b;
221
		char* id = malloc(sizeof(char)*128);
222
		char* pid = malloc(sizeof(char)*128);
223
		char* name = malloc(sizeof(char)*128);
224
		char* type = malloc(sizeof(char)*128);
225
226
		// The parent swap node.
227
		addToTreeArray(parentid, SWAP_PARENT,"${LINUX.AGENT.1}","${LINUX.AGENT.2}","");
228
229
		// Cycle through the swaps
230
	
231
		b = strchr(buff,'\n');
232
		b++;
233
234
		while (b[0] != '\0')
235
		{
236
			sscanf(b, "%s %s %*d %*d %*d",name, type);
237
238
			// Add the partition node
239
			sprintf(pid, "%s_%s%c",SWAP_PART,name,'\0');
240
			addToTreeArray(SWAP_PARENT,pid, name, type, "");
241
242
			// Now add its children
243
			sprintf(id, "%s_%s%c",SWAP_PUSED,name,'\0');
244
			addToTreeArray(pid,id,"${LINUX.AGENT.3}","${LINUX.AGENT.4}","");
245
			sprintf(id, "%s_%s%c",SWAP_PFREE,name,'\0');
246
			addToTreeArray(pid,id,"${LINUX.AGENT.5}","${LINUX.AGENT.6}","");
247
			sprintf(id, "%s_%s%c",SWAP_TOTAL,name, '\0');
248
			addToTreeArray(pid,id,"${LINUX.AGENT.7}","${LINUX.AGENT.8}","");
249
			sprintf(id, "%s_%s%c",SWAP_USED,name,'\0');
250
			addToTreeArray(pid,id,"${LINUX.AGENT.9}","${LINUX.AGENT.10}","");
251
			sprintf(id, "%s_%s%c",SWAP_FREE,name,'\0');
252
			addToTreeArray(pid,id,"${LINUX.AGENT.11}","${LINUX.AGENT.12}","");
253
254
			b = strchr(b,'\n');
255
			b++;
256
		}
257
258
		b = NULL;
259
	
260
	 	free(id);
261
		free(pid);
262
		free(name);
263
		free(type);
264
	}
265
	if (VERBOSE == TRUE) printf("*** out getSwapTree\n");
266
}
267
268
void getSwapResults()
269
{
270
	if (VERBOSE == TRUE) printf("*** in getSwapResults\n");
271
272
	if (tableGet(filtersHash, SWAP_PARENT) != (XINT64) NULL)
273
	{
274
		if (readSwapInfo())
275
		{
276
			char* b;
277
			char* id = malloc(sizeof(char)*128);
278
			char* resultString = malloc(sizeof(char) * 128);
279
			char* name = malloc(sizeof(char)*128);
280
			long used, ssize;
281
282
			// Cycle through the swaps
283
	
284
			b = strchr(buff,'\n');
285
			b++;
286
287
			while (b[0] != '\0')
288
			{
289
				sscanf(b, "%s %*s %d %d %*d",name, &ssize, &used);
290
291
				// Now add its children
292
				sprintf(id, "%s_%s%c",SWAP_PUSED,name,'\0');
293
				if (tableGet(filtersHash, id) != (XINT64) NULL)
294
					addDoubleCounter(((double) used)/((double)ssize)*100, id,resultString);
295
296
				sprintf(id, "%s_%s%c",SWAP_PFREE,name,'\0');
297
				if (tableGet(filtersHash, id) != (XINT64) NULL)
298
					addDoubleCounter(((double) ssize-used)/((double)ssize)*100, id,resultString);
299
300
				sprintf(id, "%s_%s%c",SWAP_TOTAL,name, '\0');
301
				if (tableGet(filtersHash, id) != (XINT64) NULL)
302
					addLongCounter(ssize, id,resultString);
303
304
				sprintf(id, "%s_%s%c",SWAP_USED,name,'\0');
305
				if (tableGet(filtersHash, id) != (XINT64) NULL)
306
					addDoubleCounter(used, id,resultString);
307
308
				sprintf(id, "%s_%s%c",SWAP_FREE,name,'\0');
309
				if (tableGet(filtersHash, id) != (XINT64) NULL)
310
					addDoubleCounter(ssize-used, id,resultString);
311
312
313
				b = strchr(b,'\n');
314
				b++;
315
			}
316
317
			b = NULL;
318
	
319
	 		free(id);
320
			free(resultString);
321
			free(name);
322
		}
323
	}
324
	if (VERBOSE == TRUE) printf("*** out getSwapTree\n");
325
326
}
327
328
void addMountCounterTree( char* pid, char* dir)
329
{
330
	long bytesize;
331
	char* id = malloc(sizeof(char) * 128);
332
333
	sprintf(id,"%s_%s%c",PART_PERCU,dir,'\0');
334
	addToTreeArray(pid, id, "${LINUX.AGENT.13}","${LINUX.AGENT.14}","");
335
	
336
	sprintf(id,"%s_%s%c",PART_PERCF,dir,'\0');
337
	addToTreeArray(pid, id, "${LINUX.AGENT.15}","${LINUX.AGENT.16}","");
338
	
339
	sprintf(id,"%s_%s%c",PART_TOTAL_SIZE,dir,'\0');
340
	addToTreeArray(pid, id, "${LINUX.AGENT.17}","${LINUX.AGENT.18}","");
341
	
342
	sprintf(id,"%s_%s%c",PART_FREE_SIZE,dir,'\0');
343
	addToTreeArray(pid, id, "${LINUX.AGENT.19}","${LINUX.AGENT.20}","");
344
	
345
	sprintf(id,"%s_%s%c",PART_AVAIL_SIZE,dir,'\0');
346
	addToTreeArray(pid, id, "${LINUX.AGENT.21}","${LINUX.AGENT.22}","");
347
	
348
	sprintf(id,"%s_%s%c",PART_USED_SIZE,dir,'\0');
349
	addToTreeArray(pid, id, "${LINUX.AGENT.23}","${LINUX.AGENT.24}","");
350
	
351
	sprintf(id,"%s_%s%c",PART_TOTAL_BLKS,dir,'\0');
352
	addToTreeArray(pid, id, "${LINUX.AGENT.25}","${LINUX.AGENT.26}","");
353
	
354
	sprintf(id,"%s_%s%c",PART_USED_BLKS,dir,'\0');
355
	addToTreeArray(pid, id, "${LINUX.AGENT.27}","${LINUX.AGENT.28}","");
356
357
	sprintf(id,"%s_%s%c",PART_FREE_BLKS,dir,'\0');
358
	addToTreeArray(pid, id, "${LINUX.AGENT.29}","${LINUX.AGENT.30}","");
359
	
360
	sprintf(id,"%s_%s%c",PART_AVAIL_BLKS,dir,'\0');
361
	addToTreeArray(pid, id, "${LINUX.AGENT.31}","${LINUX.AGENT.32}","");
362
	
363
	sprintf(id,"%s_%s%c",PART_OPTIMAL,dir,'\0');
364
	addToTreeArray(pid, id, "${LINUX.AGENT.33}","${LINUX.AGENT.34}","kb");
365
	
366
	sprintf(id,"%s_%s%c",PART_TOTAL_NODES,dir,'\0');
367
	addToTreeArray(pid, id, "${LINUX.AGENT.35}","${LINUX.AGENT.36}","");
368
	
369
	sprintf(id,"%s_%s%c",PART_TOTAL_USED,dir,'\0');
370
	addToTreeArray(pid, id, "${LINUX.AGENT.37}","${LINUX.AGENT.38}","");
371
372
	sprintf(id,"%s_%s%c",PART_TOTAL_FREE,dir,'\0');
373
	addToTreeArray(pid, id, "${LINUX.AGENT.39}","${LINUX.AGENT.40}","");
374
	
375
	sprintf(id,"%s_%s%c",PART_TOTAL_MAXLEN,dir,'\0');
376
	addToTreeArray(pid, id, "${LINUX.AGENT.41}","${LINUX.AGENT.42}","");
377
	
378
	free(id);
379
}
380
381
void getMountTree( char* parentid)
382
{
383
	FILE* fp;
384
	struct mntent* mnt;
385
	char* id = malloc(sizeof(char) * 128);
386
	char* name = malloc(sizeof(char) * 128);
387
	char* desc = malloc(sizeof(char) * 128);
388
389
	fp = setmntent("/etc/mtab", "r");
390
	if (fp != NULL)
391
	{
392
		// Lets add the parent node here - only if /etc/mtab was opened succesfully
393
		addToTreeArray(parentid, PART_PARENT, "${LINUX.AGENT.43}","${LINUX.AGENT.44}","");
394
395
		mnt = getmntent(fp);
396
		while (mnt != NULL)
397
		{
398
			sprintf(id, "%s_%s%c",PART_PART,(*mnt).mnt_dir,'\0');
399
			sprintf(desc, "%s [%s]%c", (*mnt).mnt_type, (*mnt).mnt_dir, '\0');
400
			addToTreeArray(PART_PARENT, id, (*mnt).mnt_fsname, desc, "");
401
402
			addMountCounterTree(id, (*mnt).mnt_dir);
403
404
			mnt = getmntent(fp);
405
		}
406
	}
407
	endmntent(fp);
408
409
	free(id);
410
	free(name);
411
	free(desc);
412
}
413
414
void addMountCounterResults(char* dir)
415
{
416
	struct statfs fs;
417
	char* id = malloc(sizeof(char) * 128);
418
	char* resultString = malloc(sizeof(char) * 128);
419
420
  statfs(dir, &fs);
421
422
	sprintf(id,"%s_%s%c",PART_PERCU,dir,'\0');
423
	if (tableGet(filtersHash, id) != (XINT64)NULL)
424
		addDoubleCounter(((double) (fs.f_blocks - fs.f_bavail))/((double)fs.f_blocks)*100, id, resultString);
425
	
426
	sprintf(id,"%s_%s%c",PART_PERCF,dir,'\0');
427
	if (tableGet(filtersHash, id) != (XINT64)NULL)
428
		addDoubleCounter(((double) (fs.f_bavail))/((double)fs.f_blocks)*100, id, resultString);
429
430
	sprintf(id,"%s_%s%c",PART_TOTAL_SIZE,dir,'\0');
431
	if (tableGet(filtersHash, id) != (XINT64)NULL)
432
		addLongCounter(fs.f_blocks * fs.f_bsize, id, resultString);
433
434
	sprintf(id,"%s_%s%c",PART_FREE_SIZE,dir,'\0');
435
	if (tableGet(filtersHash, id) != (XINT64)NULL)
436
		addLongCounter(fs.f_bfree * fs.f_bsize, id, resultString);
437
438
	sprintf(id,"%s_%s%c",PART_AVAIL_SIZE,dir,'\0');
439
	if (tableGet(filtersHash, id) != (XINT64)NULL)
440
		addLongCounter(fs.f_bavail * fs.f_bsize, id, resultString);
441
442
	sprintf(id,"%s_%s%c",PART_USED_SIZE,dir,'\0');
443
	if (tableGet(filtersHash, id) != (XINT64)NULL)
444
		addLongCounter((fs.f_blocks - fs.f_bfree)*fs.f_bsize, id, resultString);
445
446
	sprintf(id,"%s_%s%c",PART_TOTAL_BLKS,dir,'\0');
447
	if (tableGet(filtersHash, id) != (XINT64)NULL)
448
		addLongCounter(fs.f_blocks, id, resultString);
449
450
	sprintf(id,"%s_%s%c",PART_USED_BLKS,dir,'\0');
451
	if (tableGet(filtersHash, id) != (XINT64)NULL)
452
		addLongCounter(fs.f_blocks - fs.f_bfree, id, resultString);
453
454
	sprintf(id,"%s_%s%c",PART_FREE_BLKS,dir,'\0');
455
	if (tableGet(filtersHash, id) != (XINT64)NULL)
456
		addLongCounter(fs.f_bfree, id, resultString);
457
458
	sprintf(id,"%s_%s%c",PART_AVAIL_BLKS,dir,'\0');
459
	if (tableGet(filtersHash, id) != (XINT64)NULL)
460
		addLongCounter(fs.f_bavail, id, resultString);
461
462
	sprintf(id,"%s_%s%c",PART_OPTIMAL,dir,'\0');
463
	if (tableGet(filtersHash, id) != (XINT64)NULL)
464
		addLongCounter(fs.f_bsize, id, resultString);
465
466
	sprintf(id,"%s_%s%c",PART_TOTAL_NODES,dir,'\0');
467
	if (tableGet(filtersHash, id) != (XINT64)NULL)
468
		addLongCounter(fs.f_files, id, resultString);
469
470
	sprintf(id,"%s_%s%c",PART_TOTAL_USED,dir,'\0');
471
	if (tableGet(filtersHash, id) != (XINT64)NULL)
472
		addLongCounter(fs.f_files - fs.f_ffree, id, resultString);
473
474
	sprintf(id,"%s_%s%c",PART_TOTAL_FREE,dir,'\0');
475
	if (tableGet(filtersHash, id) != (XINT64)NULL)
476
		addLongCounter(fs.f_ffree, id, resultString);
477
478
	sprintf(id,"%s_%s%c",PART_TOTAL_MAXLEN,dir,'\0');
479
	if (tableGet(filtersHash, id) != (XINT64)NULL)
480
		addLongCounter(fs.f_namelen, id, resultString);
481
482
	free(id);
483
	free(resultString);
484
}
485
486
void getMountResults()
487
{
488
	if (tableGet(filtersHash, PART_PARENT) != (XINT64) NULL)
489
	{
490
		FILE* fp;
491
		struct mntent *mnt;
492
		char* id = malloc(sizeof(char) * 128);
493
494
		fp = setmntent("/etc/mtab", "r");
495
		if (fp != NULL)
496
		{
497
			mnt = getmntent(fp);
498
			while (mnt != NULL)
499
			{
500
				sprintf(id, "%s_%s%c",PART_PART,(*mnt).mnt_dir,'\0');
501
				addMountCounterResults((*mnt).mnt_dir);
502
503
				mnt = getmntent(fp);
504
			}
505
		}
506
		endmntent(fp);
507
508
		free(id);
509
	}
510
}
511
512
long getProcessCount()
513
{
514
  DIR * proc;
515
	static struct direct * ent;
516
517
	long value = 0;
518
	
519
 	if ((proc = opendir("/proc")) == NULL) 
520
		crash("/proc");
521
522
	// Read all the entries in the proc directory
523
	while((ent = readdir(proc))) 
524
 		if (isdigit(ent->d_name[0])) 
525
			value++;
526
527
 	closedir(proc);
528
529
	return value;
530
}
531
532
void getSysStatsInfoTree(char* pid) 
533
{
534
	int len;
535
	char * b = strstr(buff, "cpu ");
536
  unsigned long l1, l2, l3 ,l4;
537
	int i;
538
	char* id = malloc(sizeof(char)*128);
539
	char* cpuid = malloc(sizeof(char) * 128);
540
	char* name = malloc(sizeof(char) * 128);
541
	int counterCount = 0;
542
	long t;
543
	
544
	if (VERBOSE == TRUE) printf("*** in getSysStatsInfoTree\n");
545
546
	counterCount = sscanf(buff,"cpu %lu %lu %lu %lu %lu %lu %lu",&t,&t,&t,&t,&t,&t,&t);
547
548
	addToTreeArray(pid, STAT_CPU_TOTAL, "${LINUX.AGENT.45}", "${LINUX.AGENT.46}", "");
549
	addToTreeArray(STAT_CPU_TOTAL, STAT_CPU0_TOTAL, "${LINUX.AGENT.64}", "${LINUX.AGENT.65}","");
550
	addToTreeArray(STAT_CPU_TOTAL, STAT_CPU1_TOTAL, "${LINUX.AGENT.66}", "${LINUX.AGENT.67}", "");
551
	addToTreeArray(STAT_CPU_TOTAL, STAT_CPU3_TOTAL, "${LINUX.AGENT.68}", "${LINUX.AGENT.69}", "");
552
	addToTreeArray(STAT_CPU_TOTAL, STAT_CPU2_TOTAL, "${LINUX.AGENT.70}", "${LINUX.AGENT.71}", "");
553
	addToTreeArray(STAT_CPU_TOTAL, STAT_CPU4_TOTAL, "${LINUX.AGENT.72}", "${LINUX.AGENT.73}", "");
554
555
	if (counterCount == 7)
556
	{
557
		addToTreeArray(STAT_CPU_TOTAL, STAT_CPU5_TOTAL, "${LINUX.AGENT.74}", "${LINUX.AGENT.75}", "");
558
		addToTreeArray(STAT_CPU_TOTAL, STAT_CPU6_TOTAL, "${LINUX.AGENT.76}", "${LINUX.AGENT.77}", "");
559
		addToTreeArray(STAT_CPU_TOTAL, STAT_CPU7_TOTAL, "${LINUX.AGENT.78}", "${LINUX.AGENT.79}", "");
560
	}
561
562
	// In linux kernel 2.6, there are 7 counters, the above ones PLUS 3 others
563
	// Check if they are available and then add them.
564
565
566
	for (i =0; i<cpuCount; i++)
567
	{
568
		char test[32];
569
		// We need to check if this is an older kernel rep
570
		// or a newer one.
571
		
572
		sprintf(test, "cpu%d%c",i,'\0');
573
574
		if (strstr(buff,test) != NULL)
575
		{
576
	
577
  		// Add the 4 CPU counters
578
			sprintf(cpuid, "%s_%d%c",STAT_CPU,i,'\0');
579
			sprintf(name, "CPU_%d%c",i,'\0');
580
			addToTreeArray(pid, cpuid, name, "${LINUX.AGENT.63}","");
581
582
			sprintf(id, "%s_%d%c", STAT_CPU0,i,'\0');
583
			addToTreeArray(cpuid, id, "${LINUX.AGENT.64}", "${LINUX.AGENT.65}","");
584
			sprintf(id, "%s_%d%c", STAT_CPU1,i,'\0');
585
			addToTreeArray(cpuid, id,"${LINUX.AGENT.66}","${LINUX.AGENT.67}","");
586
			sprintf(id, "%s_%d%c", STAT_CPU3,i,'\0');
587
			addToTreeArray(cpuid, id,"${LINUX.AGENT.68}","${LINUX.AGENT.69}","");
588
			sprintf(id, "%s_%d%c", STAT_CPU2,i,'\0');
589
			addToTreeArray(cpuid, id,"${LINUX.AGENT.70}","${LINUX.AGENT.71}","");
590
			sprintf(id, "%s_%d%c", STAT_CPU4,i,'\0');
591
			addToTreeArray(cpuid, id,"${LINUX.AGENT.72}","${LINUX.AGENT.73}","");
592
593
			if (counterCount == 7)
594
			{			
595
				sprintf(id, "%s_%d%c", STAT_CPU5,i,'\0');
596
				addToTreeArray(cpuid, id, "${LINUX.AGENT.74}", "${LINUX.AGENT.75}", "");			
597
				
598
				sprintf(id, "%s_%d%c", STAT_CPU6,i,'\0');
599
				addToTreeArray(cpuid, id, "${LINUX.AGENT.76}", "${LINUX.AGENT.77}", "");			
600
				
601
				sprintf(id, "%s_%d%c", STAT_CPU7,i,'\0');
602
				addToTreeArray(cpuid, id, "${LINUX.AGENT.78}", "${LINUX.AGENT.79}", "");
603
604
			}
605
		}
606
	}
607
608
	addToTreeArray(pid, STAT_OTHER, "${LINUX.AGENT.80}","${LINUX.AGENT.81}","");
609
610
	if (counterCount != 7)
611
	{
612
  		b = strstr(buff, "page ");
613
		if (b != NULL)
614
		{
615
	    		// Add the 2 Page counters
616
			addToTreeArray(STAT_OTHER, STAT_PAGE1,"${LINUX.AGENT.82}","${LINUX.AGENT.83}","");
617
			addToTreeArray(STAT_OTHER, STAT_PAGE2,"${LINUX.AGENT.84}","${LINUX.AGENT.85}","");
618
		}
619
620
  		b = strstr(buff, "swap ");
621
		if (b != NULL)
622
		{
623
	  		// Add the 2 swap counters
624
			addToTreeArray(STAT_OTHER, STAT_SWAP2,"${LINUX.AGENT.86}","${LINUX.AGENT.87}","");
625
			addToTreeArray(STAT_OTHER, STAT_SWAP1,"${LINUX.AGENT.88}","${LINUX.AGENT.89}","");
626
		}
627
	}
628
629
  b = strstr(buff, "intr ");
630
	if (b != NULL)
631
    // Add the 1 Interrupt counter here
632
		addToTreeArray(STAT_OTHER, STAT_INTR,"${LINUX.AGENT.90}","${LINUX.AGENT.91}","");
633
634
  b = strstr(buff, "ctxt ");
635
  if (b != NULL)
636
    // Add the context switch counter
637
		addToTreeArray(STAT_OTHER, STAT_CTXT,"${LINUX.AGENT.92}","${LINUX.AGENT.93}","");
638
  
639
	b = strstr(buff, "btime ");
640
  if (b != NULL)
641
		addToTreeArray(STAT_OTHER, STAT_BTIME,"${LINUX.AGENT.94}","${LINUX.AGENT.95}","");
642
643
	b = strstr(buff, "processes ");
644
  if (b != NULL)
645
		addToTreeArray(STAT_OTHER, STAT_PROC,"${LINUX.AGENT.96}","${LINUX.AGENT.97}","");
646
647
	addToTreeArray(STAT_OTHER, STAT_TOTAL_PROC, "${LINUX.AGENT.98}","${LINUX.AGENT.99}","");
648
649
	b = NULL;
650
651
	if (VERBOSE == TRUE) printf("*** out getSysStatsInfoTree\n");
652
	free(id);
653
	free(name);
654
	free(cpuid);
655
} 
656
657
void addSysCounter( long value, char* id, char* resultString)
658
{
659
	long prevValue = (XINT64) tableGet(previousValues, id);
660
661
	if (tableGet(filtersHash, id) != (XINT64) NULL)
662
	{
663
		if (prevValue == 0)
664
		{
665
			if (containsKey(previousValues, id) == TRUE)
666
				addLongCounter(value-prevValue,id, resultString);
667
		}
668
		else
669
			addLongCounter(value-prevValue,id, resultString);
670
	}
671
672
	tablePut(previousValues, id, (XINT64) value);
673
}
674
675
void addCPUCounter( long value, long prevValue,long total, char* id, char* resultString)
676
{
677
	if (tableGet(filtersHash, id) != (XINT64) NULL)
678
	{
679
		if (prevValue == 0)
680
		{
681
			if (containsKey(previousValues, id) == TRUE)
682
				addDoubleCounter(((double) (value-prevValue)/ (double) total)*100, id, resultString);
683
		}
684
		else
685
			addDoubleCounter(((double) (value-prevValue)/ (double) total)*100, id, resultString);
686
	}
687
688
	tablePut(previousValues, id, (XINT64) value);
689
	tablePut(currentValues, id, (XINT64) value-prevValue);
690
691
}
692
693
void getSysStatsInfoResults() 
694
{
695
  // Previous values used for caching of previous result - better than doing hashtable lookups
696
	char* resultString = malloc(sizeof(char)*128);
697
	char* cpuid = malloc(sizeof(char) * 128);
698
	char* cpu = malloc(sizeof(char) * 128);
699
	char * b;
700
701
	long l1, l2,l3, l4, total, l5, l6, l7;
702
	long pl1, pl2, pl3, pl4,pl5,pl6,pl7;
703
	int i;
704
	int counterCount = 0;
705
	long t;
706
	
707
	if (VERBOSE == TRUE) 
708
		printf("*** in getSysStatsInfoResults\n");
709
710
711
	b = strstr(buff, "cpu ");
712
713
	// Deal with the total first
714
	counterCount = sscanf(b, "cpu  %u %u %u %u %u %u %u", &l1, &l2, &l3, &l4, &l5, &l6, &l7);
715
716
	// We ALWAYS do this, because the values are used later on in other calculations
717
	pl1 = (long) tableGet(previousValues, STAT_CPU1_TOTAL);
718
	pl2 = (long) tableGet(previousValues, STAT_CPU2_TOTAL);
719
	pl3 = (long) tableGet(previousValues, STAT_CPU3_TOTAL);
720
	pl4 = (long) tableGet(previousValues, STAT_CPU4_TOTAL);
721
722
	if (counterCount > 4)
723
	{
724
		pl5 = (long) tableGet(previousValues, STAT_CPU5_TOTAL);
725
		pl6 = (long) tableGet(previousValues, STAT_CPU6_TOTAL);
726
		pl7 = (long) tableGet(previousValues, STAT_CPU7_TOTAL);
727
728
		total = (l1-pl1) + (l2-pl2) + (l3-pl3) + (l4-pl4) + (l5 - pl5) + (l6-pl6) + (l7-pl7);
729
		addCPUCounter((l1+l2+l3+l5+l6+l7), pl1+pl2+pl3+pl5+pl6+pl7,total,STAT_CPU0_TOTAL,resultString);
730
	}
731
	else
732
	{
733
		total = (l1-pl1) + (l2-pl2) + (l3-pl3) + (l4-pl4);
734
		addCPUCounter((l1+l2+l3), pl1+pl2+pl3,total,STAT_CPU0_TOTAL,resultString);
735
	}
736
737
	addCPUCounter(l1, pl1, total, STAT_CPU1_TOTAL, resultString);
738
	addCPUCounter(l2, pl2, total, STAT_CPU2_TOTAL, resultString);
739
	addCPUCounter(l3, pl3, total, STAT_CPU3_TOTAL, resultString);
740
	addCPUCounter(l4, pl4, total, STAT_CPU4_TOTAL, resultString);
741
742
	if (counterCount > 4)
743
	{
744
		addCPUCounter(l5, pl5, total, STAT_CPU5_TOTAL, resultString);
745
		addCPUCounter(l6, pl6, total, STAT_CPU6_TOTAL, resultString);
746
		addCPUCounter(l7, pl7, total, STAT_CPU7_TOTAL, resultString);
747
	}
748
	
749
	tablePut(currentValues, STAT_TOTAL, (XINT64) total);
750
751
	// Now check for each 'sub' CPU
752
	for (i=0; i<cpuCount; i++)
753
	{
754
		static char cpu0[32];
755
		static char cpu1[32];
756
		static char cpu2[32];
757
		static char cpu3[32];
758
		static char cpu4[32];
759
		static char cpu5[32];
760
		static char cpu6[32];
761
		static char cpu7[32];
762
763
		sprintf(cpu, "cpu%d ", i);
764
		b = strstr(buff, cpu);
765
		if (b != NULL)
766
		{
767
			sprintf(cpu, "cpu%d",i,'\0');
768
			strcat(cpu," \%u \%u \%u \%u \%u \%u \%u");
769
			counterCount = sscanf(b, cpu, &l1, &l2, &l3, &l4, &l5, &l6, &l7);
770
			sprintf(cpu0, "%s_%d%c", STAT_CPU0,i,'\0');	
771
			sprintf(cpu1, "%s_%d%c", STAT_CPU1,i,'\0');	
772
			sprintf(cpu2, "%s_%d%c", STAT_CPU2,i,'\0');	
773
			sprintf(cpu3, "%s_%d%c", STAT_CPU3,i,'\0');	
774
			sprintf(cpu4, "%s_%d%c", STAT_CPU4,i,'\0');	
775
			sprintf(cpu5, "%s_%d%c", STAT_CPU5,i,'\0');	
776
			sprintf(cpu6, "%s_%d%c", STAT_CPU6,i,'\0');	
777
			sprintf(cpu7, "%s_%d%c", STAT_CPU7,i,'\0');	
778
		
779
			pl1 = (XINT64) tableGet(previousValues, cpu1);
780
			pl2 = (XINT64) tableGet(previousValues, cpu2);
781
			pl3 = (XINT64) tableGet(previousValues, cpu3);
782
			pl4 = (XINT64) tableGet(previousValues, cpu4);							
783
784
			if (counterCount > 4)
785
			{
786
				pl5 = (XINT64) tableGet(previousValues, cpu5);							
787
				pl6 = (XINT64) tableGet(previousValues, cpu6);							
788
				pl7 = (XINT64) tableGet(previousValues, cpu7);							
789
				total = l1 - pl1 + l2 - pl2 + l3 - pl3 + l4 - pl4 + l5 - pl5 + l6 - pl6 + l7 - pl7;
790
				addCPUCounter(l1+l2+l3, pl1+pl2+pl3 ,total, cpu0, resultString);
791
			}
792
			else
793
			{
794
				total = l1 - pl1 + l2 - pl2 + l3 - pl3 + l4 - pl4;
795
				addCPUCounter(l1+l2+l3+l5+l6+l7, pl1+pl2+pl3+pl5+pl6+pl7 ,total, cpu0, resultString);
796
			}
797
798
  		addCPUCounter(l1, pl1, total, cpu1, resultString);
799
			addCPUCounter(l2, pl2, total, cpu2, resultString);
800
			addCPUCounter(l3, pl3, total, cpu3, resultString);
801
			addCPUCounter(l4, pl4, total, cpu4, resultString);
802
803
			if (counterCount > 4)
804
			{
805
				addCPUCounter(l5, pl5, total, cpu5, resultString);
806
				addCPUCounter(l6, pl6, total, cpu6, resultString);
807
				addCPUCounter(l7, pl7, total, cpu7, resultString);
808
			}
809
		}	
810
	}
811
812
	if (counterCount != 7)
813
	{
814
		// Page swaps
815
  		b = strstr(buff, "page ");
816
	  	sscanf(b, "page %lu %lu", &l1, &l2);
817
818
		addSysCounter(l1, STAT_PAGE1, resultString);
819
		addSysCounter(l2, STAT_PAGE2, resultString);
820
821
		// Swap swaps
822
		b = strstr(buff, "swap ");
823
  		sscanf(b, "swap %lu %lu", &l1, &l2);
824
	
825
		addSysCounter(l1, STAT_SWAP1, resultString);
826
		addSysCounter(l2, STAT_SWAP2, resultString);
827
	}
828
	// Interrupts
829
  b = strstr(buff, "intr ");
830
  sscanf(b, "intr %lu", &l1);
831
832
	addSysCounter(l1, STAT_INTR, resultString);
833
834
	// Context Switches
835
  b = strstr(buff, "ctxt ");
836
  sscanf(b, "ctxt %lu", &l1);
837
	
838
	addSysCounter(l1, STAT_CTXT, resultString);
839
840
	// Boottime 
841
  b = strstr(buff, "btime ");
842
  sscanf(b, "btime %lu", &l1);
843
	
844
	if (tableGet(filtersHash, STAT_BTIME) != (XINT64) NULL)
845
		addLongCounter(l1 ,STAT_BTIME, resultString);
846
847
	// Processes
848
  b = strstr(buff, "processes ");
849
  sscanf(b, "processes %lu", &l1);
850
851
	if (tableGet(filtersHash, STAT_PROC) != (XINT64) NULL)
852
		addDoubleCounter(l1,STAT_PROC, resultString);
853
854
	// This call is different, execute code to fetch process count
855
	if (tableGet(filtersHash, STAT_TOTAL_PROC) != (XINT64) NULL)
856
	{
857
		addDoubleCounter(getProcessCount(), STAT_TOTAL_PROC,resultString);
858
	}
859
	
860
	b = NULL;
861
862
	free(resultString);
863
	free(cpuid);
864
	free(cpu);
865
	if (VERBOSE == TRUE) printf("*** out getSysStatsInfo\n");
866
} 
867
868
869
/*************************************************************************************/
870
// DISK METHODS
871
// 
872
873
void addDiskCounter( long val, char* mainid, char* counterid, char ch, char* resultString)
874
{
875
	long diff;
876
// Below comments remove caching
877
	sprintf(counterid, "%s%d%c",mainid,(ch-'a'+1),'\0');
878
	if (tableGet(filtersHash,counterid) != (XINT64)NULL)
879
	{
880
//		diff = val - ((XINT64) tableGet(previousValues, counterid));
881
//		if (diff == val)
882
//		{
883
//			if (containsKey(previousValues, counterid)==TRUE)	
884
//				addLongCounter(diff, counterid, resultString);
885
//		}
886
//		else	
887
//			addLongCounter(diff, counterid, resultString);
888
889
	// New line below
890
		addLongCounter(val, counterid, resultString);
891
//		tablePut(previousValues, counterid, (XINT64) val);
892
	}
893
}								
894
895
void addDiskResults( long major, long minor, long noinfo, long r_io, long r_blks, long w_io, long w_blks, char ch)
896
{
897
	char* counterid = malloc(sizeof(char)*128);
898
	char* resultString = malloc(sizeof(char)*128);
899
	long diff;
900
901
	// This populates the disk menu, for the disk with id ch.
902
	// We must cache previous values, as all are total counts.
903
	addDiskCounter(r_io, STAT_READ_IO, counterid, ch, resultString);
904
	addDiskCounter(r_blks, STAT_READ_BLKS, counterid, ch, resultString);
905
	addDiskCounter(w_io, STAT_WRITE_IO, counterid, ch, resultString);
906
	addDiskCounter(w_blks, STAT_WRITE_BLKS, counterid, ch, resultString);
907
	addDiskCounter(noinfo, STAT_NOINFO, counterid, ch, resultString);
908
909
  free(counterid);	
910
	free(resultString);
911
}
912
913
void addNewDiskResults( long major, long minor, char* name,long readno,long rmerge,long rsectors,long rmilli,long writeno,long wmerge,long wsectors,long wmilli,long ioc,long iomilli, long ioweight)
914
{
915
	char* id = malloc(sizeof(char)*128);
916
	char* pid = malloc(sizeof(char)*128);
917
	char* result = malloc(sizeof(char)*128);
918
919
	sprintf(id, "%s_%s%c",NEW_DISK_READNO,name,'\0');
920
	if (tableGet(filtersHash,id) != (XINT64) NULL)
921
		addLongCounter(readno, id, result);
922
	sprintf(id, "%s_%s%c",NEW_DISK_READMERGE,name,'\0');
923
	if (tableGet(filtersHash,id) != (XINT64) NULL)
924
	  addLongCounter(rmerge, id, result);
925
	sprintf(id, "%s_%s%c",NEW_DISK_READSECTORS,name,'\0');
926
	if (tableGet(filtersHash,id) != (XINT64) NULL)
927
	  addLongCounter(rsectors, id, result);
928
	sprintf(id, "%s_%s%c",NEW_DISK_READMILLI,name,'\0');
929
	if (tableGet(filtersHash,id) != (XINT64) NULL)
930
	  addLongCounter(rmilli, id, result);
931
	sprintf(id, "%s_%s%c",NEW_DISK_WRITENO,name,'\0');
932
	if (tableGet(filtersHash,id) != (XINT64) NULL)
933
	  addLongCounter(writeno, id, result);
934
	sprintf(id, "%s_%s%c",NEW_DISK_WRITEMERGE,name,'\0');
935
	if (tableGet(filtersHash,id) != (XINT64) NULL)
936
	  addLongCounter(wmerge, id, result);
937
	sprintf(id, "%s_%s%c",NEW_DISK_WRITESECTORS,name,'\0');
938
	if (tableGet(filtersHash,id) != (XINT64) NULL)
939
	  addLongCounter(wsectors, id, result);
940
	sprintf(id, "%s_%s%c",NEW_DISK_WRITEMILLI,name,'\0');
941
	if (tableGet(filtersHash,id) != (XINT64) NULL)
942
	  addLongCounter(wmilli, id, result);
943
	sprintf(id, "%s_%s%c",NEW_DISK_IOCOUNT,name,'\0');
944
	if (tableGet(filtersHash,id) != (XINT64) NULL)
945
	  addLongCounter(ioc, id, result);
946
	sprintf(id, "%s_%s%c",NEW_DISK_IOMILLI,name,'\0');
947
	if (tableGet(filtersHash,id) != (XINT64) NULL)
948
	  addLongCounter(iomilli, id, result);
949
	sprintf(id, "%s_%s%c",NEW_DISK_WEIGHTED,name,'\0');
950
	if (tableGet(filtersHash,id) != (XINT64) NULL)
951
	  addLongCounter(ioweight, id, result);
952
953
	free(pid);
954
	free(id);
955
	free(result);
956
}
957
958
void addDisk( char* pid, long major, long minor, long noinfo, long r_io, long r_blks, long w_io, long w_blks, char ch)
959
{
960
	char* newid = malloc(sizeof(char)*128);
961
	char* name = malloc(sizeof(char)*128);
962
	char* desc = malloc(sizeof(char)*128);
963
	char* childid = malloc(sizeof(char)*128);
964
	
965
	sprintf(newid,"%s%d%c",STAT_DISK,ch-'a'+1,'\0');
966
967
	// Construct the disk name here
968
 	sprintf(name, "Disk %d%c",ch-'a'+1,'\0');	
969
	sprintf(desc, "");
970
971
	// Construct the disks description here, eg hd'a' hd'b' and sd'c' sd'd' ... etc..
972
  if (major == 8)
973
	  sprintf(desc,"/dev/sd%c (%lu,%lu)%c",ch-1,major,minor,'\0');
974
	else if (major == 3)
975
	  sprintf(desc,"/dev/hd%c (%lu,%lu)%c",ch-1,major,minor,'\0');
976
	else
977
		sprintf(desc,"%c%c",ch-1,'\0');
978
979
  addToTreeArray(pid, newid, name,desc, "");	
980
	
981
	// Now add all the child nodes
982
	sprintf(name, "${LINUX.AGENT.100}%c",'\0');
983
	sprintf(childid, "%s%d%c",STAT_READ_IO,(ch-'a'+1),'\0');
984
	addToTreeArray(newid, childid, name, "${LINUX.AGENT.101}", "");
985
	
986
	sprintf(name, "Read Blocks%c",'\0');
987
	sprintf(childid, "%s%d%c",STAT_READ_BLKS,(ch-'a'+1),'\0');
988
	addToTreeArray(newid, childid, name, "${LINUX.AGENT.103}", "");
989
	
990
	sprintf(name, "Write IO Operations%c",'\0');
991
	sprintf(childid, "%s%d%c",STAT_WRITE_IO,(ch-'a'+1),'\0');
992
	addToTreeArray(newid, childid, name, "${LINUX.AGENT.105}", "");
993
	
994
	sprintf(name, "Write Blocks%c",'\0');
995
	sprintf(childid, "%s%d%c",STAT_WRITE_BLKS,(ch-'a'+1),'\0');
996
	addToTreeArray(newid, childid, name, "${LINUX.AGENT.107}", "");
997
	
998
	sprintf(name, "No Info%c",'\0');
999
	sprintf(childid, "%s%d%c",STAT_NOINFO,(ch-'a'+1),'\0');
1000
	addToTreeArray(newid, childid, name, "${LINUX.AGENT.109}", "");
1001
1002
	free(newid);
1003
	free(name);
1004
	free(desc);
1005
	free(childid);
1006
}
1007
1008
void getDiskStatsInfoResults()
1009
{
1010
	if (VERBOSE == TRUE) printf("*** in getDiskStatsInfoResults\n");
1011
1012
	if (tableGet(filtersHash, STAT_PARENT) != (XINT64) NULL)
1013
	{
1014
		char disk[17] = "disk_io ";
1015
		char * b;
1016
		long major=0, minor=0, noinfo=0, read_io_ops=0, read_blks=0, write_io_ops=0, write_blks=0;
1017
		char ch = 'a';
1018
		char* diskid = malloc(sizeof(char)*128);
1019
1020
		if (strstr(buff, "disk_io: ") != NULL)
1021
		{
1022
1023
			b = strstr(buff, "disk_io: ");
1024
1025
		  sscanf(b, "disk_io: (%lu,%lu):(%lu,%lu,%lu,%lu,%lu)",&major,&minor,&noinfo, &read_io_ops, &read_blks, &write_io_ops, &write_blks);
1026
1027
			sprintf(diskid,"%s%d%c",STAT_DISK,(ch-'a'+1),'\0');
1028
1029
			if (tableGet(filtersHash, diskid) != (XINT64)NULL)
1030
				addDiskResults(major, minor, noinfo, read_io_ops, read_blks, write_io_ops, write_blks,ch);
1031
1032
		  ch++;	
1033
			b = strstr(b,") ");
1034
1035
			if (b == NULL)
1036
				return;
1037
1038
			while ((b = strstr(b," ("))!= NULL)
1039
			{
1040
				sscanf(b, " (%lu,%lu):(%lu,%lu,%lu,%lu,%lu)",&major,&minor,&noinfo, &read_io_ops, &read_blks, &write_io_ops, &write_blks);
1041
1042
				sprintf(diskid,"%s%d%c",STAT_DISK,(ch-'a'+1),'\0');
1043
1044
				if (tableGet(filtersHash, diskid) != (XINT64)NULL)
1045
					addDiskResults(major, minor, noinfo, read_io_ops, read_blks, write_io_ops, write_blks,ch);
1046
	
1047
	  		ch++;
1048
			  b = strstr(b,") ");
1049
			}
1050
		}
1051
		else if (strstr(buff,"disk") != NULL)
1052
		{
1053
			long noinfo1, noinfo2, noinfo3, noinfo4;
1054
			long read_io1, read_io2, read_io3, read_io4;
1055
			long write_io1, write_io2, write_io3, write_io4;
1056
			long write_blks1, write_blks2, write_blks3, write_blks4;
1057
			long read_blks1, read_blks2, read_blks3, read_blks4;
1058
		
1059
			// Deal with the older format here
1060
			b = strstr(buff, "disk ");
1061
			sscanf(b,"disk %lu %lu %lu %lu",&noinfo1, &noinfo2, &noinfo3, &noinfo4);
1062
			b = strstr(buff, "disk_rio ");
1063
			sscanf(b,"disk_rio %lu %lu %lu %lu",&read_io1, &read_io2, &read_io3, &read_io4);
1064
			b = strstr(buff, "disk_wio ");
1065
			sscanf(b,"disk_wio %lu %lu %lu %lu",&write_io1, &write_io2, &write_io3, &write_io4);
1066
			b = strstr(buff, "disk_rblk ");
1067
			sscanf(b,"disk_rblk %lu %lu %lu %lu",&read_blks1,&read_blks2,&read_blks3,&read_blks4);
1068
			b = strstr(buff, "disk_wblk ");
1069
			sscanf(b,"disk_wblk %lu %lu %lu %lu",&write_blks1,&write_blks2,&write_blks3,&write_blks4);
1070
1071
			major = 0;
1072
			minor = 0;
1073
1074
			addDiskResults(major, minor, noinfo1, read_io1, read_blks1, write_io1, write_blks1,'a');
1075
			addDiskResults(major, minor, noinfo2, read_io2, read_blks2, write_io2, write_blks2,'b');
1076
			addDiskResults(major, minor, noinfo3, read_io3, read_blks3, write_io3, write_blks3,'c');
1077
  		addDiskResults(major, minor, noinfo4, read_io4, read_blks4, write_io4, write_blks4,'d');
1078
1079
		} 
1080
		else if (readFromFile("/proc/diskstats"))
1081
		{
1082
			long read_no, read_merge, read_sectors, read_milli, write_no, write_sectors, write_milli, iocount, iomilli, weighted, major, minor, write_merge;
1083
1084
			char* name = malloc(sizeof(char)*128);
1085
1086
			b = buff;
1087
			while ((b[0] != '\0') && (b[0] != '\n'))
1088
			{
1089
				sscanf(b,"%u %u %s %u %u %u %u %u %u %u %u %u %u %u",&major,&minor,name,&read_no,&read_merge, &read_sectors, &read_milli, &write_no, &write_merge, &write_sectors, &write_milli, &iocount,&iomilli, &weighted);
1090
				addNewDiskResults(major, minor,name, read_no, read_merge, read_sectors, read_milli, write_no, write_merge,write_sectors, write_milli, iocount, iomilli, weighted);
1091
				b = strchr(b,'\n')+1;
1092
			}
1093
1094
			free(name); 	
1095
		}
1096
1097
	  b = NULL;
1098
1099
		free(diskid);
1100
	}
1101
 
1102
	if (VERBOSE == TRUE) printf("*** out getDiskStatsInfoResults\n");
1103
}
1104
1105
void addNewDisk( char* parent, long major, long minor, char* name)
1106
{
1107
	char* id = malloc(sizeof(char)*128);
1108
	char* pid = malloc(sizeof(char)*128);
1109
	char* dname = malloc(sizeof(char) * 128);
1110
1111
	sprintf(dname, "%s (%u,%u)%c",name,major,minor,'\0');
1112
	
1113
	sprintf(pid,"%s_%s%c",NEW_DISK_PARENT,name,'\0');
1114
	addToTreeArray(parent,pid,dname,"${LINUX.AGENT.110}","");
1115
	sprintf(id, "%s_%s%c",NEW_DISK_READNO,name,'\0');
1116
	addToTreeArray(pid,id,"${LINUX.AGENT.111}","${LINUX.AGENT.112}",""); 
1117
	sprintf(id, "%s_%s%c",NEW_DISK_READMERGE,name,'\0');
1118
	addToTreeArray(pid,id,"${LINUX.AGENT.113}","${LINUX.AGENT.114}","");
1119
	sprintf(id, "%s_%s%c",NEW_DISK_READSECTORS,name,'\0');
1120
	addToTreeArray(pid,id,"${LINUX.AGENT.115}","${LINUX.AGENT.116}","");
1121
	sprintf(id, "%s_%s%c",NEW_DISK_READMILLI,name,'\0');
1122
	addToTreeArray(pid,id,"${LINUX.AGENT.117}","${LINUX.AGENT.118}","");
1123
	sprintf(id, "%s_%s%c",NEW_DISK_WRITENO,name,'\0');
1124
	addToTreeArray(pid,id,"${LINUX.AGENT.119}","${LINUX.AGENT.120}","");
1125
	sprintf(id, "%s_%s%c",NEW_DISK_WRITEMERGE,name,'\0');
1126
	addToTreeArray(pid,id,"${LINUX.AGENT.121}","${LINUX.AGENT.122}","");
1127
	sprintf(id, "%s_%s%c",NEW_DISK_WRITESECTORS,name,'\0');
1128
	addToTreeArray(pid,id,"${LINUX.AGENT.123}","${LINUX.AGENT.124}","");
1129
	sprintf(id, "%s_%s%c",NEW_DISK_WRITEMILLI,name,'\0');
1130
	addToTreeArray(pid,id,"${LINUX.AGENT.125}","${LINUX.AGENT.126}","");
1131
	sprintf(id, "%s_%s%c",NEW_DISK_IOCOUNT,name,'\0');
1132
	addToTreeArray(pid,id,"${LINUX.AGENT.127}","${LINUX.AGENT.128}","");
1133
	sprintf(id, "%s_%s%c",NEW_DISK_IOMILLI,name,'\0');
1134
	addToTreeArray(pid,id,"${LINUX.AGENT.129}","${LINUX.AGENT.130}","");
1135
	sprintf(id, "%s_%s%c",NEW_DISK_WEIGHTED,name,'\0');
1136
	addToTreeArray(pid,id,"${LINUX.AGENT.131}","${LINUX.AGENT.132}","");
1137
1138
	free(pid);
1139
	free(id);
1140
	free(dname);
1141
}
1142
1143
void getDiskStatsInfoTree( char* pid) 
1144
{
1145
	char * b;
1146
	long major=0, minor=0, noinfo=0, read_io_ops=0, read_blks=0, write_io_ops=0, write_blks=0;
1147
	char ch = 'a';
1148
	int kver = 0; // Just a value we can switch on later
1149
1150
	addToTreeArray(pid, STAT_PARENT, "${LINUX.AGENT.133}", "${LINUX.AGENT.249}", "");
1151
	// Populate the tree with entries and ids relevant for each disk installed.
1152
	// What we do here is scanf entries from the disk_io stats entry
1153
	// and for each entry we can get we populate the tree
1154
	if (VERBOSE == TRUE) printf("*** in getDiskStatsInfoTree\n");
1155
1156
	// Accomadate for older kernel disk usage here - 
1157
	// check if disk_io is present : if so, then assume ~2.4
1158
	// check if diskstats file exists : if so then assume ~2.6
1159
  // else, assume older disk in stat : k ~2.2	
1160
1161
	if (strstr(buff, "disk_io") != NULL)
1162
	{
1163
		b = strstr(buff, "disk_io: ");
1164
1165
  	sscanf(b, "disk_io: (%lu,%lu):(%lu,%lu,%lu,%lu,%lu)",&major,&minor,&noinfo, &read_io_ops, &read_blks, &write_io_ops, &write_blks);
1166
1167
		addDisk(STAT_PARENT, major, minor, noinfo, read_io_ops, read_blks, write_io_ops, write_blks,ch);
1168
1169
	  ch++;	
1170
		b = strstr(b,") ");
1171
1172
		if (b == NULL)
1173
			return;
1174
1175
		while ((b = strstr(b," ("))!= NULL)
1176
		{
1177
			sscanf(b, " (%lu,%lu):(%lu,%lu,%lu,%lu,%lu)",&major,&minor,&noinfo, &read_io_ops, &read_blks, &write_io_ops, &write_blks);
1178
1179
		  addDisk(STAT_PARENT, major, minor, noinfo, read_io_ops, read_blks, write_io_ops, write_blks,ch);
1180
	  	ch++;
1181
		  b = strstr(b,") ");
1182
		}
1183
	}
1184
	else if (strstr(buff,"disk") != NULL)
1185
	{
1186
		long noinfo1, noinfo2, noinfo3, noinfo4;
1187
		long read_io1, read_io2, read_io3, read_io4;
1188
		long write_io1, write_io2, write_io3, write_io4;
1189
		long write_blks1, write_blks2, write_blks3, write_blks4;
1190
		long read_blks1, read_blks2, read_blks3, read_blks4;
1191
		
1192
		// Deal with the older format here
1193
		b = strstr(buff, "disk ");
1194
		sscanf(b,"disk %lu %lu %lu %lu",&noinfo1, &noinfo2, &noinfo3, &noinfo4);
1195
		b = strstr(buff, "disk_rio ");
1196
		sscanf(b,"disk_rio %lu %lu %lu %lu",&read_io1, &read_io2, &read_io3, &read_io4);
1197
		b = strstr(buff, "disk_wio ");
1198
		sscanf(b,"disk_wio %lu %lu %lu %lu",&write_io1, &write_io2, &write_io3, &write_io4);
1199
		b = strstr(buff, "disk_rblk ");
1200
		sscanf(b,"disk_rblk %lu %lu %lu %lu",&read_blks1,&read_blks2,&read_blks3,&read_blks4);
1201
		b = strstr(buff, "disk_wblk ");
1202
		sscanf(b,"disk_wblk %lu %lu %lu %lu",&write_blks1,&write_blks2,&write_blks3,&write_blks4);
1203
1204
		major = 0;
1205
		minor = 0;
1206
1207
		addDisk(STAT_PARENT, major, minor, noinfo1, read_io1, read_blks1, write_io1, write_blks1,'a');
1208
		addDisk(STAT_PARENT, major, minor, noinfo2, read_io2, read_blks2, write_io2, write_blks2,'b');
1209
		addDisk(STAT_PARENT, major, minor, noinfo3, read_io3, read_blks3, write_io3, write_blks3,'c');
1210
		addDisk(STAT_PARENT, major, minor, noinfo4, read_io4, read_blks4, write_io4, write_blks4,'d');
1211
1212
	}
1213
	else if (readFromFile("/proc/diskstats"))
1214
	{
1215
		long read_no, read_merge, read_sectors, read_milli, write_no, write_sectors, write_milli, iocount, iomilli, weighted, major, minor;
1216
1217
		char* name = malloc(sizeof(char)*128);
1218
1219
		b = buff;
1220
		while ((b[0] != '\0') && (b[0] != '\n'))
1221
		{
1222
			sscanf(b,"%u %u %s %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u",&major,&minor,name);
1223
			addNewDisk(STAT_PARENT, major, minor,name);
1224
1225
			b = strchr(b,'\n')+1;
1226
		}
1227
1228
		free(name); 	
1229
	}
1230
1231
  b = NULL;
1232
 
1233
	if (VERBOSE == TRUE) printf("*** out getDiskStatsInfoTree\n");
1234
} 
1235
1236
// Count the cpu number
1237
int processCpuCount()
1238
{
1239
  char* cpu = malloc(sizeof(char)*16);
1240
	int count = 0;
1241
1242
	// The format of the stats file is cpu#, starting from 0
1243
	// Lets count them up
1244
	
1245
	sprintf(cpu,"cpu%d",count);
1246
1247
	while (strstr(buff, cpu) != NULL)
1248
	{
1249
		count++;
1250
		sprintf(cpu,"cpu%d ",count);
1251
	}
1252
1253
	free(cpu);
1254
	return count;
1255
}
1256
1257
void getStatResults()  
1258
{
1259
	char* newpid = "/proc/stat";
1260
1261
  if (VERBOSE == TRUE) printf("*** in getStatResults\n");
1262
1263
 		if (readStatInfo()) 
1264
		{
1265
			getSysStatsInfoResults();
1266
1267
		  getDiskStatsInfoResults();
1268
		}
1269
		else 
1270
		{
1271
	   	crash("/proc/stat");
1272
	 	} /* end if */
1273
	if (VERBOSE == TRUE) printf("*** out getStatResults\n");
1274
}
1275
1276
1277
void getStatInfo( char* pid)  
1278
{
1279
	char* newpid = "/proc/stat";
1280
1281
  if (VERBOSE == TRUE) printf("*** in getStatInfo\n");
1282
1283
	addToTreeArray(pid, newpid, "${LINUX.AGENT.134}","${LINUX.AGENT.135}", "");	 
1284
1285
 	if (readStatInfo()) 
1286
	{
1287
		cpuCount = processCpuCount();
1288
1289
		getSysStatsInfoTree(newpid);
1290
		getDiskStatsInfoTree(pid);
1291
 	} 
1292
	else 
1293
   	crash("/proc/stat");
1294
1295
	if (VERBOSE == TRUE) printf("*** out getStatInfo\n");
1296
}
1297
1298
1299
/*************************************************************************************/
1300
// MEMINFO STUFF BELOW
1301
1302
void getMemInfoTree(char* parentid) 
1303
{
1304
	if (VERBOSE == TRUE) printf("*** in getMemInfo\n");
1305
1306
	addToTreeArray(parentid, MEM_PARENT, "${LINUX.AGENT.136}","${LINUX.AGENT.137}","");
1307
1308
	if (readMemInfo()) 
1309
	{
1310
			addToTreeArray(MEM_PARENT,MEM_PERC, "${LINUX.AGENT.138}", "${LINUX.AGENT.139}" ,"");
1311
			addToTreeArray(MEM_PARENT,MEM_SPERC, "${LINUX.AGENT.140}", "${LINUX.AGENT.141}" ,"");
1312
			addToTreeArray(MEM_PARENT,MEM_TOTAL, "${LINUX.AGENT.142}","${LINUX.AGENT.143}","");
1313
			addToTreeArray(MEM_PARENT,MEM_FREE, "${LINUX.AGENT.144}","${LINUX.AGENT.145}","");
1314
			addToTreeArray(MEM_PARENT,MEM_USED, "${LINUX.AGENT.146}","${LINUX.AGENT.147}","");
1315
			addToTreeArray(MEM_PARENT,MEM_SWAPT, "${LINUX.AGENT.148}","${LINUX.AGENT.149}","");
1316
			addToTreeArray(MEM_PARENT,MEM_SWAPF, "${LINUX.AGENT.150}","${LINUX.AGENT.151}","");
1317
			addToTreeArray(MEM_PARENT,MEM_SWAPU, "${LINUX.AGENT.152}","${LINUX.AGENT.153}","");
1318
			addToTreeArray(MEM_PARENT,MEM_CACHED, "${LINUX.AGENT.154}","${LINUX.AGENT.155}","");
1319
			addToTreeArray(MEM_PARENT,MEM_BUFFERS, "${LINUX.AGENT.156}","${LINUX.AGENT.157}","");
1320
	} 
1321
	else 
1322
		crash("/proc/meminfo");
1323
1324
	if (VERBOSE == TRUE) printf("*** out getMemInfo\n");
1325
} 
1326
1327
void getMemInfoResults()
1328
{
1329
	if (VERBOSE == TRUE) printf("*** in getMemInfoResults\n");
1330
1331
	if (tableGet(filtersHash, MEM_PARENT) != (XINT64) NULL)
1332
	{
1333
		char* resultString = malloc(sizeof(char) * 128);
1334
1335
		// Just return the memory info from /proc/meminfo - its pretty standard stuff.
1336
		// No need for caching here, as we are interested in the TOTAL :)
1337
		if (readMemInfo()) 
1338
		{
1339
			char* b;
1340
			long total, free;
1341
1342
  	  b = strstr(buff, "MemTotal:    ");
1343
	    sscanf(b, "MemTotal: %lu", &total);
1344
			if (tableGet(filtersHash, MEM_TOTAL) != (XINT64) NULL)
1345
				addLongCounter(total, MEM_TOTAL, resultString);
1346
			// Add the total memory to the currentvalues hash so that we can use it later.
1347
			tablePut(currentValues, MEM_TOTAL, (XINT64) total);
1348
1349
	    b = strstr(buff, "MemFree:    ");
1350
  	  sscanf(b, "MemFree: %lu", &free);
1351
			if (tableGet(filtersHash, MEM_FREE) != (XINT64) NULL)
1352
				addLongCounter(free, MEM_FREE, resultString);
1353
1354
			if (tableGet(filtersHash, MEM_USED) != (XINT64) NULL)
1355
				addLongCounter(total-free, MEM_USED, resultString);
1356
1357
			if (tableGet(filtersHash, MEM_PERC) != (XINT64) NULL)
1358
				addDoubleCounter((((double) (total-free))/((double) total))*100 ,MEM_PERC,resultString);
1359
	
1360
	    b = strstr(buff, "Buffers:  ");
1361
  	  sscanf(b, "Buffers: %u", &total);
1362
			if (tableGet(filtersHash, MEM_BUFFERS) != (XINT64) NULL)
1363
				addLongCounter(total, MEM_BUFFERS, resultString);
1364
1365
	    b = strstr(buff, "Cached:  ");
1366
	    sscanf(b, "Cached: %u", &total);
1367
			if (tableGet(filtersHash, MEM_CACHED) != (XINT64) NULL)
1368
				addLongCounter(total, MEM_CACHED, resultString);
1369
	
1370
	    b = strstr(buff, "SwapTotal:  ");
1371
  	  sscanf(b, "SwapTotal: %lu", &total);
1372
			if (tableGet(filtersHash, MEM_SWAPT) != (XINT64) NULL)
1373
				addLongCounter(total, MEM_SWAPT, resultString);
1374
	
1375
	    b = strstr(buff, "SwapFree:  ");
1376
  	  sscanf(b, "SwapFree: %u", &free);
1377
			if (tableGet(filtersHash, MEM_SWAPF) != (XINT64) NULL)
1378
				addLongCounter(free, MEM_SWAPF, resultString);
1379
1380
			if (tableGet(filtersHash, MEM_SWAPU) != (XINT64) NULL)
1381
				addLongCounter(total-free, MEM_SWAPU,resultString);
1382
1383
			if (tableGet(filtersHash, MEM_SPERC) != (XINT64) NULL)
1384
				addDoubleCounter((((double) (total-free))/((double) total))*100 ,MEM_SPERC,resultString);
1385
																																								     
1386
			b = NULL;
1387
		} 
1388
		else 
1389
			crash("/proc/meminfo");
1390
	
1391
		free(resultString);
1392
	}
1393
	if (VERBOSE == TRUE) printf("*** out getMemInfoResults\n");
1394
1395
}
1396
1397
/*************************************************************************************/
1398
// PROCESS METHODS
1399
// 
1400
void addProcessMemChild( int pid, char* parentid)
1401
{
1402
	char* id = malloc(sizeof(char) * 128);
1403
	char* memid = malloc(sizeof(char) * 128);
1404
	
1405
	sprintf(memid, "%s_%d%c",PROC_MEM,pid,'\0');
1406
	addToTreeArray(parentid, memid, "${LINUX.AGENT.158}", "${LINUX.AGENT.159}","");
1407
1408
	sprintf(id, "%s_%d%c",PROC_MEM_PERC,pid,'\0');
1409
	addToTreeArray(memid, id, "${LINUX.AGENT.160}","${LINUX.AGENT.161}","");
1410
1411
	sprintf(id,"%s_%d%c",PROC_MEM_SIZE,pid,'\0');
1412
	addToTreeArray(memid, id, "${LINUX.AGENT.162}","${LINUX.AGENT.163}","kb");
1413
	
1414
	sprintf(id,"%s_%d%c",PROC_MEM_RESIDENT,pid,'\0');
1415
	addToTreeArray(memid, id, "${LINUX.AGENT.164}","${LINUX.AGENT.165}","kb");
1416
1417
	sprintf(id,"%s_%d%c",PROC_MEM_SWAP,pid,'\0');
1418
	addToTreeArray(memid, id, "${LINUX.AGENT.166}","${LINUX.AGENT.167}","kb");	
1419
	
1420
	sprintf(id,"%s_%d%c",PROC_MEM_SHARE,pid,'\0');
1421
	addToTreeArray(memid, id, "${LINUX.AGENT.168}","${LINUX.AGENT.169}","kb");
1422
	
1423
	sprintf(id,"%s_%d%c",PROC_MEM_TRS,pid,'\0');
1424
	addToTreeArray(memid, id, "${LINUX.AGENT.170}","${LINUX.AGENT.171}","kb");
1425
	
1426
	sprintf(id,"%s_%d%c",PROC_MEM_DRS,pid,'\0');
1427
	addToTreeArray(memid, id, "${LINUX.AGENT.172}","${LINUX.AGENT.173}","kb");
1428
	
1429
	sprintf(id,"%s_%d%c",PROC_MEM_LRS,pid,'\0');
1430
	addToTreeArray(memid, id, "${LINUX.AGENT.174}","${LINUX.AGENT.175}","kb");
1431
1432
	sprintf(id,"%s_%d%c",PROC_MEM_DT,pid,'\0');
1433
	addToTreeArray(memid, id, "${LINUX.AGENT.176}","${LINUX.AGENT.177}","");
1434
	
1435
	sprintf(id, "%s_%d%c",PROC_MEM_MAJFLT,  pid,'\0');
1436
	addToTreeArray(memid, id,"${LINUX.AGENT.178}","${LINUX.AGENT.179}","");
1437
1438
	sprintf(id, "%s_%d%c",PROC_MEM_MINFLT, pid,'\0');
1439
	addToTreeArray(memid, id,"${LINUX.AGENT.180}", "${LINUX.AGENT.181}","");
1440
	
1441
	sprintf(id, "%s_%d%c",PROC_MEM_CMAJFLT, pid,'\0');
1442
	addToTreeArray(memid, id,"${LINUX.AGENT.182}","${LINUX.AGENT.183}","");
1443
	
1444
	sprintf(id, "%s_%d%c",PROC_MEM_CMINFLT,  pid,'\0');
1445
	addToTreeArray(memid, id,"${LINUX.AGENT.184}", "${LINUX.AGENT.185}","");
1446
1447
	sprintf(id, "%s_%d%c",PROC_MEM_NSWAP,  pid,'\0');
1448
	addToTreeArray(memid, id,"${LINUX.AGENT.186}", "${LINUX.AGENT.187}","");
1449
1450
	sprintf(id, "%s_%d%c",PROC_MEM_CNSWAP,  pid,'\0');
1451
	addToTreeArray(memid, id,"${LINUX.AGENT.188}", "${LINUX.AGENT.189}","");
1452
1453
	free(id);
1454
	free(memid);
1455
}
1456
1457
void addProcessOtherChild( int pid, char* parentid)
1458
{
1459
	char* otherid = malloc(sizeof(char) * 128);
1460
	char* id = malloc(sizeof(char) * 128);
1461
1462
	// First, add the Other tree node
1463
	sprintf(otherid, "%s_%d%c",PROC_OTHER,pid,'\0');
1464
	addToTreeArray(parentid, otherid, "${LINUX.AGENT.190}", "${LINUX.AGENT.191}","");
1465
	
1466
	sprintf(id, "%s_%d%c",PROC_OTHER_PID, pid, '\0');
1467
	addToTreeArray(otherid, id,"${LINUX.AGENT.192}", "${LINUX.AGENT.193}","");
1468
	
1469
	sprintf(id, "%s_%d%c",PROC_OTHER_PPID, pid, '\0');
1470
	addToTreeArray(otherid, id,"${LINUX.AGENT.194}", "${LINUX.AGENT.195}","");
1471
1472
	sprintf(id, "%s_%d%c",PROC_OTHER_PROCESSOR, pid, '\0');
1473
	addToTreeArray(otherid, id,"${LINUX.AGENT.196}", "${LINUX.AGENT.197}","");
1474
1475
	free(id);
1476
	free(otherid);
1477
1478
}
1479
1480
void addProcessCpuChild( int pid, char* parentid)
1481
{				
1482
	char* cpuid = malloc(sizeof(char) * 128);
1483
	char* id = malloc(sizeof(char) * 128);
1484
1485
	// First, add the CPU tree node
1486
	sprintf(cpuid, "%s_%d%c",PROC_CPU,pid,'\0');
1487
	addToTreeArray(parentid, cpuid, "${LINUX.AGENT.198}", "${LINUX.AGENT.199}","");
1488
1489
	sprintf(id, "%s_%d%c", PROC_CPU_BOTH, pid, '\0');
1490
	addToTreeArray(cpuid, id, "${LINUX.AGENT.200}", "${LINUX.AGENT.201}","");
1491
	
1492
	sprintf(id, "%s_%d%c",PROC_CPU_TIME, pid, '\0');
1493
	addToTreeArray(cpuid, id,"${LINUX.AGENT.202}", "${LINUX.AGENT.203}","");
1494
1495
	sprintf(id, "%s_%d%c",PROC_CPU_UTIME,   pid,'\0');
1496
	addToTreeArray(cpuid, id,"${LINUX.AGENT.204}", "${LINUX.AGENT.205}","");
1497
	
1498
	sprintf(id, "%s_%d%c",PROC_CPU_STIME,   pid,'\0');
1499
	addToTreeArray(cpuid, id,"${LINUX.AGENT.206}", "${LINUX.AGENT.207}","");
1500
	
1501
	sprintf(id, "%s_%d%c",PROC_CPU_CTIME,   pid,'\0');
1502
	addToTreeArray(cpuid, id,"${LINUX.AGENT.208}", "${LINUX.AGENT.209}","");
1503
	
1504
	sprintf(id, "%s_%d%c",PROC_CPU_CUTIME,  pid,'\0');
1505
	addToTreeArray(cpuid, id,"${LINUX.AGENT.210}", "${LINUX.AGENT.211}","");
1506
	
1507
	sprintf(id, "%s_%d%c",PROC_CPU_CSTIME,   pid,'\0');
1508
	addToTreeArray(cpuid, id,"${LINUX.AGENT.212}", "${LINUX.AGENT.213}","");
1509
	
1510
	free(id);
1511
	free(cpuid);
1512
}
1513
1514
void getProcessesTree( char* parentid)
1515
{
1516
	// return the tree of the processs' stat file, and statm files
1517
	static struct direct * ent;
1518
  static char filename[128];
1519
	static char executeName[128];
1520
	static int pid;
1521
  DIR * proc;
1522
	char* procParentID = malloc(sizeof(char)*128);
1523
	char* procName = malloc(sizeof(char) * 128);
1524
	char* strpid = malloc(sizeof(char)*128);
1525
1526
	if (VERBOSE == TRUE) printf("*** in getProcesses\n");
1527
1528
 	if ((proc = opendir("/proc")) == NULL) 
1529
		crash("/proc");
1530
1531
	// Lets add the process parent element to the resutls tree	
1532
	addToTreeArray(parentid, PROC_MAIN,"${LINUX.AGENT.214}","${LINUX.AGENT.215}","");
1533
1534
	// Read all the entries in the proc directory
1535
	while((ent = readdir(proc))) 
1536
	{
1537
		// Processes must have directories that start with a digit
1538
 		if (isdigit(ent->d_name[0])) 
1539
		{ 
1540
   		sprintf(filename, "/proc/%s/stat", ent->d_name);
1541
   		if (readProcInfo(filename)) 
1542
			{
1543
				sscanf(buff, "%d (%s) %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %*d %*d %*d %*d %*d %*d %*u %*u %*d %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u\n", &pid, executeName);
1544
1545
				executeName[strlen(executeName)-1] = '\0';
1546
1547
				// First, lets deal with the process tree node
1548
				sprintf(procParentID,"%s_%d%c",PROC_PARENT, pid,'\0');
1549
				sprintf(procName, "%s [%d]%c",executeName, pid,'\0');
1550
				sprintf(strpid, "%d%c",pid,'\0');
1551
				
1552
				// Add to the process Hash - this just keeps a record of all the processes that we have populated the tree
1553
				// with, and should be less expensive than processing ALL ids
1554
				tablePut(processHash, strpid,1);
1555
				addToTreeArray(PROC_MAIN, procParentID, procName,"","");
1556
				
1557
1558
				// Now lets deal with the children of the process node
1559
				addProcessCpuChild(pid, procParentID);
1560
   		
1561
				sprintf(filename, "/proc/%s/statm", ent->d_name);
1562
	   		if (readProcInfo(filename)) 
1563
				{								
1564
					sscanf(buff, "%*d %*d %*d %*d %*d %*d %*d");
1565
1566
					addProcessMemChild(pid, procParentID);
1567
				} 
1568
				addProcessOtherChild(pid, procParentID);
1569
			}
1570
		} 
1571
	} 	
1572
 	closedir(proc);
1573
1574
	free(procParentID);
1575
	free(procName);
1576
	free(strpid);
1577
1578
	if (VERBOSE == TRUE) printf("***out getProcessesTree\n");
1579
} 
1580
1581
// Add the other counter results here
1582
void addProcessOtherResults( char* pid,long lpid, long ppid, long processor)
1583
{
1584
	char* id = malloc(sizeof(char)*128);
1585
	char* resultString = malloc(sizeof(char) *  128);
1586
1587
	sprintf(id, "%s_%s%c",PROC_OTHER_PID, pid,'\0');
1588
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1589
		addLongCounter(lpid, id,resultString);
1590
	sprintf(id, "%s_%s%c",PROC_OTHER_PPID, pid,'\0');
1591
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1592
		addLongCounter(ppid, id,resultString);
1593
	sprintf(id, "%s_%s%c",PROC_OTHER_PROCESSOR, pid,'\0');
1594
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1595
		addLongCounter(processor, id,resultString);
1596
1597
	free(resultString);
1598
	free(id);
1599
}
1600
1601
1602
// Add the memopry specific stuff to the results tree for a specific process
1603
void addProcessMemResults(char* pid,long size,long resident,long share,long trs,long drs,long lrs,long dr)
1604
{
1605
	char* id = malloc(sizeof(char) * 128);	
1606
	char* resultString = malloc(sizeof(char) *  128);
1607
1608
	sprintf(id, "%s_%s%c",PROC_MEM_PERC,pid,'\0');
1609
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1610
	{
1611
		long total = (XINT64) tableGet(currentValues, MEM_TOTAL);
1612
		long res = resident*pageSize/1024;
1613
		double perc = ((double) res)/ ((double) total)*100;
1614
		addDoubleCounter(perc, id, resultString);
1615
	}
1616
1617
	sprintf(id, "%s_%s%c",PROC_MEM_SIZE, pid,'\0');
1618
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1619
		addLongCounter(size*pageSize/1024, id,resultString);
1620
	sprintf(id, "%s_%s%c",PROC_MEM_RESIDENT, pid,'\0');
1621
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1622
		addLongCounter(resident*pageSize/1024, id,resultString);
1623
	
1624
	sprintf(id, "%s_%s%c",PROC_MEM_SWAP, pid,'\0'); // SWAP = VIRT - RES = size - resident
1625
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1626
		addLongCounter((size - resident)*pageSize/1024, id,resultString);
1627
1628
	sprintf(id, "%s_%s%c",PROC_MEM_SHARE, pid,'\0');
1629
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1630
		addLongCounter(share*pageSize/1024, id,resultString);
1631
	sprintf(id, "%s_%s%c",PROC_MEM_TRS, pid,'\0');
1632
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1633
		addLongCounter(trs*pageSize/1024, id,resultString);
1634
	sprintf(id, "%s_%s%c",PROC_MEM_DRS, pid,'\0');
1635
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1636
		addLongCounter((drs+lrs)*pageSize/1024, id,resultString);
1637
	sprintf(id, "%s_%s%c",PROC_MEM_LRS, pid,'\0');
1638
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1639
		addLongCounter(lrs*pageSize/1024, id,resultString);
1640
	sprintf(id, "%s_%s%c",PROC_MEM_DT, pid,'\0');
1641
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1642
		addLongCounter(dr, id,resultString);
1643
1644
	free(id);
1645
	free(resultString);
1646
}
1647
1648
// Add Process Results method - covenience method to add the result children of a process node
1649
// Must check if the counters have been requested, and so much rebuild the specific keys
1650
// for this pid
1651
1652
void addProcessCounter( char* pid, char* id, char* mainid, long current, char* resultString)
1653
{
1654
	// Remove Caching with the comments below...
1655
1656
	sprintf(id, "%s_%s%c",mainid, pid,'\0');
1657
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1658
	{
1659
//		long prev = (long) tableGet(previousValues, id);
1660
//		if (prev == 0)
1661
//		{
1662
//			if (containsKey(previousValues, id) == TRUE)
1663
//				addLongCounter(current-prev, id,resultString);					}						
1664
//		else
1665
//			addLongCounter(current-prev, id,resultString);
1666
//		tablePut(previousValues,id,(XINT64) current);
1667
1668
// New line below
1669
		addLongCounter(current, id, resultString);
1670
	}
1671
}
1672
1673
long getProcessCounter( char* pid, char* idtemp, char* mainid, long current, long ptotal, char* resultString)
1674
{
1675
	long val, prev;
1676
	
1677
	sprintf(idtemp, "%s_%s%c",mainid,   pid,'\0');
1678
	if ((prev = tableGet(previousValues, idtemp)) == (XINT64) NULL) 
1679
		prev = 0;	
1680
	val = ((double) (current-prev)/ (double) ptotal)*100;
1681
	
1682
	if (tableGet(filtersHash, idtemp) != (XINT64) NULL)
1683
	{
1684
		if (prev != 0)
1685
			addDoubleCounter(val, idtemp,resultString);
1686
		else
1687
			if (containsKey(previousValues, idtemp) == TRUE)
1688
				addDoubleCounter(val, idtemp,resultString);
1689
	}
1690
1691
	// return -1 if this value should NOT be used for a CPU aggregate
1692
	if (prev == 0)
1693
		if (containsKey(previousValues, idtemp) == TRUE)
1694
		{
1695
			tablePut(previousValues,idtemp,(XINT64) current);
1696
			return val;
1697
		}
1698
		else
1699
		{
1700
			tablePut(previousValues,idtemp,(XINT64) current);
1701
			return -1;
1702
		}
1703
	tablePut(previousValues,idtemp,(XINT64) current);
1704
	
1705
	return val;
1706
}
1707
1708
void addProcessResults( char* pid,long minflt,long cminflt,long majflt,long cmajflt,long utime,long stime,long cutime,long cstime,long vsize,long rss,long nswap,long cnswap)
1709
{
1710
	char* id = malloc(sizeof(char) * 128);
1711
	char* idtemp = malloc(sizeof(char) * 128);
1712
	char* resultString = malloc(sizeof(char)*128);
1713
	long total = utime+stime;
1714
	long ctotal = cutime + cstime;
1715
	
1716
	addProcessCounter(pid, id, PROC_MEM_MINFLT, minflt, resultString);
1717
	addProcessCounter(pid, id, PROC_MEM_CMINFLT, cminflt, resultString);
1718
	addProcessCounter(pid, id, PROC_MEM_MAJFLT, majflt, resultString);
1719
	addProcessCounter(pid, id, PROC_MEM_CMAJFLT, cmajflt, resultString);
1720
1721
	sprintf(id, "%s_%s%c", PROC_CPU_BOTH, pid, '\0');
1722
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1723
	{
1724
		long prev, ptotal;
1725
		double val1, val2, val3, val4;
1726
1727
		ptotal = (XINT64) tableGet(currentValues, STAT_TOTAL);
1728
1729
		val1 = getProcessCounter(pid, idtemp, PROC_CPU_UTIME, utime, ptotal, resultString);
1730
		val2 = getProcessCounter(pid, idtemp, PROC_CPU_STIME, stime, ptotal, resultString);
1731
		val3 = getProcessCounter(pid, idtemp, PROC_CPU_CUTIME, cutime, ptotal, resultString);
1732
		val4 = getProcessCounter(pid, idtemp, PROC_CPU_CSTIME, cstime, ptotal, resultString);
1733
1734
		// If the accumulated counters have been requested then just return them below,
1735
		// as we already have computed all the values required.
1736
	  if (!(val1 == -1 || val2 == -1 || val3 == -1 || val4 == -1))
1737
	  {
1738
			sprintf(idtemp, "%s_%s%c", PROC_CPU_TIME, pid, '\0');
1739
			if (tableGet(filtersHash, idtemp) != (XINT64) NULL)
1740
				addDoubleCounter(val1+val2,idtemp, resultString);
1741
1742
			sprintf(idtemp, "%s_%s%c", PROC_CPU_CTIME, pid, '\0');
1743
			if (tableGet(filtersHash, idtemp) != (XINT64) NULL)
1744
				addDoubleCounter(val3+val4,idtemp, resultString);
1745
1746
			addDoubleCounter(val1+val2+val3+val4, id, resultString);
1747
		}
1748
	}
1749
	else
1750
	{
1751
1752
		sprintf(id, "%s_%s%c", PROC_CPU_TIME, pid, '\0');
1753
		if (tableGet(filtersHash, id) != (XINT64) NULL)
1754
		{
1755
			double val1, val2;
1756
			long ptotal = (XINT64) tableGet(currentValues, STAT_TOTAL);
1757
1758
			val1 = getProcessCounter(pid, idtemp, PROC_CPU_UTIME, utime, ptotal, resultString);
1759
			val2 = getProcessCounter(pid, idtemp, PROC_CPU_STIME, stime, ptotal, resultString);
1760
1761
			if (!(val1 == -1 || val2 == -1))
1762
			  addDoubleCounter(val1+val2, id, resultString);
1763
		}
1764
		else
1765
		{
1766
			long ptotal = (XINT64) tableGet(currentValues, STAT_TOTAL);
1767
1768
			getProcessCounter(pid, idtemp, PROC_CPU_UTIME, utime, ptotal, resultString);
1769
			getProcessCounter(pid, idtemp, PROC_CPU_STIME, utime, ptotal, resultString);
1770
		}
1771
1772
		sprintf(id, "%s_%s%c", PROC_CPU_CTIME, pid, '\0');
1773
		if (tableGet(filtersHash, id) != (XINT64) NULL)
1774
		{
1775
			double val1, val2;
1776
			long ptotal = (XINT64) tableGet(currentValues, STAT_TOTAL);
1777
1778
			val1 = getProcessCounter(pid, idtemp, PROC_CPU_CUTIME, utime, ptotal, resultString);
1779
			val2 = getProcessCounter(pid, idtemp, PROC_CPU_CSTIME, stime, ptotal, resultString);
1780
1781
			if (!(val1 == -1 || val2 == -1))
1782
				addDoubleCounter(val1+val2, id, resultString);
1783
		}
1784
		else
1785
		{
1786
			long ptotal = (XINT64) tableGet(currentValues, STAT_TOTAL);
1787
1788
			getProcessCounter(pid, idtemp, PROC_CPU_CUTIME, utime, ptotal, resultString);
1789
			getProcessCounter(pid, idtemp, PROC_CPU_CSTIME, utime, ptotal, resultString);
1790
		}
1791
	}
1792
1793
	sprintf(id, "%s_%s%c",PROC_VSIZE,     pid,'\0');
1794
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1795
		addLongCounter(vsize, id,resultString);
1796
	sprintf(id, "%s_%s%c",PROC_MEM_RSS,   pid,'\0');
1797
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1798
		addLongCounter(rss, id,resultString);
1799
	sprintf(id, "%s_%s%c",PROC_MEM_NSWAP,  pid,'\0');
1800
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1801
		addLongCounter(nswap, id,resultString);
1802
	sprintf(id, "%s_%s%c",PROC_MEM_CNSWAP,  pid,'\0');
1803
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1804
		addLongCounter(cnswap, id,resultString);
1805
1806
	free(id);
1807
	free(idtemp);
1808
	free(resultString);
1809
}
1810
1811
void getProcessesResults()
1812
{
1813
 // Get the results of the requested (if any) processes
1814
1815
	int pSize = 0;
1816
	int pLen = 128;
1817
	char** processes = malloc(sizeof(char*)*pLen);
1818
1819
	if (VERBOSE == TRUE) printf("*** in getProcessesResults\n");
1820
1821
	while (pLen <= (pSize = tableKeysAsList(processHash, processes, pLen)))
1822
	{
1823
		pLen = pLen * 2;
1824
		processes = realloc(processes, sizeof(char*)*pLen);
1825
	}
1826
1827
	if (pSize > 0)
1828
	{
1829
	  static char filename[128];
1830
		static char executeName[128];
1831
		char* procParentID = malloc(sizeof(char)*128);
1832
		char* procName = malloc(sizeof(char) * 128);
1833
		int i;
1834
		long minflt=0,cminflt=0,majflt=0,cmajflt=0,utime=0,stime=0,cutime=0,cstime=0,vsize=0,rss=0,nswap=0,cnswap=0;
1835
		long size, resident, share, trs, drs, lrs, dr, pid, ppid, processor;
1836
1837
		for (i=0; i<pSize; i++)
1838
		{
1839
			// Recreate the process key here,and then check if it has been requested
1840
			sprintf(procParentID,"%s_%s%c",PROC_PARENT, processes[i],'\0');
1841
1842
    	if (tableGet(filtersHash, procParentID) != (XINT64) NULL)
1843
			{
1844
  	 		sprintf(filename, "/proc/%s/stat", processes[i]);
1845
   			if (readProcInfo(filename)) 
1846
				{
1847
					sscanf(buff, "%d %*s %*c %d %*d %*d %*d %*d %*u %lu %lu %lu %lu %lu %lu %lu %lu %*d %*d %*u %*u %*d %lu %lu %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %lu %lu %*d %d",&pid, &ppid, &minflt,&cminflt,&majflt,&cmajflt,&utime,&stime,&cutime,&cstime,&vsize,&rss,&nswap,&cnswap, &processor);
1848
1849
					addProcessResults(processes[i],minflt,cminflt,majflt,cmajflt,utime,stime,cutime,cstime,vsize,rss,nswap,cnswap);
1850
												
1851
					sprintf(filename, "/proc/%s/statm", processes[i]);
1852
	   			if (readProcInfo(filename)) 
1853
					{
1854
						sscanf(buff, "%d %d %d %d %d %d %d",&size,&resident,&share,&trs,&drs,&lrs,&dr);
1855
						addProcessMemResults(processes[i],size,resident,share,trs,drs,lrs,dr);
1856
					}
1857
					addProcessOtherResults(processes[i],pid, ppid, processor);
1858
				}
1859
			} 
1860
		} 	
1861
1862
		free(procParentID);
1863
		free(procName);
1864
	}
1865
1866
	free(processes);
1867
1868
	if (VERBOSE == TRUE) printf("***out getProcesses\n");
1869
} 
1870
1871
/*************************************************************************************/
1872
// NET METHODS
1873
1874
void addNetInterface(char* parentid, char** bstr)
1875
{
1876
	char* b = *bstr;
1877
	char* name = malloc(sizeof(char) * 128);
1878
	char* temp = malloc(sizeof(char) * 128);
1879
	char* interfaceid = malloc(sizeof(char) * 128);
1880
	char* id = malloc(sizeof(char) * 128);
1881
	int i=0;
1882
1883
	while (b[i] != ':')
1884
		i++;
1885
1886
	b[i] = '\0';
1887
	sprintf(temp, "%s%c",b,'\0');
1888
	sscanf(temp, "%s",name);
1889
	b = b+(sizeof(char)*(i+1));
1890
1891
	// Firstly, lets add the interface node
1892
	sprintf(interfaceid,"%s_%s%c",NET_INTERFACE,name,'\0');
1893
	addToTreeArray(parentid, interfaceid, name,"${LINUX.AGENT.216}","");
1894
1895
	sprintf(id,"%s_%s%c",NET_RBYTES,name,'\0');
1896
	addToTreeArray(interfaceid, id, "${MySQL.AGENT.217}","${LINUX.AGENT.218}","");
1897
1898
	sprintf(id,"%s_%s%c",NET_RPACKETS,name,'\0');
1899
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.219}","${LINUX.AGENT.220}","");
1900
	
1901
	sprintf(id,"%s_%s%c",NET_RERRS,name,'\0');
1902
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.221}","${LINUX.AGENT.222}","");
1903
	
1904
	sprintf(id,"%s_%s%c",NET_RDROP,name,'\0');
1905
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.223}","${LINUX.AGENT.224}","");
1906
	
1907
	sprintf(id,"%s_%s%c",NET_RFIFO,name,'\0');
1908
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.225}","${LINUX.AGENT.226}","");
1909
	
1910
	sprintf(id,"%s_%s%c",NET_RFRAME,name,'\0');
1911
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.227}","${LINUX.AGENT.228}","");
1912
	
1913
	sprintf(id,"%s_%s%c",NET_RCOMPRESSED,name,'\0');
1914
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.229}","${LINUX.AGENT.230}","");
1915
	
1916
	sprintf(id,"%s_%s%c",NET_RMULTICAST,name,'\0');
1917
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.231}","${LINUX.AGENT.232}","");
1918
	
1919
	sprintf(id,"%s_%s%c",NET_TBYTES,name,'\0');
1920
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.233}","${LINUX.AGENT.234}","");
1921
	
1922
	sprintf(id,"%s_%s%c",NET_TPACKETS,name,'\0');
1923
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.235}","${LINUX.AGENT.236}","");
1924
	
1925
	sprintf(id,"%s_%s%c",NET_TERRS,name,'\0');
1926
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.237}","${LINUX.AGENT.238}","");
1927
	
1928
	sprintf(id,"%s_%s%c",NET_TDROP,name,'\0');
1929
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.239}","${LINUX.AGENT.240}","");
1930
	
1931
	sprintf(id,"%s_%s%c",NET_TFIFO,name,'\0');
1932
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.241}","${LINUX.AGENT.242}","");
1933
	
1934
	sprintf(id,"%s_%s%c",NET_TCOLLISIONS,name,'\0');
1935
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.243}","${LINUX.AGENT.244}","");
1936
	
1937
	sprintf(id,"%s_%s%c",NET_TCARRIER,name,'\0');
1938
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.245}","${LINUX.AGENT.246}","");
1939
	
1940
	sprintf(id,"%s_%s%c",NET_TCOMPRESSED,name,'\0');
1941
	addToTreeArray(interfaceid, id, "${LINUX.AGENT.247}","${LINUX.AGENT.248}","");
1942
1943
	free(id);
1944
	free(interfaceid);
1945
	free(temp);
1946
	free(name);
1947
	*bstr = b;
1948
}
1949
1950
void getNetInterfaceResults( char** bstr)
1951
{
1952
	char* b = *bstr;
1953
	char* name = malloc(sizeof(char) * 128);
1954
	char* temp = malloc(sizeof(char) * 128);
1955
	char* id = malloc(sizeof(char) * 128);
1956
	char* resultString = malloc(sizeof(char) * 128);
1957
	long rbytes, rpackets, rerrs, rdrop, rfifo, rframe, rcompressed, rmulticast;
1958
	long tbytes, tpackets, terrs, tdrop, tfifo, tcollisions, tcarrier, tcompressed;
1959
	int i=0;
1960
1961
	while (b[i] != ':')
1962
		i++;
1963
1964
	b[i] = '\0';
1965
	sprintf(temp, "%s%c",b,'\0');
1966
	sscanf(temp, "%s",name);
1967
	b = b+(sizeof(char)*(i+1));
1968
1969
	sscanf(b, "%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu", &rbytes, &rpackets, &rerrs, &rdrop, &rfifo, &rframe, &rcompressed, &rmulticast, &tbytes, &tpackets, &terrs, &tdrop, &tfifo, &tcollisions, &tcarrier, &tcompressed);
1970
1971
	sprintf(id,"%s_%s%c",NET_RBYTES,name,'\0');
1972
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1973
		addLongCounter(rbytes,id,resultString);
1974
										
1975
	sprintf(id,"%s_%s%c",NET_RPACKETS,name,'\0');
1976
	if (tableGet(filtersHash, id) != (XINT64) NULL)
1977
		addLongCounter(rpackets,id,resultString);
1978
1979
	sprintf(id,"%s_%s%c",NET_RERRS,name,'\0');
1980
	if (tableGet(filtersHash, id) != (XINT64)NULL)
1981
		addLongCounter(rerrs,id,resultString);
1982
1983
	sprintf(id,"%s_%s%c",NET_RDROP,name,'\0');
1984
	if (tableGet(filtersHash, id) != (XINT64)NULL)
1985
		addLongCounter(rdrop,id,resultString);
1986
1987
	sprintf(id,"%s_%s%c",NET_RFIFO,name,'\0');
1988
	if (tableGet(filtersHash, id) != (XINT64)NULL)
1989
		addLongCounter(rfifo,id,resultString);
1990
1991
	sprintf(id,"%s_%s%c",NET_RFRAME,name,'\0');
1992
	if (tableGet(filtersHash, id) != (XINT64)NULL)
1993
		addLongCounter(rframe,id,resultString);
1994
1995
	sprintf(id,"%s_%s%c",NET_RCOMPRESSED,name,'\0');
1996
	if (tableGet(filtersHash, id) != (XINT64)NULL)
1997
		addLongCounter(rcompressed,id,resultString);
1998
1999
	sprintf(id,"%s_%s%c",NET_RMULTICAST,name,'\0');
2000
	if (tableGet(filtersHash, id) != (XINT64)NULL)
2001
		addLongCounter(rmulticast,id,resultString);
2002
2003
	sprintf(id,"%s_%s%c",NET_TBYTES,name,'\0');
2004
	if (tableGet(filtersHash, id) != (XINT64)NULL)
2005
		addLongCounter(tbytes,id,resultString);
2006
2007
	sprintf(id,"%s_%s%c",NET_TPACKETS,name,'\0');
2008
	if (tableGet(filtersHash, id) != (XINT64)NULL)
2009
		addLongCounter(tpackets,id,resultString);
2010
2011
	sprintf(id,"%s_%s%c",NET_TERRS,name,'\0');
2012
	if (tableGet(filtersHash, id) != (XINT64)NULL)
2013
		addLongCounter(terrs,id,resultString);
2014
2015
	sprintf(id,"%s_%s%c",NET_TDROP,name,'\0');
2016
	if (tableGet(filtersHash, id) != (XINT64)NULL)
2017
		addLongCounter(tdrop,id,resultString);
2018
2019
	sprintf(id,"%s_%s%c",NET_TFIFO,name,'\0');
2020
	if (tableGet(filtersHash, id) != (XINT64)NULL)
2021
		addLongCounter(tfifo,id,resultString);
2022
2023
	sprintf(id,"%s_%s%c",NET_TCOLLISIONS,name,'\0');
2024
	if (tableGet(filtersHash, id) != (XINT64)NULL)
2025
		addLongCounter(tcollisions,id,resultString);
2026
2027
	sprintf(id,"%s_%s%c",NET_TCARRIER,name,'\0');
2028
	if (tableGet(filtersHash, id) != (XINT64)NULL)
2029
		addLongCounter(tcarrier,id,resultString);
2030
2031
	sprintf(id,"%s_%s%c",NET_TCOMPRESSED,name,'\0');
2032
	if (tableGet(filtersHash, id) != (XINT64)NULL)
2033
		addLongCounter(tcompressed,id,resultString);
2034
2035
	free(id);
2036
	free(temp);
2037
	free(name);
2038
	free(resultString);
2039
	*bstr = b;
2040
}
2041
2042
void getNetInfoResults()
2043
{
2044
	if (VERBOSE == TRUE) printf("*** in getNetInfoResults\n");
2045
2046
	if (readNetDevInfo()) 
2047
	{
2048
		char *b, *btemp = NULL;
2049
		char* name = malloc(sizeof(char)*32);
2050
		int i = 0;
2051
2052
		// Parse the buffer and add each interface to the disk
2053
		// Delete the first two lines - they are headings, and useless
2054
		b = strstr(buff,"\n");
2055
		b++;
2056
		b = strstr(b,"\n");
2057
		b++;
2058
		while (b != NULL && b[0] != '\0')
2059
		{
2060
			if (strchr(b,':') == NULL)
2061
				break;
2062
			getNetInterfaceResults(&b);
2063
2064
			if (b[0] == '\0')
2065
				break;
2066
2067
			b = strchr(b,'\n');
2068
		}
2069
		free(name);
2070
	}	
2071
	else
2072
	  crash("/proc/net");
2073
	
2074
	if (VERBOSE == TRUE) printf("*** out getNetInfoResults\n");
2075
}
2076
2077
void getNetInfoTree( char* parentid)
2078
{
2079
	if (VERBOSE == TRUE) printf("*** in getNetInfoTree\n");
2080
2081
	if (readNetDevInfo()) 
2082
	{
2083
		char *b, *btemp = NULL;
2084
		char* name = malloc(sizeof(char)*32);
2085
		int i = 0;
2086
2087
		addToTreeArray(parentid, "/proc/net", "${LINUX.AGENT.250}","${LINUX.AGENT.251}","");		
2088
2089
		// Parse the buffer and add each interface to the disk
2090
		// Delete the first two lines - they are headings, and useless
2091
		b = strstr(buff,"\n");
2092
		b++;
2093
		b = strstr(b,"\n");
2094
		b++;
2095
2096
		while (b[0] != '\0')
2097
		{
2098
			if (strchr(b,':') == NULL)
2099
				break;
2100
2101
			addNetInterface("/proc/net", &b);
2102
			if (b[0] == '\0')
2103
				break;
2104
2105
			b = strchr(b,'\n');
2106
		}
2107
		free(name);
2108
	}	
2109
	else
2110
	  crash("/proc/net");
2111
2112
	if (VERBOSE == TRUE) printf("*** out getNetInfoTree\n");
2113
}
2114
2115
/*************************************************************************************/
2116
2117
void freeArray()
2118
{
2119
	int i;
2120
	if (max != 0)
2121
	{
2122
//		printf("about to free array : size = %d, max = %d\n",size,max);
2123
		for (i=0;i<size;i++)
2124
			free(results[i]);
2125
		free(results);	
2126
		max = 0;
2127
		size = 0;
2128
		results = NULL;
2129
	}
2130
}
2131
2132
void getResults()
2133
{
2134
	getLinuxResults();
2135
}
2136
2137
void getTree() 
2138
{
2139
	getLinuxTree();
2140
} /* end getStats */
2141
2142
2143
char** DC_CollectionGetTree	(int* numresults)
2144
{
2145
	freeArray();
2146
	getTree();
2147
	*numresults = size;
2148
	max = 0;
2149
	size = 0;
2150
	return results;
2151
}
2152
2153
char** DC_CollectionGetResults (int* numresults)
2154
{
2155
	freeArray();
2156
	getResults();
2157
	*numresults = size;
2158
	return results;
2159
}
2160
2161
int DC_CollectionStartup(HashTable* hasht_variables, HashTable* hasht_filters, HashTable* hasht_tree)
2162
{
2163
	variablesHash = hasht_variables;
2164
	filtersHash = hasht_filters;
2165
	treeHash = hasht_tree;
2166
	previousValues = tableCreate();
2167
	processHash = tableCreate();
2168
	currentValues = tableCreate();
2169
2170
  	pageSize = getpagesize();
2171
2172
	buff = malloc(sizeof(char) * buflen);
2173
								
2174
	return 0;
2175
}
2176
2177
int DC_CollectionShutdown()
2178
{
2179
	tableDelete(previousValues);	
2180
	tableDelete(processHash);
2181
	tableDelete(currentValues);
2182
2183
	free(buff);
2184
2185
	return 0;
2186
}
2187
2188
char* DC_CollectionGetAgentName()
2189
{
2190
	return agent_type;
2191
}
(-)src-native-new/src/agents/native/java_profiler/binary_print.h (+98 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: binary_print.h,v 1.2 2005/02/25 22:17:34 hleung Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef BINARY_PRINT_H
14
#define BINARY_PRINT_H
15
16
extern void BINARYTRACE_printUnknownRoot(ThreadLocalStorage* tps,
17
				    ObjectEntry*        unknown);
18
extern void BINARYTRACE_printJNIGlobalRoot(ThreadLocalStorage* tps,
19
				      ObjectEntry*        parent,
20
				      ObjectEntry*        child);
21
extern void BINARYTRACE_printJNILocalRoot(ThreadLocalStorage* tps,
22
				     ObjectEntry*        object,
23
				     ThreadLocalStorage* localToThisThread,
24
				     int stackDepth);
25
extern void BINARYTRACE_printJavaStackRoot(ThreadLocalStorage* tps,
26
				      ThreadLocalStorage* rootedToThisThread,
27
				      ObjectEntry*        object,
28
				      int                 depth);
29
extern void BINARYTRACE_printNativeStackRoot(ThreadLocalStorage* tps,
30
					ThreadLocalStorage* rootedToThisThread,
31
					ObjectEntry*        object);
32
extern void BINARYTRACE_printStickyClassRoot(ThreadLocalStorage* tps,
33
					ObjectEntry*        clazzObject);
34
extern void BINARYTRACE_printThreadRoot(ThreadLocalStorage* tps,
35
				   ThreadLocalStorage* theThread,
36
				   ObjectEntry*        theThreadObject);
37
extern void BINARYTRACE_printMonitorRoot(ThreadLocalStorage* tps,
38
				    ObjectEntry*        monitorObject);
39
40
extern void BINARYTRACE_printGeneration(ThreadLocalStorage* tps);
41
extern unsigned short BINARYTRACE_printArrayReference(char* buffer,
42
						 unsigned long parentOID,
43
						 unsigned long childOID);
44
unsigned short BINARYTRACE_printClassReference(char* buffer,
45
					  unsigned long parentCID,
46
					  unsigned long childOID);
47
extern unsigned short BINARYTRACE_printObjectReference(char* buffer,
48
						  unsigned long parentOID,
49
						  unsigned long childOID);
50
extern void BINARYTRACE_printBOB(ThreadLocalStorage* tps);
51
extern void BINARYTRACE_printEOB(ThreadLocalStorage* tps);
52
extern void BINARYTRACE_printFields(ThreadLocalStorage* tps,
53
			       ClassEntry* classEntry,
54
			       jint        numFields,
55
			       int         startIndex,
56
			       PI_Field*   fields,
57
			       BOOL        isStatic);
58
extern unsigned short BINARYTRACE_printClassDefine(char*       buffer,
59
					      ClassEntry* classEntry);
60
extern unsigned short BINARYTRACE_printClassLoad(char*       buffer,
61
					    ClassEntry* classEntry);
62
extern unsigned short BINARYTRACE_printMethodDefine(char*        buffer,
63
					       MethodEntry* methodEntry);
64
extern unsigned short BINARYTRACE_printMethodEnter(char*          buffer,
65
					      StackEntry*    stackEntry);
66
unsigned short BINARYTRACE_printMethodExit(char*               buffer,
67
				      ThreadLocalStorage* tps,
68
				      timestamp_t timeJustAfterGotControl);
69
extern unsigned short BINARYTRACE_appendTimestamp(char*           buffer,
70
					     unsigned short  offset,
71
					     timestamp_t*    time);
72
73
extern unsigned short BINARYTRACE_printThreadStart(char*               buffer,
74
					      ThreadLocalStorage* tps);
75
extern unsigned short BINARYTRACE_printObjectFree(char*      buffer,
76
					     HashEntry* objectHashEntry);
77
extern unsigned short
78
BINARYTRACE_printWitnessedObjectAllocation(char*                 buffer,
79
				      ThreadPrivateStorage* creatingThread,
80
				      HashEntry*            objectHashEntry,
81
				      HashEntry*            classHashEntry,
82
				      timestamp_t           allocTime);
83
extern unsigned short BINARYTRACE_printObjectAllocation(char*      buffer,
84
						   HashEntry* objectHashEntry,
85
						   HashEntry* classHashEntry);
86
extern unsigned short BINARYTRACE_printClassUnload(char* buffer,
87
					      HashEntry* classHashEntry);
88
extern unsigned short BINARYTRACE_printThreadEnd(char*               buffer,
89
					    ThreadLocalStorage* tps);
90
extern unsigned short BINARYTRACE_printGcStart(char* buffer);
91
extern unsigned short BINARYTRACE_printGcFinish(char* buffer);
92
extern unsigned short BINARYTRACE_printEndOfXMLHeader(char* buffer);
93
extern void BINARYTRACE_printTraceHeader(ThreadLocalStorage* tps);
94
extern void BINARYTRACE_printTraceEnd(ThreadLocalStorage* tps);
95
96
/* #include "watson_fieldvalues.h" */
97
98
#endif /* BINARY_PRINT_H */
(-)src-native-new/src/agents/perfmon/sysperf/perfcontrol.h (+25 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: perfcontrol.h,v 1.3 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
14
15
#ifndef __PERFCONTROL_H__
16
#define __PERFCONTROL_H__
17
18
#include "hashtable.h"
19
#include "system.h"
20
#include "DataCollectionInterface.h"
21
22
void printout(char** data,int numstrings);
23
void cleardata(char** data,int numstrings);
24
25
#endif
(-)src-native-new/src/agents/native/java_profiler/binary_print.c (+1171 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: binary_print.c,v 1.2 2005/02/25 22:17:34 hleung Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
#ifdef BINARY_TRACE
13
14
#include "hash.h"
15
#include "binarytrace.h"
16
#include "binary_privates.h"
17
#include "binary_print.h"
18
19
#if 0
20
#define BINARYTRACE_DEBUG(buffer, msg) \
21
  memcpy(buffer, msg, strlen(msg));\
22
  buffer += strlen(msg);
23
#else
24
#define BINARYTRACE_DEBUG(buffer, msg)
25
#endif
26
27
static inline char jvmpi_to_jni(char jvmpi_type) {
28
  switch(jvmpi_type) {
29
  case JVMPI_BYTE:
30
    return SIGNATURE_BYTE;
31
  case JVMPI_BOOLEAN:
32
    return SIGNATURE_BOOLEAN;
33
  case JVMPI_CHAR:
34
    return SIGNATURE_CHAR;
35
  case JVMPI_SHORT:
36
    return SIGNATURE_SHORT;
37
  case JVMPI_INT:
38
    return SIGNATURE_INT;
39
  case JVMPI_FLOAT:
40
    return SIGNATURE_FLOAT;
41
  case JVMPI_LONG:
42
    return SIGNATURE_LONG;
43
  case JVMPI_DOUBLE:
44
    return SIGNATURE_DOUBLE;
45
  case JVMPI_CLASS:
46
    return SIGNATURE_CLASS;
47
  default:
48
    assert(0);
49
    return 0;
50
  }
51
}
52
53
inline void prof_fill_u1(char* cursor,
54
			 char  data)
55
{
56
  *cursor = data;
57
}
58
inline void prof_fill_boolean(char* cursor,
59
			      BOOL  data)
60
{
61
  prof_fill_u1(cursor, data ? 1 : 0);
62
}
63
inline void prof_fill_EventType(char*         cursor,
64
				jsEventType_t event)
65
{
66
  prof_fill_u1(cursor, event);
67
}
68
inline void prof_fill_u2(char* cursor,
69
			 short data)
70
{
71
#ifdef NEED_ALIGNMENT
72
  memcpy((void*)cursor, (void*)&data, sizeof(short));
73
#else
74
  short* buf = (short*)cursor;
75
  *buf = data;
76
#endif /* NEED_ALIGNMENT */
77
}
78
inline void prof_fill_u4(char*   cursor,
79
			 int32_t data)
80
{
81
#ifdef NEED_ALIGNMENT
82
  memcpy((void*)cursor, (void*)&data, sizeof(int32_t));
83
#else
84
  int32_t* buf = (int32_t*)cursor;
85
  *buf = data;
86
#endif /* NEED_ALIGNMENT */
87
}
88
inline void prof_fill_float(char* cursor,
89
			    float data)
90
{
91
#ifdef NEED_ALIGNMENT
92
  memcpy((void*)cursor, (void*)&data, sizeof(float));
93
#else
94
  float* buf = (float*)cursor;
95
  *buf = data;
96
#endif /* NEED_ALIGNMENT */
97
}
98
inline void prof_fill_double(char*  cursor,
99
			     double data)
100
{
101
#ifdef NEED_ALIGNMENT
102
  memcpy((void*)cursor, (void*)&data, sizeof(double));
103
#else
104
  double* buf = (double*)cursor;
105
  *buf = data;
106
#endif /* NEED_ALIGNMENT */
107
}
108
inline void prof_fill_u8(char*   cursor,
109
			 int64_t data)
110
{
111
#ifdef NEED_ALIGNMENT
112
  memcpy((void*)cursor, (void*)&data, sizeof(int64_t));
113
#else
114
  int64_t* buf = (int64_t*)cursor;
115
  *buf = data;
116
#endif /* NEED_ALIGNMENT */
117
}
118
inline void prof_fill_timestamp(char*       cursor,
119
				timestamp_t time)
120
{
121
#ifdef SMURF
122
  uint64_t longy = time->seconds;
123
  longy *= 1000000;
124
  longy += time->microseconds;
125
#else
126
  uint64_t longy = time;
127
#endif
128
129
  /*fprintf(stderr, "%d %llu\n", sizeof(int64_t), longy);*/
130
  prof_fill_u8(cursor, longy);
131
}
132
inline void prof_fill_current_timestamp(char* cursor)
133
{
134
  timestamp_t now;
135
  jvmpiAgent_getCurrentTime(&now);
136
  prof_fill_timestamp(cursor, now);
137
}
138
inline void prof_fill_TID(char*                 cursor,
139
			  ThreadPrivateStorage* tps)
140
{
141
  jsThreadID_t data = tps->staticThreadId;
142
#ifdef NEED_ALIGNMENT
143
  memcpy((void*)cursor, (void*)&data, sizeof(jsThreadID_t));
144
#else
145
  jsThreadID_t* buf = (jsThreadID_t*)cursor;
146
  *buf = data;
147
#endif /* NEED_ALIGNMENT */
148
}
149
inline void prof_fill_OID(char*        cursor,
150
			  jsObjectID_t data)
151
{
152
  prof_fill_u4(cursor, data);
153
}
154
inline void prof_fill_CID(char*       cursor,
155
			  jsClassID_t data)
156
{
157
  prof_fill_u4(cursor, data);
158
}
159
inline void prof_fill_MID(char*        cursor,
160
			  jsMethodID_t data)
161
{
162
  prof_fill_u4(cursor, data);
163
}
164
inline unsigned short prof_fill_string(char*       cursor,
165
				       const char* string)
166
{
167
  int len = strlen(string);
168
169
  prof_fill_u2(cursor, len);
170
  cursor += 2;
171
172
  memcpy(cursor, string, len);
173
174
  return (unsigned short)len+2;
175
}
176
_inline void prof_fill_ValueTypeTag(char* cursor, jsValueTypeTag_t type)
177
{
178
  prof_fill_u1(cursor, type);
179
}
180
_inline char* prof_fill_byteValue(char* cursor, jsByteValue_t b)
181
{
182
  prof_fill_ValueTypeTag(cursor, SIGNATURE_BYTE);
183
  cursor += sizeof(jsValueTypeTag_t);
184
185
  prof_fill_u1(cursor, b);
186
  cursor += sizeof(jsByteValue_t);
187
188
  return cursor;
189
}
190
_inline char* prof_fill_booleanValue(char* cursor, jsBooleanValue_t b)
191
{
192
  prof_fill_ValueTypeTag(cursor, SIGNATURE_BOOLEAN);
193
  cursor += sizeof(jsValueTypeTag_t);
194
195
  prof_fill_boolean(cursor, b);
196
  cursor += sizeof(jsBooleanValue_t);
197
198
  return cursor;
199
}
200
_inline char* prof_fill_charValue(char* cursor, jsCharValue_t c)
201
{
202
  prof_fill_ValueTypeTag(cursor, SIGNATURE_CHAR);
203
  cursor += sizeof(jsValueTypeTag_t);
204
205
  prof_fill_u2(cursor, c);
206
  cursor += sizeof(jsCharValue_t);
207
208
  return cursor;
209
}
210
_inline char* prof_fill_shortValue(char* cursor, jsShortValue_t s)
211
{
212
  prof_fill_ValueTypeTag(cursor, SIGNATURE_SHORT);
213
  cursor += sizeof(jsValueTypeTag_t);
214
215
  prof_fill_u2(cursor, s);
216
  cursor += sizeof(jsShortValue_t);
217
218
  return cursor;
219
}
220
_inline char* prof_fill_intValue(char* cursor, jsIntValue_t i)
221
{
222
  prof_fill_ValueTypeTag(cursor, SIGNATURE_INT);
223
  cursor += sizeof(jsValueTypeTag_t);
224
225
  prof_fill_u4(cursor, i);
226
  cursor += sizeof(jsIntValue_t);
227
228
  return cursor;
229
}
230
_inline char* prof_fill_floatValue(char* cursor, jsFloatValue_t f)
231
{
232
  prof_fill_ValueTypeTag(cursor, SIGNATURE_FLOAT);
233
  cursor += sizeof(jsValueTypeTag_t);
234
235
  prof_fill_float(cursor, f);
236
  cursor += sizeof(jsFloatValue_t);
237
238
  return cursor;
239
}
240
_inline char* prof_fill_doubleValue(char* cursor, jsDoubleValue_t d)
241
{
242
  prof_fill_ValueTypeTag(cursor, SIGNATURE_DOUBLE);
243
  cursor += sizeof(jsValueTypeTag_t);
244
245
  prof_fill_double(cursor, d);
246
  cursor += sizeof(jsDoubleValue_t);
247
248
  return cursor;
249
}
250
_inline char* prof_fill_longValue(char* cursor, jsLongValue_t l)
251
{
252
  prof_fill_ValueTypeTag(cursor, SIGNATURE_LONG);
253
  cursor += sizeof(jsValueTypeTag_t);
254
255
  prof_fill_u8(cursor, l);
256
  cursor += sizeof(jsLongValue_t);
257
258
  return cursor;
259
}
260
261
262
/* hack for missing access bits: */
263
const short ACCESS_DEFAULT = 0x0000;
264
const short ACCESS_STATIC  = 0x0008;
265
266
#ifdef NEVER
267
/* left this in temporarily because it is used by some code that's ifdef'd out.
268
 * Find out from Richard if we can pull the other dead code. see printInterfaces. */
269
270
static _inline void printClassId(char* buffer, jobjectID clazz)
271
{
272
  HashEntry *classHashEntry = jvmpiAgent_FindSymbol((jint)clazz, Class_t);
273
  if(classHashEntry == NULL) {
274
    prof_fill_CID(buffer, NULL_CID);
275
  }
276
  else {
277
    prof_fill_CID(buffer, CLASS_ENTRY(classHashEntry)->static_id);
278
  }
279
}
280
#endif /* NEVER */
281
282
void BINARYTRACE_printFields(ThreadLocalStorage* tps,
283
			ClassEntry* classEntry,
284
			jint        numFields,
285
			int         startIndex,
286
			PI_Field*   fields,
287
			BOOL        isStatic) /* hack since don't have access bits*/
288
{
289
  char*     buffer = tps->buffer;
290
  char* bufferOrig = buffer;
291
  int i;
292
293
  for(i=0; i<numFields; i++) {
294
    buffer = bufferOrig;
295
296
    /* 1. event type */
297
    prof_fill_EventType(buffer, FieldDefine);
298
    buffer += sizeof(jsEventType_t);
299
300
    /* 2. class cid */
301
    prof_fill_CID(buffer, classEntry->static_id);
302
    buffer += sizeof(jsClassID_t);
303
304
    /* 3. field index */
305
    prof_fill_u4(buffer, i+startIndex);
306
    buffer += 4;
307
308
    /* 3. field id */
309
    prof_fill_u4(buffer, fields[i].fieldId);
310
    buffer += 4;
311
312
    /* 4. field name */
313
    buffer += prof_fill_string(buffer, fields[i].field_name);
314
315
    /* 5. field signature */
316
    buffer += prof_fill_string(buffer, fields[i].field_signature);
317
318
    /* 6. field access */
319
    prof_fill_u2(buffer, isStatic ? ACCESS_STATIC : ACCESS_DEFAULT); /* hacko */
320
    buffer += 2;
321
322
    jvmpiAgent_print(tps, tps->buffer, buffer-bufferOrig);
323
  }
324
}
325
326
unsigned short printInterfaces(char*       buffer,
327
			       ClassEntry* classEntry)
328
{
329
#ifdef NEVER
330
	/* What are we saving this for? */
331
  char *bufferOrig = buffer;
332
  int i;
333
334
 prof_fill_u2(buffer, classEntry->numInterfaces);
335
  buffer += 2;
336
337
  for(i=0; i<classEntry->numInterfaces; i++) {
338
    jobjectID interface = classEntry->interfaces[i];
339
    printClassId(buffer, interface);
340
    buffer += sizeof(jsClassID_t);
341
  }
342
343
  return buffer - bufferOrig;
344
#else /* NEVER */
345
  return 0;
346
#endif /* NEVER */
347
}
348
349
unsigned short BINARYTRACE_printClassDefine(char*       buffer,
350
				       ClassEntry* classEntry)
351
{
352
  /* 1. event type */
353
  prof_fill_EventType(buffer, ClassDefine);
354
  buffer += sizeof(jsEventType_t);
355
356
  /* 2. timestamp of the classload */
357
  if(_jvmpiAgent_Options.timestamp) {
358
    prof_fill_timestamp(buffer, classEntry->timestamp);
359
  }
360
  else {
361
    prof_fill_current_timestamp(buffer);
362
  }
363
  buffer += sizeof(jsTimestamp_t);
364
365
  /* 3. class cid */
366
  prof_fill_CID(buffer, classEntry->static_id);
367
  buffer += sizeof(jsClassID_t);
368
369
  /* 4. class oid */
370
  if(classEntry->classObject == NULL) {
371
    prof_fill_OID(buffer, NULL_OID);
372
  }
373
  else {
374
    prof_fill_OID(buffer, OBJECT_ENTRY(classEntry->classObject)->static_id);
375
  }
376
  buffer += sizeof(jsObjectID_t);
377
378
#if 0
379
  /* this would make it a ClassDefine2 */
380
381
  /* 5. loading thread */
382
  prof_fill_TID(buffer, NULL_TID); /* NMM FIXME */
383
  buffer += sizeof(jsThreadID_t);
384
#endif
385
386
387
  return sizeof(jsEventType_t)
388
    +    sizeof(jsTimestamp_t)
389
    +    sizeof(jsClassID_t)
390
    +    sizeof(jsObjectID_t);
391
}
392
/*
393
  Contents are: type, tick, oid, jsClsId, name_len, name
394
*/
395
unsigned short BINARYTRACE_printClassLoad(char*       buffer,
396
				     ClassEntry* classEntry)
397
{
398
  char *bufferOrig = buffer;
399
400
  BINARYTRACE_DEBUG(buffer, "CLASS LOAD");
401
402
  /* 1. event type */
403
  prof_fill_EventType(buffer, ClassLoad);
404
  buffer += sizeof(jsEventType_t);
405
406
  /* 2. timestamp of the classload */
407
  if(_jvmpiAgent_Options.timestamp) {
408
    prof_fill_timestamp(buffer, classEntry->timestamp);
409
  }
410
  else {
411
    prof_fill_current_timestamp(buffer);
412
  }
413
  buffer += sizeof(jsTimestamp_t);
414
415
  /* 3. class cid */
416
  prof_fill_CID(buffer, classEntry->static_id);
417
  buffer += sizeof(jsClassID_t);
418
419
420
  /* 4. instance size */
421
  prof_fill_u2(buffer, 0/*(short)classEntry->instanceSize*/);
422
  buffer += 2;
423
424
  /* 5. class name */
425
  buffer += prof_fill_string(buffer, classEntry->className);
426
427
  /* 6. num methods */
428
  prof_fill_u2(buffer, classEntry->numMethods);
429
  buffer += 2;
430
431
  /* 7. num static fields */
432
  prof_fill_u2(buffer, classEntry->numStaticFields);
433
  buffer += 2;
434
435
  /* 8. num instance fields */
436
  prof_fill_u2(buffer, classEntry->numInstanceFields);
437
  buffer += 2;
438
439
  /* 9. superclass */
440
  if (classEntry->superClassEntry) {
441
	prof_fill_CID(buffer, CLASS_ENTRY(classEntry->superClassEntry)->static_id);
442
  } else {
443
	prof_fill_CID(buffer, NULL_CID);
444
  }
445
  buffer += sizeof(jsClassID_t);
446
447
  /* 10. interfaces */
448
  buffer += printInterfaces(buffer, classEntry);
449
450
  return buffer - bufferOrig;
451
}
452
/*
453
  Contents are: tag, classId, methodId methodName, methodSignature
454
*/
455
unsigned short BINARYTRACE_printMethodDefine(char*        buffer,
456
					MethodEntry* methodEntry)
457
{
458
  unsigned short methodNameLength, signatureLength;
459
460
  BINARYTRACE_DEBUG(buffer, "METHOD DEFINE");
461
462
  /* 1. event type */
463
  prof_fill_EventType(buffer, MethodDefine);
464
  buffer += sizeof(jsEventType_t);
465
466
  /* 2. class id */
467
  {
468
    ClassEntry* classEntry = CLASS_ENTRY(methodEntry->classHashEntry);
469
    prof_fill_CID(buffer, classEntry->static_id);
470
    buffer += sizeof(jsClassID_t);
471
  }
472
473
  /* 3. method id */
474
  prof_fill_MID(buffer, methodEntry->static_id);
475
  buffer += sizeof(jsMethodID_t);
476
477
  /* 4. method name */
478
  methodNameLength = prof_fill_string(buffer, methodEntry->methodData.method_name);
479
  buffer += methodNameLength;
480
481
  /* 5. method signature */
482
  signatureLength = prof_fill_string(buffer, methodEntry->methodData.method_signature);
483
  buffer += signatureLength;
484
485
  /* 6. method access bits */
486
  prof_fill_u2(buffer, ACCESS_DEFAULT);
487
  /*buffer += 2;*/
488
489
  return sizeof(jsEventType_t)
490
    +    sizeof(jsClassID_t)
491
    +    sizeof(jsMethodID_t)
492
    +    methodNameLength
493
    +    signatureLength
494
    +    2;
495
}
496
/*
497
   Contents are: type, ticks, jsThreadId<-threadCounter, jsMethodId, jsObjId,
498
*/
499
unsigned short BINARYTRACE_printMethodEnter(char*          buffer,
500
				       StackEntry*    stackEntry)
501
{
502
  jsObjectID_t oid;
503
  BINARYTRACE_DEBUG(buffer, "METHOD ENTER");
504
505
  /* 1. event type */
506
  prof_fill_EventType(buffer, JavaMethodEntry);
507
  buffer += sizeof(jsEventType_t);
508
509
  /* 2. timestamp of the enter */
510
  prof_fill_timestamp(buffer, stackEntry->timestamp);
511
  buffer += sizeof(jsTimestamp_t);
512
513
  /* 3. thread id */
514
  prof_fill_TID(buffer, stackEntry->tps);
515
  buffer += sizeof(jsThreadID_t);
516
517
  /* 4. method id */
518
  prof_fill_u4(buffer, METHOD_ENTRY(stackEntry->methodHashEntry)->static_id);
519
  buffer += sizeof(jsMethodID_t);
520
521
  /* 5. object id */
522
  if(stackEntry->objectHashEntry == NULL) {
523
    oid = NULL_OID;
524
  }
525
  else {
526
    oid = OBJECT_ENTRY(stackEntry->objectHashEntry)->static_id;
527
  }
528
  prof_fill_OID(buffer, oid);
529
530
#ifdef BINARYTRACE_LINENUMBERED_INVOCATIONS
531
  buffer += sizeof(jsObjectID_t);
532
533
  /* 6. line number */
534
  prof_fill_u2(buffer, 0); /* NMM FIXME */
535
  /*buffer += 2;*/
536
#endif /* BINARYTRACE_LINENUMBERED_INVOCATIONS */
537
538
  return
539
#ifdef BINARYTRACE_LINENUMBERED_INVOCATIONS
540
    2
541
#endif /* BINARYTRACE_LINENUMBERED_INVOCATIONS */
542
    sizeof(jsEventType_t)
543
    +    sizeof(jsTimestamp_t)
544
    +    sizeof(jsThreadID_t)
545
    +    sizeof(jsMethodID_t)
546
    +    sizeof(jsObjectID_t);
547
}
548
unsigned short BINARYTRACE_printMethodExit(char*               buffer,
549
				      ThreadLocalStorage* tps,
550
				      timestamp_t         timeJustAfterGotControl)
551
{
552
  uint64_t exit_overhead, overheadSoFar, totalInvocationOverhead;
553
  timestamp_t now;
554
  BINARYTRACE_DEBUG(buffer, "METHOD EXIT");
555
556
  /* 1. event type */
557
  prof_fill_EventType(buffer, JavaMethodExit);
558
  buffer += sizeof(jsEventType_t);
559
560
  /* 2. timestamp of the exit */
561
  jvmpiAgent_getCurrentTime(&now);
562
  prof_fill_timestamp(buffer, now);
563
  buffer += sizeof(jsTimestamp_t);
564
565
  /* 3. overhead compensation */
566
#ifdef BINARYTRACE_OVERHEAD
567
  exit_overhead = now-timeJustAfterGotControl;
568
  overheadSoFar = tps->stackEntry[tps->tos].cumulative_overhead;
569
  totalInvocationOverhead = overheadSoFar+exit_overhead;
570
#else
571
  totalInvocationOverhead = 0;
572
#endif /* BINARYTRACE_OVERHEAD */
573
  prof_fill_u8(buffer, totalInvocationOverhead);
574
  buffer += 8;
575
576
  /* 4. thread id */
577
  prof_fill_TID(buffer, tps);
578
  /*buffer += sizeof(jsThreadID_t);*/
579
580
  return sizeof(jsEventType_t)
581
    +    sizeof(jsTimestamp_t)
582
    +    8
583
    +    sizeof(jsThreadID_t);
584
}
585
586
/*
587
  Contents are: type, tick, jsObjId, threadName
588
*/
589
unsigned short BINARYTRACE_printThreadStart(char*               buffer,
590
				       ThreadLocalStorage* tps)
591
{
592
  unsigned short lengthOfThreadName;
593
594
  BINARYTRACE_DEBUG(buffer, "THREAD_START");
595
596
  /* 1. event type */
597
  prof_fill_EventType(buffer, ThreadStart);
598
  buffer += sizeof(jsEventType_t);
599
600
  /* 2. timestamp of thread start */
601
  prof_fill_current_timestamp(buffer);
602
  buffer += sizeof(jsTimestamp_t);
603
604
  /* 3. thread id */
605
  prof_fill_TID(buffer, tps);
606
  buffer += sizeof(jsThreadID_t);
607
608
  /* 4. thread name */
609
  lengthOfThreadName = prof_fill_string(buffer, tps->threadName);
610
  /* buffer += lengthOfThreadName; */
611
612
  return sizeof(jsEventType_t)
613
    +    sizeof(jsTimestamp_t)
614
    +    sizeof(jsThreadID_t)
615
    +    lengthOfThreadName;
616
}
617
/* Contents: type, ticks, objectId */
618
unsigned short BINARYTRACE_printObjectFree(char*      buffer,
619
				      HashEntry* objectHashEntry)
620
{
621
  BINARYTRACE_DEBUG(buffer, "OBJECT FREE");
622
623
  prof_fill_EventType(buffer, ObjectFree);
624
  buffer += sizeof(jsEventType_t);
625
626
  prof_fill_current_timestamp(buffer);
627
  buffer += sizeof(jsTimestamp_t);
628
629
  prof_fill_OID(buffer, (unsigned long)(OBJECT_ENTRY(objectHashEntry)->static_id));
630
  /*buffer += sizeof(jsObjectID_t);*/
631
632
  return sizeof(jsEventType_t) + sizeof(jsTimestamp_t) + sizeof(jsObjectID_t);
633
}
634
unsigned short
635
BINARYTRACE_printWitnessedObjectAllocation(char*                 buffer,
636
				      ThreadPrivateStorage* creatingThread,
637
				      HashEntry*            objectHashEntry,
638
				      HashEntry*            classHashEntry,
639
				      timestamp_t           allocTime)
640
{
641
  char* bufferOrig = buffer;
642
  ObjectEntry* newObject = OBJECT_ENTRY(objectHashEntry);
643
  BOOL isArray = newObject->is_array != JVMPI_NORMAL_OBJECT;
644
645
  /* 1. type of event */
646
  if(!isArray) {
647
    prof_fill_EventType(buffer, WitnessedObjectCreation);
648
  }
649
  else {
650
    prof_fill_EventType(buffer, WitnessedArrayCreation);
651
  }
652
  buffer += sizeof(jsEventType_t);
653
654
655
  /* 2. time of creation */
656
  prof_fill_timestamp(buffer, allocTime);
657
  buffer += sizeof(jsTimestamp_t);
658
659
  /* 3. element type, for array objects */
660
  if(newObject->is_array == JVMPI_CLASS) {
661
    prof_fill_CID(buffer, CLASS_ENTRY(classHashEntry)->static_id);
662
    buffer += sizeof(jsClassID_t);
663
  }
664
  else if(isArray) {
665
    prof_fill_u1(buffer, jvmpi_to_jni(newObject->is_array));
666
    buffer += sizeof(char);
667
  }
668
669
  /* 4. OID */
670
  prof_fill_OID(buffer, newObject->static_id);
671
  buffer += sizeof(jsObjectID_t);
672
673
  /* 5. CID */
674
  if(!isArray) {
675
    prof_fill_CID(buffer, CLASS_ENTRY(classHashEntry)->static_id);
676
    buffer += sizeof(jsClassID_t);
677
  }
678
  else {
679
    prof_fill_u4(buffer, newObject->size);
680
    buffer += 4;
681
  }
682
683
  prof_fill_TID(buffer, creatingThread);
684
  buffer += sizeof(jsThreadID_t);
685
686
  return buffer-bufferOrig;
687
}
688
/* Contents: type, ticks, jsObjId, jsClsId */
689
unsigned short BINARYTRACE_printObjectAllocation(char*      buffer,
690
					    HashEntry* objectHashEntry,
691
					    HashEntry* classHashEntry)
692
{
693
  ObjectEntry* objectEntry = OBJECT_ENTRY(objectHashEntry);
694
  BINARYTRACE_DEBUG(buffer, "OBJECT ALLOCATION");
695
696
  switch(objectEntry->is_array) {
697
  case JVMPI_NORMAL_OBJECT:
698
    {
699
      /* instances */
700
      prof_fill_EventType(buffer, ObjectFirstSeen);
701
      buffer += sizeof(jsEventType_t);
702
703
      prof_fill_current_timestamp(buffer);
704
      buffer += sizeof(jsTimestamp_t);
705
706
      prof_fill_OID(buffer, objectEntry->static_id);
707
      buffer += sizeof(jsObjectID_t);
708
709
      prof_fill_CID(buffer, CLASS_ENTRY(classHashEntry)->static_id);
710
      /*buffer += sizeof(jsClassID_t);*/
711
712
      return sizeof(jsEventType_t)
713
	+    sizeof(jsTimestamp_t)
714
	+    sizeof(jsObjectID_t)
715
	+    sizeof(jsClassID_t);
716
    }
717
718
  case JVMPI_CLASS:
719
    {
720
      /* arrays of objects */
721
      prof_fill_EventType(buffer, ArrayOfObjectsFirstSeen);
722
      buffer += sizeof(jsEventType_t);
723
724
      prof_fill_current_timestamp(buffer);
725
      buffer += sizeof(jsTimestamp_t);
726
727
      prof_fill_OID(buffer, objectEntry->static_id);
728
      buffer += sizeof(jsObjectID_t);
729
730
      prof_fill_CID(buffer, CLASS_ENTRY(classHashEntry)->static_id);
731
      buffer += sizeof(jsClassID_t);
732
733
      prof_fill_u4(buffer, objectEntry->size);
734
      /* buffer += 4; */
735
736
      return sizeof(jsEventType_t)
737
	+    sizeof(jsTimestamp_t)
738
	+    sizeof(jsObjectID_t)
739
	+    sizeof(jsClassID_t)
740
	+    4;
741
    }
742
743
  default:
744
    {
745
      /* arrays of primitives */
746
      prof_fill_EventType(buffer, ArrayOfPrimitivesFirstSeen);
747
      buffer += sizeof(jsEventType_t);
748
749
      prof_fill_current_timestamp(buffer);
750
      buffer += sizeof(jsTimestamp_t);
751
752
      prof_fill_u1(buffer, jvmpi_to_jni((char) objectEntry->is_array));
753
      buffer += 1;
754
755
      prof_fill_OID(buffer, objectEntry->static_id);
756
      buffer += sizeof(jsObjectID_t);
757
	
758
      prof_fill_u4(buffer, objectEntry->size);
759
      /* buffer += 4; */
760
	
761
      return sizeof(jsEventType_t)
762
	+    sizeof(jsTimestamp_t)
763
	+    1
764
	+    sizeof(jsObjectID_t)
765
	+    4;
766
    }
767
  }
768
}
769
770
/* Contents: type, tick, jsClsId */
771
unsigned short BINARYTRACE_printClassUnload(char* buffer,
772
				       HashEntry* classHashEntry)
773
{
774
  BINARYTRACE_DEBUG(buffer, "CLASS UNLOAD");
775
776
  prof_fill_EventType(buffer, ClassUnload);
777
  buffer += sizeof(jsEventType_t);
778
779
  prof_fill_current_timestamp(buffer);
780
  buffer += sizeof(jsTimestamp_t);
781
782
  prof_fill_CID(buffer, CLASS_ENTRY(classHashEntry)->static_id);
783
  /*buffer += sizeof(jsClassID_t);*/
784
785
  return sizeof(jsEventType_t)
786
    +    sizeof(jsTimestamp_t)
787
    +    sizeof(jsClassID_t);
788
}
789
/* Contents: type, ticks, jsThreadId */
790
unsigned short BINARYTRACE_printThreadEnd(char*               buffer,
791
				     ThreadLocalStorage* tps)
792
{
793
  BINARYTRACE_DEBUG(buffer, "THREAD END");
794
795
  prof_fill_EventType(buffer, ThreadExit);
796
  buffer += sizeof(jsEventType_t);
797
798
  prof_fill_current_timestamp(buffer);
799
  buffer += sizeof(jsTimestamp_t);
800
801
  prof_fill_TID(buffer, tps);
802
  /*buffer += sizeof(jsThreadID_t);*/
803
804
  return sizeof(jsEventType_t)
805
    +    sizeof(jsTimestamp_t)
806
    +    sizeof(jsThreadID_t);
807
}
808
/* Contents: type, tick */
809
unsigned short BINARYTRACE_printGenericTimestampedEvent(char*         buffer,
810
						   jsEventType_t event)
811
{
812
  prof_fill_EventType(buffer, event);
813
  buffer += sizeof(jsEventType_t);
814
815
  prof_fill_current_timestamp(buffer);
816
  /* buffer += sizeof(jsTimestamp_t); */
817
818
  return sizeof(jsEventType_t)
819
    +    sizeof(jsTimestamp_t);
820
}
821
unsigned short BINARYTRACE_printGcStart(char* buffer)
822
{
823
  BINARYTRACE_DEBUG(buffer, "GC START");
824
  return BINARYTRACE_printGenericTimestampedEvent(buffer, GCStart);
825
}
826
unsigned short BINARYTRACE_printGcFinish(char* buffer)
827
{
828
  BINARYTRACE_DEBUG(buffer, "GC FINISH");
829
  return BINARYTRACE_printGenericTimestampedEvent(buffer, GCFinish);
830
}
831
BOOL isBigEndian() {
832
  long i = 0x44332211;
833
  unsigned char* a = (unsigned char*) &i;
834
  int end = (*a != 0x11);
835
  fprintf(stderr, "[Watson: detected %s-endian platform]\n",
836
	  ((end==1)?"big":"little"));
837
  return end==1;
838
}
839
unsigned short BINARYTRACE_printEndOfXMLHeader(char* buffer)
840
{
841
  char* bufferOrig = buffer;
842
843
  /* 1. some termination characters, so we know XML header is done */
844
  prof_fill_u1(buffer, 0xD);
845
  buffer += 1;
846
  prof_fill_u1(buffer, 0xE);
847
  buffer += 1;
848
  prof_fill_u1(buffer, 0xA);
849
  buffer += 1;
850
  prof_fill_u1(buffer, 0xD);
851
  buffer += 1;
852
853
  /* 2. boolean indicating the endianness of this platform */
854
  prof_fill_boolean(buffer, isBigEndian());
855
  buffer += sizeof(jsBooleanValue_t);
856
857
  /* 3. short indicating the binary trace format version */
858
  prof_fill_u2(buffer, BINARYTRACE_TRACE_FORMAT_VERSION);
859
  buffer += 2;
860
861
  /* 4. boolean indicating whether enter events will include line
862
     numbers */
863
#ifdef BINARYTRACE_LINENUMBERED_INVOCATIONS
864
  prof_fill_boolean(buffer, TRUE);
865
#else
866
  prof_fill_boolean(buffer, FALSE);
867
#endif /* BINARYTRACE_LINENUMBERED_INVOCATIONS */
868
  buffer += sizeof(jsBooleanValue_t);
869
870
  /* 5. minimum tick count in the trace */
871
  prof_fill_timestamp(buffer, _startTime);
872
  buffer += sizeof(jsTimestamp_t);
873
874
  /* 6. ticks per microsecond of the tick counts */
875
  {
876
    /* at the end of this file */
877
    prof_fill_u4(buffer, _ticksPerMicrosecond);
878
    buffer += 4;
879
  }
880
881
  return buffer - bufferOrig;
882
}
883
void BINARYTRACE_printTraceHeader(ThreadLocalStorage* tps)
884
{
885
  if (!_jvmpiAgent_suspendIO) {
886
    char* buffer = tps->buffer;
887
    char* bufferOrig = buffer;
888
889
    if (!_jvmpiAgent_Options.standalone) {
890
      /* jinsight viz expects ACK as first byte when connected live */
891
      prof_fill_u1(buffer, 1);
892
      buffer += 1;
893
    }
894
895
    prof_fill_u1(buffer, 'w');
896
    buffer += 1;
897
898
    {
899
      unsigned short numBytes = buffer - bufferOrig;
900
      jvmpiAgent_print(tps, tps->buffer, numBytes);
901
    }
902
  }
903
}
904
void BINARYTRACE_printTraceEnd(ThreadLocalStorage* tps)
905
{
906
  char* buffer = tps->buffer;
907
908
  prof_fill_EventType(buffer, TraceEnd);
909
  buffer += sizeof(jsEventType_t);
910
911
  prof_fill_u4(buffer, 0xDEAD);
912
  buffer += 4;
913
914
  prof_fill_u4(buffer, 0xDEAD);
915
  /*buffer += 4;*/
916
917
  {
918
    unsigned short numBytes =
919
      sizeof(jsEventType_t)
920
      + 4
921
      + 4;
922
    jvmpiAgent_print(tps, tps->buffer, numBytes);
923
  }
924
}
925
926
void BINARYTRACE_printBOB(ThreadLocalStorage* tps)
927
{
928
  char* buffer = tps->buffer;
929
930
  prof_fill_EventType(buffer, BOBEvent);
931
  buffer += sizeof(jsEventType_t);
932
933
  prof_fill_current_timestamp(buffer);
934
  /* buffer += sizeof(jsTimestamp_t); */
935
936
  jvmpiAgent_print(tps, tps->buffer, 1+sizeof(jsTimestamp_t));
937
}
938
void BINARYTRACE_printEOB(ThreadLocalStorage* tps)
939
{
940
  char* buffer = tps->buffer;
941
  prof_fill_EventType(buffer, EOBEvent);
942
  buffer += sizeof(jsEventType_t);
943
944
  prof_fill_current_timestamp(buffer);
945
  /* buffer += sizeof(jsTimestamp_t); */
946
947
  jvmpiAgent_print(tps, tps->buffer, 1+sizeof(jsTimestamp_t));
948
}
949
unsigned short BINARYTRACE_printArrayReference(char* buffer,
950
					  unsigned long parentOID,
951
					  unsigned long childOID)
952
{
953
   if (TRUE || !_jvmpiAgent_suspendIO) {
954
    char* bufferOrig = buffer;
955
956
    prof_fill_EventType(buffer, ArrayRefs);
957
    buffer += sizeof(jsEventType_t);
958
959
    prof_fill_OID(buffer, parentOID);
960
    buffer += sizeof(jsObjectID_t);
961
962
    prof_fill_u4(buffer, 1);
963
    buffer += 4;
964
965
    prof_fill_OID(buffer, childOID);
966
    buffer += sizeof(jsObjectID_t);
967
968
    return buffer-bufferOrig;
969
  }
970
971
  return 0;
972
}
973
unsigned short BINARYTRACE_printClassReference(char* buffer,
974
					  unsigned long parentCID,
975
					  unsigned long childOID)
976
{
977
  if (!_jvmpiAgent_suspendIO) {
978
    char* bufferOrig = buffer;
979
980
    prof_fill_EventType(buffer, GC_StaticRoot);
981
    buffer += sizeof(jsEventType_t);
982
983
    prof_fill_CID(buffer, parentCID);
984
    buffer += sizeof(jsClassID_t);
985
986
    prof_fill_OID(buffer, childOID);
987
    buffer += sizeof(jsObjectID_t);
988
989
    prof_fill_OID(buffer, NULL_OID);
990
    buffer += sizeof(jsObjectID_t);
991
992
    return buffer-bufferOrig;
993
  }
994
995
  return 0;
996
}
997
unsigned short BINARYTRACE_printObjectReference(char* buffer,
998
					   unsigned long parentOID,
999
					   unsigned long childOID)
1000
{
1001
  if (!_jvmpiAgent_suspendIO) {
1002
    char* bufferOrig = buffer;
1003
1004
    prof_fill_EventType(buffer, ObjectRefs);
1005
    buffer += sizeof(jsEventType_t);
1006
1007
    prof_fill_OID(buffer, parentOID);
1008
    buffer += sizeof(jsObjectID_t);
1009
1010
    prof_fill_OID(buffer, childOID);
1011
    buffer += sizeof(jsObjectID_t);
1012
1013
    prof_fill_OID(buffer, NULL_OID);
1014
    buffer += sizeof(jsObjectID_t);
1015
1016
    return buffer-bufferOrig;
1017
  }
1018
1019
  return 0;
1020
}
1021
void BINARYTRACE_printGeneration(ThreadLocalStorage* tps)
1022
{
1023
  char* buffer = tps->buffer;
1024
  char* bufferOrig = buffer;
1025
1026
  prof_fill_EventType(buffer, Generation);
1027
  buffer += sizeof(jsEventType_t);
1028
1029
  prof_fill_current_timestamp(buffer);
1030
  buffer += sizeof(jsTimestamp_t);
1031
1032
  jvmpiAgent_print(tps, tps->buffer, buffer-bufferOrig);
1033
}
1034
void BINARYTRACE_printUnknownRoot(ThreadLocalStorage* tps,
1035
			     ObjectEntry*        unknown)
1036
{
1037
  char* buffer     = tps->buffer;
1038
  char* bufferOrig = buffer;
1039
1040
  prof_fill_EventType(buffer, GC_UnknownRoot);
1041
  buffer += sizeof(jsEventType_t);
1042
1043
  prof_fill_OID(buffer, unknown->static_id);
1044
  buffer += sizeof(jsObjectID_t);
1045
1046
  jvmpiAgent_print(tps, tps->buffer, buffer-bufferOrig);
1047
}
1048
void BINARYTRACE_printJNIGlobalRoot(ThreadLocalStorage* tps,
1049
			       ObjectEntry* parent,
1050
			       ObjectEntry* child)
1051
{
1052
  char* buffer     = tps->buffer;
1053
  char* bufferOrig = buffer;
1054
1055
  prof_fill_EventType(buffer, GC_JNI_GlobalRoot);
1056
  buffer += sizeof(jsEventType_t);
1057
1058
  prof_fill_OID(buffer, parent->static_id);
1059
  buffer += sizeof(jsObjectID_t);
1060
1061
  prof_fill_OID(buffer, child->static_id);
1062
  buffer += sizeof(jsObjectID_t);
1063
1064
  jvmpiAgent_print(tps, tps->buffer, buffer-bufferOrig);
1065
}
1066
void BINARYTRACE_printJNILocalRoot(ThreadLocalStorage* tps,
1067
			      ObjectEntry* object,
1068
			      ThreadLocalStorage* localToThisThread,
1069
			      int stackDepth)
1070
{
1071
  char* buffer     = tps->buffer;
1072
  char* bufferOrig = buffer;
1073
1074
  prof_fill_EventType(buffer, GC_JNI_LocalRoot);
1075
  buffer += sizeof(jsEventType_t);
1076
1077
  prof_fill_TID(buffer, localToThisThread);
1078
  buffer += sizeof(jsThreadID_t);
1079
1080
  prof_fill_OID(buffer, object->static_id);
1081
  buffer += sizeof(jsObjectID_t);
1082
1083
  jvmpiAgent_print(tps, tps->buffer, buffer-bufferOrig);
1084
}
1085
void BINARYTRACE_printJavaStackRoot(ThreadLocalStorage* tps,
1086
			       ThreadLocalStorage* rootedToThisThread,
1087
			       ObjectEntry*        object,
1088
			       int                 depth)
1089
{
1090
  char* buffer     = tps->buffer;
1091
  char* bufferOrig = buffer;
1092
1093
  prof_fill_EventType(buffer, GC_JavaStackRoot);
1094
  buffer += sizeof(jsEventType_t);
1095
1096
  prof_fill_TID(buffer, rootedToThisThread);
1097
  buffer += sizeof(jsThreadID_t);
1098
1099
  prof_fill_OID(buffer, object->static_id);
1100
  buffer += sizeof(jsObjectID_t);
1101
1102
  jvmpiAgent_print(tps, tps->buffer, buffer-bufferOrig);
1103
}
1104
void BINARYTRACE_printNativeStackRoot(ThreadLocalStorage* tps,
1105
				 ThreadLocalStorage* rootedToThisThread,
1106
				 ObjectEntry* object)
1107
{
1108
  char* buffer     = tps->buffer;
1109
  char* bufferOrig = buffer;
1110
1111
  prof_fill_EventType(buffer, GC_NativeStackRoot);
1112
  buffer += sizeof(jsEventType_t);
1113
1114
  prof_fill_TID(buffer, rootedToThisThread);
1115
  buffer += sizeof(jsThreadID_t);
1116
1117
  prof_fill_OID(buffer, object->static_id);
1118
  buffer += sizeof(jsObjectID_t);
1119
1120
  jvmpiAgent_print(tps, tps->buffer, buffer-bufferOrig);
1121
}
1122
void BINARYTRACE_printStickyClassRoot(ThreadLocalStorage* tps,
1123
				 ObjectEntry*        clazzObject)
1124
{
1125
  char* buffer     = tps->buffer;
1126
  char* bufferOrig = buffer;
1127
1128
  prof_fill_EventType(buffer, GC_StickyClassRoot);
1129
  buffer += sizeof(jsEventType_t);
1130
1131
  prof_fill_OID(buffer, clazzObject->static_id);
1132
  buffer += sizeof(jsObjectID_t);
1133
1134
  jvmpiAgent_print(tps, tps->buffer, buffer-bufferOrig);
1135
}
1136
void BINARYTRACE_printThreadRoot(ThreadLocalStorage* tps,
1137
			    ThreadLocalStorage* theThread,
1138
			    ObjectEntry*        theThreadObject)
1139
{
1140
  char* buffer     = tps->buffer;
1141
  char* bufferOrig = buffer;
1142
1143
  prof_fill_EventType(buffer, GC_ThreadRoot);
1144
  buffer += sizeof(jsEventType_t);
1145
1146
  prof_fill_TID(buffer, theThread);
1147
  buffer += sizeof(jsThreadID_t);
1148
1149
  prof_fill_OID(buffer, theThreadObject->static_id);
1150
  buffer += sizeof(jsObjectID_t);
1151
1152
  jvmpiAgent_print(tps, tps->buffer, buffer-bufferOrig);
1153
}
1154
void BINARYTRACE_printMonitorRoot(ThreadLocalStorage* tps,
1155
			     ObjectEntry*        monitorObject)
1156
{
1157
  char* buffer     = tps->buffer;
1158
  char* bufferOrig = buffer;
1159
1160
  prof_fill_EventType(buffer, GC_MonitorRoot);
1161
  buffer += sizeof(jsEventType_t);
1162
1163
  prof_fill_OID(buffer, monitorObject->static_id);
1164
  buffer += sizeof(jsObjectID_t);
1165
1166
  jvmpiAgent_print(tps, tps->buffer, buffer-bufferOrig);
1167
}
1168
1169
/* #include "watson_fieldvalues.c" */
1170
1171
#endif /* BINARY_TRACE */
(-)src-native-new/src/agents/native/WinBuild/heapsnapshots.mak64 (+326 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on heapsnapshots.dsp
2
!IF "$(CFG)" == ""
3
CFG=heapsnapshots - IA64 Debug
4
!MESSAGE No configuration specified. Defaulting to heapsnapshots - IA64 Debug.
5
!ENDIF 
6
7
!IF "$(CFG)" != "heapsnapshots - IA64 Release" && "$(CFG)" != "heapsnapshots - IA64 Debug" && "$(CFG)" != "heapsnapshots - X64 Release" && "$(CFG)" != "heapsnapshots - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "heapsnapshots.mak64" CFG="heapsnapshots - IA64 Debug"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "heapsnapshots - IA64 Release"
17
!MESSAGE "heapsnapshots - IA64 Debug"
18
!MESSAGE "heapsnapshots - X64 Release"
19
!MESSAGE "heapsnapshots - X64 Debug"
20
!MESSAGE 
21
!ERROR An invalid configuration is specified.
22
!ENDIF 
23
24
!IF "$(OS)" == "Windows_NT"
25
NULL=
26
!ELSE 
27
NULL=nul
28
!ENDIF 
29
30
!IF  "$(CFG)" == "heapsnapshots - IA64 Release"
31
32
OUTDIR=..\..\..\..\lib
33
INTDIR=.\Release
34
# Begin Custom Macros
35
OutDir=..\..\..\..\lib
36
# End Custom Macros
37
38
ALL : "$(OUTDIR)\heapsnapshots.lib"
39
40
41
CLEAN :
42
	-@erase "$(INTDIR)\AbstractHeapSnapshotManager.obj"
43
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager.obj"
44
	-@erase "$(INTDIR)\vc60.idb"
45
	-@erase "$(OUTDIR)\heapsnapshots.lib"
46
47
"$(OUTDIR)" :
48
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
49
50
"$(INTDIR)" :
51
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
52
53
CPP=cl.exe
54
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"$(INTDIR)\heapsnapshots.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
55
56
.c{$(INTDIR)}.obj::
57
   $(CPP) @<<
58
   $(CPP_PROJ) $< 
59
<<
60
61
.cpp{$(INTDIR)}.obj::
62
   $(CPP) @<<
63
   $(CPP_PROJ) $< 
64
<<
65
66
.cxx{$(INTDIR)}.obj::
67
   $(CPP) @<<
68
   $(CPP_PROJ) $< 
69
<<
70
71
.c{$(INTDIR)}.sbr::
72
   $(CPP) @<<
73
   $(CPP_PROJ) $< 
74
<<
75
76
.cpp{$(INTDIR)}.sbr::
77
   $(CPP) @<<
78
   $(CPP_PROJ) $< 
79
<<
80
81
.cxx{$(INTDIR)}.sbr::
82
   $(CPP) @<<
83
   $(CPP_PROJ) $< 
84
<<
85
86
RSC=rc.exe
87
88
LIB32=link.exe -lib
89
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\heapsnapshots.lib" 
90
LIB32_OBJS= \
91
	"$(INTDIR)\AbstractHeapSnapshotManager.obj" \
92
	"$(INTDIR)\StatelessHeapSnapshotManager.obj"
93
94
"$(OUTDIR)\heapsnapshots.lib" : "$(OUTDIR)" $(LIB32_OBJS)
95
    $(LIB32) @<<
96
  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
97
<<
98
99
!ELSEIF  "$(CFG)" == "heapsnapshots - IA64 Debug"
100
101
OUTDIR=..\..\..\..\lib
102
INTDIR=.\Debug
103
# Begin Custom Macros
104
OutDir=..\..\..\..\lib
105
# End Custom Macros
106
107
ALL : "$(OUTDIR)\heapsnapshots.lib"
108
109
110
CLEAN :
111
	-@erase "$(INTDIR)\AbstractHeapSnapshotManager.obj"
112
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager.obj"
113
	-@erase "$(INTDIR)\vc60.idb"
114
	-@erase "$(INTDIR)\vc60.pdb"
115
	-@erase "$(OUTDIR)\heapsnapshots.lib"
116
117
"$(OUTDIR)" :
118
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
119
120
"$(INTDIR)" :
121
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
122
123
CPP=cl.exe
124
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Fp"$(INTDIR)\heapsnapshots.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
125
126
.c{$(INTDIR)}.obj::
127
   $(CPP) @<<
128
   $(CPP_PROJ) $< 
129
<<
130
131
.cpp{$(INTDIR)}.obj::
132
   $(CPP) @<<
133
   $(CPP_PROJ) $< 
134
<<
135
136
.cxx{$(INTDIR)}.obj::
137
   $(CPP) @<<
138
   $(CPP_PROJ) $< 
139
<<
140
141
.c{$(INTDIR)}.sbr::
142
   $(CPP) @<<
143
   $(CPP_PROJ) $< 
144
<<
145
146
.cpp{$(INTDIR)}.sbr::
147
   $(CPP) @<<
148
   $(CPP_PROJ) $< 
149
<<
150
151
.cxx{$(INTDIR)}.sbr::
152
   $(CPP) @<<
153
   $(CPP_PROJ) $< 
154
<<
155
156
RSC=rc.exe
157
158
LIB32=link.exe -lib
159
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\heapsnapshots.lib" 
160
LIB32_OBJS= \
161
	"$(INTDIR)\AbstractHeapSnapshotManager.obj" \
162
	"$(INTDIR)\StatelessHeapSnapshotManager.obj"
163
164
"$(OUTDIR)\heapsnapshots.lib" : "$(OUTDIR)" $(LIB32_OBJS)
165
    $(LIB32) @<<
166
  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
167
<<
168
169
!ELSEIF  "$(CFG)" == "heapsnapshots - X64 Release"
170
171
OUTDIR=..\..\..\..\lib
172
INTDIR=.\Release
173
# Begin Custom Macros
174
OutDir=..\..\..\..\lib
175
# End Custom Macros
176
177
ALL : "$(OUTDIR)\heapsnapshots.lib"
178
179
180
CLEAN :
181
	-@erase "$(INTDIR)\AbstractHeapSnapshotManager.obj"
182
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager.obj"
183
	-@erase "$(INTDIR)\vc60.idb"
184
	-@erase "$(OUTDIR)\heapsnapshots.lib"
185
186
"$(OUTDIR)" :
187
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
188
189
"$(INTDIR)" :
190
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
191
192
CPP=cl.exe
193
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"$(INTDIR)\heapsnapshots.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
194
195
.c{$(INTDIR)}.obj::
196
   $(CPP) @<<
197
   $(CPP_PROJ) $< 
198
<<
199
200
.cpp{$(INTDIR)}.obj::
201
   $(CPP) @<<
202
   $(CPP_PROJ) $< 
203
<<
204
205
.cxx{$(INTDIR)}.obj::
206
   $(CPP) @<<
207
   $(CPP_PROJ) $< 
208
<<
209
210
.c{$(INTDIR)}.sbr::
211
   $(CPP) @<<
212
   $(CPP_PROJ) $< 
213
<<
214
215
.cpp{$(INTDIR)}.sbr::
216
   $(CPP) @<<
217
   $(CPP_PROJ) $< 
218
<<
219
220
.cxx{$(INTDIR)}.sbr::
221
   $(CPP) @<<
222
   $(CPP_PROJ) $< 
223
<<
224
225
RSC=rc.exe
226
227
LIB32=link.exe -lib
228
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\heapsnapshots.lib" 
229
LIB32_OBJS= \
230
	"$(INTDIR)\AbstractHeapSnapshotManager.obj" \
231
	"$(INTDIR)\StatelessHeapSnapshotManager.obj"
232
233
"$(OUTDIR)\heapsnapshots.lib" : "$(OUTDIR)" $(LIB32_OBJS)
234
    $(LIB32) @<<
235
  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
236
<<
237
238
!ELSEIF  "$(CFG)" == "heapsnapshots - X64 Debug"
239
240
OUTDIR=..\..\..\..\lib
241
INTDIR=.\Debug
242
# Begin Custom Macros
243
OutDir=..\..\..\..\lib
244
# End Custom Macros
245
246
ALL : "$(OUTDIR)\heapsnapshots.lib"
247
248
249
CLEAN :
250
	-@erase "$(INTDIR)\AbstractHeapSnapshotManager.obj"
251
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager.obj"
252
	-@erase "$(INTDIR)\vc60.idb"
253
	-@erase "$(INTDIR)\vc60.pdb"
254
	-@erase "$(OUTDIR)\heapsnapshots.lib"
255
256
"$(OUTDIR)" :
257
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
258
259
"$(INTDIR)" :
260
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
261
262
CPP=cl.exe
263
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Fp"$(INTDIR)\heapsnapshots.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
264
265
.c{$(INTDIR)}.obj::
266
   $(CPP) @<<
267
   $(CPP_PROJ) $< 
268
<<
269
270
.cpp{$(INTDIR)}.obj::
271
   $(CPP) @<<
272
   $(CPP_PROJ) $< 
273
<<
274
275
.cxx{$(INTDIR)}.obj::
276
   $(CPP) @<<
277
   $(CPP_PROJ) $< 
278
<<
279
280
.c{$(INTDIR)}.sbr::
281
   $(CPP) @<<
282
   $(CPP_PROJ) $< 
283
<<
284
285
.cpp{$(INTDIR)}.sbr::
286
   $(CPP) @<<
287
   $(CPP_PROJ) $< 
288
<<
289
290
.cxx{$(INTDIR)}.sbr::
291
   $(CPP) @<<
292
   $(CPP_PROJ) $< 
293
<<
294
295
RSC=rc.exe
296
297
LIB32=link.exe -lib
298
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\heapsnapshots.lib" 
299
LIB32_OBJS= \
300
	"$(INTDIR)\AbstractHeapSnapshotManager.obj" \
301
	"$(INTDIR)\StatelessHeapSnapshotManager.obj"
302
303
"$(OUTDIR)\heapsnapshots.lib" : "$(OUTDIR)" $(LIB32_OBJS)
304
    $(LIB32) @<<
305
  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
306
<<
307
308
!ENDIF 
309
310
311
!IF "$(CFG)" == "heapsnapshots - IA64 Release" || "$(CFG)" == "heapsnapshots - IA64 Debug" || "$(CFG)" == "heapsnapshots - X64 Release" || "$(CFG)" == "heapsnapshots - X64 Debug"
312
SOURCE=..\heapsnapshots\AbstractHeapSnapshotManager.cpp
313
314
"$(INTDIR)\AbstractHeapSnapshotManager.obj" : $(SOURCE) "$(INTDIR)"
315
	$(CPP) $(CPP_PROJ) $(SOURCE)
316
317
318
SOURCE=..\heapsnapshots\StatelessHeapSnapshotManager.cpp
319
320
"$(INTDIR)\StatelessHeapSnapshotManager.obj" : $(SOURCE) "$(INTDIR)"
321
	$(CPP) $(CPP_PROJ) $(SOURCE)
322
323
324
325
!ENDIF 
326
(-)src-native-new/src/agents/perfmon/sysperf/perfcontrol.c (+1559 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2007 Scapa Technologies Limited and others
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
14
15
//#include <winsock2.h> /* Bug 134924 */
16
#include <windows.h>
17
#include <stdio.h>
18
#include <stdlib.h>
19
#include <tchar.h> 
20
#include <string.h>
21
#include "hashtable.h"
22
#include "perfcontrol.h"
23
#include "perfconstants.h"
24
#include "system.h"
25
#include "perfcalc.h"
26
27
#ifdef WIN32
28
    #ifdef _DEBUG
29
		#define _CRTDBG_MAP_ALLOC // include Microsoft memory leak detection procedures
30
		#define _INC_MALLOC	     // exclude standard memory alloc procedures
31
32
        #include <crtdbg.h>
33
    #endif
34
#endif
35
36
37
#define USE_REG_CONNECT TRUE
38
39
#define TOTALBYTES    131072
40
#define BYTEINCREMENT 8192
41
42
#define PERF_OBJ_TIME_TIMER 543229184
43
#define PERF_LARGE_RAW_BASE 1073939715
44
#define PERF_PRECISION_TIMESTAMP 1073939712
45
#define PERF_PRECISION_100NS_TIMER 542573824
46
#define PERF_PRECISION_OBJECT_TIMER 543622400
47
#define PERF_PRECISION_SYSTEM_TIMER 541525248
48
#define PERF_COUNTER_100NS_QUEUELEN_TYPE 5571840
49
50
LPSTR *lpNamesArray = NULL;
51
LPSTR lpNameStrings;
52
LPSTR *lpHelpArray = NULL;
53
LPSTR lpHelpStrings;
54
HashTable* instancecount;
55
56
static char* PREFIX = "Perfmon Datacollection:";
57
char* agent_type = "PerfmonAgent";
58
59
static HashTable* idhasht;
60
61
static HashTable* hasht_variables;
62
static HashTable* hasht_filters;
63
static HashTable* hasht_tree;
64
65
static int results_len = -1;
66
static char** results = NULL;
67
static int value_index = 0;
68
69
static BOOLEAN is_connected = 0;
70
static BOOLEAN disconnect = FALSE;
71
static char* connected_host = NULL;
72
73
int LOG_TO_FILE = FALSE;
74
static FILE* f = NULL;
75
static char filename[] = "SysPerfDll.log";
76
77
//////////////////////
78
// Bug 165319
79
static int isVista = 0;
80
unsigned long lpNamesArraySize = 0;
81
//////////////////////
82
83
void logToFile(const char*, ...);
84
85
void logToFile(const char* temp, ...)
86
{
87
	if (LOG_TO_FILE)
88
	{
89
		va_list ap;
90
		if (f == NULL)
91
			f = fopen(filename,  "w");
92
		va_start (ap, temp);
93
		vfprintf (f, temp, ap);
94
//		printf(temp,ap);
95
		va_end (ap);
96
		fflush(f);
97
	}
98
}
99
100
//////////////////////////////////////////////////////////////
101
// Bug 165319
102
// Check whether or not this is running on VISTA
103
104
int isVistaOrLater()
105
{
106
	int bIsWindowsVistaOrLater = 0;
107
	OSVERSIONINFO OSVer;
108
	OSVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
109
	
110
	if(GetVersionEx(&OSVer))
111
	{
112
		bIsWindowsVistaOrLater = (OSVer.dwMajorVersion >=6);
113
	}
114
	return bIsWindowsVistaOrLater;
115
}
116
//////////////////////////////////////////////////////////////
117
118
int DC_CollectionStartup(HashTable* xhasht_variables, HashTable* xhasht_filters, HashTable* xhasht_tree)
119
{
120
	isVista = isVistaOrLater();
121
122
	hasht_variables = xhasht_variables;
123
	hasht_filters = xhasht_filters;
124
	hasht_tree = xhasht_tree;
125
126
	createValueTables();
127
	idhasht = tableCreate();
128
129
	return 0;
130
}
131
132
BOOLEAN isConnectedWin32(char* host)
133
{	
134
	DWORD dwResult, cchBuff = sizeof(1024); 
135
 
136
	// Call the WNetGetConnection function.
137
	//
138
	dwResult = WNetGetConnection(NULL, (LPSTR) host, &cchBuff); 
139
 
140
	logToFile("RESULT = %d\n", dwResult);
141
	switch (dwResult) 
142
	{ 
143
		//
144
		// Print the connection name or process errors.
145
		//
146
		case NO_ERROR: 			
147
			return TRUE;
148
        break; 
149
150
	    case ERROR_NOT_CONNECTED: 
151
		    return FALSE;
152
		break;
153
154
		default:
155
			return FALSE; 
156
		break;
157
	}
158
}
159
160
void disconnectWin32(char* host)
161
{	
162
	DWORD dwResult; 
163
	
164
	logToFile("Attempting to disconnect...\n");
165
 
166
	dwResult = WNetCancelConnection2(host, 
167
		CONNECT_UPDATE_PROFILE, // remove connection from profile 
168
		FALSE);                 // fail if open files or jobs 
169
 
170
	if (dwResult == ERROR_NOT_CONNECTED) 
171
	{ 
172
		// It was not connected...
173
		return; 
174
	}  
175
	else if(dwResult != NO_ERROR) 
176
	{ 
177
		logToFile("Undefined error while disconnecting... \n\n");
178
		return; 
179
	}
180
	
181
	logToFile("Succesfully disconnected...\n\n");
182
}
183
184
int DC_CollectionShutdown()
185
{
186
	tableDelete(idhasht);
187
	freeValueTables();
188
189
	if (disconnect)
190
	{
191
		if (connected_host == NULL)
192
		{
193
			disconnectWin32(connected_host);
194
		}
195
	}
196
197
	return 0;
198
}
199
200
201
202
// Connect using the following credentials to the specified host
203
BOOLEAN connectWin32(char* host, char* username, char* password)
204
{
205
	DWORD connectResult; 
206
	NETRESOURCE networkResource; 
207
208
	logToFile("Attempting to establish WNET Connection to %s...\n", host);
209
	
210
    networkResource.dwType = RESOURCETYPE_ANY;
211
    networkResource.lpLocalName = NULL;
212
    networkResource.lpRemoteName = host;
213
    networkResource.lpProvider = NULL;
214
	
215
	// Call the WNetAddConnection2 function to make the connection, do not make this connection persistent	
216
	connectResult = WNetAddConnection2(&networkResource, (LPSTR) password, (LPSTR) username, 0);
217
 
218
	//  The local device is already connected to a network resource.
219
	if (connectResult == ERROR_ALREADY_ASSIGNED) 
220
	{ 
221
		logToFile("Already connected to specified resource.\n\n"); 
222
		return FALSE; 
223
	} 
224
	else if (connectResult == ERROR_LOGON_FAILURE)
225
	{
226
		logToFile("The credentials for logon failed.\n\n");
227
		return FALSE;
228
	} 
229
	else if(connectResult != NO_ERROR) 
230
	{ 
231
		logToFile("Undefined Error # %d\n\n", connectResult);
232
		return FALSE; 
233
	} 
234
 
235
	logToFile("Connected to specified resource.\n\n"); 
236
	connected_host = host;
237
	return TRUE;
238
}
239
240
241
int getRemoteKey(char* REG_HOST, HKEY* rKey)
242
{
243
	HKEY remoteKey;
244
	int rt;
245
246
	if (REG_HOST == NULL) 
247
	{
248
		remoteKey = HKEY_PERFORMANCE_DATA;
249
	}
250
	else 
251
	{
252
		if (USE_REG_CONNECT) 
253
		{
254
			logToFile("%sTrying to connect to remote registry %s\n",PREFIX,REG_HOST);
255
256
			if (is_connected == FALSE)
257
			{
258
				// We need to get a connection to the remote host
259
				
260
				// First, lets just try a default connection
261
262
				char* newHostName = (char*) malloc(sizeof(char)*strlen(REG_HOST)+4);
263
				sprintf(newHostName, "\\\\%s%c",REG_HOST, '\0');
264
265
				if (isConnectedWin32(newHostName))
266
				{
267
					// We are already connected
268
					logToFile("Already connected to %s\n",newHostName);
269
					is_connected = TRUE;
270
				}
271
				else
272
				{
273
					if (connectWin32(newHostName, NULL, NULL))
274
					{
275
						// SUCCESS
276
						is_connected = TRUE;
277
						disconnect = TRUE;
278
					}
279
					else
280
					{
281
						// Try using passed in credentials
282
						char* USERNAME = (char*) tableGet(hasht_variables,PERFMON_USERNAME);
283
						char* PASSWORD = (char*) tableGet(hasht_variables,PERFMON_PASSWORD);
284
						if (PASSWORD == NULL)
285
							PASSWORD = "";
286
						if (connectWin32(newHostName, USERNAME, PASSWORD))
287
						{
288
							is_connected = TRUE;
289
							disconnect = TRUE;
290
						}
291
					}							
292
				}
293
			}
294
			// else we already have a valid connection
295
296
			//
297
			// Connect to the registry (may be NULL in case we will connect to the local registry
298
			//
299
			if ((rt = RegConnectRegistry(REG_HOST,HKEY_PERFORMANCE_DATA,&remoteKey)) == ERROR_BAD_NETPATH)
300
			{
301
				logToFile("%sCONNECT ERROR : ERROR BAD NETPATH (Network Busy) %d",PREFIX,rt);
302
303
				return -1;
304
			}
305
			logToFile("%sConnected to remote machine OK\n",PREFIX);
306
		} 
307
		else 
308
		{
309
			remoteKey = HKEY_PERFORMANCE_DATA;
310
		}
311
	}
312
	*rKey = remoteKey;
313
	return ERROR_SUCCESS;
314
}
315
316
char* getReqList(HashTable* hasht_filters)
317
{
318
319
	int objLen = 10;
320
	int objSiz, z;
321
	char** objList = (char**) malloc(sizeof(char*) * objLen);
322
323
	int reqLen = 1024;
324
	int reqCount = 0;
325
	char* reqList = (char*) malloc(sizeof(char) * reqLen);
326
327
	memset(objList,0,sizeof(char*) * objLen);
328
	while (objLen <= (objSiz = tableKeysAsList(hasht_filters,objList,objLen))) {
329
		objLen *= 2;
330
		objList = (char**) realloc(objList,sizeof(char*) * objLen);
331
	}
332
333
	//
334
	// Build a list of the requested objects so we can request just those from HKEY_PERFORMANCE_DATA
335
	//
336
	reqCount = 0;
337
	for (z = 0; z < objSiz; z++) {
338
		if (objList[z] != NULL) {
339
			char objTmp[64];
340
			char* tmp = objList[z];
341
			int index = 0;
342
343
			while (tmp[index] != '\0') {
344
				objTmp[index] = tmp[index];
345
				if (objTmp[index] == 'C' || objTmp[index] == 'I') {
346
					index = -1;
347
					break;
348
				}
349
				index++;
350
			}
351
352
			if (index > 0) {
353
				//string length = index
354
				//memcopy over the string into the buffer
355
356
				while ((reqLen-2) < (reqCount + index + 10)) {
357
					//increase buffer size
358
					reqLen *= 2;
359
					reqList = (char*)  realloc(reqList,sizeof(char) * reqLen);
360
				}
361
362
				memcpy(&(reqList[reqCount]),tmp,index);
363
				reqCount += index;
364
				reqList[reqCount++] = ' ';
365
366
			}
367
		}
368
	}
369
370
	reqList[reqCount++] = '\0';
371
372
	free(objList);
373
	return reqList;
374
}
375
376
377
PPERF_DATA_BLOCK getPerfData(char* REG_HOST, BOOL results, HashTable* hasht_filters, XINT64 getGlobalAgain)
378
{
379
	XINT32 TmpBufferSize = 0;
380
	static XINT32 BufferSize = 64000;
381
	DWORD rt;
382
	char* reqFinal;
383
	char* reqList;
384
	char* tree_reqList = NULL;
385
	char request_buf[20480];
386
387
    PPERF_DATA_BLOCK PerfData = NULL;
388
	HKEY remoteKey;
389
390
	PerfData = (PPERF_DATA_BLOCK) malloc( BufferSize );
391
392
	if (getRemoteKey(REG_HOST, &remoteKey) == -1)
393
	{
394
		free(PerfData);
395
		return NULL;
396
	}
397
398
	if (results == TRUE)
399
	{
400
		reqList = getReqList(hasht_filters);
401
		if (REG_HOST == NULL || USE_REG_CONNECT) 
402
			sprintf(request_buf,"%s%c",reqList,'\0');
403
		else
404
			sprintf(request_buf,"Foreign %s %s%c",REG_HOST,reqList,'\0');
405
406
		reqFinal = request_buf;
407
	}
408
	else
409
	{
410
		tree_reqList = getReqList(hasht_tree);
411
		if (REG_HOST == NULL || USE_REG_CONNECT) 
412
			sprintf(request_buf,"%s%c",tree_reqList,'\0');
413
		else
414
			sprintf(request_buf,"Foreign %s %s%c",REG_HOST,tree_reqList,'\0');
415
416
		reqFinal = request_buf;
417
	}
418
419
	if (reqFinal[0] == '\0' || getGlobalAgain == 1)
420
	{
421
		reqFinal = "Global";
422
	}
423
424
	TmpBufferSize = BufferSize;
425
	while( (rt=RegQueryValueEx(remoteKey,
426
							   reqFinal,
427
							   NULL,
428
							   NULL,
429
							   (LPBYTE) PerfData,
430
							   (ULONG*) &TmpBufferSize )) == ERROR_MORE_DATA ) 
431
	{
432
		/* RKD:  The key is opened, we just failed to have enough room for the data.  Close the key, create room,
433
		 *        and run again.
434
		 */
435
		RegCloseKey(remoteKey);
436
437
		/* We closed the key, need to reopen it again
438
		 * 
439
		 */
440
		if (getRemoteKey(REG_HOST, &remoteKey) == -1)
441
		{
442
			free(PerfData);
443
			return NULL;
444
		}
445
446
		BufferSize *= 2;
447
		PerfData = (PPERF_DATA_BLOCK) realloc( PerfData, BufferSize );
448
		TmpBufferSize = BufferSize;
449
	}
450
451
	if (rt != ERROR_SUCCESS) 
452
	{
453
		logToFile("%sFailed to query performance data registry key for tree %d\n",PREFIX,rt);
454
		free(PerfData);
455
		return NULL;
456
	}
457
458
	if ((rt=RegCloseKey(remoteKey)) != ERROR_SUCCESS) 
459
		logToFile("%sRegCloseKey FAILED %d\n",PREFIX,rt); 
460
	
461
	if (results == TRUE)
462
		free(reqList);
463
464
	if (tree_reqList != NULL)
465
		free(tree_reqList);
466
467
	return PerfData;
468
}
469
470
int isBaseType(int type)
471
{
472
	switch(type)
473
	{
474
		case PERF_AVERAGE_BASE:
475
		case PERF_SAMPLE_BASE:
476
		case PERF_RAW_BASE:
477
		case PERF_COUNTER_MULTI_BASE:
478
		case PERF_LARGE_RAW_BASE: 
479
		case PERF_PRECISION_TIMESTAMP: return 1;
480
	}
481
	return 0;
482
}
483
484
void printtype(char* key, PPERF_COUNTER_DEFINITION PerfCntr)
485
{
486
	logToFile("Key: %s - ",key);
487
	switch(PerfCntr->CounterType)
488
	{
489
490
		case PERF_100NSEC_MULTI_TIMER:			printf("PERF_100NSEC_MULTI_TIMER");break;
491
		case PERF_100NSEC_MULTI_TIMER_INV:		printf("PERF_100NSEC_MULTI_TIMER_INV");break;
492
		case PERF_100NSEC_TIMER:				printf("PERF_100NSEC_TIMER");break;
493
		case PERF_100NSEC_TIMER_INV:			printf("PERF_100NSEC_TIMER_INV");break;
494
		case PERF_AVERAGE_BASE:					printf("PERF_AVERAGE_BASE");break;
495
		case PERF_AVERAGE_BULK:					printf("PERF_AVERAGE_BULK");break;
496
		case PERF_AVERAGE_TIMER:				printf("PERF_AVERAGE_TIMER");break;
497
		case PERF_COUNTER_100NS_QUEUELEN_TYPE:	printf("PERF_COUNTER_100NS_QUEUELEN_TYPE");break;
498
		case PERF_COUNTER_BULK_COUNT:			printf("PERF_COUNTER_BULK_COUNT");break;
499
		case PERF_COUNTER_COUNTER:				printf("PERF_COUNTER_COUNTER");break;
500
		case PERF_COUNTER_DELTA:				printf("PERF_COUNTER_DELTA");break;
501
		case PERF_COUNTER_LARGE_DELTA:			printf("PERF_COUNTER_LARGE_DELTA");break;
502
		case PERF_COUNTER_LARGE_QUEUELEN_TYPE:	printf("PERF_COUNTER_LARGE_QUEUELEN_TYPE");break;
503
		case PERF_COUNTER_LARGE_RAWCOUNT:		printf("PERF_COUNTER_LARGE_RAWCOUNT");break;
504
		case PERF_COUNTER_LARGE_RAWCOUNT_HEX:	printf("PERF_COUNTER_LARGE_RAWCOUNT_HEX");break;
505
		case PERF_COUNTER_MULTI_BASE:			printf("PERF_COUNTER_MULTI_BASE");break;
506
		case PERF_COUNTER_MULTI_TIMER:			printf("PERF_COUNTER_MULTI_TIMER");break;
507
		case PERF_COUNTER_MULTI_TIMER_INV:		printf("PERF_COUNTER_MULTI_TIMER_INV");break;
508
		case PERF_COUNTER_NODATA:				printf("PERF_COUNTER_NODATA");break;
509
		case PERF_COUNTER_QUEUELEN_TYPE:		printf("PERF_COUNTER_QUEUELEN_TYPE");break;
510
		case PERF_COUNTER_RAWCOUNT:				printf("PERF_COUNTER_RAWCOUNT");break;
511
		case PERF_COUNTER_RAWCOUNT_HEX:			printf("PERF_COUNTER_RAWCOUNT_HEX");break;
512
		case PERF_COUNTER_TEXT:					printf("PERF_COUNTER_TEXT");break;
513
		case PERF_COUNTER_TIMER:				printf("PERF_COUNTER_TIMER");break;
514
		case PERF_COUNTER_TIMER_INV:			printf("PERF_COUNTER_TIMER_INV");break;
515
		case PERF_ELAPSED_TIME:					printf("PERF_ELAPSED_TIME");break;
516
		case PERF_LARGE_RAW_BASE:				printf("PERF_LARGE_RAW_BASE");break;
517
		case PERF_OBJ_TIME_TIMER:				printf("PERF_OBJ_TIME_TIMER");break;
518
		case PERF_PRECISION_100NS_TIMER:		printf("PERF_PRECISION_100NS_TIMER");break;
519
		case PERF_PRECISION_OBJECT_TIMER:		printf("PERF_PRECISION_OBJECT_TIMER");break;
520
		case PERF_PRECISION_SYSTEM_TIMER:		printf("PERF_PRECISION_SYSTEM_TIMER");break;
521
		case PERF_RAW_BASE:						printf("PERF_RAW_BASE");break;
522
		case PERF_RAW_FRACTION:					printf("PERF_RAW_FRACTION");break;
523
		case PERF_SAMPLE_BASE:					printf("PERF_SAMPLE_BASE");break;
524
		case PERF_SAMPLE_COUNTER:				printf("PERF_SAMPLE_COUNTER");break;
525
		case PERF_SAMPLE_FRACTION:				printf("PERF_SAMPLE_FRACTION");break;
526
		case PERF_PRECISION_TIMESTAMP:			printf("PERF_PRECISION_TIMESTAMP");break;
527
		default : printf("Unrecognised Type");
528
	}
529
	printf("\n");
530
}
531
532
PPERF_OBJECT_TYPE FirstObject( PPERF_DATA_BLOCK PerfData )
533
{
534
    return( (PPERF_OBJECT_TYPE)((PBYTE)PerfData + PerfData->HeaderLength) );
535
}
536
537
PPERF_OBJECT_TYPE NextObject(PPERF_OBJECT_TYPE PerfObj)
538
{
539
    return( (PPERF_OBJECT_TYPE)((PBYTE)PerfObj + PerfObj->TotalByteLength) );
540
}
541
542
PPERF_INSTANCE_DEFINITION FirstInstance(PPERF_OBJECT_TYPE PerfObj)
543
{
544
    return( (PPERF_INSTANCE_DEFINITION)((PBYTE)PerfObj + PerfObj->DefinitionLength) );
545
}
546
547
PPERF_INSTANCE_DEFINITION NextInstance(PPERF_INSTANCE_DEFINITION PerfInst)
548
{
549
    PPERF_COUNTER_BLOCK PerfCntrBlk;
550
551
    PerfCntrBlk = (PPERF_COUNTER_BLOCK)((PBYTE)PerfInst + PerfInst->ByteLength);
552
553
    return( (PPERF_INSTANCE_DEFINITION)((PBYTE)PerfCntrBlk + PerfCntrBlk->ByteLength) );
554
}
555
556
PPERF_COUNTER_DEFINITION FirstCounter(PPERF_OBJECT_TYPE PerfObj)
557
{
558
    return( (PPERF_COUNTER_DEFINITION) ((PBYTE)PerfObj + PerfObj->HeaderLength) );
559
}
560
561
PPERF_COUNTER_DEFINITION NextCounter(PPERF_COUNTER_DEFINITION PerfCntr)
562
{
563
    return( (PPERF_COUNTER_DEFINITION)((PBYTE)PerfCntr + PerfCntr->ByteLength) );
564
}
565
566
void formatOutputString(char* output)
567
{
568
	int i = 0;
569
	for (i=strlen(output)-1; i>= 0; i--)
570
	{
571
		if ((output[i] >= 48 && output[i] <= 57) || output[i] == 'E' || output[i] == '-')
572
		{
573
			// The char is either a number of an E. ignore it
574
		}
575
		else
576
		{
577
			output[i] = '.';
578
			return;
579
		}
580
	}
581
}
582
583
char* checktype(char* key, PPERF_COUNTER_BLOCK PtrToCntr,PPERF_COUNTER_DEFINITION PerfCntr,PPERF_DATA_BLOCK PerfData, PPERF_OBJECT_TYPE PerfObj)
584
{
585
	char* output;
586
587
	PPERF_COUNTER_DEFINITION PerfCntr2; 
588
589
	output = malloc(1024);
590
	memset(output,'\0',1024);
591
592
//	printtype(key,PerfCntr);
593
594
	switch(PerfCntr->CounterType)
595
	{
596
// Preliminary Testing Done...
597
		case PERF_100NSEC_TIMER:				getPERF_100NSEC_TIMER(output,key, PtrToCntr, PerfCntr, PerfData);break;
598
		case PERF_100NSEC_TIMER_INV:			getPERF_100NSEC_TIMER_INV(output,key, PtrToCntr, PerfCntr, PerfData);break;
599
		case PERF_AVERAGE_BULK:					PerfCntr2 = NextCounter(PerfCntr);getPERF_AVERAGE_BULK(output,key, PtrToCntr, PerfCntr, PerfCntr2);break;
600
		case PERF_AVERAGE_TIMER:				PerfCntr2 = NextCounter(PerfCntr);getPERF_AVERAGE_TIMER(output,key, PtrToCntr,PerfCntr, PerfCntr2 , PerfData);break;
601
		case PERF_COUNTER_BULK_COUNT:			getPERF_COUNTER_BULK_COUNT(output,key, PtrToCntr,PerfCntr,PerfData);break;
602
		case PERF_COUNTER_COUNTER:				getPERF_COUNTER_COUNTER(output,key, PtrToCntr,PerfCntr,PerfData);break;
603
		case PERF_COUNTER_LARGE_RAWCOUNT:		getPERF_COUNTER_LARGE_RAWCOUNT(output, key,PtrToCntr,PerfCntr);break;
604
		case PERF_COUNTER_LARGE_RAWCOUNT_HEX:	getPERF_COUNTER_LARGE_RAWCOUNT_HEX(output,key, PtrToCntr,PerfCntr);break;
605
		case PERF_COUNTER_NODATA:				getPERF_COUNTER_NODATA(output,key, PtrToCntr,PerfCntr);break;
606
		case PERF_COUNTER_RAWCOUNT:				getPERF_COUNTER_RAWCOUNT(output,key, PtrToCntr,PerfCntr);break;
607
		case PERF_ELAPSED_TIME:					getPERF_ELAPSED_TIME(output,key, PtrToCntr,PerfCntr, PerfData, PerfObj);break;
608
		case PERF_RAW_FRACTION:					PerfCntr2 = NextCounter(PerfCntr); getPERF_RAW_FRACTION(output,key, PtrToCntr,PerfCntr, PerfCntr2);break;
609
		case PERF_SAMPLE_FRACTION:				PerfCntr2 = NextCounter(PerfCntr); getPERF_SAMPLE_FRACTION(output,key, PtrToCntr,PerfCntr,PerfCntr2);break;
610
611
// NOT TESTED
612
		case PERF_COUNTER_DELTA:				getPERF_COUNTER_DELTA(output,key, PtrToCntr,PerfCntr);break;
613
		case PERF_COUNTER_LARGE_DELTA:			getPERF_COUNTER_LARGE_DELTA(output, key,PtrToCntr,PerfCntr);break;
614
		case PERF_SAMPLE_COUNTER:				PerfCntr2 = NextCounter(PerfCntr); getPERF_SAMPLE_COUNTER(output,key, PtrToCntr,PerfCntr,PerfCntr2);break;
615
		case PERF_COUNTER_LARGE_QUEUELEN_TYPE:	getPERF_COUNTER_LARGE_QUEUELEN_TYPE(output,key, PtrToCntr,PerfCntr, PerfData);break;
616
		case PERF_100NSEC_MULTI_TIMER:			PerfCntr2 = NextCounter(PerfCntr);getPERF_100NSEC_MULTI_TIMER(output, key, PtrToCntr, PerfCntr, PerfCntr2, PerfData);break;
617
		case PERF_100NSEC_MULTI_TIMER_INV:		PerfCntr2 = NextCounter(PerfCntr);getPERF_100NSEC_MULTI_TIMER_INV(output, key,PtrToCntr, PerfCntr, PerfCntr2, PerfData);break;
618
		case PERF_COUNTER_RAWCOUNT_HEX:			getPERF_COUNTER_RAWCOUNT_HEX(output,key, PtrToCntr, PerfCntr);break;
619
		case PERF_COUNTER_TIMER:				getPERF_COUNTER_TIMER(output,key, PtrToCntr,PerfCntr, PerfData);break;
620
		case PERF_COUNTER_TIMER_INV:			getPERF_COUNTER_TIMER_INV(output,key, PtrToCntr,PerfCntr, PerfData);break;
621
		case PERF_COUNTER_MULTI_TIMER:			PerfCntr2 = NextCounter(PerfCntr);getPERF_COUNTER_MULTI_TIMER(output,key, PtrToCntr,PerfCntr, PerfCntr2, PerfData);break;
622
		case PERF_COUNTER_MULTI_TIMER_INV:		PerfCntr2 = NextCounter(PerfCntr);getPERF_COUNTER_MULTI_TIMER_INV(output,key, PtrToCntr,PerfCntr, PerfCntr2, PerfData);break;
623
		case PERF_COUNTER_QUEUELEN_TYPE:		getPERF_COUNTER_QUEUELEN_TYPE(output,key, PtrToCntr,PerfCntr, PerfData);break;
624
		case PERF_OBJ_TIME_TIMER:				getPERF_OBJ_TIME_TIMER(output,key, PtrToCntr,PerfCntr, PerfData);break;
625
		case PERF_PRECISION_100NS_TIMER:		PerfCntr2 = NextCounter(PerfCntr);getPERF_PRECISION_100NS_TIMER(output,key, PtrToCntr,PerfCntr,PerfCntr2, PerfData);break;
626
		case PERF_PRECISION_OBJECT_TIMER:		PerfCntr2 = NextCounter(PerfCntr);printf("PERF_PRECISION_OBJECT_TIMER");break;
627
		case PERF_PRECISION_SYSTEM_TIMER:		PerfCntr2 = NextCounter(PerfCntr);printf("PERF_PRECISION_SYSTEM_TIMER");break;
628
		case PERF_COUNTER_100NS_QUEUELEN_TYPE:	getPERF_COUNTER_100NS_QUEUELEN_TYPE(output,key, PtrToCntr,PerfCntr, PerfData);break;
629
630
// NOT DONE YET
631
//		case PERF_COUNTER_TEXT: getPERF_COUNTER_TEXT(output, PtrToCntr,PerfCntr);break;
632
633
//Base Types - NO CALCULA TION NEEDED
634
		case PERF_AVERAGE_BASE: break;
635
		case PERF_SAMPLE_BASE: break;
636
		case PERF_RAW_BASE: break;
637
		case PERF_COUNTER_MULTI_BASE: break;
638
		case PERF_LARGE_RAW_BASE: break;
639
		case PERF_PRECISION_TIMESTAMP: break;
640
641
//Not Recognised Types 
642
		default: printf("Unrecognised Type (%s) - %d\n",key,PerfCntr->CounterType);
643
	}
644
645
	formatOutputString(output);
646
	return output;
647
}
648
649
650
int GetNameStrings(char* host)
651
{
652
    HKEY hKeyPerflib;      
653
    HKEY hKeyPerflib009;   
654
    DWORD dwMaxValueLen;   // maximum size of key values
655
    DWORD dwBuffer;        // bytes to allocate for buffers
656
    DWORD dwBufferSize;    // size of dwBuffer
657
    LPSTR lpCurrentString; // pointer for enumerating data strings
658
    DWORD dwCounter;       // current counter index
659
	HKEY remoteKeyLocalMachine;
660
	int rt;
661
662
// Get the number of Counter items.
663
664
	if ((rt = RegConnectRegistry(host,HKEY_LOCAL_MACHINE,&remoteKeyLocalMachine)) != ERROR_SUCCESS)
665
	{
666
		logToFile("%sRegConnectRegistry ERROR : ? %d\n",PREFIX,rt);
667
		return 0;
668
	}
669
670
671
    if( (rt = RegOpenKeyEx( remoteKeyLocalMachine,
672
        "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib",
673
        0,
674
        KEY_READ,
675
        &hKeyPerflib)) != ERROR_SUCCESS
676
		) {
677
		logToFile("%sRegOpenKeyEx ERROR : ? %d\n",PREFIX,rt);
678
		return 0;
679
	}
680
681
    dwBufferSize = sizeof(dwBuffer);
682
683
    if( (rt = RegQueryValueEx( hKeyPerflib,
684
        "Last Counter",
685
        NULL,
686
        NULL,
687
        (LPBYTE) &dwBuffer,
688
        &dwBufferSize )) != ERROR_SUCCESS
689
		) {
690
		logToFile("%sRegQueryValueEx ERROR : ? %d\n",PREFIX,rt);
691
        return 0;
692
	}
693
694
// Allocate memory for the names array.
695
696
    lpNamesArray = malloc( (dwBuffer+1) * sizeof(LPSTR) );
697
	lpNamesArraySize = dwBuffer+1;
698
    if( lpNamesArray == NULL) {
699
		return 0;
700
	}
701
	memset(lpNamesArray,'\0',(dwBuffer+1) * sizeof(LPSTR));
702
703
	lpHelpArray = malloc( (dwBuffer+3) * sizeof(LPSTR) );
704
    if( lpHelpArray == NULL) {
705
		free(lpNamesArray);
706
        return 0;
707
	}
708
	memset(lpHelpArray,'\0',(dwBuffer+3) * sizeof(LPSTR));
709
710
// Open the key containing the counter and object names.
711
712
    if( (rt=RegOpenKeyEx( remoteKeyLocalMachine,
713
    "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009",
714
        0,
715
        KEY_READ,
716
        &hKeyPerflib009)) != ERROR_SUCCESS
717
		){
718
		logToFile("%sRegOpenKexEx ERROR : ? %d\n",PREFIX,rt);
719
        return 0;
720
	}
721
722
// Get the size of the largest value in the key (Counter or Help).
723
724
    if( (rt=RegQueryInfoKey( hKeyPerflib009,
725
        NULL,
726
        NULL,
727
        NULL,
728
        NULL,
729
        NULL,
730
        NULL,
731
        NULL,
732
        NULL,
733
        &dwMaxValueLen,
734
        NULL,
735
        NULL)) != ERROR_SUCCESS
736
      )	{
737
		logToFile("%sRegQueryValueEx ERROR : ? %d\n",PREFIX,rt);
738
        return 0;
739
	}
740
741
// Allocate memory for the counter and object names.
742
743
    dwBuffer = dwMaxValueLen + 1;
744
745
    lpNameStrings = malloc( dwBuffer * sizeof(CHAR) );
746
	if (lpNameStrings == NULL) {
747
		free( lpNamesArray );
748
		free( lpHelpArray );
749
		return 0;
750
	}
751
    lpHelpStrings = malloc( dwBuffer * sizeof(CHAR) );
752
    if (lpHelpStrings == NULL)
753
    {
754
        free( lpNamesArray );
755
		free( lpHelpArray );
756
		free( lpNameStrings );
757
		return 0;
758
    }
759
760
// Read the Counter value.
761
762
	dwBufferSize = dwBuffer;
763
764
    if( (rt=RegQueryValueEx( hKeyPerflib009,
765
        "Counter",
766
        NULL,
767
        NULL,
768
        lpNameStrings, &dwBuffer )) != ERROR_SUCCESS
769
		) {
770
      free( lpNamesArray );
771
 	  free( lpHelpArray );
772
	  free( lpNameStrings );
773
	  free( lpHelpStrings );
774
	  logToFile("%sUnable to read counter value : ? %d\n",PREFIX,rt);
775
      return 0;
776
	}
777
778
    if( (rt = RegQueryValueEx( hKeyPerflib009,
779
        "Help",
780
        NULL,
781
        NULL,
782
        lpHelpStrings, &dwBufferSize )) != ERROR_SUCCESS
783
		) {
784
      free( lpNamesArray );
785
 	  free( lpHelpArray );
786
	  free( lpNameStrings );
787
	  free( lpHelpStrings );
788
	  logToFile("%sUnable to read counter value : ? %d\n",PREFIX,rt);
789
      return 0;
790
	}
791
    RegCloseKey( hKeyPerflib009 );
792
	RegCloseKey(remoteKeyLocalMachine);
793
    RegCloseKey( hKeyPerflib );
794
795
// Load names into an array, by index.
796
797
    for( lpCurrentString = lpNameStrings; *lpCurrentString;lpCurrentString += (lstrlen(lpCurrentString)+1) )
798
    {
799
        dwCounter = atol( lpCurrentString );
800
801
        lpCurrentString += (lstrlen(lpCurrentString)+1);
802
803
        lpNamesArray[dwCounter] = (LPSTR) lpCurrentString;
804
    }
805
806
    for( lpCurrentString = lpHelpStrings; *lpCurrentString;lpCurrentString += (lstrlen(lpCurrentString)+1) )
807
    {
808
        dwCounter = atol( lpCurrentString );
809
810
        lpCurrentString += (lstrlen(lpCurrentString)+1);
811
812
        lpHelpArray[dwCounter] = (LPSTR) lpCurrentString;
813
    }
814
815
    return 1;
816
817
}
818
819
void printout(char** data,int numstrings)
820
{
821
	int i;
822
	for (i=0;i<numstrings;i++)
823
	{
824
		logToFile("%s\n",data[i]);
825
	}
826
}
827
828
void cleardata(char** data,int numstrings)
829
{
830
	int i;
831
	for (i=0;i<numstrings;i++)
832
	{
833
		free(data[i]);
834
	}
835
	free(data);
836
}
837
838
wchar_t* getParentInstanceName(PPERF_DATA_BLOCK PerfData, DWORD parentinstindex, DWORD objectid)
839
{
840
	PPERF_OBJECT_TYPE PerfObj;
841
	PPERF_INSTANCE_DEFINITION PerfInst;
842
	wchar_t* strname;
843
	DWORD i,k; 
844
845
    PerfObj = FirstObject( PerfData );
846
847
    for( i=0; i < PerfData->NumObjectTypes; i++ )
848
    {
849
		if (PerfObj->ObjectNameTitleIndex != objectid)
850
		{
851
			PerfObj = NextObject( PerfObj );
852
			continue;
853
		}
854
855
        if( PerfObj->NumInstances > 0 )
856
        {
857
            PerfInst = FirstInstance( PerfObj );
858
859
            for( k=0; k < (DWORD)(PerfObj->NumInstances); k++ )
860
            {
861
862
				if (k != parentinstindex)
863
				{
864
					PerfInst = NextInstance( PerfInst );
865
					continue;
866
				}
867
868
				strname = ((wchar_t*)((PBYTE)PerfInst + PerfInst->NameOffset));
869
870
				return strname;		
871
			}
872
		}
873
		return NULL;
874
	}
875
	return NULL;
876
}
877
878
879
int getObjectID(PPERF_OBJECT_TYPE PerfObj, char* id, int idsiz) {
880
	int ret = _snprintf(id,idsiz,"%d\0",PerfObj->ObjectNameTitleIndex);
881
	if (ret < 0) ret = idsiz;
882
	return ret;
883
}
884
885
int getObjectCntrID(PPERF_OBJECT_TYPE PerfObj, PPERF_COUNTER_DEFINITION PerfCntr, char* id, int idsiz) {
886
	int ret = _snprintf(id,idsiz,"%dC%d\0",PerfObj->ObjectNameTitleIndex,PerfCntr->CounterNameTitleIndex);
887
	if (ret < 0) ret = idsiz;
888
	return ret;
889
}
890
891
int getInstanceKey(PPERF_DATA_BLOCK PerfData, PPERF_INSTANCE_DEFINITION PerfInst, char* id, int idsiz) {
892
893
	wchar_t* temp1;
894
	wchar_t* temp2;
895
	int len1;
896
	int len2;
897
898
	int ret;
899
900
	char* buf;
901
	int count = 0;
902
903
	if (PerfInst->ParentObjectInstance != 0)
904
	{
905
		temp1 = getParentInstanceName(PerfData,PerfInst->ParentObjectInstance,PerfInst->ParentObjectTitleIndex);
906
		temp2 = ((wchar_t*)((PBYTE)PerfInst + PerfInst->NameOffset));
907
		if (temp1 != NULL)
908
		{
909
			len1 = wcslen(temp1);
910
			len2 = wcslen(temp2);
911
912
			buf = malloc(sizeof(char) * (len1+len2+10));
913
			sprintf(buf,"%S/%S%c",temp1,temp2,'\0');
914
		}
915
		else
916
		{
917
			len2 = wcslen(temp2);
918
919
			buf = malloc(sizeof(char) * (len2+10));
920
			sprintf(buf,"%S%c",temp2,'\0');
921
		}	
922
	}
923
	else
924
	{
925
		temp2 = ((wchar_t*)((PBYTE)PerfInst + PerfInst->NameOffset));
926
927
		len2 = wcslen(temp2);
928
929
		buf = malloc(sizeof(char) * (len2+10));
930
		sprintf(buf,"%S%c",temp2,'\0');
931
			
932
	}	
933
934
	ret = _snprintf(id,idsiz,"%s%c",buf,'\0');
935
	if (ret < 0) ret = idsiz;
936
	free(buf);
937
	return ret;
938
}
939
940
int getInstanceName(PPERF_DATA_BLOCK PerfData, char* instKey, int count, char* id, int idsiz) {
941
	int ret;
942
943
	if (count == 0) {
944
		ret = _snprintf(id,idsiz,"%s%c",instKey,'\0');
945
		if (ret < 0) ret = idsiz;
946
		return ret;
947
	} else {
948
		ret = _snprintf(id,idsiz,"%s#%d%c",instKey,count,'\0');
949
		if (ret < 0) ret = idsiz;
950
		return ret;
951
	}
952
}
953
954
int getInstanceID(PPERF_DATA_BLOCK PerfData, PPERF_OBJECT_TYPE PerfObj, char* instName, char* id, int idsiz, HashTable* idhasht, int populate_idhash) {
955
	int keyLen = sizeof(char) * 128;
956
	char* keyID = malloc(keyLen);
957
	int instid;
958
	int ret;
959
960
	while (0 > _snprintf(keyID,keyLen,"%dI%s%c",PerfObj->ObjectNameTitleIndex,instName,'\0')) {
961
		keyLen *= 2;
962
		keyID = realloc(keyID,keyLen);
963
	}
964
965
	instid = (int)tableGet(idhasht,keyID);
966
967
	if (instid == 0 && populate_idhash)
968
	{
969
		instid = idhasht->count+1;
970
 
971
		tablePut(idhasht,keyID,instid);
972
	}
973
974
	free(keyID);
975
976
	ret = _snprintf(id,idsiz,"%dI%d%c",PerfObj->ObjectNameTitleIndex,instid,'\0');
977
	if (ret < 0) ret = idsiz;
978
	return ret;
979
}
980
981
int getInstanceCntrID(PPERF_DATA_BLOCK PerfData, PPERF_OBJECT_TYPE PerfObj, char* instid, PPERF_COUNTER_DEFINITION PerfCntr, char* id, int idsiz, HashTable* idhasht) {
982
	int ret = _snprintf(id,idsiz,"%sC%d%c",instid,PerfCntr->CounterNameTitleIndex,'\0');
983
	if (ret < 0) ret = idsiz;
984
	return ret;
985
}
986
987
void clearData(char** array, int count)
988
{
989
	int i;
990
	for (i =0 ;i<count;i++) {
991
		free(array[i]);
992
	}
993
	free(array);
994
}
995
996
unsigned long getObjectCount(PPERF_DATA_BLOCK PerfData)
997
{
998
	PPERF_OBJECT_TYPE PerfObj;
999
	unsigned long count =0;
1000
	unsigned long totalsize = 0;
1001
1002
	if (PerfData->TotalByteLength == PerfData->HeaderLength)
1003
		return 0;
1004
1005
	PerfObj = FirstObject(PerfData);
1006
	totalsize = PerfData->HeaderLength + PerfObj->TotalByteLength;
1007
	count++;
1008
1009
	while (totalsize < PerfData->TotalByteLength)
1010
	{
1011
		PerfObj = NextObject(PerfObj);
1012
		count++;
1013
		totalsize = totalsize + PerfObj->TotalByteLength;
1014
	}
1015
1016
	return count;
1017
}
1018
1019
char* getRemoteHost()
1020
{
1021
	char* remoteHost = (char*) tableGet(hasht_variables,PERFMON_KEY_HOST);
1022
1023
	while (remoteHost == NULL)
1024
	{
1025
		logToFile("Waiting for variables to arrive...");
1026
		Sleep(50);
1027
		remoteHost = (char*) tableGet(hasht_variables,PERFMON_KEY_HOST);
1028
	}
1029
1030
	if (isVista)
1031
	{
1032
		if (strcmp(remoteHost,"localhost") == 0 || strcmp(remoteHost,"127.0.0.1") == 0)
1033
		{
1034
			return NULL;
1035
		}
1036
	}
1037
	else
1038
	{
1039
		if (strcmp(remoteHost,"localhost") == 0)
1040
		{
1041
			return NULL;
1042
		}
1043
	}
1044
1045
1046
	return remoteHost;
1047
}
1048
1049
char** DC_CollectionGetResults(int* numresults)
1050
{
1051
	int z;
1052
1053
	PPERF_DATA_BLOCK PerfData = NULL;
1054
1055
	char* REG_HOST;
1056
1057
	REG_HOST = getRemoteHost();	
1058
1059
1060
	PerfData = getPerfData(REG_HOST, TRUE, hasht_filters,0);
1061
1062
1063
	if (PerfData != NULL)
1064
	{
1065
	    PPERF_OBJECT_TYPE PerfObj;
1066
		PPERF_COUNTER_DEFINITION PerfCntr;
1067
		PPERF_INSTANCE_DEFINITION PerfInst;
1068
		PPERF_COUNTER_BLOCK PtrToCntr;
1069
1070
		HashTable* instancecount = tableCreate();
1071
1072
		DWORD i, j, k;
1073
1074
		int objLen = sizeof(char) * 128;
1075
		char* objID = malloc(128);
1076
		int cntrLen = sizeof(char) * 128;
1077
		char* cntrID = malloc(128);
1078
		int instLen = sizeof(char) * 128;
1079
		char* instID = malloc(128);
1080
		int instnLen = sizeof(char) * 128;
1081
		char* instName = malloc(instnLen);
1082
		int instkLen = sizeof(char) * 128;
1083
		char* instKey = malloc(instkLen);
1084
		int count;
1085
1086
		int value_len = 0;
1087
		char* value;
1088
1089
		if (results_len != -1) {
1090
			for (z = 0; z < value_index; z++) {
1091
				free(results[z]);
1092
			}
1093
			if (results != NULL) {
1094
				free(results);
1095
			} else {
1096
//				logToFile("NULL results! length = %d\n",value_index);
1097
			}
1098
		}
1099
		value_index = 0;
1100
		results_len = 10;
1101
		results = malloc(sizeof(char*) * results_len);
1102
1103
		PerfObj = FirstObject( PerfData );
1104
1105
		for( i=0; i < PerfData->NumObjectTypes; i++ ) 
1106
		{			
1107
			if (isVista)
1108
			{
1109
				// An out of bounds check on the name array
1110
				// A generic fix that is valid for all windows versions
1111
				if (PerfObj->ObjectNameTitleIndex > lpNamesArraySize)
1112
				{
1113
					PerfObj = NextObject( PerfObj );
1114
					continue;
1115
				}
1116
			}
1117
1118
			while (objLen <= getObjectID(PerfObj,objID,objLen)) 
1119
			{
1120
				objLen *= 2;
1121
				objID = realloc(objID,objLen);
1122
			}
1123
1124
			if (tableGet(hasht_filters,objID) != (XINT64)NULL) 
1125
			{
1126
				//this object is ON
1127
				if (PerfObj->NumInstances == PERF_NO_INSTANCES) 
1128
				{
1129
					// just check its counters
1130
					
1131
					PerfCntr = FirstCounter(PerfObj);
1132
1133
					for ( j=0; j < PerfObj->NumCounters; j++ ) {
1134
						while (cntrLen <= getObjectCntrID(PerfObj,PerfCntr,cntrID,cntrLen)) {
1135
							cntrLen *= 2;
1136
							cntrID = realloc(cntrID,cntrLen);
1137
						}
1138
						if ((tableGet(hasht_filters,cntrID) != (XINT64)NULL) && (isBaseType(PerfCntr->CounterType)==0)) {
1139
							//this counter is ON - send its value
1140
							PtrToCntr = (PPERF_COUNTER_BLOCK) ((PBYTE)PerfObj + PerfObj->DefinitionLength );
1141
1142
							value = checktype(cntrID,PtrToCntr,PerfCntr,PerfData,PerfObj);
1143
							value_len = strlen(cntrID) + strlen(value) + 4;
1144
1145
							results[value_index] = malloc(value_len);
1146
							_snprintf(results[value_index],value_len,"%s%c%s%c",cntrID,'\0',value,'\0');
1147
1148
							value_index++;
1149
1150
							if (value_index == results_len) {
1151
								results_len *= 2;
1152
								results = realloc(results,sizeof(char*) * results_len);
1153
							}
1154
1155
							free(value);
1156
						}
1157
1158
						PerfCntr = NextCounter(PerfCntr);						
1159
					}
1160
1161
				} else {
1162
					//check its instances and their counters
1163
1164
					tableClear(instancecount);
1165
1166
					PerfInst = FirstInstance( PerfObj );
1167
1168
					for ( j=0; j < ((DWORD) (PerfObj->NumInstances)); j++) 
1169
					{
1170
1171
						while (instkLen <= getInstanceKey(PerfData,PerfInst,instKey,instkLen)) 
1172
						{
1173
							instkLen *= 2;
1174
							instKey = realloc(instKey,instkLen);
1175
						}
1176
1177
						count = (int)tableGet(instancecount,instKey);
1178
						while (instnLen <= getInstanceName(PerfData,instKey,count,instName,instnLen)) 
1179
						{
1180
							instnLen *= 2;
1181
							instName = realloc(instName,instnLen);
1182
						}
1183
						tablePut(instancecount,instKey,count+1);
1184
1185
						while (instLen <= getInstanceID(PerfData,PerfObj,instName,instID,instLen,idhasht,FALSE)) 
1186
						{
1187
							instLen *= 2;
1188
							instID = realloc(instID,instLen);
1189
						}
1190
				
1191
						if (tableGet(hasht_filters,instID) != (XINT64)NULL) 
1192
						{
1193
							PerfCntr = FirstCounter(PerfObj);
1194
1195
							for ( k=0; k < PerfObj->NumCounters; k++ ) 
1196
							{
1197
								while (cntrLen <= getInstanceCntrID(PerfData,PerfObj,instID,PerfCntr,cntrID,cntrLen,idhasht)) 
1198
								{
1199
									cntrLen *= 2;
1200
									cntrID = realloc(cntrID,cntrLen);
1201
								}
1202
								
1203
								if ((tableGet(hasht_filters,cntrID) != (XINT64)NULL)&& (isBaseType(PerfCntr->CounterType)==0)) 
1204
								{
1205
									//this counter is ON - send its value
1206
									PtrToCntr = (PPERF_COUNTER_BLOCK) ((PBYTE)PerfInst + PerfInst->ByteLength);
1207
1208
									value = checktype(cntrID,PtrToCntr,PerfCntr,PerfData,PerfObj);
1209
1210
									value_len = strlen(cntrID) + strlen(value) + 4;
1211
									results[value_index] = malloc(value_len);
1212
									_snprintf(results[value_index],value_len,"%s%c%s%c",cntrID,'\0',value,'\0');
1213
									value_index++;
1214
1215
									if (value_index == results_len) 
1216
									{
1217
										results_len *= 2;
1218
										results = realloc(results,sizeof(char*) * results_len);
1219
									}
1220
1221
									free(value);
1222
1223
								}
1224
								PerfCntr = NextCounter(PerfCntr);						
1225
							}
1226
						}
1227
						PerfInst = NextInstance( PerfInst );
1228
					}
1229
				}
1230
			}
1231
			PerfObj = NextObject( PerfObj );
1232
		}
1233
		free(PerfData);
1234
1235
		tableClear(instancecount);
1236
1237
		tableDelete(instancecount);
1238
1239
		free(objID);
1240
		free(instID);
1241
		free(cntrID);
1242
		free(instName);
1243
		free(instKey);
1244
1245
		*numresults = value_index;
1246
1247
		return results;
1248
	}
1249
	else
1250
	{
1251
		*numresults = 0;
1252
1253
		return NULL;
1254
	}
1255
}
1256
1257
void addToTree(char*** treedatp, int* treelenp, int* treeindexp, char* pid, char* id, char* name, char* help, char* suffix) 
1258
{
1259
	char** treedat = *treedatp;
1260
	int treelen = *treelenp;
1261
	int treeindex = *treeindexp;
1262
	int counter = 0;
1263
1264
	//this needs to be pid\id\name\help\suffix
1265
	int datLen = 128;
1266
	treedat[treeindex] = malloc(sizeof(char) * datLen);
1267
1268
	// Check if this is a counter or not.
1269
	if (strchr(id, 'C') == NULL)
1270
		counter = 0;
1271
	else 
1272
		counter = 1;
1273
1274
//logToFile("ADD %s %s %s %s %s\n",pid,id,name,"(help)",suffix);
1275
1276
	while (0 >  _snprintf(treedat[treeindex],datLen,"%s%c%s%c%s%c%s%c%s%c%d%c",
1277
									pid,'\0',		//pid
1278
									id,'\0',		//id
1279
									name,'\0',		//name
1280
									help,'\0',		//help
1281
									suffix,'\0',    //suffix
1282
									counter,'\0')) 
1283
	{	
1284
		datLen *=2;
1285
1286
		treedat[treeindex] = realloc(treedat[treeindex],sizeof(char) * datLen);
1287
	}
1288
1289
	treeindex++;
1290
1291
	//extend tree length if necessary
1292
	if (treeindex == treelen) {
1293
		treelen += 20;
1294
		treedat = realloc(treedat,sizeof(char*) * treelen);
1295
	}
1296
	
1297
	*treedatp = treedat;
1298
	*treelenp = treelen;
1299
	*treeindexp = treeindex;
1300
}
1301
1302
char* DC_CollectionGetAgentName()
1303
{
1304
	logToFile("Sending agent name from the collection DLL - %s\n",agent_type);
1305
	return agent_type;
1306
}
1307
1308
char** DC_CollectionGetTree( int* numstrings)
1309
{
1310
	char* REG_HOST;
1311
	XINT64 getGlobalAgain;
1312
	PPERF_DATA_BLOCK PerfData;
1313
1314
	getGlobalAgain = tableGet(hasht_variables,REGET_CHILDREN);
1315
1316
	REG_HOST = getRemoteHost();		
1317
1318
	logToFile("%sCollecting from host %s\n",PREFIX,REG_HOST);
1319
1320
	PerfData = getPerfData(REG_HOST, FALSE, NULL,getGlobalAgain);
1321
	if (PerfData != NULL)
1322
	{
1323
	    PPERF_OBJECT_TYPE PerfObj;
1324
	    PPERF_INSTANCE_DEFINITION PerfInst;
1325
	    PPERF_COUNTER_DEFINITION PerfCntr;
1326
1327
		HashTable* instancecount = tableCreate();
1328
1329
		int treelen = 10;
1330
		int treeindex = 0;
1331
		char** treedat = malloc(sizeof(char*) * treelen);
1332
1333
		DWORD i, j, k;
1334
1335
		int objLen = sizeof(char) * 128;
1336
		char* objID = malloc(objLen);
1337
1338
		int instLen = sizeof(char) * 128;
1339
		char* instID = malloc(instLen);
1340
1341
		int cntrLen = sizeof(char) * 128;
1342
		char* cntrID = malloc(cntrLen);
1343
1344
		int instnLen = sizeof(char) * 128;
1345
		char* instName = malloc(instnLen);
1346
1347
		int instkLen = sizeof(char) * 128;
1348
		char* instKey = malloc(instkLen);
1349
		int count;
1350
1351
		//get the name and help arrays
1352
		if(GetNameStrings(REG_HOST)==0)
1353
		{
1354
			logToFile("%sError getting performance data from the registry...",PREFIX);
1355
1356
			/* RKD:  Before we return we need to free the perfData object we recieved from the kernel */
1357
			free(PerfData);
1358
1359
			return 0;
1360
		}
1361
1362
		//iterate through everything 
1363
		//logToFile("Object Count is %lu\n",PerfData->NumObjectTypes);
1364
		PerfObj = FirstObject( PerfData );
1365
1366
		for( i=0; i < PerfData->NumObjectTypes; i++ ) 
1367
		{	
1368
			if (isVista)
1369
			{
1370
				// Out of bounds check
1371
				if (PerfObj->ObjectNameTitleIndex > lpNamesArraySize)
1372
				{
1373
					PerfObj = NextObject( PerfObj );
1374
					continue;
1375
				}
1376
			}
1377
1378
			//
1379
			// Get the object ID
1380
			//
1381
			while (objLen <= getObjectID(PerfObj,objID,objLen)) 
1382
			{
1383
				objLen *=2;
1384
				objID = realloc(objID,objLen);
1385
			}
1386
1387
			//
1388
			// Unseen object - trace its data
1389
			//
1390
			addToTree(&treedat,&treelen,&treeindex,
1391
								"",												//pid
1392
								objID,											//id
1393
								lpNamesArray[PerfObj->ObjectNameTitleIndex],	//name
1394
								lpHelpArray[PerfObj->ObjectHelpTitleIndex],		//help / desc
1395
								"");											//suffix
1396
1397
			if (PerfObj->NumInstances == PERF_NO_INSTANCES) 
1398
			{
1399
				// just check its counters				
1400
				PerfCntr = FirstCounter(PerfObj);
1401
1402
				for ( j=0; j < PerfObj->NumCounters; j++ ) 
1403
				{
1404
					char *t1, *t2;
1405
					//
1406
					// Get the counter ID
1407
					//
1408
					while (cntrLen <= getObjectCntrID(PerfObj,PerfCntr,cntrID,cntrLen)) 
1409
					{
1410
						cntrLen *= 2;
1411
						cntrID = realloc(cntrID,cntrLen);
1412
					}
1413
1414
					//
1415
					// Unseen counter - trace its data
1416
					//
1417
1418
					t1 = lpNamesArray[PerfCntr->CounterNameTitleIndex];
1419
					t2 = lpHelpArray[PerfCntr->CounterHelpTitleIndex];
1420
1421
					if (t1 == NULL)
1422
					{
1423
						logToFile("%sSkipped Counter #%d\n",PREFIX,PerfCntr->CounterNameTitleIndex);							
1424
						logToFile("%s\n",t2);
1425
						continue;
1426
					}
1427
					else if (t1[0] == '\0')
1428
					{
1429
						logToFile("%sSkipped Counter #%d\n",PREFIX,PerfCntr->CounterNameTitleIndex);
1430
						logToFile("%s\n",t2);
1431
						continue;
1432
					}
1433
1434
					addToTree(&treedat,&treelen,&treeindex,
1435
										objID,												//pid
1436
										cntrID,											//id
1437
										lpNamesArray[PerfCntr->CounterNameTitleIndex],	//name
1438
										lpHelpArray[PerfCntr->CounterHelpTitleIndex],		//help / desc
1439
										"");											//suffix
1440
1441
					PerfCntr = NextCounter(PerfCntr);						
1442
				}
1443
			} 
1444
			else 
1445
			{
1446
				//check its instances and their counters
1447
1448
				tableClear(instancecount);
1449
1450
				PerfInst = FirstInstance( PerfObj );
1451
1452
				for ( j=0; j < ((DWORD)(PerfObj->NumInstances)); j++) 
1453
				{
1454
1455
					while (instkLen <= getInstanceKey(PerfData,PerfInst,instKey,instkLen)) 
1456
					{
1457
						instkLen *= 2;
1458
						instKey = realloc(instKey,instkLen);
1459
					}
1460
1461
					count = (int)tableGet(instancecount,instKey);
1462
					while (instnLen <= getInstanceName(PerfData,instKey,count,instName,instnLen)) 
1463
					{
1464
						instnLen *= 2;
1465
						instName = realloc(instName,instnLen);
1466
					}
1467
					tablePut(instancecount,instKey,count+1);
1468
					
1469
					//
1470
					// Get the instance ID
1471
					//
1472
					while(instLen <= getInstanceID(PerfData,PerfObj,instName,instID,instLen,idhasht,TRUE)) 
1473
					{
1474
						instLen *= 2;
1475
						instID = realloc(instID,instLen);
1476
					}
1477
1478
					//
1479
					// Unseen instance - trace its data
1480
					//
1481
1482
					addToTree(&treedat,&treelen,&treeindex,
1483
										objID,											//pid
1484
										instID,											//id
1485
										instName,										//name
1486
										"",												//help / desc
1487
										"");											//suffix
1488
					
1489
					PerfCntr = FirstCounter(PerfObj);
1490
1491
					for ( k=0; k < PerfObj->NumCounters; k++ ) 
1492
					{
1493
						char* t1;
1494
						//
1495
						// Get the counter ID
1496
						//
1497
						while (cntrLen <= getInstanceCntrID(PerfData,PerfObj,instID,PerfCntr,cntrID,cntrLen,idhasht)) 
1498
						{
1499
							cntrLen *= 2;
1500
							cntrID = realloc(cntrID,cntrLen);
1501
						}
1502
					
1503
						//
1504
						// Unseen instance counter - trace its data
1505
						//
1506
1507
						t1 = lpNamesArray[PerfCntr->CounterNameTitleIndex];
1508
1509
						if (t1 == NULL)
1510
						{
1511
							logToFile("%sSkipped Counter #%d\n",PREFIX,PerfCntr->CounterNameTitleIndex);
1512
							continue;
1513
						}
1514
						else if (t1[0] == '\0')
1515
						{
1516
							logToFile("%sSkipped Counter #%d\n",PREFIX,PerfCntr->CounterNameTitleIndex);
1517
							continue;
1518
						}		
1519
1520
						addToTree(&treedat,&treelen,&treeindex,
1521
											instID,											//pid
1522
											cntrID,											//id
1523
											lpNamesArray[PerfCntr->CounterNameTitleIndex],	//name
1524
											lpHelpArray[PerfCntr->CounterHelpTitleIndex],	//help / desc
1525
											"");											//suffix
1526
							
1527
1528
						PerfCntr = NextCounter(PerfCntr);						
1529
					}
1530
					PerfInst = NextInstance( PerfInst );
1531
				}
1532
1533
			}
1534
1535
			PerfObj = NextObject( PerfObj );
1536
		}
1537
1538
		free(PerfData);
1539
		tableDelete(instancecount);
1540
		free(objID);
1541
		free(instID);
1542
		free(cntrID);
1543
		free(instName);
1544
		free(instKey);
1545
		free( lpNameStrings );
1546
		free( lpHelpStrings );
1547
		free( (void*)lpNamesArray );
1548
		free( (void*)lpHelpArray );
1549
		*numstrings = treeindex;
1550
		return treedat;
1551
	}
1552
	else
1553
	{
1554
		*numstrings = 0;
1555
		return NULL;
1556
	}
1557
}
1558
1559
(-)src-native-new/src/HCLauncher/WinBuild/HCLauncher.dsw (+29 lines)
Added Link Here
1
Microsoft Developer Studio Workspace File, Format Version 6.00
2
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3
4
###############################################################################
5
6
Project: "HCLauncher"=.\HCLauncher.dsp - Package Owner=<4>
7
8
Package=<5>
9
{{{
10
}}}
11
12
Package=<4>
13
{{{
14
}}}
15
16
###############################################################################
17
18
Global:
19
20
Package=<5>
21
{{{
22
}}}
23
24
Package=<3>
25
{{{
26
}}}
27
28
###############################################################################
29
(-)src-native-new/src/agents/RABindings/WinBuild/RABindings.dsw (+29 lines)
Added Link Here
1
Microsoft Developer Studio Workspace File, Format Version 6.00
2
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3
4
###############################################################################
5
6
Project: "RABindings"=".\RABindings.dsp" - Package Owner=<4>
7
8
Package=<5>
9
{{{
10
}}}
11
12
Package=<4>
13
{{{
14
}}}
15
16
###############################################################################
17
18
Global:
19
20
Package=<5>
21
{{{
22
}}}
23
24
Package=<3>
25
{{{
26
}}}
27
28
###############################################################################
29
(-)src-native-new/src/agents/native/java_profiler/stack.h (+20 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: stack.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef __STACK_H__
14
#define __STACK_H__ 1
15
16
17
#include "segmentedValue.h"
18
19
20
#endif
(-)src-native-new/src/agents/perfmon/resutils/system.h (+472 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: system.h,v 1.5 2006/05/23 16:21:24 gchristelis Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
/***********************************************************************
14
 *      
15
 * File: system.h
16
 * Overview:  system abstraction header file
17
 *
18
 ***********************************************************************/
19
20
#ifndef __XSYSTEM_H__
21
#define __XSYSTEM_H__
22
23
#include <stdio.h>
24
#include <stdlib.h>
25
#include <stdarg.h>
26
#include <memory.h>
27
#include <string.h>
28
#include <limits.h>
29
#include <float.h>
30
31
#ifdef WIN32
32
	#define XSNPrintf _snprintf
33
#else
34
	#define XSNPrintf snprintf
35
#endif
36
37
#ifdef _DEBUG
38
39
   #define _CRTDBG_MAP_ALLOC // include Microsoft memory leak detection procedures
40
   #define _INC_MALLOC	     // exclude standard memory alloc procedures
41
	
42
   #include <crtdbg.h>
43
#endif
44
45
#ifdef _DEBUG
46
#ifndef DEBUG
47
#define DEBUG
48
#endif
49
#endif
50
51
#ifdef WIN32
52
//#include <winsock2.h> /* Bug 134924 */
53
#include <windows.h>
54
#include <winbase.h>
55
#include <process.h>
56
#include <signal.h>
57
#endif
58
59
#if defined(SOLARIS) || defined(LINUX) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
60
#include <unistd.h>
61
#include <sys/types.h>
62
#include <sys/wait.h>
63
#include <sys/socket.h>
64
#include <sys/timeb.h>
65
#include <pthread.h>
66
#include <netdb.h>
67
#include <netinet/in.h>
68
#include <pwd.h>
69
#include <signal.h>
70
#include <time.h>
71
#include <sys/time.h>
72
#include <dlfcn.h>
73
#include <errno.h>
74
#include <fcntl.h>
75
#include <syslog.h>
76
77
#ifdef AIX
78
#include <sys/ldr.h>
79
#endif
80
81
#endif
82
83
#ifdef _DEBUG
84
85
   #define _CRTDBG_MAP_ALLOC // include Microsoft memory leak detection procedures
86
   #define _INC_MALLOC	     // exclude standard memory alloc procedures
87
	
88
   #include <crtdbg.h>
89
#endif
90
/**
91
static FILE* ALOG = NULL;
92
#define   malloc(s)         malloc(s);if(ALOG==NULL){ALOG=fopen("C:\\ALLOC_LOG.txt","w");}fprintf(ALOG,"ALLOC %s,%d %d bytes\n",__FILE__, __LINE__,s)
93
#define   realloc(o,s)         realloc(o,s);if(ALOG==NULL){ALOG=fopen("C:\\ALLOC_LOG.txt","w");}fprintf(ALOG,"REALLOC %s,%d %d bytes\n",__FILE__, __LINE__,s)
94
**/
95
96
/*----------------------------------------
97
 * Usefuls section
98
 *----------------------------------------*/
99
100
#ifndef TRUE
101
#define TRUE (1)
102
#endif
103
#ifndef FALSE
104
#define FALSE (0)
105
#endif
106
#ifndef NONE
107
#define NONE (-1)
108
#endif
109
#ifndef BOOL
110
#define BOOL int
111
#endif
112
113
#define SUCCESS (FALSE)
114
#define FAILURE (NONE)
115
116
/*----------------------------------------
117
 * Limits section
118
 *----------------------------------------*/
119
120
#define XFILE_NAME_LIMIT (1023)
121
#define XFILE_NAME_ALLOC ((XFILE_NAME_LIMIT) + 1)
122
123
#define XARGUMENT_LIMIT (511)
124
#define XARGUMENT_ALLOC ((XARGUMENT_LIMIT) + 1)
125
126
#define XCOMMAND_LIMIT (1023)
127
#define XCOMMAND_ALLOC ((XCOMMAND_LIMIT) + 1)
128
129
#define XHOST_NAME_LIMIT (255)
130
#define XHOST_NAME_ALLOC ((XHOST_NAME_LIMIT) + 1)
131
132
#define XPORT_NAME_LIMIT (7)
133
#define XPORT_NAME_ALLOC ((XPORT_NAME_LIMIT) + 1)
134
135
#define XKIND_NAME_LIMIT (7)
136
#define XKIND_NAME_ALLOC ((XKIND_NAME_LIMIT) + 1)
137
138
#define XUSER_NAME_LIMIT (31)
139
#define XUSER_NAME_ALLOC ((XUSER_NAME_LIMIT) + 1)
140
141
#define XPASS_WORD_LIMIT (31)
142
#define XPASS_WORD_ALLOC ((XPASS_WORD_LIMIT) + 1)
143
144
#define XSTRING_LIMIT (2047)
145
#define XSTRING_ALLOC ((XSTRING_LIMIT) + 1)
146
147
/*----------------------------------------
148
 * Datatypes section
149
 *----------------------------------------*/
150
151
typedef signed   char  XINT8;
152
typedef unsigned char  XUINT8;
153
typedef unsigned short XUINT16;
154
typedef signed   short XINT16;
155
typedef unsigned int   XUINT32;
156
typedef signed   int   XINT32;
157
#ifdef WIN32
158
typedef ULONGLONG      XUINT64;
159
typedef  LONGLONG      XINT64;
160
#else
161
typedef unsigned long long  XUINT64;
162
typedef signed   long long  XINT64;
163
#endif
164
typedef float   XFLOAT;
165
typedef double  XDOUBLE;
166
167
typedef XINT8   XBYTE;  /* alias for INT8   */
168
typedef XINT16  XSHORT; /* alias for INT16  */ 
169
typedef XINT32  XINT;   /* alias for INT16  */ 
170
typedef XINT64  XLONG;  /* alias for INT64  */
171
typedef XUINT32 XBOOL;  /* alias for UINT32 */
172
173
#define XBYTE_MIN ((XBYTE)(SCHAR_MIN))
174
#define XBYTE_MAX ((XBYTE)(SCHAR_MAX))
175
176
#define XSHORT_MIN ((XSHORT)(SHRT_MIN))
177
#define XSHORT_MAX ((XSHORT)(SHRT_MAX))
178
179
#define XINT_MIN ((XINT)(INT_MIN))
180
#define XINT_MAX ((XINT)(INT_MAX))
181
182
#ifdef WIN32
183
#define XLONG_MIN ((XLONG)(0X8000000000000000I64))
184
#define XLONG_MAX ((XLONG)(0X7FFFFFFFFFFFFFFFI64))
185
#else
186
#define XLONG_MIN ((XLONG)(LLONG_MIN))
187
#define XLONG_MAX ((XLONG)(LLONG_MAX))
188
#endif
189
190
#define XFLOAT_MIN (FLT_MIN)
191
#define XFLOAT_MAX (FLT_MAX)
192
193
#define XDOUBLE_MIN (DBL_MIN)
194
#define XDOUBLE_MAX (DBL_MAX)
195
196
#define XDT_ENDIAN_LITTLE (0)
197
#define XDT_ENDIAN_BIG    (1)
198
199
#define XDT_FLOATING_IEEE    (0)
200
#define XDT_FLOATING_VAX     (1)
201
#define XDT_FLOATING_CRAY    (2)
202
#define XDT_FLOATING_IBM     (3)
203
204
#define XDT_CHARACTER_ASCII  (0)
205
#define XDT_CHARACTER_EBCDIC (1)
206
207
#define XDT_NO_MEMORY_ALIGNMENT        (0)
208
#define XDT_SPECIAL_MEMORY_ALIGNMENT   (1)
209
210
#ifdef WIN32
211
#define XDT_ENDIAN_LOCAL    (XDT_ENDIAN_LITTLE)
212
#define XDT_MEMORY_ALIGNMENT (XDT_NO_MEMORY_ALIGNMENT)
213
#endif
214
#ifdef LINUX
215
#define XDT_ENDIAN_LOCAL    (XDT_ENDIAN_LITTLE)
216
#define XDT_MEMORY_ALIGNMENT (XDT_NO_MEMORY_ALIGNMENT)
217
#endif
218
#ifdef LINUX_S390
219
#define XDT_ENDIAN_LOCAL    (XDT_ENDIAN_BIG)
220
#define XDT_MEMORY_ALIGNMENT (XDT_NO_MEMORY_ALIGNMENT)
221
#endif
222
#ifdef SOLARIS_I386
223
#define XDT_ENDIAN_LOCAL    (XDT_ENDIAN_LITTLE)
224
#define XDT_MEMORY_ALIGNMENT (XDT_SPECIAL_MEMORY_ALIGNMENT)
225
#define XDT_ALIGNMENT_16   (2)
226
#define XDT_ALIGNMENT_32   (4)
227
#define XDT_ALIGNMENT_64   (8)
228
#endif
229
#ifdef SOLARIS
230
#define XDT_ENDIAN_LOCAL    (XDT_ENDIAN_BIG)
231
#define XDT_MEMORY_ALIGNMENT (XDT_SPECIAL_MEMORY_ALIGNMENT)
232
#define XDT_ALIGNMENT_16   (2)
233
#define XDT_ALIGNMENT_32   (4)
234
#define XDT_ALIGNMENT_64   (8)
235
#endif
236
#ifdef AIX
237
#define XDT_ENDIAN_LOCAL    (XDT_ENDIAN_BIG)
238
#define XDT_MEMORY_ALIGNMENT (XDT_NO_MEMORY_ALIGNMENT)
239
#define PTHREAD_INIT_NEEDED
240
#define XDT_THREAD_SAFE_MALLOC
241
#endif
242
#if defined(USS) || defined(HPUX)
243
#error Byte endianness not defined for this platform, please define in system.h
244
#endif
245
246
#define XDT_FLOATING_LOCAL  (XDT_FLOATING_IEEE)
247
#define XDT_CHARACTER_LOCAL (XDT_CHARACTER_ASCII)
248
249
#ifdef XDT_ENDIAN_LOCAL
250
#if (XDT_ENDIAN_LOCAL != XDT_ENDIAN_LITTLE)
251
#define XDT_REVERSE_BYTE_ORDER
252
#endif
253
#endif
254
255
#ifdef XDT_FLOATING_LOCAL
256
#if (XDT_FLOATING_LOCAL != XDT_FLOATING_IEEE)
257
#error "UNSUPPORTED FLOATING FORMAT (NOT IEEE)"
258
#endif
259
#endif
260
261
#if (XDT_CHARACTER_LOCAL != XDT_CHARACTER_ASCII)
262
#error "UNSUPPORTED CHARACTER FORMAT (NOT ASCII)"
263
#endif
264
265
266
/*----------------------------------------
267
 * BEGIN ALL FUNCTION CALL PROTOTYPES
268
 * WE DO EXTERN "C" ROUND ALL FUNCTIONS
269
 *----------------------------------------*/
270
271
#ifdef __cplusplus
272
extern "C" {
273
#endif
274
275
extern void XDTByteToNative(void *data);
276
extern void XDTShortToNative(void *data);
277
extern void XDTIntToNative(void *data);
278
extern void XDTLongToNative(void *data);
279
extern void XDTFloatToNative(void *data);
280
extern void XDTDoubleToNative(void *data);
281
extern void XDTStringToNative(void *data);
282
283
extern void XDTByteToNeutral(void *data);
284
extern void XDTShortToNeutral(void *data);
285
extern void XDTIntToNeutral(void *data);
286
extern void XDTLongToNeutral(void *data);
287
extern void XDTFloatToNeutral(void *data);
288
extern void XDTDoubleToNeutral(void *data);
289
extern void XDTStringToNeutral(void *data);
290
291
extern XSHORT  XDTShortToAligned(XSHORT*, void* data);
292
extern XINT    XDTIntToAligned(XINT*, void* data);
293
extern XFLOAT  XDTFloatToAligned(XFLOAT*, void* data);
294
extern XLONG   XDTLongToAligned(XLONG*, void* data);
295
extern XDOUBLE XDTDoubleToAligned(XDOUBLE*, void* data);
296
297
/*----------------------------------------
298
 * System section
299
 *----------------------------------------*/
300
301
#define XSYSTEM_ERROR ((0XFF000000) + (0XF00000))
302
303
#ifdef WIN32
304
#define XPATH_SEPARATOR "\\"
305
#define XPATH_SEPARATOR_CHAR '\\'
306
#define XDISK_SEPARATOR ":"
307
#define XLINE_SEPARATOR "\r\n"
308
#define XLIBRARY_PREFIX ""
309
#define XLIBRARY_EXTENSION "dll"
310
#define XLONG_FMT "I64"
311
#define XTHREADSPERPROCESS (128)
312
313
#define strcasecmp stricmp
314
#define atoll atoi64
315
316
#endif
317
318
#if defined(LINUX) || defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
319
#define XPATH_SEPARATOR "/"
320
#define XPATH_SEPARATOR_CHAR '/'
321
#define XDISK_SEPARATOR ""
322
#define XLINE_SEPARATOR "\n"
323
#define XLIBRARY_PREFIX "lib"
324
#define XLIBRARY_EXTENSION "so"
325
#define XLONG_FMT "ll"
326
#define XTHREADSPERPROCESS (128)
327
328
#endif
329
330
331
/*----------------------------------------
332
 * Clock section
333
 *----------------------------------------*/
334
335
#define XCLOCK_ERROR         ((XSYSTEM_ERROR) + (0X20000))
336
#define XCLOCK_ERROR_UNKNOWN ((XCLOCK_ERROR)  + (0X00000))
337
338
#define XCLOCK_PRECISION (10)
339
340
typedef struct 
341
{
342
  XINT64 initial;
343
} XClock;
344
345
extern int XClockMillis(XINT64 *d);
346
extern int XClockCreate(XClock *clock);
347
extern int XClockDelete(XClock *clock);
348
extern int XClockAdjust(XClock *clock, XINT64 adj);
349
extern int XClockRead(XClock *clock, XINT64 *ticks);
350
extern int XClockWait(XClock *clock, XINT64 until);
351
352
/*----------------------------------------
353
 * Mutex section
354
 *----------------------------------------*/
355
356
#define XMUTEX_ERROR         ((XSYSTEM_ERROR) + (0X40000))
357
#define XMUTEX_ERROR_CREATE  ((XMUTEX_ERROR)  + (0X00000))
358
#define XMUTEX_ERROR_CLAIM   ((XMUTEX_ERROR)  + (0X00001))
359
#define XMUTEX_ERROR_RELEASE ((XMUTEX_ERROR)  + (0X00002))
360
#define XMUTEX_ERROR_DELETE  ((XMUTEX_ERROR)  + (0X00003))
361
#define XMUTEX_ERROR_UNKNOWN ((XMUTEX_ERROR)  + (0X00004))
362
363
typedef struct
364
{
365
#ifdef WIN32
366
#undef MUTEX_HANDLE
367
#ifdef MUTEX_HANDLE
368
  HANDLE handle;
369
#else
370
  CRITICAL_SECTION cs;
371
#endif
372
#endif
373
#if defined(LINUX) || defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
374
  pthread_mutex_t mutex;
375
#endif
376
} XMutex;
377
378
extern int XMutexCreate(XMutex *mutex);
379
extern int XMutexClaim(XMutex *mutex);
380
extern int XMutexRelease(XMutex *mutex);
381
extern int XMutexDelete(XMutex *mutex);
382
383
/*----------------------------------------
384
 * Thread section
385
 *----------------------------------------*/
386
387
#define XTHREAD_ERROR         ((XSYSTEM_ERROR) + (0X50000))
388
#define XTHREAD_ERROR_CREATE  ((XTHREAD_ERROR) + (0X00000))
389
#define XTHREAD_ERROR_EXIT    ((XTHREAD_ERROR) + (0X00001))
390
#define XTHREAD_ERROR_WAIT    ((XTHREAD_ERROR) + (0X00002))
391
#define XTHREAD_ERROR_ABORT   ((XTHREAD_ERROR) + (0X00003))
392
#define XTHREAD_ERROR_UNKNOWN ((XTHREAD_ERROR) + (0X00004))
393
394
#define XTHREAD_STACKSZ (4 * 1024)
395
396
typedef void (XThreadFunction)(void *);
397
398
typedef struct
399
{
400
#ifdef WIN32
401
  HANDLE handle;
402
  DWORD id;
403
  XThreadFunction *function;
404
  void           *argument;
405
#endif
406
#if defined(LINUX) || defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
407
  XThreadFunction *function;
408
  void           *argument;
409
  pthread_t      pthread;
410
#endif
411
} XThread;
412
413
extern int XThreadStartup();
414
extern int XThreadMakeAbortable();
415
extern int XThreadCreate(XThreadFunction *function, void *argument, XThread *thread);
416
extern void XThreadExit(XUINT32 code);
417
extern int XThreadWait(XThread *thread, XUINT32 *code);
418
extern int XThreadAbort(XThread *thread);
419
extern int XThreadGetIdentifier(XINT32 *tid);
420
421
/*----------------------------------------
422
 * Library section
423
 *----------------------------------------*/
424
425
#define XLIBRARY_ERROR         ((XSYSTEM_ERROR)  + (0X60000))
426
#define XLIBRARY_ERROR_CREATE  ((XLIBRARY_ERROR) + (0X00000))
427
#define XLIBRARY_ERROR_SYMBOL  ((XLIBRARY_ERROR) + (0X00001))
428
#define XLIBRARY_ERROR_DELETE  ((XLIBRARY_ERROR) + (0X00002))
429
#define XLIBRARY_ERROR_UNKNOWN ((XLIBRARY_ERROR) + (0X00003))
430
431
typedef struct
432
{
433
#ifdef WIN32
434
  HINSTANCE instance;
435
#endif
436
#if defined(LINUX) || defined(SOLARIS) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
437
  void *handle;
438
#endif
439
} XLibrary;
440
441
extern int XLibraryCreate(XLibrary *library, char *filename);
442
extern int XLibrarySymbol(XLibrary *library, char *symbol, void **address);
443
extern int XLibraryDelete(XLibrary *library);
444
445
/*----------------------------------------
446
 * Random section
447
 *----------------------------------------*/
448
449
#define XRANDOM_ERROR         ((XSYSTEM_ERROR)      + (0XA0000))
450
#define XRANDOM_ERROR_UNKNOWN ((XENVIRONMENT_ERROR) + (0X00001))
451
452
extern void XRandomSeed(XINT s);
453
extern XDOUBLE XRandomUniform(void);
454
extern XDOUBLE XRandomNormal(void);
455
456
extern int StrEq(char* a, char* b);
457
458
/*----------------------------------------
459
 * END ALL FUNCTION CALL PROTOTYPES
460
 * WE DO EXTERN "C" ROUND ALL FUNCTIONS
461
 *----------------------------------------*/
462
463
#ifdef __cplusplus
464
}
465
#endif
466
467
468
#endif
469
/***********************************************************************
470
 * EOF
471
 ***********************************************************************/
472
(-)src-native-new/src/agents/perfmon/resutils/streq.c (+38 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: streq.c,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
#include "system.h"
14
15
int StrEq(char* a, char* b) {
16
	int index = 0;
17
	char ch_a, ch_b;
18
19
	if (a == NULL) {
20
		return -1;
21
	} else if (b == NULL) {
22
		return -1;
23
	}
24
25
	while (0==0) {
26
		ch_a = a[index];
27
		ch_b = b[index];
28
29
		if (ch_a != ch_b) return index+1;
30
31
		//could get rid of the OR here?
32
		if (ch_a == '\0' || ch_b == '\0') {
33
			return 0;
34
		}
35
36
		index++;
37
	}
38
}
(-)src-native-new/src/HCLauncher/WinBuild/HCLauncher.dsp (+161 lines)
Added Link Here
1
# Microsoft Developer Studio Project File - Name="HCLaunch" - Package Owner=<4>
2
# Microsoft Developer Studio Generated Build File, Format Version 6.00
3
# ** DO NOT EDIT **
4
5
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
6
7
CFG=HCLaunch - Win32 Debug
8
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9
!MESSAGE use the Export Makefile command and run
10
!MESSAGE 
11
!MESSAGE NMAKE /f "HCLauncher.mak".
12
!MESSAGE 
13
!MESSAGE You can specify a configuration when running NMAKE
14
!MESSAGE by defining the macro CFG on the command line. For example:
15
!MESSAGE 
16
!MESSAGE NMAKE /f "HCLauncher.mak" CFG="HCLaunch - Win32 Debug"
17
!MESSAGE 
18
!MESSAGE Possible choices for configuration are:
19
!MESSAGE 
20
!MESSAGE "HCLaunch - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
21
!MESSAGE "HCLaunch - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
22
!MESSAGE 
23
24
# Begin Project
25
# PROP AllowPerConfigDependencies 0
26
# PROP Scc_ProjName ""
27
# PROP Scc_LocalPath ""
28
CPP=cl.exe
29
MTL=midl.exe
30
RSC=rc.exe
31
32
!IF  "$(CFG)" == "HCLaunch - Win32 Release"
33
34
# PROP BASE Use_MFC 0
35
# PROP BASE Use_Debug_Libraries 0
36
# PROP BASE Output_Dir "HCLaunch___Win32_Release"
37
# PROP BASE Intermediate_Dir "HCLaunch___Win32_Release"
38
# PROP BASE Target_Dir ""
39
# PROP Use_MFC 0
40
# PROP Use_Debug_Libraries 0
41
# PROP Output_Dir "..\..\..\lib"
42
# PROP Intermediate_Dir "Release"
43
# PROP Ignore_Export_Lib 0
44
# PROP Target_Dir ""
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCLaunch_EXPORTS" /YX /FD /c
46
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\transport\RACommon" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCLaunch_EXPORTS" /YX /FD /c
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
49
# ADD BASE RSC /l 0x409 /d "NDEBUG"
50
# ADD RSC /l 0x409 /fo"Release/hclaunch.res" /d "NDEBUG"
51
BSC32=bscmake.exe
52
# ADD BASE BSC32 /nologo
53
# ADD BSC32 /nologo
54
LINK32=link.exe
55
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
56
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib rpcrt4.lib /nologo /dll /machine:I386 /out:"..\..\..\bin\hclaunch.dll"
57
# SUBTRACT LINK32 /nodefaultlib
58
59
!ELSEIF  "$(CFG)" == "HCLaunch - Win32 Debug"
60
61
# PROP BASE Use_MFC 0
62
# PROP BASE Use_Debug_Libraries 1
63
# PROP BASE Output_Dir "HCLaunch___Win32_Debug"
64
# PROP BASE Intermediate_Dir "HCLaunch___Win32_Debug"
65
# PROP BASE Target_Dir ""
66
# PROP Use_MFC 0
67
# PROP Use_Debug_Libraries 1
68
# PROP Output_Dir "..\..\..\lib"
69
# PROP Intermediate_Dir "Debug"
70
# PROP Ignore_Export_Lib 0
71
# PROP Target_Dir ""
72
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCLaunch_EXPORTS" /YX /FD /GZ /c
73
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\transport\RACommon" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCLaunch_EXPORTS" /YX /FD /GZ /c
74
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
75
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
76
# ADD BASE RSC /l 0x409 /d "_DEBUG"
77
# ADD RSC /l 0x409 /fo"Debug/hclaunch.res" /d "_DEBUG"
78
BSC32=bscmake.exe
79
# ADD BASE BSC32 /nologo
80
# ADD BSC32 /nologo
81
LINK32=link.exe
82
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
83
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib rpcrt4.lib /nologo /dll /debug /machine:I386 /out:"..\..\..\bin\hclaunch.dll" /pdbtype:sept
84
# SUBTRACT LINK32 /nodefaultlib
85
86
!ENDIF 
87
88
# Begin Target
89
90
# Name "HCLaunch - Win32 Release"
91
# Name "HCLaunch - Win32 Debug"
92
# Begin Group "Source Files"
93
94
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
95
# Begin Source File
96
97
SOURCE=..\hclaunch.c
98
# End Source File
99
# Begin Source File
100
101
SOURCE=..\..\transport\RACommon\java.c
102
# End Source File
103
# Begin Source File
104
105
SOURCE=..\launcher_common.c
106
# End Source File
107
# Begin Source File
108
109
SOURCE=..\launcher_md.c
110
# End Source File
111
# Begin Source File
112
113
SOURCE=..\launcher_os400.c
114
# End Source File
115
# Begin Source File
116
117
SOURCE=..\..\transport\RACommon\RAComm.c
118
# End Source File
119
# End Group
120
# Begin Group "Header Files"
121
122
# PROP Default_Filter "h;hpp;hxx;hm;inl"
123
# Begin Source File
124
125
SOURCE=..\hclaunch.h
126
# End Source File
127
# Begin Source File
128
129
SOURCE=..\launcher_common.h
130
# End Source File
131
# Begin Source File
132
133
SOURCE=..\launcher_error.h
134
# End Source File
135
# Begin Source File
136
137
SOURCE=..\launcher_md.h
138
# End Source File
139
# Begin Source File
140
141
SOURCE=..\launcher_os400.h
142
# End Source File
143
# Begin Source File
144
145
SOURCE=..\..\transport\RACommon\RAError.h
146
# End Source File
147
# Begin Source File
148
149
SOURCE=..\..\transport\RACommon\resource.h
150
# End Source File
151
# End Group
152
# Begin Group "Resource Files"
153
154
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
155
# Begin Source File
156
157
SOURCE=..\version.rc
158
# End Source File
159
# End Group
160
# End Target
161
# End Project
(-)src-native-new/src/agents/perfmon/PerfmonAgent/PerfmonAgent.cpp (+822 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: PerfmonAgent.cpp,v 1.12 2006/05/23 16:21:26 gchristelis Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
#include "PerfmonAgent.h"
14
15
#ifdef WIN32
16
//#include <winsock2.h> /* Bug 134924 */
17
#include <windows.h>
18
#endif
19
20
#include <stdio.h>
21
#include <stdlib.h>
22
23
#include "hashtable.h"
24
#include "system.h"
25
#include "DataTransferInterface.h"
26
#include "DataCollectionInterface.h"
27
28
29
int PRINT_XML = FALSE;
30
int VERBOSE = FALSE;
31
int LOG_TO_FILE = FALSE;
32
33
int BATCH_XML_MESSAGES = TRUE;
34
35
HashTable* hasht_request;
36
HashTable* hasht_filters;
37
HashTable* hasht_variables;
38
HashTable* hasht_tree;
39
40
// Message Buffer Info
41
int buf_ptr = 0;
42
int buf_len = 204800;
43
char* buf;	//20k buffer
44
45
char digits[] = {
46
'0' , '1' , '2' , '3' , '4' , '5' ,
47
'6' , '7' , '8' , '9' , 'a' , 'b' ,
48
'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
49
'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
50
'o' , 'p' , 'q' , 'r' , 's' , 't' ,
51
'u' , 'v' , 'w' , 'x' , 'y' , 'z'
52
};
53
54
static FILE* f = NULL;
55
56
static char filename[] = "PerfmonAgent.log";
57
58
void logToFile(const char*, ...);
59
60
void logToFile(const char* temp, ...)
61
{
62
	if (LOG_TO_FILE)
63
	{
64
		if (f == NULL)
65
			f = fopen(filename,  "w");
66
		va_list ap;
67
		va_start (ap, temp);
68
		vfprintf (f, temp, ap);
69
//		printf(temp,ap);
70
		va_end (ap);
71
		fflush(f);
72
	}
73
}
74
75
void longToString(XINT64 i, char* str) 
76
{
77
	int radix = 10;
78
	char buf[65];
79
80
	int charPos = 64;
81
	int negative = (i < 0);
82
83
	if (!negative) {
84
	    i = -i;
85
	}
86
87
	while (i <= -radix) 
88
	{
89
	    buf[charPos--] = digits[(int)(-(i % radix))];
90
	    i = i / radix;
91
	}
92
	buf[charPos] = digits[(int)(-i)];
93
94
	if (negative) {
95
	    buf[--charPos] = '-';
96
	}
97
98
	memcpy(str,&(buf[charPos]),(65 - charPos));
99
}
100
101
int increaseBufferSize(char** buf, int* buflen) {
102
	//double the size of the buffer
103
	int newlen = *buflen * 2;
104
	char* newbuf = (char*)malloc(newlen);
105
106
	memcpy(newbuf,*buf,*buflen);
107
	free(*buf);
108
109
	*buf = newbuf;
110
	*buflen = newlen;
111
112
	return newlen;
113
}
114
115
void clearData(char** array, int count)
116
{
117
	for (int i =0 ;i<count;i++) {
118
		free(array[i]);
119
	}
120
	free(array);
121
}
122
123
void fetchTree(LPGETTREE getTree, LPCOMSENDMESSAGE comSendMessage)
124
{
125
	char** treedata;
126
	int numstrings=0;
127
	int i=0, ret=0;
128
	int buf_ptr = 0;
129
	int total_dat;
130
131
	//////////////////////////////////////////////
132
	// TREE BUILDING - descriptors				//
133
	//////////////////////////////////////////////
134
	//
135
	// Get the names of all the counters, treedata contains the names, numstrings the number...
136
	//
137
138
	logToFile("Retrieving tree data..\n");	
139
	treedata = getTree(&numstrings);
140
	logToFile("Parsing tree data.. Got %d strings \n", numstrings);
141
	//
142
	// go through each of the strings and create XML
143
	//
144
	for (i = 0; i < numstrings; i++) 
145
	{
146
		char* dat[6];
147
		char* currdat = treedata[i];
148
149
		int keyindex = 1;
150
		int datindex = 0;
151
152
		logToFile("Parsing %d of %d\n", i, numstrings);
153
154
		//dat[0] = pid, dat[1] = id, dat[2] = name, dat[3] = help, dat[4] = suffix (not used)
155
		//check to see if this is the child of a requested parent
156
		if ((tableGet(hasht_variables,REGET_CHILDREN) && currdat[0] == '\0') || (tableGet(hasht_tree,currdat) == 1) ) 
157
		{			
158
			logToFile("This has been requested");
159
			// check if buffer size is > 5 or 10k here and send it back as
160
			// one message if it is - rather than sending a 4000k message
161
			if (BATCH_XML_MESSAGES) 
162
				if (buf_ptr > 10240) 
163
				{
164
					ret = comSendMessage(buf, 0, buf_ptr);
165
					total_dat += buf_ptr;
166
					buf_ptr = 0;
167
				}
168
169
			//
170
			// Parse out all the strings for this counter
171
			//
172
			dat[0] = currdat;
173
174
			while (TRUE) 
175
			{
176
				//filter out non-XML characters
177
				if (currdat[datindex] == '\"' || currdat[datindex] == '\'') 
178
					currdat[datindex] = '_';
179
				if (currdat[datindex] < 0)
180
					currdat[datindex] = ' ';
181
				if (currdat[datindex] == '\0') 
182
				{
183
					if (keyindex == 6) 
184
						break;	//this means we check all the strings
185
					dat[keyindex++] = &currdat[datindex+1];
186
				}
187
				datindex++;
188
			}
189
190
			if (tableGet(hasht_request,dat[1]) == 0) 
191
			{
192
				tablePut(hasht_request,dat[1],1);
193
194
				logToFile("%s, %s, %s, (help), %s\n",dat[0],dat[1],dat[2],dat[4]);
195
196
				while (TRUE) 
197
				{
198
					if (dat[0][0] == '\0') 
199
					{
200
						//no help = no description
201
						if (dat[3][0] == '\0')
202
						{
203
							//not sending back help strings drops data from 3.7M to 1.2M
204
							//new IDs should drop it down to around 800k with no help strings
205
							if (dat[5][0] == '0')
206
								ret = XSNPrintf( &buf[buf_ptr], buf_len-buf_ptr, "<Descriptor id=\"%s\" name=\"%s\" />\n",dat[1],dat[2],dat[3]);
207
							else								
208
								ret = XSNPrintf( &buf[buf_ptr], buf_len-buf_ptr, "<CounterDescriptor id=\"%s\" name=\"%s\" />\n",dat[1],dat[2],dat[3]);
209
						}
210
						else
211
						{
212
							if (dat[5][0] == '0')
213
								ret = XSNPrintf( &buf[buf_ptr], buf_len-buf_ptr, "<Descriptor id=\"%s\" name=\"%s\" >\n<description>%s</description>\n</Descriptor>\n",dat[1],dat[2],dat[3]);
214
							else								
215
								ret = XSNPrintf( &buf[buf_ptr], buf_len-buf_ptr, "<CounterDescriptor id=\"%s\" name=\"%s\" >\n<description>%s</description>\n</CounterDescriptor>\n",dat[1],dat[2],dat[3]);
216
						}
217
218
					} 
219
					else 
220
					{
221
						//no help = no description
222
						if (dat[3][0] == '\0') 
223
						{
224
							//not sending back help strings drops data from 3.7M to 1.2M
225
							//new IDs should drop it down to around 800k with no help strings
226
							if (dat[5][0] == '0')
227
								ret = XSNPrintf( &buf[buf_ptr], buf_len-buf_ptr, "<Descriptor parent=\"%s\" id=\"%s\" name=\"%s\" />\n",dat[0],dat[1],dat[2],dat[3]);
228
							else								
229
								ret = XSNPrintf( &buf[buf_ptr], buf_len-buf_ptr, "<CounterDescriptor parent=\"%s\" id=\"%s\" name=\"%s\" />\n",dat[0],dat[1],dat[2],dat[3]);
230
						}
231
						else 
232
						{
233
							if (dat[5][0] == '0')
234
								ret = XSNPrintf( &buf[buf_ptr], buf_len-buf_ptr, "<Descriptor parent=\"%s\" id=\"%s\" name=\"%s\" >\n<description>%s</description>\n</Descriptor>\n",dat[0],dat[1],dat[2],dat[3]);
235
							else								
236
								ret = XSNPrintf( &buf[buf_ptr], buf_len-buf_ptr, "<CounterDescriptor parent=\"%s\" id=\"%s\" name=\"%s\" >\n<description>%s</description>\n</CounterDescriptor>\n",dat[0],dat[1],dat[2],dat[3]);
237
						}
238
					}
239
240
					if (ret < 0)
241
						increaseBufferSize(&buf,&buf_len);
242
					else 
243
					{
244
						buf_ptr += ret;
245
						break;
246
					}
247
248
				}
249
250
251
				if (!BATCH_XML_MESSAGES) 
252
				{
253
					ret = comSendMessage(buf, 0, buf_ptr);
254
					total_dat += buf_ptr;
255
					buf_ptr = 0;
256
				}
257
				
258
				if (PRINT_XML) logToFile("XML = %s\n\n",buf);
259
			}
260
		}
261
	}
262
263
	tablePut(hasht_variables, REGET_CHILDREN,(XINT64) 0);
264
	//
265
	// print out how many messages we sent and the total number of bytes we sent
266
	//
267
	logToFile("%d descriptors, total bytes = %d bytes\n\n",numstrings,total_dat);
268
269
	//
270
	// deallocate the strings
271
	//
272
	clearData(treedata,numstrings);
273
	//
274
	// Send any remaining buffer data
275
	//
276
	if (BATCH_XML_MESSAGES) 
277
	{
278
		logToFile("Sending data back to the workbench...\n");
279
280
		ret = comSendMessage(buf, 0, buf_ptr);
281
282
		total_dat += buf_ptr;
283
		buf_ptr = 0;
284
	}
285
286
287
	if (PRINT_XML) 
288
		logToFile("XML = %s\n\n",buf);
289
}
290
291
void setVariables(HashTable* hasht_variables)
292
{
293
	//variables hashtable initialisation
294
	tablePut(hasht_variables,DC_KEY_MONITORING,DC_VAL_FALSE);
295
	tablePut(hasht_variables,DC_KEY_FINISHED,DC_VAL_FALSE);
296
	tablePut(hasht_variables,DC_KEY_WAITTIME,(XINT64)1000);
297
	tablePut(hasht_variables,DC_KEY_TREE_REQUESTED,DC_VAL_FALSE);
298
}
299
300
301
int manageResources(LPSTARTUP resStartup, LPSHUTDOWN resShutdown, LPGETTREE getTree, LPGETRESULTS getResults,
302
					LPCOMSTARTUP comStartup, LPCOMSHUTDOWN comShutdown, LPCOMSENDMESSAGE comSendMessage)
303
{
304
	XClock x_clock;
305
	int memdiff = 5;
306
	char** results;
307
	XINT64 ctime;
308
	int ret,i;
309
310
	// Time Buffer Info
311
	char timebuf[64];	//print time into here
312
	XINT64 javatime;
313
	int total_dat = 0, numresults=0;
314
315
	hasht_request = tableCreate();
316
	hasht_filters = tableCreate();
317
	hasht_variables = tableCreate();
318
	hasht_tree = tableCreate();
319
320
	setVariables(hasht_variables);
321
322
	//
323
	// Startup the COMM and RES
324
	//
325
	ret = comStartup( hasht_variables, hasht_filters, hasht_tree );
326
	if (ret != 0) 
327
	{
328
		logToFile("Failed to start up Communications\n");
329
		return -1;
330
	}
331
	resStartup( hasht_variables, hasht_filters, hasht_tree);
332
333
	//
334
	// Set up the XML buffer
335
	//
336
	logToFile("Allocating buffer\n");
337
	buf = (char*)malloc(sizeof(char) * buf_len);
338
339
	//
340
	// Create our x_clock
341
	//
342
    XClockCreate(&x_clock);
343
	XClockRead(&x_clock,&ctime);
344
345
	//
346
	//finished when an agent detaches from us
347
	// Bug 99153
348
	while (!tableGet(hasht_variables,DC_KEY_FINISHED) && !tableGet(hasht_variables,DC_AGENT_CONTROLLER_STOPPED)) 
349
	{
350
		XINT64 ctime_tmp = 0;
351
		XINT64 ctime_max = 0;
352
353
		XINT32 WAIT_TIME = (XINT32)tableGet(hasht_variables,DC_KEY_WAITTIME);
354
		XINT32 TREE_REQUESTED = (XINT32)tableGet(hasht_variables,DC_KEY_TREE_REQUESTED);
355
356
		//
357
		// Clean up the XML buffer
358
		//
359
		memset(buf,'\0',buf_len);
360
		buf_ptr = 0;
361
362
		ctime_max = ctime + WAIT_TIME;
363
		XClockRead(&x_clock,&ctime_tmp);
364
		
365
		while ((ctime_max - ctime_tmp > 0) && !tableGet(hasht_variables,DC_KEY_FINISHED)) 
366
		{
367
			ctime_tmp += 50;
368
			XClockWait(&x_clock,ctime_tmp);
369
370
			WAIT_TIME = (XINT32)tableGet(hasht_variables,DC_KEY_WAITTIME);
371
			ctime_max = ctime + WAIT_TIME;			
372
373
			// Lets return the tree as soon as we can
374
			if (tableGet(hasht_variables, DC_KEY_MONITORING))
375
			{
376
				TREE_REQUESTED = (XINT32)tableGet(hasht_variables,DC_KEY_TREE_REQUESTED);
377
				if (TREE_REQUESTED)
378
				{
379
					fetchTree(getTree, comSendMessage);
380
					TREE_REQUESTED = FALSE;
381
					tablePut(hasht_variables,DC_KEY_TREE_REQUESTED,TREE_REQUESTED);
382
				}
383
			}
384
		}
385
386
		if (tableGet(hasht_variables,DC_KEY_FINISHED)) 
387
			break;
388
389
		ctime += WAIT_TIME;
390
391
		//
392
		// Wait for a bit
393
		//
394
		XClockWait(&x_clock,ctime);
395
		XClockRead(&x_clock,&ctime);
396
397
		if (!tableGet(hasht_variables,DC_KEY_MONITORING)) 
398
		{
399
			logToFile("No agent monitoring yet (freq:%dms)\n",tableGet(hasht_variables,DC_KEY_WAITTIME));
400
			tablePut(hasht_variables, REGET_CHILDREN,(XINT64) 1);
401
			TREE_REQUESTED = TRUE;
402
			tablePut(hasht_variables,DC_KEY_TREE_REQUESTED,TREE_REQUESTED);
403
404
			// We clear this so that we send back ALL the tree information again...
405
			tableClear(hasht_request);
406
407
			continue;
408
		}
409
		//
410
		// Get the current time in java System.currentTimeMillis() format
411
		//
412
413
		if (TREE_REQUESTED) 
414
		{			
415
			fetchTree(getTree, comSendMessage);
416
			TREE_REQUESTED = FALSE;
417
			tablePut(hasht_variables,DC_KEY_TREE_REQUESTED,TREE_REQUESTED);
418
		}
419
420
		XClockMillis(&javatime);
421
		memset(timebuf,'\0',64);
422
		longToString(javatime,timebuf);
423
424
		results = getResults(&numresults);
425
		logToFile("NUMRESULTS = %d, results=%08X\n",numresults,results);
426
		//
427
		// go through each of the strings and create and create an XML
428
		//
429
		for (i = 0; results!=NULL && i < numresults; i++) 
430
		{
431
432
			char* dat[2];
433
			char* currdat = results[i];
434
435
			int keyindex = 1;
436
			int datindex = 0;
437
438
			//
439
			// check if buffer size is > 5 or 10k here and send it back as
440
			// one message if it is - rather than sending a 4000k message
441
			//
442
443
			if (BATCH_XML_MESSAGES) {
444
				if (buf_ptr > 10240) 
445
				{
446
					ret = comSendMessage(buf, 0, buf_ptr);
447
					total_dat += buf_ptr;
448
					buf_ptr = 0;
449
				}
450
451
				if (PRINT_XML) logToFile("XML = %s\n\n",buf);
452
			}
453
454
455
			//
456
			// Parse out all the strings for this counter
457
			//
458
			dat[0] = currdat;
459
			while (TRUE) 
460
			{
461
				//filter out non-XML characters
462
				if (currdat[datindex] == '\"' || currdat[datindex] == '\'') 
463
					currdat[datindex] = '_';
464
				if (currdat[datindex] < 0)
465
					currdat[datindex] = ' ';
466
				if (currdat[datindex] == '\0')
467
				{
468
					if (keyindex == 2) 
469
						break;	//this means we check all the strings
470
					dat[keyindex++] = &currdat[datindex+1];
471
				}
472
				datindex++;
473
			}
474
475
			//dat[0] = id
476
			//dat[1] = value (string)
477
478
			logToFile("--[%s,%s]--\n",dat[0],dat[1]);
479
480
			while (TRUE) 
481
			{
482
				ret = XSNPrintf( &buf[buf_ptr], buf_len-buf_ptr, "<ContiguousObservation memberDescriptor=\"%s\" time=\"%s\" value=\"%s\" />\n",dat[0],timebuf,dat[1]);
483
484
				if (ret < 0)
485
					increaseBufferSize(&buf,&buf_len);
486
				else 
487
				{
488
					buf_ptr += ret;
489
					break;
490
				}
491
			}
492
493
			if (!BATCH_XML_MESSAGES) 
494
			{
495
				ret = comSendMessage(buf, 0, buf_ptr);
496
				total_dat += buf_ptr;
497
				buf_ptr = 0;
498
			}
499
500
			if (PRINT_XML) 
501
				logToFile("XML = %s\n\n",buf);
502
		}
503
504
		//
505
		// Send any remaining buffer data
506
		//
507
508
		if (BATCH_XML_MESSAGES) 
509
		{
510
			ret = comSendMessage(buf, 0, buf_ptr);
511
			total_dat += buf_ptr;
512
			buf_ptr = 0;
513
		}
514
515
		if (PRINT_XML) 
516
			logToFile("XML = %s\n\n",buf);
517
	}
518
519
	//
520
	// We are finished - shutdown the RES and COM and unload the libraries
521
	//
522
	resShutdown();
523
	ret = comShutdown();
524
	if (ret != 0) 
525
	{
526
		logToFile("Failed to shut down Communications agent\n");
527
		return -1;
528
	}
529
530
	//
531
	// Cleanup stuff we allocated
532
	//
533
	tableDelete(hasht_request);
534
	tableDelete(hasht_filters);
535
	tableDelete(hasht_variables);
536
	tableDelete(hasht_tree);
537
538
	free(buf);
539
	return 0;
540
}
541
542
void showInfo()
543
{
544
	logToFile("PerfmonAgent\n\n");
545
	logToFile("Usage:   PerfmonAgent.exe [-v] [Resource DLL] [Communications DLL]\n");
546
	logToFile("Default: PerfmonAgent.exe sysperf.dll rac.dll\n");
547
	logToFile("\n-v\t: Enable verbose output\n");
548
}
549
550
//
551
//	Load the DLL functions for the resource gatherer and communciator.
552
//	If successful, pass these functions to the manageresource method.
553
//
554
int process(char* resDLLname, char* commDLLname)
555
{	
556
	LPSTARTUP resStartup;
557
	LPSHUTDOWN resShutdown;
558
	LPGETTREE getTree;
559
	LPGETRESULTS getResults;
560
	LPGETAGENTNAME getAgentName = NULL;
561
	int rt;
562
563
	LPCOMSTARTUP COMStartup;
564
	LPCOMSHUTDOWN COMShutdown;
565
	LPCOMSENDMESSAGE COMSendMessage;
566
	LPCOMSETAGENTNAME COMSetAgentName = NULL;
567
568
#ifdef LINUX
569
  const char *error;
570
  void *resmodule;
571
	void *commodule;
572
573
	// First lets try and open the two libraries
574
	logToFile("trying to open resource library %s\n",resDLLname);
575
	resmodule = dlopen(resDLLname, RTLD_LAZY);
576
	if (!resmodule) 
577
	{
578
		fprintf(stderr, "Couldn't open reslibrary: %s\n",dlerror());
579
		logToFile("Couldn't open reslibrary: %s\n",dlerror());
580
		exit(1);
581
	}
582
	printf("trying to open communiction library %s\n",commDLLname);
583
584
	commodule = dlopen(commDLLname, RTLD_LAZY);
585
	if (!commodule) 
586
	{
587
		dlclose(resmodule);
588
		fprintf(stderr, "Couldn't open commlibrary: %s\n",dlerror());
589
		logToFile("Couldn't open commlibrary: %s\n",dlerror());
590
		exit(1);
591
	}
592
593
	logToFile("Address %08x\n",commodule);
594
595
	//Okay, we must now try and get all the methods we need!
596
597
	dlerror();
598
	resStartup = (LPSTARTUP) dlsym(resmodule, "DC_CollectionStartup");
599
	if ((error = dlerror())) 
600
	{
601
		dlclose(resmodule);
602
		dlclose(commodule);
603
604
		fprintf(stderr, "Couldn't find DC_CollectionStartup: %s\n", error);
605
		logToFile("Couldn't find DC_CollectionStartup: %s\n", error);
606
		exit(1);
607
	}
608
	dlerror();
609
	resShutdown = (LPSHUTDOWN) dlsym(resmodule, "DC_CollectionShutdown");
610
	if ((error = dlerror())) 
611
	{
612
		dlclose(resmodule);
613
		dlclose(commodule);
614
615
  		fprintf(stderr, "Couldn't find DC_CollectionShutdown: %s\n", error);
616
		logToFile("Couldn't find DC_CollectionShutdown: %s\n", error);
617
		exit(1);
618
	}
619
	dlerror();
620
	getTree = (LPGETTREE) dlsym(resmodule, "DC_CollectionGetTree");
621
	if ((error = dlerror())) 
622
	{
623
		dlclose(resmodule);
624
		dlclose(commodule);
625
		
626
  		fprintf(stderr, "Couldn't find DC_CollectionGetTree: %s\n", error);
627
		logToFile("Couldn't find DC_CollectionGetTree: %s\n", error);
628
		exit(1);
629
	}
630
	dlerror();
631
	getResults = (LPGETRESULTS) dlsym(resmodule, "DC_CollectionGetResults");
632
	if ((error = dlerror())) 
633
	{
634
		dlclose(resmodule);
635
		dlclose(commodule);
636
		
637
  		fprintf(stderr, "Couldn't find DC_CollectionGetResults: %s\n", error);
638
  		logToFile("Couldn't find DC_CollectionGetResults: %s\n", error);
639
		exit(1);
640
	}
641
	dlerror();
642
	getAgentName = (LPGETAGENTNAME) dlsym(resmodule, "DC_CollectionGetAgentName");
643
	if ((error = dlerror())) 
644
	{
645
		dlclose(resmodule);
646
		dlclose(commodule);
647
		
648
  		fprintf(stderr, "Couldn't find DC_CollectionGetAgentName: %s\n", error);
649
		logToFile("Couldn't find DC_CollectionGetAgentName: %s\n", error);
650
		exit(1);
651
	}
652
653
	COMStartup = (LPCOMSTARTUP) dlsym(commodule, "DC_TransferStartup");
654
	if ((error = dlerror()))
655
	{
656
		dlclose(resmodule);
657
		dlclose(commodule);
658
		
659
		fprintf(stderr, "Couldn't find DC_TransferStartup: %s\n", error);
660
		logToFile("Couldn't find DC_TransferStartup: %s\n", error);
661
		exit(1);
662
	}
663
664
	COMShutdown = (LPCOMSHUTDOWN) dlsym(commodule, "DC_TransferShutdown");
665
	if ((error = dlerror()))
666
	{
667
		dlclose(resmodule);
668
		dlclose(commodule);
669
		
670
		fprintf(stderr, "Couldn't find DC_TransferShutdown: %s\n", error);
671
		logToFile("Couldn't find DC_TransferShutdown: %s\n", error);
672
		exit(1);
673
	}
674
	COMSendMessage = (LPCOMSENDMESSAGE) dlsym(commodule, "DC_SendMessage");
675
	if ((error = dlerror()))
676
	{
677
		dlclose(resmodule);
678
		dlclose(commodule);
679
		
680
		fprintf(stderr, "Couldn't find DC_SendMessage: %s\n", error);
681
		logToFile("Couldn't find DC_SendMessage: %s\n", error);
682
		exit(1);
683
	}
684
685
	COMSetAgentName = (LPCOMSETAGENTNAME) dlsym(commodule, "DC_TransferSetAgentName");
686
	if ((error = dlerror()))
687
	{
688
		dlclose(resmodule);
689
		dlclose(commodule);
690
		
691
		fprintf(stderr, "Couldn't find DC_SetAgentName: %s\n", error);
692
		logToFile("Couldn't find DC_SetAgentName: %s\n", error);
693
		exit(1);
694
	}
695
696
	// Lets pass on the agentname from the collection dLL to the resource DLL
697
	char* agentName = getAgentName();
698
	COMSetAgentName(agentName);
699
700
	// Perform processing
701
	rt = manageResources(resStartup, resShutdown, getTree, getResults,COMStartup,COMShutdown,COMSendMessage);
702
703
 /* All done, close things cleanly */
704
	dlclose(resmodule);
705
	dlclose(commodule);
706
	return 0;
707
708
#else
709
				
710
	HINSTANCE hResDLL;               
711
	HINSTANCE hCommDLL;               
712
713
714
	// LOAD THE RESOURCE DLL FUNCTIONS
715
	hResDLL = LoadLibrary(resDLLname);
716
	if (hResDLL == NULL)
717
	{
718
		logToFile("Error encountered: %s is not a valid DLL\n",resDLLname);		
719
		MessageBox(NULL,"Error Loading resourceDLL","Error Loading resourceDLL",MB_OK);
720
		return -1;
721
	}
722
723
	resStartup	= (LPSTARTUP)	GetProcAddress(hResDLL, "DC_CollectionStartup");
724
	resShutdown	= (LPSHUTDOWN)	GetProcAddress(hResDLL, "DC_CollectionShutdown");
725
	getTree		= (LPGETTREE)	GetProcAddress(hResDLL, "DC_CollectionGetTree");
726
	getResults	= (LPGETRESULTS)GetProcAddress(hResDLL, "DC_CollectionGetResults");
727
	getAgentName = (LPGETAGENTNAME) GetProcAddress(hResDLL, "DC_CollectionGetAgentName");
728
729
	if (!resStartup)
730
		logToFile("resStartup\n");
731
	if (!resShutdown)
732
		logToFile("resShutdown\n");
733
	if (!getTree)
734
		logToFile("getTree\n");
735
	if (!getResults)
736
		logToFile("getResults\n");
737
	if (!getAgentName)
738
		logToFile("getAgentName\n");
739
740
	if (!resStartup || !resShutdown || !getTree || !getResults || !getAgentName)
741
	{
742
		// handle the error
743
		FreeLibrary(hResDLL);       
744
		logToFile("Unable to load function(s) from Resource DLL.\n");
745
		MessageBox(NULL,"Error Loading Functions (RESOURCEDLL)","Error Loading Functions (RESOURCEDLL)",MB_OK);
746
	    return -1;
747
	}
748
749
	// LOAD THE COMM DLL FUNCTIONS
750
	hCommDLL = LoadLibrary(commDLLname);
751
	if (hCommDLL == NULL)
752
	{
753
		FreeLibrary(hResDLL);
754
		logToFile("Error encountered: %s is not a valid DLL\n",commDLLname);
755
		MessageBox(NULL,"Error Loading commDLL","Error Loading commDLL",MB_OK);
756
		return -1;
757
	}
758
759
	COMStartup		= (LPCOMSTARTUP)		GetProcAddress(hCommDLL, "DC_TransferStartup");
760
	COMShutdown		= (LPCOMSHUTDOWN)		GetProcAddress(hCommDLL, "DC_TransferShutdown");
761
	COMSendMessage	= (LPCOMSENDMESSAGE)	GetProcAddress(hCommDLL, "DC_SendMessage");
762
	COMSetAgentName = (LPCOMSETAGENTNAME)	GetProcAddress(hCommDLL, "DC_TransferSetAgentName");
763
764
	if (!COMStartup || !COMShutdown || !COMSendMessage || !COMSetAgentName)
765
	{
766
		// handle the error
767
		FreeLibrary(hResDLL);       
768
		FreeLibrary(hCommDLL);
769
		logToFile("Unable to load function(s) from Communications DLL.\n");
770
		MessageBox(NULL,"Error Loading Functions (COMDLL)","Error Loading Functions (COMDLL)",MB_OK);
771
	    return -1;
772
	}
773
774
	// Lets pass on the agentname from the collection dLL to the resource DLL
775
	char* agentName = getAgentName();
776
	logToFile("PerfmonAgent received agentname of %s\n",agentName);
777
	COMSetAgentName(agentName);
778
779
	rt = manageResources(resStartup, resShutdown, getTree, getResults,COMStartup,COMShutdown,COMSendMessage);
780
781
	FreeLibrary(hResDLL);       
782
	FreeLibrary(hCommDLL);
783
	return rt;
784
#endif
785
}
786
787
//
788
//	Main Agent Method : Parse the command line arguments and set DLL names
789
//
790
int main(int argc, char** argv)
791
{
792
	char* resDLLname = NULL;
793
	char* commDLLname = NULL;
794
795
	for (int i = 1; i < argc; i++)
796
	{
797
		if (argv[i][0] == '\0')
798
			continue;
799
		if (strcmp(argv[i],"-v")==0)
800
			VERBOSE = TRUE;
801
		else if ((strcmp(argv[i],"--help")==0) || (strcmp(argv[i],"/?")==0) || (strcmp(argv[i],"-h")==0))
802
		{
803
			showInfo();
804
			return 0;
805
		}
806
		else if (resDLLname == NULL)
807
		{
808
			resDLLname = argv[i];
809
		}
810
		else if (commDLLname == NULL)
811
		{
812
			commDLLname = argv[i];
813
		}
814
	}
815
	if (resDLLname == NULL) resDLLname = DEFAULT_RES;
816
	if (commDLLname == NULL) commDLLname = DEFAULT_COM;
817
818
	logToFile("Using Resource DLL \"%s\", Communications DLL \"%s\"\n",resDLLname, commDLLname);
819
	return process(resDLLname, commDLLname);
820
}
821
822
(-)src-native-new/src/agents/java/WinBuild/WinBuild.dsw (+29 lines)
Added Link Here
1
Microsoft Developer Studio Workspace File, Format Version 6.00
2
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3
4
###############################################################################
5
6
Project: "log_agent"=.\log_agent.dsp - Package Owner=<4>
7
8
Package=<5>
9
{{{
10
}}}
11
12
Package=<4>
13
{{{
14
}}}
15
16
###############################################################################
17
18
Global:
19
20
Package=<5>
21
{{{
22
}}}
23
24
Package=<3>
25
{{{
26
}}}
27
28
###############################################################################
29
(-)src-native-new/src/agents/native/java_profiler/stack.c (+401 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: stack.c,v 1.10 2006/05/16 22:09:53 bduncan Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include <assert.h>
14
#include "stack.h"
15
#include "RADataTransfer.h"
16
#include "RAComm.h"
17
#include "options.h"
18
#include "utility.h"
19
#include "JvmpiWriter.h"
20
21
extern void getStackFrameStructureLock();	/* for pre-aggregation. Belongs in a header file */
22
extern void releaseStackFrameStructureLock();	/* for pre-aggregation. Belongs in a header file */
23
24
static unsigned long _staticThreadIdCount = 0;
25
26
/* Allocates an entry in the symbol table for the object */
27
HashEntry * jvmpiAgent_CreateStack(JNIEnv * env_id)
28
{
29
 HashEntry *hashEntry;
30
 ThreadPrivateStorage *tps = (ThreadPrivateStorage *)jvmpiAgent_Calloc(sizeof(ThreadPrivateStorage));
31
 jvmpiAgent_initializeSegmentedValue(&tps->ticket, 0);
32
 tps->currentStackSize = ORIGINAL_STACK_SIZE;
33
 tps->tos = 0;
34
 tps->threadStartEventSeen = 0;
35
 tps->staticThreadId = ++_staticThreadIdCount;
36
 tps->env=env_id;
37
 tps->threadStackKnown=0;
38
 tps->boundaryDepth=-1;
39
40
 /*##MW There is a race condition between the increment and the copy that must be fixed */
41
 jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
42
 jvmpiAgent_copySegmentedValue(&tps->collation, &_jvmpiAgent_collation);
43
44
 tps->stackEntry = (StackEntry *)jvmpiAgent_Calloc(tps->currentStackSize * sizeof(StackEntry));
45
 tps->buffer=(char *)ra_allocateMessageBlock(ORIGINAL_MESSAGE_BUFFER_SIZE);
46
#ifdef __OS400__ 
47
 tps->buffer2=(char *)ra_allocateMessageBlock(ORIGINAL_MESSAGE_BUFFER_SIZE+1);
48
#endif
49
 hashEntry = jvmpiAgent_CreateThreadSymbol(env_id);
50
 hashEntry->entry = tps;
51
 return hashEntry;
52
}
53
54
/** DESTROY_STACK  ************************************************************
55
  *
56
  */
57
void jvmpiAgent_DestroyStack(JNIEnv *env_id) {
58
 ThreadLocalStorage *tps;
59
 tps = jvmpiAgent_getThreadLocalStorage(env_id);
60
 if (tps)
61
 {
62
  HashEntry *hashEntry;
63
  hashEntry = jvmpiAgent_FindThreadSymbol(env_id);
64
  free(tps->stackEntry);
65
  ra_freeMessageBlock((unsigned char *)tps->buffer);
66
#ifdef __OS400__ 
67
  ra_freeMessageBlock((unsigned char *)tps->buffer2);
68
#endif
69
  jvmpiAgent_DeleteSymbol(hashEntry, Thread_t);
70
 }
71
}
72
73
/** PUSH  ***********************************************************************
74
  */
75
StackEntry * jvmpiAgent_Push(ThreadPrivateStorage *tps, JNIEnv *env_id, HashEntry *methodHashEntry, HashEntry * objectHashEntry, timestamp_t timestamp, timestamp_t cpu_timestamp)
76
{
77
 if (!tps) return 0;
78
 tps->tos++;
79
80
 /* If the Stack is full, increment it's size by STACK_INCREMENT_SIZE */
81
 if(tps->tos == tps->currentStackSize)
82
 {
83
   StackEntry *oldStack=tps->stackEntry;
84
   int newStackSize=tps->currentStackSize+STACK_INCREMENT_SIZE;
85
   tps->stackEntry=(StackEntry *)jvmpiAgent_Calloc(newStackSize * sizeof(StackEntry));
86
   memcpy(tps->stackEntry, oldStack, tps->currentStackSize * sizeof(StackEntry));
87
   free(oldStack);
88
   tps->currentStackSize=newStackSize;
89
 }
90
91
 jvmpiAgent_incrementSegmentedValue(&tps->ticket, 0);
92
 jvmpiAgent_copySegmentedValue(&(tps->stackEntry[tps->tos].ticket), &tps->ticket);
93
 tps->stackEntry[tps->tos].objectHashEntry = objectHashEntry;
94
95
 if (tps->stackEntry[tps->tos].methodHashEntry = methodHashEntry) /* Note: Intentional assignment rather than compare */
96
 {
97
  METHOD_ENTRY(methodHashEntry)->methodCount++;
98
 }
99
 /* Get the timestamp information if necessary */
100
 if(_jvmpiAgent_Options.timestamp)
101
 {
102
   tps->stackEntry[tps->tos].timestamp = timestamp;
103
 }
104
 if(_jvmpiAgent_Options.cpuTime) {
105
    tps->stackEntry[tps->tos].cpuTime=cpu_timestamp; 
106
 }
107
 else {
108
    tps->stackEntry[tps->tos].cpuTime=0;
109
 }
110
 tps->stackEntry[tps->tos].printed = 0;
111
 tps->stackEntry[tps->tos].tps = tps;
112
 tps->stackEntry[tps->tos].entryEventSeen=1;
113
114
 /* If pre-aggregating, initialize the StackEntry's preagg fields */
115
 if(_jvmpiAgent_Options.compressLevel==CompressAggregate) {
116
	 StackEntry* new_entry = &tps->stackEntry[tps->tos];
117
	 new_entry->baseTime = 0;
118
	 new_entry->baseCPUTime = 0;
119
	 new_entry->lastEntryTime = 0;
120
	 new_entry->lastEntryCPUTime = 0;
121
	 new_entry->realFrame = 0;
122
     new_entry->stackFrame = NULL;   /* 136721 (permanent) */
123
 }
124
125
 if(tps->tos==1) {
126
	tps->stackEntry[tps->tos].currentBoundaryDepth=0;
127
 }
128
 else {
129
     if(tps->stackEntry[tps->tos-1].currentBoundaryDepth==0) {
130
		 tps->stackEntry[tps->tos].currentBoundaryDepth=0;
131
	 }
132
	 else {
133
		 tps->stackEntry[tps->tos].currentBoundaryDepth=tps->stackEntry[tps->tos-1].currentBoundaryDepth-1;
134
	 }
135
 }
136
 if(_jvmpiAgent_Options.compressLevel==CompressAggregate)  /* 136721 (permanent) */ 
137
 {
138
	/* pre-aggregation: initialize the StackFrame of this StackEntry.
139
	 *
140
	 * This code sets things up for a frame that's filtered out:
141
	 * stackFrame is set to NULL for the first StackEntry on a stack, 
142
	 * or to the same frame that the previous StackEntry points to.
143
	 * In either case, realFrame is set to zero (false).
144
	 *
145
	 * A StackEntry whose stackFrame points to its caller's stackFrame
146
	 * and whose "realFrame" flag is zero indicates a frame that's filtered out.
147
	 *
148
	 * If the entry being pushed is NOT filtered out, the caller of Push
149
	 * (usually handleMethodEntry) will call CreateStackFrame to change 
150
	 * these pointers and values.
151
	 */
152
153
	if (tps->tos == 1) {
154
		/* The newly-pushed frame is the only frame on the stack */
155
		tps->stackEntry[tps->tos].stackFrame = NULL;
156
	}
157
	else {
158
		/* There is a previous entry, a caller */
159
		StackEntry * caller = &tps->stackEntry[tps->tos - 1];
160
		tps->stackEntry[tps->tos].stackFrame = caller->stackFrame;
161
	}
162
	tps->stackEntry[tps->tos].realFrame = 0;
163
 }
164
 
165
 return &tps->stackEntry[tps->tos];
166
}
167
168
/* for pre-aggregation (that is, CompressAggregate) */
169
/*
170
 * Execute a "pop" for the aggregated method information.
171
 * This is called from jvmpiAgent_Pop (normal method exit).
172
 * It is also called from thread death, JVM shutdown,  and
173
 * suspendTracing processing: in those cases, we have to
174
 * account for the time in frames that are currently live
175
 * at thread death time or JVM shutdown time.
176
 *
177
 * Before calling this, the caller (especially the
178
 * thread-death and shutdown callers) need to update
179
 * baseTime of each stackEntry on the live stack(s).
180
 *
181
 * Note that a stackEntry can only be agPop'ed once. If it
182
 * is agPop'ed a second time, nothing happens. This is forced
183
 * by clearing the stackEntry->stackFrame field. This is a 
184
 * good practice generally and is used particularly in 
185
 * suspendTracing where an agRollUpStack is done followed by
186
 * a stackCleaner, both of which trigger agPops directly or
187
 * indirectly respectively.  (bug 134635)
188
 *
189
 * If I weren't such a chicken, I'd change the thread-death
190
 * and JVM shutdown handlers to simulate method-exit for all
191
 * active frames, and let that automatically handle the
192
 * bookkeeping. But I don't want to expose myself to breakage
193
 * because of (e.g.) method calls that arrive after thread death
194
 * or shutdown notification (from VMs with bad JVMPI impls).
195
 */
196
197
void jvmpiAgent_agPop(StackEntry* stackEntry) 
198
{
199
	StackFrame* frame = stackEntry->stackFrame;
200
	if (frame != NULL) {
201
		timestamp_t baseTime = stackEntry->baseTime;
202
		timestamp_t baseCPUTime = stackEntry->baseCPUTime;
203
		if (stackEntry->realFrame) {
204
			/* This is a "real" frame, one for a non-filtered method. */
205
			/* Update the times for this method along this call chain. */
206
			timestamp_t totalBaseTime ;
207
			timestamp_t totalBaseCPUTime ;
208
209
			/* 
210
			 * Do not acquire stackFrameStructureLock here, despite the 
211
			 * possibility that another thread is dumping data right now.
212
			 * It's just too expensive, and the risk of damage
213
			 * is limited to improper rolled-up data; you won't crash.
214
			 */
215
			totalBaseTime = frame->filteredMethodsBaseTime + baseTime;
216
			DBG_CHK_AND_REPORT_TIME_OVERFLOW(totalBaseTime, "Time overflowed?! (agPop: totalBaseTime)\n"); /* 134577 */
217
218
			if (frame->maxTime < totalBaseTime )
219
				frame->maxTime = totalBaseTime ;
220
			if (frame->minTime == 0 || frame->minTime > totalBaseTime )
221
				frame->minTime = totalBaseTime ;
222
223
			frame->baseTime += totalBaseTime ;
224
			DBG_CHK_AND_REPORT_TIME_OVERFLOW(frame->baseTime, "Time overflowed?! (agPop: frame->baseTime)\n"); /* 134577 */
225
226
			frame->filteredMethodsBaseTime = 0;
227
228
			/* Do it again for CPU time - just base time, no min/max */
229
			totalBaseCPUTime = frame->filteredMethodsBaseCPUTime + baseCPUTime;
230
			frame->baseCPUTime += totalBaseCPUTime;
231
			frame->filteredMethodsBaseCPUTime = 0;
232
			frame->numCalls ++ ;
233
		}
234
		else {
235
			/* This is a filtered method. Accumulate basetime
236
			   into the filteredMethodsBaseTime of this non-real frame
237
			   so we can roll it up to the real frame when we reach one. */
238
			frame->filteredMethodsBaseTime += baseTime;
239
			DBG_CHK_AND_REPORT_TIME_OVERFLOW(frame->filteredMethodsBaseTime, 
240
			                                 "Time overflowed?! (agPop: frame->filteredMethodsBaseTime)\n"); /* 134577 */			
241
			frame->filteredMethodsBaseCPUTime += baseCPUTime;
242
		}
243
		stackEntry->stackFrame = NULL;  /* 134635 */
244
	}
245
}
246
247
/** POP  ************************************************************************
248
  */
249
void jvmpiAgent_Pop(ThreadPrivateStorage *tps)
250
{
251
	if (tps != NULL  &&  tps->tos == 0)  {
252
		/* RKD:  We are underflowing here.  Mark the stack as invalid and return */
253
		tps->threadStackKnown=0;
254
		return;
255
	}
256
 assert(tps && tps->tos);
257
#ifdef SEGMENTED_VALUE_MULTIWORD
258
 free(tps->stackEntry[tps->tos].ticket.values);
259
#endif
260
261
  /* if pre-aggregating, roll up this frame's data to its StackFrame */
262
  if(_jvmpiAgent_Options.compressLevel==CompressAggregate)
263
	jvmpiAgent_agPop(&tps->stackEntry[tps->tos]);
264
265
 tps->tos--;
266
}
267
268
/**********************************************************
269
	jvmpiAgent_CreateStackFrame()
270
	Creates a stack frame for a stack entry. Called if this method is being
271
	tracked, then it searches the caller's stack frames, if not found 
272
	creates a new entry. Marks the StackEntry "real" to say it
273
	represents a tracked method, not one that's filtered out.
274
	
275
***************************************************************/
276
void jvmpiAgent_CreateStackFrame(ThreadPrivateStorage * tps, 
277
								 HashEntry* methodHashEntry,
278
								 StackEntry* caller)
279
{
280
281
	StackFrame * callerStackFrame = NULL;
282
	StackFrame * frame = NULL;
283
	StackFrame * it = NULL;
284
	StackFrame** base = NULL;
285
	StackFrame** prev = NULL;
286
287
	/*
288
	 * Search through the caller's stackframes to see if we already have
289
	 * a matching one. The "caller" might be the thread itself if the thread 
290
	 * stack is empty.
291
	 * 
292
	 * During this search, set "base" to point to the "calledList" that the
293
	 * frame if found on, or the one it belongs on if it's not found.
294
	 *
295
	 * Also, set "prev" to point to the "next" pointer that pointed to the
296
	 * found frame, if one is found; we use this to unlink the frame
297
	 * and move it to the base of the list it is on, as an optimization.
298
	 */	
299
300
	if( caller == NULL || caller->stackFrame == NULL) {
301
 		/* no caller; use the thread's list of top-level functions */
302
		callerStackFrame = NULL;
303
		base = &(tps->calledList);
304
		prev = base;
305
		it = *base;
306
	}
307
	else {
308
 		/* There is a caller: use that frame's list of called functions */
309
		callerStackFrame = caller->stackFrame;
310
		base = &(callerStackFrame->calledList);
311
		prev = base;
312
		it = *base;
313
	}
314
315
	/* now "it" is the first entry on the proper calledList */
316
317
	while ( it != NULL ) {
318
		if( it->methodHashEntry == methodHashEntry ) {
319
			/* we've seen this call before: re-use the existing frame */
320
			frame = it;
321
			/* Optimization opportunity here: 
322
			 * if the "it" frame isn't first, make it first, on the theory
323
			 * that the caller might call the same callee again soon,
324
			 * and it will make the search time shorter.
325
			 * Tradeoff: it will mean acquiring stackFrameStructureLock,
326
			 * which might wipe out the benefit. See notes elsewhere
327
			 * about stackFrameStructureLock, talking about why it's needed 
328
			 * and what the no-lock alternatives might be.
329
			 */
330
			break;
331
		}
332
333
		/* no match. update "prev" and "it" to walk to the next link in the chain */
334
		prev = &(it->next);
335
		it = *prev;
336
	}
337
338
	if ( frame == NULL ) {
339
		/* This is a new child of its caller; create a stack frame */
340
341
		/* Optimization opportunity: use a chunky allocator for StackFrame objects.
342
		 * They persist without being freed until they all get freed at once when this thread dies.
343
		 * Then again, malloc is usually pretty optimized, and jvmpiAgent_Calloc attempts some
344
		 * out-of-memory error reporting.
345
		 */
346
		frame = (StackFrame *)jvmpiAgent_Calloc(sizeof(StackFrame));
347
		frame->methodHashEntry = methodHashEntry;
348
349
		/* 
350
		 * Prepend this new frame to the proper calledList.
351
		 * Remember, "base" is a pointer to either tps->calledList or
352
		 * the caller's calledList. We prepend because it's quicker and
353
		 * because it could be a slight optimization for locality,
354
		 * making searches shorter. (Imagine a function call in a loop.)
355
		 *
356
		 * Get stackFrameStructureLock here because another thread might be 
357
		 * dumping a snapshot right now. We only use this when adding a new 
358
		 * unique frame, not on every entry/exit. See notes elsewhere
359
		 * about no-lock alternatives to stackFrameStructureLock.
360
		 */
361
		getStackFrameStructureLock();
362
		{
363
			frame->caller = callerStackFrame;
364
			frame->next = *base;
365
			*base = frame;
366
		}
367
		releaseStackFrameStructureLock();
368
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
369
		printf("jvmpiAgent_CreateStackFrame: tps, &stackframe, &methodHashEntry, MethodIdRef= %8x, %8x, %8x, %5d\n",
370
			    (void *)tps, (void *)frame, (void*)methodHashEntry, (jint)((METHOD_ENTRY(methodHashEntry))->static_id)); 
371
		fflush(stdout);
372
#endif
373
	}
374
375
	tps->stackEntry[tps->tos].stackFrame = frame;
376
	tps->stackEntry[tps->tos].realFrame = 1;
377
}
378
379
380
/** PEEK  ***********************************************************************
381
  */
382
StackEntry * jvmpiAgent_Peek(ThreadPrivateStorage *tps, int offset)
383
{
384
 assert(tps);
385
 if((int)tps->tos <= offset)
386
	 return NULL;
387
 return &tps->stackEntry[tps->tos-offset];
388
}
389
390
/** TOP_OF_STACK  ***************************************************************
391
  */
392
unsigned long jvmpiAgent_TOS(ThreadPrivateStorage *tps)
393
{
394
 return tps ? tps->tos : 0;
395
}
396
397
/** STACK_DEPTH  ***************************************************************
398
  */
399
unsigned long jvmpiAgent_StackDepth(ThreadPrivateStorage *tps) {
400
	return tps->tos;
401
}
(-)src-native-new/src/agents/RABindings/WinBuild/RABindings.dsp (+131 lines)
Added Link Here
1
# Microsoft Developer Studio Project File - Name="RABinding" - Package Owner=<4>
2
# Microsoft Developer Studio Generated Build File, Format Version 6.00
3
# ** DO NOT EDIT **
4
5
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
6
7
CFG=RABinding - Win32 Debug
8
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9
!MESSAGE use the Export Makefile command and run
10
!MESSAGE 
11
!MESSAGE NMAKE /f "RABinding.mak".
12
!MESSAGE 
13
!MESSAGE You can specify a configuration when running NMAKE
14
!MESSAGE by defining the macro CFG on the command line. For example:
15
!MESSAGE 
16
!MESSAGE NMAKE /f "RABinding.mak" CFG="RABinding - Win32 Debug"
17
!MESSAGE 
18
!MESSAGE Possible choices for configuration are:
19
!MESSAGE 
20
!MESSAGE "RABinding - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
21
!MESSAGE "RABinding - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
22
!MESSAGE 
23
24
# Begin Project
25
# PROP AllowPerConfigDependencies 0
26
# PROP Scc_ProjName ""
27
# PROP Scc_LocalPath ""
28
CPP=cl.exe
29
MTL=midl.exe
30
RSC=rc.exe
31
32
!IF  "$(CFG)" == "RABinding - Win32 Release"
33
34
# PROP BASE Use_MFC 0
35
# PROP BASE Use_Debug_Libraries 0
36
# PROP BASE Output_Dir "RABinding___Win32_Release"
37
# PROP BASE Intermediate_Dir "RABinding___Win32_Release"
38
# PROP BASE Target_Dir ""
39
# PROP Use_MFC 0
40
# PROP Use_Debug_Libraries 0
41
# PROP Output_Dir "..\..\..\..\lib"
42
# PROP Intermediate_Dir "Release"
43
# PROP Ignore_Export_Lib 0
44
# PROP Target_Dir ""
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RABINDING_EXPORTS" /YX /FD /c
46
# ADD CPP /nologo /MT /W3 /GX /O2 /Ob0 /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RABINDING_EXPORTS" /YX /FD /c
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
49
# ADD BASE RSC /l 0x409 /d "NDEBUG"
50
# ADD RSC /l 0x409 /fo"Release/hcbnd.res" /d "NDEBUG"
51
BSC32=bscmake.exe
52
# ADD BASE BSC32 /nologo
53
# ADD BSC32 /nologo
54
LINK32=link.exe
55
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
56
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib hcclco.lib /nologo /version:0.1 /dll /pdb:none /machine:I386 /out:"..\..\..\..\bin\hcbnd.dll" /libpath:"..\..\..\..\lib"
57
58
!ELSEIF  "$(CFG)" == "RABinding - Win32 Debug"
59
60
# PROP BASE Use_MFC 0
61
# PROP BASE Use_Debug_Libraries 1
62
# PROP BASE Output_Dir "RABinding___Win32_Debug"
63
# PROP BASE Intermediate_Dir "RABinding___Win32_Debug"
64
# PROP BASE Target_Dir ""
65
# PROP Use_MFC 0
66
# PROP Use_Debug_Libraries 1
67
# PROP Output_Dir "..\..\..\..\lib"
68
# PROP Intermediate_Dir "Debug"
69
# PROP Ignore_Export_Lib 0
70
# PROP Target_Dir ""
71
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RABINDING_EXPORTS" /YX /FD /GZ /c
72
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RABINDING_EXPORTS" /YX /FD /GZ /c
73
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
74
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
75
# ADD BASE RSC /l 0x409 /d "_DEBUG"
76
# ADD RSC /l 0x409 /fo"Debug/hcbnd.res" /d "_DEBUG"
77
BSC32=bscmake.exe
78
# ADD BASE BSC32 /nologo
79
# ADD BSC32 /nologo
80
LINK32=link.exe
81
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
82
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib hcclco.lib /nologo /dll /debug /machine:I386 /out:"..\..\..\..\bin\hcbnd.dll" /pdbtype:sept /libpath:"..\..\..\..\lib"
83
84
!ENDIF 
85
86
# Begin Target
87
88
# Name "RABinding - Win32 Release"
89
# Name "RABinding - Win32 Debug"
90
# Begin Group "Source Files"
91
92
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
93
# Begin Source File
94
95
SOURCE=..\lock3.c
96
# End Source File
97
# Begin Source File
98
99
SOURCE=..\RABindings.c
100
# End Source File
101
# Begin Source File
102
103
SOURCE=..\RABindings.def
104
# End Source File
105
# End Group
106
# Begin Group "Header Files"
107
108
# PROP Default_Filter "h;hpp;hxx;hm;inl"
109
# Begin Source File
110
111
SOURCE=..\lock3.h
112
# End Source File
113
# Begin Source File
114
115
SOURCE=..\RABindings.h
116
# End Source File
117
# Begin Source File
118
119
SOURCE=..\resource.h
120
# End Source File
121
# End Group
122
# Begin Group "Resource Files"
123
124
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
125
# Begin Source File
126
127
SOURCE=..\version.rc
128
# End Source File
129
# End Group
130
# End Target
131
# End Project
(-)src-native-new/src/agents/native/java_profiler/StatelessHeapSnapshotManager_C.h (+56 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: StatelessHeapSnapshotManager_C.h,v 1.4 2005/04/06 19:15:49 samwai Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef STATELESS_HEAP_SNAPSHOT_MANAGER_C_H
14
#define STATELESS_HEAP_SNAPSHOT_MANAGER_C_H
15
16
#include <jvmpi.h>
17
18
/* Error Codes */ 
19
#define RA_OPT_HEAP_DISK_FULL             1
20
#define RA_OPT_HEAP_COULD_NOT_CREATE_FILE 2
21
22
#ifdef __cplusplus
23
extern "C"
24
#endif
25
int StatelessHeapSnapshotManager_handleHeapSnapshot_FromC(JNIEnv*      env,
26
							   int          dump_level,
27
							   char*        begin,
28
							   char*        end);
29
30
#ifdef __cplusplus
31
extern "C"
32
#endif
33
void StatelessHeapSnapshotManager_setup_FromC(JVMPI_Interface *jvmpi,
34
											  BOOL classInfoCallback);
35
36
#ifdef __cplusplus
37
extern "C"
38
#endif
39
void StatelessHeapSnapshotManager_classInfoCallback(const char*  className,
40
						    int          numInterfaces,
41
						    int          numStaticFields,
42
						    JVMPI_Field* statics);
43
44
#ifdef __OS400__
45
#ifdef __cplusplus
46
extern "C"
47
#endif
48
void StatelessHeapSnapshotManager_objectDumpCallbackMethod(JVMPI_Event *event);
49
#endif
50
/* Bug 64476 */
51
#ifdef __cplusplus
52
extern "C"
53
#endif
54
void StatelessHeapSnapshotManager_optHeapCallBack(char* filename)  ;
55
56
#endif /* STATELESS_HEAP_SNAPSHOT_MANAGER_C_H */
(-)src-native-new/src/agents/native/heapsnapshots/StatelessHeapSnapshotManager.h (+54 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: StatelessHeapSnapshotManager.h,v 1.6 2005/10/03 19:30:59 bduncan Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef STATELESS_HEAP_SNAPSHOT_MANAGER_H
14
#define STATELESS_HEAP_SNAPSHOT_MANAGER_H
15
16
#include "AbstractHeapSnapshotManager.h"
17
18
#if defined MVS /* Bug 110369 */
19
#ifndef true
20
typedef unsigned int bool;
21
#define true 1
22
#define false 0
23
#endif
24
#endif
25
26
class StatelessHeapSnapshotManager : public AbstractHeapSnapshotManager {
27
 public:
28
  StatelessHeapSnapshotManager(SnapshotFiller*         filler,
29
			       SnapshotAgentInterface* agent,
30
			       JVMPI_Interface*        jvmpi,
31
			       bool					   optHeapDebug,
32
			       FILE *				   debugOut);
33
34
  void handleHeapSnapshot(JNIEnv*      env,
35
			  int          dump_level,
36
			  char*        begin,
37
			  char*        end,
38
			  HeapDumpMode heapDumpMode);
39
  char isStateless() const;
40
41
 protected:
42
  void *prof_dump_read_ptr(char **current) const;
43
  char getClassInfos(char* begin, char* end) const;
44
  void parseClassDump(unsigned int object_dump_len, 
45
  	char *object_dump_data, int numInterfaces, 
46
  	int numStaticReferenceFields,
47
	unsigned int *instanceSize, jobjectID** classRefs) const;
48
49
 private:
50
   bool				_optHeapDebug;
51
   FILE*			_debugOut;
52
};
53
54
#endif /* STATELESS_HEAP_SNAPSHOT_MANAGER_H */
(-)src-native-new/src/HCLauncher/launcher_error.h (+34 lines)
Added Link Here
1
/**********************************************************************
2
Copyright (c) 2005 IBM Corporation and others.
3
All rights reserved.   This program and the accompanying materials
4
are made available under the terms of the Eclipse Public License v1.0
5
which accompanies this distribution, and is available at
6
http://www.eclipse.org/legal/epl-v10.html
7
$Id: launcher_error.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 
9
Contributors:
10
    IBM Corporation - initial implementation
11
**********************************************************************/
12
13
/* Error code */
14
#define ERROR_JNI_ENV                    -100
15
16
#define ERROR_JNI_LAUNCH_EXE_CLS         -101
17
#define ERROR_JNI_LAUNCH_EXE_OBJ_ID      -102
18
#define ERROR_JNI_LAUNCH_EXE_OBJ         -103
19
#define ERROR_JNI_LAUNCH_EXE_NAME        -104
20
#define ERROR_JNI_LAUNCH_CMD_LINE        -105
21
#define ERROR_JNI_LAUNCH_LOCATION        -106
22
23
#define ERROR_JNI_LAUNCH_ENV_OBJ_ID      -201
24
#define ERROR_JNI_LAUNCH_ENV_OBJARRAY_ID -202
25
#define ERROR_JNI_LAUNCH_PROP_CLASSS     -203
26
#define ERROR_JNI_LAUNCH_ENV_OBJARRAY    -204
27
#define ERROR_JNI_LAUNCH_ENV_NAME_ID     -205
28
#define ERROR_JNI_LAUNCH_ENV_VALUE_ID    -206
29
#define ERROR_JNI_LAUNCH_ENV_NAME        -207
30
#define ERROR_JNI_LAUNCH_ENV_VALUE       -208
31
32
#define ERROR_JNI_LISTENER_CLS           -301
33
#define ERROR_JNI_LISTENER_OBJ_ID        -302
34
#define ERROR_JNI_LISTENER_OBJ           -303
(-)src-native-new/src/agents/native/java_profiler/StatelessHeapSnapshotManager_C.cpp (+752 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: StatelessHeapSnapshotManager_C.cpp,v 1.8 2006/05/11 22:20:00 bduncan Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include <string.h>
14
#include <time.h>
15
#include <stdlib.h>
16
#include "options.h"
17
#include "JvmpiWriter.h"
18
#include "StatelessHeapSnapshotManager_C.h"
19
#include "performance.h" // Uint64, _ticksPerMicrosecond
20
21
#include "../heapsnapshots/HeapSnapshotManager.h"
22
#include "../heapsnapshots/StatelessHeapSnapshotManager.h"
23
#include "../heapsnapshots/SnapshotFiller.h"
24
#include "../heapsnapshots/SnapshotAgentInterface.h"
25
26
27
#ifdef _WIN32
28
#include <winsock2.h> /* Bug 134924 */
29
#include <windows.h>
30
#include <process.h>
31
 /* typedef int PID; */
32
#else
33
#include <unistd.h>
34
 /* typedef pid_t PID; */
35
#endif
36
37
static bool optHeapDebug = false;
38
static FILE *debugOut = stderr;
39
40
/* Modification History */
41
/*Bugzilla 82214 - The code has been cleaned to remove the moves and free handling 
42
*/ 
43
44
/* Bug Number 73480 */
45
#ifdef __OS400__
46
/** CALLOC  *************************************************************
47
  * Allocate some memory from the heap.  If there is no more memory left
48
  * the VM will exit gracefully.
49
  */
50
static void* jvmpiAgent_Calloc(unsigned int size) {
51
	void *p=malloc(size);
52
	if(p==NULL) {
53
		fprintf(stderr, "FATAL ERROR:  Out of memory...JVM Exiting\n");
54
		fflush(stderr); 
55
		_jvmpiAgent_jvmpiInterface->ProfilerExit((jint)-1);
56
	}
57
	memset(p, 0, size);
58
	return p;
59
}
60
61
62
/** CREATE_SYMBOL  *************************************************************
63
  *
64
  */
65
static HashEntry * jvmpiAgent_CreateSymbol(void *id)
66
{
67
 /* Create a new hash entry and then insert it into the hash table */
68
 HashEntry * hashEntry = (HashEntry *)jvmpiAgent_Calloc(sizeof(HashEntry));
69
 hashEntry->id=id;
70
 hashEntry->printed=0;
71
 hashEntry->deleted= 0;
72
 hashEntry->toBeFreed=0;
73
 hashEntry->next=NULL;
74
 return hashEntry;
75
}
76
77
78
void StatelessHeapSnapshotManager_createClassSymbol(jobjectID classId,
79
						const char*  className,
80
						int          numInterfaces,
81
						int          numStaticFields
82
						) {
83
	//HashEntry *classObjectEntry;
84
	//classObjectEntry=jvmpiAgent_FindObjectSymbol(classId);
85
	ClassEntry *classEntry;
86
	HashEntry *hashEntry;
87
	ClassHashKey *k; 
88
	/* AM: This block of code will ensure that a class symbol is not created more than once for the same class */
89
	hashEntry = jvmpiAgent_FindClassSymbol (classId) ;
90
	if (!hashEntry) {
91
		k = (ClassHashKey *)jvmpiAgent_Calloc(sizeof(ClassHashKey)); 
92
		k->id=classId; 
93
		hashEntry = jvmpiAgent_CreateSymbol((void *)k);
94
		/* Allocate and copy the event data into the symbol table structure */
95
		hashEntry->entry  = (ClassEntry*)jvmpiAgent_Calloc(sizeof(ClassEntry));
96
		classEntry = CLASS_ENTRY(hashEntry);
97
		if(className) {
98
			STRDUP(classEntry->className, className);
99
		}
100
		classEntry->numInterfaces = numInterfaces;
101
		classEntry->numStaticFields   = numStaticFields;
102
		insertClassOptSymbol(hashEntry);
103
	}
104
}
105
#endif
106
107
108
/* Piyush Bug 58049 */
109
class FillerException {
110
  private :
111
	int e ;
112
  public :
113
	FillerException ( int error ) :e(error) {} 
114
	int getErrorCode () { return e ; }
115
 
116
} ;
117
118
119
class HyadesSnapshotFiller : public SnapshotFiller {
120
 public:
121
  HyadesSnapshotFiller(unsigned int objectMoveBatchSize, unsigned int objectFreeBatchSize)
122
  {
123
  }
124
  ~HyadesSnapshotFiller() {
125
  }
126
127
  void makeFileName(char *buf) {
128
	PID pid;
129
	time_t currentTime;
130
	struct tm ltime, *pMemoryLeak=NULL;
131
	char* hdfilename = '\0' ;
132
	char pidString[10] ;
133
	int lenPidString ;
134
135
#ifdef MVS
136
#pragma convlit(suspend)
137
#endif
138
	/* start from dir name */
139
	*buf = '\0';
140
#ifdef MVS
141
__atoe(_jvmpiAgent_Options.workDir) ;
142
#endif
143
	strcpy(buf, _jvmpiAgent_Options.workDir);
144
#ifdef MVS
145
__etoa(_jvmpiAgent_Options.workDir) ;
146
#endif
147
	buf += strlen(_jvmpiAgent_Options.workDir);
148
#ifdef _WIN32
149
	*buf = '\\'; /* file delim in Windows */
150
#else
151
	*buf = '/'; /* file delim in Unix */
152
#endif
153
	buf += 1; *buf = '\0';
154
	hdfilename = buf ;
155
	/* Applend the file prefix */
156
#ifdef MVS
157
__atoe(_jvmpiAgent_Options.heapInfoFilePrefix) ;
158
#endif
159
	strcat(buf, _jvmpiAgent_Options.heapInfoFilePrefix);
160
#ifdef MVS
161
__etoa(_jvmpiAgent_Options.heapInfoFilePrefix) ;
162
#endif
163
	/* buf always points to the end, where things can be appended */
164
	buf += strlen(_jvmpiAgent_Options.heapInfoFilePrefix);
165
166
	/* Get the time and date */
167
	time(&currentTime);
168
	/* ToDo: localtime_r() is not in Windows, otherwise that is better suited.
169
	 * Not deleting pLocalTimeBreakup, because not sure who owns it, so it is
170
	 * very small one time leak, but we should fix it.
171
	 */
172
173
	/*Piyush Bug 82214 */
174
	/* We have changed the naming of files so that every name will have new time. */
175
		pMemoryLeak = localtime(&currentTime);
176
		ltime = *pMemoryLeak;
177
		/* free (pMemLeak); can I free it here?  */
178
		sprintf(_headerTimeStamp, ".%.4d%.2d%.2d.%.2d%.2d%.2d \n",
179
			1900+ltime.tm_year, 1+ltime.tm_mon, ltime.tm_mday,
180
			ltime.tm_hour, ltime.tm_min, ltime.tm_sec);
181
		_headerTimeStamp[17] = '\0' ;
182
183
	/* Use the stored timestamp */
184
	strcpy(buf,_headerTimeStamp) ;
185
	buf += 16; /* .YYYYMMDD.HHMMSS = 12 bytes */
186
187
	/* get process id */
188
	pid = getpid();
189
190
#ifdef _WIN32
191
    itoa((int)pid,pidString,10) ;
192
	sprintf(buf, ".%d", (int) pid);
193
	lenPidString = strlen(pidString) + 1 ;
194
#else
195
	/* Here the "." is included in sprintf so the lenPidString = strlen(pidString) +1 
196
	   which is similar to the one above */
197
	lenPidString = sprintf(buf, ".%d", (int) pid);
198
#endif
199
	buf += lenPidString ;
200
201
	/* append cycle etc */
202
	sprintf(buf, ".trcopt");
203
	strcpy(_hdFileName,hdfilename) ;
204
	hdfilename = NULL ;
205
206
#ifdef MVS
207
#pragma convlit(resume)
208
#endif
209
  }
210
  void FillJinsightHeader() {
211
#if 0
212
    struct event {
213
      char traceFormatTag;   /* 'o' */
214
      int traceVersion;      /* 10 */
215
      int platformTag;
216
      int numberOfEvents;
217
      int maxThread;
218
      int maxClass;
219
      int ticksPerMicrosecond;
220
      Uint64 connectionTime_in_ticks;
221
      int processStartTime_in_ms;
222
      int connectionTime_in_ms;
223
      int parentJVMOverhead;
224
    };
225
    struct event e = {'o', 10, 44, 0, 0x100, 0x4000, 0, 0, 0, 0, 0};
226
    fillerfwrite(&e, sizeof(event), 1, _snappieFile);
227
#endif
228
229
	const int BINARY_HEAP_DUMP_VERSION = 12;
230
231
    time_t connectionStartTime;
232
    time(&connectionStartTime);
233
234
#if defined(__OS400__)
235
#pragma convert(819)
236
#endif
237
    traceWriteByte('o');
238
#if defined(__OS400__)
239
#pragma convert(0)
240
#endif
241
    traceWriteInt32LittleEndian(BINARY_HEAP_DUMP_VERSION);
242
    traceWritePlatformLittleEndian();
243
    traceWriteInt32LittleEndian(0); // UNUSED: number of events
244
    traceWriteInt32LittleEndian(0); // UNUSED: max thread id
245
    traceWriteInt32LittleEndian(0); // UNUSED: max class id
246
    traceWriteInt32LittleEndian(_ticksPerMicrosecond);
247
    traceWriteTimestampLittleEndian(0);
248
    traceWriteInt32LittleEndian(0);
249
    traceWriteInt32LittleEndian(connectionStartTime);
250
    traceWriteInt32LittleEndian(0);
251
252
    fflush(_snappieFile);
253
  }
254
  void traceWriteByte(char b){
255
	fillerfwrite(&b, sizeof(char), 1, _snappieFile);
256
  }
257
  void traceWriteOID(jobjectID oid) {
258
    fillerfwrite(&oid, sizeof(jobjectID), 1, _snappieFile);
259
  }
260
  void traceWriteOIDArray(jobjectID* oids, unsigned int num) {
261
    fillerfwrite(oids, sizeof(jobjectID), num, _snappieFile);
262
  }
263
  void traceWritePlatformLittleEndian() {
264
265
#if defined(_WIN32)
266
    traceWriteInt32LittleEndian(11);
267
#elif defined(_AIX)
268
    traceWriteInt32LittleEndian(22);
269
#elif defined(MVS)
270
    traceWriteInt32LittleEndian(33);
271
#elif defined(__linux__) && defined(__i386__)
272
    traceWriteInt32LittleEndian(44);
273
#elif defined(__linux__) && defined(__s390__)
274
    traceWriteInt32LittleEndian(55);
275
#elif defined(_SOLARIS)
276
    traceWriteInt32LittleEndian(66);
277
#elif defined(_HPUX)
278
    traceWriteInt32LittleEndian(77);
279
#elif defined(__OS400__)
280
    traceWriteInt32LittleEndian(88);
281
#elif defined(__linux__) && defined(__powerpc64__) || defined(_WIN64) /*ts. bug 120479*/
282
    /* traceWriteInt32LittleEndian(99); */
283
#else
284
#error "unknown platform"
285
#endif
286
  }
287
  void traceWriteInt16LittleEndian(unsigned short id) {
288
    traceWriteByte(id&0xff);
289
    traceWriteByte((id&0xff00)>>8);
290
  }
291
  void traceWriteInt16(unsigned short id) {
292
	  fillerfwrite(&id, sizeof(unsigned short), 1, _snappieFile);
293
  }
294
  void traceWriteInt32LittleEndian(unsigned int id) {
295
    traceWriteByte(id&0xff);
296
    traceWriteByte((id&0xff00)>>8);
297
    traceWriteByte((id&0xff0000)>>16);
298
    traceWriteByte((id&0xff000000)>>24);
299
  }
300
  void traceWriteInt32(unsigned int id) {
301
	  fillerfwrite(&id, sizeof(unsigned int), 1, _snappieFile);
302
  }
303
  void traceWriteString(const char* bytes, unsigned int numBytes) {
304
    traceWriteInt16(numBytes);
305
    fillerfwrite(bytes, sizeof(char), numBytes, _snappieFile);
306
  }
307
  void traceWriteTimestampLittleEndian(Uint64 id) {
308
#ifdef IBM_OE
309
    unsigned long long mask;
310
#else
311
    Uint64 mask;
312
#endif // IBM_OE
313
314
    mask = 0xff;
315
    char byte1    = (char)(id&mask);
316
    traceWriteByte(byte1);
317
318
    mask = mask << 8;
319
    char byte2 = (char)((id&mask)>>8);
320
    traceWriteByte(byte2);
321
322
    mask = mask << 8;
323
    char byte3 = (char)((id&mask)>>16);
324
    traceWriteByte(byte3);
325
326
    mask = mask << 8;
327
    char byte4 = (char)((id&mask)>>24);
328
    traceWriteByte(byte4);
329
330
    mask = mask << 8;
331
    char byte5 = (char)((id&mask)>>32);
332
    traceWriteByte(byte5);
333
334
    mask = mask << 8;
335
    char byte6 = (char)((id&mask)>>40);
336
    traceWriteByte(byte6);
337
338
    mask = mask << 8;
339
    char byte7 = (char)((id&mask)>>48);
340
    traceWriteByte(byte7);
341
342
    mask = mask << 8;
343
    char byte8 = (char)((id&mask)>>56);
344
    traceWriteByte(byte8);
345
  }
346
  void traceWriteTimestamp(Uint64 id) {
347
	  fillerfwrite(&id, sizeof(Uint64), 1, _snappieFile);
348
  }
349
  void FillClassInfo(jobjectID   classID,
350
		     const char* className,
351
		     int         numStaticReferenceFields,
352
		     int         numInterfaces,
353
#if defined(__OS400__)
354
			 int         instanceSize,
355
			 jobjectID*  classRefs) {
356
#else
357
			 int         instanceSize) {
358
#endif
359
#if 0
360
    struct event1 {
361
      char eventTag;
362
      jobjectID classID;
363
      short classNameNumBytes;
364
    };
365
    struct event2 {
366
      int numStaticReferenceFields;
367
      int numInterfaces;
368
    };
369
    int classNameNumBytes = strlen(className);
370
    struct event1 e1 = {81, classID, classNameNumBytes};
371
    struct event2 e2 = {numStaticReferenceFields, numInterfaces};
372
    fillerfwrite(&e1, sizeof(event1), 1, _snappieFile);
373
    fillerfwrite(className, sizeof(char), classNameNumBytes, _snappieFile);
374
    fillerfwrite(&e2, sizeof(event2), 1, _snappieFile);
375
#endif
376
377
    traceWriteByte(81);
378
#if defined(__OS400__)
379
	traceWriteOID(classID);
380
#else
381
    traceWriteInt32((int)classID);
382
#endif
383
    traceWriteString(className, strlen(className));
384
    traceWriteInt32(numStaticReferenceFields);
385
    traceWriteInt32(numInterfaces);
386
	traceWriteInt32(instanceSize);
387
#if defined(__OS400__)
388
	if (classRefs) {
389
		traceWriteInt32(numStaticReferenceFields);
390
		traceWriteOIDArray(classRefs, numStaticReferenceFields);
391
	} else {
392
		traceWriteInt32(0);
393
	}
394
#endif
395
  }
396
  void FillJvmpiSnapshot(char* begin, char* end) {
397
#if 0
398
    struct event {
399
      char eventTag;
400
      Uint64 timestamp;
401
      int sizeofVoidStar;
402
      int numBytesInSnapshot;
403
    };
404
    struct event e = {80, 0, sizeof(void*), end-begin};
405
    fillerfwrite(&e, sizeof(event), 1, _snappieFile);
406
#endif
407
408
    traceWriteByte(80);
409
    traceWriteTimestamp(0);
410
    traceWriteInt32(sizeof(void*));
411
    traceWriteInt32(end-begin);
412
    fillerfwrite(begin, sizeof(char), end-begin,  _snappieFile);
413
    fflush(_snappieFile);
414
  }
415
416
417
418
  void writeHeader()	
419
  {
420
    FillJinsightHeader();
421
  }
422
 
423
  void closeHeapDumpFile()
424
  {
425
    fclose(_snappieFile) ;
426
	/* Moved the callback method here so that it is called only after the heap dump is created */
427
	StatelessHeapSnapshotManager_optHeapCallBack(_hdFileName) ;
428
	
429
  }
430
431
432
#ifdef MVS
433
#pragma convlit(suspend)
434
#endif
435
  void createHeapDumpFile()
436
  {
437
    char filename[511];
438
	makeFileName(filename);
439
440
	_snappieFile = fopen(filename, "wb");
441
	
442
	/* check if fopen() failed */
443
	if(_snappieFile == NULL) {
444
		if (_jvmpiAgent_Options.standalone) {
445
		  fprintf(stderr, "*** Could not open output file \"%s\".  Exiting JVM. ***\n", filename);
446
		  fflush(stderr);  
447
		  _jvmpiAgent_jvmpiInterface->ProfilerExit((jint)-1);
448
		}
449
		throw FillerException(RA_OPT_HEAP_COULD_NOT_CREATE_FILE) ;/* Piyush 58049 */
450
	}
451
  }
452
#ifdef MVS
453
#pragma convlit(resume)
454
#endif
455
  
456
  /* Piyush Bug 58049 */
457
  void fillerfwrite(const void* buffer, size_t size, size_t count, FILE* stream)  {
458
	size_t result = 0 ;
459
	int error = 0 ;
460
	result = fwrite(buffer, size, count, stream);
461
	error = ferror(stream) ;
462
	if ( error || result != count )
463
	{
464
		throw FillerException(RA_OPT_HEAP_DISK_FULL) ;	
465
	}
466
  }	
467
468
// Multiple File Support
469
 private:
470
  FILE* _snappieFile;
471
  char _hdFileName[511];
472
  char _headerTimeStamp[17] ;
473
};
474
475
class HyadesSnapshotAgentInterface : public SnapshotAgentInterface {
476
 public:
477
  HyadesSnapshotAgentInterface(JVMPI_Interface* jvmpi, BOOL classInfoCallback)
478
	  : _jvmpi(jvmpi), _classInfoCallback(classInfoCallback)
479
  {
480
  }
481
  void classInfoCallback(const char*  className,
482
			 int          numInterfaces,
483
			 int          numStaticFields,
484
			 JVMPI_Field* statics) {
485
    int i;
486
    int numStaticReferenceFields = 0;
487
    for (i=0; i<numStaticFields; i++) {
488
      char prim = statics[i].field_signature[0];
489
#ifdef __OS400__
490
#pragma convert(819)
491
#endif
492
      if (prim == '[' || prim == 'L') {
493
#ifdef __OS400__
494
#pragma convert(0)
495
#endif
496
	numStaticReferenceFields++;
497
      }
498
    }
499
500
    _stashedClassName = strdup(className);
501
    _stashedNumInterfaces = numInterfaces;
502
    _stashedNumStaticReferenceFields = numStaticReferenceFields;
503
  }
504
  
505
#ifdef __OS400__
506
  void objectDumpCallbackMethod(JVMPI_Event *event) {
507
    _stashedObjectDumpLen = event->u.object_dump.data_len;
508
    _stashedObjectDumpData = (char *)jvmpiAgent_Calloc(_stashedObjectDumpLen);
509
  	memcpy(_stashedObjectDumpData,event->u.object_dump.data,_stashedObjectDumpLen);
510
  }
511
#endif
512
  
513
  char getClassInfo(jobjectID classID,
514
		    char**    className_outvar,
515
		    char*     className_freeMe,
516
		    int*      numInterfaces_outvar,
517
		    int*      numStaticReferenceFields_outvar) {
518
519
#ifdef __OS400__
520
/* Bug Number 73480 */
521
    int status = 0;
522
    /* 96198 Return all the values, even if the class is already
523
	   in the table 
524
     */
525
	if (jvmpiAgent_FindClassSymbol(classID)) status = 1;
526
#endif
527
528
    BOOL tmp = _classInfoCallback; /* backup the original value */
529
	_classInfoCallback = (BOOL) TRUE; /* change it for requesting next event */
530
	REQUEST_EVENT2(JVMPI_EVENT_CLASS_LOAD, classID);
531
    _classInfoCallback = tmp; /* restore */
532
533
    /* _stashedClassName is already a copy - caller to free*/
534
	*className_outvar = _stashedClassName;
535
    *className_freeMe = 1;
536
    *numInterfaces_outvar = _stashedNumInterfaces;
537
    *numStaticReferenceFields_outvar = _stashedNumStaticReferenceFields;
538
    if (optHeapDebug) {
539
	    fprintf(debugOut, 
540
		"Return from JVMPI_EVENT_CLASS_LOAD for cls_id=0x%x, cls_name=%s, numInterfaces=%d, numStatics=%d.\n",
541
		classID, (_stashedClassName ? _stashedClassName : "NULL"),
542
		_stashedNumInterfaces, _stashedNumStaticReferenceFields);
543
		fflush(debugOut);
544
    }
545
546
/* Bug Number 73480 */
547
#ifdef __OS400__
548
    if (status == 0) {
549
	StatelessHeapSnapshotManager_createClassSymbol(classID,_stashedClassName,
550
										_stashedNumInterfaces,_stashedNumStaticReferenceFields) ;
551
	}
552
	return status;
553
#else
554
555
    return 0;
556
#endif
557
  }
558
  
559
#ifdef __OS400__
560
  char getOS400ClassInfo(jobjectID classID,
561
		    char**    className_outvar,
562
		    char*     className_freeMe,
563
		    int*      numInterfaces_outvar,
564
		    int*      numStaticReferenceFields_outvar,
565
		    unsigned int*	  object_dump_len,
566
		    char**	  object_dump_data) {
567
568
	if (jvmpiAgent_FindClassSymbol(classID)) return 1;
569
570
    BOOL tmp = _classInfoCallback; /* backup the original value */
571
	_classInfoCallback = (BOOL) TRUE; /* change it for requesting next event */
572
	REQUEST_EVENT2(JVMPI_EVENT_CLASS_LOAD, classID);
573
	REQUEST_EVENT2(JVMPI_EVENT_OBJECT_DUMP, classID);
574
    _classInfoCallback = tmp; /* restore */
575
576
    /* _stashedClassName is already a copy  - caller to free*/
577
	*className_outvar = _stashedClassName;
578
    *className_freeMe = 1;
579
    *numInterfaces_outvar = _stashedNumInterfaces;
580
    *numStaticReferenceFields_outvar = _stashedNumStaticReferenceFields;
581
    *object_dump_len = _stashedObjectDumpLen;
582
    /* _stashedObjectDumpData is already a copy  - caller to free*/
583
	*object_dump_data = _stashedObjectDumpData;
584
585
	StatelessHeapSnapshotManager_createClassSymbol(classID,_stashedClassName,
586
										_stashedNumInterfaces,_stashedNumStaticReferenceFields) ;
587
588
    return 0;
589
  }
590
#endif
591
  
592
  char stillAlive() {
593
    return 1;
594
  }
595
  char stillTracing() {
596
    return stillAlive(); /*&&  file/socket not closed? */
597
  }
598
  char shouldIReportHeapSnapshotDuration() {
599
    return 1;
600
  }
601
  short swap16(short n) {
602
    return ntohs(n);
603
  }
604
  int swap32(int n) {
605
    return ntohl(n);
606
  }
607
  char dump_read_u1(char* cursor) {
608
    unsigned char u1;
609
    memcpy(&u1, cursor, sizeof(char));
610
    return u1;
611
  }
612
  short dump_read_u2(char* cursor) {
613
    unsigned short u2;
614
    memcpy(&u2, cursor, sizeof(short));
615
    return u2;
616
  }
617
  int dump_read_u4(char* cursor) {
618
    unsigned int u4;
619
    memcpy(&u4, cursor, sizeof(int));
620
    return u4;
621
  }
622
  jobjectID dump_read_jobjectID(char* cursor) {
623
    // Anandi 25 May 2004 - Change this so it works for 64-bit jobjectIDs
624
    jobjectID ptr;
625
    memcpy(&ptr, cursor, sizeof(jobjectID));
626
    return ptr;
627
  }
628
#ifdef MVS
629
#pragma convlit(suspend)
630
#endif
631
  void status(const char* message) {
632
  if (optHeapDebug) {
633
    fprintf(debugOut, "snapshot status: %s\n", message);
634
    fflush(debugOut);
635
  }
636
  }
637
  void status(const char* message, int message2) {
638
  if (optHeapDebug) {
639
    fprintf(debugOut, "snapshot status: %s %d\n", message, message2);
640
    fflush(debugOut);
641
  }
642
  }
643
  void error(const char* message) {
644
  if (optHeapDebug) {
645
    fprintf(debugOut, "snapshot error: %s\n", message);
646
    fflush(debugOut);
647
  }
648
  }
649
#ifdef MVS
650
#pragma convlit(resume)
651
#endif
652
653
 private:
654
  JVMPI_Interface* _jvmpi;
655
  BOOL _classInfoCallback;
656
  char* _stashedClassName;
657
  int _stashedNumInterfaces;
658
  int _stashedNumStaticReferenceFields;
659
#ifdef __OS400__
660
  unsigned int _stashedObjectDumpLen;
661
  char *_stashedObjectDumpData;
662
#endif
663
};
664
665
HeapSnapshotManager*          _manager;
666
HyadesSnapshotAgentInterface* _agent;
667
HyadesSnapshotFiller*         _filler;
668
669
extern "C"
670
void StatelessHeapSnapshotManager_classInfoCallback(const char*  className,
671
						    int          numInterfaces,
672
						    int          numStaticFields,
673
						    JVMPI_Field* statics)
674
{
675
  _agent->classInfoCallback(className,
676
			    numInterfaces,
677
			    numStaticFields,
678
			    statics);
679
}
680
681
#ifdef __OS400__
682
void StatelessHeapSnapshotManager_objectDumpCallbackMethod(JVMPI_Event *event)
683
{
684
  _agent->objectDumpCallbackMethod(event);
685
}
686
687
/* Bug Number 73480 */
688
/** DELETE_HASH_ENTRY  *********************************************************
689
  *
690
  */
691
int deleteHashEntry(HashEntry *entry,
692
                    void *param) {
693
	jvmpiAgent_DeleteSymbol(entry, (*(enum EntryType*)param));
694
	return 0;
695
}
696
#endif
697
698
699
extern "C"
700
void StatelessHeapSnapshotManager_setup_FromC(JVMPI_Interface *jvmpi,
701
											  BOOL classInfoCallback)
702
{
703
  char *debugOptHeap = getenv("DEBUGOPTHEAP");
704
  if (debugOptHeap && strcmp(debugOptHeap, "TRUE")) optHeapDebug = true;
705
  _filler  = new HyadesSnapshotFiller(1000, 1000);
706
  _agent   = new HyadesSnapshotAgentInterface(jvmpi, classInfoCallback);
707
  _manager = new StatelessHeapSnapshotManager(_filler, _agent, jvmpi, optHeapDebug, debugOut);
708
}
709
710
extern "C"
711
int StatelessHeapSnapshotManager_handleHeapSnapshot_FromC(JNIEnv*      env,
712
							   int          dump_level,
713
							   char*        begin,
714
							   char*        end)
715
{
716
  int errorCode = 0 ;
717
  try {
718
719
	  /*Piyush Bug 82214*/
720
	  /* Write the header in the heap dump file */
721
	  _filler->createHeapDumpFile() ;
722
	  _filler->writeHeader() ;
723
724
	  _manager->handleHeapSnapshot(env, dump_level, begin, end, askingForDumpReferences);
725
726
	  _filler->closeHeapDumpFile() ;
727
728
  } catch ( FillerException ex) {
729
	  /* Piyush Bug 58049 */
730
	  errorCode = ex.getErrorCode() ;
731
#ifdef _DEBUG
732
	  fprintf(stderr,"Caught Exception in handleHeapSnapShot : Error Code %d\n",errorCode) ;
733
	  fflush(stderr); 
734
#endif
735
  }
736
#ifdef __OS400__
737
/* Bug Number 73480 */
738
  	enum EntryType type;
739
	/* Delete each of the classes */
740
	type=Class_t;
741
	jvmpiAgent_ForAll(Class_t, deleteHashEntry, &type);
742
	type = Class_t ;
743
#endif
744
  return errorCode ;
745
}
746
747
/* Bug 64476 - Wrapper method added for name mangling*/
748
extern  "C"
749
void StatelessHeapSnapshotManager_optHeapCallBack(char* filename) {
750
    _jvmpiAgent_optHeapCallBack.ohdcb(filename) ;
751
}
752
(-)src-native-new/src/agents/native/WinBuild/WinBuild.dsw (+52 lines)
Added Link Here
1
Microsoft Developer Studio Workspace File, Format Version 6.00
2
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3
4
###############################################################################
5
6
Project: "heapsnapshots"=.\heapsnapshots.dsp - Package Owner=<4>
7
8
Package=<5>
9
{{{
10
    begin source code control
11
    heapsnapshots
12
    ..
13
    end source code control
14
}}}
15
16
Package=<4>
17
{{{
18
}}}
19
20
###############################################################################
21
22
Project: "java_profiler"=.\java_profiler.dsp - Package Owner=<4>
23
24
Package=<5>
25
{{{
26
    begin source code control
27
    java_profiler
28
    ..
29
    end source code control
30
}}}
31
32
Package=<4>
33
{{{
34
    Begin Project Dependency
35
    Project_Dep_Name heapsnapshots
36
    End Project Dependency
37
}}}
38
39
###############################################################################
40
41
Global:
42
43
Package=<5>
44
{{{
45
}}}
46
47
Package=<3>
48
{{{
49
}}}
50
51
###############################################################################
52
(-)src-native-new/src/agents/native/WinBuild/java_profiler.mak (+501 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on java_profiler.dsp
2
!IF "$(CFG)" == ""
3
CFG=java_profiler - Win32 Debug
4
!MESSAGE No configuration specified. Defaulting to java_profiler - Win32 Debug.
5
!ENDIF 
6
7
!IF "$(CFG)" != "java_profiler - Win32 Release" && "$(CFG)" != "java_profiler - Win32 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "java_profiler.mak" CFG="java_profiler - Win32 Debug"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "java_profiler - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
17
!MESSAGE "java_profiler - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
18
!MESSAGE 
19
!ERROR An invalid configuration is specified.
20
!ENDIF 
21
22
!IF "$(OS)" == "Windows_NT"
23
NULL=
24
!ELSE 
25
NULL=nul
26
!ENDIF 
27
28
CPP=cl.exe
29
MTL=midl.exe
30
RSC=rc.exe
31
32
!IF  "$(CFG)" == "java_profiler - Win32 Release"
33
34
OUTDIR=.\bin
35
INTDIR=.\Release
36
# Begin Custom Macros
37
OutDir=.\bin
38
# End Custom Macros
39
40
!IF "$(RECURSE)" == "0" 
41
42
ALL : "$(OUTDIR)\piAgent.dll"
43
44
!ELSE 
45
46
ALL : "heapsnapshots - Win32 Release" "$(OUTDIR)\piAgent.dll"
47
48
!ENDIF 
49
50
!IF "$(RECURSE)" == "1" 
51
CLEAN :"heapsnapshots - Win32 ReleaseCLEAN" 
52
!ELSE 
53
CLEAN :
54
!ENDIF 
55
	-@erase "$(INTDIR)\agentDebug.obj"
56
	-@erase "$(INTDIR)\filters.obj"
57
	-@erase "$(INTDIR)\hash.obj"
58
	-@erase "$(INTDIR)\JvmpiWriter.obj"
59
	-@erase "$(INTDIR)\options.obj"
60
	-@erase "$(INTDIR)\performance.obj"
61
	-@erase "$(INTDIR)\piagent.res"
62
	-@erase "$(INTDIR)\print.obj"
63
	-@erase "$(INTDIR)\segmentedValue.obj"
64
	-@erase "$(INTDIR)\stack.obj"
65
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager_C.obj"
66
	-@erase "$(INTDIR)\utility.obj"
67
	-@erase "$(INTDIR)\vc60.idb"
68
	-@erase "$(OUTDIR)\piAgent.dll"
69
	-@erase "$(OUTDIR)\piAgent.exp"
70
	-@erase "$(OUTDIR)\piAgent.lib"
71
	-@erase ".\Release\piAgent.map"
72
73
"$(OUTDIR)" :
74
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
75
76
"$(INTDIR)" :
77
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
78
79
CPP_PROJ=/nologo /MT /W3 /GX /O2 /Ob2 /I "..\..\..\framework\RABindings" /I "..\..\..\framework\RACommon" /I "..\..\..\framework\RADataTransfer" /I "..\..\..\framework\RASharedMemory" /I "..\..\..\framework\RASocket" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JAVA_PROFILER_EXPORTS" /D "_INTEL" /Fp"$(INTDIR)\java_profiler.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
80
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
81
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\piagent.res" /d "NDEBUG" 
82
BSC32=bscmake.exe
83
BSC32_FLAGS=/nologo /o"$(OUTDIR)\java_profiler.bsc" 
84
BSC32_SBRS= \
85
	
86
LINK32=link.exe
87
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib rpcrt4.lib ws2_32.lib hcclco.lib hccldt.lib hccls.lib hcbnd.lib hcclsm.lib /nologo /version:0.1 /dll /pdb:none /map:"$(INTDIR)\piAgent.map" /machine:I386 /out:"$(OUTDIR)\piAgent.dll" /implib:"$(OUTDIR)\piAgent.lib" /libpath:"..\..\..\framework\WinBuild\bin" 
88
LINK32_OBJS= \
89
	"$(INTDIR)\agentDebug.obj" \
90
	"$(INTDIR)\filters.obj" \
91
	"$(INTDIR)\hash.obj" \
92
	"$(INTDIR)\JvmpiWriter.obj" \
93
	"$(INTDIR)\options.obj" \
94
	"$(INTDIR)\performance.obj" \
95
	"$(INTDIR)\print.obj" \
96
	"$(INTDIR)\segmentedValue.obj" \
97
	"$(INTDIR)\stack.obj" \
98
	"$(INTDIR)\StatelessHeapSnapshotManager_C.obj" \
99
	"$(INTDIR)\utility.obj" \
100
	"$(INTDIR)\piagent.res" \
101
	"$(OUTDIR)\heapsnapshots.lib"
102
103
"$(OUTDIR)\piAgent.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
104
    $(LINK32) @<<
105
  $(LINK32_FLAGS) $(LINK32_OBJS)
106
<<
107
108
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
109
110
OUTDIR=.\bin
111
INTDIR=.\Debug
112
# Begin Custom Macros
113
OutDir=.\bin
114
# End Custom Macros
115
116
!IF "$(RECURSE)" == "0" 
117
118
ALL : "$(OUTDIR)\piAgent.dll" "$(OUTDIR)\java_profiler.bsc"
119
120
!ELSE 
121
122
ALL : "heapsnapshots - Win32 Debug" "$(OUTDIR)\piAgent.dll" "$(OUTDIR)\java_profiler.bsc"
123
124
!ENDIF 
125
126
!IF "$(RECURSE)" == "1" 
127
CLEAN :"heapsnapshots - Win32 DebugCLEAN" 
128
!ELSE 
129
CLEAN :
130
!ENDIF 
131
	-@erase "$(INTDIR)\agentDebug.obj"
132
	-@erase "$(INTDIR)\agentDebug.sbr"
133
	-@erase "$(INTDIR)\filters.obj"
134
	-@erase "$(INTDIR)\filters.sbr"
135
	-@erase "$(INTDIR)\hash.obj"
136
	-@erase "$(INTDIR)\hash.sbr"
137
	-@erase "$(INTDIR)\JvmpiWriter.obj"
138
	-@erase "$(INTDIR)\JvmpiWriter.sbr"
139
	-@erase "$(INTDIR)\options.obj"
140
	-@erase "$(INTDIR)\options.sbr"
141
	-@erase "$(INTDIR)\performance.obj"
142
	-@erase "$(INTDIR)\performance.sbr"
143
	-@erase "$(INTDIR)\piagent.res"
144
	-@erase "$(INTDIR)\print.obj"
145
	-@erase "$(INTDIR)\print.sbr"
146
	-@erase "$(INTDIR)\segmentedValue.obj"
147
	-@erase "$(INTDIR)\segmentedValue.sbr"
148
	-@erase "$(INTDIR)\stack.obj"
149
	-@erase "$(INTDIR)\stack.sbr"
150
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager_C.obj"
151
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager_C.sbr"
152
	-@erase "$(INTDIR)\utility.obj"
153
	-@erase "$(INTDIR)\utility.sbr"
154
	-@erase "$(INTDIR)\vc60.idb"
155
	-@erase "$(INTDIR)\vc60.pdb"
156
	-@erase "$(OUTDIR)\java_profiler.bsc"
157
	-@erase "$(OUTDIR)\piAgent.dll"
158
	-@erase "$(OUTDIR)\piAgent.exp"
159
	-@erase "$(OUTDIR)\piAgent.ilk"
160
	-@erase "$(OUTDIR)\piAgent.lib"
161
	-@erase "$(OUTDIR)\piAgent.pdb"
162
163
"$(OUTDIR)" :
164
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
165
166
"$(INTDIR)" :
167
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
168
169
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\framework\RABindings" /I "..\..\..\framework\RACommon" /I "..\..\..\framework\RADataTransfer" /I "..\..\..\framework\RASharedMemory" /I "..\..\..\framework\RASocket" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JAVA_PROFILER_EXPORTS" /D "_INTEL" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\java_profiler.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
170
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
171
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\piagent.res" /d "_DEBUG" 
172
BSC32=bscmake.exe
173
BSC32_FLAGS=/nologo /o"$(OUTDIR)\java_profiler.bsc" 
174
BSC32_SBRS= \
175
	"$(INTDIR)\agentDebug.sbr" \
176
	"$(INTDIR)\filters.sbr" \
177
	"$(INTDIR)\hash.sbr" \
178
	"$(INTDIR)\JvmpiWriter.sbr" \
179
	"$(INTDIR)\options.sbr" \
180
	"$(INTDIR)\performance.sbr" \
181
	"$(INTDIR)\print.sbr" \
182
	"$(INTDIR)\segmentedValue.sbr" \
183
	"$(INTDIR)\stack.sbr" \
184
	"$(INTDIR)\StatelessHeapSnapshotManager_C.sbr" \
185
	"$(INTDIR)\utility.sbr"
186
187
"$(OUTDIR)\java_profiler.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
188
    $(BSC32) @<<
189
  $(BSC32_FLAGS) $(BSC32_SBRS)
190
<<
191
192
LINK32=link.exe
193
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib rpcrt4.lib ws2_32.lib hcclco.lib hccldt.lib hccls.lib hcbnd.lib hcclsm.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\piAgent.pdb" /debug /machine:I386 /out:"$(OUTDIR)\piAgent.dll" /implib:"$(OUTDIR)\piAgent.lib" /pdbtype:sept /libpath:"..\..\..\framework\WinBuild\bin" 
194
LINK32_OBJS= \
195
	"$(INTDIR)\agentDebug.obj" \
196
	"$(INTDIR)\filters.obj" \
197
	"$(INTDIR)\hash.obj" \
198
	"$(INTDIR)\JvmpiWriter.obj" \
199
	"$(INTDIR)\options.obj" \
200
	"$(INTDIR)\performance.obj" \
201
	"$(INTDIR)\print.obj" \
202
	"$(INTDIR)\segmentedValue.obj" \
203
	"$(INTDIR)\stack.obj" \
204
	"$(INTDIR)\StatelessHeapSnapshotManager_C.obj" \
205
	"$(INTDIR)\utility.obj" \
206
	"$(INTDIR)\piagent.res" \
207
	"$(OUTDIR)\heapsnapshots.lib"
208
209
"$(OUTDIR)\piAgent.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
210
    $(LINK32) @<<
211
  $(LINK32_FLAGS) $(LINK32_OBJS)
212
<<
213
214
!ENDIF 
215
216
.c{$(INTDIR)}.obj::
217
   $(CPP) @<<
218
   $(CPP_PROJ) $< 
219
<<
220
221
.cpp{$(INTDIR)}.obj::
222
   $(CPP) @<<
223
   $(CPP_PROJ) $< 
224
<<
225
226
.cxx{$(INTDIR)}.obj::
227
   $(CPP) @<<
228
   $(CPP_PROJ) $< 
229
<<
230
231
.c{$(INTDIR)}.sbr::
232
   $(CPP) @<<
233
   $(CPP_PROJ) $< 
234
<<
235
236
.cpp{$(INTDIR)}.sbr::
237
   $(CPP) @<<
238
   $(CPP_PROJ) $< 
239
<<
240
241
.cxx{$(INTDIR)}.sbr::
242
   $(CPP) @<<
243
   $(CPP_PROJ) $< 
244
<<
245
246
247
!IF "$(NO_EXTERNAL_DEPS)" != "1"
248
!IF EXISTS("java_profiler.dep")
249
!INCLUDE "java_profiler.dep"
250
!ELSE 
251
!MESSAGE Warning: cannot find "java_profiler.dep"
252
!ENDIF 
253
!ENDIF 
254
255
256
!IF "$(CFG)" == "java_profiler - Win32 Release" || "$(CFG)" == "java_profiler - Win32 Debug"
257
SOURCE=..\java_profiler\agentDebug.c
258
259
!IF  "$(CFG)" == "java_profiler - Win32 Release"
260
261
262
"$(INTDIR)\agentDebug.obj" : $(SOURCE) "$(INTDIR)"
263
	$(CPP) $(CPP_PROJ) $(SOURCE)
264
265
266
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
267
268
269
"$(INTDIR)\agentDebug.obj"	"$(INTDIR)\agentDebug.sbr" : $(SOURCE) "$(INTDIR)"
270
	$(CPP) $(CPP_PROJ) $(SOURCE)
271
272
273
!ENDIF 
274
275
SOURCE=..\java_profiler\filters.c
276
277
!IF  "$(CFG)" == "java_profiler - Win32 Release"
278
279
280
"$(INTDIR)\filters.obj" : $(SOURCE) "$(INTDIR)"
281
	$(CPP) $(CPP_PROJ) $(SOURCE)
282
283
284
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
285
286
287
"$(INTDIR)\filters.obj"	"$(INTDIR)\filters.sbr" : $(SOURCE) "$(INTDIR)"
288
	$(CPP) $(CPP_PROJ) $(SOURCE)
289
290
291
!ENDIF 
292
293
SOURCE=..\java_profiler\hash.c
294
295
!IF  "$(CFG)" == "java_profiler - Win32 Release"
296
297
298
"$(INTDIR)\hash.obj" : $(SOURCE) "$(INTDIR)"
299
	$(CPP) $(CPP_PROJ) $(SOURCE)
300
301
302
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
303
304
305
"$(INTDIR)\hash.obj"	"$(INTDIR)\hash.sbr" : $(SOURCE) "$(INTDIR)"
306
	$(CPP) $(CPP_PROJ) $(SOURCE)
307
308
309
!ENDIF 
310
311
SOURCE=..\java_profiler\JvmpiWriter.c
312
313
!IF  "$(CFG)" == "java_profiler - Win32 Release"
314
315
316
"$(INTDIR)\JvmpiWriter.obj" : $(SOURCE) "$(INTDIR)"
317
	$(CPP) $(CPP_PROJ) $(SOURCE)
318
319
320
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
321
322
323
"$(INTDIR)\JvmpiWriter.obj"	"$(INTDIR)\JvmpiWriter.sbr" : $(SOURCE) "$(INTDIR)"
324
	$(CPP) $(CPP_PROJ) $(SOURCE)
325
326
327
!ENDIF 
328
329
SOURCE=..\java_profiler\options.c
330
331
!IF  "$(CFG)" == "java_profiler - Win32 Release"
332
333
334
"$(INTDIR)\options.obj" : $(SOURCE) "$(INTDIR)"
335
	$(CPP) $(CPP_PROJ) $(SOURCE)
336
337
338
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
339
340
341
"$(INTDIR)\options.obj"	"$(INTDIR)\options.sbr" : $(SOURCE) "$(INTDIR)"
342
	$(CPP) $(CPP_PROJ) $(SOURCE)
343
344
345
!ENDIF 
346
347
SOURCE=..\java_profiler\performance.c
348
349
!IF  "$(CFG)" == "java_profiler - Win32 Release"
350
351
352
"$(INTDIR)\performance.obj" : $(SOURCE) "$(INTDIR)"
353
	$(CPP) $(CPP_PROJ) $(SOURCE)
354
355
356
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
357
358
359
"$(INTDIR)\performance.obj"	"$(INTDIR)\performance.sbr" : $(SOURCE) "$(INTDIR)"
360
	$(CPP) $(CPP_PROJ) $(SOURCE)
361
362
363
!ENDIF 
364
365
SOURCE=..\java_profiler\print.c
366
367
!IF  "$(CFG)" == "java_profiler - Win32 Release"
368
369
370
"$(INTDIR)\print.obj" : $(SOURCE) "$(INTDIR)"
371
	$(CPP) $(CPP_PROJ) $(SOURCE)
372
373
374
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
375
376
377
"$(INTDIR)\print.obj"	"$(INTDIR)\print.sbr" : $(SOURCE) "$(INTDIR)"
378
	$(CPP) $(CPP_PROJ) $(SOURCE)
379
380
381
!ENDIF 
382
383
SOURCE=..\java_profiler\segmentedValue.c
384
385
!IF  "$(CFG)" == "java_profiler - Win32 Release"
386
387
388
"$(INTDIR)\segmentedValue.obj" : $(SOURCE) "$(INTDIR)"
389
	$(CPP) $(CPP_PROJ) $(SOURCE)
390
391
392
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
393
394
395
"$(INTDIR)\segmentedValue.obj"	"$(INTDIR)\segmentedValue.sbr" : $(SOURCE) "$(INTDIR)"
396
	$(CPP) $(CPP_PROJ) $(SOURCE)
397
398
399
!ENDIF 
400
401
SOURCE=..\java_profiler\stack.c
402
403
!IF  "$(CFG)" == "java_profiler - Win32 Release"
404
405
406
"$(INTDIR)\stack.obj" : $(SOURCE) "$(INTDIR)"
407
	$(CPP) $(CPP_PROJ) $(SOURCE)
408
409
410
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
411
412
413
"$(INTDIR)\stack.obj"	"$(INTDIR)\stack.sbr" : $(SOURCE) "$(INTDIR)"
414
	$(CPP) $(CPP_PROJ) $(SOURCE)
415
416
417
!ENDIF 
418
419
SOURCE=..\java_profiler\StatelessHeapSnapshotManager_C.cpp
420
421
!IF  "$(CFG)" == "java_profiler - Win32 Release"
422
423
424
"$(INTDIR)\StatelessHeapSnapshotManager_C.obj" : $(SOURCE) "$(INTDIR)"
425
	$(CPP) $(CPP_PROJ) $(SOURCE)
426
427
428
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
429
430
431
"$(INTDIR)\StatelessHeapSnapshotManager_C.obj"	"$(INTDIR)\StatelessHeapSnapshotManager_C.sbr" : $(SOURCE) "$(INTDIR)"
432
	$(CPP) $(CPP_PROJ) $(SOURCE)
433
434
435
!ENDIF 
436
437
SOURCE=..\java_profiler\utility.c
438
439
!IF  "$(CFG)" == "java_profiler - Win32 Release"
440
441
442
"$(INTDIR)\utility.obj" : $(SOURCE) "$(INTDIR)"
443
	$(CPP) $(CPP_PROJ) $(SOURCE)
444
445
446
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
447
448
449
"$(INTDIR)\utility.obj"	"$(INTDIR)\utility.sbr" : $(SOURCE) "$(INTDIR)"
450
	$(CPP) $(CPP_PROJ) $(SOURCE)
451
452
453
!ENDIF 
454
455
SOURCE=..\java_profiler\version.rc
456
457
!IF  "$(CFG)" == "java_profiler - Win32 Release"
458
459
460
"$(INTDIR)\piagent.res" : $(SOURCE) "$(INTDIR)"
461
	$(RSC) /l 0x409 /fo"$(INTDIR)\piagent.res" /i "\eclipse\workspace\org.eclipse.hyades.datacollection\collection\collectors\native\java_profiler" /d "NDEBUG" $(SOURCE)
462
463
464
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
465
466
467
"$(INTDIR)\piagent.res" : $(SOURCE) "$(INTDIR)"
468
	$(RSC) /l 0x409 /fo"$(INTDIR)\piagent.res" /i "\eclipse\workspace\org.eclipse.hyades.datacollection\collection\collectors\native\java_profiler" /d "_DEBUG" $(SOURCE)
469
470
471
!ENDIF 
472
473
!IF  "$(CFG)" == "java_profiler - Win32 Release"
474
475
"heapsnapshots - Win32 Release" : 
476
   cd "."
477
   $(MAKE) /$(MAKEFLAGS) /F .\heapsnapshots.mak CFG="heapsnapshots - Win32 Release" 
478
   cd "."
479
480
"heapsnapshots - Win32 ReleaseCLEAN" : 
481
   cd "."
482
   $(MAKE) /$(MAKEFLAGS) /F .\heapsnapshots.mak CFG="heapsnapshots - Win32 Release" RECURSE=1 CLEAN 
483
   cd "."
484
485
!ELSEIF  "$(CFG)" == "java_profiler - Win32 Debug"
486
487
"heapsnapshots - Win32 Debug" : 
488
   cd "."
489
   $(MAKE) /$(MAKEFLAGS) /F .\heapsnapshots.mak CFG="heapsnapshots - Win32 Debug" 
490
   cd "."
491
492
"heapsnapshots - Win32 DebugCLEAN" : 
493
   cd "."
494
   $(MAKE) /$(MAKEFLAGS) /F .\heapsnapshots.mak CFG="heapsnapshots - Win32 Debug" RECURSE=1 CLEAN 
495
   cd "."
496
497
!ENDIF 
498
499
500
!ENDIF 
501
(-)src-native-new/src/agents/perfmon/WinBuild/resutils.mak64 (+394 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on resutils.dsp
2
!IF "$(CFG)" == ""
3
CFG=resutils - IA64 Release
4
!MESSAGE No configuration specified. Defaulting to resutils - IA64 Release.
5
!ENDIF 
6
7
!IF "$(CFG)" != "resutils - IA64 Release" && "$(CFG)" != "resutils - IA64 Debug" && "$(CFG)" != "resutils - X64 Release" && "$(CFG)" != "resutils - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "resutils.mak64" CFG="resutils - IA64 Release"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "resutils - IA64 Release"
17
!MESSAGE "resutils - IA64 Debug"
18
!MESSAGE "resutils - X64 Release"
19
!MESSAGE "resutils - X64 Debug"
20
!MESSAGE 
21
!ERROR An invalid configuration is specified.
22
!ENDIF 
23
24
!IF "$(OS)" == "Windows_NT"
25
NULL=
26
!ELSE 
27
NULL=nul
28
!ENDIF 
29
30
!IF  "$(CFG)" == "resutils - IA64 Release"
31
32
OUTDIR=..\..\..\..\lib
33
INTDIR=.\Release
34
# Begin Custom Macros
35
OutDir=..\..\..\..\lib
36
# End Custom Macros
37
38
ALL : "$(OUTDIR)\resutils.lib"
39
40
41
CLEAN :
42
	-@erase "$(INTDIR)\clock.obj"
43
	-@erase "$(INTDIR)\hashtable.obj"
44
	-@erase "$(INTDIR)\library.obj"
45
	-@erase "$(INTDIR)\mutex.obj"
46
	-@erase "$(INTDIR)\random.obj"
47
	-@erase "$(INTDIR)\streq.obj"
48
	-@erase "$(INTDIR)\thread.obj"
49
	-@erase "$(INTDIR)\vc60.idb"
50
	-@erase "$(OUTDIR)\resutils.lib"
51
52
"$(OUTDIR)" :
53
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
54
55
"$(INTDIR)" :
56
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
57
58
CPP=cl.exe
59
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"$(INTDIR)\resutils.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
60
61
.c{$(INTDIR)}.obj::
62
   $(CPP) @<<
63
   $(CPP_PROJ) $< 
64
<<
65
66
.cpp{$(INTDIR)}.obj::
67
   $(CPP) @<<
68
   $(CPP_PROJ) $< 
69
<<
70
71
.cxx{$(INTDIR)}.obj::
72
   $(CPP) @<<
73
   $(CPP_PROJ) $< 
74
<<
75
76
.c{$(INTDIR)}.sbr::
77
   $(CPP) @<<
78
   $(CPP_PROJ) $< 
79
<<
80
81
.cpp{$(INTDIR)}.sbr::
82
   $(CPP) @<<
83
   $(CPP_PROJ) $< 
84
<<
85
86
.cxx{$(INTDIR)}.sbr::
87
   $(CPP) @<<
88
   $(CPP_PROJ) $< 
89
<<
90
91
RSC=rc.exe
92
93
LIB32=link.exe -lib
94
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\resutils.lib" 
95
LIB32_OBJS= \
96
	"$(INTDIR)\clock.obj" \
97
	"$(INTDIR)\hashtable.obj" \
98
	"$(INTDIR)\library.obj" \
99
	"$(INTDIR)\mutex.obj" \
100
	"$(INTDIR)\random.obj" \
101
	"$(INTDIR)\streq.obj" \
102
	"$(INTDIR)\thread.obj"
103
104
"$(OUTDIR)\resutils.lib" : "$(OUTDIR)" $(LIB32_OBJS)
105
    $(LIB32) @<<
106
  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
107
<<
108
109
!ELSEIF  "$(CFG)" == "resutils - IA64 Debug"
110
111
OUTDIR=..\..\..\..\lib
112
INTDIR=.\Debug
113
# Begin Custom Macros
114
OutDir=..\..\..\..\lib
115
# End Custom Macros
116
117
ALL : "$(OUTDIR)\resutils.lib"
118
119
120
CLEAN :
121
	-@erase "$(INTDIR)\clock.obj"
122
	-@erase "$(INTDIR)\hashtable.obj"
123
	-@erase "$(INTDIR)\library.obj"
124
	-@erase "$(INTDIR)\mutex.obj"
125
	-@erase "$(INTDIR)\random.obj"
126
	-@erase "$(INTDIR)\streq.obj"
127
	-@erase "$(INTDIR)\thread.obj"
128
	-@erase "$(INTDIR)\vc60.idb"
129
	-@erase "$(OUTDIR)\resutils.lib"
130
131
"$(OUTDIR)" :
132
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
133
134
"$(INTDIR)" :
135
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
136
137
CPP=cl.exe
138
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"$(INTDIR)\resutils.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
139
140
.c{$(INTDIR)}.obj::
141
   $(CPP) @<<
142
   $(CPP_PROJ) $< 
143
<<
144
145
.cpp{$(INTDIR)}.obj::
146
   $(CPP) @<<
147
   $(CPP_PROJ) $< 
148
<<
149
150
.cxx{$(INTDIR)}.obj::
151
   $(CPP) @<<
152
   $(CPP_PROJ) $< 
153
<<
154
155
.c{$(INTDIR)}.sbr::
156
   $(CPP) @<<
157
   $(CPP_PROJ) $< 
158
<<
159
160
.cpp{$(INTDIR)}.sbr::
161
   $(CPP) @<<
162
   $(CPP_PROJ) $< 
163
<<
164
165
.cxx{$(INTDIR)}.sbr::
166
   $(CPP) @<<
167
   $(CPP_PROJ) $< 
168
<<
169
170
RSC=rc.exe
171
172
LIB32=link.exe -lib
173
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\resutils.lib" 
174
LIB32_OBJS= \
175
	"$(INTDIR)\clock.obj" \
176
	"$(INTDIR)\hashtable.obj" \
177
	"$(INTDIR)\library.obj" \
178
	"$(INTDIR)\mutex.obj" \
179
	"$(INTDIR)\random.obj" \
180
	"$(INTDIR)\streq.obj" \
181
	"$(INTDIR)\thread.obj"
182
183
"$(OUTDIR)\resutils.lib" : "$(OUTDIR)" $(LIB32_OBJS)
184
    $(LIB32) @<<
185
  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
186
<<
187
188
!ELSEIF  "$(CFG)" == "resutils - X64 Release"
189
190
OUTDIR=..\..\..\..\lib
191
INTDIR=.\Release
192
# Begin Custom Macros
193
OutDir=..\..\..\..\lib
194
# End Custom Macros
195
196
ALL : "$(OUTDIR)\resutils.lib"
197
198
199
CLEAN :
200
	-@erase "$(INTDIR)\clock.obj"
201
	-@erase "$(INTDIR)\hashtable.obj"
202
	-@erase "$(INTDIR)\library.obj"
203
	-@erase "$(INTDIR)\mutex.obj"
204
	-@erase "$(INTDIR)\random.obj"
205
	-@erase "$(INTDIR)\streq.obj"
206
	-@erase "$(INTDIR)\thread.obj"
207
	-@erase "$(INTDIR)\vc60.idb"
208
	-@erase "$(OUTDIR)\resutils.lib"
209
210
"$(OUTDIR)" :
211
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
212
213
"$(INTDIR)" :
214
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
215
216
CPP=cl.exe
217
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"$(INTDIR)\resutils.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
218
219
.c{$(INTDIR)}.obj::
220
   $(CPP) @<<
221
   $(CPP_PROJ) $< 
222
<<
223
224
.cpp{$(INTDIR)}.obj::
225
   $(CPP) @<<
226
   $(CPP_PROJ) $< 
227
<<
228
229
.cxx{$(INTDIR)}.obj::
230
   $(CPP) @<<
231
   $(CPP_PROJ) $< 
232
<<
233
234
.c{$(INTDIR)}.sbr::
235
   $(CPP) @<<
236
   $(CPP_PROJ) $< 
237
<<
238
239
.cpp{$(INTDIR)}.sbr::
240
   $(CPP) @<<
241
   $(CPP_PROJ) $< 
242
<<
243
244
.cxx{$(INTDIR)}.sbr::
245
   $(CPP) @<<
246
   $(CPP_PROJ) $< 
247
<<
248
249
RSC=rc.exe
250
251
LIB32=link.exe -lib
252
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\resutils.lib" 
253
LIB32_OBJS= \
254
	"$(INTDIR)\clock.obj" \
255
	"$(INTDIR)\hashtable.obj" \
256
	"$(INTDIR)\library.obj" \
257
	"$(INTDIR)\mutex.obj" \
258
	"$(INTDIR)\random.obj" \
259
	"$(INTDIR)\streq.obj" \
260
	"$(INTDIR)\thread.obj"
261
262
"$(OUTDIR)\resutils.lib" : "$(OUTDIR)" $(LIB32_OBJS)
263
    $(LIB32) @<<
264
  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
265
<<
266
267
!ELSEIF  "$(CFG)" == "resutils - X64 Debug"
268
269
OUTDIR=..\..\..\..\lib
270
INTDIR=.\Debug
271
# Begin Custom Macros
272
OutDir=..\..\..\..\lib
273
# End Custom Macros
274
275
ALL : "$(OUTDIR)\resutils.lib"
276
277
278
CLEAN :
279
	-@erase "$(INTDIR)\clock.obj"
280
	-@erase "$(INTDIR)\hashtable.obj"
281
	-@erase "$(INTDIR)\library.obj"
282
	-@erase "$(INTDIR)\mutex.obj"
283
	-@erase "$(INTDIR)\random.obj"
284
	-@erase "$(INTDIR)\streq.obj"
285
	-@erase "$(INTDIR)\thread.obj"
286
	-@erase "$(INTDIR)\vc60.idb"
287
	-@erase "$(OUTDIR)\resutils.lib"
288
289
"$(OUTDIR)" :
290
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
291
292
"$(INTDIR)" :
293
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
294
295
CPP=cl.exe
296
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"$(INTDIR)\resutils.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
297
298
.c{$(INTDIR)}.obj::
299
   $(CPP) @<<
300
   $(CPP_PROJ) $< 
301
<<
302
303
.cpp{$(INTDIR)}.obj::
304
   $(CPP) @<<
305
   $(CPP_PROJ) $< 
306
<<
307
308
.cxx{$(INTDIR)}.obj::
309
   $(CPP) @<<
310
   $(CPP_PROJ) $< 
311
<<
312
313
.c{$(INTDIR)}.sbr::
314
   $(CPP) @<<
315
   $(CPP_PROJ) $< 
316
<<
317
318
.cpp{$(INTDIR)}.sbr::
319
   $(CPP) @<<
320
   $(CPP_PROJ) $< 
321
<<
322
323
.cxx{$(INTDIR)}.sbr::
324
   $(CPP) @<<
325
   $(CPP_PROJ) $< 
326
<<
327
328
RSC=rc.exe
329
330
LIB32=link.exe -lib
331
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\resutils.lib" 
332
LIB32_OBJS= \
333
	"$(INTDIR)\clock.obj" \
334
	"$(INTDIR)\hashtable.obj" \
335
	"$(INTDIR)\library.obj" \
336
	"$(INTDIR)\mutex.obj" \
337
	"$(INTDIR)\random.obj" \
338
	"$(INTDIR)\streq.obj" \
339
	"$(INTDIR)\thread.obj"
340
341
"$(OUTDIR)\resutils.lib" : "$(OUTDIR)" $(LIB32_OBJS)
342
    $(LIB32) @<<
343
  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
344
<<
345
346
!ENDIF 
347
348
349
!IF "$(CFG)" == "resutils - IA64 Release" || "$(CFG)" == "resutils - IA64 Debug" || "$(CFG)" == "resutils - X64 Release" || "$(CFG)" == "resutils - X64 Debug"
350
SOURCE=..\resutils\clock.c
351
352
"$(INTDIR)\clock.obj" : $(SOURCE) "$(INTDIR)"
353
	$(CPP) $(CPP_PROJ) $(SOURCE)
354
355
356
SOURCE=..\resutils\hashtable.c
357
358
"$(INTDIR)\hashtable.obj" : $(SOURCE) "$(INTDIR)"
359
	$(CPP) $(CPP_PROJ) $(SOURCE)
360
361
362
SOURCE=..\resutils\library.c
363
364
"$(INTDIR)\library.obj" : $(SOURCE) "$(INTDIR)"
365
	$(CPP) $(CPP_PROJ) $(SOURCE)
366
367
368
SOURCE=..\resutils\mutex.c
369
370
"$(INTDIR)\mutex.obj" : $(SOURCE) "$(INTDIR)"
371
	$(CPP) $(CPP_PROJ) $(SOURCE)
372
373
374
SOURCE=..\resutils\random.c
375
376
"$(INTDIR)\random.obj" : $(SOURCE) "$(INTDIR)"
377
	$(CPP) $(CPP_PROJ) $(SOURCE)
378
379
380
SOURCE=..\resutils\streq.c
381
382
"$(INTDIR)\streq.obj" : $(SOURCE) "$(INTDIR)"
383
	$(CPP) $(CPP_PROJ) $(SOURCE)
384
385
386
SOURCE=..\resutils\thread.c
387
388
"$(INTDIR)\thread.obj" : $(SOURCE) "$(INTDIR)"
389
	$(CPP) $(CPP_PROJ) $(SOURCE)
390
391
392
393
!ENDIF 
394
(-)src-native-new/src/transport/RADataTransfer/RADataTransfer.mak64 (+582 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on RADataTransfer.dsp
2
!IF "$(CFG)" == ""
3
CFG=RADataTransfer - IA64 Debug
4
!MESSAGE No configuration specified. Defaulting to RADataTransfer - IA64 Debug.
5
!ENDIF 
6
7
!IF "$(CFG)" != "RADataTransfer - IA64 Release" && "$(CFG)" != "RADataTransfer - IA64 Debug" && "$(CFG)" != "RADataTransfer - X64 Release" && "$(CFG)" != "RADataTransfer - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "RADataTransfer.mak64" CFG="RADataTransfer - IA64 Debug"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "RADataTransfer - IA64 Release"
17
!MESSAGE "RADataTransfer - IA64 Debug"
18
!MESSAGE "RADataTransfer - X64 Release"
19
!MESSAGE "RADataTransfer - X64 Debug"
20
!MESSAGE 
21
!ERROR An invalid configuration is specified.
22
!ENDIF 
23
24
!IF "$(OS)" == "Windows_NT"
25
NULL=
26
!ELSE 
27
NULL=nul
28
!ENDIF 
29
30
!IF  "$(CFG)" == "RADataTransfer - IA64 Release"
31
32
OUTDIR=..\..\..\bin
33
INTDIR=.\Release
34
# Begin Custom Macros
35
OutDir=..\..\..\bin
36
# End Custom Macros
37
38
!IF "$(RECURSE)" == "0" 
39
40
ALL : "$(OUTDIR)\hccldt.dll"
41
42
!ELSE 
43
44
ALL : "RASocket - IA64 Release" "RASharedMemory - IA64 Release" "RACommon - IA64 Release" "$(OUTDIR)\hccldt.dll"
45
46
!ENDIF 
47
48
!IF "$(RECURSE)" == "1" 
49
CLEAN :"RACommon - IA64 ReleaseCLEAN" "RASharedMemory - IA64 ReleaseCLEAN" "RASocket - IA64 ReleaseCLEAN" 
50
!ELSE 
51
CLEAN :
52
!ENDIF 
53
	-@erase "$(INTDIR)\hccldt.res"
54
	-@erase "$(INTDIR)\RADataTransfer.obj"
55
	-@erase "$(INTDIR)\vc60.idb"
56
	-@erase "$(OUTDIR)\hccldt.dll"
57
	-@erase "$(OUTDIR)\..\lib\hccldt.exp"
58
	-@erase "$(OUTDIR)\..\lib\hccldt.lib"
59
60
"$(OUTDIR)" :
61
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
62
63
"$(INTDIR)" :
64
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
65
66
CPP=cl.exe
67
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /Ob0 /I "..\RACommon" /I "..\RASharedMemory" /I "..\RASocket" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RADATATRANSFER_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\RADataTransfer.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
68
69
.c{$(INTDIR)}.obj::
70
   $(CPP) @<<
71
   $(CPP_PROJ) $< 
72
<<
73
74
.cpp{$(INTDIR)}.obj::
75
   $(CPP) @<<
76
   $(CPP_PROJ) $< 
77
<<
78
79
.cxx{$(INTDIR)}.obj::
80
   $(CPP) @<<
81
   $(CPP_PROJ) $< 
82
<<
83
84
.c{$(INTDIR)}.sbr::
85
   $(CPP) @<<
86
   $(CPP_PROJ) $< 
87
<<
88
89
.cpp{$(INTDIR)}.sbr::
90
   $(CPP) @<<
91
   $(CPP_PROJ) $< 
92
<<
93
94
.cxx{$(INTDIR)}.sbr::
95
   $(CPP) @<<
96
   $(CPP_PROJ) $< 
97
<<
98
99
MTL=midl.exe
100
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
101
RSC=rc.exe
102
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hccldt.res" /d "NDEBUG" 
103
104
LINK32=link.exe
105
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib /nologo /version:0.1 /dll /pdb:none /def:"..\RADataTransfer\RADataTransfer.def" /out:"$(OUTDIR)\hccldt.dll" /implib:"$(OUTDIR)\..\lib\hccldt.lib" /libpath:".\bin" /machine:IA64
106
LINK32_OBJS= \
107
	"$(INTDIR)\RADataTransfer.obj" \
108
	"$(INTDIR)\hccldt.res" \
109
	"$(OUTDIR)\..\lib\hcclco.lib" \
110
	"$(OUTDIR)\..\lib\hcclsm.lib" \
111
	"$(OUTDIR)\..\lib\hccls.lib"
112
113
"$(OUTDIR)\hccldt.dll" : "$(OUTDIR)" $(LINK32_OBJS)
114
    $(LINK32) @<<
115
  $(LINK32_FLAGS) $(LINK32_OBJS)
116
<<
117
118
!ELSEIF  "$(CFG)" == "RADataTransfer - IA64 Debug"
119
120
OUTDIR=..\..\..\bin
121
INTDIR=.\Debug
122
# Begin Custom Macros
123
OutDir=..\..\..\bin
124
# End Custom Macros
125
126
!IF "$(RECURSE)" == "0" 
127
128
ALL : "$(OUTDIR)\hccldt.dll"
129
130
!ELSE 
131
132
ALL : "RASocket - IA64 Debug" "RASharedMemory - IA64 Debug" "RACommon - IA64 Debug" "$(OUTDIR)\hccldt.dll"
133
134
!ENDIF 
135
136
!IF "$(RECURSE)" == "1" 
137
CLEAN :"RACommon - IA64 DebugCLEAN" "RASharedMemory - IA64 DebugCLEAN" "RASocket - IA64 DebugCLEAN" 
138
!ELSE 
139
CLEAN :
140
!ENDIF 
141
	-@erase "$(INTDIR)\hccldt.res"
142
	-@erase "$(INTDIR)\RADataTransfer.obj"
143
	-@erase "$(INTDIR)\vc60.idb"
144
	-@erase "$(INTDIR)\vc60.pdb"
145
	-@erase "$(OUTDIR)\hccldt.dll"
146
	-@erase "$(OUTDIR)\..\lib\hccldt.exp"
147
	-@erase "$(OUTDIR)\..\lib\hccldt.ilk"
148
	-@erase "$(OUTDIR)\..\lib\hccldt.lib"
149
	-@erase "$(OUTDIR)\..\lib\hccldt.pdb"
150
151
"$(OUTDIR)" :
152
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
153
154
"$(INTDIR)" :
155
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
156
157
CPP=cl.exe
158
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\RACommon" /I "..\RASharedMemory" /I "..\RASocket" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RADATATRANSFER_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\RADataTransfer.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
159
160
.c{$(INTDIR)}.obj::
161
   $(CPP) @<<
162
   $(CPP_PROJ) $< 
163
<<
164
165
.cpp{$(INTDIR)}.obj::
166
   $(CPP) @<<
167
   $(CPP_PROJ) $< 
168
<<
169
170
.cxx{$(INTDIR)}.obj::
171
   $(CPP) @<<
172
   $(CPP_PROJ) $< 
173
<<
174
175
.c{$(INTDIR)}.sbr::
176
   $(CPP) @<<
177
   $(CPP_PROJ) $< 
178
<<
179
180
.cpp{$(INTDIR)}.sbr::
181
   $(CPP) @<<
182
   $(CPP_PROJ) $< 
183
<<
184
185
.cxx{$(INTDIR)}.sbr::
186
   $(CPP) @<<
187
   $(CPP_PROJ) $< 
188
<<
189
190
MTL=midl.exe
191
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
192
RSC=rc.exe
193
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hccldt.res" /d "_DEBUG" 
194
195
LINK32=link.exe
196
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hccldt.pdb" /debug /def:"..\RADataTransfer\RADataTransfer.def" /out:"$(OUTDIR)\hccldt.dll" /implib:"$(OUTDIR)\..\lib\hccldt.lib" /libpath:".\bin" /machine:IA64
197
LINK32_OBJS= \
198
	"$(INTDIR)\RADataTransfer.obj" \
199
	"$(INTDIR)\hccldt.res" \
200
	"$(OUTDIR)\..\lib\hcclco.lib" \
201
	"$(OUTDIR)\..\lib\hcclsm.lib" \
202
	"$(OUTDIR)\..\lib\hccls.lib"
203
204
"$(OUTDIR)\hccldt.dll" : "$(OUTDIR)" $(LINK32_OBJS)
205
    $(LINK32) @<<
206
  $(LINK32_FLAGS) $(LINK32_OBJS)
207
<<
208
209
!ELSEIF  "$(CFG)" == "RADataTransfer - X64 Release"
210
211
OUTDIR=..\..\..\bin
212
INTDIR=.\Release
213
# Begin Custom Macros
214
OutDir=..\..\..\bin
215
# End Custom Macros
216
217
!IF "$(RECURSE)" == "0" 
218
219
ALL : "$(OUTDIR)\hccldt.dll"
220
221
!ELSE 
222
223
ALL : "RASocket - X64 Release" "RASharedMemory - X64 Release" "RACommon - X64 Release" "$(OUTDIR)\hccldt.dll"
224
225
!ENDIF 
226
227
!IF "$(RECURSE)" == "1" 
228
CLEAN :"RACommon - X64 ReleaseCLEAN" "RASharedMemory - X64 ReleaseCLEAN" "RASocket - X64 ReleaseCLEAN" 
229
!ELSE 
230
CLEAN :
231
!ENDIF 
232
	-@erase "$(INTDIR)\hccldt.res"
233
	-@erase "$(INTDIR)\RADataTransfer.obj"
234
	-@erase "$(INTDIR)\vc60.idb"
235
	-@erase "$(OUTDIR)\hccldt.dll"
236
	-@erase "$(OUTDIR)\..\lib\hccldt.exp"
237
	-@erase "$(OUTDIR)\..\lib\hccldt.lib"
238
239
"$(OUTDIR)" :
240
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
241
242
"$(INTDIR)" :
243
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
244
245
CPP=cl.exe
246
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /Ob0 /I "..\RACommon" /I "..\RASharedMemory" /I "..\RASocket" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RADATATRANSFER_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\RADataTransfer.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
247
248
.c{$(INTDIR)}.obj::
249
   $(CPP) @<<
250
   $(CPP_PROJ) $< 
251
<<
252
253
.cpp{$(INTDIR)}.obj::
254
   $(CPP) @<<
255
   $(CPP_PROJ) $< 
256
<<
257
258
.cxx{$(INTDIR)}.obj::
259
   $(CPP) @<<
260
   $(CPP_PROJ) $< 
261
<<
262
263
.c{$(INTDIR)}.sbr::
264
   $(CPP) @<<
265
   $(CPP_PROJ) $< 
266
<<
267
268
.cpp{$(INTDIR)}.sbr::
269
   $(CPP) @<<
270
   $(CPP_PROJ) $< 
271
<<
272
273
.cxx{$(INTDIR)}.sbr::
274
   $(CPP) @<<
275
   $(CPP_PROJ) $< 
276
<<
277
278
MTL=midl.exe
279
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
280
RSC=rc.exe
281
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hccldt.res" /d "NDEBUG" 
282
283
LINK32=link.exe
284
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib /nologo /version:0.1 /dll /pdb:none /def:"..\RADataTransfer\RADataTransfer.def" /out:"$(OUTDIR)\hccldt.dll" /implib:"$(OUTDIR)\..\lib\hccldt.lib" /libpath:".\bin" /machine:AMD64
285
LINK32_OBJS= \
286
	"$(INTDIR)\RADataTransfer.obj" \
287
	"$(INTDIR)\hccldt.res" \
288
	"$(OUTDIR)\..\lib\hcclco.lib" \
289
	"$(OUTDIR)\..\lib\hcclsm.lib" \
290
	"$(OUTDIR)\..\lib\hccls.lib"
291
292
"$(OUTDIR)\hccldt.dll" : "$(OUTDIR)" $(LINK32_OBJS)
293
    $(LINK32) @<<
294
  $(LINK32_FLAGS) $(LINK32_OBJS)
295
<<
296
297
!ELSEIF  "$(CFG)" == "RADataTransfer - X64 Debug"
298
299
OUTDIR=..\..\..\bin
300
INTDIR=.\Debug
301
# Begin Custom Macros
302
OutDir=..\..\..\bin
303
# End Custom Macros
304
305
!IF "$(RECURSE)" == "0" 
306
307
ALL : "$(OUTDIR)\hccldt.dll"
308
309
!ELSE 
310
311
ALL : "RASocket - X64 Debug" "RASharedMemory - X64 Debug" "RACommon - X64 Debug" "$(OUTDIR)\hccldt.dll"
312
313
!ENDIF 
314
315
!IF "$(RECURSE)" == "1" 
316
CLEAN :"RACommon - X64 DebugCLEAN" "RASharedMemory - X64 DebugCLEAN" "RASocket - X64 DebugCLEAN" 
317
!ELSE 
318
CLEAN :
319
!ENDIF 
320
	-@erase "$(INTDIR)\hccldt.res"
321
	-@erase "$(INTDIR)\RADataTransfer.obj"
322
	-@erase "$(INTDIR)\vc60.idb"
323
	-@erase "$(INTDIR)\vc60.pdb"
324
	-@erase "$(OUTDIR)\hccldt.dll"
325
	-@erase "$(OUTDIR)\..\lib\hccldt.exp"
326
	-@erase "$(OUTDIR)\..\lib\hccldt.ilk"
327
	-@erase "$(OUTDIR)\..\lib\hccldt.lib"
328
	-@erase "$(OUTDIR)\..\lib\hccldt.pdb"
329
330
"$(OUTDIR)" :
331
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
332
333
"$(INTDIR)" :
334
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
335
336
CPP=cl.exe
337
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\RACommon" /I "..\RASharedMemory" /I "..\RASocket" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RADATATRANSFER_EXPORTS" /D "ENW" /D "SQLWINT" /Fp"$(INTDIR)\RADataTransfer.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
338
339
.c{$(INTDIR)}.obj::
340
   $(CPP) @<<
341
   $(CPP_PROJ) $< 
342
<<
343
344
.cpp{$(INTDIR)}.obj::
345
   $(CPP) @<<
346
   $(CPP_PROJ) $< 
347
<<
348
349
.cxx{$(INTDIR)}.obj::
350
   $(CPP) @<<
351
   $(CPP_PROJ) $< 
352
<<
353
354
.c{$(INTDIR)}.sbr::
355
   $(CPP) @<<
356
   $(CPP_PROJ) $< 
357
<<
358
359
.cpp{$(INTDIR)}.sbr::
360
   $(CPP) @<<
361
   $(CPP_PROJ) $< 
362
<<
363
364
.cxx{$(INTDIR)}.sbr::
365
   $(CPP) @<<
366
   $(CPP_PROJ) $< 
367
<<
368
369
MTL=midl.exe
370
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
371
RSC=rc.exe
372
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hccldt.res" /d "_DEBUG" 
373
374
LINK32=link.exe
375
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hccldt.pdb" /debug /def:"..\RADataTransfer\RADataTransfer.def" /out:"$(OUTDIR)\hccldt.dll" /implib:"$(OUTDIR)\..\lib\hccldt.lib" /libpath:".\bin" /machine:AMD64
376
LINK32_OBJS= \
377
	"$(INTDIR)\RADataTransfer.obj" \
378
	"$(INTDIR)\hccldt.res" \
379
	"$(OUTDIR)\..\lib\hcclco.lib" \
380
	"$(OUTDIR)\..\lib\hcclsm.lib" \
381
	"$(OUTDIR)\..\lib\hccls.lib"
382
383
"$(OUTDIR)\hccldt.dll" : "$(OUTDIR)" $(LINK32_OBJS)
384
    $(LINK32) @<<
385
  $(LINK32_FLAGS) $(LINK32_OBJS)
386
<<
387
388
!ENDIF 
389
390
391
!IF "$(CFG)" == "RADataTransfer - IA64 Release" || "$(CFG)" == "RADataTransfer - IA64 Debug" || "$(CFG)" == "RADataTransfer - X64 Release" || "$(CFG)" == "RADataTransfer - X64 Debug"
392
SOURCE=..\RADataTransfer\RADataTransfer.c
393
394
"$(INTDIR)\RADataTransfer.obj" : $(SOURCE) "$(INTDIR)"
395
	$(CPP) $(CPP_PROJ) $(SOURCE)
396
397
398
SOURCE=..\RADataTransfer\version.rc
399
400
!IF  "$(CFG)" == "RADataTransfer - IA64 Release"
401
402
403
"$(INTDIR)\hccldt.res" : $(SOURCE) "$(INTDIR)"
404
	$(RSC) /l 0x409 /fo"$(INTDIR)\hccldt.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RADataTransfer" /d "NDEBUG" $(SOURCE)
405
406
407
!ELSEIF  "$(CFG)" == "RADataTransfer - IA64 Debug"
408
409
410
"$(INTDIR)\hccldt.res" : $(SOURCE) "$(INTDIR)"
411
	$(RSC) /l 0x409 /fo"$(INTDIR)\hccldt.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RADataTransfer" /d "_DEBUG" $(SOURCE)
412
413
414
!ELSEIF  "$(CFG)" == "RADataTransfer - X64 Release"
415
416
417
"$(INTDIR)\hccldt.res" : $(SOURCE) "$(INTDIR)"
418
	$(RSC) /l 0x409 /fo"$(INTDIR)\hccldt.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RADataTransfer" /d "NDEBUG" $(SOURCE)
419
420
421
!ELSEIF  "$(CFG)" == "RADataTransfer - X64 Debug"
422
423
424
"$(INTDIR)\hccldt.res" : $(SOURCE) "$(INTDIR)"
425
	$(RSC) /l 0x409 /fo"$(INTDIR)\hccldt.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RADataTransfer" /d "_DEBUG" $(SOURCE)
426
427
428
!ENDIF 
429
430
!IF  "$(CFG)" == "RADataTransfer - IA64 Release"
431
432
"RACommon - IA64 Release" : 
433
   cd "..\RACommon"
434
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Release" 
435
   cd "..\RADataTransfer"
436
437
"RACommon - IA64 ReleaseCLEAN" : 
438
   cd "..\RACommon"
439
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Release" RECURSE=1 CLEAN 
440
   cd "..\RADataTransfer"
441
442
!ELSEIF  "$(CFG)" == "RADataTransfer - IA64 Debug"
443
444
"RACommon - IA64 Debug" : 
445
   cd "..\RACommon"
446
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Debug" 
447
   cd "..\RADataTransfer"
448
449
"RACommon - IA64 DebugCLEAN" : 
450
   cd "..\RACommon"
451
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - IA64 Debug" RECURSE=1 CLEAN 
452
   cd "..\RADataTransfer"
453
454
!ELSEIF  "$(CFG)" == "RADataTransfer - X64 Release"
455
456
"RACommon - X64 Release" : 
457
   cd "..\RACommon"
458
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Release" 
459
   cd "..\RADataTransfer"
460
461
"RACommon - X64 ReleaseCLEAN" : 
462
   cd "..\RACommon"
463
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Release" RECURSE=1 CLEAN 
464
   cd "..\RADataTransfer"
465
466
!ELSEIF  "$(CFG)" == "RADataTransfer - X64 Debug"
467
468
"RACommon - X64 Debug" : 
469
   cd "..\RACommon"
470
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Debug" 
471
   cd "..\RADataTransfer"
472
473
"RACommon - X64 DebugCLEAN" : 
474
   cd "..\RACommon"
475
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak64" CFG="RACommon - X64 Debug" RECURSE=1 CLEAN 
476
   cd "..\RADataTransfer"
477
478
!ENDIF 
479
480
!IF  "$(CFG)" == "RADataTransfer - IA64 Release"
481
482
"RASharedMemory - IA64 Release" : 
483
   cd "..\RASharedMemory"
484
   $(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - IA64 Release" 
485
   cd "..\RADataTransfer"
486
487
"RASharedMemory - IA64 ReleaseCLEAN" : 
488
   cd "..\RASharedMemory"
489
   $(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - IA64 Release" RECURSE=1 CLEAN 
490
   cd "..\RADataTransfer"
491
492
!ELSEIF  "$(CFG)" == "RADataTransfer - IA64 Debug"
493
494
"RASharedMemory - IA64 Debug" : 
495
   cd "..\RASharedMemory"
496
   $(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - IA64 Debug" 
497
   cd "..\RADataTransfer"
498
499
"RASharedMemory - IA64 DebugCLEAN" : 
500
   cd "..\RASharedMemory"
501
   $(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - IA64 Debug" RECURSE=1 CLEAN 
502
   cd "..\RADataTransfer"
503
504
!ELSEIF  "$(CFG)" == "RADataTransfer - X64 Release"
505
506
"RASharedMemory - X64 Release" : 
507
   cd "..\RASharedMemory"
508
   $(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - X64 Release" 
509
   cd "..\RADataTransfer"
510
511
"RASharedMemory - X64 ReleaseCLEAN" : 
512
   cd "..\RASharedMemory"
513
   $(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - X64 Release" RECURSE=1 CLEAN 
514
   cd "..\RADataTransfer"
515
516
!ELSEIF  "$(CFG)" == "RADataTransfer - X64 Debug"
517
518
"RASharedMemory - X64 Debug" : 
519
   cd "..\RASharedMemory"
520
   $(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - X64 Debug" 
521
   cd "..\RADataTransfer"
522
523
"RASharedMemory - X64 DebugCLEAN" : 
524
   cd "..\RASharedMemory"
525
   $(MAKE) /$(MAKEFLAGS) /F ".\RASharedMemory.mak64" CFG="RASharedMemory - X64 Debug" RECURSE=1 CLEAN 
526
   cd "..\RADataTransfer"
527
528
!ENDIF 
529
530
!IF  "$(CFG)" == "RADataTransfer - IA64 Release"
531
532
"RASocket - IA64 Release" : 
533
   cd "..\RASocket"
534
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Release" 
535
   cd "..\RADataTransfer"
536
537
"RASocket - IA64 ReleaseCLEAN" : 
538
   cd "..\RASocket"
539
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Release" RECURSE=1 CLEAN 
540
   cd "..\RADataTransfer"
541
542
!ELSEIF  "$(CFG)" == "RADataTransfer - IA64 Debug"
543
544
"RASocket - IA64 Debug" : 
545
   cd "..\RASocket"
546
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Debug" 
547
   cd "..\RADataTransfer"
548
549
"RASocket - IA64 DebugCLEAN" : 
550
   cd "..\RASocket"
551
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - IA64 Debug" RECURSE=1 CLEAN 
552
   cd "..\RADataTransfer"
553
554
!ELSEIF  "$(CFG)" == "RADataTransfer - X64 Release"
555
556
"RASocket - X64 Release" : 
557
   cd "..\RASocket"
558
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - X64 Release" 
559
   cd "..\RADataTransfer"
560
561
"RASocket - X64 ReleaseCLEAN" : 
562
   cd "..\RASocket"
563
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - X64 Release" RECURSE=1 CLEAN 
564
   cd "..\RADataTransfer"
565
566
!ELSEIF  "$(CFG)" == "RADataTransfer - X64 Debug"
567
568
"RASocket - X64 Debug" : 
569
   cd "..\RASocket"
570
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - X64 Debug" 
571
   cd "..\RADataTransfer"
572
573
"RASocket - X64 DebugCLEAN" : 
574
   cd "..\RASocket"
575
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak64" CFG="RASocket - X64 Debug" RECURSE=1 CLEAN 
576
   cd "..\RADataTransfer"
577
578
!ENDIF 
579
580
581
!ENDIF 
582
(-)src-native-new/src/agents/perfmon/PerfmonAgent/version.rc (+109 lines)
Added Link Here
1
//Microsoft Developer Studio generated resource script.
2
//
3
#include "resource.h"
4
5
#define APSTUDIO_READONLY_SYMBOLS
6
/////////////////////////////////////////////////////////////////////////////
7
//
8
// Generated from the TEXTINCLUDE 2 resource.
9
//
10
#include "afxres.h"
11
12
/////////////////////////////////////////////////////////////////////////////
13
#undef APSTUDIO_READONLY_SYMBOLS
14
15
/////////////////////////////////////////////////////////////////////////////
16
// English (U.S.) resources
17
18
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
19
#ifdef _WIN32
20
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21
#pragma code_page(1252)
22
#endif //_WIN32
23
24
#ifndef _MAC
25
/////////////////////////////////////////////////////////////////////////////
26
//
27
// Version
28
//
29
30
VS_VERSION_INFO VERSIONINFO
31
 FILEVERSION 3,1,0,0
32
 PRODUCTVERSION 3,1,0,0
33
 FILEFLAGSMASK 0x3fL
34
#ifdef _DEBUG
35
 FILEFLAGS 0x1L
36
#else
37
 FILEFLAGS 0x0L
38
#endif
39
 FILEOS 0x40004L
40
 FILETYPE 0x2L
41
 FILESUBTYPE 0x0L
42
BEGIN
43
    BLOCK "StringFileInfo"
44
    BEGIN
45
        BLOCK "040904b0"
46
        BEGIN
47
            VALUE "Comments", "\0"
48
            VALUE "CompanyName", "ECLIPSE\0"
49
            VALUE "FileDescription", "Performance Monitor Agent\0"
50
            VALUE "FileVersion", "3, 1, 0, 0\0"
51
            VALUE "InternalName", "\0"
52
            VALUE "LegalCopyright", "© Copyright International Business Machines Corporation, 2003\0"
53
            VALUE "LegalTrademarks", "\0"
54
            VALUE "OriginalFilename", "PerfmonAgent.exe\0"
55
            VALUE "PrivateBuild", "\0"
56
            VALUE "ProductName", "\0"
57
            VALUE "ProductVersion", "3, 1, 0, 0\0"
58
            VALUE "SpecialBuild", "\0"
59
        END
60
    END
61
    BLOCK "VarFileInfo"
62
    BEGIN
63
        VALUE "Translation", 0x409, 1200
64
    END
65
END
66
67
#endif    // !_MAC
68
69
70
#ifdef APSTUDIO_INVOKED
71
/////////////////////////////////////////////////////////////////////////////
72
//
73
// TEXTINCLUDE
74
//
75
76
1 TEXTINCLUDE DISCARDABLE
77
BEGIN
78
    "resource.h\0"
79
END
80
81
2 TEXTINCLUDE DISCARDABLE
82
BEGIN
83
    "#include ""afxres.h""\r\n"
84
    "\0"
85
END
86
87
3 TEXTINCLUDE DISCARDABLE
88
BEGIN
89
    "\r\n"
90
    "\0"
91
END
92
93
#endif    // APSTUDIO_INVOKED
94
95
#endif    // English (U.S.) resources
96
/////////////////////////////////////////////////////////////////////////////
97
98
99
100
#ifndef APSTUDIO_INVOKED
101
/////////////////////////////////////////////////////////////////////////////
102
//
103
// Generated from the TEXTINCLUDE 3 resource.
104
//
105
106
107
/////////////////////////////////////////////////////////////////////////////
108
#endif    // not APSTUDIO_INVOKED
109
(-)src-native-new/src/agents/native/java_profiler/version.rc (+110 lines)
Added Link Here
1
#include "../../../../include/tptp/version.h"
2
//Microsoft Developer Studio generated resource script.
3
//
4
#include "resource.h"
5
6
#define APSTUDIO_READONLY_SYMBOLS
7
/////////////////////////////////////////////////////////////////////////////
8
//
9
// Generated from the TEXTINCLUDE 2 resource.
10
//
11
#include "afxres.h"
12
13
/////////////////////////////////////////////////////////////////////////////
14
#undef APSTUDIO_READONLY_SYMBOLS
15
16
/////////////////////////////////////////////////////////////////////////////
17
// English (U.S.) resources
18
19
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20
#ifdef _WIN32
21
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
22
#pragma code_page(1252)
23
#endif //_WIN32
24
25
#ifndef _MAC
26
/////////////////////////////////////////////////////////////////////////////
27
//
28
// Version
29
//
30
31
VS_VERSION_INFO VERSIONINFO
32
 FILEVERSION _VERSION_WIN
33
 PRODUCTVERSION _VERSION_WIN
34
 FILEFLAGSMASK 0x3fL
35
#ifdef _DEBUG
36
 FILEFLAGS 0x1L
37
#else
38
 FILEFLAGS 0x0L
39
#endif
40
 FILEOS 0x40004L
41
 FILETYPE 0x2L
42
 FILESUBTYPE 0x0L
43
BEGIN
44
    BLOCK "StringFileInfo"
45
    BEGIN
46
        BLOCK "040904b0"
47
        BEGIN
48
            VALUE "Comments", "\0"
49
            VALUE "CompanyName", _COMPANY_NAME
50
            VALUE "FileDescription", "Java Profiling Agent\0"
51
            VALUE "FileVersion", _VERSION
52
            VALUE "InternalName", "piAgent\0"
53
            VALUE "LegalCopyright", _COPYRIGHT
54
            VALUE "LegalTrademarks", "\0"
55
            VALUE "OriginalFilename", "piAgent.dll\0"
56
            VALUE "PrivateBuild", "\0"
57
            VALUE "ProductName", "\0"
58
            VALUE "ProductVersion", _VERSION
59
            VALUE "SpecialBuild", "\0"
60
        END
61
    END
62
    BLOCK "VarFileInfo"
63
    BEGIN
64
        VALUE "Translation", 0x409, 1200
65
    END
66
END
67
68
#endif    // !_MAC
69
70
71
#ifdef APSTUDIO_INVOKED
72
/////////////////////////////////////////////////////////////////////////////
73
//
74
// TEXTINCLUDE
75
//
76
77
1 TEXTINCLUDE DISCARDABLE
78
BEGIN
79
    "resource.h\0"
80
END
81
82
2 TEXTINCLUDE DISCARDABLE
83
BEGIN
84
    "#include ""afxres.h""\r\n"
85
    "\0"
86
END
87
88
3 TEXTINCLUDE DISCARDABLE
89
BEGIN
90
    "\r\n"
91
    "\0"
92
END
93
94
#endif    // APSTUDIO_INVOKED
95
96
#endif    // English (U.S.) resources
97
/////////////////////////////////////////////////////////////////////////////
98
99
100
101
#ifndef APSTUDIO_INVOKED
102
/////////////////////////////////////////////////////////////////////////////
103
//
104
// Generated from the TEXTINCLUDE 3 resource.
105
//
106
107
108
/////////////////////////////////////////////////////////////////////////////
109
#endif    // not APSTUDIO_INVOKED
110
(-)src-native-new/src/agents/perfmon/WinBuild/PerfmonAgent.dsp (+119 lines)
Added Link Here
1
# Microsoft Developer Studio Project File - Name="PerfmonAgent" - Package Owner=<4>
2
# Microsoft Developer Studio Generated Build File, Format Version 6.00
3
# ** DO NOT EDIT **
4
5
# TARGTYPE "Win32 (x86) Console Application" 0x0103
6
7
CFG=PerfmonAgent - Win32 Release
8
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9
!MESSAGE use the Export Makefile command and run
10
!MESSAGE 
11
!MESSAGE NMAKE /f "PerfmonAgent.mak".
12
!MESSAGE 
13
!MESSAGE You can specify a configuration when running NMAKE
14
!MESSAGE by defining the macro CFG on the command line. For example:
15
!MESSAGE 
16
!MESSAGE NMAKE /f "PerfmonAgent.mak" CFG="PerfmonAgent - Win32 Release"
17
!MESSAGE 
18
!MESSAGE Possible choices for configuration are:
19
!MESSAGE 
20
!MESSAGE "PerfmonAgent - Win32 Release" (based on "Win32 (x86) Console Application")
21
!MESSAGE "PerfmonAgent - Win32 Debug" (based on "Win32 (x86) Console Application")
22
!MESSAGE 
23
24
# Begin Project
25
# PROP AllowPerConfigDependencies 0
26
# PROP Scc_ProjName ""
27
# PROP Scc_LocalPath ""
28
CPP=cl.exe
29
RSC=rc.exe
30
31
!IF  "$(CFG)" == "PerfmonAgent - Win32 Release"
32
33
# PROP BASE Use_MFC 0
34
# PROP BASE Use_Debug_Libraries 0
35
# PROP BASE Output_Dir "PerfmonAgent___Win32_Release"
36
# PROP BASE Intermediate_Dir "PerfmonAgent___Win32_Release"
37
# PROP BASE Target_Dir ""
38
# PROP Use_MFC 0
39
# PROP Use_Debug_Libraries 0
40
# PROP Output_Dir "..\..\..\..\bin"
41
# PROP Intermediate_Dir "Release"
42
# PROP Ignore_Export_Lib 0
43
# PROP Target_Dir ""
44
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
45
# ADD CPP /nologo /MD /W3 /GX /O2 /I "../resutils" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
46
# ADD BASE RSC /l 0x409 /d "NDEBUG"
47
# ADD RSC /l 0x409 /d "NDEBUG"
48
BSC32=bscmake.exe
49
# ADD BASE BSC32 /nologo
50
# ADD BSC32 /nologo
51
LINK32=link.exe
52
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
53
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\lib"
54
55
!ELSEIF  "$(CFG)" == "PerfmonAgent - Win32 Debug"
56
57
# PROP BASE Use_MFC 0
58
# PROP BASE Use_Debug_Libraries 0
59
# PROP BASE Output_Dir "PerfmonAgent___Win32_Debug"
60
# PROP BASE Intermediate_Dir "PerfmonAgent___Win32_Debug"
61
# PROP BASE Ignore_Export_Lib 0
62
# PROP BASE Target_Dir ""
63
# PROP Use_MFC 0
64
# PROP Use_Debug_Libraries 0
65
# PROP Output_Dir "..\..\..\..\bin"
66
# PROP Intermediate_Dir "Debug"
67
# PROP Ignore_Export_Lib 0
68
# PROP Target_Dir ""
69
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "../resutils" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
70
# ADD CPP /nologo /MD /W3 /GX /O2 /I "../resutils" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
71
# ADD BASE RSC /l 0x409 /d "NDEBUG"
72
# ADD RSC /l 0x409 /d "NDEBUG"
73
BSC32=bscmake.exe
74
# ADD BASE BSC32 /nologo
75
# ADD BSC32 /nologo
76
LINK32=link.exe
77
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib /nologo /subsystem:console /machine:I386 /libpath:"bin"
78
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\lib"
79
80
!ENDIF 
81
82
# Begin Target
83
84
# Name "PerfmonAgent - Win32 Release"
85
# Name "PerfmonAgent - Win32 Debug"
86
# Begin Group "Source Files"
87
88
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
89
# Begin Source File
90
91
SOURCE=..\PerfmonAgent\PerfmonAgent.cpp
92
# End Source File
93
# End Group
94
# Begin Group "Header Files"
95
96
# PROP Default_Filter "h;hpp;hxx;hm;inl"
97
# Begin Source File
98
99
SOURCE=..\PerfmonAgent\cominterface.h
100
# End Source File
101
# Begin Source File
102
103
SOURCE=..\PerfmonAgent\PerfmonAgent.h
104
# End Source File
105
# Begin Source File
106
107
SOURCE=..\PerfmonAgent\resinterface.h
108
# End Source File
109
# End Group
110
# Begin Group "Resource Files"
111
112
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
113
# Begin Source File
114
115
SOURCE=..\PerfmonAgent\version.rc
116
# End Source File
117
# End Group
118
# End Target
119
# End Project
(-)src-native-new/src/agents/perfmon/sysperf/version.rc (+109 lines)
Added Link Here
1
//Microsoft Developer Studio generated resource script.
2
//
3
#include "resource.h"
4
5
#define APSTUDIO_READONLY_SYMBOLS
6
/////////////////////////////////////////////////////////////////////////////
7
//
8
// Generated from the TEXTINCLUDE 2 resource.
9
//
10
#include "afxres.h"
11
12
/////////////////////////////////////////////////////////////////////////////
13
#undef APSTUDIO_READONLY_SYMBOLS
14
15
/////////////////////////////////////////////////////////////////////////////
16
// English (U.S.) resources
17
18
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
19
#ifdef _WIN32
20
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21
#pragma code_page(1252)
22
#endif //_WIN32
23
24
#ifndef _MAC
25
/////////////////////////////////////////////////////////////////////////////
26
//
27
// Version
28
//
29
30
VS_VERSION_INFO VERSIONINFO
31
 FILEVERSION 3,1,0,0
32
 PRODUCTVERSION 3,1,0,0
33
 FILEFLAGSMASK 0x3fL
34
#ifdef _DEBUG
35
 FILEFLAGS 0x1L
36
#else
37
 FILEFLAGS 0x0L
38
#endif
39
 FILEOS 0x40004L
40
 FILETYPE 0x2L
41
 FILESUBTYPE 0x0L
42
BEGIN
43
    BLOCK "StringFileInfo"
44
    BEGIN
45
        BLOCK "040904b0"
46
        BEGIN
47
            VALUE "Comments", "\0"
48
            VALUE "CompanyName", "ECLIPSE\0"
49
            VALUE "FileDescription", "Performance Monitor Library\0"
50
            VALUE "FileVersion", "3, 1, 0, 0\0"
51
            VALUE "InternalName", "\0"
52
            VALUE "LegalCopyright", "© Copyright International Business Machines Corporation, 2003\0"
53
            VALUE "LegalTrademarks", "\0"
54
            VALUE "OriginalFilename", "sysperf.dll\0"
55
            VALUE "PrivateBuild", "\0"
56
            VALUE "ProductName", "\0"
57
            VALUE "ProductVersion", "3, 1, 0, 0\0"
58
            VALUE "SpecialBuild", "\0"
59
        END
60
    END
61
    BLOCK "VarFileInfo"
62
    BEGIN
63
        VALUE "Translation", 0x409, 1200
64
    END
65
END
66
67
#endif    // !_MAC
68
69
70
#ifdef APSTUDIO_INVOKED
71
/////////////////////////////////////////////////////////////////////////////
72
//
73
// TEXTINCLUDE
74
//
75
76
1 TEXTINCLUDE DISCARDABLE
77
BEGIN
78
    "resource.h\0"
79
END
80
81
2 TEXTINCLUDE DISCARDABLE
82
BEGIN
83
    "#include ""afxres.h""\r\n"
84
    "\0"
85
END
86
87
3 TEXTINCLUDE DISCARDABLE
88
BEGIN
89
    "\r\n"
90
    "\0"
91
END
92
93
#endif    // APSTUDIO_INVOKED
94
95
#endif    // English (U.S.) resources
96
/////////////////////////////////////////////////////////////////////////////
97
98
99
100
#ifndef APSTUDIO_INVOKED
101
/////////////////////////////////////////////////////////////////////////////
102
//
103
// Generated from the TEXTINCLUDE 3 resource.
104
//
105
106
107
/////////////////////////////////////////////////////////////////////////////
108
#endif    // not APSTUDIO_INVOKED
109
(-)src-native-new/src/agents/perfmon/perflin/perflin.make (+129 lines)
Added Link Here
1
2
################################################################################
3
#                                       
4
#  makefile:  perflin project  
5
#                                       
6
# $Id
7
################################################################################
8
9
10
#-----------------------------------
11
#
12
#   Customizable section
13
#
14
#   - The TARGETREALNAME variable specifies the name of the library file
15
#     that will be generated, this includes a base (TARGETLIB) plus	a 
16
#     version number plus a minor number plus a release number
17
#   - The TARGETSONAME variable specifies a file name that has just the
18
#     library name plus the major version number
19
#   - The TARGETLIB variable specifies the base library name
20
#   - The TARGETSONAME and TARGETLIB are generated as symbolic links
21
#     when the library is built
22
#
23
#-----------------------------------
24
TARGET         :=  libperflin
25
TARGETDIR      :=  ../../../../lib
26
27
if [ x$VERSIONNUM = x ]; then export VERSIONNUM=0; fi
28
if [ x$MINORNUM = x ]; then export MINORNUM=0; fi
29
if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi
30
31
TARGETLIB      :=  $(TARGET).so
32
TARGETSONAME   :=  $(TARGETLIB).$(VERSIONNUM)
33
TARGETREALNAME :=  $(TARGETSONAME).$(MINORNUM).$(RELEASENUM)
34
35
36
#-----------------------------------
37
#   list of additional INCLUDE directories to search headers from
38
#      (separated by blanks)
39
#-----------------------------------
40
INCLUDEDIRS    :=  . ../resutils
41
42
43
#-----------------------------------
44
#   list of additional libraries to be linked with
45
#      (separated by blanks)
46
#-----------------------------------
47
LIBS       :=  dl resutils
48
49
#-----------------------------------
50
#   list of additional library directories to search from
51
#      (separated by blanks)
52
#-----------------------------------
53
LIBDIRS    :=  ../../../../lib
54
55
56
#-----------------------------------
57
#
58
#   Compiler options
59
#
60
#      -g       produce debug info
61
#      -Wall    enable all types of warnings
62
#      -O3      highest level of code optimization
63
#      -fPIC    generate position-independent code (PIC).
64
#               This is required for building shared library.
65
#      -c       compile only
66
#
67
#   Linking options
68
#
69
#       -Wl       pass options to linker
70
#       -shared   produce shared library
71
#       -L        add the given directory to the search path for libraries
72
#
73
#-----------------------------------
74
75
DEFINES    :=  -DLINUX
76
77
CFLAGS     :=  $(C_FLAGS) $(DEBUGABLE) -Wall $(OPTIMIZABLE) -fPIC $(addprefix -I,$(INCLUDEDIRS))  -D_LINUX_X86  $(DEFINES)
78
79
CXXFLAGS   :=  $(CFLAGS)
80
81
LINKOPTS   :=  $(L_FLAGS) $(DEBUGABLE) -shared -Wl,-soname,$(TARGETSONAME) -o $(TARGETDIR)/$(TARGETREALNAME) $(addprefix -L,$(LIBDIRS))
82
83
84
#-----------------------------------
85
#   general commands and options
86
#-----------------------------------
87
88
CC          :=  gcc
89
CXX         :=  $(CC)
90
91
SOURCE     :=  $(wildcard *.c)  $(wildcard *.cpp)
92
93
OBJS       :=  $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
94
95
REMOVEFILE :=  rm -f
96
CREATELINK :=  ln -sf
97
98
99
#-----------------------------------
100
#   "make" rules
101
#-----------------------------------
102
103
.PHONY : default everything objs clean veryclean rebuild $(TARGET)
104
105
106
default : $(TARGET)
107
108
109
objs : $(OBJS)
110
111
112
clean :
113
	$(REMOVEFILE) *.o
114
115
116
veryclean: clean
117
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETLIB)
118
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETSONAME)
119
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETREALNAME)
120
121
122
rebuild: veryclean everything
123
124
125
$(TARGET) : $(OBJS)
126
	$(CC) $(LINKOPTS) $(OBJS) $(addprefix -l,$(LIBS))
127
	$(CREATELINK) $(TARGETREALNAME)  $(TARGETDIR)/$(TARGETSONAME)
128
	$(CREATELINK) $(TARGETSONAME)    $(TARGETDIR)/$(TARGETLIB)
129
(-)src-native-new/src/agents/native/java_profiler/print.h (+386 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: print.h,v 1.6 2006/04/09 21:42:24 bduncan Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef __PRINT_H__
14
#define __PRINT_H__ 1
15
16
#include "RAComm.h"
17
#include <jvmpi.h>
18
#include "hash.h"
19
#include "stack.h"
20
#include "filters.h"
21
#include "performance.h"
22
#include "JvmpiWriter.h"
23
#include "RABindings.h"
24
25
/* TYPES
26
 */
27
#ifdef _WIN32									/* _WIN32 */
28
 #define TIMEB  struct _timeb
29
 #define FTIME(param)  _ftime(param)
30
 typedef unsigned __int64 Uint64;
31
#else											/* else */
32
 #define TIMEB	struct timeb
33
 #define FTIME(param)  ftime(param)
34
#endif											/* endif */
35
36
enum FieldType {Static, Instance};                    /* Indicates whether a field is a static field or an object instance field */
37
typedef enum FieldType FieldType_t;
38
39
/* GLOBALS
40
 */
41
extern RA_HANDLE _jvmpiAgent_outFile;
42
extern int    _jvmpiAgent_suspendIO;         /* TRUE = suspend output, FALSE = produce output */
43
44
/** INITIALIZE_STANDALONE_IO  **************************************************
45
  * Must be called when tracing in standalone mode to create IO buffers and
46
  * asynchronous IO support (if enabled).
47
  */
48
void jvmpiAgent_initializeStandaloneIO();
49
50
51
/** CLEANUP_STANDALONE_IO  *****************************************************
52
  * Must be called when tracing in standalone to flush/close all the IO buffers.
53
  */
54
void jvmpiAgent_cleanupStandaloneIO();
55
56
57
/** PRINT  ********************************************************************
58
  * Transmit/print the raw data to the median.
59
  * @param  buffer - the buffer to write to the median.
60
  * @param  length - number of bytes to write
61
  */
62
void jvmpiAgent_print(ThreadPrivateStorage *tps,
63
					  char *buffer,
64
					  unsigned short length);
65
66
67
/** PRINT_CLASS  **************************************************************
68
  * Handles the output of the CLASS_LOAD element and attributes
69
  */
70
void jvmpiAgent_printClass(HashEntry *classHashEntry,
71
						   ThreadPrivateStorage *tps);
72
73
74
/** PRINT_FIELDS  *************************************************************
75
  * Handles the output of all the STATIC_FIELD or INSTANCE_FIELD elements
76
  * and attributes for a class.
77
  */
78
void jvmpiAgent_printFields(ThreadPrivateStorage *tps,
79
							PI_Field *fp,
80
							int count,
81
							FieldType_t fieldType);
82
83
84
/** PRINT_METHODS  ************************************************************
85
  *  Handles the output of all the METHOD elements and attributes for a class.
86
  */
87
void jvmpiAgent_printMethods(HashEntry **mp,
88
							 int count,
89
							 ThreadPrivateStorage *tps);
90
91
92
/** PRINT_METHOD  *************************************************************
93
  */
94
void jvmpiAgent_printMethod(MethodEntry *methodEntry,
95
							ThreadPrivateStorage *buffer);
96
97
/** PRINT_METHOD_ENTRY_EVENT  *************************************************
98
  *
99
  */
100
void jvmpiAgent_printMethodEntryEvent(JVMPI_Event *event,
101
									  ThreadLocalStorage *tps,
102
									  StackEntry *se,
103
									  unsigned long stackDepth);
104
105
106
/** PRINT_METHOD_EXIT_EVENT  **************************************************
107
  *
108
  */
109
void jvmpiAgent_printMethodExitElement(JVMPI_Event *event,
110
									   ThreadLocalStorage *tps,
111
									   HashEntry *methodHashEntry,
112
				       timestamp_t timestamp,
113
					   timestamp_t cpu_timestamp);
114
					   
115
/** PRINT_AG_METHOD_ENTRY_EVENT  **************************preAgg/135437*******
116
  *
117
  */
118
void jvmpiAgent_printAgMethodEntryEvent(ThreadPrivateStorage * tps, 
119
									   StackFrame * call);
120
121
122
/** PRINT_AG_METHOD_EXIT_ELEMENT  *************************preAgg/135437*******
123
  *
124
  */
125
void jvmpiAgent_printAgMethodExitElement(ThreadPrivateStorage * tps, 
126
									   StackFrame * call);
127
128
129
/** PRINT_EXCEPTION_ELEMENT  **************************************************
130
  *
131
  */
132
void jvmpiAgent_printExceptionElement(JNIEnv *env,
133
									  ThreadLocalStorage *tps,
134
									  enum ThrowOrCatch type,
135
									  HashEntry *methodHashEntry,
136
									  jobjectID objId,
137
									  jthrowable e);
138
139
/** PRINT_LINE_ELEMENT  *******************************************************
140
  *
141
  */
142
void jvmpiAgent_printLineElement(JNIEnv *env,
143
								 ThreadLocalStorage *tps,
144
								 HashEntry *methodHashEntry,
145
								 unsigned short lineNumber);
146
147
148
/** PRINT_THREAD_END_ELEMENT  *************************************************
149
  */
150
void jvmpiAgent_printThreadEndElement(JNIEnv *env_id,
151
									  ThreadLocalStorage *tps);
152
153
/** PRINT_OBJ_MOVE_ELEMENT  ***************************************************
154
  * Handles the output of OBJ_MOVE.
155
  */
156
void jvmpiAgent_printObjMoveElement(JVMPI_Event *event,
157
									HashEntry *objectHashEntry);
158
159
/** PRINT_OBJ_FREE_ELEMENT  ***************************************************
160
  * Handles the output of OBJ_FREE.
161
  */
162
void jvmpiAgent_printObjFreeElement(ThreadLocalStorage *tps,
163
									HashEntry *objectHashEntry);
164
165
166
/** PRINT_CLASS_UNLOAD_ELEMENT  ***********************************************
167
  *
168
  * PRECONDITIONS:  classHashEntry must be valid.
169
  */
170
void jvmpiAgent_printClassUnloadElement(JVMPI_Event *event,
171
										ThreadLocalStorage *tps,
172
										HashEntry *classHashEntry);
173
174
175
void jvmpiAgent_printJvmInitDoneElement(JVMPI_Event *event);
176
void jvmpiAgent_printJvmShutdownElement(JVMPI_Event *event);
177
178
void jvmpiAgent_printGcStartElement(JVMPI_Event *event);
179
void jvmpiAgent_printGcFinishElement(JVMPI_Event *event);
180
181
/** PRINT_MONITOR_WAIT_ELEMENT  *****************************************************
182
  *
183
  * Print the <monWait> element to the trace indicating JVMPI_EVENT_MONITOR_WAIT occurred. 
184
  *
185
  * args - 
186
  *		objectHashEntry - the hash entry corresponding to the monitor object 
187
  *		event - the MONITOR_WAIT event as reported by JVMPI
188
  *		timestamp - when the MONITOR_WAIT event occurred
189
  *     isThreadSleep - 0 indicates regular monitor, 1 indicates wait occurred 
190
  *                     within Thread.sleep()
191
  */
192
void 
193
jvmpiAgent_printMonitorWaitElement(HashEntry *objectHashEntry, JVMPI_Event *event, 
194
								   timestamp_t timestamp, int isThreadSleep); 
195
196
/** PRINT_MONITOR_WAITED_ELEMENT  *****************************************************
197
  *
198
  * Print the <monWaited> element to the trace indicating JVMPI_EVENT_MONITOR_WAITED occurred. 
199
  *
200
  * args - 
201
  *     objectHashEntry - the hash entry corresponding to the monitor object 
202
  *		event - the MONITOR_WAITED event as reported by JVMPI
203
  *		timestamp - when the MONITOR_WAITED event occurred
204
  *     isThreadSleep - 0 indicates regular monitor, 1 indicates wait occurred 
205
  *                     within Thread.sleep()
206
  */
207
void 
208
jvmpiAgent_printMonitorWaitedElement(HashEntry *objectHashEntry, JVMPI_Event *event, 
209
								   timestamp_t timestamp, int isThreadSleep);
210
211
212
/** PRINT_MONITOR_STILL_OWNED_ELEMENT  ************************************************
213
  *
214
  * Print the <monStillOwned> element to the trace indicating
215
  * a thread is still owning a monitor at the moment we checked
216
  * It is potentially sent on JVMPI_EVENT_MONITOR_CONTENDED_ENTER
217
  * just before a <monContendedEnter> element where the
218
  * thread is the contended thread
219
  *
220
  * args -
221
  *		objectHashEntry - the hash entry corresponding to the monitor object
222
  *		event - the JVMPI_EVENT_MONITOR_CONTENDED_ENTER event as reported by JVMPI
223
  */
224
void
225
jvmpiAgent_printMonitorStillOwnedElement(HashEntry *objectHashEntry, JVMPI_Event *event);
226
227
/** PRINT_MONITOR_CONTENDED_ENTER_ELEMENT  ************************************************
228
  *
229
  * Print the <monContendedEnter> element to the trace indicating 
230
  * JVMPI_EVENT_MONITOR_CONTENDED_ENTER occurred. 
231
  *
232
  * args - 
233
  *		objectHashEntry - the hash entry corresponding to the monitor object
234
  *		event - the MONITOR_WAITED event as reported by JVMPI
235
  *		thread_owner - the current owner thread of the monitor object 
236
  *		timestamp - when the MONITOR_WAITED event occurred
237
  */
238
void
239
jvmpiAgent_printMonitorContendedEnterElement(HashEntry *objectHashEntry, JVMPI_Event *event, 
240
			unsigned long thread_owner, timestamp_t timestamp);
241
242
/** PRINT_MONITOR_CONTENDED_ENTERED_ELEMENT  ************************************************
243
  *
244
  * Print the <monContendedEntered> element to the trace indicating 
245
  * JVMPI_EVENT_MONITOR_CONTENDED_ENTERED occurred. 
246
  *
247
  * args - 
248
  *		objectHashEntry - the hash entry corresponding to the monitor object
249
  *		event - the MONITOR_WAITED event as reported by JVMPI
250
  *		timestamp - when the MONITOR_WAITED event occurred
251
  */
252
void
253
jvmpiAgent_printMonitorContendedEnteredElement(HashEntry *objectHashEntry, JVMPI_Event *event, 
254
			timestamp_t timestamp);
255
256
/** PRINT_OBJ_ALLOC_ELEMENT  **************************************************
257
  * Print OBJ_ALLOC to handle an object allocation.
258
  */
259
void jvmpiAgent_printObjAllocElement(HashEntry *objectHashEntry,
260
									 JNIEnv *env_id,
261
                                     timestamp_t timestamp);
262
263
/* REALLOCATE memory if the buffer size insufficient*******************************
264
 * Check buffer size and realloc memory to prevent 
265
 * buffer overflow.
266
 *
267
 */
268
void
269
jvmpiAgent_checkMemorySize(ThreadPrivateStorage *tps, 
270
						   int in_value,
271
						   unsigned short current);
272
273
/** PRINT_THREAD_START_ELEMENT  ***********************************************
274
  *
275
  */
276
void jvmpiAgent_printThreadStartElement(JNIEnv *env_id,
277
										HashEntry *threadHashEntry);
278
279
/** PRINT_FILTER  *************************************************************
280
  * Outputs a FILTER element
281
  */
282
void jvmpiAgent_printFilter(ThreadLocalStorage *tps,
283
							Filter *filter);
284
285
/** PRINT_OPTION  *************************************************************
286
  * Outputs an OPTION element
287
  */
288
void jvmpiAgent_PrintOption(ThreadLocalStorage *tps,
289
							char *key,
290
							char *value);
291
292
char * jvmpiAgent_formatName(char *name);
293
294
/** PRINT_TRACE_START_ELEMENT  ************************************************
295
  */
296
void jvmpiAgent_printTraceStartElement(ThreadLocalStorage *tps,
297
									   char *options);
298
299
/** PRINT_TRACE_STOP_ELEMENT  *************************************************
300
 */
301
void jvmpiAgent_printTraceStopElement(ThreadLocalStorage *tps);
302
303
void jvmpiAgent_printTraceEndElement(ThreadLocalStorage *tps);
304
305
/** PRINT_STANDALONE_TRACE_TAG_OPEN  ******************************************
306
  */
307
void jvmpiAgent_printStandaloneTraceTagOpen(ThreadLocalStorage *tps);
308
309
/** PRINT_STANDALONE_TRACE_TAG_CLOSE  *****************************************
310
  */
311
void jvmpiAgent_printStandaloneTraceTagClose(ThreadLocalStorage *tps);
312
313
/** PRINT_NODE_ELEMENT  *******************************************************
314
  */
315
void jvmpiAgent_printNodeElement(ThreadLocalStorage *tps);
316
317
/** PRINT_PROCESS_CREATE_ELEMENT  *********************************************
318
  */
319
void jvmpiAgent_printProcessCreateElement(ThreadLocalStorage *tps);
320
321
/** PRINT_AGENT_CREATE_ELEMENT  ***********************************************
322
  */
323
void jvmpiAgent_printAgentCreateElement(ThreadLocalStorage *tps,
324
										char *options);
325
/** PRINT_OBJECTREFERENCE_ELEMENT  ********************************************
326
  */
327
void jvmpiAgent_printObjectArrayReferenceElement(ThreadLocalStorage *tps,
328
												 unsigned long obj_id,
329
												 unsigned int index,
330
												 jint objRef_id,
331
												 unsigned int firstSeen);
332
333
void jvmpiAgent_printObjectInstanceReferenceElement(ThreadLocalStorage *tps,
334
													unsigned long obj_id,
335
													unsigned int index,
336
													jint objRef_id,
337
													unsigned int firstSeen,
338
													unsigned long fieldId);
339
340
void jvmpiAgent_printStaticReferenceElement(ThreadLocalStorage *tps,
341
											unsigned long class_id,
342
											unsigned int index,
343
											jint objRef_id,
344
											unsigned long fieldId);
345
346
/** PRINT_HEAP_DUMP START ELEMENT *********************************************
347
*/
348
void jvmpiAgent_printHDStartElement(ThreadLocalStorage *tps,
349
									char* heapDefName);
350
351
/** PRINT_AGENT_DESTROY_ELEMENT  **********************************************
352
  */
353
void jvmpiAgent_printAgentDestroyElement(ThreadLocalStorage *tps);
354
355
356
/** PRINT_AGENT_DESTROY_ELEMENT  **********************************************
357
  */
358
unsigned short jvmpiAgent_printTicketAttribute(SegmentedValue_t *ticket,
359
											   char *buffer,
360
											   unsigned short current);
361
362
/** PRINT_XML_START_ELEMENT  **************************************************
363
  * Place the standard XML file start entry in the specified buffer.
364
  * @param  buffer - the buffer that will be loaded with the string (beginning)
365
  */
366
void jvmpiAgent_printXMLStartElement(ThreadLocalStorage *tps);
367
368
/** PRINT_VM_SUSPEND  *********************************************************
369
  * Loads the memory address specified by 'buffer' with a Suspend entity including
370
  * timestamp.
371
  */
372
extern void jvmpiAgent_printVMSuspend(ThreadLocalStorage *tps);
373
374
/** PRINT_VM_RESUME  **********************************************************
375
  * Loads the memory address specified by 'buffer' with a Resume entity including
376
  * timestamp.
377
  */
378
extern void jvmpiAgent_printVMResume(ThreadLocalStorage *tps);
379
380
381
/** PRINT GC_ROOT *************************************************************
382
 */
383
void jvmpiAgent_printGcRootElement(JVMPI_Event *event, unsigned long id, char* type);
384
385
386
#endif
(-)src-native-new/src/agents/native/java_profiler/utility.h (+125 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: utility.h,v 1.3 2006/04/24 13:29:35 samwai Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef __UTILITY_H__
14
#define __UTILITY_H__ 1
15
16
#ifdef _WIN32
17
	#include <winsock2.h> /* Bug 134924 */
18
	#include <Windows.h>
19
	#include <Winbase.h>
20
	#ifndef PATH_MAX
21
		#define PATH_MAX (10 * _MAX_PATH)
22
		char *realpath(const char* fileName, char * buf) ;
23
	#endif
24
#elif defined(__OS400__)
25
	char *realpath(const char* fileName, char * buf) ;
26
#endif
27
28
#ifndef PATH_MAX
29
#define PATH_MAX 2048
30
#endif
31
32
#if defined __cplusplus && defined _HPUX
33
	#define ENV(e) e
34
	#define ENVPARM(e)
35
#else
36
	#define ENV(e) (*e)
37
	#define ENVPARM(e) e,
38
#endif
39
40
/** Macros used to simplify the use of JNI *************************/
41
42
43
/* Calling instance methods */
44
#define CALL_OBJ_METHOD0(env, classInstance, methodId) (jstring)(ENV(env)->CallObjectMethod(ENVPARM(env) classInstance, methodId))
45
#define CALL_OBJ_METHOD1(env, classInstance, methodId, param1) (jstring)(ENV(env)->CallObjectMethod(ENVPARM(env) classInstance, methodId, param1))
46
#define CALL_OBJ_METHOD2(env, classInstance, methodId, param1, param2) (jstring)(ENV(env)->CallObjectMethod(ENVPARM(env) classInstance, methodId, param1, param2))
47
48
/* Calling static methods */
49
#define CALL_OBJ_SMETHOD0(env, classAssociated, methodId) (jstring)(ENV(env)->CallStaticObjectMethod(ENVPARM(env) classAssociated, methodId))
50
#define CALL_OBJ_SMETHOD1(env, classAssociated, methodId, param1) (jstring)(ENV(env)->CallStaticObjectMethod(ENVPARM(env) classAssociated, methodId, param1))
51
52
53
#define CREATE_JSTRING(env, text) ENV(env)->NewStringUTF(ENVPARM(env) text)
54
#define FIND_CLASS(env, className) ENV(env)->FindClass(ENVPARM(env) className)
55
56
/* Get ID operations */
57
#define GET_METHODID(env, classAssociated, methodName, methodSig) ENV(env)->GetMethodID(ENVPARM(env) classAssociated, methodName, methodSig)
58
#define GET_SMETHODID(env, classAssociated, methodName, methodSig) ENV(env)->GetStaticMethodID(ENVPARM(env) classAssociated, methodName, methodSig)
59
#define GET_FIELDID(env, classAssociated, name, signature) ENV(env)->GetFieldID(ENVPARM(env) classAssociated, name, signature)
60
#define GET_SFIELDID(env, classAssociated, name, signature) ENV(env)->GetStaticFieldID(ENVPARM(env) classAssociated, name, signature)
61
62
63
#define GET_SFIELD(env, classAssociated, fieldId) ENV(env)->GetStaticObjectField(ENVPARM(env) classAssociated, fieldId)
64
#define NEW_ARRAY(env, size, classAssociated, initialValue) ENV(env)->NewObjectArray(ENVPARM(env) size, classAssociated, initialValue)
65
#define GET_ARRAY_SIZE(env, array) ENV(env)->GetArrayLength(ENVPARM(env) array)
66
#define GET_ARRAY_ELEM(env, array, index) ENV(env)->GetObjectArrayElement(ENVPARM(env) array, index)
67
#define ADD_TO_ARRAY(env, array, index, obj) ENV(env)->SetObjectArrayElement(ENVPARM(env) array, index, obj)
68
69
/* String operations */
70
#define CONVERT_TO_UTF(env, jstr) ENV(env)->GetStringUTFChars(ENVPARM(env) (jstring)jstr, NULL)
71
#define RELEASE_UTF_CHARS(env, jstr, chrs) ENV(env)->ReleaseStringUTFChars(ENVPARM(env) (jstring)jstr, chrs)
72
73
74
/* Exception checks and clears */
75
#if defined __cplusplus && defined _HPUX
76
	#define CHECK_EXCEPTION(env) ENV(env)->ExceptionOccurred()
77
#else
78
	#define CHECK_EXCEPTION(env) ENV(env)->ExceptionOccurred(env)
79
#endif
80
81
82
#if defined __cplusplus && defined _HPUX
83
	#define CLEAR_EXCEPTIONS(env) ENV(env)->ExceptionClear()
84
#else
85
	#define CLEAR_EXCEPTIONS(env) ENV(env)->ExceptionClear(env)
86
#endif
87
88
89
/** CALLOC  *************************************************************
90
  * Allocate some memory from the heap.  If there is no more memory left
91
  * the VM will exit gracefully.
92
  */
93
extern void* jvmpiAgent_Calloc(unsigned int size);
94
95
/********************************************************
96
 * strcpyrealloc()
97
 * 
98
 * Copy one string to the other, first reallocating the 
99
 * space pointed to by the destination so that the src
100
 * can comfortably fit in it. 
101
 * @param dest pointer to pointer to destination 
102
 * @param src the source string 
103
 * @return 0 if successful, -1 otherwise 
104
 */ 
105
106
int strcpyrealloc(char **dest, const char *src); 
107
108
/*********************************************************
109
 * double2string()
110
 *
111
 * Take a value of type double and convert it into a string, 
112
 * using '.' (period) as the decimal symbol (i.e. ignore what
113
 * the locale setting uses for a decimal place). 
114
 *
115
 * The method further assumes val is non-negative. 
116
 * 
117
 * @param val the double value to be converted into a string (non-negative value) 
118
 * @param buffer the buffer into which the string should be put
119
 * @param offset the offset into the buffer where to start writing
120
 * @param precision the number of digits to appear after the decimal place
121
 * @return the offset just past the last written position in buffer
122
 */ 
123
unsigned short double2string(double val, char *buffer, unsigned short offset, int precision); 
124
125
#endif
(-)src-native-new/src/agents/native/java_profiler/print.c (+3656 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: print.c,v 1.12 2006/06/05 23:12:42 bduncan Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifdef _JVMPI__ASYNCRONOUS_IO
14
#ifdef _WIN32
15
	#include <winsock2.h> /* Bug 134924 */
16
	#include <windows.h>
17
#else
18
	#include <aio.h>
19
#endif
20
#endif
21
22
#ifndef _WIN32
23
 #include <fcntl.h>
24
 #include <sys/stat.h>   /* 199558 */
25
 #ifdef _HPUX
26
  #include <unistd.h>
27
 #endif
28
#endif
29
30
#include "utility.h"
31
#include "print.h"
32
#include "options.h"
33
#include "RASocket.h"
34
#include "RADataTransfer.h"
35
#include "RABindings.h"
36
#include "JvmpiWriter.h"
37
#include "eventmask.h"
38
#include "strings.h"
39
#include "assert.h"
40
41
#ifdef BINARY_TRACE
42
#include "binary_print.h"
43
#endif /* BINARY_TRACE */
44
45
/* CPU timestamp granularity for each plaform */
46
#ifdef _WIN32									/* _WIN32 */
47
 #include <process.h>
48
 #define THREADCPUPRECISION		7
49
 #define THREADCPUGRANULARITY	10000000
50
#else											/* else */
51
 #define THREADCPUPRECISION		6
52
 #define THREADCPUGRANULARITY	1000000
53
#endif											/* endif */
54
55
#define TIMESTAMPPRECISION	6
56
57
#ifdef _JVMPI__ASYNCRONOUS_IO
58
 #define SEGMENT_SIZE	1024 /*1048576*/
59
 #define SEGMENT_COUNT	16
60
#endif
61
62
int REALLOCATED_BUFFER_SIZE = 1024;
63
64
static char *DOW[7]= {"Sun", "Mon", "Tue", "Wed",
65
					  "Thu", "Fri", "Sat"};
66
67
static char *MOY[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
68
						"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
69
70
RA_HANDLE			_jvmpiAgent_outFile = RA_HANDLE_NULL;			/* The output file */
71
72
int                 _jvmpiAgent_suspendIO = 1;          /* TRUE = suspend output, FALSE = produce output */
73
74
75
#ifdef _JVMPI__ASYNCRONOUS_IO
76
#ifdef _WIN32
77
typedef struct {
78
	int count;
79
	int offset;
80
	BOOL			flushPending;
81
	OVERLAPPED		overlap;
82
	char			buffer[SEGMENT_SIZE];
83
}IOSegment_t;
84
85
#else
86
#ifdef _AIX
87
 #define AIO_WRITE(fildes, aiocb)  aio_write(fildes, aiocb)
88
#else
89
 #define AIO_WRITE(fildes, aiocb) aio_write(aiocb)
90
#endif
91
92
typedef struct {
93
	int count;
94
	int offset;
95
	BOOL			flushPending;
96
	struct aiocb    aiocb;
97
	char			buffer[SEGMENT_SIZE];
98
}IOSegment_t;
99
100
#endif
101
102
103
IOSegment_t			_ioBuffers[SEGMENT_COUNT];			/* The buffers for IO */
104
int					_ioSegment=0;						/* The currently active IO segment */
105
long				_fileOffset=0;						/* The offset in the file */
106
107
108
static int getSegment()
109
{
110
	int oldCount;
111
	int currentSegment=_ioSegment;
112
	/* Increment the count on the current segment */
113
	oldCount=_ioBuffers[currentSegment].count;
114
	while(!ra_atomicCAS((int*)&_ioBuffers[currentSegment].count, (int*)&oldCount, (int)(oldCount+1)));
115
	return currentSegment;
116
}
117
118
static void releaseSegment(int currentSegment, int segmentOffset)
119
{
120
	int oldCount;
121
122
	/* Decrement the count on the segment */
123
	oldCount=_ioBuffers[currentSegment].count;
124
	while(!ra_atomicCAS((int*)&_ioBuffers[currentSegment].count, (int*)&oldCount, (int)(oldCount-1)));
125
126
	/* If we were the last element in the segment does it need to be flushed? */
127
	if(oldCount==1) {
128
		int currentFileOffset;
129
		int bytesWritten;
130
131
		if(_ioBuffers[currentSegment].flushPending)
132
		{
133
			/* Increment the file pointer for the next IO operation */
134
			currentFileOffset=_fileOffset;
135
			while(!ra_atomicCAS(&_fileOffset, &currentFileOffset, currentFileOffset+segmentOffset));
136
137
138
#ifdef _WIN32
139
			_ioBuffers[currentSegment].overlap.Offset=currentFileOffset;
140
startWrite:
141
			/* Ensure it has finished flushing from the last time it was full */
142
			WaitForSingleObject(_ioBuffers[currentSegment].overlap.hEvent, 0);
143
			if(!WriteFile(_jvmpiAgent_outFile, _ioBuffers[currentSegment].buffer, _ioBuffers[currentSegment].offset, &bytesWritten, &_ioBuffers[currentSegment].overlap))
144
			{
145
				DWORD error=GetLastError();
146
				if(error!=ERROR_IO_PENDING)
147
				{
148
					switch(error)
149
					{
150
					case ERROR_NOT_ENOUGH_MEMORY:
151
					case ERROR_INVALID_USER_BUFFER:
152
					case ERROR_NOT_ENOUGH_QUOTA:
153
					case ERROR_WORKING_SET_QUOTA:
154
						goto startWrite;
155
					default:
156
						printf("Severe error pushing IO\n");
157
						fflush(stdout); 
158
					}
159
				}
160
			}
161
#else
162
			_ioBuffers[currentSegment].aiocb.aio_offset=currentFileOffset;
163
			_ioBuffers[currentSegment].aiocb.aio_nbytes=_ioBuffers[currentSegment].offset;
164
startWrite:
165
			printf("Flushing buffer\n");
166
			fflush(stdout); 
167
			if(AIO_WRITE(_jvmpiAgent_outFile, &_ioBuffers[currentSegment].aiocb))
168
			{
169
					printf("     Flushing failed\n");
170
					fflush(stdout); 
171
172
			}
173
#endif
174
175
			/* Reset the offset of this segment to zero */
176
			/* while(!ra_atomicCAS(&_ioBuffers[currentSegment].offset, &currentBufferOffset, 0)); */
177
			_ioBuffers[currentSegment].offset=0;
178
			_ioBuffers[currentSegment].flushPending=FALSE;
179
		}
180
	}
181
182
}
183
#endif /* _JVMPI__ASYNCRONOUS_IO */
184
185
186
187
void jvmpiAgent_initializeStandaloneIO() {
188
#ifdef _WIN32
189
  _jvmpiAgent_outFile=CreateFile(_jvmpiAgent_Options.outputFileName,
190
								   GENERIC_WRITE,
191
								   FILE_SHARE_READ,
192
								   NULL,
193
								   CREATE_ALWAYS,
194
								   FILE_ATTRIBUTE_NORMAL
195
#ifdef _JVMPI__ASYNCRONOUS_IO
196
								   | FILE_FLAG_OVERLAPPED
197
#endif
198
								   ,
199
								   NULL);
200
201
#else
202
/* 199373 - added permissions */
203
  _jvmpiAgent_outFile = open(_jvmpiAgent_Options.outputFileName,
204
						     O_WRONLY|O_CREAT|O_TRUNC,
205
							 S_IRUSR | S_IWUSR | S_IRGRP );
206
#endif
207
208
209
  /* Check the file descriptor to ensure it is valid */
210
211
  if(_jvmpiAgent_outFile
212
#ifdef _WIN32
213
                         == INVALID_HANDLE_VALUE)
214
#else
215
                         < 0)
216
#endif
217
  {
218
#ifdef MVS
219
#pragma convlit(suspend)
220
#endif
221
	   fprintf(stderr, "*** Could not open profile output file \"%s\".  Exiting JVM. ***\n", _jvmpiAgent_Options.outputFileName);
222
	   fflush(stderr); 
223
#ifdef MVS
224
#pragma convlit(resume)
225
#endif
226
	_jvmpiAgent_jvmpiInterface->ProfilerExit((jint)-1);
227
  }
228
229
230
231
#ifdef _JVMPI__ASYNCRONOUS_IO
232
	int i;
233
 for(i=0; i<SEGMENT_COUNT; i++)
234
 {
235
	 _ioBuffers[i].offset=0;
236
#ifdef _WIN32
237
	 _ioBuffers[i].overlap.hEvent=CreateEvent(NULL, FALSE, FALSE, NULL);
238
	 _ioBuffers[i].overlap.Offset=0;
239
	 _ioBuffers[i].overlap.OffsetHigh=0;
240
#else
241
#ifndef _AIX
242
	 _ioBuffers[i].aiocb.aio_fildes=_jvmpiAgent_outFile; /* output file */
243
#else
244
	 _ioBuffers[i].aiocb.aio_offset=0;					 /* file offset */
245
	 _ioBuffers[i].aiocb.aio_buf=_ioBuffers[i].buffer;   /* i/o buffer */
246
	 _ioBuffers[i].aiocb.aio_reqprio=0;					 /* request priority offset */
247
#ifdef _AIX
248
	 /*_ioBuffers[i].aiocb.aio_event); */       /* signal number and value */
249
#else
250
	  /*_ioBuffers[i].aiocb.aio_sigevent= */               /* signal number and value */
251
#endif
252
	 /*_ioBuffers[i].aiocb.aio_lio_opcode=LIO_WRITE; */ 	 /* operation to be preformed */
253
#endif
254
#endif
255
	 _ioBuffers[i].flushPending=FALSE;
256
 }
257
#endif /* _JVMPI__ASYNCRONOUS_IO */
258
}
259
260
void jvmpiAgent_cleanupStandaloneIO()
261
{
262
#ifdef _JVMPI__ASYNCRONOUS_IO
263
  int segment=getSegment();
264
  _ioBuffers[segment].flushPending=TRUE;
265
  releaseSegment(segment, _ioBuffers[segment].offset);
266
#endif /* _JVMPI__ASYNCRONOUS_IO */
267
  CLOSE_RA_HANDLE(_jvmpiAgent_outFile);
268
}
269
270
271
/** PRINT  **********************************************************************
272
  * Transmit/print the raw data to the median.
273
  * @param  buffer - the buffer to write to the median.
274
  * @param  length - number of bytes to write
275
  */
276
void jvmpiAgent_print(ThreadPrivateStorage *tps, char *s, unsigned short length)
277
{
278
279
 if (!_jvmpiAgent_suspendIO)
280
 {
281
  if (!_jvmpiAgent_Options.standalone)
282
  {
283
   /* Insert the length of the data in the buffer and transmit */
284
#ifdef __OS400__
285
	  if (s) {
286
	    /* need to reassign the result back to tps->buffer2 because iconv modified tps->buffer2 */ 
287
		tps->buffer2 = as400_etoa_tobuffer(s, tps->buffer2); 
288
		ra_writeMessageBlock(&_jvmpiAgent_Options.targetHdl, RA_BINARY_DATA, (unsigned char *)tps->buffer2, length); /* 232010 */
289
	  }
290
#else
291
   ra_writeMessageBlock(&_jvmpiAgent_Options.targetHdl, RA_BINARY_DATA, (unsigned char *)s, length);
292
#endif
293
  }
294
  else
295
  {
296
	int currentBufferOffset;
297
	BOOL success=FALSE;
298
299
	if(!_jvmpiAgent_Options.jinsightFormat) {
300
	  s[length++]='\n';
301
	}
302
303
#ifndef _JVMPI__ASYNCRONOUS_IO
304
305
#ifdef _WIN32
306
	WriteFile(_jvmpiAgent_outFile, s, length, &currentBufferOffset, NULL);
307
#else
308
#ifdef MVS                    /* 174190 */
309
	if(!_jvmpiAgent_Options.jinsightFormat) {
310
	  s[length]='\0';           /* need to make the string null terminated for atoe conversion */
311
	  __atoe(s);
312
	}
313
#endif
314
	write(_jvmpiAgent_outFile, s, length);
315
#endif
316
#else /*  _JVMPI__ASYNCRONOUS_IO  */
317
318
	/* Always work with the same segment */
319
	currentSegment=getSegment();
320
321
	/* Grab some space within this segment */
322
	currentBufferOffset=_ioBuffers[currentSegment].offset;
323
	while(!ra_atomicCAS((int*)&_ioBuffers[currentSegment].offset, (int*)&currentBufferOffset, (int)(currentBufferOffset+length)));
324
325
	/* If there is room in this segment copy our data in.  Otherwise mark
326
	   this buffer to be flushed and increment the segment counter */
327
	if(currentBufferOffset+length<SEGMENT_SIZE)
328
	{
329
#ifdef MVS                    /* 174190 */
330
	if(!_jvmpiAgent_Options.jinsightFormat) {
331
	  s[length]='\0';         /* need to make the string null terminated for atoe conversion */
332
	  __atoe(s);
333
	}
334
#endif
335
		memcpy(&_ioBuffers[currentSegment].buffer[currentBufferOffset], s, length);
336
		success=TRUE;
337
	}
338
	else {
339
		/* printf("Flush pending\n"); */
340
		_ioBuffers[currentSegment].flushPending=TRUE;
341
342
		/* Increment the segment pointer */
343
		while(!ra_atomicCAS((int*)&_ioSegment, (int*)&currentSegment, (int)((currentSegment+1)%16)));
344
	}
345
346
	releaseSegment(currentSegment, currentBufferOffset);
347
348
	/* If we failed to transfer our data we need to try again */
349
	if(!success)
350
	{
351
		jvmpiAgent_print(tps, s, length);
352
	}
353
#endif /* _JVMPI__ASYNCRONOUS_IO */
354
355
  }
356
 }
357
}
358
359
/* REALLOCATE memory if the buffer size insufficient*******************************
360
 * Check buffer size and realloc memory to prevent 
361
 * buffer overflow.
362
 *
363
 */
364
void
365
jvmpiAgent_checkMemorySize(ThreadPrivateStorage *tps, 
366
						   int in_value,
367
						   unsigned short current)
368
{	
369
	if(in_value > REALLOCATED_BUFFER_SIZE){
370
		char *p = (char *)ra_allocateMessageBlock((ra_uint_t)(in_value+1) * sizeof(char));
371
	#ifdef __OS400__
372
		char *p2 = (char *)ra_allocateMessageBlock((ra_uint_t)(in_value+1) * sizeof(char));
373
	#endif	
374
		if(p != NULL && tps->buffer != NULL){			
375
			memcpy(p, tps->buffer, current);
376
			p[current] = '\0';
377
			ra_freeMessageBlock((unsigned char *)tps->buffer);
378
			tps->buffer = (char *)p;
379
			REALLOCATED_BUFFER_SIZE = in_value+1;
380
	#ifdef __OS400__
381
			memcpy(p2, tps->buffer2, current);
382
			p2[current] = '\0';
383
			ra_freeMessageBlock((unsigned char *)tps->buffer2);
384
			tps->buffer2 = (char *)p2; 
385
			REALLOCATED_BUFFER_SIZE = in_value+1;
386
	#endif
387
		}
388
	}
389
}
390
391
/** INSERT_ELEMENT_START  ********************************************************
392
  * Creates an XML entry tag and places it immediately following the data header
393
  * of the provided buffer. DOES NO BOUNDS CHECKING.
394
  * with the name specified. This function
395
  * @param       elementName - The XML tage name
396
  * @param elementNameLength - the length of the element name
397
  * @param      buffer - The buffer to place the tag in (at the beginning)
398
  * @returns        >0 - the next index in the buffer free for writing.
399
  *                  0 -
400
  */
401
static unsigned short
402
jvmpiAgent_insertElementStart(const char *elementName,
403
							  unsigned short elementNameLength,
404
							  ThreadPrivateStorage *tps)
405
{ 
406
 if (!_jvmpiAgent_suspendIO)
407
 {
408
  tps->buffer[0]='<';
409
  memcpy(&tps->buffer[1], elementName, elementNameLength);
410
  return elementNameLength+1;
411
 }
412
 return 0;
413
}
414
static unsigned short
415
jvmpiAgent_appendInt16(char *buffer,
416
						 unsigned short offset,
417
						 unsigned short value) {
418
	buffer[offset++]=(unsigned char)value>>8 & 0x00ff;
419
	buffer[offset++]=(unsigned char)value;
420
	return offset;
421
}
422
423
static unsigned short
424
jvmpiAgent_appendInt32(char *buffer,
425
						 unsigned short offset,
426
						 unsigned long value) {
427
	buffer[offset++]=(unsigned char)value>>24 & 0x000000ff;
428
	buffer[offset++]=(unsigned char)value>>16 & 0x000000ff;
429
	buffer[offset++]=(unsigned char)value>>8  & 0x000000ff;
430
	buffer[offset++]=(unsigned char)value;
431
	return offset;
432
}
433
434
435
/** APPEND_INTEGER_ATTRIBUTE  **********************************************************
436
  */
437
static unsigned short
438
jvmpiAgent_appendIntegerAttribute(const char *attributeName,
439
						 unsigned short attributeNameLength,
440
						 unsigned short offset,
441
						 int value,
442
						 char *buffer)
443
{
444
#ifdef _WIN32
445
 buffer[offset++]=' ';
446
 memcpy(&buffer[offset], attributeName, attributeNameLength);
447
 offset+=attributeNameLength;
448
 buffer[offset++]='=';
449
 buffer[offset++]='\"';
450
 /* We could optimize this conversion by writing assembley language
451
	   and keepin track of the offset, instead we will convert using itoa
452
	   and then add the length of this string to the offset */
453
 itoa(value, &buffer[offset], 10);
454
 offset+=strlen(&buffer[offset]);
455
 buffer[offset++]='\"';
456
 return offset;
457
#else
458
	int length;
459
#ifdef MVS                    /* 174190 */
460
#pragma convlit(suspend)
461
   char intstr[20];
462
   length=sprintf(intstr,"=\"%d\"",value);
463
   __etoa(intstr);
464
	length=sprintf(&buffer[offset], "%c%s%s", 0x20, attributeName, intstr);
465
#pragma convlit(resume)
466
#else
467
	length=sprintf(&buffer[offset], " %s=\"%d\"", attributeName, value);
468
#endif
469
	return offset+length;
470
#endif
471
}
472
473
474
475
/** APPEND_INTEGER_64_ATTRIBUTE  **********************************************************
476
  */
477
static unsigned short
478
jvmpiAgent_appendInteger64Attribute(const char *attributeName,
479
						   unsigned short attributeNameLength,
480
						   unsigned short offset,
481
						   Uint64 value,
482
						   char *buffer)
483
{
484
#ifdef _WIN32
485
 buffer[offset++]=' ';
486
 memcpy(&buffer[offset], attributeName, attributeNameLength);
487
 offset+=attributeNameLength;
488
 buffer[offset++]='=';
489
 buffer[offset++]='\"';
490
 /* This is a Microsoft specific conversion routine */
491
 _ui64toa(value, &buffer[offset], 10);
492
 offset+=strlen(&buffer[offset]);
493
 buffer[offset++]='\"';
494
 return offset;
495
#else
496
	int length;
497
#ifdef MVS                    /* 174190 */
498
#pragma convlit(suspend)
499
   char intstr[50];
500
   length=sprintf(intstr,"=\"%lu\"",value); /*fix 89008*/
501
   __etoa(intstr);
502
	length=sprintf(&buffer[offset], "%c%s%s", 0x20, attributeName, intstr);
503
#pragma convlit(resume)
504
#else
505
	length=sprintf(&buffer[offset], " %s=\"%lu\"", attributeName, value); /*fix 89008*/
506
#endif
507
	return offset+length;
508
#endif
509
}
510
511
512
/** APPEND_LONG_ATTRIBUTE  **********************************************************
513
  */
514
static unsigned short
515
jvmpiAgent_appendLongAttribute(const char *attributeName,
516
					      unsigned short attributeNameLength,
517
					      unsigned short offset,
518
					      long value,
519
					      char *buffer)
520
{
521
#ifdef _WIN32
522
 buffer[offset++]=' ';
523
 memcpy(&buffer[offset], attributeName, attributeNameLength);
524
 offset+=attributeNameLength;
525
 buffer[offset++]='=';
526
 buffer[offset++]='\"';
527
 /* We could optimize this conversion by writing assembley language
528
	   and keepin track of the offset, instead we will convert using itoa
529
	   and then add the length of this string to the offset */
530
 ltoa(value, &buffer[offset], 10);
531
 offset+=strlen(&buffer[offset]);
532
 buffer[offset++]='\"';
533
 return offset;
534
#else
535
	int length;
536
#ifdef MVS                    /* 174190 */
537
#pragma convlit(suspend)
538
   char intstr[50];
539
   length=sprintf(intstr,"=\"%ld\"",value); /*fix 89008*/
540
   __etoa(intstr);
541
	length=sprintf(&buffer[offset], "%c%s%s", 0x20, attributeName, intstr);
542
#pragma convlit(resume)
543
#else
544
	length=sprintf(&buffer[offset], " %s=\"%ld\"", attributeName, value); /*fix 89008*/
545
#endif
546
	return offset+length;
547
#endif
548
}
549
550
static unsigned short
551
jvmpiAgent_appendUnsignedLongAttribute(const char *attributeName,
552
						      unsigned short attributeNameLength,
553
						      unsigned short offset,
554
						      unsigned long value,
555
						      char *buffer)
556
{
557
#ifdef _WIN32
558
 buffer[offset++]=' ';
559
 memcpy(&buffer[offset], attributeName, attributeNameLength);
560
 offset+=attributeNameLength;
561
 buffer[offset++]='=';
562
 buffer[offset++]='\"';
563
 /* We could optimize this conversion by writing assembley language
564
	   and keepin track of the offset, instead we will convert using itoa
565
	   and then add the length of this string to the offset */
566
 ultoa(value, &buffer[offset], 10);
567
 offset+=strlen(&buffer[offset]);
568
 buffer[offset++]='\"';
569
 return offset;
570
#else
571
	int length;
572
#ifdef MVS                    /* 174190 */
573
#pragma convlit(suspend)
574
   char intstr[50];
575
   length=sprintf(intstr,"=\"%lu\"",value); /*fix 89008*/
576
   __etoa(intstr);
577
	length=sprintf(&buffer[offset], "%c%s%s", 0x20, attributeName, intstr);
578
#pragma convlit(resume)
579
#else
580
	length=sprintf(&buffer[offset], " %s=\"%lu\"", attributeName, value); /*fix 89008*/
581
#endif
582
	return offset+length;
583
#endif
584
}
585
586
static unsigned short
587
jvmpiAgent_appendListInteger(unsigned short offset,
588
					    int value,
589
					    char *buffer)
590
{
591
#ifdef _WIN32
592
 /* Overwrite the previously appended space  */
593
 buffer[offset-1]=',';
594
 ltoa(value, &buffer[offset], 10);
595
 offset+=strlen(&buffer[offset]);
596
 buffer[offset++]='\"';
597
 return offset;
598
#else
599
	int length;
600
	buffer[offset-1]=',';
601
#ifdef MVS                    /* 174190 */
602
#pragma convlit(suspend)
603
#endif
604
	length=sprintf(&buffer[offset], "%d\"", value);
605
#ifdef MVS                    /* 174190 */
606
  buffer[offset+length]='\0';
607
#pragma convlit(resume)
608
  __etoa(buffer+offset);
609
#endif
610
	return offset+length;
611
#endif
612
}
613
614
static unsigned short
615
jvmpiAgent_appendListUnsignedLong(unsigned short offset,
616
						 unsigned long value,
617
						 char *buffer)
618
{
619
#ifdef _WIN32
620
 /* Overwrite the previously appended space  */
621
 buffer[offset-1]=',';
622
 ultoa(value, &buffer[offset], 10);
623
 offset+=strlen(&buffer[offset]);
624
 buffer[offset++]='\"';
625
 return offset;
626
#else
627
	int length;
628
	buffer[offset-1]=',';
629
#ifdef MVS                    /* 174190 */
630
#pragma convlit(suspend)
631
#endif
632
	length=sprintf(&buffer[offset], "%u\"", value);
633
#ifdef MVS                    /* 174190 */
634
  buffer[offset+length]='\0';
635
#pragma convlit(resume)
636
  __etoa(buffer+offset);
637
#endif
638
	return offset+length;
639
#endif
640
}
641
642
643
/** APPEND_STRING_ATTRIBUTE  **********************************************************
644
  */
645
646
/* 50273
647
 * KC: Certain characters occurring in string attributes must be escaped
648
 * to make them palatabale to XML. For example, '>' better show up as
649
 * '&gt;'. The code below is in support of these conversions, on behalf
650
 * of jvmpiAgent_appendStringAttribute.
651
 */
652
#ifndef MAX
653
#define MAX(a,b) ((a) >= (b) ? (a) : (b))
654
#endif
655
656
#define MAX_ESCAPED_STRING_SIZE 7
657
typedef struct escape_seq
658
{
659
	char s[MAX_ESCAPED_STRING_SIZE];
660
	int  len;
661
} escape_seq_t;
662
663
/* ordering in escapees must match that in escape_str table */
664
665
#ifdef __OS400__ 
666
#pragma convert(819)
667
#endif
668
669
const char escapees[] = "<>&\"'";
670
static const escape_seq_t escape_str[] =
671
  {
672
	{/* < */ "&lt;",   sizeof("&lt;") - 1},
673
	{/* > */ "&gt;",   sizeof("&gt;") - 1},
674
	{/* & */ "&amp;",  sizeof("&amp;") - 1},
675
	{/* " */ "&quot;", sizeof("&quot;") - 1},
676
	{/* ' */ "&apos;", sizeof("&apos;") - 1},
677
	{"", 0}
678
  };
679
680
#ifdef __OS400__ /* 239987 starts */
681
#pragma convert(0)
682
#endif
683
684
/* To accomodate escape strings, we need to alloc some extra space.
685
 * Do it in chunks instead of one string at a time, to minimize
686
 * the allocation thrash. */
687
#define XML_ESCAPE_CHUNK_SIZE 128
688
689
690
typedef struct range {
691
	unsigned char lower; 
692
	unsigned char upper; 
693
} Range; 
694
695
696
/* This table of values is based on Table 3-6 "Well-formed UTF-8
697
Byte Sequences", available at 
698
http://www.unicode.org/versions/Unicode4.0.0/ch03.pdf
699
700
Entries with 0x00 as the upper part of the range are NOT part of
701
the expected byte sequence in a well-formed utf-8 byte sequence. 
702
For example, for utf8Table[1], the first character seen in the valid
703
byte sequence is between 0xC2 and 0xDF, and the next must be between 0x80
704
and 0xBF. Since utf8Table[1][2].upper is 0x00, the next character beyond this 
705
is considered to be part of the "next" byte sequence. 
706
*/ 
707
708
Range utf8Table[][4] = 
709
{ 
710
	{ {0x00,0x7F},{0x00,0x00},{0x00,0x00}, {0x00,0x00} },
711
	{ {0xC2,0xDF},{0x80,0xBF},{0x00,0x00}, {0x00,0x00} },
712
	{ {0xE0,0xE0},{0xA0,0xBF},{0x80,0xBF}, {0x00,0x00} },
713
	{ {0xE1,0xEC},{0x80,0xBF},{0x80,0xBF}, {0x00,0x00} },
714
	{ {0xED,0xED},{0x80,0x9F},{0x80,0xBF}, {0x00,0x00} },
715
	{ {0xEE,0xEF},{0x80,0xBF},{0x80,0xBF}, {0x00,0x00} },
716
	{ {0xF0,0xF0},{0x90,0xBF},{0x80,0xBF}, {0x80,0xBF} },
717
	{ {0xF1,0xF3},{0x80,0xBF},{0x80,0xBF}, {0x80,0xBF} },
718
	{ {0xF4,0xF4},{0x80,0x8F},{0x80,0xBF}, {0x80,0xBF} }
719
}; 
720
721
722
723
/* stripControls(const char *inbuf, char **outBuf)
724
 
725
   Strip invalid UTF-8 characters. 
726
727
   This function strips invalid UTF-8 characters by verifying that the
728
   byte sequences within the buffer provided (inbuf) are valid according
729
   to the "Well-formed UTF-8 Byte Sequences" table. 
730
731
   @param inbuf the buffer to strip of invalid utf-8 characters
732
   @param outBuf the buffer into which to put the stripped version of inbuf
733
   @return outBuf if any characters were stripped from inbuf, NULL otherwise. 
734
*/ 
735
static char* 
736
stripControls(const unsigned char *inbuf, unsigned char **outBuf) {
737
	const unsigned char * end;
738
	unsigned char *offset=NULL;
739
	unsigned char *current=(unsigned char*)inbuf;
740
	end=inbuf+strlen((const char *)inbuf);
741
	while(current<end) {
742
		int idx, row = -1, 	numCharsToStrip = 0, numCharsToPass = 1; 
743
744
		/* we first determine the row of the UTF-8 table that we are dealing 
745
		with. This will allow us to examine the byte sequence to see
746
		if the individual bytes fall within the expected range as laid out in 
747
		the table. */ 
748
		for (idx = 0; idx < 9; idx++) {
749
			if (*current >= utf8Table[idx][0].lower &&
750
				*current <= utf8Table[idx][0].upper) {
751
					row = idx; 
752
					break; 
753
			}
754
		}
755
756
757
		/* If we were unable to determine the row, then this character
758
		   comprises an ill-formed byte-sequence and should be stripped */ 
759
		if (row == -1) {
760
			numCharsToStrip = 1; 
761
		}
762
763
		/* If we are dealing with the first row, then this is a standard ASCII
764
	       character and we must check if there are any control characters 
765
		   to be stripped */ 
766
		else if (row == 0) {
767
			if (*current < 0x20) {
768
				switch (*current) {
769
					case 0x9: /* Horizontal TAB */ 
770
					case 0xA: /* New line */ 
771
					case 0xD: /* Carriage return */ 
772
						break; /* do not strip the character */ 
773
					default:
774
						numCharsToStrip = 1; /* strip the character */
775
						break;  
776
				}
777
			}
778
		}
779
780
		/* Otherwise verify that each byte in the byte-sequence
781
		falls within the required range as dictated by the utf-8 table */ 
782
		else {
783
			for (idx = 1; idx < 4 && current+idx < end &&  
784
				utf8Table[row][idx].upper != 0x00; idx++) {
785
					if (*(current+idx) < utf8Table[row][idx].lower ||
786
						*(current+idx) > utf8Table[row][idx].upper) {
787
							/* We have detected an invalid byte in the
788
							   byte sequence. We can safely strip the 
789
							   bytes up to but not including the
790
							   current byte we are examining. */ 
791
							numCharsToStrip = idx;
792
							break;
793
					}
794
					else {
795
						numCharsToPass++; 
796
					}
797
			}
798
			/* If we fell off the end before the byte-sequence was expected
799
			   to finish then we should strip the characters */ 
800
			if (current + idx >= end && idx < 4 
801
				&& utf8Table[row][idx].upper != 0x00) {
802
                    numCharsToStrip = idx; 
803
			}
804
805
			/* Code points U+FFFE and U+FFFF are not valid XML -- we need
806
			the following special case to check for the UTF-8 encodings of these 
807
			code points and strip them */ 
808
			if (numCharsToStrip == 0 && row == 5 && idx == 3) {
809
				/* check for code points U+FFFE or U+FFFF */ 
810
				if ( (*current == 0xEF) && 
811
					 (*(current+1) == 0xBF) &&
812
					 ( (*(current+2) == 0xBE) || (*(current+2) == 0xBF) ) ) {
813
						 numCharsToStrip = 3; 
814
				}
815
			}
816
		}
817
818
		if (numCharsToStrip > 0) {
819
			/* if necessary create the new buffer into which we put 
820
			   the stripped version of the original buffer */ 
821
			if(!offset) {
822
				offset=(unsigned char*)malloc(strlen((const char *)inbuf));
823
				memcpy(offset, inbuf, current-inbuf);
824
				*outBuf=offset;
825
				offset+=current-inbuf;
826
			}
827
			current += numCharsToStrip; 
828
		}
829
		else if(offset) {
830
			if (numCharsToPass == 1) {
831
				/* we don't bother with the overhead calling the memcpy
832
				   function in the most frequent case */ 
833
				*offset++ = *current++; 
834
			}
835
			else {
836
				memcpy(offset,current,numCharsToPass); 
837
				offset += numCharsToPass; 
838
				current += numCharsToPass;
839
			}
840
		}
841
		else {
842
			current += numCharsToPass;
843
		}	 
844
	}
845
846
847
	if(offset) {
848
		*offset='\0';
849
		return (char *)*outBuf;
850
	}
851
	return NULL;
852
853
}
854
855
/* The basic idea is to locate and quickly copy the substrings
856
 * within inbuf that do not require escaping, then do something more
857
 * costly for handling the special characters. An assumption is made
858
 * that special chars will be few and far between, so the code is
859
 * optimized first for the case where there are no special chars
860
 * and then for large substrings of "normal" chars. */
861
static char*
862
escape_for_xml(const char *inbuf, char **outbuf)
863
{
864
	size_t span;				/* span of substr not requiring escape */
865
	char *op;					/* current loc in output buffer */
866
	char *start_op;				/* beginning of output buffer */
867
	char *end_op;				/* end of alloc'd output buffer */
868
	size_t out_len;				/* size of alloc'd output buffer */
869
	const char *ip;				/* current loc in inbuf */
870
	const char *end_ip;			/* ptr to terminating null in inbuf */
871
	size_t in_len = strlen(inbuf);
872
	
873
874
	/* Check the green path first */
875
	span = strcspn(inbuf, escapees);
876
	if (span == in_len) {
877
		/* No chars require escaping. We're outta here. */
878
		return NULL;
879
	}
880
881
	/* There are one or more escapable characters. */
882
	ip = inbuf;
883
	end_ip = inbuf + in_len;
884
885
	out_len = in_len + XML_ESCAPE_CHUNK_SIZE;
886
	start_op = (char*) malloc(out_len);
887
	end_op = start_op + out_len;
888
	op = start_op;
889
890
	while (ip < end_ip)
891
	{
892
		int i;
893
894
		/* do we need more space in output buffer? */
895
		if (op + span + MAX_ESCAPED_STRING_SIZE >= end_op)
896
		{
897
			size_t used = op - start_op;
898
899
			out_len += MAX(span+MAX_ESCAPED_STRING_SIZE,
900
							XML_ESCAPE_CHUNK_SIZE);
901
			start_op = (char*) realloc(start_op, out_len);
902
			op = start_op + used;		/* reset curr ptr in new buffer */
903
			end_op = start_op + out_len;
904
		}
905
906
		/* handle unescaped portion with straight copy */
907
		if (span > 0) {
908
			memcpy(op, ip, span);
909
			op += span;
910
			ip += span;
911
		}
912
913
		/* handle char requiring escaping */
914
		for (i = 0; escape_str[i].len > 0; i++) {
915
			if ( *ip == escapees[i] ) {
916
				memcpy(op, escape_str[i].s, escape_str[i].len);
917
				op += escape_str[i].len;
918
				ip++;
919
				break;
920
			}
921
		}
922
923
		/* are there any more chars requiring escaping? */
924
		span = strcspn(ip, escapees);
925
	}
926
	*op = '\0';
927
	*outbuf = start_op;
928
929
	return start_op;
930
}
931
932
static unsigned short
933
jvmpiAgent_appendStringAttribute(const char *attributeName,
934
												 unsigned short attributeNameLength,
935
												 unsigned short offset,
936
												 const char *in_value,
937
												 ThreadPrivateStorage *tps)
938
{
939
	int valLength;
940
	int addToBuffer;
941
	
942
	valLength= in_value ? strlen(in_value) : 0;
943
	
944
	addToBuffer = offset + 4 + attributeNameLength + valLength + 1;
945
	jvmpiAgent_checkMemorySize(tps, addToBuffer, offset);
946
	
947
	tps->buffer[offset++]=' ';
948
	memcpy(&tps->buffer[offset], attributeName, attributeNameLength);
949
	offset+=attributeNameLength;
950
	tps->buffer[offset++]='=';
951
	tps->buffer[offset++]='\"';
952
	if(valLength>0)
953
	{
954
		const char *value;
955
		const char *strippedValue=NULL;
956
957
		/* Strip invalid control characters from the string.  These will mess up the XML */
958
959
#ifdef __OS400__ 
960
		if( !strcmp(attributeName, APPLICATION_NAME_ATTRIBUTE) ||
961
			!strcmp(attributeName, GROUP_NAME_ATTRIBUTE) ||
962
			!strcmp(attributeName, NAME_ATTRIBUTE) ||
963
			!strcmp(attributeName, PARENT_NAME_ATTRIBUTE) ||
964
			!strcmp(attributeName, SOURCE_NAME_ATTRIBUTE) ||
965
			!strcmp(attributeName, SIGNATURE_ATTRIBUTE) ||
966
			!strcmp(attributeName, THREAD_NAME_ATTRIBUTE) ||
967
			!strcmp(attributeName, PATTERN_ATTRIBUTE) ||
968
			!strcmp(attributeName, METHOD_PATTERN_ATTRIBUTE)) {
969
#endif
970
		if(stripControls((unsigned char *)in_value, (unsigned char**)&strippedValue)) {
971
			valLength = strlen(strippedValue);
972
		}
973
		else {
974
			strippedValue=in_value;
975
		}
976
#ifdef __OS400__
977
		}
978
		else {
979
			strippedValue = in_value; 
980
		}
981
#endif 
982
983
		if (escape_for_xml(strippedValue, (char**)&value)) {	/* 50273 */
984
			/* we had to add escape sequences to input string */
985
			valLength = strlen(value);
986
		} else {
987
			/* nothing changed, use orig input, don't reset length */
988
			value = strippedValue;
989
		}
990
991
#ifdef __OS400__ /* 236501 */
992
		if( !strcmp(attributeName, APPLICATION_NAME_ATTRIBUTE) ||
993
			!strcmp(attributeName, GROUP_NAME_ATTRIBUTE) ||
994
			!strcmp(attributeName, NAME_ATTRIBUTE) ||
995
			!strcmp(attributeName, PARENT_NAME_ATTRIBUTE) ||
996
			!strcmp(attributeName, SOURCE_NAME_ATTRIBUTE) ||
997
			!strcmp(attributeName, SIGNATURE_ATTRIBUTE) ||
998
			!strcmp(attributeName, THREAD_NAME_ATTRIBUTE) ||
999
			!strcmp(attributeName, PATTERN_ATTRIBUTE) ||
1000
			!strcmp(attributeName, METHOD_PATTERN_ATTRIBUTE)) {
1001
			memcpy(&tps->buffer[offset], as400_atoe((char*)value), valLength); /* 232010 */
1002
		}
1003
		else {
1004
			memcpy(&tps->buffer[offset], (char*)value, valLength); /* 232010 */
1005
		}
1006
#else
1007
		memcpy(&tps->buffer[offset], value, valLength);
1008
	
1009
#endif
1010
1011
		if(strippedValue!=in_value) {
1012
			free((void*)strippedValue);
1013
		}
1014
1015
		if (value != strippedValue) {	/* 50273 */
1016
			/* pointing to buffer alloc'd by escape_for_xml */
1017
			free((void*)value);
1018
		}
1019
1020
	}
1021
	offset+=valLength;
1022
	tps->buffer[offset++]='\"';
1023
1024
	return offset;
1025
}
1026
1027
1028
/** APPEND_ELEMENT_END  ********************************************************
1029
  * Creates an XML closing tag and places in at the end of the provided buffer.
1030
  * If the elementName is NULL the entire buffer is appended with the closing
1031
  * tag.  If it is non-NULL the buffer is loaded with a closing tag with the
1032
  * specified name.  NOTE:  When a elementName is specified the buffer is trampled
1033
  * @param       elementName - The XML tag name, NULL for empty tag
1034
  * @param elementNameLength - length of the XML tag name, ignored if elementName=NULL
1035
  * @param            offset - the offset in the buffer to place the closing tag
1036
  * @param            buffer - The buffer to place the tag ending
1037
  * @returns			>0   - the length of the  entire element
1038
  */
1039
static unsigned short
1040
jvmpiAgent_appendElementEnd(const char *elementName,
1041
					   unsigned short elementNameLength,
1042
					   unsigned short offset,
1043
					   ThreadPrivateStorage *tps)
1044
{
1045
 if (!_jvmpiAgent_suspendIO)
1046
 {
1047
  if(elementName!=NULL)
1048
  {
1049
   memcpy(&tps->buffer[offset], elementName, elementNameLength);
1050
   offset+=elementNameLength;
1051
  }
1052
  memcpy(&tps->buffer[offset], "/>", 2);
1053
 }
1054
 return offset+2;
1055
}
1056
1057
1058
1059
/*
1060
 * Used to start a new empty element
1061
 */
1062
static unsigned short
1063
jvmpiAgent_insertEmptyEventHeader(JNIEnv *env_id,
1064
								  ThreadPrivateStorage *tps,
1065
								  const char *eventName,
1066
								  unsigned short eventNameLength)
1067
{
1068
 unsigned short current=0;
1069
 if (!_jvmpiAgent_suspendIO)
1070
 {
1071
  current=jvmpiAgent_insertElementStart(eventName, eventNameLength, tps);
1072
  if (jvmpiAgent_isPrintStaticId())
1073
  {
1074
   current=jvmpiAgent_appendIntegerAttribute(STATIC_THREAD_IDREF_ATTRIBUTE,
1075
					 STRLEN_STATIC_THREAD_IDREF_ATTRIBUTE,
1076
					 current,
1077
					 tps->staticThreadId,
1078
					 tps->buffer);
1079
  }
1080
  if (jvmpiAgent_isPrintObjId())
1081
  {
1082
   current=jvmpiAgent_appendIntegerAttribute(THREAD_IDREF_ATTRIBUTE,
1083
					STRLEN_THREAD_IDREF_ATTRIBUTE,
1084
					current,
1085
					(jint)env_id,
1086
					tps->buffer);
1087
  }
1088
 }
1089
 return current;
1090
}
1091
1092
/*
1093
 * Used to start a new empty element
1094
 */
1095
static unsigned short
1096
jvmpiAgent_insertEmptyEventHeader1(JNIEnv *env_id,
1097
								   ThreadPrivateStorage *tps,
1098
								   const char *eventName,
1099
								   unsigned short eventNameLength)
1100
{
1101
 unsigned short current=0;
1102
 if (!_jvmpiAgent_suspendIO)
1103
 {
1104
  current=jvmpiAgent_insertElementStart(eventName, eventNameLength, tps);
1105
  if (jvmpiAgent_isPrintStaticId())
1106
  {
1107
   current=jvmpiAgent_appendIntegerAttribute(STATIC_THREAD_ID_ATTRIBUTE,
1108
				STRLEN_STATIC_THREAD_ID_ATTRIBUTE,
1109
				current,
1110
				tps->staticThreadId,
1111
				tps->buffer);
1112
  }
1113
  if (jvmpiAgent_isPrintObjId())
1114
  {
1115
   current=jvmpiAgent_appendIntegerAttribute(THREAD_ID_ATTRIBUTE,
1116
				STRLEN_THREAD_ID_ATTRIBUTE,
1117
				current,
1118
				(jint)env_id,
1119
				tps->buffer);
1120
  }
1121
 }
1122
 return current;
1123
}
1124
1125
static unsigned short
1126
jvmpiAgent_printTraceIdrefAttribute(ThreadPrivateStorage *tps,
1127
									unsigned short current)
1128
{
1129
 if (_jvmpiAgent_Options.traceIdrefs)
1130
 {
1131
  return jvmpiAgent_appendStringAttribute(TRACE_IDREF_ATTRIBUTE, STRLEN_TRACE_IDREF_ATTRIBUTE, current, _jvmpiAgent_trace_id , tps);
1132
 }
1133
 else
1134
 {
1135
  return current;
1136
 }
1137
}
1138
1139
1140
/** APPEND__LABELED_TIMESTAMP  ****************************************************
1141
  *
1142
  */
1143
static unsigned short
1144
jvmpiAgent_appendLabeledTimestamp(char *buffer,
1145
				  unsigned short offset,
1146
				  const char *attributeName,
1147
				  unsigned short attributeNameLength,
1148
				  timestamp_t time,
1149
				  BOOL asInterval) {
1150
#ifdef MVS                    /* 174190 */
1151
   int mycurr;
1152
#endif
1153
1154
 
1155
 buffer[offset++]=' ';
1156
 memcpy(&buffer[offset], attributeName, attributeNameLength);
1157
 offset+=attributeNameLength;
1158
 buffer[offset++]='=';
1159
 buffer[offset++]='\"';
1160
1161
#ifdef MVS                    /* 174190 */
1162
   mycurr = offset;
1163
#pragma convlit(suspend)
1164
#endif
1165
1166
 /* convert the time to a string using helper method that is locale-insensitive */ 
1167
 offset = double2string(ticksToTime2(time, asInterval),buffer,offset,9); 
1168
1169
 buffer[offset++]='\"';
1170
#ifdef MVS                    /* 174190 */
1171
  buffer[offset]='\0';
1172
#pragma convlit(resume)
1173
  __etoa(buffer+mycurr);
1174
#endif
1175
 return offset;
1176
}
1177
1178
/** APPEND_TIMESTAMP  ****************************************************
1179
  *
1180
  */
1181
static unsigned short
1182
jvmpiAgent_appendTimestamp(char *buffer,
1183
						   unsigned short offset,
1184
						   timestamp_t time)
1185
{
1186
  return jvmpiAgent_appendLabeledTimestamp(buffer, offset, TIME_ATTRIBUTE, STRLEN_TIME_ATTRIBUTE, time, FALSE);
1187
}
1188
1189
1190
static unsigned short
1191
jvmpiAgent_appendOverhead(char *buffer,
1192
						   unsigned short offset,
1193
						   Uint64 time)
1194
{
1195
  return jvmpiAgent_appendLabeledTimestamp(buffer, offset, OVERHEAD_ATTRIBUTE, STRLEN_OVERHEAD_ATTRIBUTE, time, TRUE);
1196
}
1197
1198
/** APPEND_TIMESTAMP  ****************************************************
1199
  *
1200
  */
1201
static unsigned short
1202
jvmpiAgent_appendString(char *buffer,
1203
						unsigned short offset,
1204
						const char *value)
1205
{
1206
	int length=strlen(value);
1207
	memcpy(&buffer[offset], value, length+1);
1208
	return offset+length+1;
1209
}
1210
1211
1212
1213
1214
/** PRINT_COLLATION_VALUE_ATTRIBUTE  **********************************************
1215
  */
1216
static unsigned short
1217
jvmpiAgent_printCollationValueAttribute(char *buffer,
1218
										unsigned short current,
1219
										SegmentedValue_t *collationValue)
1220
{
1221
 if (_jvmpiAgent_Options.collationValues)
1222
 {
1223
#ifdef SEGMENTED_VALUE_MULTIWORD
1224
  unsigned long i;
1225
  current=jvmpiAgent_appendUnsignedLongAttribute(COLLATION_VALUE_ATTRIBUTE, STRLEN_COLLATION_VALUE_ATTRIBUTE, current, collationValue->values[0], buffer);
1226
  for (i = 1; i < collationValue->numberOfWords; i++)
1227
  {
1228
   current=jvmpiAgent_appendListUnsignedLong(current, collationValue->values[i], buffer);
1229
  }
1230
#else
1231
  current=jvmpiAgent_appendUnsignedLongAttribute(COLLATION_VALUE_ATTRIBUTE, STRLEN_COLLATION_VALUE_ATTRIBUTE, current, collationValue->value, buffer);
1232
#endif
1233
 }
1234
 return current;
1235
}
1236
1237
/*
1238
 * Handles the output of a METHOD_COUNT element and attributes.
1239
 */
1240
static int
1241
jvmpiAgent_printMethodCount(HashEntry *hashEntry, void * parm)
1242
{
1243
1244
 if (!_jvmpiAgent_suspendIO && CLASS_ENTRY(METHOD_ENTRY(hashEntry)->classHashEntry)->traceFlag 
1245
	 && METHOD_ENTRY(hashEntry)->traceFlag)
1246
 {
1247
  ThreadPrivateStorage *tps=(ThreadPrivateStorage*)parm;
1248
   unsigned short current=0;
1249
  jvmpiAgent_outputMethodDeclaration(hashEntry, tps);
1250
  current=jvmpiAgent_insertElementStart(METHOD_COUNT_ELEMENT, STRLEN_METHOD_COUNT_ELEMENT, tps);
1251
  current=jvmpiAgent_appendIntegerAttribute(STATIC_METHOD_IDREF_ATTRIBUTE, STRLEN_STATIC_METHOD_IDREF_ATTRIBUTE, current, METHOD_ENTRY(hashEntry)->static_id, tps->buffer);
1252
  current=jvmpiAgent_appendIntegerAttribute(COUNT_ATTRIBUTE, STRLEN_COUNT_ATTRIBUTE, current, METHOD_ENTRY(hashEntry)->methodCount, tps->buffer);
1253
1254
  /*##MW There is a race condition between the increment and the print that must be fixed */
1255
  jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
1256
  current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
1257
1258
  current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
1259
  current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
1260
  jvmpiAgent_print(tps, tps->buffer, current);
1261
 }
1262
 return 0;
1263
}
1264
1265
1266
/** PRINT_OPTION  **********************************************************
1267
  * Outputs an OPTION element
1268
  */
1269
void
1270
jvmpiAgent_PrintOption(ThreadPrivateStorage *tps,
1271
					   char *key,
1272
					   char *value)
1273
{
1274
 unsigned short current=0;
1275
 if (!_jvmpiAgent_suspendIO)
1276
 { 
1277
	 current=jvmpiAgent_insertElementStart(OPTION_ELEMENT, STRLEN_OPTION_ELEMENT, tps);
1278
	 current=jvmpiAgent_appendStringAttribute(KEY_ATTRIBUTE,
1279
		 STRLEN_KEY_ATTRIBUTE,
1280
		 current,
1281
		 key,
1282
		 tps);
1283
	 current=jvmpiAgent_appendStringAttribute(VALUE_ATTRIBUTE,
1284
		 STRLEN_VALUE_ATTRIBUTE,
1285
		 current,
1286
		 value,
1287
		 tps);
1288
	 current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
1289
	 jvmpiAgent_print(tps, tps->buffer, current);	 
1290
 }
1291
}
1292
1293
unsigned short jvmpiAgent_appendCurrentTimeStamp(char *buffer,
1294
						 unsigned short offset)
1295
{
1296
 timestamp_t timestamp;
1297
 jvmpiAgent_getCurrentTime(&timestamp);
1298
 return jvmpiAgent_appendTimestamp(buffer, offset, timestamp);
1299
}
1300
1301
1302
1303
1304
/* Append the Thread CPU time. 
1305
1306
  This function appends the cumulative cpuTime into the trace. It assumes the time value
1307
  passed in is in nanoseconds (the JVMPI method GetCurrentThreadCPUTime() returns
1308
  values in units of nanoseconds). 
1309
1310
   @param buffer the buffer to write to
1311
   @param offset the offset into the buffer where we're writing
1312
   @param time the cumulative cpu time to put into the trace element (in nanoseconds) 
1313
*/ 
1314
 
1315
static unsigned short
1316
jvmpiAgent_appendThreadCPUTime(char *buffer,
1317
					      unsigned short offset,
1318
					      Uint64 time)
1319
{
1320
1321
  /* convert the time into a double value. This allows us to use our
1322
	utility function double2string to properly output the timestamp */ 
1323
#ifdef _WIN32
1324
 double ts_double = ((double) (signed __int64)time) / ((double)1000000000); 
1325
#else
1326
 double ts_double = ((double)time) / ((double)1000000000); 
1327
#endif 
1328
1329
1330
#ifdef MVS                    /* 174190 */
1331
   int mycurr;
1332
#endif
1333
 
1334
 buffer[offset++]=' ';
1335
 memcpy(&buffer[offset], THREAD_CPU_TIME_ATTRIBUTE, STRLEN_THREAD_CPU_TIME_ATTRIBUTE);
1336
 offset+=STRLEN_THREAD_CPU_TIME_ATTRIBUTE;
1337
 buffer[offset++]='=';
1338
 buffer[offset++]='\"';
1339
1340
#ifdef MVS                    /* 174190 */
1341
   mycurr = offset;
1342
#pragma convlit(suspend)
1343
#endif
1344
1345
 /* convert the time to a string using helper method that is locale-insensitive */ 
1346
offset = double2string(ts_double,buffer,offset,9); 
1347
1348
 buffer[offset++]='\"';
1349
#ifdef MVS                    /* 174190 */
1350
  buffer[offset]='\0';
1351
#pragma convlit(resume)
1352
  __etoa(buffer+mycurr);
1353
#endif
1354
 return offset;
1355
}
1356
1357
1358
/** PRINT_FILTER  **********************************************************
1359
  * Outputs a FILTER element
1360
  */
1361
void
1362
jvmpiAgent_printFilter(ThreadPrivateStorage *tps,
1363
					   Filter *filter) {
1364
    if (!_jvmpiAgent_suspendIO) {
1365
1366
        unsigned short current=0;
1367
        char *startPattern;
1368
		
1369
        current=jvmpiAgent_insertElementStart(FILTER_ELEMENT, STRLEN_FILTER_ELEMENT, tps);
1370
        startPattern=tps->buffer+current;
1371
		current=jvmpiAgent_appendStringAttribute(PATTERN_ATTRIBUTE, STRLEN_PATTERN_ATTRIBUTE, current, filter->pattern, tps);
1372
1373
		*(tps->buffer + current) = '\0';
1374
1375
        /* RKD:  If the pattern contains any '/' replace these with '.' */
1376
        while((startPattern=strchr(startPattern, '/'))) {
1377
	        *startPattern=(char)'.';
1378
        }
1379
1380
        if (jvmpiAgent_getClassFilterMode(filter) == INCLUDE) {
1381
            current=jvmpiAgent_appendStringAttribute(CLASS_MODE_ATTRIBUTE, STRLEN_CLASS_MODE_ATTRIBUTE, current, INCLUDE_VALUE, tps);
1382
        }
1383
        else {
1384
            current=jvmpiAgent_appendStringAttribute(CLASS_MODE_ATTRIBUTE, STRLEN_CLASS_MODE_ATTRIBUTE, current, EXCLUDE_VALUE, tps);
1385
        }
1386
        if (filter->genericPattern == NONE) {
1387
            current=jvmpiAgent_appendStringAttribute(GENERICPATTERN_ATTRIBUTE, STRLEN_GENERICPATTERN_ATTRIBUTE, current, NONE_VALUE, tps);
1388
        }
1389
        else if (filter->genericPattern == PREFIX) {
1390
            current=jvmpiAgent_appendStringAttribute(GENERICPATTERN_ATTRIBUTE, STRLEN_GENERICPATTERN_ATTRIBUTE, current, PREFIX_VALUE, tps);
1391
        }
1392
        else {
1393
            current=jvmpiAgent_appendStringAttribute(GENERICPATTERN_ATTRIBUTE, STRLEN_GENERICPATTERN_ATTRIBUTE, current, SUFFIX_VALUE, tps);
1394
        }
1395
1396
        if(filter->methodDetailCount>0) {
1397
            unsigned int i;
1398
            for(i=0; i<filter->methodDetailCount;i++) {
1399
                unsigned short offset=current;
1400
				offset=jvmpiAgent_appendStringAttribute(METHOD_PATTERN_ATTRIBUTE, STRLEN_METHOD_PATTERN_ATTRIBUTE, offset, filter->methodDetails[i].pattern, tps);
1401
				
1402
				if (filter->methodDetails[i].mode == INCLUDE)
1403
				{
1404
					offset=jvmpiAgent_appendStringAttribute(METHOD_MODE_ATTRIBUTE, STRLEN_METHOD_MODE_ATTRIBUTE, offset, INCLUDE_VALUE, tps);
1405
				}
1406
				else
1407
				{
1408
					offset=jvmpiAgent_appendStringAttribute(METHOD_MODE_ATTRIBUTE, STRLEN_METHOD_MODE_ATTRIBUTE, offset, EXCLUDE_VALUE, tps);
1409
				}
1410
1411
                if (filter->methodDetails[i].genericPattern == NONE) {
1412
                    offset=jvmpiAgent_appendStringAttribute(METHOD_GENERICPATTERN_ATTRIBUTE, STRLEN_METHOD_GENERICPATTERN_ATTRIBUTE, offset, NONE_VALUE, tps);
1413
                }
1414
                else if (filter->methodDetails[i].genericPattern == PREFIX) {
1415
                    offset=jvmpiAgent_appendStringAttribute(METHOD_GENERICPATTERN_ATTRIBUTE, STRLEN_METHOD_GENERICPATTERN_ATTRIBUTE, offset, PREFIX_VALUE, tps);
1416
                }
1417
                else {
1418
                    offset=jvmpiAgent_appendStringAttribute(METHOD_GENERICPATTERN_ATTRIBUTE, STRLEN_METHOD_GENERICPATTERN_ATTRIBUTE, offset, SUFFIX_VALUE, tps);
1419
                }
1420
1421
                offset=jvmpiAgent_printTraceIdrefAttribute(tps, offset);
1422
                offset=jvmpiAgent_appendElementEnd(NULL, 0, offset, tps);
1423
                jvmpiAgent_print(tps, tps->buffer, offset);
1424
            }
1425
        }
1426
        else {
1427
            current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
1428
            current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
1429
            jvmpiAgent_print(tps, tps->buffer, current);
1430
        }
1431
    }
1432
}
1433
1434
/*
1435
 This function ensures that the string name can be legally output as XML by translating any
1436
 '<' or '>" characters to '-'.
1437
*/
1438
char * jvmpiAgent_formatName(char *name)
1439
{
1440
	int i;
1441
	if (name)
1442
	{
1443
		for (i=strlen(name)-1; i >=0; i--)
1444
		{
1445
#ifdef __OS400__
1446
#pragma convert(819) /* 236501 */
1447
#endif
1448
			if (name[i] == '<' || name[i] == '>') name[i] = '-';
1449
#ifdef __OS400__
1450
#pragma convert(0)
1451
#endif
1452
		}
1453
	}
1454
	return name;
1455
}
1456
1457
1458
/** PRINT_METHOD  **********************************************************
1459
  * Handles the output of a METHOD element and attributes
1460
  */
1461
void jvmpiAgent_printMethod(MethodEntry *methodEntry,
1462
							ThreadPrivateStorage *tps)
1463
{
1464
 if (!_jvmpiAgent_suspendIO && (_jvmpiAgent_Options.stackInfo > StackInfoNone || _jvmpiAgent_Options.methodCounts))
1465
 {
1466
  unsigned short current=0;
1467
1468
  if(_jvmpiAgent_Options.jinsightFormat)
1469
  {
1470
#ifdef BINARY_TRACE
1471
    unsigned short numBytes = BINARYTRACE_printMethodDefine(tps->buffer, methodEntry);
1472
    jvmpiAgent_print(tps, tps->buffer, numBytes);
1473
#endif /* BINARY_TRACE */
1474
  }
1475
  else
1476
  {
1477
    current=jvmpiAgent_insertElementStart(METHOD_ELEMENT, STRLEN_METHOD_ELEMENT, tps);
1478
    current=jvmpiAgent_appendStringAttribute(NAME_ATTRIBUTE, STRLEN_NAME_ATTRIBUTE, current, jvmpiAgent_formatName(methodEntry->methodData.method_name), tps);
1479
    current=jvmpiAgent_appendStringAttribute(SIGNATURE_ATTRIBUTE, STRLEN_SIGNATURE_ATTRIBUTE, current, methodEntry->methodData.method_signature, tps);
1480
1481
    /* A.M: Print the method detail attribute if the proper option is set */
1482
	if (_jvmpiAgent_Options.methodDetails)
1483
	{
1484
        /* Visibility */
1485
        if(methodEntry->isPrivate) {
1486
            current=jvmpiAgent_appendStringAttribute(VISIBILITY_ATTRIBUTE, STRLEN_VISIBILITY_ATTRIBUTE, current, "private", tps);
1487
        }
1488
        else if(methodEntry->isProtected) {
1489
            current=jvmpiAgent_appendStringAttribute(VISIBILITY_ATTRIBUTE, STRLEN_VISIBILITY_ATTRIBUTE, current, "protected", tps);
1490
        }
1491
        else if(methodEntry->isPublic) {
1492
            current=jvmpiAgent_appendStringAttribute(VISIBILITY_ATTRIBUTE, STRLEN_VISIBILITY_ATTRIBUTE, current, "public", tps);
1493
        }
1494
1495
		/* isNative? */
1496
		current=jvmpiAgent_appendStringAttribute(IS_NATIVE_ATTRIBUTE, STRLEN_IS_NATIVE_ATTRIBUTE, current, (methodEntry->isNative ? "true" : "false"), tps);
1497
		/* isAbstract? */
1498
		current=jvmpiAgent_appendStringAttribute(IS_ABSTRACT_ATTRIBUTE, STRLEN_IS_ABSTRACT_ATTRIBUTE, current, (methodEntry->isAbstract ? "true" : "false"), tps);
1499
		/* isStatic? */
1500
		current=jvmpiAgent_appendStringAttribute(IS_STATIC_ATTRIBUTE, STRLEN_IS_STATIC_ATTRIBUTE, current, (methodEntry->isStatic ? "true" : "false"), tps);
1501
		/* isSynchronized? */
1502
		current=jvmpiAgent_appendStringAttribute(IS_SYNCHRONIZED_ATTRIBUTE, STRLEN_IS_SYNCHRONIZED_ATTRIBUTE, current, (methodEntry->isSynchronized ? "true" : "false"), tps);
1503
1504
		/* Exceptions */
1505
        if (methodEntry->exceptions != (int)NULL && strlen(methodEntry->exceptions) != (int)NULL) {
1506
			current=jvmpiAgent_appendStringAttribute(EXCEPTIONS_ATTRIBUTE, STRLEN_EXCEPTIONS_ATTRIBUTE, current, methodEntry->exceptions, tps);
1507
        }
1508
1509
	}
1510
1511
    if (methodEntry->methodData.start_lineno != -1)
1512
	{
1513
      current=jvmpiAgent_appendIntegerAttribute(START_LINENO_ATTRIBUTE, STRLEN_START_LINENO_ATTRIBUTE, current, methodEntry->methodData.start_lineno, tps->buffer);
1514
	}
1515
    if (methodEntry->methodData.end_lineno != -1)
1516
	{
1517
      current=jvmpiAgent_appendIntegerAttribute(END_LINENO_ATTRIBUTE, STRLEN_END_LINENO_ATTRIBUTE, current, methodEntry->methodData.end_lineno, tps->buffer);
1518
	}
1519
    if(jvmpiAgent_isPrintStaticId())
1520
	{
1521
      current=jvmpiAgent_appendIntegerAttribute(STATIC_METHOD_ID_ATTRIBUTE, STRLEN_STATIC_METHOD_ID_ATTRIBUTE, current, methodEntry->static_id, tps->buffer);
1522
	}
1523
    if(jvmpiAgent_isPrintMethodId())
1524
	{
1525
	  current=jvmpiAgent_appendIntegerAttribute(METHOD_ID_ATTRIBUTE, STRLEN_METHOD_ID_ATTRIBUTE, current, (jint)(methodEntry->methodData.method_id), tps->buffer);
1526
	}
1527
    if (jvmpiAgent_isPrintObjId())
1528
	{
1529
      current=jvmpiAgent_appendIntegerAttribute(CLASS_IDREF_ATTRIBUTE, STRLEN_CLASS_IDREF_ATTRIBUTE, current, (jint)(CLASS_ENTRY(methodEntry->classHashEntry)->classId), tps->buffer);
1530
	}
1531
    if(jvmpiAgent_isPrintStaticId())
1532
	{
1533
      current=jvmpiAgent_appendIntegerAttribute(STATIC_CLASS_IDREF_ATTRIBUTE, STRLEN_STATIC_CLASS_IDREF_ATTRIBUTE, current, (jint)(CLASS_ENTRY(methodEntry->classHashEntry)->static_id), tps->buffer);
1534
	}
1535
    current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &methodEntry->collation);
1536
    current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
1537
    current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
1538
    jvmpiAgent_print(tps, tps->buffer, current);
1539
  }
1540
 }
1541
}
1542
1543
/** PRINT_METHOD_ENTRY_EVENT  **********************************************
1544
  * Handles the output of a METHOD_ENTRY, METHOD_CALL element and attributes
1545
  */
1546
void jvmpiAgent_printMethodEntryEvent(JVMPI_Event *event,
1547
                                      ThreadLocalStorage *tps,
1548
                                      StackEntry *stackEntry,
1549
                                      unsigned long stackDepth) {
1550
 unsigned short current=0;
1551
1552
 /* Print the information */
1553
 stackEntry->printed = 1; /* Indicate that this entry is printed */
1554
 jvmpiAgent_outputMethodDeclaration(stackEntry->methodHashEntry, tps);
1555
1556
 /* Make sure that the objAlloc is printed if necessary. 
1557
	The following conditions ensure that if either the attribute transientObjIdRef, 
1558
	or objIdRef is printed in the methodEntry element, the objAlloc 
1559
	will have been 	printed first. (The conditions come directly from those used
1560
	for testing whether to print the attribute -- see below.) 
1561
	bugzilla_46357
1562
 */ 
1563
 
1564
	if( stackEntry->objectHashEntry &&
1565
		( (jvmpiAgent_isPrintObjId() && _jvmpiAgent_Options.mode==TraceModeFull) ||
1566
		jvmpiAgent_isPrintStaticId())) {
1567
1568
		if (!stackEntry->objectHashEntry->printed) {
1569
			jvmpiAgent_printObjAllocElement(stackEntry->objectHashEntry,event->env_id, 0); 
1570
		}
1571
	}
1572
1573
1574
 if(_jvmpiAgent_Options.jinsightFormat)
1575
 {
1576
#ifdef BINARY_TRACE
1577
   unsigned short numBytes = BINARYTRACE_printMethodEnter(tps->buffer, stackEntry);
1578
   jvmpiAgent_print(tps, tps->buffer, numBytes);
1579
#endif /* BINARY_TRACE */
1580
 }
1581
 else
1582
 {
1583
   /* RKD:  There is no longer a need for differentiating between method entry and method call events
1584
            in the profiler as we are not supporting multiple process tracing correlation.  If we ever
1585
			do go down that route we will need to differntiate.
1586
   current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps, CLASS_ENTRY(METHOD_ENTRY(stackEntry->methodHashEntry)->classHashEntry)->traceFlag ? METHOD_ENTRY_ATTRIBUTE : METHOD_CALL_ATTRIBUTE, (unsigned short)(CLASS_ENTRY(METHOD_ENTRY(stackEntry->methodHashEntry)->classHashEntry)->traceFlag ? STRLEN_METHOD_ENTRY_ATTRIBUTE : STRLEN_METHOD_CALL_ATTRIBUTE));
1587
    */
1588
   current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps, METHOD_ENTRY_ATTRIBUTE, STRLEN_METHOD_ENTRY_ATTRIBUTE );
1589
1590
   if(_jvmpiAgent_Options.timestamp)
1591
   {
1592
     current=jvmpiAgent_appendTimestamp(tps->buffer, current, stackEntry->timestamp );
1593
   }
1594
   if(jvmpiAgent_isPrintStaticId())
1595
   {
1596
     current=jvmpiAgent_appendIntegerAttribute(STATIC_METHOD_IDREF_ATTRIBUTE, STRLEN_STATIC_METHOD_IDREF_ATTRIBUTE, current, (jint)(METHOD_ENTRY(stackEntry->methodHashEntry)->static_id), tps->buffer);
1597
   }
1598
   if(jvmpiAgent_isPrintMethodId())
1599
   {
1600
 	 current=jvmpiAgent_appendIntegerAttribute(METHOD_IDREF_ATTRIBUTE, STRLEN_METHOD_IDREF_ATTRIBUTE, current, (jint)( ((MethodHashKey *)stackEntry->methodHashEntry->id)->id), tps->buffer);
1601
   }
1602
1603
1604
   /* Only print the object information when in FULL TraceMode and when requested */
1605
   if(jvmpiAgent_isPrintObjId() && _jvmpiAgent_Options.mode==TraceModeFull)
1606
   {
1607
     current=jvmpiAgent_appendIntegerAttribute(OBJ_IDREF_ATTRIBUTE, STRLEN_OBJ_IDREF_ATTRIBUTE, current, stackEntry->objectHashEntry ? (jint)((ObjectHashKey*)stackEntry->objectHashEntry->id)->id : 0, tps->buffer);
1608
     current=jvmpiAgent_appendIntegerAttribute(CLASS_IDREF_ATTRIBUTE, STRLEN_CLASS_IDREF_ATTRIBUTE, current, (jint)((ClassHashKey*)METHOD_ENTRY(stackEntry->methodHashEntry)->classHashEntry->id)->id, tps->buffer);
1609
   }
1610
   if (stackEntry->objectHashEntry && jvmpiAgent_isPrintStaticId())
1611
   {
1612
     current=jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_IDREF_ATTRIBUTE, STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current, stackEntry->objectHashEntry ? OBJECT_ENTRY(stackEntry->objectHashEntry)->static_id : 0 , tps->buffer);
1613
   }
1614
   if(jvmpiAgent_isPrintStaticId())
1615
   {
1616
     current=jvmpiAgent_appendIntegerAttribute(STATIC_CLASS_IDREF_ATTRIBUTE, STRLEN_STATIC_CLASS_IDREF_ATTRIBUTE, current, CLASS_ENTRY(METHOD_ENTRY(stackEntry->methodHashEntry)->classHashEntry)->static_id, tps->buffer);
1617
   }
1618
1619
   if(_jvmpiAgent_Options.ticket)
1620
   {
1621
     current=jvmpiAgent_printTicketAttribute(&stackEntry->ticket,tps->buffer, current);
1622
   }
1623
   current=jvmpiAgent_appendIntegerAttribute(STACK_DEPTH_ATTRIBUTE, STRLEN_STACK_DEPTH_ATTRIBUTE, current, stackDepth, tps->buffer);
1624
   if (_jvmpiAgent_Options.contextFlow)
1625
   {
1626
     /*## Values of context flow information not implemented yet. */
1627
     current=jvmpiAgent_appendIntegerAttribute(SEQUENCE_COUNTER_ATTRIBUTE, STRLEN_SEQUENCE_COUNTER_ATTRIBUTE, current, 0, tps->buffer);
1628
     current=jvmpiAgent_appendStringAttribute(CONTEXT_DATA_ATTRIBUTE, STRLEN_CONTEXT_DATA_ATTRIBUTE, current, "##not implemented yet##", tps);
1629
   }
1630
1631
   /*##MW There is a race condition between the increment and the print that must be fixed */
1632
   jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
1633
   current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
1634
1635
   current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
1636
   current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
1637
   jvmpiAgent_print(tps, tps->buffer, current);
1638
 }
1639
1640
}
1641
1642
/** PRINT_AG_METHOD_ENTRY_EVENT  **************************preagg/135437*******
1643
  *
1644
  * Handles the output of a AG_METHOD_ENTRY element and attributes
1645
  */
1646
void jvmpiAgent_printAgMethodEntryEvent(ThreadPrivateStorage * tps, StackFrame * call) {
1647
1648
   unsigned short current=0;
1649
1650
   /* Note that tps->env is passed in place of event->env_id passed elsewhere and should be equivalent in the preAgg case. */
1651
   current=jvmpiAgent_insertEmptyEventHeader(tps->env, tps, AG_METHOD_ENTRY_ELEMENT, STRLEN_AG_METHOD_ENTRY_ELEMENT);
1652
1653
   current=jvmpiAgent_appendIntegerAttribute(STATIC_METHOD_IDREF_ATTRIBUTE, STRLEN_STATIC_METHOD_IDREF_ATTRIBUTE, current, 
1654
                                             (jint)(METHOD_ENTRY(call->methodHashEntry)->static_id), tps->buffer);
1655
1656
   current=jvmpiAgent_appendLabeledTimestamp(tps->buffer, current, BASETIME1_ATTRIBUTE, STRLEN_BASETIME1_ATTRIBUTE, call->baseTime, TRUE);
1657
   current=jvmpiAgent_appendLabeledTimestamp(tps->buffer, current, MINTIME_ATTRIBUTE, STRLEN_MINTIME_ATTRIBUTE, call->minTime, TRUE);
1658
   current=jvmpiAgent_appendLabeledTimestamp(tps->buffer, current, MAXTIME_ATTRIBUTE, STRLEN_MAXTIME_ATTRIBUTE, call->maxTime, TRUE);   
1659
   
1660
   current=jvmpiAgent_appendIntegerAttribute(COUNT_ATTRIBUTE, STRLEN_COUNT_ATTRIBUTE, current, call->numCalls, tps->buffer);
1661
1662
   if (_jvmpiAgent_Options.cpuTime) {
1663
      current=jvmpiAgent_appendThreadCPUTime(tps->buffer, current, (Uint64)(call->baseCPUTime)); 
1664
   }
1665
1666
   current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);   
1667
   jvmpiAgent_print(tps, tps->buffer, current);
1668
}
1669
1670
/** PRINT_THREAD_START_ELEMENT  ********************************************
1671
  *
1672
  */
1673
void
1674
jvmpiAgent_printThreadStartElement(JNIEnv *env_id,
1675
								   HashEntry *threadHashEntry)
1676
{
1677
 if (!_jvmpiAgent_suspendIO)
1678
 {
1679
  unsigned short current=0;
1680
  HashEntry *objectHashEntry = 0;
1681
  ThreadLocalStorage *tps = THREAD_ENTRY(threadHashEntry);
1682
  timestamp_t now;
1683
1684
  threadHashEntry->printed = 1;
1685
  jvmpiAgent_getCurrentTime(&now);
1686
1687
  if(_jvmpiAgent_Options.jinsightFormat)
1688
  {
1689
#ifdef BINARY_TRACE
1690
    unsigned short numBytes = BINARYTRACE_printThreadStart(tps->buffer, tps);
1691
    jvmpiAgent_print(tps, tps->buffer, numBytes);
1692
#endif /* BINARY_TRACE */
1693
  }
1694
  else
1695
  {
1696
    /* The thread object is found using a special function */
1697
    jobjectID threadObject=_jvmpiAgent_jvmpiInterface->GetThreadObject(env_id);
1698
1699
    /* Ensure our thread object has been declared */
1700
    objectHashEntry = jvmpiAgent_FindObjectSymbolWithAllocate(threadObject, env_id);
1701
1702
1703
    current=jvmpiAgent_insertEmptyEventHeader1(((ThreadHashKey*)threadHashEntry->id)->id, tps, THREAD_START_ELEMENT, STRLEN_THREAD_START_ELEMENT);
1704
    /* Get the timestamp information if necessary */
1705
    if(_jvmpiAgent_Options.timestamp)
1706
	{
1707
      current=jvmpiAgent_appendTimestamp(tps->buffer, current, now );
1708
	}
1709
	current=jvmpiAgent_appendStringAttribute(THREAD_NAME_ATTRIBUTE, STRLEN_THREAD_NAME_ATTRIBUTE, current, jvmpiAgent_formatName(tps->threadName), tps);
1710
    current=jvmpiAgent_appendStringAttribute(GROUP_NAME_ATTRIBUTE, STRLEN_GROUP_NAME_ATTRIBUTE, current, jvmpiAgent_formatName(tps->groupName), tps);
1711
    current=jvmpiAgent_appendStringAttribute(PARENT_NAME_ATTRIBUTE, STRLEN_PARENT_NAME_ATTRIBUTE, current, jvmpiAgent_formatName(tps->parentName), tps);
1712
    if(jvmpiAgent_isPrintObjId())
1713
	{
1714
      current=jvmpiAgent_appendIntegerAttribute(OBJ_IDREF_ATTRIBUTE, STRLEN_OBJ_IDREF_ATTRIBUTE, current, (jint)threadObject, tps->buffer);
1715
	}
1716
1717
    /* Since we don't see an OBJ_ALLOC for some of the system threads we can only output a 0 for the static object id */
1718
    /* ##MW Perhaps we could internally manufacture an object and use that to hold a unique static id */
1719
    if(jvmpiAgent_isPrintStaticId())
1720
	{
1721
      current=jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_IDREF_ATTRIBUTE, STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current, objectHashEntry ? OBJECT_ENTRY(objectHashEntry)->static_id : 0, tps->buffer);
1722
	}
1723
    current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &tps->collation);
1724
    current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
1725
    current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
1726
	jvmpiAgent_print(tps, tps->buffer, current);
1727
  }
1728
 }
1729
}
1730
1731
1732
/** PRINT_OBJ_FREE_ELEMENT  ************************************************
1733
  * Handles the output of OBJ_FREE.
1734
  */
1735
void
1736
jvmpiAgent_printObjFreeElement(ThreadLocalStorage *tps,
1737
							   HashEntry *objectHashEntry)
1738
{
1739
 HashEntry *classHashEntry=OBJECT_ENTRY(objectHashEntry)->classHashEntry;
1740
1741
 if (!_jvmpiAgent_suspendIO && classHashEntry && (_jvmpiAgent_Options.gc != GcNone))
1742
  {
1743
1744
	if(_jvmpiAgent_Options.jinsightFormat)
1745
	{
1746
#ifdef BINARY_TRACE
1747
	  unsigned short numBytes = BINARYTRACE_printObjectFree(tps->buffer, objectHashEntry);
1748
	  jvmpiAgent_print(tps, tps->buffer, numBytes);
1749
#endif /* BINARY_TRACE */
1750
	}
1751
	else
1752
	{
1753
	  unsigned short current=0;
1754
1755
      jvmpiAgent_outputClassDeclaration(classHashEntry, tps);
1756
1757
      current=jvmpiAgent_insertEmptyEventHeader(tps->env, tps, OBJ_FREE_ELEMENT, STRLEN_OBJ_FREE_ELEMENT);
1758
      /* Get the timestamp information if necessary */
1759
      if (_jvmpiAgent_Options.timestamp)
1760
	  {
1761
        current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
1762
	  }
1763
      if (jvmpiAgent_isPrintStaticId())
1764
	  {
1765
        current=jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_IDREF_ATTRIBUTE, STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current, OBJECT_ENTRY(objectHashEntry)->static_id, tps->buffer);
1766
	  }
1767
      if (jvmpiAgent_isPrintObjId())
1768
	  {
1769
        current=jvmpiAgent_appendIntegerAttribute(OBJ_IDREF_ATTRIBUTE, STRLEN_OBJ_IDREF_ATTRIBUTE, current, (jint)((ObjectHashKey*)objectHashEntry->id)->id, tps->buffer);
1770
	  }
1771
      if (_jvmpiAgent_Options.contextFlow)
1772
	  {
1773
        /*## Values of context flow information not implemented yet. */
1774
        current=jvmpiAgent_appendIntegerAttribute(SEQUENCE_COUNTER_ATTRIBUTE, STRLEN_SEQUENCE_COUNTER_ATTRIBUTE, current, 0, tps->buffer);
1775
        current=jvmpiAgent_appendStringAttribute(CONTEXT_DATA_ATTRIBUTE, STRLEN_CONTEXT_DATA_ATTRIBUTE, current, "##not implemented yet##", tps);
1776
	  }
1777
1778
      /*##MW There is a race condition between the increment and the print that must be fixed */
1779
      jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
1780
      current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
1781
1782
      current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
1783
      current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
1784
      jvmpiAgent_print(tps, tps->buffer, current);
1785
	}
1786
  }
1787
}
1788
1789
1790
void jvmpiAgent_printJvmInitDoneElement(JVMPI_Event *event)
1791
{
1792
  if(_jvmpiAgent_Options.jinsightFormat && !_jvmpiAgent_Options.standalone) {
1793
    return;
1794
  }
1795
1796
 if (!_jvmpiAgent_suspendIO)
1797
 {
1798
  ThreadPrivateStorage *tps = jvmpiAgent_getThreadLocalStorage(event->env_id);
1799
  unsigned short current=0;
1800
1801
  current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps, JVM_INIT_DONE_ELEMENT, STRLEN_JVM_INIT_DONE_ELEMENT);
1802
  /* Get the timestamp information if necessary */
1803
  if(_jvmpiAgent_Options.timestamp)
1804
  {
1805
   current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
1806
  }
1807
1808
  /*##MW There is a race condition between the increment and the print that must be fixed */
1809
  jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
1810
  current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
1811
1812
  current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
1813
  current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
1814
  jvmpiAgent_print(tps, tps->buffer, current);
1815
 }
1816
1817
  if(_jvmpiAgent_Options.jinsightFormat && _jvmpiAgent_Options.standalone) {
1818
#ifdef BINARY_TRACE
1819
    unsigned short numBytes = BINARYTRACE_printEndOfXMLHeader(tps->buffer);
1820
    jvmpiAgent_print(tps, tps->buffer, numBytes);
1821
#endif /* BINARY_TRACE */
1822
  }
1823
}
1824
1825
1826
void jvmpiAgent_printGcStartElement(JVMPI_Event *event)
1827
{
1828
 if (!_jvmpiAgent_suspendIO && _jvmpiAgent_Options.gc != GcNone)
1829
 {
1830
  ThreadPrivateStorage *tps = jvmpiAgent_getThreadLocalStorage(event->env_id);
1831
  unsigned short current=0;
1832
  if(_jvmpiAgent_Options.jinsightFormat)
1833
  {
1834
#ifdef BINARY_TRACE
1835
    unsigned short numBytes = BINARYTRACE_printGcStart(tps->buffer);
1836
    jvmpiAgent_print(tps, tps->buffer, numBytes);
1837
#endif /* BINARY_TRACE */
1838
  }
1839
  else
1840
  {
1841
	 current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps, GC_START_ELEMENT, STRLEN_GC_START_ELEMENT);
1842
     /* Get the timestamp information if necessary */
1843
     if(_jvmpiAgent_Options.timestamp)
1844
	 {
1845
       current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
1846
	 }
1847
1848
     /*##MW There is a race condition between the increment and the print that must be fixed */
1849
     jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
1850
     current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
1851
1852
     current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
1853
     current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
1854
     jvmpiAgent_print(tps, tps->buffer, current);
1855
  }
1856
 }
1857
}
1858
1859
1860
void jvmpiAgent_printGcFinishElement(JVMPI_Event *event)
1861
{
1862
 if (!_jvmpiAgent_suspendIO && _jvmpiAgent_Options.gc != GcNone)
1863
 {
1864
  ThreadPrivateStorage *tps = jvmpiAgent_getThreadLocalStorage(event->env_id);
1865
  unsigned short current=0;
1866
1867
  if(_jvmpiAgent_Options.jinsightFormat)
1868
  {
1869
#ifdef BINARY_TRACE
1870
    unsigned short numBytes = BINARYTRACE_printGcFinish(tps->buffer);
1871
    jvmpiAgent_print(tps, tps->buffer, numBytes);
1872
#endif /* BINARY_TRACE */
1873
  }
1874
  else
1875
  {
1876
	 current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps, GC_FINISH_ELEMENT, STRLEN_GC_FINISH_ELEMENT);
1877
     /* Get the timestamp information if necessary */
1878
     if(_jvmpiAgent_Options.timestamp)
1879
	 {
1880
       current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
1881
	 }
1882
#ifdef __OS400__
1883
     current=jvmpiAgent_appendInteger64Attribute(USED_OBJECTS_ATTRIBUTE, STRLEN_USED_OBJECTS_ATTRIBUTE, current, (event->u.gc_info.used_objects).unsigned_ll, tps->buffer);
1884
     current=jvmpiAgent_appendInteger64Attribute(USED_OBJECT_SPACE_ATTRIBUTE, STRLEN_USED_OBJECT_SPACE_ATTRIBUTE, current, (event->u.gc_info.used_object_space).unsigned_ll, tps->buffer);
1885
     current=jvmpiAgent_appendInteger64Attribute(TOTAL_OBJECT_SPACE_ATTRIBUTE, STRLEN_TOTAL_OBJECT_SPACE_ATTRIBUTE, current, (event->u.gc_info.total_object_space).unsigned_ll, tps->buffer);
1886
#else
1887
     current=jvmpiAgent_appendInteger64Attribute(USED_OBJECTS_ATTRIBUTE, STRLEN_USED_OBJECTS_ATTRIBUTE, current, event->u.gc_info.used_objects, tps->buffer);
1888
     current=jvmpiAgent_appendInteger64Attribute(USED_OBJECT_SPACE_ATTRIBUTE, STRLEN_USED_OBJECT_SPACE_ATTRIBUTE, current, event->u.gc_info.used_object_space, tps->buffer);
1889
     current=jvmpiAgent_appendInteger64Attribute(TOTAL_OBJECT_SPACE_ATTRIBUTE, STRLEN_TOTAL_OBJECT_SPACE_ATTRIBUTE, current, event->u.gc_info.total_object_space, tps->buffer);
1890
#endif
1891
1892
     /*##MW There is a race condition between the increment and the print that must be fixed */
1893
     jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
1894
     current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
1895
1896
     current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
1897
     current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
1898
     jvmpiAgent_print(tps, tps->buffer, current);
1899
  }
1900
 }
1901
}
1902
1903
1904
/** PRINT_GC_ROOT_ELEMEMT  *******************************************************
1905
 *
1906
 */
1907
void
1908
jvmpiAgent_printGcRootElement(JVMPI_Event *event,
1909
							  unsigned long id,
1910
							  char* type)
1911
{
1912
	if(!_jvmpiAgent_suspendIO && _jvmpiAgent_Options.gc != GcNone)
1913
	{
1914
		unsigned short current=0;
1915
		ThreadPrivateStorage *tps = jvmpiAgent_getThreadLocalStorage(event->env_id);
1916
		
1917
		if(_jvmpiAgent_Options.jinsightFormat)
1918
		{
1919
#ifdef BINARY_TRACE
1920
			/* BINARY_TRACE */
1921
#endif
1922
		}
1923
		else
1924
		{
1925
			current=jvmpiAgent_insertElementStart(GC_ROOT_ELEMENT, STRLEN_GC_ROOT_ELEMENT, tps);
1926
1927
			if(strcmp(type, "STICKY_CLASS") == 0)
1928
			{
1929
				current = jvmpiAgent_appendIntegerAttribute(STATIC_CLASS_IDREF_ATTRIBUTE, STRLEN_STATIC_CLASS_IDREF_ATTRIBUTE, current, id, tps->buffer);
1930
			}
1931
/*
1932
			else if(strcmp(type, "THREAD_BLOCK") == 0)
1933
			{
1934
				current = jvmpiAgent_appendIntegerAttribute(STATIC_THREAD_IDREF_ATTRIBUTE, STRLEN_STATIC_THREAD_IDREF_ATTRIBUTE, current, id, tps->buffer);
1935
			}
1936
*/
1937
			else
1938
			{
1939
				current = jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_IDREF_ATTRIBUTE, STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current, id, tps->buffer);
1940
			}
1941
1942
			current = jvmpiAgent_appendStringAttribute(GC_ROOT_TYPE_ATTRIBUTE, STRLEN_GC_ROOT_TYPE_ATTRIBUTE, current, type, tps);
1943
1944
			/* Finish up */
1945
			current = jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
1946
			jvmpiAgent_print(tps, tps->buffer, current);
1947
		}
1948
	}
1949
}
1950
1951
1952
1953
unsigned short
1954
jvmpiAgent_printThreadOwnerAttribute(char *buffer, unsigned short current,
1955
									 unsigned long thread_owner)
1956
{
1957
	return jvmpiAgent_appendUnsignedLongAttribute(THREAD_OWNER_ATTRIBUTE,
1958
						      STRLEN_THREAD_OWNER_ATTRIBUTE,
1959
						      current,thread_owner, buffer);
1960
}
1961
1962
unsigned short
1963
jvmpiAgent_printTimeoutAttribute(char *buffer, unsigned short current,
1964
								 Uint64 timeout)
1965
{
1966
1967
	return jvmpiAgent_appendInteger64Attribute(TIMEOUT_ATTRIBUTE,
1968
						      STRLEN_TIMEOUT_ATTRIBUTE,current,timeout,buffer);
1969
}
1970
1971
1972
/** PRINT_MONITOR_WAIT_ELEMENT  *****************************************************
1973
  *
1974
  * Print the <monWait> element to the trace indicating JVMPI_EVENT_MONITOR_WAIT occurred.
1975
  *
1976
  * args -
1977
  *		objectHashEntry - the hash entry corresponding to the monitor object
1978
  *		event - the MONITOR_WAIT event as reported by JVMPI
1979
  *		timestamp - when the MONITOR_WAIT event occurred
1980
  *     isThreadSleep - 0 indicates regular monitor, 1 indicates wait occurred
1981
  *                     within Thread.sleep()
1982
  */
1983
void
1984
jvmpiAgent_printMonitorWaitElement(HashEntry *objectHashEntry, JVMPI_Event *event,
1985
								   timestamp_t timestamp, int isThreadSleep)
1986
{
1987
1988
	/* only print element if io is not suspended */
1989
	if (!_jvmpiAgent_suspendIO) {
1990
		
1991
		unsigned short current=0;
1992
		ThreadPrivateStorage *tps;
1993
		
1994
		tps = jvmpiAgent_getThreadLocalStorage(event->env_id);
1995
		
1996
		if(!timestamp) {
1997
			jvmpiAgent_getCurrentTime(&timestamp);
1998
		}
1999
2000
		/* does there need to be any code handling binary trace/jinsight format?
2001
   		 (not dealt with for now) */
2002
2003
		current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps, MONITOR_WAIT_ELEMENT,
2004
			STRLEN_MONITOR_WAIT_ELEMENT);
2005
2006
		if(_jvmpiAgent_Options.timestamp)
2007
		{
2008
			current=jvmpiAgent_appendTimestamp(tps->buffer, current, timestamp);
2009
		}
2010
2011
2012
		/* Print the object identifier. Object identifier is -1 if in Thread.sleep() */
2013
2014
		if(jvmpiAgent_isPrintStaticId())
2015
		{
2016
			current=jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_IDREF_ATTRIBUTE,
2017
				STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current,
2018
				(isThreadSleep == 0 ? OBJECT_ENTRY(objectHashEntry)->static_id : -1),
2019
				tps->buffer);
2020
		}
2021
2022
		if(jvmpiAgent_isPrintObjId())
2023
		{
2024
			current=jvmpiAgent_appendIntegerAttribute(OBJ_IDREF_ATTRIBUTE,
2025
				STRLEN_OBJ_IDREF_ATTRIBUTE, current,
2026
				(isThreadSleep == 0 ? (jint)((ObjectHashKey*)objectHashEntry->id)->id : -1),
2027
				tps->buffer);
2028
2029
		}
2030
2031
2032
		/* print the timeout attribute */
2033
#ifdef __OS400__
2034
		current = jvmpiAgent_printTimeoutAttribute(tps->buffer,current,
2035
			(event->u.monitor_wait.timeout).unsigned_ll);
2036
#else
2037
		current = jvmpiAgent_printTimeoutAttribute(tps->buffer,current,
2038
			event->u.monitor_wait.timeout);
2039
#endif
2040
2041
			
2042
		/* The collation value */
2043
2044
2045
		/*##MW There is a race condition between the increment and the print
2046
		that must be fixed */
2047
2048
		jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
2049
		current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current,
2050
			&_jvmpiAgent_collation);
2051
2052
		/* The trace Id */
2053
2054
		current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
2055
2056
		/* Finish up */
2057
2058
		current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2059
		jvmpiAgent_print(tps, tps->buffer, current);
2060
	}
2061
2062
}
2063
2064
2065
/** PRINT_MONITOR_WAITED_ELEMENT  *****************************************************
2066
  *
2067
  * Print the <monWaited> element to the trace indicating JVMPI_EVENT_MONITOR_WAITED occurred.
2068
  *
2069
  * args -
2070
  *		objectHashEntry - hash entry corresponding to the monitor object
2071
  *		event - the MONITOR_WAITED event as reported by JVMPI
2072
  *		timestamp - when the MONITOR_WAITED event occurred
2073
  *     isThreadSleep - 0 indicates regular monitor, 1 indicates wait occurred
2074
  *                     within Thread.sleep()
2075
  */
2076
void
2077
jvmpiAgent_printMonitorWaitedElement(HashEntry* objectHashEntry, JVMPI_Event *event,
2078
								   timestamp_t timestamp, int isThreadSleep)
2079
{
2080
2081
	/* only print element if io is not suspended */
2082
	if (!_jvmpiAgent_suspendIO) {
2083
		
2084
		unsigned short current=0;
2085
		ThreadPrivateStorage *tps;
2086
		
2087
		tps = jvmpiAgent_getThreadLocalStorage(event->env_id);
2088
		
2089
		if(!timestamp) {
2090
			jvmpiAgent_getCurrentTime(&timestamp);
2091
		}
2092
2093
		/* does there need to be any code handling binary trace/jinsight format?
2094
		   (not dealt with for now) */
2095
2096
		current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps, MONITOR_WAITED_ELEMENT,
2097
			STRLEN_MONITOR_WAITED_ELEMENT);
2098
2099
		if(_jvmpiAgent_Options.timestamp)
2100
		{
2101
			current=jvmpiAgent_appendTimestamp(tps->buffer, current, timestamp);
2102
		}
2103
2104
2105
		/* Print the object identifier. Object identifier is -1 if in Thread.sleep() */
2106
2107
		if(jvmpiAgent_isPrintStaticId())
2108
		{
2109
			current=jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_IDREF_ATTRIBUTE,
2110
				STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current,
2111
				(isThreadSleep == 0 ? OBJECT_ENTRY(objectHashEntry)->static_id : -1),
2112
				tps->buffer);
2113
		}
2114
2115
		if(jvmpiAgent_isPrintObjId())
2116
		{
2117
			current=jvmpiAgent_appendIntegerAttribute(OBJ_IDREF_ATTRIBUTE,
2118
				STRLEN_OBJ_IDREF_ATTRIBUTE, current,
2119
				(isThreadSleep == 0 ? (jint)((ObjectHashKey *)objectHashEntry->id)->id : -1),
2120
				tps->buffer);
2121
2122
		}
2123
2124
		/* print the timeout attribute */
2125
#ifdef __OS400__
2126
		current = jvmpiAgent_printTimeoutAttribute(tps->buffer,current,
2127
			(event->u.monitor_wait.timeout).unsigned_ll);
2128
#else
2129
		current = jvmpiAgent_printTimeoutAttribute(tps->buffer,current,
2130
			event->u.monitor_wait.timeout);
2131
#endif
2132
2133
		/* The collation value */
2134
2135
2136
		/*##MW There is a race condition between the increment and the print
2137
		that must be fixed */
2138
2139
		jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
2140
		current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current,
2141
			&_jvmpiAgent_collation);
2142
2143
		/* The trace Id */
2144
2145
		current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
2146
2147
		/* Finish up */
2148
2149
		current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2150
		jvmpiAgent_print(tps, tps->buffer, current);
2151
	}
2152
}
2153
2154
/** PRINT_MONITOR_STILL_OWNED_ELEMENT  ************************************************
2155
  *
2156
  * Print the <monStillOwned> element to the trace indicating
2157
  * a thread is still owning a monitor at the moment we checked
2158
  * It is potentially sent on JVMPI_EVENT_MONITOR_CONTENDED_ENTER
2159
  * just before a <monContendedEnter> element where the
2160
  * thread is the contended thread
2161
  *
2162
  * args -
2163
  *		objectHashEntry - the hash entry corresponding to the monitor object
2164
  *		event - the JVMPI_EVENT_MONITOR_CONTENDED_ENTER event as reported by JVMPI
2165
  */
2166
void
2167
jvmpiAgent_printMonitorStillOwnedElement(HashEntry *objectHashEntry, JVMPI_Event *event)
2168
2169
{
2170
	/* only print element if io is not suspended */
2171
	if (!_jvmpiAgent_suspendIO) {
2172
		
2173
		unsigned short current=0;
2174
		ThreadPrivateStorage *tps;
2175
		
2176
		tps = jvmpiAgent_getThreadLocalStorage(event->env_id);
2177
		
2178
		current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps,
2179
			MONITOR_STILL_OWNED_EVENT, STRLEN_MONITOR_STILL_OWNED_EVENT);
2180
2181
		/* Print the object identifier. */
2182
2183
		if(jvmpiAgent_isPrintStaticId())
2184
		{
2185
			current=jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_IDREF_ATTRIBUTE,
2186
				STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current,
2187
				OBJECT_ENTRY(objectHashEntry)->static_id,
2188
				tps->buffer);
2189
		}
2190
2191
		if(jvmpiAgent_isPrintObjId())
2192
		{
2193
			current=jvmpiAgent_appendIntegerAttribute(OBJ_IDREF_ATTRIBUTE,
2194
				STRLEN_OBJ_IDREF_ATTRIBUTE, current,
2195
				(jint)((ObjectHashKey*)objectHashEntry->id)->id, tps->buffer);
2196
2197
		}
2198
2199
2200
		/* The collation value */
2201
2202
2203
		/*##MW There is a race condition between the increment and the print
2204
		that must be fixed */
2205
2206
		jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
2207
		current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current,
2208
			&_jvmpiAgent_collation);
2209
2210
		/* The trace Id */
2211
2212
		current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
2213
2214
		/* Finish up */
2215
2216
		current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2217
		jvmpiAgent_print(tps, tps->buffer, current);
2218
	}
2219
2220
}
2221
2222
2223
/** PRINT_MONITOR_CONTENDED_ENTER_ELEMENT  ************************************************
2224
  *
2225
  * Print the <monContendedEnter> element to the trace indicating
2226
  * JVMPI_EVENT_MONITOR_CONTENDED_ENTER occurred.
2227
  *
2228
  * args -
2229
  *		objectHashEntry - the hash entry corresponding to the monitor object
2230
  *		event - the MONITOR_WAITED event as reported by JVMPI
2231
  *		thread_owner - the current thread that owns the monitor object
2232
  *		timestamp - when the MONITOR_WAITED event occurred
2233
  */
2234
void
2235
jvmpiAgent_printMonitorContendedEnterElement(HashEntry *objectHashEntry, JVMPI_Event *event,
2236
							 unsigned long thread_owner, timestamp_t timestamp)
2237
2238
{
2239
	/* only print element if io is not suspended */
2240
	if (!_jvmpiAgent_suspendIO) {
2241
		
2242
		unsigned short current=0;
2243
		ThreadPrivateStorage *tps;
2244
		
2245
		tps = jvmpiAgent_getThreadLocalStorage(event->env_id);
2246
		
2247
		if(!timestamp) {
2248
			jvmpiAgent_getCurrentTime(&timestamp);
2249
		}
2250
2251
		/* does there need to be any code handling binary trace/jinsight format?
2252
		   (not dealt with for now) */
2253
2254
		current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps,
2255
			MONITOR_CONTENDED_ENTER_ELEMENT, STRLEN_MONITOR_CONTENDED_ENTER_ELEMENT);
2256
2257
		if(_jvmpiAgent_Options.timestamp)
2258
		{
2259
			current=jvmpiAgent_appendTimestamp(tps->buffer, current, timestamp);
2260
		}
2261
2262
2263
		/* Print the object identifier. */
2264
2265
		if(jvmpiAgent_isPrintStaticId())
2266
		{
2267
			current=jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_IDREF_ATTRIBUTE,
2268
				STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current,
2269
				OBJECT_ENTRY(objectHashEntry)->static_id,
2270
				tps->buffer);
2271
		}
2272
2273
		if(jvmpiAgent_isPrintObjId())
2274
		{
2275
			current=jvmpiAgent_appendIntegerAttribute(OBJ_IDREF_ATTRIBUTE,
2276
				STRLEN_OBJ_IDREF_ATTRIBUTE, current,
2277
				(jint)((ObjectHashKey*)objectHashEntry->id)->id, tps->buffer);
2278
2279
		}
2280
2281
2282
		/* print the thread owner attribute */
2283
2284
		current = jvmpiAgent_printThreadOwnerAttribute(tps->buffer,current, thread_owner);
2285
			
2286
		/* The collation value */
2287
2288
2289
		/*##MW There is a race condition between the increment and the print
2290
		that must be fixed */
2291
2292
		jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
2293
		current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current,
2294
			&_jvmpiAgent_collation);
2295
2296
		/* The trace Id */
2297
2298
		current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
2299
2300
		/* Finish up */
2301
2302
		current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2303
		jvmpiAgent_print(tps, tps->buffer, current);
2304
	}
2305
2306
}
2307
2308
2309
/** PRINT_MONITOR_CONTENDED_ENTERED_ELEMENT  ************************************************
2310
  *
2311
  * Print the <monContendedEntered> element to the trace indicating
2312
  * JVMPI_EVENT_MONITOR_CONTENDED_ENTERED occurred.
2313
  *
2314
  * args -
2315
  *		objectHashEntry - the hash entry corresponding to the monitor object
2316
  *		event - the MONITOR_WAITED event as reported by JVMPI
2317
  *		timestamp - when the MONITOR_WAITED event occurred
2318
  */
2319
void
2320
jvmpiAgent_printMonitorContendedEnteredElement(HashEntry *objectHashEntry, JVMPI_Event *event,
2321
											   timestamp_t timestamp)
2322
{
2323
	/* only print element if io is not suspended */
2324
	if (!_jvmpiAgent_suspendIO) {
2325
		
2326
		unsigned short current=0;
2327
		ThreadPrivateStorage *tps;
2328
		
2329
		tps = jvmpiAgent_getThreadLocalStorage(event->env_id);
2330
		
2331
		if(!timestamp) {
2332
			jvmpiAgent_getCurrentTime(&timestamp);
2333
		}
2334
2335
		/* does there need to be any code handling binary trace/jinsight format?
2336
		 (not dealt with for now) */
2337
2338
		current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps,
2339
			MONITOR_CONTENDED_ENTERED_ELEMENT, STRLEN_MONITOR_CONTENDED_ENTERED_ELEMENT);
2340
2341
		if(_jvmpiAgent_Options.timestamp)
2342
		{
2343
			current=jvmpiAgent_appendTimestamp(tps->buffer, current, timestamp);
2344
		}
2345
2346
		/* Print the object identifier. */
2347
2348
		if(jvmpiAgent_isPrintStaticId())
2349
		{
2350
			current=jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_IDREF_ATTRIBUTE,
2351
				STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current,
2352
				OBJECT_ENTRY(objectHashEntry)->static_id,
2353
				tps->buffer);
2354
		}
2355
2356
		if(jvmpiAgent_isPrintObjId())
2357
		{
2358
			current=jvmpiAgent_appendIntegerAttribute(OBJ_IDREF_ATTRIBUTE,
2359
				STRLEN_OBJ_IDREF_ATTRIBUTE, current,
2360
				(jint)((ObjectHashKey*)objectHashEntry->id)->id, tps->buffer);
2361
2362
		}
2363
2364
2365
			
2366
		/* The collation value */
2367
2368
2369
		/*##MW There is a race condition between the increment and the print
2370
		that must be fixed */
2371
2372
		jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
2373
		current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current,
2374
			&_jvmpiAgent_collation);
2375
2376
		/* The trace Id */
2377
2378
		current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
2379
2380
		/* Finish up */
2381
2382
		current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2383
		jvmpiAgent_print(tps, tps->buffer, current);
2384
	}
2385
}
2386
2387
2388
2389
2390
2391
/** PRINT_OBJ_ALLOC_ELEMENT  *****************************************************
2392
  *
2393
  */
2394
void
2395
jvmpiAgent_printObjAllocElement(HashEntry *objectHashEntry,
2396
								JNIEnv *env_id,
2397
                                timestamp_t timestamp)
2398
{
2399
 if (!_jvmpiAgent_suspendIO)
2400
 {
2401
  unsigned short current=0;
2402
  ThreadPrivateStorage *tps = jvmpiAgent_getThreadLocalStorage(env_id);
2403
  HashEntry *classHashEntry = OBJECT_ENTRY(objectHashEntry)->classHashEntry;
2404
2405
  objectHashEntry->printed = 1;
2406
2407
  if(!timestamp) {
2408
      jvmpiAgent_getCurrentTime(&timestamp);
2409
  }
2410
2411
2412
  if(_jvmpiAgent_Options.jinsightFormat)
2413
  {
2414
#ifdef BINARY_TRACE
2415
    unsigned short numBytes = BINARYTRACE_printObjectAllocation(tps->buffer,
2416
								objectHashEntry,
2417
								classHashEntry);
2418
    jvmpiAgent_print(tps, tps->buffer, numBytes);
2419
#endif /* BINARY_TRACE */
2420
  }
2421
  else
2422
  {
2423
2424
	/* Ensure our class declaration has been printed */
2425
    jvmpiAgent_outputClassDeclaration(OBJECT_ENTRY(objectHashEntry)->classHashEntry, tps);
2426
2427
    current=jvmpiAgent_insertEmptyEventHeader(env_id, tps, OBJ_ALLOC_ELEMENT, STRLEN_OBJ_ALLOC_ELEMENT);
2428
2429
    if(_jvmpiAgent_Options.timestamp)
2430
	{
2431
      current=jvmpiAgent_appendTimestamp(tps->buffer, current, timestamp);
2432
	}
2433
2434
    /* Print the object identifier as well as the class identifier */
2435
    if(jvmpiAgent_isPrintStaticId())
2436
	{
2437
      current=jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_ID_ATTRIBUTE, STRLEN_STATIC_OBJ_ID_ATTRIBUTE, current, OBJECT_ENTRY(objectHashEntry)->static_id, tps->buffer);
2438
      current=jvmpiAgent_appendIntegerAttribute(STATIC_CLASS_IDREF_ATTRIBUTE, STRLEN_STATIC_CLASS_IDREF_ATTRIBUTE, current, (jint)(classHashEntry ? CLASS_ENTRY(classHashEntry)->static_id : 0), tps->buffer);
2439
	}
2440
    if(jvmpiAgent_isPrintObjId())
2441
	{
2442
      current=jvmpiAgent_appendIntegerAttribute(OBJ_ID_ATTRIBUTE, STRLEN_OBJ_ID_ATTRIBUTE, current, (jint)((ObjectHashKey*)objectHashEntry->id)->id, tps->buffer);
2443
      current=jvmpiAgent_appendIntegerAttribute(CLASS_IDREF_ATTRIBUTE, STRLEN_CLASS_IDREF_ATTRIBUTE, current, (jint)(classHashEntry ? ((ClassHashKey*)classHashEntry->id)->id : 0), tps->buffer);
2444
	}
2445
2446
2447
    if(_jvmpiAgent_Options.objAllocIsArray)
2448
	{
2449
      current=jvmpiAgent_appendIntegerAttribute(IS_ARRAY_ATTRIBUTE, STRLEN_IS_ARRAY_ATTRIBUTE, current, OBJECT_ENTRY(objectHashEntry)->is_array, tps->buffer);
2450
	}
2451
2452
    /* Print the size of this object */
2453
#ifdef _LP64
2454
    current=jvmpiAgent_appendLongAttribute(SIZE_ATTRIBUTE, STRLEN_SIZE_ATTRIBUTE, current, OBJECT_ENTRY(objectHashEntry)->size, tps->buffer); /*fix 89008*/
2455
#else
2456
    current=jvmpiAgent_appendIntegerAttribute(SIZE_ATTRIBUTE, STRLEN_SIZE_ATTRIBUTE, current, OBJECT_ENTRY(objectHashEntry)->size, tps->buffer);
2457
#endif
2458
2459
    /* The collation value */
2460
    current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &OBJECT_ENTRY(objectHashEntry)->collation);
2461
2462
    /* The trace Id */
2463
    current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
2464
2465
    /* Finish up */
2466
    current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2467
    jvmpiAgent_print(tps, tps->buffer, current);
2468
  }
2469
 }
2470
}
2471
2472
/** PRINT_CLASS_UNLOAD_ELEMENT  ********************************************
2473
  *
2474
  */
2475
void
2476
jvmpiAgent_printClassUnloadElement(JVMPI_Event *event,
2477
								   ThreadLocalStorage *tps,
2478
								   HashEntry *classHashEntry)
2479
{
2480
 if (!_jvmpiAgent_suspendIO && CLASS_ENTRY(classHashEntry)->traceFlag && (_jvmpiAgent_Options.gc != GcNone))
2481
 {
2482
	 if(_jvmpiAgent_Options.jinsightFormat)
2483
	 {
2484
#ifdef BINARY_TRACE
2485
	   unsigned short numBytes = BINARYTRACE_printClassUnload(tps->buffer, classHashEntry);
2486
	   jvmpiAgent_print(tps, tps->buffer, numBytes);
2487
#endif /* BINARY_TRACE */
2488
	 }
2489
	 else
2490
	 {
2491
	    unsigned short current=0;
2492
        current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps, CLASS_UNLOAD_ELEMENT, STRLEN_CLASS_UNLOAD_ELEMENT);
2493
        if(jvmpiAgent_isPrintObjId())
2494
		{
2495
          current=jvmpiAgent_appendIntegerAttribute(CLASS_IDREF_ATTRIBUTE, STRLEN_CLASS_IDREF_ATTRIBUTE, current, (jint)(event->u.class_unload.class_id), tps->buffer);
2496
		}
2497
        if(jvmpiAgent_isPrintStaticId())
2498
		{
2499
           current=jvmpiAgent_appendIntegerAttribute(STATIC_CLASS_IDREF_ATTRIBUTE, STRLEN_STATIC_CLASS_IDREF_ATTRIBUTE, current, (jint)(CLASS_ENTRY(classHashEntry)->static_id), tps->buffer);
2500
		}
2501
        /* Get the timestamp information if necessary */
2502
        if(_jvmpiAgent_Options.timestamp)
2503
		{
2504
          current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
2505
		}
2506
2507
        /*##MW There is a race condition between the increment and the print that must be fixed */
2508
        jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
2509
        current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
2510
2511
        current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
2512
        current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2513
        jvmpiAgent_print(tps, tps->buffer, current);
2514
	 }
2515
 }
2516
}
2517
2518
/** PRINT_OBJ_MOVE_ELEMENT  ************************************************
2519
  * Handles the output of OBJ_MOVE.
2520
  */
2521
void jvmpiAgent_printObjMoveElement(JVMPI_Event *event,
2522
									HashEntry *objectHashEntry)
2523
{
2524
 HashEntry *classHashEntry = OBJECT_ENTRY(objectHashEntry)->classHashEntry;
2525
 if (!_jvmpiAgent_suspendIO && classHashEntry)
2526
 {
2527
  ThreadPrivateStorage *tps = jvmpiAgent_getThreadLocalStorage(event->env_id);
2528
  unsigned short current=0;
2529
2530
  jvmpiAgent_outputClassDeclaration(classHashEntry, tps);
2531
2532
  current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps, OBJ_MOVE_ELEMENT, STRLEN_OBJ_MOVE_ELEMENT);
2533
  /* Get the timestamp information if necessary */
2534
  if(_jvmpiAgent_Options.timestamp)
2535
  {
2536
   current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
2537
  }
2538
  if (jvmpiAgent_isPrintStaticId())
2539
  {
2540
   current=jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_IDREF_ATTRIBUTE, STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current, OBJECT_ENTRY(objectHashEntry)->static_id, tps->buffer);
2541
  }
2542
  if (jvmpiAgent_isPrintObjId())
2543
  {
2544
   current=jvmpiAgent_appendIntegerAttribute(OBJ_IDREF_ATTRIBUTE, STRLEN_OBJ_IDREF_ATTRIBUTE, current, (jint)(event->u.obj_move.obj_id), tps->buffer);
2545
  }
2546
  if (jvmpiAgent_isPrintObjId())
2547
  {
2548
   current=jvmpiAgent_appendIntegerAttribute(NEW_OBJ_ID_ATTRIBUTE, STRLEN_NEW_OBJ_ID_ATTRIBUTE, current, (jint)(event->u.obj_move.new_obj_id), tps->buffer);
2549
  }
2550
2551
  /*##MW There is a race condition between the increment and the print that must be fixed */
2552
  jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
2553
  current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
2554
2555
  current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
2556
  current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2557
  jvmpiAgent_print(tps, tps->buffer, current);
2558
 }
2559
}
2560
2561
2562
/** PRINT_THREAD_END_ELEMENT  **********************************************
2563
  */
2564
void jvmpiAgent_printThreadEndElement(JNIEnv *env_id,
2565
									  ThreadLocalStorage *tps)
2566
{
2567
 if (!_jvmpiAgent_suspendIO)
2568
 {
2569
	unsigned short current=0;
2570
	
2571
	if(_jvmpiAgent_Options.jinsightFormat)
2572
	{
2573
#ifdef BINARY_TRACE
2574
	  unsigned short numBytes = BINARYTRACE_printThreadEnd(tps->buffer, tps);
2575
	  jvmpiAgent_print(tps, tps->buffer, numBytes);
2576
#endif /* BINARY_TRACE */
2577
	 }
2578
	 else
2579
	 {
2580
	   current=jvmpiAgent_insertEmptyEventHeader(env_id, tps, THREAD_END_ELEMENT, STRLEN_THREAD_END_ELEMENT);
2581
	   /* Get the timestamp information if necessary */
2582
	   if(_jvmpiAgent_Options.timestamp)
2583
	   {
2584
	     current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
2585
	   }
2586
2587
	   /*##MW There is a race condition between the increment and the print that must be fixed */
2588
	   jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
2589
	   current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
2590
2591
	   current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
2592
	   current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2593
	   jvmpiAgent_print(tps, tps->buffer, current);
2594
	
2595
	 }
2596
 }
2597
}
2598
2599
2600
/** PRINT_METHOD_EXIT_EVENT  ***********************************************
2601
  * Prints the METHOD_EXIT, METHOD_RETURN element
2602
  */
2603
void
2604
jvmpiAgent_printMethodExitElement(JVMPI_Event *event,
2605
								  ThreadLocalStorage *tps,
2606
								  HashEntry *methodHashEntry,
2607
				  timestamp_t timestamp, 
2608
				  timestamp_t cpu_timestamp)
2609
{
2610
 unsigned short current=0;
2611
 jobjectID object_id = 0;   
2612
 jint static_id = 0;
2613
 HashEntry *objectHashEntry = jvmpiAgent_Peek(tps, 0)->objectHashEntry;
2614
 
2615
 if(_jvmpiAgent_Options.jinsightFormat) {
2616
#ifdef BINARY_TRACE
2617
   unsigned short numBytes = BINARYTRACE_printMethodExit(tps->buffer, tps,
2618
							 timeJustAfterGotControl);
2619
   jvmpiAgent_print(tps, tps->buffer, numBytes);
2620
#endif /* BINARY_TRACE */
2621
   return;
2622
 }
2623
2624
  /* Object information will only be there if we are in FULL trace mode */
2625
 if (objectHashEntry)
2626
 {
2627
  object_id = ((ObjectHashKey*)objectHashEntry->id)->id;
2628
  static_id = OBJECT_ENTRY(objectHashEntry)->static_id ;
2629
 }
2630
 assert(event);
2631
 assert(methodHashEntry);
2632
 assert(tps);
2633
2634
2635
 if (object_id && jvmpiAgent_isPrintStaticId())
2636
 {
2637
  HashEntry *objectHashEntry = 0;
2638
  objectHashEntry = jvmpiAgent_FindObjectSymbolWithAllocate(object_id, event->env_id);
2639
 }
2640
2641
 /* RKD:  We don't emit methidCall events any more.  So remove the methodreturn peer.
2642
 current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps, CLASS_ENTRY(METHOD_ENTRY(methodHashEntry)->classHashEntry)->traceFlag ? METHOD_EXIT_ELEMENT : METHOD_RETURN_ELEMENT,
2643
 (unsigned short)(CLASS_ENTRY(METHOD_ENTRY(methodHashEntry)->classHashEntry)->traceFlag ? STRLEN_METHOD_EXIT_ELEMENT : STRLEN_METHOD_RETURN_ELEMENT));
2644
 */
2645
  current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps, METHOD_EXIT_ELEMENT, STRLEN_METHOD_EXIT_ELEMENT);
2646
2647
2648
 if(jvmpiAgent_isPrintStaticId())
2649
 {
2650
   current=jvmpiAgent_appendIntegerAttribute(STATIC_METHOD_IDREF_ATTRIBUTE, STRLEN_STATIC_METHOD_IDREF_ATTRIBUTE, current, (jint)(METHOD_ENTRY(methodHashEntry)->static_id), tps->buffer);
2651
 }
2652
 if(jvmpiAgent_isPrintMethodId())
2653
 {
2654
	current=jvmpiAgent_appendIntegerAttribute(METHOD_IDREF_ATTRIBUTE, STRLEN_METHOD_IDREF_ATTRIBUTE, current, (jint)(METHOD_ENTRY(methodHashEntry)->methodData.method_id), tps->buffer);
2655
 }
2656
2657
2658
2659
 if(object_id && jvmpiAgent_isPrintObjId())
2660
 {
2661
  current=jvmpiAgent_appendIntegerAttribute(OBJ_IDREF_ATTRIBUTE, STRLEN_OBJ_IDREF_ATTRIBUTE, current, (jint)object_id, tps->buffer);
2662
  current=jvmpiAgent_appendIntegerAttribute(CLASS_IDREF_ATTRIBUTE, STRLEN_CLASS_IDREF_ATTRIBUTE, current,(jint)((ClassHashKey*) ((MethodEntry *)methodHashEntry->entry)->classHashEntry->id)->id, tps->buffer);
2663
 }
2664
 if (object_id && jvmpiAgent_isPrintStaticId())
2665
 {
2666
  if (objectHashEntry)
2667
  {
2668
   current=jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_IDREF_ATTRIBUTE, STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current, ((ObjectEntry*)objectHashEntry->entry)->static_id, tps->buffer);
2669
  }
2670
 }
2671
 if(jvmpiAgent_isPrintStaticId())
2672
 {
2673
  current=jvmpiAgent_appendIntegerAttribute(STATIC_CLASS_IDREF_ATTRIBUTE, STRLEN_STATIC_CLASS_IDREF_ATTRIBUTE, current, CLASS_ENTRY(METHOD_ENTRY(methodHashEntry)->classHashEntry)->static_id, tps->buffer);
2674
 }
2675
 if(_jvmpiAgent_Options.cpuTime) {
2676
  Uint64 cpu_exit_overhead, cpu_overheadSoFar, cpu_totalInvocationOverhead, cpu_cumulativeTime;
2677
   timestamp_t cpuNow;
2678
2679
   /* load the running sum of all overhead so far */
2680
   cpu_overheadSoFar = tps->stackEntry[tps->tos].cumulative_cpu_overhead;
2681
2682
   /* determine the cumulative method time spent in this method */ 
2683
   cpu_cumulativeTime = TIMESTAMP_SUB(cpu_timestamp,tps->stackEntry[tps->tos].cpuTime); 
2684
2685
   /* subtract the overhead  */ 
2686
   cpu_cumulativeTime = TIMESTAMP_SUB(cpu_cumulativeTime,cpu_overheadSoFar); 
2687
   
2688
   /* print the CPU cumulative time */
2689
   current=jvmpiAgent_appendThreadCPUTime(tps->buffer, current, cpu_cumulativeTime); 
2690
2691
   /* now we have to add the overhead so far to the 
2692
   overhead in the call one up on the stack  (overhead is cumulative in the call stack) */ 
2693
2694
   /* acquire the timestamp as late as possible; note: anything after
2695
      this will be overhead that is blamed to the invoker, but it's
2696
      the best we can do for now */
2697
   cpuNow = jvmpiAgent_getCurrentThreadCPUTime(); 
2698
2699
    /* determine the current exit overhead */
2700
   cpu_exit_overhead = TIMESTAMP_SUB(cpuNow,cpu_timestamp);
2701
2702
   /* add it to the running sum of all overhead for this invocation */
2703
   cpu_totalInvocationOverhead = cpu_overheadSoFar+cpu_exit_overhead;
2704
2705
   /* now add it to the stack entry one up in the stack */ 
2706
   if (tps->tos > 1) {
2707
	   tps->stackEntry[tps->tos-1].cumulative_cpu_overhead += cpu_totalInvocationOverhead; 
2708
   }
2709
 }
2710
 if(_jvmpiAgent_Options.ticket)
2711
 {
2712
  current=jvmpiAgent_printTicketAttribute(&jvmpiAgent_Peek(tps, 0)->ticket, tps->buffer, current);
2713
 }
2714
 if (_jvmpiAgent_Options.contextFlow)
2715
 {
2716
  /*## Values of context flow information not implemented yet. */
2717
  current=jvmpiAgent_appendIntegerAttribute(SEQUENCE_COUNTER_ATTRIBUTE, STRLEN_SEQUENCE_COUNTER_ATTRIBUTE, current, 0, tps->buffer);
2718
  current=jvmpiAgent_appendStringAttribute(CONTEXT_DATA_ATTRIBUTE, STRLEN_CONTEXT_DATA_ATTRIBUTE, current, "##not implemented yet##", tps);
2719
 }
2720
2721
 /*##MW There is a race condition between the increment and the print that must be fixed */
2722
 jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
2723
 current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
2724
2725
 current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
2726
2727
 /* Print the timestamp (and overhead) information if necessary */
2728
 if(_jvmpiAgent_Options.timestamp)
2729
 {
2730
   Uint64 exit_overhead, overheadSoFar, totalInvocationOverhead;
2731
   timestamp_t now;
2732
2733
   /* load the running sum of all overhead so far */
2734
   overheadSoFar = tps->stackEntry[tps->tos].cumulative_overhead;
2735
2736
   /* acquire the timestamp as late as possible; note: anything after
2737
      this will be overhead that is blamed to the invoker, but it's
2738
      the best we can do for now */
2739
   jvmpiAgent_getCurrentTime(&now);
2740
2741
   /* print the timestamp */
2742
   current=jvmpiAgent_appendTimestamp(tps->buffer, current, now);
2743
2744
   /* determine the current exit overhead */
2745
   exit_overhead = TIMESTAMP_SUB(now,timestamp);
2746
2747
   /* add it to the running sum of all overhead for this invocation */
2748
   totalInvocationOverhead = overheadSoFar+exit_overhead;
2749
   current = jvmpiAgent_appendOverhead(tps->buffer, current, totalInvocationOverhead);
2750
 }
2751
2752
 current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2753
 jvmpiAgent_print(tps, tps->buffer, current);
2754
}
2755
2756
2757
/** PRINT_AG_METHOD_EXIT_ELEMENT **************************preAgg/135437*******
2758
  * 
2759
  * Prints the METHOD_EXIT element
2760
  */
2761
void jvmpiAgent_printAgMethodExitElement(ThreadPrivateStorage * tps, StackFrame * call) {
2762
2763
   unsigned short current=0;
2764
   
2765
   /* Note that tps->env is passed in place of event->env_id passed elsewhere and should be equivalent in the preAgg case. */
2766
   current=jvmpiAgent_insertEmptyEventHeader(tps->env, tps, AG_METHOD_EXIT_ELEMENT, STRLEN_AG_METHOD_EXIT_ELEMENT);
2767
   
2768
   current=jvmpiAgent_appendIntegerAttribute(STATIC_METHOD_IDREF_ATTRIBUTE, STRLEN_STATIC_METHOD_IDREF_ATTRIBUTE, current, 
2769
                                             (jint)(METHOD_ENTRY(call->methodHashEntry)->static_id), tps->buffer);
2770
   
2771
   current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2772
   
2773
   jvmpiAgent_print(tps, tps->buffer, current);
2774
}
2775
2776
/** PRINT_METHODS  **********************************************************
2777
  *  Handles the output of all the METHOD elements and attributes for a class.
2778
  */
2779
void
2780
jvmpiAgent_printMethods(HashEntry **mp,
2781
						int count,
2782
						ThreadPrivateStorage *tps)
2783
{
2784
 if (!_jvmpiAgent_suspendIO && (_jvmpiAgent_Options.stackInfo > StackInfoNone || _jvmpiAgent_Options.methodCounts))
2785
 {
2786
  int i;
2787
  for (i=0; i < count; i++)
2788
  {
2789
	if (METHOD_ENTRY(mp[i])->traceFlag) { 
2790
	   jvmpiAgent_printMethod(METHOD_ENTRY(mp[i]), tps);
2791
	   mp[i]->printed = 1;
2792
	}
2793
  }
2794
 }
2795
}
2796
2797
2798
/** PRINT_FIELDS  ***********************************************************
2799
  * Handles the output of all the STATIC_FIELD or INSTANCE_FIELD elements
2800
  * and attributes for a class.
2801
  */
2802
void jvmpiAgent_printFields(ThreadPrivateStorage *tps,
2803
							PI_Field *fp, int count,
2804
							FieldType_t fieldType)
2805
{
2806
 if (!_jvmpiAgent_suspendIO)
2807
 {
2808
  int i;
2809
  for (i=0; i < count && fp; i++)
2810
  {
2811
   unsigned short current=0;
2812
2813
   if (fieldType == Static)
2814
   {
2815
 	current=jvmpiAgent_insertElementStart(STATIC_FIELD_ELEMENT, STRLEN_STATIC_FIELD_ELEMENT, tps);
2816
   }
2817
   else
2818
   {
2819
	current=jvmpiAgent_insertElementStart(INSTANCE_FIELD_ELEMENT, STRLEN_INSTANCE_FIELD_ELEMENT, tps);
2820
   }
2821
   current=jvmpiAgent_appendStringAttribute(NAME_ATTRIBUTE, STRLEN_NAME_ATTRIBUTE, current, fp->field_name, tps);
2822
   current=jvmpiAgent_appendStringAttribute(SIGNATURE_ATTRIBUTE, STRLEN_SIGNATURE_ATTRIBUTE, current, fp->field_signature, tps);
2823
   current=jvmpiAgent_appendIntegerAttribute(FIELD_ID_ATTRIBUTE, STRLEN_FIELD_ID_ATTRIBUTE, current, fp->fieldId, tps->buffer);
2824
   current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2825
   jvmpiAgent_print(tps, tps->buffer, current);
2826
   fp++; /* Skip to the next method */
2827
  }
2828
 }
2829
}
2830
2831
2832
/** PRINT_CLASS  ****************************************************************
2833
  * Handles the output of the CLASS_LOAD element and attributes
2834
  */
2835
void
2836
jvmpiAgent_printClass(HashEntry *classHashEntry,
2837
					  ThreadPrivateStorage *tps)
2838
{
2839
 unsigned short current=0;
2840
 if (!_jvmpiAgent_suspendIO)
2841
 {
2842
2843
	classHashEntry->printed = 1;
2844
2845
2846
	if(_jvmpiAgent_Options.jinsightFormat)
2847
	{
2848
#ifdef BINARY_TRACE
2849
	  ClassEntry *classEntry = CLASS_ENTRY(classHashEntry);
2850
	  unsigned short numBytes;
2851
2852
	  /* 1. "define" the class, which just defines the class id */
2853
	  numBytes = BINARYTRACE_printClassDefine(tps->buffer, classEntry);
2854
	  jvmpiAgent_print(tps, tps->buffer, numBytes);
2855
2856
	  /* 2. "load" the class, which defines properies of class */
2857
	  numBytes = BINARYTRACE_printClassLoad(tps->buffer, classEntry);
2858
	  jvmpiAgent_print(tps, tps->buffer, numBytes);
2859
2860
	  /* 3. instance fields */
2861
	  BINARYTRACE_printFields(tps, classEntry, classEntry->numInstanceFields,
2862
				  0,
2863
				  classEntry->instances, FALSE);
2864
2865
	  /* 4. static fields */
2866
	  BINARYTRACE_printFields(tps, classEntry, classEntry->numStaticFields,
2867
				  classEntry->numInstanceFields,
2868
				  classEntry->statics, TRUE);
2869
#endif /* BINARY_TRACE */
2870
	}
2871
	else
2872
	{
2873
	  ClassEntry *classEntry = CLASS_ENTRY(classHashEntry);
2874
2875
      current=jvmpiAgent_insertEmptyEventHeader(tps->env, tps,
2876
	    										CLASS_LOAD_ELEMENT,
2877
		    									STRLEN_CLASS_LOAD_ELEMENT);
2878
2879
2880
      current=jvmpiAgent_appendStringAttribute(NAME_ATTRIBUTE, STRLEN_NAME_ATTRIBUTE, current, classEntry->className, tps);
2881
      current=jvmpiAgent_appendStringAttribute(SOURCE_NAME_ATTRIBUTE, STRLEN_SOURCE_NAME_ATTRIBUTE, current, classEntry->sourceName, tps);
2882
      if (_jvmpiAgent_Options.classLoadDetails)
2883
	  {
2884
2885
		/* Show the classloader of this entry (if one has been detected) */
2886
		if (classEntry->classLoaderName && strlen(classEntry->classLoaderName) > 0)
2887
			current = jvmpiAgent_appendStringAttribute(CLASS_LOADER_NAME, STRLEN_CLASS_LOADER_NAME, current, classEntry->classLoaderName, tps);
2888
2889
		if (classEntry->superClassName && strlen(classEntry->superClassName) > 0)
2890
			current=jvmpiAgent_appendStringAttribute(SUPER_CLASS_NAME_ATTRIBUTE, STRLENT_SUPER_CLASS_NAME_ATTRIBUTE, current, classEntry->superClassName, tps);
2891
2892
		current=jvmpiAgent_appendIntegerAttribute(NUM_INTERFACES_ATTRIBUTE, STRLEN_NUM_INTERFACES_ATTRIBUTE, current, classEntry->numInterfaces, tps->buffer);
2893
2894
		/* Show the interface names only if there are any interfaces implemented */
2895
		if (classEntry->nameOfInterfaces && strlen(classEntry->nameOfInterfaces) > 0)
2896
			current=jvmpiAgent_appendStringAttribute(INTERFACE_NAMES_ATTRIBUTE, STRLEN_INTERFACE_NAMES_ATTRIBUTE, current, classEntry->nameOfInterfaces, tps);
2897
2898
		current=jvmpiAgent_appendIntegerAttribute(NUM_METHODS_ATTRIBUTE, STRLEN_NUM_METHODS_ATTRIBUTE, current, classEntry->numMethods, tps->buffer);
2899
		current=jvmpiAgent_appendIntegerAttribute(NUM_STATIC_FIELDS_ATTRIBUTE, STRLEN_NUM_STATIC_FIELDS_ATTRIBUTE, current, classEntry->numStaticFields, tps->buffer);
2900
		current=jvmpiAgent_appendIntegerAttribute(NUM_INSTANCE_FIELDS_ATTRIBUTE, STRLEN_NUM_INSTANCE_FIELDS_ATTRIBUTE, current, classEntry->numInstanceFields, tps->buffer);
2901
	  }
2902
      if (jvmpiAgent_isPrintObjId())
2903
	  {
2904
        current=jvmpiAgent_appendIntegerAttribute(CLASS_ID_ATTRIBUTE, STRLEN_CLASS_ID_ATTRIBUTE, current, (jint)classEntry->classId, tps->buffer);
2905
	  }
2906
      if(jvmpiAgent_isPrintStaticId())
2907
	  {
2908
        current=jvmpiAgent_appendIntegerAttribute(STATIC_CLASS_ID_ATTRIBUTE, STRLEN_STATIC_CLASS_ID_ATTRIBUTE, current, (jint)classEntry->static_id, tps->buffer);
2909
		/* Give the objectID of our class object if we have it*/
2910
		if(CLASS_ENTRY(classHashEntry)->classObject) {
2911
			current=jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_IDREF_ATTRIBUTE, STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current, (jint)OBJECT_ENTRY(CLASS_ENTRY(classHashEntry)->classObject)->static_id, tps->buffer);
2912
2913
		}
2914
	  }
2915
      if(_jvmpiAgent_Options.timestamp)
2916
	  {
2917
        /* In case we don't have a time for it (which is the case for primitives), this would be a good time to figure it out */
2918
		if (classEntry->timestamp == 0)
2919
		{
2920
            jvmpiAgent_getCurrentTime(&classEntry->timestamp);
2921
        }
2922
        current=jvmpiAgent_appendTimestamp(tps->buffer, current, classEntry->timestamp);
2923
	  }
2924
      if (_jvmpiAgent_Options.contextFlow)
2925
	  {
2926
        /*## Values of context flow information not implemented yet. */
2927
        current=jvmpiAgent_appendIntegerAttribute(SEQUENCE_COUNTER_ATTRIBUTE, STRLEN_SEQUENCE_COUNTER_ATTRIBUTE, current, 0, tps->buffer);
2928
        current=jvmpiAgent_appendStringAttribute(CONTEXT_DATA_ATTRIBUTE, STRLEN_CONTEXT_DATA_ATTRIBUTE, current, "##not implemented yet##", tps);
2929
	  }
2930
      current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &classEntry->collation);
2931
      current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
2932
      current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2933
      jvmpiAgent_print(tps, tps->buffer, current);
2934
2935
      if (_jvmpiAgent_Options.classLoadDetails)
2936
	  {
2937
        jvmpiAgent_printFields(tps, CLASS_ENTRY(classHashEntry)->statics, CLASS_ENTRY(classHashEntry)->numStaticFields, Static);
2938
        jvmpiAgent_printFields(tps, CLASS_ENTRY(classHashEntry)->instances, CLASS_ENTRY(classHashEntry)->numInstanceFields, Instance);
2939
	  }
2940
	}
2941
 }
2942
}
2943
2944
void jvmpiAgent_printTraceEndElement(ThreadPrivateStorage *tps)
2945
{
2946
 unsigned short current = 0;
2947
 current=jvmpiAgent_insertElementStart(TRACE_STOP_ELEMENT, STRLEN_TRACE_STOP_ELEMENT, tps);
2948
 current = jvmpiAgent_printTraceIdrefAttribute(tps, current);
2949
2950
 /* Get the timestamp information if necessary */
2951
 if(_jvmpiAgent_Options.timestamp)
2952
 {
2953
  current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
2954
 }
2955
2956
 /*##MW There is a race condition between the increment and the print that must be fixed */
2957
 jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
2958
 current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
2959
2960
 current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
2961
 jvmpiAgent_print(tps, tps->buffer, current);
2962
}
2963
2964
2965
unsigned short jvmpiAgent_printTicketAttribute(SegmentedValue_t *ticket, char *buffer, unsigned short current)
2966
{
2967
#ifdef SEGMENTED_VALUE_MULTIWORD
2968
 unsigned long i;
2969
 current=jvmpiAgent_appendUnsignedLongAttribute(TICKET_ATTRIBUTE, STRLEN_TICKET_ATTRIBUTE, current, ticket->values[0], buffer);
2970
 for (i = 1; i < ticket->numberOfWords; i++)
2971
 {
2972
  current=jvmpiAgent_appendListUnsignedLong(current, ticket->values[i], buffer);
2973
 }
2974
#else
2975
  current=jvmpiAgent_appendUnsignedLongAttribute(TICKET_ATTRIBUTE, STRLEN_TICKET_ATTRIBUTE, current, ticket->value, buffer);
2976
#endif
2977
 return current;
2978
}
2979
2980
2981
void jvmpiAgent_printTraceStartElement(ThreadLocalStorage *tps, char *options)
2982
{
2983
 if (!_jvmpiAgent_suspendIO)
2984
 {
2985
  ra_string_t uuid;
2986
  ra_IPAddresses_t addresses;
2987
  timestamp_t startTime;
2988
  unsigned short current=0;
2989
  jvmpiAgent_getCurrentTime(&startTime);
2990
2991
  /* We need to free this later so set to null in case the API call fails that does malloc */
2992
  addresses.addresses=NULL;
2993
2994
  /* Initialize the collation value sequence */
2995
  jvmpiAgent_initializeSegmentedValue(&_jvmpiAgent_collation, 1);
2996
2997
  current=jvmpiAgent_insertElementStart(TRACE_START_ELEMENT, STRLEN_TRACE_START_ELEMENT, tps);
2998
2999
  ra_generateUUID(&uuid);
3000
#ifdef MVS
3001
  if (uuid.length != __etoa(uuid.data)) {
3002
#pragma convlit(suspend)
3003
      printf("EBCDIC to ASCII conversion failure.\n");
3004
	  fflush(stdout); 
3005
#pragma convlit(resume)
3006
  }
3007
#endif
3008
  _jvmpiAgent_trace_id=uuid.data;
3009
3010
  current=jvmpiAgent_appendStringAttribute(TRACE_ID_ATTRIBUTE, STRLEN_TRACE_ID_ATTRIBUTE, current, _jvmpiAgent_trace_id , tps);
3011
/* 199373 begin */
3012
#ifdef MVS
3013
  uuid.length = strlen(ra_getAgentUUID(_jvmpiAgent_bindingStorage));
3014
  uuid.data = (char *)malloc(uuid.length+1);
3015
  if (uuid.data == NULL) {
3016
#pragma convlit(suspend)
3017
     printf("Memory allocation failure.\n");
3018
	 fflush(stdout); 
3019
#pragma convlit(resume)
3020
     return;
3021
  }
3022
  strcpy(uuid.data, ra_getAgentUUID(_jvmpiAgent_bindingStorage));
3023
  if (uuid.length != __etoa(uuid.data)) {
3024
#pragma convlit(suspend)
3025
      printf("EBCDIC to ASCII conversion failure.\n");
3026
	  fflush(stdout); 
3027
#pragma convlit(resume)
3028
  }
3029
  current=jvmpiAgent_appendStringAttribute(AGENT_IDREF_ATTRIBUTE, STRLEN_AGENT_IDREF_ATTRIBUTE, current, uuid.data, tps);
3030
  free(uuid.data);
3031
#else
3032
  current=jvmpiAgent_appendStringAttribute(AGENT_IDREF_ATTRIBUTE, STRLEN_AGENT_IDREF_ATTRIBUTE, current, ra_getAgentUUID(_jvmpiAgent_bindingStorage) , tps);
3033
#endif
3034
/* 199373 end */
3035
3036
  if(_jvmpiAgent_Options.timestamp) {
3037
	current=jvmpiAgent_appendTimestamp(tps->buffer, current, startTime);
3038
  }
3039
3040
  /*##MW There is a race condition between the increment and the print that must be fixed */
3041
  jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
3042
  current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
3043
3044
  current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3045
  jvmpiAgent_print(tps, tps->buffer, current);
3046
 }
3047
}
3048
3049
3050
static unsigned short printHostNameAttribute(ThreadPrivateStorage *tps, unsigned short current)
3051
{
3052
 char hostNameBuffer[100];
3053
3054
 if(ra_getLocalHostName(hostNameBuffer, sizeof(hostNameBuffer))==0)
3055
 {
3056
#ifdef MVS                    /* 174190 */
3057
  __etoa(hostNameBuffer);
3058
#endif
3059
  current=jvmpiAgent_appendStringAttribute(HOSTNAME_ATTRIBUTE, STRLEN_HOSTNAME_ATTRIBUTE, current, hostNameBuffer, tps);
3060
 }
3061
 return current;
3062
}
3063
3064
3065
static unsigned short printIPAddressAttribute(ThreadPrivateStorage *tps, unsigned short current)
3066
{
3067
 ra_IPAddresses_t addresses;
3068
 unsigned char *p;
3069
 int i;
3070
 
3071
 /* Get the network information and print it */
3072
 if(ra_getLocalIPAddresses(&addresses)==0)
3073
 {
3074
#ifdef MVS                    /* 174190 */
3075
   int mycurr = current;
3076
#pragma convlit(suspend)
3077
#endif
3078
  tps->buffer[current++]=' ';
3079
  memcpy(&tps->buffer[current], IPADDRESS_ATTRIBUTE, STRLEN_IPADDRESS_ATTRIBUTE);
3080
  current+=STRLEN_IPADDRESS_ATTRIBUTE;
3081
  tps->buffer[current++]='=';
3082
  tps->buffer[current++]='\"';
3083
  for (p=addresses.addresses; *p; p+=addresses.addressLength)
3084
  {
3085
   /* If this isn't the first IP address add a comma */
3086
   if(p!=addresses.addresses)
3087
   {
3088
	tps->buffer[current++]=',';
3089
   }
3090
3091
   /* the first number of the address */
3092
#ifdef _WIN32
3093
   itoa(p[0], &tps->buffer[current], 10);
3094
   current+=strlen(&tps->buffer[current]);
3095
#else
3096
   current+=sprintf(&tps->buffer[current], "%d", p[0]);
3097
#endif
3098
3099
   /* Subsequent "." separated address numbers */
3100
   for (i=1; i < addresses.addressLength; i++)
3101
   {
3102
	tps->buffer[current++]='.';
3103
#ifdef _WIN32
3104
	itoa(p[i], &tps->buffer[current], 10);
3105
	current+=strlen(&tps->buffer[current]);
3106
#else
3107
	current+=sprintf(&tps->buffer[current], "%d", p[i]);
3108
#endif
3109
   }
3110
  }
3111
  /* Add closing quote */
3112
  tps->buffer[current++]='\"';
3113
#ifdef MVS                    /* 174190 */
3114
  tps->buffer[current]='\0';
3115
#pragma convlit(resume)
3116
  __etoa(tps->buffer+mycurr);
3117
#endif
3118
 }
3119
 else
3120
 {
3121
  /* Couldn't resolve the IP (probably no network) */
3122
  current=jvmpiAgent_appendStringAttribute(IPADDRESS_ATTRIBUTE, STRLEN_IPADDRESS_ATTRIBUTE, current, UNAVAILABLE, tps);
3123
 }
3124
 /* The memory required for the addreses is allocated in the jvmpicommGetLocalIPAddresses
3125
  */
3126
#ifndef _DEBUG
3127
 ra_free(addresses.addresses); /*ts. Bug 143342, changed from free to ra_free to match with ra_malloc */
3128
#endif
3129
 return current;
3130
}
3131
3132
3133
void jvmpiAgent_printNodeElement(ThreadLocalStorage *tps)
3134
{
3135
 unsigned short current = 0;
3136
 timestamp_t time;
3137
#ifdef MVS
3138
 char *uuid;
3139
 int uuidlen;
3140
#endif
3141
 jvmpiAgent_getProcessStartTime(&time);
3142
 current=jvmpiAgent_insertElementStart(NODE_ELEMENT, STRLEN_NODE_ELEMENT, tps);
3143
3144
#ifdef MVS
3145
  uuidlen = strlen(ra_getNodeUUID(_jvmpiAgent_bindingStorage));
3146
  uuid = (char *)malloc(uuidlen+1);   /* 192196 */
3147
  if (uuid == NULL) {
3148
#pragma convlit(suspend)
3149
     printf("Memory allocation failure.\n");
3150
	 fflush(stdout); 
3151
#pragma convlit(resume)
3152
     return;
3153
  }
3154
  strcpy(uuid, ra_getNodeUUID(_jvmpiAgent_bindingStorage));
3155
  if (uuidlen != __etoa(uuid)) {
3156
#pragma convlit(suspend)
3157
      printf("EBCDIC to ASCII conversion failure.\n");
3158
	  fflush(stdout); 
3159
#pragma convlit(resume)
3160
  }
3161
 current=jvmpiAgent_appendStringAttribute(NODE_ID_ATTRIBUTE, STRLEN_NODE_ID_ATTRIBUTE, current, uuid, tps);
3162
 free(uuid);
3163
#else
3164
 current=jvmpiAgent_appendStringAttribute(NODE_ID_ATTRIBUTE, STRLEN_NODE_ID_ATTRIBUTE, current, ra_getNodeUUID(_jvmpiAgent_bindingStorage) , tps);
3165
#endif
3166
 current=printHostNameAttribute(tps, current);
3167
 current=printIPAddressAttribute(tps, current);
3168
 current=jvmpiAgent_appendIntegerAttribute(TIMEZONE_ATTRIBUTE, STRLEN_TIMEZONE_ATTRIBUTE, current, jvmpiAgent_getTimezone(), tps->buffer);
3169
 if(_jvmpiAgent_Options.timestamp) {
3170
	current=jvmpiAgent_appendTimestamp(tps->buffer, current, time);
3171
 }
3172
 current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3173
 jvmpiAgent_print(tps, tps->buffer, current);
3174
}
3175
3176
3177
void jvmpiAgent_printProcessCreateElement(ThreadLocalStorage *tps)
3178
{
3179
 unsigned short current = 0;
3180
 timestamp_t time;
3181
#ifdef MVS
3182
 char *uuid;
3183
 int uuidlen;
3184
#endif
3185
 jvmpiAgent_getProcessStartTime(&time);
3186
3187
 current=jvmpiAgent_insertElementStart(PROCESS_CREATE_ELEMENT, STRLEN_PROCESS_CREATE_ELEMENT, tps);
3188
#ifdef MVS
3189
  uuidlen = strlen(ra_getProcessUUID(_jvmpiAgent_bindingStorage));
3190
  uuid = (char *)malloc(uuidlen+1);   /* 192196 */
3191
  if (uuid == NULL) {
3192
#pragma convlit(suspend)
3193
     printf("Memory allocation failure.\n");
3194
	 fflush(stdout); 
3195
#pragma convlit(resume)
3196
     return;
3197
  }
3198
  strcpy(uuid, ra_getProcessUUID(_jvmpiAgent_bindingStorage));
3199
  if (uuidlen != __etoa(uuid)) {
3200
#pragma convlit(suspend)
3201
      printf("EBCDIC to ASCII conversion failure.\n");
3202
	  fflush(stdout); 
3203
#pragma convlit(resume)
3204
  }
3205
 current=jvmpiAgent_appendStringAttribute(PROCESS_ID_ATTRIBUTE, STRLEN_PROCESS_ID_ATTRIBUTE, current, uuid, tps);
3206
 free(uuid);
3207
#else
3208
 current=jvmpiAgent_appendStringAttribute(PROCESS_ID_ATTRIBUTE, STRLEN_PROCESS_ID_ATTRIBUTE, current, ra_getProcessUUID(_jvmpiAgent_bindingStorage) , tps);
3209
#endif
3210
 current=jvmpiAgent_appendIntegerAttribute(PID_ATTRIBUTE, STRLEN_PID_ATTRIBUTE, current, ra_getProcessId(), tps->buffer);
3211
#ifdef MVS
3212
  uuidlen = strlen(ra_getNodeUUID(_jvmpiAgent_bindingStorage));
3213
  uuid = (char *)malloc(uuidlen+1);   /* 192196 */
3214
  if (uuid == NULL) {
3215
#pragma convlit(suspend)
3216
     printf("Memory allocation failure.\n");
3217
	 fflush(stdout); 
3218
#pragma convlit(resume)
3219
     return;
3220
  }
3221
  strcpy(uuid, ra_getNodeUUID(_jvmpiAgent_bindingStorage));
3222
  if (uuidlen != __etoa(uuid)) {
3223
#pragma convlit(suspend)
3224
      printf("EBCDIC to ASCII conversion failure.\n");
3225
	  fflush(stdout); 
3226
#pragma convlit(resume)
3227
  }
3228
 current=jvmpiAgent_appendStringAttribute(NODE_IDREF_ATTRIBUTE, STRLEN_NODE_IDREF_ATTRIBUTE, current, uuid , tps);
3229
 free(uuid);
3230
#else
3231
 current=jvmpiAgent_appendStringAttribute(NODE_IDREF_ATTRIBUTE, STRLEN_NODE_IDREF_ATTRIBUTE, current, ra_getNodeUUID(_jvmpiAgent_bindingStorage) , tps);
3232
#endif
3233
 if(_jvmpiAgent_Options.timestamp) {
3234
	current=jvmpiAgent_appendTimestamp(tps->buffer, current, time);
3235
 }
3236
/* 8884 */
3237
/* current=jvmpiAgent_appendStringAttribute(APPLICATION_NAME_ATTRIBUTE, STRLEN_APPLICATION_NAME_ATTRIBUTE, current, ra_getProcessCommandLine() , tps->buffer); */
3238
/* 8884 */
3239
 current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3240
 jvmpiAgent_print(tps, tps->buffer, current);
3241
}
3242
3243
3244
/** PRINT_EXCEPTION_ELEMENT  ***********************************************
3245
  *
3246
  */
3247
void jvmpiAgent_printExceptionElement(JNIEnv *env,
3248
									  ThreadLocalStorage *tps,
3249
									  enum ThrowOrCatch type,
3250
									  HashEntry *methodHashEntry,
3251
									  jobjectID objId,
3252
									  jthrowable e)
3253
{
3254
 HashEntry *objectHashEntry = jvmpiAgent_FindObjectSymbolWithAllocate(objId, env);
3255
 unsigned short current=0;
3256
3257
 current=jvmpiAgent_insertEmptyEventHeader(env, tps, type == Throw ? THROW_ELEMENT : CATCH_ELEMENT, (unsigned short) (type == Throw ? STRLEN_THROW_ELEMENT : STRLEN_CATCH_ELEMENT));
3258
3259
 /* Get the timestamp information if necessary */
3260
 if(_jvmpiAgent_Options.timestamp)
3261
 {
3262
  current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
3263
 }
3264
 if (jvmpiAgent_isPrintObjId())
3265
 {
3266
  if (objId)
3267
  {
3268
   current=jvmpiAgent_appendIntegerAttribute(OBJ_IDREF_ATTRIBUTE, STRLEN_OBJ_IDREF_ATTRIBUTE, current, (unsigned long)objId, tps->buffer);
3269
  }
3270
  else
3271
  {
3272
   current=jvmpiAgent_appendStringAttribute(OBJ_IDREF_ATTRIBUTE, STRLEN_OBJ_IDREF_ATTRIBUTE, current, UNAVAILABLE, tps);
3273
  }
3274
 }
3275
 if (jvmpiAgent_isPrintStaticId())
3276
 {
3277
  if (objId && objectHashEntry)
3278
  {
3279
   current=jvmpiAgent_appendIntegerAttribute(STATIC_OBJ_IDREF_ATTRIBUTE, STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current, ((ObjectEntry*)objectHashEntry->entry)->static_id, tps->buffer);
3280
  }
3281
  else
3282
  {
3283
   current=jvmpiAgent_appendStringAttribute(STATIC_OBJ_IDREF_ATTRIBUTE, STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE, current, UNAVAILABLE, tps);
3284
  }
3285
 }
3286
 current=jvmpiAgent_appendIntegerAttribute(OBJ_HANDLE_ATTRIBUTE, STRLEN_OBJ_HANDLE_ATTRIBUTE, current, (unsigned long)e, tps->buffer);
3287
 current=jvmpiAgent_appendIntegerAttribute(METHOD_IDREF_ATTRIBUTE, STRLEN_METHOD_IDREF_ATTRIBUTE, current, (jint)(((MethodEntry *)methodHashEntry->entry)->methodData.method_id), tps->buffer);
3288
3289
 if(_jvmpiAgent_Options.ticket)
3290
 {
3291
  current=jvmpiAgent_printTicketAttribute(&jvmpiAgent_Peek(tps,2)->ticket,tps->buffer, current);
3292
 }
3293
3294
 /*##MW There is a race condition between the increment and the print that must be fixed */
3295
 jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
3296
 current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
3297
3298
 current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
3299
 current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3300
 jvmpiAgent_print(tps, tps->buffer, current);
3301
}
3302
3303
/** PRINT_LINE_ELEMENT  ****************************************************
3304
  *
3305
  */
3306
void jvmpiAgent_printLineElement(JNIEnv *env,
3307
								 ThreadLocalStorage *tps,
3308
								 HashEntry *methodHashEntry,
3309
								 unsigned short lineNumber)
3310
{
3311
  unsigned short current=0;
3312
3313
  current=jvmpiAgent_insertEmptyEventHeader(env, tps, LINE_ELEMENT, STRLEN_LINE_ELEMENT);
3314
  /* Get the timestamp information if necessary */
3315
  if(_jvmpiAgent_Options.timestamp)
3316
  {
3317
   current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
3318
  }
3319
3320
  current=jvmpiAgent_appendIntegerAttribute(LINE_NUMBER_ATTRIBUTE, STRLEN_LINE_NUMBER_ATTRIBUTE, current, lineNumber, tps->buffer);
3321
  current=jvmpiAgent_appendIntegerAttribute(METHOD_IDREF_ATTRIBUTE, STRLEN_METHOD_IDREF_ATTRIBUTE, current, (jint)(((MethodEntry *)methodHashEntry->entry)->methodData.method_id), tps->buffer);
3322
3323
  /*##MW There is a race condition between the increment and the print that must be fixed */
3324
  jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
3325
  current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
3326
  current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
3327
  current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3328
  jvmpiAgent_print(tps, tps->buffer, current);
3329
}
3330
3331
void jvmpiAgent_printAgentCreateElement(ThreadLocalStorage *tps,
3332
										char *options)
3333
{
3334
 unsigned short current=0;
3335
#ifdef MVS
3336
 char *uuid;
3337
 int uuidlen;
3338
#endif
3339
3340
 current=jvmpiAgent_insertElementStart(AGENT_CREATE_ELEMENT, STRLEN_AGENT_CREATE_ELEMENT, tps);
3341
/* 199373 begin */
3342
#ifdef MVS
3343
  uuidlen = strlen(ra_getAgentUUID(_jvmpiAgent_bindingStorage));
3344
  uuid = (char *)malloc(uuidlen+1);   /* 192196 */
3345
  if (uuid == NULL) {
3346
#pragma convlit(suspend)
3347
     printf("Memory allocation failure.\n");
3348
	 fflush(stdout); 
3349
#pragma convlit(resume)
3350
     return;
3351
  }
3352
  strcpy(uuid, ra_getAgentUUID(_jvmpiAgent_bindingStorage));
3353
  if (uuidlen != __etoa(uuid)) {
3354
#pragma convlit(suspend)
3355
      printf("EBCDIC to ASCII conversion failure.\n");
3356
	  fflush(stdout); 
3357
#pragma convlit(resume)
3358
  }
3359
 current=jvmpiAgent_appendStringAttribute(AGENT_ID_ATTRIBUTE, STRLEN_AGENT_ID_ATTRIBUTE, current, uuid, tps);
3360
 free(uuid);
3361
#else
3362
 current=jvmpiAgent_appendStringAttribute(AGENT_ID_ATTRIBUTE, STRLEN_AGENT_ID_ATTRIBUTE, current, ra_getAgentUUID(_jvmpiAgent_bindingStorage) , tps);
3363
#endif
3364
/* 199373 end */
3365
3366
 current=jvmpiAgent_appendStringAttribute(AGENT_VERSION_ATTRIBUTE, STRLEN_AGENT_VERSION_ATTRIBUTE, current, AGENT_VERSION, tps);
3367
3368
#ifdef MVS
3369
  uuidlen = strlen(ra_getProcessUUID(_jvmpiAgent_bindingStorage));
3370
  uuid = (char *)malloc(uuidlen+1);   /* 192196 */
3371
  if (uuid == NULL) {
3372
#pragma convlit(suspend)
3373
     printf("Memory allocation failure.\n");
3374
	 fflush(stdout); 
3375
#pragma convlit(resume)
3376
     return;
3377
  }
3378
  strcpy(uuid, ra_getProcessUUID(_jvmpiAgent_bindingStorage));
3379
  if (uuidlen != __etoa(uuid)) {
3380
#pragma convlit(suspend)
3381
      printf("EBCDIC to ASCII conversion failure.\n");
3382
	  fflush(stdout); 
3383
#pragma convlit(resume)
3384
  }
3385
 current=jvmpiAgent_appendStringAttribute(PROCESS_IDREF_ATTRIBUTE, STRLEN_PROCESS_IDREF_ATTRIBUTE, current, uuid, tps);
3386
 free(uuid);
3387
#else
3388
 current=jvmpiAgent_appendStringAttribute(PROCESS_IDREF_ATTRIBUTE, STRLEN_PROCESS_IDREF_ATTRIBUTE, current, ra_getProcessUUID(_jvmpiAgent_bindingStorage) , tps);
3389
#endif
3390
 current=jvmpiAgent_appendStringAttribute(AGENT_NAME_ATTRIBUTE, STRLEN_AGENT_NAME_ATTRIBUTE, current, _jvmpiAgent_Options.processName , tps);
3391
 current=jvmpiAgent_appendStringAttribute(AGENT_TYPE_ATTRIBUTE, STRLEN_AGENT_TYPE_ATTRIBUTE, current, _jvmpiAgent_Options.processType , tps);
3392
 current=jvmpiAgent_appendStringAttribute(AGENT_PARAMETERS_ATTRIBUTE, STRLEN_AGENT_PARAMETERS_ATTRIBUTE, current, options , tps);
3393
 if(_jvmpiAgent_Options.timestamp) {
3394
	current=jvmpiAgent_appendTimestamp(tps->buffer, current, _startTimeAsTicks);
3395
 }
3396
 current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3397
 jvmpiAgent_print(tps, tps->buffer, current);
3398
}
3399
3400
/* PR Object Ref */
3401
void jvmpiAgent_printHDStartElement(ThreadLocalStorage *tps,
3402
									char* heapDefName)
3403
{
3404
  if(_jvmpiAgent_Options.jinsightFormat) {
3405
  } else {
3406
	unsigned short current=0;
3407
	current=jvmpiAgent_insertElementStart(HD_START_ELEMENT, STRLEN_HD_START_ELEMENT, tps);
3408
	current=jvmpiAgent_appendIntegerAttribute(HEAPDUMP_ID_ATTRIBUTE, STRLEN_HEAPDUMP_ID_ATTRIBUTE, current, _heapDumpInfo.index, tps->buffer);
3409
	if(_jvmpiAgent_Options.timestamp)
3410
	{
3411
		current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
3412
	}
3413
    current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
3414
	current=jvmpiAgent_appendStringAttribute(NAME_ATTRIBUTE, STRLEN_NAME_ATTRIBUTE, current, heapDefName, tps);
3415
	current=jvmpiAgent_appendLabeledTimestamp(tps->buffer, current, BASETIME_ATTRIBUTE, STRLEN_BASETIME_ATTRIBUTE, _heapDumpInfo.lastGenerationTime, FALSE);
3416
	current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3417
	jvmpiAgent_print(tps, tps->buffer, current);
3418
  }
3419
}
3420
3421
/* Added "firstSeen" for bug 46785 */
3422
void jvmpiAgent_printObjectArrayReferenceElement(ThreadLocalStorage *tps,
3423
												 unsigned long obj_id,
3424
												 unsigned int index,
3425
												 jint objRef_id,
3426
												 unsigned int firstSeen)
3427
{
3428
  if(_jvmpiAgent_Options.jinsightFormat) {
3429
#ifdef BINARY_TRACE
3430
    unsigned short numBytes = BINARYTRACE_printArrayReference(tps->buffer, obj_id, objRef_id);
3431
    jvmpiAgent_print(tps, tps->buffer, numBytes);
3432
#endif /* BINARY_TRACE */
3433
  } else {
3434
	unsigned short current=0;
3435
	current=jvmpiAgent_insertElementStart(OBJECT_REFERENCE_ATTRIBUTE, STRLEN_OBJECT_REFERENCE_ATTRIBUTE, tps);
3436
	current=jvmpiAgent_appendIntegerAttribute(OBJECT_OWNER_ATTRIBUTE, STRLEN_OBJECT_OWNER_ATTRIBUTE, current, obj_id, tps->buffer);
3437
	current=jvmpiAgent_appendIntegerAttribute(OBJECT_TARGET_ATTRIBUTE, STRLEN_OBJECT_TARGET_ATTRIBUTE, current, objRef_id, tps->buffer);
3438
	current=jvmpiAgent_appendIntegerAttribute(OBJECT_ARRAY_INDEX_ATTRIBUTE, STRLEN_OBJECT_ARRAY_INDEX_ATTRIBUTE, current, index, tps->buffer);
3439
	current=jvmpiAgent_appendIntegerAttribute(HEAPDUMP_IDREF_ATTRIBUTE, STRLEN_HEAPDUMP_IDREF_ATTRIBUTE, current, _heapDumpInfo.index, tps->buffer);
3440
	current=jvmpiAgent_appendIntegerAttribute(HEAPDUMP_FIRST_SEEN_ATTRIBUTE, STRLEN_HEAPDUMP_FIRST_SEEN_ATTRIBUTE, current, firstSeen, tps->buffer);
3441
	current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3442
	jvmpiAgent_print(tps, tps->buffer, current);
3443
  }
3444
}
3445
3446
/* Added "firstSeen" for bug 46785 */
3447
void jvmpiAgent_printObjectInstanceReferenceElement(ThreadLocalStorage *tps,
3448
													unsigned long obj_id,
3449
													unsigned int index,
3450
													jint objRef_id,
3451
													unsigned int firstSeen,
3452
													unsigned long fieldIdRef)
3453
{
3454
  if(_jvmpiAgent_Options.jinsightFormat) {
3455
#ifdef BINARY_TRACE
3456
    unsigned short numBytes = BINARYTRACE_printObjectReference(tps->buffer, obj_id, objRef_id);
3457
    jvmpiAgent_print(tps, tps->buffer, numBytes);
3458
#endif /* BINARY_TRACE */
3459
  } else {
3460
	unsigned short current=0;
3461
	current=jvmpiAgent_insertElementStart(OBJECT_REFERENCE_ATTRIBUTE, STRLEN_OBJECT_REFERENCE_ATTRIBUTE, tps);
3462
	current=jvmpiAgent_appendIntegerAttribute(OBJECT_OWNER_ATTRIBUTE, STRLEN_OBJECT_OWNER_ATTRIBUTE, current, obj_id, tps->buffer);
3463
	current=jvmpiAgent_appendIntegerAttribute(OBJECT_TARGET_ATTRIBUTE, STRLEN_OBJECT_TARGET_ATTRIBUTE, current, objRef_id, tps->buffer);
3464
	current=jvmpiAgent_appendIntegerAttribute(FIELD_IDREF_ATTRIBUTE, STRLEN_FIELD_IDREF_ATTRIBUTE, current, fieldIdRef, tps->buffer);
3465
	current=jvmpiAgent_appendIntegerAttribute(HEAPDUMP_IDREF_ATTRIBUTE, STRLEN_HEAPDUMP_IDREF_ATTRIBUTE, current, _heapDumpInfo.index, tps->buffer);
3466
	current=jvmpiAgent_appendIntegerAttribute(HEAPDUMP_FIRST_SEEN_ATTRIBUTE, STRLEN_HEAPDUMP_FIRST_SEEN_ATTRIBUTE, current, firstSeen, tps->buffer);
3467
	current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3468
	jvmpiAgent_print(tps, tps->buffer, current);
3469
  }
3470
}
3471
/* PR */
3472
3473
void jvmpiAgent_printStaticReferenceElement(ThreadLocalStorage *tps,
3474
											unsigned long class_id,
3475
											unsigned int index,
3476
											jint objRef_id,
3477
											unsigned long fieldIdRef) {
3478
  if(_jvmpiAgent_Options.jinsightFormat) {
3479
#ifdef BINARY_TRACE
3480
    unsigned short numBytes = BINARYTRACE_printClassReference(tps->buffer, class_id, objRef_id);
3481
    jvmpiAgent_print(tps, tps->buffer, numBytes);
3482
#endif /* BINARY_TRACE */
3483
  } else {
3484
	unsigned short current=0;
3485
	current=jvmpiAgent_insertElementStart(STATIC_REFERENCE_ATTRIBUTE, STRLEN_STATIC_REFERENCE_ATTRIBUTE, tps);
3486
	current=jvmpiAgent_appendIntegerAttribute(CLASS_OWNER_ATTRIBUTE, STRLEN_CLASS_OWNER_ATTRIBUTE, current, class_id, tps->buffer);
3487
	current=jvmpiAgent_appendIntegerAttribute(OBJECT_TARGET_ATTRIBUTE, STRLEN_OBJECT_TARGET_ATTRIBUTE, current, objRef_id, tps->buffer);
3488
	current=jvmpiAgent_appendIntegerAttribute(FIELD_IDREF_ATTRIBUTE, STRLEN_FIELD_IDREF_ATTRIBUTE, current, fieldIdRef, tps->buffer);
3489
	current=jvmpiAgent_appendIntegerAttribute(HEAPDUMP_IDREF_ATTRIBUTE, STRLEN_HEAPDUMP_IDREF_ATTRIBUTE, current, _heapDumpInfo.index, tps->buffer);
3490
	current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3491
	jvmpiAgent_print(tps, tps->buffer, current);
3492
  }
3493
}
3494
3495
void jvmpiAgent_printXMLStartElement(ThreadLocalStorage *tps)
3496
{
3497
 if (!_jvmpiAgent_suspendIO)
3498
 {
3499
  unsigned short current=0;
3500
  char *data="?xml version=\"1.0\"?>";
3501
  current=jvmpiAgent_insertElementStart(data, 20,  tps);
3502
  jvmpiAgent_print(tps, tps->buffer, current);
3503
 }
3504
}
3505
3506
3507
/** PRINT_VM_SUSPEND  ************************************************************
3508
  * Loads the memory address specified by 'buffer' with a Suspend entity including
3509
  * timestamp.
3510
  */
3511
extern void jvmpiAgent_printVMSuspend(ThreadLocalStorage *tps)
3512
{
3513
 if(!_jvmpiAgent_suspendIO)
3514
 {
3515
  unsigned short current=0;
3516
  current=jvmpiAgent_insertElementStart(PROCESS_SUSPEND_ELEMENT, STRLEN_PROCESS_SUSPEND_ELEMENT, tps);
3517
  /* Get the timestamp information if necessary */
3518
  if (_jvmpiAgent_Options.timestamp)
3519
  {
3520
   current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
3521
  }
3522
  current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
3523
  current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3524
  jvmpiAgent_print(tps, tps->buffer, current);
3525
 }
3526
}
3527
3528
3529
/** PRINT_VM_RESUME  ************************************************************
3530
  * Loads the memory address specified by 'buffer' with a Resume entity including
3531
  * timestamp.
3532
  */
3533
extern void jvmpiAgent_printVMResume(ThreadLocalStorage *tps)
3534
{
3535
 if(!_jvmpiAgent_suspendIO)
3536
 {
3537
  unsigned short current=0;
3538
  current=jvmpiAgent_insertElementStart(PROCESS_RESUME_ELEMENT, STRLEN_PROCESS_RESUME_ELEMENT, tps);
3539
  /* Get the timestamp information if necessary */
3540
  if(_jvmpiAgent_Options.timestamp)
3541
  {
3542
   current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
3543
  }
3544
  current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
3545
  current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3546
  jvmpiAgent_print(tps, tps->buffer, current);
3547
 }
3548
}
3549
3550
3551
void jvmpiAgent_printStandaloneTraceTagOpen(ThreadLocalStorage *tps)
3552
{
3553
  strcpy(tps->buffer, "<TRACE>");
3554
  jvmpiAgent_print(tps, tps->buffer, (unsigned short)strlen(tps->buffer));
3555
}
3556
3557
3558
void jvmpiAgent_printStandaloneTraceTagClose(ThreadLocalStorage *tps)
3559
{
3560
  strcpy(tps->buffer, "</TRACE>");
3561
  jvmpiAgent_print(tps, tps->buffer, (unsigned short)strlen(tps->buffer));
3562
}
3563
3564
3565
void jvmpiAgent_printAgentDestroyElement(ThreadLocalStorage *tps)
3566
{
3567
 if(!_jvmpiAgent_suspendIO)
3568
 {
3569
/* 199373 begin */
3570
#ifdef MVS
3571
  char *uuid;
3572
  int uuidlen;
3573
#endif
3574
  unsigned short current=0;
3575
  current=jvmpiAgent_insertElementStart(AGENT_DESTROY_ELEMENT, STRLEN_AGENT_DESTROY_ELEMENT, tps);
3576
3577
#ifdef MVS
3578
  uuidlen = strlen(ra_getAgentUUID(_jvmpiAgent_bindingStorage));
3579
  uuid = (char *)malloc(uuidlen+1);   /* 192196 */
3580
  if (uuid == NULL) {
3581
#pragma convlit(suspend)
3582
     printf("Memory allocation failure.\n");
3583
	 fflush(stdout); 
3584
#pragma convlit(resume)
3585
     return;
3586
  }
3587
  strcpy(uuid, ra_getAgentUUID(_jvmpiAgent_bindingStorage));
3588
  if (uuidlen != __etoa(uuid)) {
3589
#pragma convlit(suspend)
3590
      printf("EBCDIC to ASCII conversion failure.\n");
3591
	  fflush(stdout); 
3592
#pragma convlit(resume)
3593
  }
3594
  current=jvmpiAgent_appendStringAttribute(AGENT_IDREF_ATTRIBUTE, STRLEN_AGENT_IDREF_ATTRIBUTE, current, uuid, tps);
3595
  free(uuid);
3596
#else
3597
  current=jvmpiAgent_appendStringAttribute(AGENT_IDREF_ATTRIBUTE, STRLEN_AGENT_IDREF_ATTRIBUTE, current, ra_getAgentUUID(_jvmpiAgent_bindingStorage) , tps);
3598
#endif
3599
/* 199373 end */
3600
3601
  /* Get the timestamp information if necessary */
3602
  if(_jvmpiAgent_Options.timestamp)
3603
  {
3604
   current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
3605
  }
3606
  current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3607
  jvmpiAgent_print(tps, tps->buffer, current);
3608
 }
3609
}
3610
3611
void jvmpiAgent_printJvmShutdownElement(JVMPI_Event *event) {
3612
 if (!_jvmpiAgent_suspendIO)
3613
 {
3614
  ThreadPrivateStorage *tps = jvmpiAgent_getThreadLocalStorage(0);
3615
  /* char * buffer = tps->buffer; Get the global work thread buffer */
3616
3617
  if(_jvmpiAgent_Options.jinsightFormat) {
3618
#ifdef BINARY_TRACE
3619
    BINARYTRACE_printTraceEnd(tps);
3620
#endif /* BINARY_TRACE */
3621
  }
3622
  else {
3623
  unsigned short current=0;
3624
  current=jvmpiAgent_insertEmptyEventHeader(event->env_id, tps, JVM_SHUT_DOWN_ELEMENT, STRLEN_JVM_SHUT_DOWN_ELEMENT);
3625
  /* Get the timestamp information if necessary */
3626
  if(_jvmpiAgent_Options.timestamp)
3627
  {
3628
   current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
3629
  }
3630
  jvmpiAgent_incrementSegmentedValue(&_jvmpiAgent_collation, 0);
3631
  current=jvmpiAgent_printCollationValueAttribute(tps->buffer, current, &_jvmpiAgent_collation);
3632
  current=jvmpiAgent_printTraceIdrefAttribute(tps, current);
3633
  current=jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3634
  jvmpiAgent_print(tps, tps->buffer, current);
3635
  /* If a global method count was asked for,  print it out */
3636
  if (_jvmpiAgent_Options.methodCounts)
3637
  {
3638
   jvmpiAgent_ForAll(Method_t, jvmpiAgent_printMethodCount, tps);
3639
  }
3640
3641
  /* Print the closing tag */
3642
  jvmpiAgent_printTraceEndElement(tps);
3643
  jvmpiAgent_printAgentDestroyElement(tps);
3644
 }
3645
 }
3646
}
3647
3648
void jvmpiAgent_printTraceStopElement(ThreadLocalStorage *tps) {
3649
 unsigned short current=0;
3650
 current=jvmpiAgent_insertElementStart(TRACE_STOP_ELEMENT, STRLEN_TRACE_STOP_ELEMENT, tps);
3651
 if(_jvmpiAgent_Options.timestamp) {
3652
	current=jvmpiAgent_appendCurrentTimeStamp(tps->buffer, current);
3653
 }
3654
 jvmpiAgent_appendElementEnd(NULL, 0, current, tps);
3655
 jvmpiAgent_print(tps, tps->buffer, current);
3656
}
(-)src-native-new/src/agents/native/java_profiler/utility.c (+118 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: utility.c,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include "utility.h"
14
#include "JvmpiWriter.h"
15
#include <stdlib.h>
16
17
/********************************************************
18
 * strcpyrealloc()
19
 * 
20
 * Copy one string to the other, first reallocating the 
21
 * space pointed to by the destination so that the src
22
 * can comfortably fit in it. 
23
 * @param dest address of the destination buffer 
24
 * @param src the source string 
25
 * @return 0 if successful, -1 otherwise 
26
 */ 
27
28
int strcpyrealloc(char **dest, const char *src) {
29
	char *tmp; 
30
	if (*dest) {
31
		/* if realloc fails, we don't want to overwrite *dest or we'll get
32
		   a memory leak */ 
33
		tmp = (char *)realloc(*dest,strlen(src)+1); 
34
	} else {
35
		tmp = (char *)malloc(strlen(src)+1); 
36
	}
37
	if (!tmp) {
38
		return -1; 
39
	} else {
40
		*dest = tmp;
41
	}
42
	strcpy(*dest,src); 
43
	return 0; 
44
}
45
46
/** CALLOC  *************************************************************
47
  * Allocate some memory from the heap.  If there is no more memory left
48
  * the VM will exit gracefully.
49
  */
50
extern void* jvmpiAgent_Calloc(unsigned int size) {
51
	void *p=malloc(size);
52
	if(p==NULL) {
53
		fprintf(stderr, "FATAL ERROR:  Out of memory...JVM Exiting\n");
54
		fflush(stderr); 
55
		_jvmpiAgent_jvmpiInterface->ProfilerExit((jint)-1);
56
	}
57
	memset(p, 0, size);
58
	return p;
59
}
60
61
62
#ifdef MVS                    
63
#pragma convlit(suspend)
64
#endif
65
unsigned short double2string(double val, char *buffer, unsigned short offset, int precision) {
66
67
	int i; 
68
	Uint64 digits;
69
70
	digits = (Uint64) val; 
71
	
72
	/* print the values that occur before the decimal */ 
73
	offset += sprintf(&buffer[offset], "%lld", digits); 
74
 
75
	/* hard code the period '.' as the decimal symbol */ 
76
	buffer[offset++] = '.'; 
77
	/* get the digits to the right of the decimal */ 
78
#ifdef _WIN32
79
	val = val - (signed __int64)digits; 
80
#else 
81
	val = val - digits; 
82
#endif
83
	/* move the digits to the right of the decimal to be to the left */ 
84
	/* the following loop essentially shifts each digit left, at which point we grab
85
	   it and add it to the string. */ 
86
	for (i = 0; i < precision; i++) {
87
		val = val * 10; 
88
	    /* get the next digit */ 
89
		digits = (Uint64) val; 
90
		buffer[offset++] = '0' + (char)digits; 
91
#ifdef _WIN32
92
		val = val - (signed __int64)digits; 
93
#else
94
		val = val - digits; 
95
#endif
96
	}
97
	return offset; 
98
}
99
#ifdef MVS                    
100
#pragma convlit(resume)
101
#endif
102
103
104
#ifdef _WIN32
105
char *realpath(const char* fileName, char * buf)
106
{
107
	LPTSTR foo;
108
109
	GetFullPathName (fileName, PATH_MAX, buf, &foo);
110
	return buf;
111
}
112
#elif defined(__OS400__)
113
char *realpath(const char* fileName, char * buf)
114
{
115
	strcpy(buf, fileName);
116
	return buf;
117
}
118
#endif
(-)src-native-new/src/agents/RABindings/version.rc (+110 lines)
Added Link Here
1
#include "../../../include/tptp/version.h"
2
//Microsoft Developer Studio generated resource script.
3
//
4
#include "resource.h"
5
6
#define APSTUDIO_READONLY_SYMBOLS
7
/////////////////////////////////////////////////////////////////////////////
8
//
9
// Generated from the TEXTINCLUDE 2 resource.
10
//
11
#include "afxres.h"
12
13
/////////////////////////////////////////////////////////////////////////////
14
#undef APSTUDIO_READONLY_SYMBOLS
15
16
/////////////////////////////////////////////////////////////////////////////
17
// English (U.S.) resources
18
19
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20
#ifdef _WIN32
21
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
22
#pragma code_page(1252)
23
#endif //_WIN32
24
25
#ifndef _MAC
26
/////////////////////////////////////////////////////////////////////////////
27
//
28
// Version
29
//
30
31
VS_VERSION_INFO VERSIONINFO
32
 FILEVERSION _VERSION_WIN
33
 PRODUCTVERSION _VERSION_WIN
34
 FILEFLAGSMASK 0x3fL
35
#ifdef _DEBUG
36
 FILEFLAGS 0x1L
37
#else
38
 FILEFLAGS 0x0L
39
#endif
40
 FILEOS 0x40004L
41
 FILETYPE 0x2L
42
 FILESUBTYPE 0x0L
43
BEGIN
44
    BLOCK "StringFileInfo"
45
    BEGIN
46
        BLOCK "040904b0"
47
        BEGIN
48
            VALUE "Comments", "\0"
49
            VALUE "CompanyName", _COMPANY_NAME
50
            VALUE "FileDescription", "Agent Controller Agent Bindings Library\0"
51
            VALUE "FileVersion", _VERSION
52
            VALUE "InternalName", "hcbnd\0"
53
            VALUE "LegalCopyright", _COPYRIGHT
54
            VALUE "LegalTrademarks", "\0"
55
            VALUE "OriginalFilename", "hcbnd.dll\0"
56
            VALUE "PrivateBuild", "\0"
57
            VALUE "ProductName", "\0"
58
            VALUE "ProductVersion", _VERSION
59
            VALUE "SpecialBuild", "\0"
60
        END
61
    END
62
    BLOCK "VarFileInfo"
63
    BEGIN
64
        VALUE "Translation", 0x409, 1200
65
    END
66
END
67
68
#endif    // !_MAC
69
70
71
#ifdef APSTUDIO_INVOKED
72
/////////////////////////////////////////////////////////////////////////////
73
//
74
// TEXTINCLUDE
75
//
76
77
1 TEXTINCLUDE DISCARDABLE 
78
BEGIN
79
    "resource.h\0"
80
END
81
82
2 TEXTINCLUDE DISCARDABLE 
83
BEGIN
84
    "#include ""afxres.h""\r\n"
85
    "\0"
86
END
87
88
3 TEXTINCLUDE DISCARDABLE 
89
BEGIN
90
    "\r\n"
91
    "\0"
92
END
93
94
#endif    // APSTUDIO_INVOKED
95
96
#endif    // English (U.S.) resources
97
/////////////////////////////////////////////////////////////////////////////
98
99
100
101
#ifndef APSTUDIO_INVOKED
102
/////////////////////////////////////////////////////////////////////////////
103
//
104
// Generated from the TEXTINCLUDE 3 resource.
105
//
106
107
108
/////////////////////////////////////////////////////////////////////////////
109
#endif    // not APSTUDIO_INVOKED
110
(-)src-native-new/src/agents/perfmon/resutils/library.c (+118 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: library.c,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
/***********************************************************************
14
 *
15
 * File: Library.c
16
 *
17
 ***********************************************************************/
18
19
#include "system.h"
20
21
/***********************************************************************
22
 * Function: XLibraryCreate
23
 * Purpose: 
24
 * Parameters: 
25
 * Returns: 
26
 ***********************************************************************/
27
28
int XLibraryCreate(XLibrary *library, char *filename)
29
{
30
  //fprintf(stderr,"XLibraryCreate called for %s\n",filename);
31
	char* newfilename;
32
	newfilename = (char*) malloc(sizeof(char)*(strlen(filename)+7));
33
#ifdef WIN32
34
  if ((library->instance = LoadLibrary(filename)) == NULL)
35
  {
36
#ifdef DEBUG
37
//    XLoggerPrintf("LoadLibrary(\"%s\") failed [%d]\n", filename, GetLastError());
38
#endif
39
    return XLIBRARY_ERROR_CREATE;
40
  }
41
#endif
42
#if defined(SOLARIS) || defined(LINUX) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)	
43
	sprintf(newfilename,"lib%s.so",filename);
44
	
45
  if ((library->handle = dlopen(newfilename, RTLD_LAZY)) == NULL)
46
  {
47
#ifdef DEBUG
48
    const char *e;
49
    while ((e = dlerror())) fprintf(stderr, "dlerror: %s\n", e);
50
#endif
51
    fprintf(stderr,"XLibraryCreate FAILED! (%s - %d)\n",filename,(int)library->handle);
52
		free(newfilename);
53
    return FAILURE;
54
  }
55
#endif
56
  free(newfilename);
57
  return SUCCESS;
58
}
59
60
/***********************************************************************
61
 * Function: XLibrarySymbol
62
 * Purpose: 
63
 * Parameters: 
64
 ***********************************************************************/
65
66
int XLibrarySymbol(XLibrary *library, char *symbol, void **address)
67
{
68
#ifdef WIN32
69
  if ((*address = GetProcAddress(library->instance, symbol)) == NULL)
70
  {
71
#ifdef DEBUG
72
//    XLoggerPrintf("GetProcAddress(..., \"%s\") failed [%d]\n", symbol, GetLastError());
73
#endif
74
    return XLIBRARY_ERROR_SYMBOL;
75
  }
76
#endif
77
#if defined(SOLARIS) || defined(LINUX) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
78
  if ((*address = dlsym(library->handle, symbol)) == NULL)
79
  {
80
#ifdef DEBUG
81
    const char *e;
82
//    while ((e = dlerror())) XLoggerPrintf("dlerror: %s\n", e);
83
//    XLoggerPrintf("dlsym(..., %s\n", symbol);
84
#endif    
85
    return FAILURE;
86
  }
87
#endif
88
89
  return SUCCESS;
90
}
91
92
/***********************************************************************
93
 * Function: XLibraryDelete
94
 * Purpose: 
95
 * Parameters: 
96
 ***********************************************************************/
97
98
int XLibraryDelete(XLibrary *library)
99
{
100
#ifdef WIN32
101
  if (FreeLibrary(library->instance) == FALSE)
102
  {
103
#ifdef DEBUG
104
//    XLoggerPrintf("FreeLibrary failed [%d]\n", GetLastError());
105
#endif
106
    return XLIBRARY_ERROR_DELETE;
107
  }
108
#endif
109
#if defined(SOLARIS) || defined(LINUX) || defined(AIX) || defined(USS) || defined(HPUX) || defined(LINUX_S390) || defined(SOLARIS_I386)
110
  (void)dlclose(library->handle);
111
#endif
112
113
  return SUCCESS;
114
}
115
116
/***********************************************************************
117
 * EOF
118
 ***********************************************************************/
(-)src-native-new/src/agents/native/heapsnapshots/SnapshotAgentInterface.h (+47 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: SnapshotAgentInterface.h,v 1.3 2005/04/06 19:15:49 samwai Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef SNAPSHOT_AGENT_INTERFACE_H
14
#define SNAPSHOT_AGENT_INTERFACE_H
15
16
class SnapshotAgentInterface {
17
 public:
18
  virtual char getClassInfo(jobjectID classID,
19
			    char**    className_outvar,
20
			    char*     className_freeMe,
21
			    int*      numInterfaces_outvar,
22
			    int*      numStaticReferenceFields_outvar) = 0;
23
#ifdef __OS400__
24
  virtual char getOS400ClassInfo(jobjectID classID,
25
			    char**    className_outvar,
26
			    char*     className_freeMe,
27
			    int*      numInterfaces_outvar,
28
			    int*      numStaticReferenceFields_outvar,
29
			    unsigned int * object_dump_len,
30
			    char** object_dump_data) = 0;
31
#endif
32
  virtual char stillAlive() = 0;
33
  virtual char stillTracing() = 0;
34
  virtual char shouldIReportHeapSnapshotDuration() = 0;
35
  virtual short swap16(short n) = 0;
36
  virtual int swap32(int n) = 0;
37
  virtual char dump_read_u1(char* cursor) = 0;
38
  virtual short dump_read_u2(char* cursor) = 0;
39
  virtual int dump_read_u4(char* cursor) = 0;
40
  virtual jobjectID dump_read_jobjectID(char* cursor) = 0;
41
42
  virtual void status(const char* message) = 0;
43
  virtual void status(const char* message, int message2) = 0;
44
  virtual void error(const char* message) = 0;
45
};
46
47
#endif /* SNAPSHOT_AGENT_INTERFACE_H */
(-)src-native-new/src/agents/RABindings/hcbnd.exp (+30 lines)
Added Link Here
1
#! librabnd.so exports	
2
ra_initializeBindings
3
ra_finalizeBindings
4
ra_startListener
5
ra_stopListener	
6
ra_sendMessage
7
ra_getProcessId
8
ra_logErrorMessage
9
ra_getNodeUUID
10
ra_getProcessUUID
11
ra_getAgentUUID
12
ra_getDefaultConfiguration
13
ra_getProcessCommandLine
14
ra_requestPeerMonitor
15
ra_requestPeerMonitor2
16
ra_initializeVMLock
17
ra_setVMLock
18
ra_releaseVMLock
19
ra_testVMLock
20
ra_getVMLockState
21
ra_initializeLock
22
ra_deleteLock
23
ra_getWriteLock
24
ra_releaseWriteLock
25
ra_getReadLock
26
ra_releaseReadLock
27
ra_getPropertyValues
28
ra_logErrorMessage_return
29
ra_requestPeerMonitor_p
30
ra_requestPeerMonitor2_p
(-)src-native-new/src/agents/thread/WinBuild/hcthread.dsw (+29 lines)
Added Link Here
1
Microsoft Developer Studio Workspace File, Format Version 6.00
2
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3
4
###############################################################################
5
6
Project: "hcthread"=".\hcthread.dsp" - Package Owner=<4>
7
8
Package=<5>
9
{{{
10
}}}
11
12
Package=<4>
13
{{{
14
}}}
15
16
###############################################################################
17
18
Global:
19
20
Package=<5>
21
{{{
22
}}}
23
24
Package=<3>
25
{{{
26
}}}
27
28
###############################################################################
29
(-)src-native-new/src/agents/java/hcjbnd.h (+167 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: hcjbnd.h,v 1.4 2005/04/26 19:37:30 samwai Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include <jni.h>
14
#include "RASocket.h"
15
#include "RADataTransfer.h"
16
#include "RABindings.h"
17
/* Header for class Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton */
18
19
#ifndef _Included_Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
20
#define _Included_Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
21
#ifdef __cplusplus
22
extern "C" {
23
#endif
24
25
26
typedef struct  {
27
	BOOL dirty;
28
	BOOL monitored;
29
	char *agent_name;
30
	BOOL waitingServiceAvailMessage;
31
	ra_data_target_hdl_t targetHdl;
32
	jobject agent_logger;
33
	RA_AGENT_HANDLE bindingStorage;
34
	/* A customized command handler that can be used by native agents to register their own command handler */
35
	ra_commandHandler_t  nativeCommandHandler;
36
}logAgent_t;
37
38
extern ra_string_t* logAgent_getCurrentProcessId();
39
40
/* 198066 - Thread ID's have different types on different platforms so we'll return
41
            a TID as defined in RAComm.h
42
*/
43
extern TID logAgent_getCurrentThreadId() ;
44
45
extern logAgent_t* logAgent_registerAgent(char *name, char *type);
46
47
extern void logAgent_deregisterAgent(logAgent_t *agent);
48
49
extern void logAgent_logMessage(logAgent_t *agent, char *messageBuffer, ra_uint_t length, ra_dataFormat_t format);
50
extern long logAgent_logMessage_return(logAgent_t *agent, char *messageBuffer, ra_uint_t length, ra_dataFormat_t format); /* Bug 74367 */
51
/* Inaccessible static: _serviceAvailable */
52
/* Inaccessible static: _agentCount */
53
/*
54
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
55
 * Method:    deregister0
56
 * Signature: (Ljava/lang/String;)V
57
 */
58
JNIEXPORT void JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_deregister0
59
  (JNIEnv *, jobject, jstring);
60
61
/*
62
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
63
 * Method:    initializeEngine0
64
 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
65
 */
66
JNIEXPORT void JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_initializeEngine0
67
  (JNIEnv *, jobject, jstring, jstring);
68
69
/*
70
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
71
 * Method:    logMessage0
72
 * Signature: (Ljava/lang/String;[BII)J
73
 */
74
JNIEXPORT jlong JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_logMessage0__Ljava_lang_String_2_3BII
75
  (JNIEnv *, jobject, jstring, jbyteArray, jint, jint); /* Bug 74367 */
76
77
/*
78
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
79
 * Method:    logMessage0
80
 * Signature: (Ljava/lang/String;Ljava/lang/String;)J
81
 */
82
JNIEXPORT jlong JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_logMessage0__Ljava_lang_String_2Ljava_lang_String_2
83
  (JNIEnv *, jobject, jstring, jstring); /* Bug 74367 */
84
85
/*
86
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
87
 * Method:    logMessageUTF80
88
 * Signature: (Ljava/lang/String;Ljava/lang/String;)J
89
 */
90
JNIEXPORT jlong JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_logMessageUTF80
91
  (JNIEnv *, jobject, jstring, jstring); /* Bug 74367 */
92
93
/*
94
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
95
 * Method:    logMessageUTF81
96
 * Signature: (Ljava/lang/String;[B)J
97
 */
98
JNIEXPORT jlong JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_logMessageUTF81
99
  (JNIEnv *, jobject, jstring, jbyteArray); /* Bug 74367 */
100
101
102
/*
103
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
104
 * Method:    sendMessage0
105
 * Signature: (Ljava/lang/String;J)J
106
 */
107
JNIEXPORT jlong JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_sendMessage0__Ljava_lang_String_2J
108
  (JNIEnv *, jobject, jstring, jlong); /* Bug 74367 */
109
110
/*
111
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
112
 * Method:    sendMessage0
113
 * Signature: ([BIIJ)J
114
 */
115
JNIEXPORT jlong JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_sendMessage0___3BIIJ
116
  (JNIEnv *, jobject, jbyteArray, jint, jint, jlong); /* Bug 74367 */
117
118
/*
119
 * Class:     org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
120
 * Method:    sendMessageBinary0
121
 * Signature: ([BIIJ)J
122
 */
123
JNIEXPORT jlong JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_sendMessageBinary0
124
  (JNIEnv *, jobject, jbyteArray, jint, jint, jlong); /* Bug 74367 */
125
126
/*
127
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
128
 * Method:    requestMonitorThroughPeer0
129
 * Signature: ([BLjava/lang/String;)V
130
 */
131
JNIEXPORT void JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0___3BLjava_lang_String_2
132
	(JNIEnv *, jobject, jbyteArray, jstring);
133
/* Bug 77768 */
134
JNIEXPORT void JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0p___3BJLjava_lang_String_2
135
	(JNIEnv *, jobject, jbyteArray, jlong, jstring);
136
137
/*
138
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
139
 * Method:    requestMonitorThroughPeer0
140
 * Signature: ([BJLjava/lang/String;)V
141
 */
142
JNIEXPORT void JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0___3BJLjava_lang_String_2
143
	(JNIEnv *, jobject, jbyteArray, jlong, jstring);
144
/* Bug 77768 */
145
JNIEXPORT void JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0p___3BJJLjava_lang_String_2
146
	(JNIEnv *, jobject, jbyteArray, jlong, jlong, jstring);
147
148
/*
149
 * Bug 79816
150
 * Class:		Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
151
 * Method:		getPID0
152
 * Signature:
153
 */
154
JNIEXPORT jlong JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_getPID0(JNIEnv *env, jobject obj);
155
156
/*
157
 * Bug 79816
158
 * Class:		Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
159
 * Method:		generateUUID0
160
 * Signature:
161
 */
162
JNIEXPORT jstring JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_generateUUID0(JNIEnv *env, jobject obj);
163
164
#ifdef __cplusplus
165
}
166
#endif
167
#endif
(-)src-native-new/src/agents/native/java_profiler/JVMPIException.h (+74 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: JVMPIException.h,v 1.2 2005/02/25 22:17:34 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include <jni.h>
14
/* Header for class com_ibm_etools_logging_tracing_agent_Callback */
15
16
17
#ifndef _Included_com_ibm_etools_logging_tracing_agent_Callback
18
#define _Included_com_ibm_etools_logging_tracing_agent_Callback
19
#ifdef __cplusplus
20
extern "C" {
21
#endif
22
23
/*
24
 * Class:     com_ibm_etools_logging_tracing_agent_Profiler
25
 * Method:    initialize0
26
 * Signature: ()V
27
 */
28
JNIEXPORT jint JNICALL Java_com_ibm_etools_logging_tracing_agent_Profiler_initialize0
29
  (JNIEnv *, jobject);
30
31
/*
32
 * Class:     com_ibm_etools_logging_tracing_agent_Profiler
33
 * Method:    startProfiling0
34
 * Signature: (ZI)I
35
 */
36
JNIEXPORT jint JNICALL Java_com_ibm_etools_logging_tracing_agent_Profiler_startProfiling0
37
  (JNIEnv *, jobject, jboolean, jint);
38
39
/*
40
 * Class:     com_ibm_etools_logging_tracing_agent_Profiler
41
 * Method:    stopProfiling0
42
 * Signature: ()V
43
 */
44
JNIEXPORT void JNICALL Java_com_ibm_etools_logging_tracing_agent_Profiler_stopProfiling0
45
  (JNIEnv *, jobject);
46
47
/*
48
 * Class:     com_ibm_etools_logging_tracing_agent_Profiler
49
 * Method:    markHeap0
50
 * Signature: ()V
51
 */
52
JNIEXPORT void JNICALL Java_com_ibm_etools_logging_tracing_agent_Profiler_markHeap0
53
  (JNIEnv *, jobject);
54
55
/*
56
 * Class:     com_ibm_etools_logging_tracing_agent_Profiler
57
 * Method:    analyzeHeap0
58
 * Signature: (Ljava/lang/String;)V
59
 */
60
JNIEXPORT void JNICALL Java_com_ibm_etools_logging_tracing_agent_Profiler_analyzeHeap0
61
  (JNIEnv *, jobject, jstring);
62
63
/*
64
 * Class:     com_ibm_etools_logging_tracing_agent_Profiler
65
 * Method:    runGC0
66
 * Signature: ()V
67
 */
68
JNIEXPORT void JNICALL Java_com_ibm_etools_logging_tracing_agent_Profiler_runGC0
69
  (JNIEnv*,jobject);
70
71
#ifdef __cplusplus
72
}
73
#endif
74
#endif
(-)src-native-new/src/agents/java/hcjbnd.c (+2612 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: hcjbnd.c,v 1.17 2007/03/09 14:58:44 jkubasta Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include <stdlib.h>
14
#include <assert.h> /* fix 89008: partial */
15
#include "RABindings.h"
16
#include "RASocket.h"
17
#include "RADataTransfer.h"
18
#include "RAComm.h"
19
#include "hcjbnd.h"
20
21
/* MACRO's to simplify the JNI code. */
22
#if defined __cplusplus && defined _HPUX
23
 #define ENV(e) e
24
 #define ENVPARM(e)
25
#else
26
 #define ENV(e) (*e)
27
 #define ENVPARM(e) e,
28
#endif
29
30
31
/* MACRO to work with jlong on AS400 as it is a struct */
32
#ifndef __OS400__
33
 #define JLONG(value)  value
34
#else
35
 #define JLONG(value) value.ll
36
#endif
37
38
/* The size to grow the agent list by when it is full */
39
#define AGENT_LIST_INCREMENT 6
40
41
static BOOL _firstInstance=TRUE;
42
static ra_critsec_t _lock;
43
44
45
/* The command handlers for each of the languages */
46
static void _java_notifyMessage(ra_command_t *command);
47
static void _native_notifyMessage(ra_command_t *command);
48
49
/* Global reference to the JVM. */
50
static JavaVM		*_agent_vm;
51
52
typedef logAgent_t agent_list_entry_t;
53
54
55
typedef struct {
56
	unsigned int size;
57
	agent_list_entry_t **entries;
58
}agent_list_t;
59
60
61
static agent_list_t	_agent_list;
62
63
#ifdef _DEBUG2
64
#include <stdio.h>
65
static FILE *traceFile;
66
#endif
67
68
/** GROW_AGENT_LIST  ***********************************************************
69
  *
70
  */
71
static void growAgentList(int delta) {
72
	int newSize=_agent_list.size+delta;
73
	agent_list_entry_t **current=_agent_list.entries;
74
75
	#ifdef _DEBUG
76
	#ifdef MVS                    /* 198066 */
77
	#pragma convlit(suspend)
78
	#endif
79
	printf("LogAgent: Resizing agent list\n");
80
	#ifdef MVS                    /* 198066 */
81
	#pragma convlit(resume)
82
	#endif
83
	#endif
84
85
	_agent_list.entries=(agent_list_entry_t**)malloc(sizeof(agent_list_entry_t*)*newSize);
86
	BZERO(_agent_list.entries, newSize*sizeof(agent_list_entry_t*));
87
	if (current != NULL) {
88
		memcpy(_agent_list.entries, current, _agent_list.size*sizeof(agent_list_entry_t*));
89
	}
90
	_agent_list.size=newSize;
91
	if (current != NULL) {
92
		free(current);
93
	}
94
95
	#ifdef _DEBUG
96
	#ifdef MVS                    /* 198066 */
97
	#pragma convlit(suspend)
98
	#endif
99
	printf("LogAgent: Agent list resized to %d\n", _agent_list.size);
100
	#ifdef MVS                    /* 198066 */
101
	#pragma convlit(resume)
102
	#endif
103
	#endif
104
}
105
106
/** FIND_AGENT  ****************************************************************
107
  *
108
  */
109
static agent_list_entry_t *findAgent(char *name) {
110
	agent_list_entry_t *result=NULL;
111
	ra_mutexEnter(&_lock);
112
	if(name) {
113
		unsigned int i;
114
		for(i=0; i<_agent_list.size; i++) {
115
			if(_agent_list.entries[i] && _agent_list.entries[i]->dirty && _agent_list.entries[i]->agent_name &&strcmp(_agent_list.entries[i]->agent_name, name)==0) {
116
				result=_agent_list.entries[i];
117
				break;
118
			}
119
		}
120
	}
121
	ra_mutexExit(&_lock);
122
	return result;
123
}
124
125
/** INSERT_AGENT  **************************************************************
126
  *
127
  */
128
static  agent_list_entry_t *insertAgent(char *name) {
129
	if(name) {
130
		agent_list_entry_t *entry=findAgent(name);
131
		if(!entry) {
132
			unsigned int i;
133
			ra_mutexEnter(&_lock);
134
			for(i=0; i<_agent_list.size; i++) {
135
				if(!_agent_list.entries[i] || !_agent_list.entries[i]->dirty) {
136
					_agent_list.entries[i]=(agent_list_entry_t*)malloc(sizeof(agent_list_entry_t));
137
					_agent_list.entries[i]->dirty=TRUE;
138
					_agent_list.entries[i]->monitored=FALSE;
139
					_agent_list.entries[i]->agent_name=name;
140
					entry=_agent_list.entries[i];
141
					break;
142
				}
143
			}
144
			if(i==_agent_list.size) {
145
				growAgentList(AGENT_LIST_INCREMENT);
146
				_agent_list.entries[i]=(agent_list_entry_t*)malloc(sizeof(agent_list_entry_t));
147
				_agent_list.entries[i]->dirty=TRUE;
148
				_agent_list.entries[i]->monitored=FALSE;
149
				_agent_list.entries[i]->agent_name=name;
150
				entry=_agent_list.entries[i];
151
			}
152
			ra_mutexExit(&_lock);
153
	#ifdef _DEBUG
154
	#ifdef MVS                    
155
	#pragma convlit(suspend)
156
	#endif
157
	printf("Log Agent: insertAgent: inserted agent %s in position %d\n", name,i);
158
	#ifdef MVS                    
159
	#pragma convlit(resume)
160
	#endif
161
	#endif
162
		   return entry;
163
		}
164
	/* bugzilla 65470 start */
165
      else if (!entry->dirty) {
166
		/* An entry was found with the same name but it is not active so we will insert the new agent here */
167
         entry->dirty = TRUE;
168
         entry->monitored = FALSE;
169
         entry->waitingServiceAvailMessage = FALSE;
170
	#ifdef _DEBUG
171
	#ifdef MVS                    
172
	#pragma convlit(suspend)
173
	#endif
174
	printf("Log Agent: insertAgent: agent %s was found in the list but it wasn't dirty\n", name);
175
	#ifdef MVS                    
176
	#pragma convlit(resume)
177
	#endif
178
	#endif
179
		   return entry;
180
		}
181
		/* bugzilla 65470 end */
182
	}
183
	#ifdef _DEBUG
184
	#ifdef MVS                    
185
	#pragma convlit(suspend)
186
	#endif
187
	printf("Log Agent: insertAgent: findAgent found an active agent with name %s\n", name);
188
	#ifdef MVS                    
189
	#pragma convlit(resume)
190
	#endif
191
	#endif
192
193
	/* Insert failed either because the name was empty or an active agent already exists in the list with the same name */
194
	return NULL;
195
}
196
197
198
/**  GET_AGENT_OFFSET  *********************************************************
199
  *
200
  */
201
static int getAgentOffset(logAgent_t *agent) {
202
    unsigned int i;
203
    for(i=0; i<_agent_list.size; i++) {
204
		if(_agent_list.entries[i] == agent) {
205
			return i;
206
		}
207
	}
208
    return -1;
209
}
210
211
212
213
/** GET_CURRENT_PROCESS_ID  ****************************************************
214
  *
215
  */
216
ra_string_t* logAgent_getCurrentProcessId( ) {
217
	PID pid;
218
	char tempString[256];
219
220
	pid=ra_getProcessId();
221
222
#ifdef _WIN32
223
	   ltoa(pid,tempString,10);
224
#else
225
	   sprintf(tempString, "%d", pid);
226
#endif
227
  return ra_createRASTRING2(tempString);
228
}
229
230
231
/** GET_CURRENT_THREAD_ID  *****************************************************
232
  * Returns an integer thread id for the current thread.
233
  */
234
235
/* 198066 - Thread ID's have different types on different platforms so we'll return
236
            a TID as defined in RAComm.h
237
*/
238
TID logAgent_getCurrentThreadId()
239
{
240
#ifdef WIN32
241
   return GetCurrentThreadId();
242
#else
243
   return pthread_self();
244
#endif
245
}
246
247
/** CLEANUP_AT_EXIT  **********************************************************
248
  * The runtime calls this function when this dll is unloaded during application
249
  * termination.  This is our chance to clean up our resources.  This function
250
  * is actually pushed on the stack once per agent, yet cleans all the agents
251
  * resources each time.  This could possibly be optimized
252
  */
253
void cleanupAtExit(void) {
254
	unsigned int i;
255
	#ifdef _DEBUG
256
	#ifdef MVS                    /* 198066 */
257
	#pragma convlit(suspend)
258
	#endif
259
	printf("LogAgent: Cleaning up\n");
260
	#ifdef MVS                    /* 198066 */
261
	#pragma convlit(resume)
262
	#endif
263
	#endif
264
	for(i=0; i<_agent_list.size; i++) {
265
		if(_agent_list.entries[i] && _agent_list.entries[i]->dirty && _agent_list.entries[i]->monitored) {
266
			if(_agent_list.entries[i]->targetHdl.dtarget==RA_SHAREDMEMORY
267
						&& _agent_list.entries[i]->monitored) {
268
				#ifdef _DEBUG
269
				#ifdef MVS                    /* 198066 */
270
				#pragma convlit(suspend)
271
				#endif
272
				printf("LogAgent: Closing shared memory pipe\n");
273
				#ifdef MVS                    /* 198066 */
274
				#pragma convlit(resume)
275
				#endif
276
				#endif
277
				ra_stopFlushingShm(&_agent_list.entries[i]->targetHdl.dtargetHdl.shmHdl);
278
			}
279
			else if(_agent_list.entries[i]->targetHdl.dtarget==RA_SOCKET
280
						&& _agent_list.entries[i]->targetHdl.dtargetHdl.socketFD) {
281
				#ifdef _DEBUG
282
				#ifdef MVS                    /* 198066 */
283
				#pragma convlit(suspend)
284
				#endif
285
				printf("LogAgent: Closing socket\n");
286
				#ifdef MVS                    /* 198066 */
287
				#pragma convlit(resume)
288
				#endif
289
				#endif
290
				/** On windows the socket layer is already disabled at this point */
291
#ifndef _WIN32
292
				ra_closeSocket(_agent_list.entries[i]->targetHdl.dtargetHdl.socketFD);
293
#endif
294
			}
295
			/* Mark this agent as clean */
296
			_agent_list.entries[i]->dirty=FALSE;
297
			_agent_list.entries[i]->monitored=FALSE;
298
		}
299
	}
300
	#ifdef _DEBUG2
301
	if (traceFile != NULL) {
302
		#ifdef MVS                    /* 198066 */
303
		#pragma convlit(suspend)
304
		#endif
305
		fprintf(traceFile, "LogAgent: Cleanup complete\n");
306
		#ifdef MVS                    /* 198066 */
307
		#pragma convlit(resume)
308
		#endif
309
		fflush(traceFile);
310
		fclose(traceFile);
311
		traceFile = NULL;
312
	}
313
	#endif
314
315
    return;
316
}
317
318
/** INITIALIZE_AGENT_TABLE  ************************************************
319
  * Initialize the agent table to zero
320
  */
321
static void initializeAgentTable() {
322
	_agent_list.size=0;
323
	_agent_list.entries=NULL;
324
	ra_mutexCreate(&_lock);
325
}
326
327
328
void logAgent_deregisterAgent(logAgent_t *agent) {
329
330
	/* If someone is collecting data, close the connection */
331
	/* Close the appropriate logging mechanism */
332
	if(agent->targetHdl.dtarget==RA_SOCKET) {
333
		ra_closeSocket(agent->targetHdl.dtargetHdl.socketFD);
334
335
	}
336
	else if(agent->targetHdl.dtarget==RA_SHAREDMEMORY) {
337
		ra_stopFlushingShm(&agent->targetHdl.dtargetHdl.shmHdl);
338
	}
339
340
	#ifdef _DEBUG2
341
	#ifdef MVS
342
	#pragma convlit(suspend)
343
	#endif
344
	fprintf(traceFile, "logAgent_deregisterAgent: About to stop listener thread\n");
345
	fflush(traceFile);
346
	#ifdef MVS
347
	#pragma convlit(resume)
348
	#endif
349
	#endif
350
351
	ra_stopListener(agent->bindingStorage);
352
	/* ra_finalizeBindings(agent->bindingStorage); */  /* bugzilla 68521 - causing crash
353
													   when RAC is not running */
354
355
	agent->dirty=FALSE;
356
/*	free(agent->agent_name); */ /* Bug 168884 */
357
}
358
359
360
/** DEREGISTER_AGENT  ******************************************************
361
  * Clean up the resources associated with a single instance of a LogAgent.
362
363
  */
364
static void deregisterAgent(JNIEnv *env,
365
						   jobject obj) {
366
	jclass cls;
367
	jfieldID   isRegisteredDecl;
368
	jboolean isRegisteredInstance;
369
370
	/* Get the class object */
371
	cls=ENV(env)->GetObjectClass(ENVPARM(env) obj);
372
	if (cls == 0) {
373
		return;
374
	}
375
376
	/* Get the registered field from the instance */
377
#ifdef __OS400__
378
#pragma convert(819) /* 235033 */
379
#endif
380
	isRegisteredDecl=ENV(env)->GetFieldID(ENVPARM(env) cls, "isRegistered", "Z");
381
	if (isRegisteredDecl == 0) {
382
		return;
383
	}
384
#ifdef __OS400__
385
#pragma convert(0) /* 235033 */
386
#endif
387
	isRegisteredInstance=ENV(env)->GetBooleanField(ENVPARM(env) obj, isRegisteredDecl);
388
389
390
	if(isRegisteredInstance) {
391
		jlong jl_minus1;
392
		jfieldID mechDecl;
393
		jlong mech;
394
395
#ifdef __OS400__
396
#pragma convert(819) /* 235033 */
397
#endif
398
		mechDecl=ENV(env)->GetFieldID(ENVPARM(env) cls, "mechanism", "J");
399
#ifdef __OS400__
400
#pragma convert(0) /* 235033 */
401
#endif
402
		if (mechDecl == 0) {
403
			return;
404
		}
405
		mech=ENV(env)->GetLongField(ENVPARM(env) obj, mechDecl);
406
407
		if(JLONG(mech) >-1 && JLONG(mech)<_agent_list.size) {
408
			agent_list_entry_t *agent;
409
			agent=_agent_list.entries[JLONG(mech)];
410
411
			logAgent_deregisterAgent(agent);
412
413
			/* Set _isRegistered to FALSE */
414
			ENV(env)->SetBooleanField(ENVPARM(env) obj, isRegisteredDecl, (jboolean)FALSE);
415
			/* Clear the mechanism BRP */
416
417
            JLONG(jl_minus1)=-1;
418
			ENV(env)->SetLongField(ENVPARM(env) obj, mechDecl, jl_minus1);
419
420
			/* Clean up the global ref */
421
			ENV(env)->DeleteGlobalRef(ENVPARM(env) agent->agent_logger);
422
		}
423
	}
424
425
	#ifdef _DEBUG2
426
	if (traceFile != NULL) {
427
		#ifdef MVS                    /* 198066 */
428
		#pragma convlit(suspend)
429
		#endif
430
		fprintf(traceFile, "deregisterAgent: Agent was deregistered - close trace file.\n");
431
		fflush(traceFile);
432
		#ifdef MVS                    /* 198066 */
433
		#pragma convlit(resume)
434
		#endif
435
		fflush(traceFile);
436
		fclose(traceFile);
437
		traceFile = NULL;
438
	}
439
	#endif
440
}
441
442
static logAgent_t* registerAgent(char *name, char*type, BOOL java, JNIEnv *env, jobject obj) {
443
	logAgent_t *agent;
444
445
	#ifdef _DEBUG2
446
	#ifdef MVS
447
	#pragma convlit(suspend)
448
	#endif
449
	fprintf(traceFile, "Log Agent: In registerAgent\n");
450
	fflush(traceFile);
451
	#ifdef MVS
452
	#pragma convlit(resume)
453
	#endif
454
	#endif
455
456
	/* If this is the first instance initialize the agent table */
457
	if(_firstInstance) {
458
        atexit((void(*)())cleanupAtExit);
459
		initializeAgentTable();
460
		_firstInstance=FALSE;
461
	}
462
463
	#ifdef _DEBUG
464
	#ifdef MVS                    /* 198066 */
465
	#pragma convlit(suspend)
466
	#endif
467
	printf("Log Agent: registerAgent: after initializing agent table\n");
468
	#ifdef MVS                    /* 198066 */
469
	#pragma convlit(resume)
470
	#endif
471
	#endif
472
473
	agent=insertAgent(name);
474
	if(agent) {
475
476
		#ifdef _DEBUG
477
		#ifdef MVS                    /* 198066 */
478
		#pragma convlit(suspend)
479
		#endif
480
		printf("Log Agent: registerAgent: insertAgent succeeded for agent %s and about to initialize Bindings\n", name);
481
		#ifdef MVS                    /* 198066 */
482
		#pragma convlit(resume)
483
		#endif
484
		#endif
485
486
		/* Set the command handler for the appropriate language */
487
		if(java) {
488
489
			/* Create a reference to the logging agent */
490
			agent->agent_logger = ENV(env)->NewGlobalRef(ENVPARM(env) obj);
491
492
			/* Initialize the bindings for "server" mode initially */
493
			agent->bindingStorage=ra_initializeBindings(name,
494
				                                        type,
495
														_java_notifyMessage,
496
														FALSE);
497
		}
498
		else {
499
			agent->bindingStorage=ra_initializeBindings(name,
500
				                                        type,
501
														_native_notifyMessage,
502
														FALSE);
503
		}
504
505
		#ifdef _DEBUG2
506
		#ifdef MVS                    /* 198066 */
507
		#pragma convlit(suspend)
508
		#endif
509
		fprintf(traceFile, "Log Agent: registerAgent: starting Listener\n");
510
		fflush(traceFile);
511
		#ifdef MVS                    /* 198066 */
512
		#pragma convlit(resume)
513
		#endif
514
		#endif
515
516
		ra_startListener(agent->bindingStorage, 0);
517
518
		#ifdef _DEBUG2
519
		#ifdef MVS                    /* 198066 */
520
		#pragma convlit(suspend)
521
		#endif
522
		fprintf(traceFile, "Log Agent: registerAgent: after starting Listener\n");
523
		fflush(traceFile);
524
		#ifdef MVS                    /* 198066 */
525
		#pragma convlit(resume)
526
		#endif
527
		#endif
528
529
		agent->nativeCommandHandler = NULL;
530
		return agent;
531
	}
532
	return NULL;
533
}
534
535
536
537
logAgent_t* logAgent_registerAgent(char *name, char *type) {
538
	/* Make our ouw copies of the strings */
539
	char *nameCopy, *typeCopy;
540
	STRDUP(nameCopy, name);
541
	STRDUP(typeCopy, type);
542
	return registerAgent(nameCopy, typeCopy, FALSE, (JNIEnv*)NULL, (jobject)NULL);
543
}
544
545
546
/*
547
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
548
 * Method:    initializeEngine0
549
 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
550
 */
551
JNIEXPORT void JNICALL
552
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_initializeEngine0(JNIEnv *env,
553
                                                                  jobject obj,
554
                                                                  jstring name,
555
                                                                  jstring type) {
556
	jclass cls;
557
	jfieldID   isRegisteredDecl, mechDecl;
558
	jboolean isRegisteredInstance;
559
	agent_list_entry_t *agent;
560
	char *nameBytes, *typeBytes;
561
    jlong agentIndex;
562
563
	#ifdef _DEBUG2
564
	#ifdef MVS                    /* 198066 */
565
	#pragma convlit(suspend)
566
	#endif
567
	traceFile = fopen("logAgent.dbg", "w");
568
	fprintf(traceFile, "Log Agent: initializeEngine0: Inside Agent Intialization\n");
569
	fflush(traceFile);
570
	#ifdef MVS                    /* 198066 */
571
	#pragma convlit(resume)
572
	#endif
573
	#endif
574
575
	/* Copy the string bytes */
576
	if(name) {
577
		#ifdef _DEBUG
578
		#ifdef MVS                    /* 198066 */
579
		#pragma convlit(suspend)
580
		#endif
581
		printf("Log Agent: Copy the string bytes\n");
582
		#ifdef MVS                    /* 198066 */
583
		#pragma convlit(resume)
584
		#endif
585
		#endif
586
587
		nameBytes=copyJavaStringToNative(env, name);
588
	}
589
	else {
590
		#ifdef _DEBUG
591
		#ifdef MVS                    /* 198066 */
592
		#pragma convlit(suspend)
593
		#endif
594
		printf("Log Agent: No name to copy, return\n");
595
		#ifdef MVS                    /* 198066 */
596
		#pragma convlit(resume)
597
		#endif
598
		#endif
599
600
		return;
601
	}
602
	if(type) {
603
		#ifdef _DEBUG
604
		#ifdef MVS                    /* 198066 */
605
		#pragma convlit(suspend)
606
		#endif
607
		printf("Log Agent: Copy the type bytes\n");
608
		#ifdef MVS                    /* 198066 */
609
		#pragma convlit(resume)
610
		#endif
611
		#endif
612
613
		typeBytes=copyJavaStringToNative(env, type);
614
	}
615
	else {
616
		#ifdef _DEBUG
617
		#ifdef MVS                    /* 198066 */
618
		#pragma convlit(suspend)
619
		#endif
620
		printf("Log Agent: No type to copy, return\n");
621
		#ifdef MVS                    /* 198066 */
622
		#pragma convlit(resume)
623
		#endif
624
		#endif
625
626
		return;
627
	}
628
629
	/* Get the class object */
630
	#ifdef _DEBUG
631
	#ifdef MVS                    /* 198066 */
632
	#pragma convlit(suspend)
633
	#endif
634
	printf("Log Agent: Get the class object\n");
635
	#ifdef MVS                    /* 198066 */
636
	#pragma convlit(resume)
637
	#endif
638
	#endif
639
640
	cls=ENV(env)->GetObjectClass(ENVPARM(env) obj);
641
642
	/* Get the registered field from the instance */
643
	#ifdef _DEBUG
644
	#ifdef MVS                    /* 198066 */
645
	#pragma convlit(suspend)
646
	#endif
647
	printf("Log Agent: Get the registered field from the instance: GetFieldID()\n");
648
	#endif
649
#ifdef __OS400__
650
#pragma convert(819) /* 235033 */
651
#endif
652
	
653
	isRegisteredDecl=ENV(env)->GetFieldID(ENVPARM(env) cls, "isRegistered", "Z");
654
655
#ifdef __OS400__
656
#pragma convert(0) /* 235033 */
657
#endif
658
659
	#ifdef _DEBUG
660
	#ifdef MVS                    /* 198066 */
661
	#pragma convlit(suspend)
662
	#endif
663
	printf("Log Agent: Get the registered field from the instance: GetBooleanField()\n");	
664
	#ifdef MVS                    /* 198066 */
665
	#pragma convlit(resume)
666
	#endif
667
	#endif
668
669
	isRegisteredInstance=ENV(env)->GetBooleanField(ENVPARM(env) obj, isRegisteredDecl);
670
671
	#ifdef _DEBUG
672
	#ifdef MVS                    /* 198066 */
673
	#pragma convlit(suspend)
674
	#endif
675
	printf("Log Agent: Finished getting the registered field from the instance\n");
676
	#ifdef MVS                    /* 198066 */
677
	#pragma convlit(resume)
678
	#endif
679
	#endif
680
681
	#ifdef _DEBUG2
682
	#ifdef MVS                    /* 198066 */
683
	#pragma convlit(suspend)
684
	#endif
685
	fprintf(traceFile, "Log Agent: IsRegisteredInstance = %d\n", isRegisteredInstance);
686
	fflush(traceFile);
687
	#ifdef MVS                    /* 198066 */
688
	#pragma convlit(resume)
689
	#endif
690
	#endif
691
692
	/* Only run this method once */
693
	if(isRegisteredInstance) {
694
695
		#ifdef _DEBUG
696
		#ifdef MVS                    /* 198066 */
697
		#pragma convlit(suspend)
698
		#endif
699
		printf("Log Agent: isRegisteredInstance = true, return\n");
700
		#ifdef MVS                    /* 198066 */
701
		#pragma convlit(resume)
702
		#endif
703
		#endif
704
705
		return;
706
	}
707
708
	/* Resolve pointers back to relevent methods inside of JVM */
709
	#ifdef _DEBUG
710
	#ifdef MVS                    /* 198066 */
711
	#pragma convlit(suspend)
712
	#endif
713
	printf("Log Agent: Resolve pointer back to revelent methods inside of JVM\n");
714
	#ifdef MVS                    /* 198066 */
715
	#pragma convlit(resume)
716
	#endif
717
	#endif
718
719
	ENV(env)->GetJavaVM(ENVPARM(env) &_agent_vm);
720
721
	#ifdef _DEBUG2
722
	#ifdef MVS                    /* 198066 */
723
	#pragma convlit(suspend)
724
	#endif
725
	fprintf(traceFile, "Log Agent: about to register Agent name >%s<  type >%s<\n", nameBytes, typeBytes);
726
	fflush(traceFile);
727
	#ifdef MVS                    /* 198066 */
728
	#pragma convlit(resume)
729
	#endif
730
	#endif
731
732
	/* Create a global reference of this object (this needs to removed later)*/
733
	agent=registerAgent(nameBytes, typeBytes, TRUE, env, obj);
734
	if(agent) {
735
		jmethodID setAgentUUID;
736
		jstring agentUUID;
737
738
		/* Place the index of the agent in the Java layer for fast reference later */
739
#ifdef __OS400__
740
#pragma convert(819) /* 235033 */
741
#endif
742
	    mechDecl=ENV(env)->GetFieldID(ENVPARM(env) cls, "mechanism", "J");
743
744
#ifdef __OS400__
745
#pragma convert(0) /* 235033 */
746
#endif
747
        if(mechDecl) {
748
            JLONG(agentIndex)=getAgentOffset(agent);
749
            if(JLONG(agentIndex)>-1) {
750
	    	    ENV(env)->SetLongField(ENVPARM(env) obj, mechDecl, agentIndex);
751
            }
752
        }
753
754
		/* Set the agentUUID back in the Java layer.
755
		 *  RKD: This is only in the V5 or greater Java layer.  We need to catch the exception.
756
		 */
757
#ifdef __OS400__
758
#pragma convert(819) /* 235033 */
759
#endif
760
		setAgentUUID=ENV(env)->GetMethodID(ENVPARM(env) cls, "setAgentUUID", "(Ljava/lang/String;)V");
761
762
#ifdef __OS400__
763
#pragma convert(0) /* 235033 */
764
#endif
765
		if(setAgentUUID) {
766
			agentUUID = getnewstrutf(env, agent -> bindingStorage -> agentUUID.data);
767
			ENV(env)->CallVoidMethod(ENVPARM(env) agent->agent_logger, setAgentUUID, agentUUID);
768
		}
769
770
771
		#ifdef _DEBUG
772
		#ifdef MVS                    
773
		#pragma convlit(suspend)
774
		#endif
775
		printf("Log Agent: SetBooleanField\n");
776
		#ifdef MVS
777
		#pragma convlit(resume)
778
		#endif
779
		#endif
780
		/* bugzilla 65470 - moved this line here from above because before it was being set
781
         * even when registration failed.  Here we are sure registration succeeded.
782
		 *
783
  		 * Done registering so set the isRegistered flag in the java object */
784
		ENV(env)->SetBooleanField(ENVPARM(env) obj, isRegisteredDecl, (jboolean)TRUE);
785
	
786
	}
787
}
788
789
/*
790
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
791
 * Method:    deregister0
792
 * Signature: (Ljava/lang/String;)V
793
 */
794
JNIEXPORT void JNICALL
795
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_deregister0(JNIEnv *env,
796
                                                            jobject obj,
797
                                                            jstring name) {
798
	#ifdef _DEBUG2
799
	#ifdef MVS                    /* 198066 */
800
	#pragma convlit(suspend)
801
	#endif
802
	fprintf(traceFile, "_deregister0: Java code is asking us to deregister the agent\n");
803
	fflush(traceFile);
804
	#ifdef MVS                    /* 198066 */
805
	#pragma convlit(resume)
806
	#endif
807
	#endif
808
809
	deregisterAgent(env, obj);
810
}
811
812
813
/** LOGAGENT_LOG_MESSAGE  ******************************************************
814
  *
815
  */
816
/* Bug 74367 */
817
long logAgent_logMessage_return(logAgent_t *agent, char *messageBuffer, ra_uint_t length, ra_dataFormat_t format) {
818
	unsigned char *copy;
819
	long byteSent = 0;
820
821
	if(agent->monitored) {
822
		copy=ra_allocateMessageBlock(length);
823
		/* Copy the bytes */
824
		memcpy(copy, messageBuffer, length);
825
		byteSent = (long)ra_writeMessageBlock(&agent->targetHdl,
826
							 format,
827
							 copy,
828
							 length);
829
		ra_freeMessageBlock(copy);
830
	}
831
832
#if _DEBUG
833
	printf("logAgent_logMessage: %d byte sent\n", byteSent);
834
#endif
835
836
	return byteSent;
837
}
838
839
/* Bug 74367 */
840
void logAgent_logMessage(logAgent_t *agent, char *messageBuffer, ra_uint_t length, ra_dataFormat_t format) {
841
	logAgent_logMessage_return(agent, messageBuffer, length, format);
842
}
843
844
845
/*
846
 * Class:		Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
847
 * Method:		logErrorMessage
848
 * Signature:	(Ljava/lang/String;Ljava/lang/String;I)V
849
 *
850
 * Description:	The following JNI function is used to only log error messages to an active
851
 *				logging agent.
852
 *
853
 * @param message	-	The message to be logged
854
 *		  messageId -	The message ID corresponding to the error message
855
 *		  severity	-	The level of severity of the message (e.g. default = DEBUG, 1 = INFORMATION, 2 = WARNING, 3 = SEVERE, 4 = MAX ERROR LEVEL)
856
 */
857
JNIEXPORT jlong JNICALL
858
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_logErrorMessage(
859
															JNIEnv *env,
860
                                                            jobject obj,
861
															jstring message,
862
															jstring messageId,
863
															jint severity) {	
864
	
865
	/* The 'mechanism' field of 'obj' will indicate the agent that was used to invoke this
866
	 * method */
867
	jlong mech;
868
	jfieldID mechDecl;
869
	jclass clazz;
870
	jlong byteSent;
871
872
	/* The error message and its corresponding ID */
873
	char *errMsg, *msgId;
874
875
	/* The severity of the message, which is DEBUG by default */
876
	RA_ERROR_LEVEL msgSeverity = RA_DEBUG;
877
878
879
	#ifdef _DEBUG
880
		printf ("Log Agent: Inside of the logErrorMessage function\n");
881
	#endif
882
	
883
	/* Resolve the 'jclass' of 'obj' */
884
	clazz=ENV(env)->GetObjectClass(ENVPARM(env) obj);
885
886
887
	/* Making JNI calls requires that the mode to be changed */
888
	#ifdef __OS400__
889
		#pragma convert(819)
890
	#endif
891
		mechDecl=ENV(env)->GetFieldID(ENVPARM(env) clazz, "mechanism", "J");
892
	#ifdef __OS400__
893
		#pragma convert(0)
894
	#endif
895
	mech=ENV(env)->GetLongField(ENVPARM(env) obj, mechDecl);
896
897
898
    /* Get the appropriate agent and send the message */
899
	if(JLONG(mech) > -1 && JLONG(mech) < _agent_list.size) {
900
		agent_list_entry_t *agent;
901
902
        agent=_agent_list.entries[JLONG(mech)];
903
		
904
		/* Resolve the parameters passed in */
905
		errMsg = copyJavaStringToNative(env, message);
906
		msgId = copyJavaStringToNative(env, messageId);
907
		
908
		if ((int)severity == 1)
909
			{msgSeverity = RA_INFORMATION;}
910
		else if ((int)severity == 2)
911
			{msgSeverity = RA_WARNING;}
912
		else if ((int)severity == 3)
913
			{msgSeverity = RA_SEVERE;}
914
		else if ((int)severity == 4)
915
			{msgSeverity = RA_MAX_ERROR_LEVEL;}
916
917
		/* Set it to zero first */
918
		JLONG(byteSent) = 0;
919
		JLONG(byteSent) = ra_logErrorMessage_return(agent->bindingStorage, msgSeverity, msgId, errMsg);
920
921
	}	
922
923
#if _DEBUG
924
	printf("JNI_logErrorMessage: %d byte sent\n", byteSent);
925
#endif
926
927
	return byteSent;
928
}
929
930
931
/*
932
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
933
 * Method:    logMessage0
934
 * Signature: (Ljava/lang/String;[BII)V
935
 */
936
JNIEXPORT jlong JNICALL
937
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_logMessage0__Ljava_lang_String_2_3BII(JNIEnv *env,
938
                                                                                      jobject obj,
939
                                                                                      jstring name,
940
                                                                                      jbyteArray msg,
941
                                                                                      jint offset,
942
                                                                                      jint length) {
943
	jlong mech;
944
	jfieldID mechDecl;
945
	jclass clazz;
946
	jlong byteSent;
947
948
	/* No need to search, we can just use the _mechanism field in the agent.
949
	 */
950
951
	clazz=ENV(env)->GetObjectClass(ENVPARM(env) obj);
952
#ifdef __OS400__
953
#pragma convert(819) /* 235033 */
954
#endif
955
	mechDecl=ENV(env)->GetFieldID(ENVPARM(env) clazz, "mechanism", "J");
956
#ifdef __OS400__
957
#pragma convert(0) /* 235033 */
958
#endif
959
	mech=ENV(env)->GetLongField(ENVPARM(env) obj, mechDecl);
960
961
962
	#ifdef _DEBUG
963
	#ifdef MVS                    /* 198066 */
964
	#pragma convlit(suspend)
965
	#endif
966
	printf("Logging Binary message\n");
967
	#ifdef MVS                    /* 198066 */
968
	#pragma convlit(resume)
969
	#endif
970
	#endif
971
972
    if(JLONG(mech) >-1 && JLONG(mech)<_agent_list.size) {
973
		agent_list_entry_t *agent;
974
        jbyte* bytes;
975
        agent=_agent_list.entries[JLONG(mech)];
976
		bytes=ENV(env)->GetByteArrayElements(ENVPARM(env) msg, NULL);
977
978
		/* Set it to zero first */
979
		JLONG(byteSent) = 0;
980
		JLONG(byteSent) = logAgent_logMessage_return(agent, (char*)bytes, length, RA_BINARY_DATA);
981
		ENV(env)->ReleaseByteArrayElements(ENVPARM(env) msg, bytes, JNI_ABORT);
982
	}
983
984
#if _DEBUG
985
	printf("JNI_logMessage0: %d byte sent\n", byteSent);
986
#endif
987
	return byteSent;
988
}
989
990
/*
991
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
992
 * Method:    logMessage0
993
 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
994
 */
995
JNIEXPORT jlong JNICALL
996
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_logMessage0__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env,
997
                                                                                                    jobject obj,
998
                                                                                                    jstring name,
999
                                                                                                    jstring msg) {
1000
	jlong mech;
1001
	jfieldID mechDecl;
1002
	jclass clazz;
1003
	jlong byteSent;
1004
1005
	#ifdef _DEBUG
1006
	#ifdef MVS                    
1007
	#pragma convlit(suspend)
1008
	#endif
1009
		printf ("Log Agent: Inside of the logMessage0 function\n");
1010
	#ifdef MVS                    
1011
	#pragma convlit(resume)
1012
	#endif
1013
	#endif
1014
	/* No need to search, we can just use the _mechanism field in the agent.
1015
	 */
1016
	clazz=ENV(env)->GetObjectClass(ENVPARM(env) obj);
1017
#ifdef __OS400__
1018
#pragma convert(819) /* 235033 */
1019
#endif
1020
	mechDecl=ENV(env)->GetFieldID(ENVPARM(env) clazz, "mechanism", "J");
1021
#ifdef __OS400__
1022
#pragma convert(0) /* 235033 */
1023
#endif
1024
	mech=ENV(env)->GetLongField(ENVPARM(env) obj, mechDecl);
1025
1026
1027
    if(JLONG(mech) >-1 && JLONG(mech)<_agent_list.size) {
1028
		agent_list_entry_t *agent;
1029
        ra_uint_t length;
1030
		const jchar *bytes;
1031
1032
        agent=_agent_list.entries[JLONG(mech)];
1033
1034
		length=(ENV(env)->GetStringLength(ENVPARM(env) msg));
1035
1036
	#ifdef _DEBUG
1037
	#ifdef MVS                    
1038
	#pragma convlit(suspend)
1039
	#endif
1040
	printf("Logging String message of length %d\n", length);
1041
	#ifdef MVS                    
1042
	#pragma convlit(resume)
1043
	#endif
1044
	#endif
1045
		bytes=ENV(env)->GetStringChars(ENVPARM(env) msg, NULL);
1046
		/* Set it to zero first */
1047
		JLONG(byteSent) = 0;
1048
		JLONG(byteSent) = logAgent_logMessage_return(agent, (char*)bytes, length*2, RA_UNICODE_STRING_DATA);
1049
		ENV(env)->ReleaseStringChars(ENVPARM(env) msg, bytes);
1050
1051
	}
1052
1053
#if _DEBUG
1054
	printf("JNI_logMessage0: %d byte sent\n", byteSent);
1055
#endif
1056
	return byteSent;
1057
}
1058
1059
/*
1060
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
1061
 * Method:    logMessageUTF80
1062
 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
1063
 */
1064
JNIEXPORT jlong JNICALL
1065
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_logMessageUTF80(JNIEnv *env,
1066
                                                                                       jobject obj,
1067
                                                                                       jstring name,
1068
                                                                                       jstring msg) {
1069
	jlong mech;
1070
	jfieldID mechDecl;
1071
	jclass clazz;
1072
	jlong byteSent;
1073
1074
	/* No need to search, we can just use the _mechanism field in the agent.
1075
	 */
1076
1077
	#ifdef _DEBUG
1078
	#ifdef MVS                    
1079
	#pragma convlit(suspend)
1080
	#endif
1081
		printf ("Log Agent: Inside of the logMessageUTF80 function\n");
1082
	#ifdef MVS                    
1083
	#pragma convlit(resume)
1084
	#endif
1085
	#endif
1086
	clazz=ENV(env)->GetObjectClass(ENVPARM(env) obj);
1087
#ifdef __OS400__
1088
#pragma convert(819) /* 235033 */
1089
#endif
1090
	mechDecl=ENV(env)->GetFieldID(ENVPARM(env) clazz, "mechanism", "J");
1091
#ifdef __OS400__
1092
#pragma convert(0) /* 235033 */
1093
#endif
1094
	mech=ENV(env)->GetLongField(ENVPARM(env) obj, mechDecl);
1095
1096
    if(JLONG(mech) >-1 && JLONG(mech)<_agent_list.size) {
1097
		agent_list_entry_t *agent;
1098
        ra_uint_t length;
1099
		const jchar *bytes;
1100
        unsigned char *copy;
1101
		ra_uint_t i;
1102
1103
        agent=_agent_list.entries[JLONG(mech)];
1104
1105
		length=ENV(env)->GetStringLength(ENVPARM(env) msg);
1106
1107
	#ifdef _DEBUG
1108
	#ifdef MVS                    
1109
	#pragma convlit(suspend)
1110
	#endif
1111
	printf("Logging UTF8 String message of length %d\n", length);
1112
	#ifdef MVS                    
1113
	#pragma convlit(resume)
1114
	#endif
1115
	#endif
1116
		bytes=ENV(env)->GetStringChars(ENVPARM(env) msg, NULL);
1117
1118
		/* Make a copy buffer for compression */
1119
		copy=ra_allocateMessageBlock(length);
1120
1121
		for(i=0; i<length; i++) {
1122
			copy[i]=(unsigned char)bytes[i];
1123
		}
1124
		/* Set it to zero first */
1125
		JLONG(byteSent) = 0;
1126
		JLONG(byteSent) = ra_writeMessageBlock(&agent->targetHdl, RA_BINARY_DATA, copy, length);
1127
1128
		ENV(env)->ReleaseStringChars(ENVPARM(env) msg, bytes);
1129
		ra_freeMessageBlock(copy);
1130
	}
1131
1132
#if _DEBUG
1133
	printf("JNI_logMessageUTF80: %d byte sent\n", byteSent);
1134
#endif
1135
	return byteSent;
1136
}
1137
1138
/*
1139
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
1140
 * Method:    logMessageUTF80
1141
 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
1142
 */
1143
JNIEXPORT jlong JNICALL
1144
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_logMessageUTF81(JNIEnv *env,
1145
                                                                                       jobject obj,
1146
                                                                                       jstring name,
1147
                                                                                       jbyteArray msg) {
1148
	jlong mech;
1149
	jfieldID mechDecl;
1150
	jclass clazz;
1151
	jlong byteSent;
1152
1153
	/* No need to search, we can just use the _mechanism field in the agent.
1154
	 */
1155
1156
	#ifdef _DEBUG
1157
	#ifdef MVS                 
1158
	#pragma convlit(suspend)
1159
	#endif
1160
		printf ("Log Agent: Inside of the logMessageUTF81 function\n");
1161
	#ifdef MVS                    
1162
	#pragma convlit(resume)
1163
	#endif
1164
	#endif
1165
	clazz=ENV(env)->GetObjectClass(ENVPARM(env) obj);
1166
#ifdef __OS400__
1167
#pragma convert(819) /* 235033 */
1168
#endif
1169
	mechDecl=ENV(env)->GetFieldID(ENVPARM(env) clazz, "mechanism", "J");
1170
#ifdef __OS400__
1171
#pragma convert(0) /* 235033 */
1172
#endif
1173
	mech=ENV(env)->GetLongField(ENVPARM(env) obj, mechDecl);
1174
1175
    if(JLONG(mech) >-1 && JLONG(mech)<_agent_list.size) {
1176
		agent_list_entry_t *agent;
1177
        jsize length;
1178
		jbyte *bytes;
1179
1180
        agent=_agent_list.entries[JLONG(mech)];
1181
1182
		length=ENV(env)->GetArrayLength(ENVPARM(env) msg);
1183
1184
	#ifdef _DEBUG
1185
	#ifdef MVS                    /* 198066 */
1186
	#pragma convlit(suspend)
1187
	#endif
1188
	printf("Logging UTF-81 message of length %d\n", length);
1189
	#ifdef MVS                    /* 198066 */
1190
	#pragma convlit(resume)
1191
	#endif
1192
	#endif
1193
		bytes=ENV(env)->GetByteArrayElements(ENVPARM(env) msg, NULL);
1194
/* Reversed in 9434 logAgent_logMessage(agent, as400_atou((char*)bytes), length, RA_UTF8_STRING_DATA);  240091 */
1195
		/* Set it to zero first */
1196
		JLONG(byteSent) = 0;
1197
#ifdef _LP64
1198
        assert(length<=UINT_MAX); /*partial fix 89008: flag any value too large for the uint target*/
1199
#endif        
1200
		JLONG(byteSent) = logAgent_logMessage_return(agent, (char*)bytes, length, RA_UTF8_STRING_DATA);
1201
		ENV(env)->ReleaseByteArrayElements(ENVPARM(env) msg, bytes, JNI_ABORT);
1202
	}
1203
1204
#if _DEBUG
1205
	printf("JNI_logMessageUTF81: %d byte sent\n", byteSent);
1206
#endif
1207
	return byteSent;
1208
}
1209
1210
/*
1211
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
1212
 * Method:    sendMessage0
1213
 * Signature: (Ljava/lang/String;J)V
1214
 */
1215
JNIEXPORT jlong JNICALL
1216
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_sendMessage0__Ljava_lang_String_2J(JNIEnv *env,
1217
                                                                                    jobject obj,
1218
                                                                                    jstring msg,
1219
                                                                                    jlong contextId) {
1220
	jlong mech;
1221
	jfieldID mechDecl;
1222
	jclass clazz;
1223
	jlong byteSent;
1224
1225
	/* No need to search, we can just use the _mechanism field in the agent.
1226
	 */
1227
	clazz=ENV(env)->GetObjectClass(ENVPARM(env) obj);
1228
#ifdef __OS400__
1229
#pragma convert(819) /* 235033 */
1230
#endif
1231
	mechDecl=ENV(env)->GetFieldID(ENVPARM(env) clazz, "mechanism", "J");
1232
#ifdef __OS400__
1233
#pragma convert(0) /* 235033 */
1234
#endif
1235
	mech=ENV(env)->GetLongField(ENVPARM(env) obj, mechDecl);
1236
1237
	#ifdef _DEBUG2
1238
	#ifdef MVS                    /* 198066 */
1239
	#pragma convlit(suspend)
1240
	#endif
1241
	fprintf(traceFile, "LogAgent: sendMessage0String - agent list size = %d\n", mech);
1242
	fflush(traceFile);
1243
	#ifdef MVS                    /* 198066 */
1244
	#pragma convlit(resume)
1245
	#endif
1246
	#endif
1247
1248
    if(JLONG(mech) >-1 && JLONG(mech)<_agent_list.size) {
1249
		agent_list_entry_t *agent;
1250
        ra_uint_t length;
1251
		char *bytes;
1252
        char *agentName_data;
1253
        int agentName_len;
1254
		ra_message_t *message;
1255
        ra_command_t *command;
1256
		ra_uint_t i;
1257
        agent = _agent_list.entries[JLONG(mech)];
1258
1259
		length = ENV(env)->GetStringLength(ENVPARM(env) msg);
1260
		bytes = (char*)ENV(env)->GetStringUTFChars(ENVPARM(env) msg, NULL);
1261
1262
		agentName_len = unicode2native(&agentName_data, bytes, length);
1263
1264
		/* Create the message to send to the client side */
1265
		message = ra_createMessage(RA_CONTROL_MESSAGE, 0);
1266
		command = ra_addCommandToMessage(message, NULL);
1267
1268
		/* Load the data in the message */
1269
		command->tag = RA_CUSTOM_COMMAND;
1270
		command->info.custom_command.processId = ra_getProcessId();
1271
1272
		command->info.custom_command.context=(unsigned long)JLONG(contextId);
1273
1274
		ra_createRASTRING(&command->info.custom_command.agent, agent->agent_name);
1275
		ra_createRASTRING(&command->info.custom_command.message, (const char *)agentName_data);
1276
1277
		/* RKD:  Why is the context reset to zero here? */
1278
		command->info.custom_command.context=0;
1279
1280
		/* Set it to zero first */
1281
		JLONG(byteSent) = 0;
1282
		JLONG(byteSent) = ra_sendMessage(agent->bindingStorage, message);
1283
1284
		#ifdef _DEBUG2
1285
		#ifdef MVS                    /* 198066 */
1286
		#pragma convlit(suspend)
1287
		#endif
1288
		fprintf(traceFile, "LogAgent: sendMessage0String - sent Custom Command\n");
1289
		fflush(traceFile);
1290
		#ifdef MVS                    /* 198066 */
1291
		#pragma convlit(resume)
1292
		#endif
1293
		#endif
1294
1295
		ra_destroyMessage(message, TRUE);
1296
		ENV(env)->ReleaseStringUTFChars(ENVPARM(env) msg, bytes);
1297
		free(agentName_data);
1298
	}
1299
1300
#if _DEBUG
1301
	printf("JNI_sendMessage0: %d byte sent\n", byteSent);
1302
#endif
1303
	return byteSent;
1304
}
1305
1306
/*
1307
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
1308
 * Method:    sendMessage0
1309
 * Signature: ([BIIJ)V
1310
 */
1311
JNIEXPORT jlong JNICALL
1312
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_sendMessage0___3BIIJ(JNIEnv *env,
1313
                                                                                            jobject obj,
1314
                                                                                            jbyteArray msg,
1315
                                                                                            jint offset,
1316
                                                                                            jint length,
1317
                                                                                            jlong contextId) {
1318
	jlong mech;
1319
	jfieldID mechDecl;
1320
	jclass clazz;
1321
	jlong byteSent;
1322
1323
	/* No need to search, we can just use the _mechanism field in the agent.  This
1324
	   Could be a problem on some platforms where the address size is not 4 bytes.
1325
	 */
1326
	clazz=ENV(env)->GetObjectClass(ENVPARM(env) obj);
1327
#ifdef __OS400__
1328
#pragma convert(819) /* 235033 */
1329
#endif
1330
	mechDecl=ENV(env)->GetFieldID(ENVPARM(env) clazz, "mechanism", "J");
1331
#ifdef __OS400__
1332
#pragma convert(0) /* 235033 */
1333
#endif
1334
	mech=ENV(env)->GetLongField(ENVPARM(env) obj, mechDecl);
1335
1336
	#ifdef _DEBUG2
1337
	#ifdef MVS                    /* 198066 */
1338
	#pragma convlit(suspend)
1339
	#endif
1340
	fprintf(traceFile, "LogAgent: sendMessage0ByteArray - agent list size = %d\n", mech);
1341
	fflush(traceFile);
1342
	#ifdef MVS                    /* 198066 */
1343
	#pragma convlit(resume)
1344
	#endif
1345
	#endif
1346
1347
    if(JLONG(mech) >-1 && JLONG(mech)<_agent_list.size) {
1348
		agent_list_entry_t *agent;
1349
        jbyte *copy;
1350
		ra_message_t *message;
1351
        ra_command_t *command;
1352
        agent=_agent_list.entries[JLONG(mech)];
1353
1354
		copy=(jbyte*)malloc((length)*sizeof(jbyte));
1355
		ENV(env)->GetByteArrayRegion(ENVPARM(env) msg, offset, length, copy);
1356
1357
1358
		/* Create the message to send to the client side */
1359
		message=ra_createMessage(RA_CONTROL_MESSAGE, 0);
1360
		command=ra_addCommandToMessage(message, NULL);
1361
1362
		/* Load the data in the message */
1363
		command->tag = RA_CUSTOM_COMMAND;
1364
		command->info.custom_command.processId=ra_getProcessId();
1365
1366
		command->info.custom_command.context=(unsigned long)JLONG(contextId);
1367
1368
		ra_createRASTRING(&command->info.custom_command.agent, agent->agent_name);
1369
		ra_createRASTRING3(&command->info.custom_command.message, (const char*)copy, length);
1370
1371
		/* RKD:  Why is the context reset to zero here? */
1372
		command->info.custom_command.context=0;
1373
1374
		/* Set it to zero first */
1375
		JLONG(byteSent) = 0;
1376
		JLONG(byteSent) = ra_sendMessage(agent->bindingStorage, message);
1377
1378
		#ifdef _DEBUG2
1379
		#ifdef MVS                    /* 198066 */
1380
		#pragma convlit(suspend)
1381
		#endif
1382
		fprintf(traceFile, "LogAgent: sendMessage0ByteArray - sent Custom Command\n");
1383
		fflush(traceFile);
1384
		#ifdef MVS                    /* 198066 */
1385
		#pragma convlit(resume)
1386
		#endif
1387
		#endif
1388
1389
		ra_destroyMessage(message, TRUE);
1390
	}
1391
1392
#if _DEBUG
1393
	printf("JNI_sendMessage0: %d byte sent\n", byteSent);
1394
#endif
1395
	return byteSent;
1396
}
1397
1398
1399
/*
1400
 * Class:     org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
1401
 * Method:    sendMessageBinary0
1402
 * Signature: ([BIIJ)V
1403
 */
1404
JNIEXPORT jlong JNICALL
1405
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_sendMessageBinary0(JNIEnv *env,
1406
																							 jobject obj,
1407
																							 jbyteArray msg,
1408
																							 jint offset,
1409
																							 jint length,
1410
																							 jlong contextId) {
1411
	jlong mech;
1412
	jfieldID mechDecl;
1413
	jclass clazz;
1414
	jlong byteSent;
1415
1416
	/* No need to search, we can just use the _mechanism field in the agent.  This
1417
	   Could be a problem on some platforms where the address size is not 4 bytes.
1418
	 */
1419
	clazz=ENV(env)->GetObjectClass(ENVPARM(env) obj);
1420
#ifdef __OS400__
1421
#pragma convert(819) /* 235033 */
1422
#endif
1423
	mechDecl=ENV(env)->GetFieldID(ENVPARM(env) clazz, "mechanism", "J");
1424
#ifdef __OS400__
1425
#pragma convert(0) /* 235033 */
1426
#endif
1427
	mech=ENV(env)->GetLongField(ENVPARM(env) obj, mechDecl);
1428
1429
	#ifdef _DEBUG2
1430
	#ifdef MVS                    /* 198066 */
1431
	#pragma convlit(suspend)
1432
	#endif
1433
	fprintf(traceFile, "LogAgent: sendMessageBinary0 - agent list size = %d\n", mech);
1434
	fflush(traceFile);
1435
	#ifdef MVS                    /* 198066 */
1436
	#pragma convlit(resume)
1437
	#endif
1438
	#endif
1439
1440
    if(JLONG(mech) >-1 && JLONG(mech)<_agent_list.size) {
1441
		agent_list_entry_t *agent;
1442
        jbyte *copy;
1443
		ra_message_t *message;
1444
        ra_command_t *command;
1445
        agent=_agent_list.entries[JLONG(mech)];
1446
1447
		copy=(jbyte*)malloc((length)*sizeof(jbyte));
1448
		ENV(env)->GetByteArrayRegion(ENVPARM(env) msg, offset, length, copy);
1449
1450
1451
		/* Create the message to send to the client side */
1452
		message=ra_createMessage(RA_CONTROL_MESSAGE, 0);
1453
		command=ra_addCommandToMessage(message, NULL);
1454
1455
		/* Load the data in the message */
1456
		command->tag = RA_BINARY_CUSTOM_COMMAND;
1457
		command->info.custom_command.processId=ra_getProcessId();
1458
1459
		command->info.custom_command.context=(unsigned long)JLONG(contextId);
1460
1461
		ra_createRASTRING(&command->info.custom_command.agent, agent->agent_name);
1462
		ra_createRASTRING3(&command->info.custom_command.message, (const char*)copy, length);
1463
1464
		/* RKD:  Why is the context reset to zero here? */
1465
		command->info.custom_command.context=0;
1466
1467
		/* Set it to zero first */
1468
		JLONG(byteSent) = 0;
1469
		JLONG(byteSent) = ra_sendMessage(agent->bindingStorage, message);
1470
1471
		#ifdef _DEBUG2
1472
		#ifdef MVS                    /* 198066 */
1473
		#pragma convlit(suspend)
1474
		#endif
1475
		fprintf(traceFile, "LogAgent: sendMessageBinary0 - sent Binary Custom Command\n");
1476
		fflush(traceFile);
1477
		#ifdef MVS                    /* 198066 */
1478
		#pragma convlit(resume)
1479
		#endif
1480
		#endif
1481
1482
		ra_destroyMessage(message, TRUE);
1483
	}
1484
1485
#if _DEBUG
1486
	printf("JNI_sendMessageBinary0: %d byte sent\n", byteSent);
1487
#endif
1488
	return byteSent;
1489
}
1490
1491
/*
1492
 * Bug 77768
1493
 */
1494
JNIEXPORT void JNICALL
1495
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0___3BJLjava_lang_String_2(JNIEnv *env, jobject obj, jbyteArray ipaddr, jlong pid, jstring agentName) {
1496
#ifdef __OS400__
1497
	jlong port;
1498
	port.ll = 10002;
1499
#else
1500
	jlong port = 10002;
1501
#endif
1502
	Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0p___3BJJLjava_lang_String_2(env, obj, ipaddr, port, pid, agentName);
1503
}
1504
1505
/*
1506
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
1507
 * Method:    requestMonitorThroughPeer0
1508
 * Signature: ([BJLjava/lang/String;)V
1509
 */
1510
JNIEXPORT void JNICALL
1511
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0p___3BJJLjava_lang_String_2(JNIEnv *env, jobject obj, jbyteArray ipaddr, jlong port, jlong pid, jstring agentName) {
1512
	jlong mech;
1513
	jfieldID mechDecl;
1514
	jclass clazz;
1515
1516
	/* No need to search, we can just use the _mechanism field in the agent.  This
1517
	   Could be a problem on some platforms where the address size is not 4 bytes.
1518
	 */
1519
	clazz=ENV(env)->GetObjectClass(ENVPARM(env) obj);
1520
#ifdef __OS400__
1521
#pragma convert(819) /* 235033 */
1522
#endif
1523
	mechDecl=ENV(env)->GetFieldID(ENVPARM(env) clazz, "mechanism", "J");
1524
#ifdef __OS400__
1525
#pragma convert(0) /* 235033 */
1526
#endif
1527
	mech=ENV(env)->GetLongField(ENVPARM(env) obj, mechDecl);
1528
1529
    if(JLONG(mech) >-1 && JLONG(mech)<_agent_list.size) {
1530
		agent_list_entry_t *agent;
1531
        ra_ipaddr_t addr;
1532
		char *agentName_native;
1533
        agent = _agent_list.entries[JLONG(mech)];
1534
1535
		/* Extract our JNI information */
1536
		addr.addrLength = (unsigned char)ENV(env)->GetArrayLength(ENVPARM(env) ipaddr);
1537
		addr.addr = (unsigned char *)malloc(addr.addrLength * sizeof(unsigned char));
1538
		ENV(env)->GetByteArrayRegion(ENVPARM(env) ipaddr, 0, addr.addrLength, (signed char *)addr.addr);
1539
1540
		/* Convert the Unicode string */
1541
		agentName_native = copyJavaStringToNative(env, agentName);
1542
1543
		ra_requestPeerMonitor_p(agent->bindingStorage, &addr, (unsigned long)JLONG(port), (unsigned long)JLONG(pid), ra_createRASTRING2(agentName_native), 0); /* Bug 77768 */
1544
1545
		/* Cleanup our mess */
1546
		free(addr.addr);
1547
		free(agentName_native);
1548
	}
1549
}
1550
1551
/*
1552
 * Bug 77768
1553
 */
1554
JNIEXPORT void JNICALL
1555
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0___3BLjava_lang_String_2(JNIEnv *env, jobject obj, jbyteArray ipaddr, jstring agentUUID) {
1556
#ifdef __OS400__
1557
	jlong port;
1558
	port.ll = 10002;
1559
#else
1560
	jlong port = 10002;
1561
#endif
1562
	Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0p___3BJLjava_lang_String_2(env, obj, ipaddr, port, agentUUID);
1563
}
1564
1565
/*
1566
 * Class:     Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton
1567
 * Method:    requestMonitorThroughPeer0
1568
 * Signature: ([BLjava/lang/String;)V
1569
 */
1570
JNIEXPORT void JNICALL
1571
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0p___3BJLjava_lang_String_2(JNIEnv *env, jobject obj, jbyteArray ipaddr, jlong port, jstring agentUUID) {
1572
	jlong mech;
1573
	jfieldID mechDecl;
1574
	jclass clazz;
1575
1576
	/* No need to search, we can just use the _mechanism field in the agent.  This
1577
	   Could be a problem on some platforms where the address size is not 4 bytes.
1578
	 */
1579
	clazz=ENV(env)->GetObjectClass(ENVPARM(env) obj);
1580
#ifdef __OS400__
1581
#pragma convert(819) /* 235033 */
1582
#endif
1583
	mechDecl=ENV(env)->GetFieldID(ENVPARM(env) clazz, "mechanism", "J");
1584
#ifdef __OS400__
1585
#pragma convert(0) /* 235033 */
1586
#endif
1587
	mech=ENV(env)->GetLongField(ENVPARM(env) obj, mechDecl);
1588
1589
    if(JLONG(mech) >-1 && JLONG(mech)<_agent_list.size) {
1590
		agent_list_entry_t *agent;
1591
        ra_ipaddr_t addr;
1592
		char *agentUUID_native;
1593
        agent = _agent_list.entries[JLONG(mech)];
1594
1595
		/* Extract our JNI information */
1596
		addr.addrLength=(unsigned char)ENV(env)->GetArrayLength(ENVPARM(env) ipaddr);
1597
		addr.addr=(unsigned char *)malloc(addr.addrLength*sizeof(unsigned char));
1598
		ENV(env)->GetByteArrayRegion(ENVPARM(env) ipaddr, 0, addr.addrLength, (signed char *)addr.addr);
1599
1600
		/* Convert the Unicode string */
1601
		agentUUID_native = copyJavaStringToNative(env, agentUUID);
1602
1603
		ra_requestPeerMonitor2_p(agent->bindingStorage, &addr, (unsigned long)JLONG(port), ra_createRASTRING2(agentUUID_native), 0); /* Bug 77768 */
1604
1605
		/* Cleanup our mess */
1606
		free(addr.addr);
1607
		free(agentUUID_native);
1608
	}
1609
1610
1611
1612
}
1613
1614
1615
/** JAVA_NOTIFY_MESSAGE  ************************************************************
1616
  * This function is called by the underlying controller mechanism to notify a particular
1617
  * logging agent to either start/stop monitoring or to forward configuration information
1618
  * via the RA_SET_NAME_VALUE_PAIR or RA_CUSTOM_COMMAND commands.
1619
  */
1620
static void _java_notifyMessage(ra_command_t *command) {
1621
	JNIEnv *env;
1622
	jint result;
1623
	agent_list_entry_t *agent;
1624
1625
1626
	#ifdef _DEBUG
1627
	#ifdef MVS                    /* 198066 */
1628
	#pragma convlit(suspend)
1629
	#endif
1630
	printf("Java Log Agent: notifyMessage: Recieving message %d\n", command->tag);
1631
	#ifdef MVS                    /* 198066 */
1632
	#pragma convlit(resume)
1633
	#endif
1634
	#endif
1635
	/* Attach the current thread to the JVM */
1636
#if defined __cplusplus && defined _HPUX
1637
	result=ENV(_agent_vm)->AttachCurrentThread((void**)&env, NULL);
1638
#else
1639
	result=(*_agent_vm)->AttachCurrentThread(_agent_vm,  (void**)&env, NULL);
1640
#endif
1641
	if(!result) {
1642
1643
		#ifdef _DEBUG2
1644
		#ifdef MVS                    /* 198066 */
1645
		#pragma convlit(suspend)
1646
		#endif
1647
		fprintf(traceFile, "Java Log Agent: notifyMessage: Receiving message %d\n", command->tag);
1648
		fflush(traceFile);
1649
		#ifdef MVS                    /* 198066 */
1650
		#pragma convlit(resume)
1651
		#endif
1652
		#endif
1653
1654
		switch(command->tag) {
1655
		case RA_AGENT_CONTROLER_AVAILABLE:
1656
			agent=findAgent(command->info.agentName.data);
1657
			if(agent) {
1658
				jclass cls;
1659
				jmethodID agentControllerActive, setNodeUUID, setProcessUUID;
1660
				jstring nodeUUID, processUUID;
1661
				ra_agentConfigList_t *configuration;
1662
1663
				configuration=ra_getDefaultConfiguration(agent->bindingStorage);
1664
1665
				/* Find the class object */
1666
				cls=ENV(env)->GetObjectClass(ENVPARM(env) agent->agent_logger);
1667
1668
				/* Set the node UUID in the agent
1669
				 * RKD: This is a V5 addition we better catch the exception if the method does not exist.
1670
				 */
1671
#ifdef __OS400__
1672
#pragma convert(819) /* 235033 */
1673
#endif
1674
				setNodeUUID=ENV(env)->GetMethodID(ENVPARM(env) cls, "setNodeUUID", "(Ljava/lang/String;)V");
1675
#ifdef __OS400__
1676
#pragma convert(0) /* 235033 */
1677
#endif
1678
				if(setNodeUUID) {
1679
					nodeUUID = getnewstrutf(env, agent -> bindingStorage -> agentUUID.data);
1680
					ENV(env)->CallVoidMethod(ENVPARM(env) agent->agent_logger, setNodeUUID, nodeUUID);
1681
				}
1682
1683
				/* Set the process UUID in the agent
1684
				 * RKD: This is a V5 addition we better catch the exception if the method does not exist.
1685
				 */
1686
#ifdef __OS400__
1687
#pragma convert(819) /* 235033 */
1688
#endif
1689
				setProcessUUID=ENV(env)->GetMethodID(ENVPARM(env) cls, "setJVMUUID", "(Ljava/lang/String;)V");
1690
#ifdef __OS400__
1691
#pragma convert(0) /* 235033 */
1692
#endif
1693
				if(setProcessUUID) {
1694
					processUUID = getnewstrutf(env, agent -> bindingStorage -> processUUID.data);
1695
					ENV(env)->CallVoidMethod(ENVPARM(env) agent->agent_logger, setProcessUUID, processUUID);
1696
				}
1697
1698
				/* Iterate through the configuration and load the agent with the info. */
1699
				if(configuration) {
1700
					jclass agentClass=ENV(env)->GetObjectClass(ENVPARM(env) agent->agent_logger);
1701
1702
					#ifdef _DEBUG2
1703
					#ifdef MVS                    /* 198066 */
1704
					#pragma convlit(suspend)
1705
					#endif
1706
					fprintf(traceFile, "Java Log Agent: We have a configuration - try to find the agent\n");
1707
					fflush(traceFile);
1708
					#ifdef MVS                    /* 198066 */
1709
					#pragma convlit(resume)
1710
					#endif
1711
					#endif
1712
1713
					if(agentClass) {
1714
#ifdef __OS400__
1715
#pragma convert(819) /* 235033 */
1716
#endif
1717
						jmethodID factoryMethod=ENV(env)->GetMethodID(ENVPARM(env) agentClass, "createObjectInContextOfClassLoader", "(Ljava/lang/String;)Ljava/lang/Object;");
1718
#ifdef __OS400__
1719
#pragma convert(0) /* 235033 */
1720
#endif
1721
						if(factoryMethod) {
1722
#ifdef __OS400__
1723
#pragma convert(819) /* 235033 */
1724
#endif
1725
							jstring classname=ENV(env)->NewStringUTF(ENVPARM(env) "org.eclipse.hyades.internal.execution.remote.AgentConfigurationEntry"); /* Bug 78628 */
1726
#ifdef __OS400__
1727
#pragma convert(0) /* 235033 */
1728
#endif
1729
							jobject agentConfigurationEntryObject=ENV(env)->CallObjectMethod(ENVPARM(env) agent->agent_logger, factoryMethod, classname);
1730
							if(agentConfigurationEntryObject) {
1731
								jclass agentConfigurationEntryClass=ENV(env)->GetObjectClass(ENVPARM(env) agentConfigurationEntryObject);
1732
								jmethodID addEntryToDefaultConfiguration, setName, setType, setValue;
1733
								ra_agentConfigListEntry_t *configListEntry;
1734
1735
#ifdef __OS400__
1736
#pragma convert(819) /* 235033 */
1737
#endif
1738
								addEntryToDefaultConfiguration=ENV(env)->GetMethodID(ENVPARM(env) cls, "addEntryToDefaultConfiguration", "(Lorg/eclipse/hyades/internal/execution/remote/AgentConfigurationEntry;)V");
1739
								setType=ENV(env)->GetMethodID(ENVPARM(env) agentConfigurationEntryClass, "setType", "(Ljava/lang/String;)V");
1740
								setName=ENV(env)->GetMethodID(ENVPARM(env) agentConfigurationEntryClass, "setName", "(Ljava/lang/String;)V");
1741
								setValue=ENV(env)->GetMethodID(ENVPARM(env) agentConfigurationEntryClass, "setValue", "(Ljava/lang/String;)V");
1742
#ifdef __OS400__
1743
#pragma convert(0) /* 235033 */
1744
#endif
1745
								configListEntry=configuration->head;
1746
								while(configListEntry) {
1747
									agentConfigurationEntryObject=ENV(env)->CallObjectMethod(ENVPARM(env) agent->agent_logger, factoryMethod, classname);
1748
1749
									if(agentConfigurationEntryObject) {
1750
										jstring javaName;
1751
										jstring javaType;
1752
										jstring javaValue;
1753
										char *ubName; /* UTF-8 bytes */
1754
										char *ubType; /* UTF-8 bytes */
1755
										char *ubValue; /* UTF-8 bytes */
1756
1757
										native2unicode(&ubName, configListEntry->entry.name.data, configListEntry->entry.name.length);
1758
										native2unicode(&ubType, configListEntry->entry.type.data, configListEntry->entry.type.length);
1759
										native2unicode(&ubValue, configListEntry->entry.value.data, configListEntry->entry.value.length);
1760
1761
										javaName = ENV(env)->NewStringUTF(ENVPARM(env) ubName);
1762
										javaType = ENV(env)->NewStringUTF(ENVPARM(env) ubType);
1763
										javaValue = ENV(env)->NewStringUTF(ENVPARM(env) ubValue);
1764
1765
										ENV(env)->CallVoidMethod(ENVPARM(env) agentConfigurationEntryObject, setName, javaName);
1766
										ENV(env)->CallVoidMethod(ENVPARM(env) agentConfigurationEntryObject, setType, javaType);
1767
										ENV(env)->CallVoidMethod(ENVPARM(env) agentConfigurationEntryObject, setValue, javaValue);
1768
1769
										ENV(env)->CallVoidMethod(ENVPARM(env) agent->agent_logger, addEntryToDefaultConfiguration, agentConfigurationEntryObject);
1770
									}
1771
									configListEntry=configListEntry->next;
1772
								}
1773
							}
1774
						}
1775
					}
1776
				}
1777
1778
				/* If there are any pending exceptions clear them */
1779
#if defined __cplusplus && defined _HPUX
1780
				ENV(env)->ExceptionClear();
1781
#else
1782
				ENV(env)->ExceptionClear(env);
1783
#endif
1784
1785
1786
			    /* Inform that the server is available */
1787
#ifdef __OS400__
1788
#pragma convert(819) /* 235033 */
1789
#endif
1790
			    agentControllerActive=ENV(env)->GetMethodID(ENVPARM(env) cls, "agentControllerActive", "()V");
1791
#ifdef __OS400__
1792
#pragma convert(0) /* 235033 */
1793
#endif
1794
			    ENV(env)->CallVoidMethod(ENVPARM(env) agent->agent_logger, agentControllerActive);
1795
1796
				#ifdef _DEBUG2
1797
				#ifdef MVS                    /* 198066 */
1798
				#pragma convlit(suspend)
1799
				#endif
1800
				fprintf(traceFile, "Java Log Agent: Agent Controller Available processing done and called agentControllerActive method.\n");
1801
				fflush(traceFile);
1802
				#ifdef MVS                    /* 198066 */
1803
				#pragma convlit(resume)
1804
				#endif
1805
				#endif
1806
			}
1807
			break;
1808
		case RA_AGENT_CONTROLER_UNAVAILABLE:
1809
			agent=findAgent(command->info.agentName.data);
1810
			if(agent) {
1811
				jclass cls;
1812
				jmethodID agentControllerInactive;
1813
				/* Find the class object */
1814
			    cls=ENV(env)->GetObjectClass(ENVPARM(env) agent->agent_logger);
1815
				if(cls) {
1816
					/* Inform that the server is available */
1817
#ifdef __OS400__
1818
#pragma convert(819) /* 235033 */
1819
#endif
1820
					agentControllerInactive=ENV(env)->GetMethodID(ENVPARM(env) cls, "agentControllerInactive", "()V");
1821
#ifdef __OS400__
1822
#pragma convert(0) /* 235033 */
1823
#endif
1824
					if(agentControllerInactive) {
1825
						ENV(env)->CallVoidMethod(ENVPARM(env) agent->agent_logger, agentControllerInactive);
1826
					}
1827
				}
1828
			}
1829
			break;
1830
		case RA_DETACH_FROM_AGENT:
1831
			agent=findAgent(command->info.detach.agent.data);
1832
			if(agent) {
1833
				jclass cls;
1834
				jmethodID remoteClientExited;
1835
				/* Find the class object */
1836
			    cls=ENV(env)->GetObjectClass(ENVPARM(env) agent->agent_logger);
1837
				if(cls) {
1838
					/* Inform that the client is no longer available */
1839
#ifdef __OS400__
1840
#pragma convert(819) /* 235033 */
1841
#endif
1842
					remoteClientExited=ENV(env)->GetMethodID(ENVPARM(env) cls, "remoteClientExited", "()V");
1843
#ifdef __OS400__
1844
#pragma convert(0) /* 235033 */
1845
#endif
1846
					if(remoteClientExited) {
1847
						ENV(env)->CallVoidMethod(ENVPARM(env) agent->agent_logger, remoteClientExited);
1848
					}
1849
				}
1850
				
1851
			    /* Close the appropriate data channel implementation if the agent is being monitored */
1852
				if(agent->monitored) {
1853
1854
					if(agent->targetHdl.dtarget == RA_SOCKET) {
1855
						ra_closeSocket(agent->targetHdl.dtargetHdl.socketFD);
1856
					}
1857
					else if(agent->targetHdl.dtarget == RA_SHAREDMEMORY) {
1858
						ra_stopFlushingShm(&agent->targetHdl.dtargetHdl.shmHdl);
1859
					}
1860
				}
1861
				
1862
				agent->monitored = FALSE;
1863
			}
1864
			break;
1865
			
1866
		/* NOTE:  This case is used on platforms that do not support shared memory data channel implementation. */
1867
		
1868
		case RA_START_MONITORING_AGENT_REMOTE: 
1869
		{
1870
			jclass cls;
1871
			jmethodID	agent_setLogging;
1872
1873
			agent=findAgent(command->info.start_monitor_remote.agent.data);
1874
			
1875
			if(agent) {
1876
			
1877
			   if (!agent->monitored) {
1878
1879
					#ifdef _DEBUG
1880
					#ifdef MVS                    /* 198066 */
1881
					#pragma convlit(suspend)
1882
					#endif
1883
					printf("Log Agent: %s connecting to remote server\n", agent->agent_name);
1884
					#ifdef MVS                    /* 198066 */
1885
					#pragma convlit(resume)
1886
					#endif
1887
					#endif
1888
1889
					agent->targetHdl.dtarget = RA_SOCKET;
1890
1891
					ra_connectToTCPServer(command->info.start_monitor_remote.ip,
1892
									  (unsigned short)command->info.start_monitor_remote.port,
1893
									  &agent->targetHdl.dtargetHdl.socketFD);
1894
				}
1895
1896
				cls=ENV(env)->GetObjectClass(ENVPARM(env) agent->agent_logger);
1897
1898
				if(!cls) {
1899
					#ifdef _DEBUG
1900
					#ifdef MVS                    /* 198066 */
1901
					#pragma convlit(suspend)
1902
					#endif
1903
					printf("LogAgent: _agent_notifyMessage - Find class failed\n");
1904
					#ifdef MVS                    /* 198066 */
1905
					#pragma convlit(resume)
1906
					#endif
1907
					#endif
1908
					break;
1909
				}
1910
#ifdef __OS400__
1911
#pragma convert(819) /* 235033 */
1912
#endif
1913
				agent_setLogging = ENV(env)->GetMethodID(ENVPARM(env)cls, "setLogging", "(Z)V");
1914
#ifdef __OS400__
1915
#pragma convert(0) /* 235033 */
1916
#endif
1917
1918
				if(!agent_setLogging) {
1919
					#ifdef _DEBUG
1920
					#ifdef MVS                    /* 198066 */
1921
					#pragma convlit(suspend)
1922
					#endif
1923
					printf("LogAgent: _agent_notifyMessage - GetMethodID failed\n");
1924
					#ifdef MVS                    /* 198066 */
1925
					#pragma convlit(resume)
1926
					#endif
1927
					#endif
1928
					break;
1929
				}
1930
				ENV(env)->CallVoidMethod(ENVPARM(env) agent->agent_logger, agent_setLogging, (jboolean)1 );
1931
1932
				agent->monitored=TRUE;
1933
			}
1934
			#ifdef _DEBUG
1935
			else {
1936
				#ifdef MVS                    /* 198066 */
1937
				#pragma convlit(suspend)
1938
				#endif
1939
				printf("Log Agent: Couldn't find agent %s", agent->agent_name);
1940
				#ifdef MVS                    /* 198066 */
1941
				#pragma convlit(resume)
1942
				#endif
1943
			}
1944
			#endif
1945
			break;
1946
		}
1947
		
1948
		/* NOTE:  This case is used on platforms that support shared memory data channel implementation. */
1949
		
1950
		case RA_START_MONITORING_AGENT_LOCAL:
1951
		{	
1952
			jmethodID	agent_setLogging;
1953
			jclass cls;
1954
1955
			agent=findAgent(command->info.start_monitor_remote.agent.data);
1956
			
1957
			if(agent){
1958
1959
				if(!agent->monitored){
1960
					
1961
					#ifdef _DEBUG
1962
					#ifdef MVS                    /* 198066 */
1963
					#pragma convlit(suspend)
1964
					#endif
1965
					printf("Log Agent: %s connecting to shared memory pipe\n", agent->agent_name);
1966
					#ifdef MVS                    /* 198066 */
1967
					#pragma convlit(resume)
1968
					#endif
1969
					#endif
1970
	
1971
					result = ra_attachToShm(command->info.start_monitor_local.file.data,
1972
									&agent->targetHdl.dtargetHdl.shmHdl);
1973
					if(result != 0) {
1974
						#ifdef MVS                    /* 198066 */
1975
						#pragma convlit(suspend)
1976
						#endif
1977
						printf("Error %d attaching to data channel.\n", result);
1978
						#ifdef MVS                    /* 198066 */
1979
						#pragma convlit(resume)
1980
						#endif
1981
						break;
1982
					}
1983
	
1984
					agent->targetHdl.dtarget = RA_SHAREDMEMORY;
1985
				}
1986
			
1987
				cls=ENV(env)->GetObjectClass(ENVPARM(env) agent->agent_logger);
1988
1989
				if(!cls) {
1990
					#ifdef _DEBUG
1991
					#ifdef MVS                    /* 198066 */
1992
					#pragma convlit(suspend)
1993
					#endif
1994
					printf("LogAgent: _agent_notifyMessage - Find class failed\n");
1995
					#ifdef MVS                    /* 198066 */
1996
					#pragma convlit(resume)
1997
					#endif
1998
					#endif
1999
					break;
2000
				}
2001
2002
#ifdef __OS400__
2003
#pragma convert(819) /* 235033 */
2004
#endif
2005
				agent_setLogging = ENV(env)->GetMethodID(ENVPARM(env) cls, "setLogging", "(Z)V");
2006
#ifdef __OS400__
2007
#pragma convert(0) /* 235033 */
2008
#endif
2009
2010
				if(!agent_setLogging) {
2011
					#ifdef _DEBUG
2012
					#ifdef MVS                    /* 198066 */
2013
					#pragma convlit(suspend)
2014
					#endif
2015
					printf("LogAgent: _agent_notifyMessage - GetMethodID failed\n");
2016
					#ifdef MVS                    /* 198066 */
2017
					#pragma convlit(resume)
2018
					#endif
2019
					#endif
2020
					break;
2021
				}
2022
2023
				agent->monitored=TRUE;
2024
2025
				ENV(env)->CallVoidMethod(ENVPARM(env) agent->agent_logger, agent_setLogging, (jboolean)1 );
2026
			}
2027
			#ifdef _DEBUG
2028
			else {
2029
				#ifdef MVS                    /* 198066 */
2030
				#pragma convlit(suspend)
2031
				#endif
2032
				printf("Log Agent: Couldn't find agent %s", agent->agent_name);
2033
				#ifdef MVS                    /* 198066 */
2034
				#pragma convlit(resume)
2035
				#endif
2036
			}
2037
			#endif
2038
			
2039
			break; 
2040
		}
2041
		
2042
	    /* NOTE:  This case does not set the agent->monitored flag to 'FALSE' or close the data channel. */
2043
	    /*        The agent->monitored flag is used to denote when the data channel is open.  */
2044
	    /*        The data channel is only closed when a client detaches from an agent. */
2045
	    
2046
		case RA_STOP_MONITORING_AGENT:
2047
			agent=findAgent(command->info.stop_monitor.agent.data);
2048
			if(agent && agent->monitored) {
2049
				jclass cls;
2050
				jmethodID	agent_setLogging;
2051
				cls=ENV(env)->GetObjectClass(ENVPARM(env) agent->agent_logger);
2052
2053
				if(!cls) {
2054
					#ifdef _DEBUG
2055
					#ifdef MVS                    /* 198066 */
2056
					#pragma convlit(suspend)
2057
					#endif
2058
					printf("LogAgent: _agent_notifyMessage - Find Class failed\n");
2059
					#ifdef MVS                    /* 198066 */
2060
					#pragma convlit(resume)
2061
					#endif
2062
					#endif
2063
				}
2064
				else {
2065
#ifdef __OS400__
2066
#pragma convert(819) /* 235033 */
2067
#endif
2068
					agent_setLogging = ENV(env)->GetMethodID(ENVPARM(env) cls, "setLogging", "(Z)V");
2069
#ifdef __OS400__
2070
#pragma convert(0) /* 235033 */
2071
#endif
2072
					if(!agent_setLogging) {
2073
						#ifdef _DEBUG
2074
						#ifdef MVS                    /* 198066 */
2075
						#pragma convlit(suspend)
2076
						#endif
2077
						printf("LogAgent: _agent_notifyMessage - GetMethodID failed\n");
2078
						#ifdef MVS                    /* 198066 */
2079
						#pragma convlit(resume)
2080
						#endif
2081
						#endif
2082
					}
2083
					else {
2084
						ENV(env)->CallVoidMethod(ENVPARM(env) agent->agent_logger, agent_setLogging, (jboolean)0 );
2085
					}
2086
				}
2087
			}
2088
			break;
2089
		case RA_CUSTOM_COMMAND:
2090
		case RA_BINARY_CUSTOM_COMMAND:
2091
		{
2092
			BOOL isBinary = FALSE;
2093
			/* Data */
2094
			char *data;
2095
			int length;
2096
2097
			/* String constants, need to perform conversion for EBCDIC systems */
2098
#ifdef __OS400__
2099
	#pragma convert(819)
2100
#endif
2101
			char *className_CustomCommand = "org.eclipse.hyades.internal.execution.local.common.CustomCommand";
2102
			char *className_BinaryCustomCommand = "org.eclipse.hyades.internal.execution.local.common.BinaryCustomCommand";
2103
			char *funcName_createObjectInContextOfClassLoader = "createObjectInContextOfClassLoader";
2104
			char *funcSig_createObjectInContextOfClassLoader = "(Ljava/lang/String;)Ljava/lang/Object;";
2105
			char *funcName_setData = "setData";
2106
			char *funcSig_setData = "([B)V";
2107
			char *funcName_incomingCommand = "incomingCommand";
2108
			char *funcSig_incomingCommand = "(Lorg/eclipse/hyades/internal/execution/local/common/CommandElement;)V";
2109
#ifdef __OS400__
2110
	#pragma convert(0)
2111
#endif
2112
			/* Make sure data is in the correct format, based on the type of the message */
2113
			if(command->tag == RA_CUSTOM_COMMAND) { /* This contains string. Need to perform a conversion */
2114
				isBinary = FALSE;
2115
				length = native2unicode(&data, command->info.custom_command.message.data, command->info.custom_command.message.length);
2116
			}
2117
			else { /* This contains binary data, do not convert */
2118
				isBinary = TRUE;
2119
				length = command->info.custom_command.message.length;
2120
				data = (char*)ra_malloc(sizeof(char*) * length);
2121
				memcpy(data, command->info.custom_command.message.data, length);
2122
			}
2123
2124
			agent = findAgent(command->info.custom_command.agent.data);
2125
			if(agent) {
2126
				jclass agentClass = ENV(env)->GetObjectClass(ENVPARM(env) agent->agent_logger);
2127
				if(agentClass) {
2128
					jmethodID factoryMethod = ENV(env)->GetMethodID(ENVPARM(env) agentClass, funcName_createObjectInContextOfClassLoader, funcSig_createObjectInContextOfClassLoader);
2129
					if(factoryMethod) {
2130
						jstring classname;
2131
						jobject obj;
2132
2133
						if(isBinary) {
2134
							classname = ENV(env)->NewStringUTF(ENVPARM(env) className_BinaryCustomCommand);
2135
						}
2136
						else {
2137
							classname = ENV(env)->NewStringUTF(ENVPARM(env) className_CustomCommand);
2138
						}
2139
2140
						obj = ENV(env)->CallObjectMethod(ENVPARM(env) agent->agent_logger, factoryMethod, classname);
2141
						if(obj) {
2142
							jclass clazz = ENV(env)->GetObjectClass(ENVPARM(env) obj);
2143
							if(clazz) {
2144
								jmethodID setData = ENV(env)->GetMethodID(ENVPARM(env) clazz, funcName_setData, funcSig_setData);
2145
								if(setData) {
2146
									jclass cls;
2147
									jmethodID incomingCommand;
2148
									/* Call the setter on the Command object */
2149
									jbyteArray dataBytes = ENV(env)->NewByteArray(ENVPARM(env) length);
2150
									ENV(env)->SetByteArrayRegion(ENVPARM(env) dataBytes, 0, length, (jbyte*)data);
2151
									ENV(env)->CallVoidMethod(ENVPARM(env) obj, setData, dataBytes);
2152
									/* Invoke incomingCommand on the agent instance */
2153
									cls = ENV(env)->GetObjectClass(ENVPARM(env) agent->agent_logger);
2154
									if(!cls) {
2155
										#ifdef _DEBUG2
2156
										#ifdef MVS
2157
										#pragma convlit(suspend)
2158
										#endif
2159
										fprintf(traceFile, "Java LogAgent: notifyMessage - Find Class failed\n");
2160
										fflush(traceFile);
2161
										#ifdef MVS
2162
										#pragma convlit(resume)
2163
										#endif
2164
										#endif
2165
									}
2166
									else {
2167
										incomingCommand = ENV(env)->GetMethodID(ENVPARM(env) cls, funcName_incomingCommand, funcSig_incomingCommand);
2168
										if(!incomingCommand) {
2169
											#ifdef _DEBUG2
2170
											#ifdef MVS
2171
											#pragma convlit(suspend)
2172
											#endif
2173
											fprintf(traceFile, "Java LogAgent: notifyMessage - GetMethodID failed\n");
2174
											fflush(traceFile);
2175
											#ifdef MVS
2176
											#pragma convlit(resume)
2177
											#endif
2178
											#endif
2179
										}
2180
										else {
2181
											ENV(env)->CallVoidMethod(ENVPARM(env) agent->agent_logger, incomingCommand, obj);
2182
										}
2183
									}
2184
								}
2185
							}
2186
						}
2187
					}
2188
				}
2189
			}
2190
			#ifdef _DEBUG
2191
			/* Note: This call causes the process to end on zOS */
2192
			ENV(env)->ExceptionDescribe(env);
2193
			#endif
2194
			#ifdef _DEBUG2
2195
			#ifdef MVS                    /* 198066 */
2196
			#pragma convlit(suspend)
2197
			#endif
2198
			fprintf(traceFile, "Java LogAgent: notifyMessage - Custom Command processed\n");
2199
			fflush(traceFile);
2200
			#ifdef MVS                    /* 198066 */
2201
			#pragma convlit(resume)
2202
			#endif
2203
			#endif
2204
2205
			/* Free up memory */
2206
			ra_free(data);
2207
2208
			break;
2209
		}
2210
		case RA_SET_NAME_VALUE_PAIR:
2211
		{
2212
			/* The triplets, need conversion */
2213
			char *name_data;
2214
			char *type_data;
2215
			char *value_data;
2216
			int name_len;
2217
			int type_len;
2218
			int value_len;
2219
2220
			/* String constants, need conversion */
2221
#ifdef __OS400__
2222
#pragma convert(819) /* 235033 */
2223
#endif
2224
			char *className_SetNVPairCommand = "SetNVPairCommand";
2225
			char *funcName_createObjectInContextOfClassLoader = "createObjectInContextOfClassLoader";
2226
			char *funcSig_createObjectInContextOfClassLoader = "(Ljava/lang/String;)Ljava/lang/Object;";
2227
			char *funcName_setType = "setType";
2228
			char *funcSig_setType = "(Ljava/lang/String;)V";
2229
			char *funcName_setName = "setName";
2230
			char *funcSig_setName = "(Ljava/lang/String;)V";
2231
			char *funcName_setValue = "setVaue";
2232
			char *funcSig_setValue = "(Ljava/lang/String;)V";
2233
			char *funcName_incomingCommand = "incomingCommand";
2234
			char *funcSig_incomingCommand = "(Lorg/eclipse/hyades/internal/execution/local/common/CommandElement;)V";
2235
#ifdef __OS400__
2236
#pragma convert(0) /* 235033 */
2237
#endif
2238
2239
			name_len = native2unicode(&name_data, command->info.set_nv_pair.name.data, command->info.set_nv_pair.name.length);
2240
			type_len = native2unicode(&type_data, command->info.set_nv_pair.type.data, command->info.set_nv_pair.type.length);
2241
			value_len = native2unicode(&value_data, command->info.set_nv_pair.value.data, command->info.set_nv_pair.value.length);
2242
2243
			agent = findAgent(command->info.set_nv_pair.agent.data);
2244
			if(agent) {
2245
				jclass agentClass = ENV(env)->GetObjectClass(ENVPARM(env) agent->agent_logger);
2246
				if(agentClass) {
2247
					jmethodID factoryMethod = ENV(env)->GetMethodID(ENVPARM(env) agentClass, funcName_createObjectInContextOfClassLoader, funcSig_createObjectInContextOfClassLoader);
2248
					if(factoryMethod) {
2249
						jstring classname = ENV(env)->NewStringUTF(ENVPARM(env) className_SetNVPairCommand);
2250
						jobject obj = ENV(env)->CallObjectMethod(ENVPARM(env) agent->agent_logger, factoryMethod, classname);
2251
						if(obj) {
2252
							jclass clazz = ENV(env)->GetObjectClass(ENVPARM(env) obj);
2253
							if(clazz) {
2254
								jmethodID setType, setName, setValue;
2255
								setName = ENV(env)->GetMethodID(ENVPARM(env) clazz, funcName_setName, funcSig_setName);
2256
								setType = ENV(env)->GetMethodID(ENVPARM(env) clazz, funcName_setType, funcSig_setType);
2257
								setValue = ENV(env)->GetMethodID(ENVPARM(env) clazz, funcName_setValue, funcSig_setValue);
2258
								if(setType && setName && setValue) {
2259
									jclass cls;
2260
									jstring setTypeParam, setNameParam, setValueParam;
2261
									jmethodID incomingCommand;
2262
									char *name, *type, *value;
2263
2264
									/* Bug 83888 */
2265
2266
									/* Verify the name */
2267
									if(name_data == NULL) { /* name cannot be null */
2268
										break;
2269
									}
2270
2271
									/* Verify the type */
2272
									if(type_data == NULL) {
2273
										type_data = "\0";
2274
									}
2275
2276
									/* Verify the value */
2277
									if(value_data == NULL) {
2278
										value = "\0";
2279
									}
2280
2281
									/* Call the setters on the Command object */
2282
									setNameParam = ENV(env)->NewStringUTF(ENVPARM(env) name_data); /* Bug 83888 */
2283
									ENV(env)->CallVoidMethod(ENVPARM(env) obj, setName, setNameParam );
2284
									setTypeParam = ENV(env)->NewStringUTF(ENVPARM(env) type_data); /* Bug 83888 */
2285
									ENV(env)->CallVoidMethod(ENVPARM(env) obj, setType, setTypeParam );
2286
									setValueParam = ENV(env)->NewStringUTF(ENVPARM(env) value_data); /* Bug 83888 */
2287
									ENV(env)->CallVoidMethod(ENVPARM(env) obj, setValue, setValueParam );
2288
2289
									/* Invoke incomingCommand on the agent instance */
2290
									cls = ENV(env)->GetObjectClass(ENVPARM(env) agent->agent_logger);
2291
2292
									if(!cls) {
2293
										#ifdef _DEBUG
2294
										#ifdef MVS                    /* 198066 */
2295
										#pragma convlit(suspend)
2296
										#endif
2297
										printf("LogAgent: _agent_notifyMessage - Find Class failed\n");
2298
										#ifdef MVS                    /* 198066 */
2299
										#pragma convlit(resume)
2300
										#endif
2301
										#endif
2302
									}
2303
									else {
2304
										incomingCommand = ENV(env)->GetMethodID(ENVPARM(env) cls, funcName_incomingCommand, funcSig_incomingCommand);
2305
										if(!incomingCommand) {
2306
											#ifdef _DEBUG
2307
											#ifdef MVS                    /* 198066 */
2308
											#pragma convlit(suspend)
2309
											#endif
2310
											printf("LogAgent: _agent_notifyMessage - GetMethodID failed\n");
2311
											#ifdef MVS                    /* 198066 */
2312
											#pragma convlit(resume)
2313
											#endif
2314
											#endif
2315
										}
2316
										else {
2317
											ENV(env)->CallVoidMethod(ENVPARM(env) agent->agent_logger, incomingCommand, obj);
2318
										}
2319
									}
2320
								}
2321
							}
2322
						}
2323
					}
2324
				}
2325
			}
2326
2327
			ra_free(name_data);
2328
			ra_free(type_data);
2329
			ra_free(value_data);
2330
2331
			break;
2332
		}
2333
		case RA_PEER_UNREACHABLE:
2334
			agent = findAgent(command->info.peer_unreachable.agent.data);
2335
			if(agent) {
2336
					jmethodID peerUnreachable;
2337
					jclass cls;
2338
					/* Find the class object */
2339
					cls = ENV(env)->GetObjectClass(ENVPARM(env) agent->agent_logger);
2340
					/* Inform the calling agent that the remote peer is unreachable
2341
					 * RKD: This is a V5 addition we better catch the exception if the method does not exist.
2342
					 */
2343
#ifdef __OS400__
2344
#pragma convert(819) /* 235033 */
2345
#endif
2346
					peerUnreachable = ENV(env)->GetMethodID(ENVPARM(env) cls, "peerUnreachable", "()V");
2347
#ifdef __OS400__
2348
#pragma convert(0) /* 235033 */
2349
#endif
2350
					if(peerUnreachable) {
2351
						ENV(env)->CallVoidMethod(ENVPARM(env) agent->agent_logger, peerUnreachable, NULL);
2352
					}
2353
				}
2354
			break;
2355
		} /* switch */
2356
2357
		#ifdef _DEBUG2
2358
		#ifdef MVS                    /* 198066 */
2359
		#pragma convlit(suspend)
2360
		#endif
2361
		fprintf(traceFile, "Java Log Agent: notifyMessage:  Completed message handling.\n");
2362
		fflush(traceFile);
2363
		#ifdef MVS                    /* 198066 */
2364
		#pragma convlit(resume)
2365
		#endif
2366
		#endif
2367
2368
#ifdef _DEBUG
2369
		/* Note: This call causes the process to end on zOS */
2370
		ENV(env)->ExceptionDescribe(env);
2371
#endif
2372
2373
		/* If there are any pending exceptions clear them.
2374
		   Detach the current thread from the JVM
2375
		 */
2376
#if defined __cplusplus && defined _HPUX
2377
		ENV(env)->ExceptionClear();
2378
		ENV(_agent_vm)->DetachCurrentThread();
2379
#else
2380
		ENV(env)->ExceptionClear(env);
2381
		(*_agent_vm)->DetachCurrentThread(_agent_vm);
2382
#endif
2383
	}
2384
2385
}
2386
2387
2388
/** NATIVE_NOTIFY_MESSAGE  ************************************************************
2389
  * This function is called by the underlying controller mechanism to notify a particular
2390
  * logging agent to either start/stop monitoring or to forward configuration information
2391
  * via the RA_SET_NAME_VALUE_PAIR or RA_CUSTOM_COMMAND commands.
2392
  */
2393
static void _native_notifyMessage(ra_command_t *command) {
2394
	jint result;
2395
	agent_list_entry_t *agent;
2396
2397
	#ifdef _DEBUG
2398
	#ifdef MVS                    /* 198066 */
2399
	#pragma convlit(suspend)
2400
	#endif
2401
	printf("Native Log Agent: Recieving message 0x%x\n", command->tag);
2402
	#ifdef MVS                    /* 198066 */
2403
	#pragma convlit(resume)
2404
	#endif
2405
	#endif
2406
2407
		switch(command->tag) {
2408
		case RA_AGENT_CONTROLER_AVAILABLE:
2409
			agent=findAgent(command->info.agentName.data);
2410
			if(agent) {
2411
			}
2412
			break;
2413
		case RA_AGENT_CONTROLER_UNAVAILABLE:
2414
			agent=findAgent(command->info.agentName.data);
2415
			if(agent) {
2416
			}
2417
			break;
2418
		case RA_DETACH_FROM_AGENT:
2419
			agent=findAgent(command->info.detach.agent.data);
2420
			if(agent) {
2421
			}
2422
			break;
2423
		case RA_START_MONITORING_AGENT_REMOTE:
2424
			agent=findAgent(command->info.start_monitor_remote.agent.data);
2425
			if(agent && !agent->monitored) {
2426
2427
				#ifdef _DEBUG
2428
				#ifdef MVS                    /* 198066 */
2429
				#pragma convlit(suspend)
2430
				#endif
2431
				printf("Log Agent: %s connecting to remote server\n", agent->agent_name);
2432
				#ifdef MVS                    /* 198066 */
2433
				#pragma convlit(resume)
2434
				#endif
2435
				#endif
2436
2437
				agent->targetHdl.dtarget = RA_SOCKET;
2438
2439
				ra_connectToTCPServer(command->info.start_monitor_remote.ip,
2440
									  (unsigned short)command->info.start_monitor_remote.port,
2441
									  &agent->targetHdl.dtargetHdl.socketFD);
2442
2443
				agent->monitored=TRUE;
2444
			}
2445
			#ifdef _DEBUG
2446
			else {
2447
				#ifdef MVS                    /* 198066 */
2448
				#pragma convlit(suspend)
2449
				#endif
2450
				printf("Log Agent: Couldn't find agent %s", agent->agent_name);
2451
				#ifdef MVS                    /* 198066 */
2452
				#pragma convlit(resume)
2453
				#endif
2454
			}
2455
			#endif
2456
			break;
2457
		case RA_START_MONITORING_AGENT_LOCAL:
2458
			agent=findAgent(command->info.start_monitor_remote.agent.data);
2459
			if(agent && !agent->monitored) {
2460
2461
				#ifdef _DEBUG
2462
				#ifdef MVS                    /* 198066 */
2463
				#pragma convlit(suspend)
2464
				#endif
2465
				printf("Log Agent: %s connecting to shared memory pipe\n", agent->agent_name);
2466
				#ifdef MVS                    /* 198066 */
2467
				#pragma convlit(resume)
2468
				#endif
2469
				#endif
2470
2471
				result = ra_attachToShm(command->info.start_monitor_local.file.data,
2472
								&agent->targetHdl.dtargetHdl.shmHdl);
2473
				if(result != 0) {
2474
					#ifdef MVS                    /* 198066 */
2475
					#pragma convlit(suspend)
2476
					#endif
2477
					printf("Error attaching to shared memory\n");
2478
					#ifdef MVS                    /* 198066 */
2479
					#pragma convlit(resume)
2480
					#endif
2481
				}
2482
2483
				agent->targetHdl.dtarget = RA_SHAREDMEMORY;
2484
2485
				agent->monitored=TRUE;
2486
			}
2487
			#ifdef _DEBUG
2488
			else {
2489
				#ifdef MVS                    /* 198066 */
2490
				#pragma convlit(suspend)
2491
				#endif
2492
				printf("Log Agent: Couldn't find agent %s", command->info.start_monitor_remote.agent.data);
2493
				#ifdef MVS                    /* 198066 */
2494
				#pragma convlit(resume)
2495
				#endif
2496
			}
2497
			#endif
2498
			break;
2499
		case RA_STOP_MONITORING_AGENT:
2500
			agent=findAgent(command->info.stop_monitor.agent.data);
2501
			if(agent && agent->monitored) {
2502
				/* Close the appropriate logging mechanism */
2503
				if(agent->targetHdl.dtarget==RA_SOCKET) {
2504
					ra_closeSocket(agent->targetHdl.dtargetHdl.socketFD);
2505
2506
				}
2507
				else if(agent->targetHdl.dtarget==RA_SHAREDMEMORY) {
2508
					ra_stopFlushingShm(&agent->targetHdl.dtargetHdl.shmHdl);
2509
				}
2510
				agent->monitored=FALSE;
2511
			}
2512
			break;
2513
		case RA_CUSTOM_COMMAND:
2514
			agent=findAgent(command->info.custom_command.agent.data);
2515
			/* create a CustomCommand and forward this to the Agent.incomingCommand() method */
2516
			if(agent) {
2517
			}
2518
			break;
2519
		case RA_SET_NAME_VALUE_PAIR:
2520
			agent=findAgent(command->info.set_nv_pair.agent.data);
2521
			/* Create a CustomCommand and forward this to the Agent.incomingCommand() method */
2522
			if(agent) {
2523
			}
2524
			break;
2525
		}
2526
		/* Forward the command to the agent handler registered with the native agent.  The developer has the option of
2527
		 * registering their own command handler using agent->nativeCommandHandler. */
2528
		if (agent && agent->nativeCommandHandler)
2529
		{
2530
			#ifdef _DEBUG
2531
			#ifdef MVS                    /* 198066 */
2532
			#pragma convlit(suspend)
2533
			#endif
2534
				printf("Log Agent: About to forward command to the registered customized handler\n");
2535
			#ifdef MVS                    /* 198066 */
2536
			#pragma convlit(resume)
2537
			#endif
2538
			#endif
2539
			
2540
			agent->nativeCommandHandler(command);
2541
2542
			#ifdef _DEBUG
2543
			#ifdef MVS                    /* 198066 */
2544
			#pragma convlit(suspend)
2545
			#endif
2546
				printf("Log Agent: Forward of command to customized agent was successful\n");
2547
			#ifdef MVS                    /* 198066 */
2548
			#pragma convlit(resume)
2549
			#endif
2550
			#endif
2551
		}
2552
2553
	#ifdef _DEBUG
2554
	#ifdef MVS                    /* 198066 */
2555
	#pragma convlit(suspend)
2556
	#endif
2557
	printf("Log Agent: Completed message\n");
2558
	#ifdef MVS                    /* 198066 */
2559
	#pragma convlit(resume)
2560
	#endif
2561
	#endif
2562
}
2563
2564
/* Bug 79816 */
2565
JNIEXPORT jlong JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_getPID0(JNIEnv *env, jobject obj) {
2566
	jlong pid;
2567
2568
#ifdef __OS400__
2569
	pid.unsigned_ll = ra_getProcessId();
2570
#else
2571
	pid = ra_getProcessId();
2572
#endif
2573
2574
	return pid;
2575
}
2576
2577
/* Bug 79816 */
2578
JNIEXPORT jstring JNICALL Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_generateUUID0(JNIEnv *env, jobject obj) {
2579
	ra_string_t *uuid;
2580
	jstring juuid;
2581
2582
	uuid = (ra_string_t*)malloc(sizeof(ra_string_t));
2583
	ra_generateUUID(uuid); 
2584
2585
	juuid = ENV(env)->NewStringUTF(ENVPARM(env) uuid->data);
2586
	free(uuid);
2587
2588
	return juuid;
2589
}
2590
2591
2592
/* RKD:  This is not turned on yet and when it is it is Windows explicit.
2593
 */
2594
#if 0
2595
BOOL APIENTRY DllMain( HANDLE hModule,
2596
                       DWORD  ul_reason_for_call,
2597
                       LPVOID lpReserved
2598
					 )
2599
{
2600
    switch(ul_reason_for_call) {
2601
    case DLL_PROCESS_ATTACH:
2602
        break;
2603
    case DLL_THREAD_ATTACH:
2604
        break;
2605
    case DLL_THREAD_DETACH:
2606
        break;
2607
    case DLL_PROCESS_DETACH:
2608
        break;
2609
    }
2610
    return TRUE;
2611
}
2612
#endif
(-)src-native-new/src/agents/thread/WinBuild/hcthread.dsp (+117 lines)
Added Link Here
1
# Microsoft Developer Studio Project File - Name="hcthread" - Package Owner=<4>
2
# Microsoft Developer Studio Generated Build File, Format Version 6.00
3
# ** DO NOT EDIT **
4
5
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
6
7
CFG=hcthread - Win32 Debug
8
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9
!MESSAGE use the Export Makefile command and run
10
!MESSAGE 
11
!MESSAGE NMAKE /f "hcthread.mak".
12
!MESSAGE 
13
!MESSAGE You can specify a configuration when running NMAKE
14
!MESSAGE by defining the macro CFG on the command line. For example:
15
!MESSAGE 
16
!MESSAGE NMAKE /f "hcthread.mak" CFG="hcthread - Win32 Debug"
17
!MESSAGE 
18
!MESSAGE Possible choices for configuration are:
19
!MESSAGE 
20
!MESSAGE "hcthread - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
21
!MESSAGE "hcthread - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
22
!MESSAGE 
23
24
# Begin Project
25
# PROP AllowPerConfigDependencies 0
26
# PROP Scc_ProjName ""
27
# PROP Scc_LocalPath ""
28
CPP=cl.exe
29
MTL=midl.exe
30
RSC=rc.exe
31
32
!IF  "$(CFG)" == "hcthread - Win32 Release"
33
34
# PROP BASE Use_MFC 0
35
# PROP BASE Use_Debug_Libraries 0
36
# PROP BASE Output_Dir "Release"
37
# PROP BASE Intermediate_Dir "Release"
38
# PROP BASE Target_Dir ""
39
# PROP Use_MFC 0
40
# PROP Use_Debug_Libraries 0
41
# PROP Output_Dir "..\..\..\..\lib"
42
# PROP Intermediate_Dir "Release"
43
# PROP Ignore_Export_Lib 0
44
# PROP Target_Dir ""
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCTHREAD_EXPORTS" /YX /FD /c
46
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCTHREAD_EXPORTS" /FD /c
47
# SUBTRACT CPP /YX
48
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
49
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
50
# ADD BASE RSC /l 0x409 /d "NDEBUG"
51
# ADD RSC /l 0x409 /d "NDEBUG"
52
BSC32=bscmake.exe
53
# ADD BASE BSC32 /nologo
54
# ADD BSC32 /nologo
55
LINK32=link.exe
56
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
57
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hcbnd.lib hcclco.lib hccldt.lib hcclsm.lib hccls.lib /nologo /dll /machine:I386 /libpath:"..\..\..\..\lib" /out:"..\..\..\..\bin\hcthread.dll"
58
59
!ELSEIF  "$(CFG)" == "hcthread - Win32 Debug"
60
61
# PROP BASE Use_MFC 0
62
# PROP BASE Use_Debug_Libraries 1
63
# PROP BASE Output_Dir "Debug"
64
# PROP BASE Intermediate_Dir "Debug"
65
# PROP BASE Target_Dir ""
66
# PROP Use_MFC 0
67
# PROP Use_Debug_Libraries 1
68
# PROP Output_Dir "..\..\..\..\lib"
69
# PROP Intermediate_Dir "Debug"
70
# PROP Ignore_Export_Lib 0
71
# PROP Target_Dir ""
72
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCTHREAD_EXPORTS" /YX /FD /GZ /c
73
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCTHREAD_EXPORTS" /FD /GZ /c
74
# SUBTRACT CPP /YX
75
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
76
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
77
# ADD BASE RSC /l 0x409 /d "_DEBUG"
78
# ADD RSC /l 0x409 /d "_DEBUG"
79
BSC32=bscmake.exe
80
# ADD BASE BSC32 /nologo
81
# ADD BSC32 /nologo
82
LINK32=link.exe
83
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
84
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hcbnd.lib hcclco.lib hccldt.lib hcclsm.lib hccls.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\..\lib" /out:"..\..\..\..\bin\hcthread.dll"
85
86
!ENDIF 
87
88
# Begin Target
89
90
# Name "hcthread - Win32 Release"
91
# Name "hcthread - Win32 Debug"
92
# Begin Group "Source Files"
93
94
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
95
# Begin Source File
96
97
SOURCE=..\hcthread.c
98
# End Source File
99
# Begin Source File
100
101
SOURCE=..\hcthread.def
102
# End Source File
103
# End Group
104
# Begin Group "Header Files"
105
106
# PROP Default_Filter "h;hpp;hxx;hm;inl"
107
# Begin Source File
108
109
SOURCE=..\hcthread.h
110
# End Source File
111
# End Group
112
# Begin Group "Resource Files"
113
114
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
115
# End Group
116
# End Target
117
# End Project
(-)src-native-new/src/agents/RABindings/WinBuild/RABindings.mak64 (+442 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on RABinding.dsp
2
!IF "$(CFG)" == ""
3
CFG=RABinding - IA64 Debug
4
!MESSAGE No configuration specified. Defaulting to RABinding - IA64 Debug.
5
!ENDIF 
6
7
!IF "$(CFG)" != "RABinding - IA64 Release" && "$(CFG)" != "RABinding - IA64 Debug" && "$(CFG)" != "RABinding - X64 Release" && "$(CFG)" != "RABinding - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "RABinding.mak64" CFG="RABinding - IA64 Debug"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "RABinding - IA64 Release"
17
!MESSAGE "RABinding - IA64 Debug"
18
!MESSAGE "RABinding - X64 Release"
19
!MESSAGE "RABinding - X64 Debug"
20
!MESSAGE 
21
!ERROR An invalid configuration is specified.
22
!ENDIF 
23
24
!IF "$(OS)" == "Windows_NT"
25
NULL=
26
!ELSE 
27
NULL=nul
28
!ENDIF 
29
30
!IF  "$(CFG)" == "RABinding - IA64 Release"
31
32
OUTDIR=..\..\..\..\bin
33
INTDIR=.\Release
34
# Begin Custom Macros
35
OutDir=..\..\..\..\bin
36
# End Custom Macros
37
38
!IF "$(RECURSE)" == "0" 
39
40
ALL : "$(OUTDIR)\hcbnd.dll"
41
42
!ELSE 
43
44
ALL : "$(OUTDIR)\hcbnd.dll"
45
46
!ENDIF 
47
48
!IF "$(RECURSE)" == "1" 
49
CLEAN :
50
!ELSE 
51
CLEAN :
52
!ENDIF 
53
	-@erase "$(INTDIR)\hcbnd.res"
54
	-@erase "$(INTDIR)\lock3.obj"
55
	-@erase "$(INTDIR)\RABindings.obj"
56
	-@erase "$(INTDIR)\vc60.idb"
57
	-@erase "$(OUTDIR)\hcbnd.dll"
58
	-@erase "$(OUTDIR)\..\lib\hcbnd.exp"
59
	-@erase "$(OUTDIR)\..\lib\hcbnd.lib"
60
61
"$(OUTDIR)" :
62
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
63
64
"$(INTDIR)" :
65
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
66
67
CPP=cl.exe
68
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /Ob0 /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RABINDING_EXPORTS" /Fp"$(INTDIR)\RABinding.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
69
70
.c{$(INTDIR)}.obj::
71
   $(CPP) @<<
72
   $(CPP_PROJ) $< 
73
<<
74
75
.cpp{$(INTDIR)}.obj::
76
   $(CPP) @<<
77
   $(CPP_PROJ) $< 
78
<<
79
80
.cxx{$(INTDIR)}.obj::
81
   $(CPP) @<<
82
   $(CPP_PROJ) $< 
83
<<
84
85
.c{$(INTDIR)}.sbr::
86
   $(CPP) @<<
87
   $(CPP_PROJ) $< 
88
<<
89
90
.cpp{$(INTDIR)}.sbr::
91
   $(CPP) @<<
92
   $(CPP_PROJ) $< 
93
<<
94
95
.cxx{$(INTDIR)}.sbr::
96
   $(CPP) @<<
97
   $(CPP_PROJ) $< 
98
<<
99
100
MTL=midl.exe
101
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
102
RSC=rc.exe
103
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcbnd.res" /d "NDEBUG" 
104
105
LINK32=link.exe
106
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ws2_32.lib bufferoverflowU.lib /nologo /version:0.1 /dll /pdb:none /def:"..\RABindings.def" /out:"$(OUTDIR)\hcbnd.dll" /implib:"$(OUTDIR)\..\lib\hcbnd.lib" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
107
LINK32_OBJS= \
108
	"$(INTDIR)\lock3.obj" \
109
	"$(INTDIR)\RABindings.obj" \
110
	"$(INTDIR)\hcbnd.res" \
111
	"$(OUTDIR)\..\lib\hcclco.lib" \
112
	"$(OUTDIR)\..\lib\hccls.lib"
113
114
"$(OUTDIR)\hcbnd.dll" : "$(OUTDIR)" $(LINK32_OBJS)
115
    $(LINK32) @<<
116
  $(LINK32_FLAGS) $(LINK32_OBJS)
117
<<
118
119
!ELSEIF  "$(CFG)" == "RABinding - IA64 Debug"
120
121
OUTDIR=..\..\..\..\bin
122
INTDIR=.\Debug
123
# Begin Custom Macros
124
OutDir=..\..\..\..\bin
125
# End Custom Macros
126
127
!IF "$(RECURSE)" == "0" 
128
129
ALL : "$(OUTDIR)\hcbnd.dll"
130
131
!ELSE 
132
133
ALL : "$(OUTDIR)\hcbnd.dll"
134
135
!ENDIF 
136
137
!IF "$(RECURSE)" == "1" 
138
CLEAN :
139
!ELSE 
140
CLEAN :
141
!ENDIF 
142
	-@erase "$(INTDIR)\hcbnd.res"
143
	-@erase "$(INTDIR)\lock3.obj"
144
	-@erase "$(INTDIR)\RABindings.obj"
145
	-@erase "$(INTDIR)\vc60.idb"
146
	-@erase "$(INTDIR)\vc60.pdb"
147
	-@erase "$(OUTDIR)\hcbnd.dll"
148
	-@erase "$(OUTDIR)\..\lib\hcbnd.exp"
149
	-@erase "$(OUTDIR)\..\lib\hcbnd.ilk"
150
	-@erase "$(OUTDIR)\..\lib\hcbnd.lib"
151
	-@erase "$(OUTDIR)\..\lib\hcbnd.pdb"
152
153
"$(OUTDIR)" :
154
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
155
156
"$(INTDIR)" :
157
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
158
159
CPP=cl.exe
160
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RABINDING_EXPORTS" /Fp"$(INTDIR)\RABinding.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
161
162
.c{$(INTDIR)}.obj::
163
   $(CPP) @<<
164
   $(CPP_PROJ) $< 
165
<<
166
167
.cpp{$(INTDIR)}.obj::
168
   $(CPP) @<<
169
   $(CPP_PROJ) $< 
170
<<
171
172
.cxx{$(INTDIR)}.obj::
173
   $(CPP) @<<
174
   $(CPP_PROJ) $< 
175
<<
176
177
.c{$(INTDIR)}.sbr::
178
   $(CPP) @<<
179
   $(CPP_PROJ) $< 
180
<<
181
182
.cpp{$(INTDIR)}.sbr::
183
   $(CPP) @<<
184
   $(CPP_PROJ) $< 
185
<<
186
187
.cxx{$(INTDIR)}.sbr::
188
   $(CPP) @<<
189
   $(CPP_PROJ) $< 
190
<<
191
192
MTL=midl.exe
193
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
194
RSC=rc.exe
195
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcbnd.res" /d "_DEBUG" 
196
197
LINK32=link.exe
198
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ws2_32.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcbnd.pdb" /debug /def:"..\RABindings.def" /out:"$(OUTDIR)\hcbnd.dll" /implib:"$(OUTDIR)\..\lib\hcbnd.lib" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
199
LINK32_OBJS= \
200
	"$(INTDIR)\lock3.obj" \
201
	"$(INTDIR)\RABindings.obj" \
202
	"$(INTDIR)\hcbnd.res" \
203
	"$(OUTDIR)\..\lib\hcclco.lib" \
204
	"$(OUTDIR)\..\lib\hccls.lib"
205
206
"$(OUTDIR)\hcbnd.dll" : "$(OUTDIR)" $(LINK32_OBJS)
207
    $(LINK32) @<<
208
  $(LINK32_FLAGS) $(LINK32_OBJS)
209
<<
210
211
!ELSEIF  "$(CFG)" == "RABinding - X64 Release"
212
213
OUTDIR=..\..\..\..\bin
214
INTDIR=.\Release
215
# Begin Custom Macros
216
OutDir=..\..\..\..\bin
217
# End Custom Macros
218
219
!IF "$(RECURSE)" == "0" 
220
221
ALL : "$(OUTDIR)\hcbnd.dll"
222
223
!ELSE 
224
225
ALL : "$(OUTDIR)\hcbnd.dll"
226
227
!ENDIF 
228
229
!IF "$(RECURSE)" == "1" 
230
CLEAN :
231
!ELSE 
232
CLEAN :
233
!ENDIF 
234
	-@erase "$(INTDIR)\hcbnd.res"
235
	-@erase "$(INTDIR)\lock3.obj"
236
	-@erase "$(INTDIR)\RABindings.obj"
237
	-@erase "$(INTDIR)\vc60.idb"
238
	-@erase "$(OUTDIR)\hcbnd.dll"
239
	-@erase "$(OUTDIR)\..\lib\hcbnd.exp"
240
	-@erase "$(OUTDIR)\..\lib\hcbnd.lib"
241
242
"$(OUTDIR)" :
243
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
244
245
"$(INTDIR)" :
246
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
247
248
CPP=cl.exe
249
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /Ob0 /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RABINDING_EXPORTS" /Fp"$(INTDIR)\RABinding.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
250
251
.c{$(INTDIR)}.obj::
252
   $(CPP) @<<
253
   $(CPP_PROJ) $< 
254
<<
255
256
.cpp{$(INTDIR)}.obj::
257
   $(CPP) @<<
258
   $(CPP_PROJ) $< 
259
<<
260
261
.cxx{$(INTDIR)}.obj::
262
   $(CPP) @<<
263
   $(CPP_PROJ) $< 
264
<<
265
266
.c{$(INTDIR)}.sbr::
267
   $(CPP) @<<
268
   $(CPP_PROJ) $< 
269
<<
270
271
.cpp{$(INTDIR)}.sbr::
272
   $(CPP) @<<
273
   $(CPP_PROJ) $< 
274
<<
275
276
.cxx{$(INTDIR)}.sbr::
277
   $(CPP) @<<
278
   $(CPP_PROJ) $< 
279
<<
280
281
MTL=midl.exe
282
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
283
RSC=rc.exe
284
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcbnd.res" /d "NDEBUG" 
285
286
LINK32=link.exe
287
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ws2_32.lib bufferoverflowU.lib /nologo /version:0.1 /dll /pdb:none /def:"..\RABindings.def" /out:"$(OUTDIR)\hcbnd.dll" /implib:"$(OUTDIR)\..\lib\hcbnd.lib" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
288
LINK32_OBJS= \
289
	"$(INTDIR)\lock3.obj" \
290
	"$(INTDIR)\RABindings.obj" \
291
	"$(INTDIR)\hcbnd.res" \
292
	"$(OUTDIR)\..\lib\hcclco.lib" \
293
	"$(OUTDIR)\..\lib\hccls.lib"
294
295
"$(OUTDIR)\hcbnd.dll" : "$(OUTDIR)" $(LINK32_OBJS)
296
    $(LINK32) @<<
297
  $(LINK32_FLAGS) $(LINK32_OBJS)
298
<<
299
300
!ELSEIF  "$(CFG)" == "RABinding - X64 Debug"
301
302
OUTDIR=..\..\..\..\bin
303
INTDIR=.\Debug
304
# Begin Custom Macros
305
OutDir=..\..\..\..\bin
306
# End Custom Macros
307
308
!IF "$(RECURSE)" == "0" 
309
310
ALL : "$(OUTDIR)\hcbnd.dll"
311
312
!ELSE 
313
314
ALL : "$(OUTDIR)\hcbnd.dll"
315
316
!ENDIF 
317
318
!IF "$(RECURSE)" == "1" 
319
CLEAN :
320
!ELSE 
321
CLEAN :
322
!ENDIF 
323
	-@erase "$(INTDIR)\hcbnd.res"
324
	-@erase "$(INTDIR)\lock3.obj"
325
	-@erase "$(INTDIR)\RABindings.obj"
326
	-@erase "$(INTDIR)\vc60.idb"
327
	-@erase "$(INTDIR)\vc60.pdb"
328
	-@erase "$(OUTDIR)\hcbnd.dll"
329
	-@erase "$(OUTDIR)\..\lib\hcbnd.exp"
330
	-@erase "$(OUTDIR)\..\lib\hcbnd.ilk"
331
	-@erase "$(OUTDIR)\..\lib\hcbnd.lib"
332
	-@erase "$(OUTDIR)\..\lib\hcbnd.pdb"
333
334
"$(OUTDIR)" :
335
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
336
337
"$(INTDIR)" :
338
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
339
340
CPP=cl.exe
341
CPP_PROJ=/nologo /MTd /W3 /Gm /EHsc /Zi /Od /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RABINDING_EXPORTS" /Fp"$(INTDIR)\RABinding.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
342
343
.c{$(INTDIR)}.obj::
344
   $(CPP) @<<
345
   $(CPP_PROJ) $< 
346
<<
347
348
.cpp{$(INTDIR)}.obj::
349
   $(CPP) @<<
350
   $(CPP_PROJ) $< 
351
<<
352
353
.cxx{$(INTDIR)}.obj::
354
   $(CPP) @<<
355
   $(CPP_PROJ) $< 
356
<<
357
358
.c{$(INTDIR)}.sbr::
359
   $(CPP) @<<
360
   $(CPP_PROJ) $< 
361
<<
362
363
.cpp{$(INTDIR)}.sbr::
364
   $(CPP) @<<
365
   $(CPP_PROJ) $< 
366
<<
367
368
.cxx{$(INTDIR)}.sbr::
369
   $(CPP) @<<
370
   $(CPP_PROJ) $< 
371
<<
372
373
MTL=midl.exe
374
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
375
RSC=rc.exe
376
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcbnd.res" /d "_DEBUG" 
377
378
LINK32=link.exe
379
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib ws2_32.lib bufferoverflowU.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcbnd.pdb" /debug /def:"..\RABindings.def" /out:"$(OUTDIR)\hcbnd.dll" /implib:"$(OUTDIR)\..\lib\hcbnd.lib" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
380
LINK32_OBJS= \
381
	"$(INTDIR)\lock3.obj" \
382
	"$(INTDIR)\RABindings.obj" \
383
	"$(INTDIR)\hcbnd.res" \
384
	"$(OUTDIR)\..\lib\hcclco.lib" \
385
	"$(OUTDIR)\..\lib\hccls.lib"
386
387
"$(OUTDIR)\hcbnd.dll" : "$(OUTDIR)" $(LINK32_OBJS)
388
    $(LINK32) @<<
389
  $(LINK32_FLAGS) $(LINK32_OBJS)
390
<<
391
392
!ENDIF 
393
394
395
!IF "$(CFG)" == "RABinding - IA64 Release" || "$(CFG)" == "RABinding - IA64 Debug" || "$(CFG)" == "RABinding - X64 Release" || "$(CFG)" == "RABinding - X64 Debug"
396
SOURCE=..\lock3.c
397
398
"$(INTDIR)\lock3.obj" : $(SOURCE) "$(INTDIR)"
399
	$(CPP) $(CPP_PROJ) $(SOURCE)
400
401
402
SOURCE=..\RABindings.c
403
404
"$(INTDIR)\RABindings.obj" : $(SOURCE) "$(INTDIR)"
405
	$(CPP) $(CPP_PROJ) $(SOURCE)
406
407
408
SOURCE=..\version.rc
409
410
!IF  "$(CFG)" == "RABinding - IA64 Release"
411
412
413
"$(INTDIR)\hcbnd.res" : $(SOURCE) "$(INTDIR)"
414
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcbnd.res" /d "NDEBUG" $(SOURCE)
415
416
417
!ELSEIF  "$(CFG)" == "RABinding - IA64 Debug"
418
419
420
"$(INTDIR)\hcbnd.res" : $(SOURCE) "$(INTDIR)"
421
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcbnd.res" /d "_DEBUG" $(SOURCE)
422
423
424
!ELSEIF  "$(CFG)" == "RABinding - X64 Release"
425
426
427
"$(INTDIR)\hcbnd.res" : $(SOURCE) "$(INTDIR)"
428
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcbnd.res" /d "NDEBUG" $(SOURCE)
429
430
431
!ELSEIF  "$(CFG)" == "RABinding - X64 Debug"
432
433
434
"$(INTDIR)\hcbnd.res" : $(SOURCE) "$(INTDIR)"
435
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcbnd.res" /d "_DEBUG" $(SOURCE)
436
437
438
!ENDIF 
439
440
441
!ENDIF 
442
(-)src-native-new/src/agents/perfmon/rac/version.rc (+109 lines)
Added Link Here
1
//Microsoft Developer Studio generated resource script.
2
//
3
#include "resource.h"
4
5
#define APSTUDIO_READONLY_SYMBOLS
6
/////////////////////////////////////////////////////////////////////////////
7
//
8
// Generated from the TEXTINCLUDE 2 resource.
9
//
10
#include "afxres.h"
11
12
/////////////////////////////////////////////////////////////////////////////
13
#undef APSTUDIO_READONLY_SYMBOLS
14
15
/////////////////////////////////////////////////////////////////////////////
16
// English (U.S.) resources
17
18
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
19
#ifdef _WIN32
20
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21
#pragma code_page(1252)
22
#endif //_WIN32
23
24
#ifndef _MAC
25
/////////////////////////////////////////////////////////////////////////////
26
//
27
// Version
28
//
29
30
VS_VERSION_INFO VERSIONINFO
31
 FILEVERSION 3,1,0,0
32
 PRODUCTVERSION 3,1,0,0
33
 FILEFLAGSMASK 0x3fL
34
#ifdef _DEBUG
35
 FILEFLAGS 0x1L
36
#else
37
 FILEFLAGS 0x0L
38
#endif
39
 FILEOS 0x40004L
40
 FILETYPE 0x2L
41
 FILESUBTYPE 0x0L
42
BEGIN
43
    BLOCK "StringFileInfo"
44
    BEGIN
45
        BLOCK "040904b0"
46
        BEGIN
47
            VALUE "Comments", "\0"
48
            VALUE "CompanyName", "ECLIPSE\0"
49
            VALUE "FileDescription", "Performance Monitor RAC Library\0"
50
            VALUE "FileVersion", "3, 1, 0, 0\0"
51
            VALUE "InternalName", "\0"
52
            VALUE "LegalCopyright", "© Copyright International Business Machines Corporation, 2004\0"
53
            VALUE "LegalTrademarks", "\0"
54
            VALUE "OriginalFilename", "rac.dll\0"
55
            VALUE "PrivateBuild", "\0"
56
            VALUE "ProductName", "\0"
57
            VALUE "ProductVersion", "3, 1, 0, 0\0"
58
            VALUE "SpecialBuild", "\0"
59
        END
60
    END
61
    BLOCK "VarFileInfo"
62
    BEGIN
63
        VALUE "Translation", 0x409, 1200
64
    END
65
END
66
67
#endif    // !_MAC
68
69
70
#ifdef APSTUDIO_INVOKED
71
/////////////////////////////////////////////////////////////////////////////
72
//
73
// TEXTINCLUDE
74
//
75
76
1 TEXTINCLUDE DISCARDABLE
77
BEGIN
78
    "resource.h\0"
79
END
80
81
2 TEXTINCLUDE DISCARDABLE
82
BEGIN
83
    "#include ""afxres.h""\r\n"
84
    "\0"
85
END
86
87
3 TEXTINCLUDE DISCARDABLE
88
BEGIN
89
    "\r\n"
90
    "\0"
91
END
92
93
#endif    // APSTUDIO_INVOKED
94
95
#endif    // English (U.S.) resources
96
/////////////////////////////////////////////////////////////////////////////
97
98
99
100
#ifndef APSTUDIO_INVOKED
101
/////////////////////////////////////////////////////////////////////////////
102
//
103
// Generated from the TEXTINCLUDE 3 resource.
104
//
105
106
107
/////////////////////////////////////////////////////////////////////////////
108
#endif    // not APSTUDIO_INVOKED
109
(-)src-native-new/src/agents/native/WinBuild/heapsnapshots.mak (+200 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on heapsnapshots.dsp
2
!IF "$(CFG)" == ""
3
CFG=heapsnapshots - Win32 Debug
4
!MESSAGE No configuration specified. Defaulting to heapsnapshots - Win32 Debug.
5
!ENDIF 
6
7
!IF "$(CFG)" != "heapsnapshots - Win32 Release" && "$(CFG)" != "heapsnapshots - Win32 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "heapsnapshots.mak" CFG="heapsnapshots - Win32 Debug"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "heapsnapshots - Win32 Release" (based on "Win32 (x86) Static Library")
17
!MESSAGE "heapsnapshots - Win32 Debug" (based on "Win32 (x86) Static Library")
18
!MESSAGE 
19
!ERROR An invalid configuration is specified.
20
!ENDIF 
21
22
!IF "$(OS)" == "Windows_NT"
23
NULL=
24
!ELSE 
25
NULL=nul
26
!ENDIF 
27
28
!IF  "$(CFG)" == "heapsnapshots - Win32 Release"
29
30
OUTDIR=.\bin
31
INTDIR=.\Release
32
# Begin Custom Macros
33
OutDir=.\bin
34
# End Custom Macros
35
36
ALL : "$(OUTDIR)\heapsnapshots.lib"
37
38
39
CLEAN :
40
	-@erase "$(INTDIR)\AbstractHeapSnapshotManager.obj"
41
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager.obj"
42
	-@erase "$(INTDIR)\vc60.idb"
43
	-@erase "$(OUTDIR)\heapsnapshots.lib"
44
45
"$(OUTDIR)" :
46
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
47
48
"$(INTDIR)" :
49
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
50
51
CPP=cl.exe
52
CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"$(INTDIR)\heapsnapshots.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
53
54
.c{$(INTDIR)}.obj::
55
   $(CPP) @<<
56
   $(CPP_PROJ) $< 
57
<<
58
59
.cpp{$(INTDIR)}.obj::
60
   $(CPP) @<<
61
   $(CPP_PROJ) $< 
62
<<
63
64
.cxx{$(INTDIR)}.obj::
65
   $(CPP) @<<
66
   $(CPP_PROJ) $< 
67
<<
68
69
.c{$(INTDIR)}.sbr::
70
   $(CPP) @<<
71
   $(CPP_PROJ) $< 
72
<<
73
74
.cpp{$(INTDIR)}.sbr::
75
   $(CPP) @<<
76
   $(CPP_PROJ) $< 
77
<<
78
79
.cxx{$(INTDIR)}.sbr::
80
   $(CPP) @<<
81
   $(CPP_PROJ) $< 
82
<<
83
84
RSC=rc.exe
85
BSC32=bscmake.exe
86
BSC32_FLAGS=/nologo /o"$(OUTDIR)\heapsnapshots.bsc" 
87
BSC32_SBRS= \
88
	
89
LIB32=link.exe -lib
90
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\heapsnapshots.lib" 
91
LIB32_OBJS= \
92
	"$(INTDIR)\AbstractHeapSnapshotManager.obj" \
93
	"$(INTDIR)\StatelessHeapSnapshotManager.obj"
94
95
"$(OUTDIR)\heapsnapshots.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
96
    $(LIB32) @<<
97
  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
98
<<
99
100
!ELSEIF  "$(CFG)" == "heapsnapshots - Win32 Debug"
101
102
OUTDIR=.\bin
103
INTDIR=.\Debug
104
# Begin Custom Macros
105
OutDir=.\bin
106
# End Custom Macros
107
108
ALL : "$(OUTDIR)\heapsnapshots.lib"
109
110
111
CLEAN :
112
	-@erase "$(INTDIR)\AbstractHeapSnapshotManager.obj"
113
	-@erase "$(INTDIR)\StatelessHeapSnapshotManager.obj"
114
	-@erase "$(INTDIR)\vc60.idb"
115
	-@erase "$(INTDIR)\vc60.pdb"
116
	-@erase "$(OUTDIR)\heapsnapshots.lib"
117
118
"$(OUTDIR)" :
119
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
120
121
"$(INTDIR)" :
122
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
123
124
CPP=cl.exe
125
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Fp"$(INTDIR)\heapsnapshots.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
126
127
.c{$(INTDIR)}.obj::
128
   $(CPP) @<<
129
   $(CPP_PROJ) $< 
130
<<
131
132
.cpp{$(INTDIR)}.obj::
133
   $(CPP) @<<
134
   $(CPP_PROJ) $< 
135
<<
136
137
.cxx{$(INTDIR)}.obj::
138
   $(CPP) @<<
139
   $(CPP_PROJ) $< 
140
<<
141
142
.c{$(INTDIR)}.sbr::
143
   $(CPP) @<<
144
   $(CPP_PROJ) $< 
145
<<
146
147
.cpp{$(INTDIR)}.sbr::
148
   $(CPP) @<<
149
   $(CPP_PROJ) $< 
150
<<
151
152
.cxx{$(INTDIR)}.sbr::
153
   $(CPP) @<<
154
   $(CPP_PROJ) $< 
155
<<
156
157
RSC=rc.exe
158
BSC32=bscmake.exe
159
BSC32_FLAGS=/nologo /o"$(OUTDIR)\heapsnapshots.bsc" 
160
BSC32_SBRS= \
161
	
162
LIB32=link.exe -lib
163
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\heapsnapshots.lib" 
164
LIB32_OBJS= \
165
	"$(INTDIR)\AbstractHeapSnapshotManager.obj" \
166
	"$(INTDIR)\StatelessHeapSnapshotManager.obj"
167
168
"$(OUTDIR)\heapsnapshots.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
169
    $(LIB32) @<<
170
  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
171
<<
172
173
!ENDIF 
174
175
176
!IF "$(NO_EXTERNAL_DEPS)" != "1"
177
!IF EXISTS("heapsnapshots.dep")
178
!INCLUDE "heapsnapshots.dep"
179
!ELSE 
180
!MESSAGE Warning: cannot find "heapsnapshots.dep"
181
!ENDIF 
182
!ENDIF 
183
184
185
!IF "$(CFG)" == "heapsnapshots - Win32 Release" || "$(CFG)" == "heapsnapshots - Win32 Debug"
186
SOURCE=..\heapsnapshots\AbstractHeapSnapshotManager.cpp
187
188
"$(INTDIR)\AbstractHeapSnapshotManager.obj" : $(SOURCE) "$(INTDIR)"
189
	$(CPP) $(CPP_PROJ) $(SOURCE)
190
191
192
SOURCE=..\heapsnapshots\StatelessHeapSnapshotManager.cpp
193
194
"$(INTDIR)\StatelessHeapSnapshotManager.obj" : $(SOURCE) "$(INTDIR)"
195
	$(CPP) $(CPP_PROJ) $(SOURCE)
196
197
198
199
!ENDIF 
200
(-)src-native-new/src/agents/RABindings/RABindings.def (+31 lines)
Added Link Here
1
LIBRARY hcbnd
2
DESCRIPTION "Services provided to all Agents"
3
EXPORTS
4
	ra_initializeBindings		@1
5
	ra_finalizeBindings			@2
6
	ra_startListener			@3
7
	ra_stopListener				@4
8
	ra_sendMessage				@5
9
	ra_getProcessId				@6
10
	ra_getNodeUUID				@7
11
	ra_getProcessUUID			@8
12
	ra_getAgentUUID				@9
13
	ra_getDefaultConfiguration	@10
14
	ra_getProcessCommandLine	@11	
15
	ra_logErrorMessage			@12
16
	ra_requestPeerMonitor		@13
17
	ra_requestPeerMonitor2		@14
18
	ra_initializeLock			@15
19
	ra_deleteLock				@16
20
	ra_getWriteLock				@17
21
	ra_releaseWriteLock			@18
22
	ra_getReadLock				@19
23
	ra_releaseReadLock			@20
24
	ra_initializeVMLock			@21
25
	ra_setVMLock				@22
26
	ra_releaseVMLock			@23
27
	ra_testVMLock				@24
28
	ra_getPropertyValues		@25
29
	ra_logErrorMessage_return	@26
30
	ra_requestPeerMonitor_p		@27
31
	ra_requestPeerMonitor2_p	@28
(-)src-native-new/src/agents/java/hcjbnd.exp (+22 lines)
Added Link Here
1
#! libhcjbnd.so exports
2
logAgent_getCurrentProcessId
3
logAgent_getCurrentThreadId
4
logAgent_registerAgent
5
logAgent_deregisterAgent
6
logAgent_logMessage
7
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_deregister0
8
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_initializeEngine0
9
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_logMessage0__Ljava_lang_String_2_3BII
10
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_logMessage0__Ljava_lang_String_2Ljava_lang_String_2
11
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_logMessageUTF80
12
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_logMessageUTF81
13
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_sendMessage0__Ljava_lang_String_2J
14
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_sendMessage0___3BIIJ
15
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_sendMessageBinary0
16
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0___3BLjava_lang_String_2
17
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0___3BJLjava_lang_String_2
18
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_getPID0
19
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_generateUUID0
20
logAgent_logMessage_return
21
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0p___3BJLjava_lang_String_2
22
Java_org_eclipse_hyades_internal_execution_remote_RemoteComponentSkeleton_requestMonitorThroughPeer0p___3BJJLjava_lang_String_2
(-)src-native-new/src/transport/RADataTransfer/version.rc (+110 lines)
Added Link Here
1
#include "../../../include/tptp/version.h"
2
//Microsoft Developer Studio generated resource script.
3
//
4
#include "resource.h"
5
6
#define APSTUDIO_READONLY_SYMBOLS
7
/////////////////////////////////////////////////////////////////////////////
8
//
9
// Generated from the TEXTINCLUDE 2 resource.
10
//
11
#include "afxres.h"
12
13
/////////////////////////////////////////////////////////////////////////////
14
#undef APSTUDIO_READONLY_SYMBOLS
15
16
/////////////////////////////////////////////////////////////////////////////
17
// English (U.S.) resources
18
19
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20
#ifdef _WIN32
21
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
22
#pragma code_page(1252)
23
#endif //_WIN32
24
25
#ifndef _MAC
26
/////////////////////////////////////////////////////////////////////////////
27
//
28
// Version
29
//
30
31
VS_VERSION_INFO VERSIONINFO
32
 FILEVERSION _VERSION_WIN
33
 PRODUCTVERSION _VERSION_WIN
34
 FILEFLAGSMASK 0x3fL
35
#ifdef _DEBUG
36
 FILEFLAGS 0x1L
37
#else
38
 FILEFLAGS 0x0L
39
#endif
40
 FILEOS 0x40004L
41
 FILETYPE 0x2L
42
 FILESUBTYPE 0x0L
43
BEGIN
44
    BLOCK "StringFileInfo"
45
    BEGIN
46
        BLOCK "040904b0"
47
        BEGIN
48
            VALUE "Comments", "\0"
49
            VALUE "CompanyName", _COMPANY_NAME
50
            VALUE "FileDescription", "Agent Controller Data Transfer Library\0"
51
            VALUE "FileVersion", _VERSION
52
            VALUE "InternalName", "hccldt\0"
53
            VALUE "LegalCopyright", _COPYRIGHT
54
            VALUE "LegalTrademarks", "\0"
55
            VALUE "OriginalFilename", "hccldt.dll\0"
56
            VALUE "PrivateBuild", "\0"
57
            VALUE "ProductName", "\0"
58
            VALUE "ProductVersion", _VERSION
59
            VALUE "SpecialBuild", "\0"
60
        END
61
    END
62
    BLOCK "VarFileInfo"
63
    BEGIN
64
        VALUE "Translation", 0x409, 1200
65
    END
66
END
67
68
#endif    // !_MAC
69
70
71
#ifdef APSTUDIO_INVOKED
72
/////////////////////////////////////////////////////////////////////////////
73
//
74
// TEXTINCLUDE
75
//
76
77
1 TEXTINCLUDE DISCARDABLE 
78
BEGIN
79
    "resource.h\0"
80
END
81
82
2 TEXTINCLUDE DISCARDABLE 
83
BEGIN
84
    "#include ""afxres.h""\r\n"
85
    "\0"
86
END
87
88
3 TEXTINCLUDE DISCARDABLE 
89
BEGIN
90
    "\r\n"
91
    "\0"
92
END
93
94
#endif    // APSTUDIO_INVOKED
95
96
#endif    // English (U.S.) resources
97
/////////////////////////////////////////////////////////////////////////////
98
99
100
101
#ifndef APSTUDIO_INVOKED
102
/////////////////////////////////////////////////////////////////////////////
103
//
104
// Generated from the TEXTINCLUDE 3 resource.
105
//
106
107
108
/////////////////////////////////////////////////////////////////////////////
109
#endif    // not APSTUDIO_INVOKED
110
(-)src-native-new/src/agents/perfmon/PerfmonAgent/PerfmonAgent.h (+34 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: PerfmonAgent.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
14
#ifndef __PERFMON__H__
15
#define __PERFMON__H__
16
17
#ifdef LINUX
18
#define DEFAULT_COM "librac.so"
19
#define DEFAULT_RES "libperflin.so"
20
#endif
21
22
#ifdef WIN32
23
	#define DEFAULT_COM "rac.dll"
24
	#define DEFAULT_RES "sysperf.dll"
25
#endif
26
27
28
#include "cominterface.h"
29
#include "resinterface.h"
30
#include "DataTransferInterface.h"
31
#include "DataCollectionInterface.h"
32
33
#endif
34
(-)src-native-new/src/HCLauncher/hclaunch.make (+129 lines)
Added Link Here
1
2
################################################################################
3
#                                       
4
#  makefile:  hclaunch project  
5
#                                       
6
# $Id
7
################################################################################
8
9
10
#-----------------------------------
11
#
12
#   Customizable section
13
#
14
#   - The TARGETREALNAME variable specifies the name of the library file
15
#     that will be generated, this includes a base (TARGETLIB) plus	a 
16
#     version number plus a minor number plus a release number
17
#   - The TARGETSONAME variable specifies a file name that has just the
18
#     library name plus the major version number
19
#   - The TARGETLIB variable specifies the base library name
20
#   - The TARGETSONAME and TARGETLIB are generated as symbolic links
21
#     when the library is built
22
#
23
#-----------------------------------
24
TARGET         :=  libhclaunch
25
TARGETDIR      :=  ../../lib
26
27
if [ x$VERSIONNUM = x ]; then export VERSIONNUM=0; fi
28
if [ x$MINORNUM = x ]; then export MINORNUM=0; fi
29
if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi
30
31
TARGETLIB      :=  $(TARGET).so
32
TARGETSONAME   :=  $(TARGETLIB).$(VERSIONNUM)
33
TARGETREALNAME :=  $(TARGETSONAME).$(MINORNUM).$(RELEASENUM)
34
35
36
#-----------------------------------
37
#   list of additional INCLUDE directories to search headers from
38
#      (separated by blanks)
39
#-----------------------------------
40
INCLUDEDIRS    :=  .  ../../include ../transport/RACommon $(JAVA_HOME)/include $(JAVA_HOME)/include/linux
41
42
43
#-----------------------------------
44
#   list of additional libraries to be linked with
45
#      (separated by blanks)
46
#-----------------------------------
47
LIBS       :=  dl pthread hcclco
48
49
#-----------------------------------
50
#   list of additional library directories to search from
51
#      (separated by blanks)
52
#-----------------------------------
53
LIBDIRS    :=  ../../lib
54
55
56
#-----------------------------------
57
#
58
#   Compiler options
59
#
60
#      -g       produce debug info
61
#      -Wall    enable all types of warnings
62
#      -O3      highest level of code optimization
63
#      -fPIC    generate position-independent code (PIC).
64
#               This is required for building shared library.
65
#      -c       compile only
66
#
67
#   Linking options
68
#
69
#       -Wl       pass options to linker
70
#       -shared   produce shared library
71
#       -L        add the given directory to the search path for libraries
72
#
73
#-----------------------------------
74
75
DEFINES    := -DSQLUNIX -DSQLLinux -DENW -DREENTRANT -D_REENTRANT -DCONFIG_X86_CMPXCHG
76
77
CFLAGS     :=  $(C_FLAGS) $(DEBUGABLE) -Wall $(OPTIMIZABLE) -fPIC $(addprefix -I,$(INCLUDEDIRS))  -D_LINUX_X86  $(DEFINES)
78
79
CXXFLAGS   :=  $(CFLAGS)
80
81
LINKOPTS   :=  $(L_FLAGS) $(DEBUGABLE) -shared -Wl,-soname,$(TARGETSONAME) -o $(TARGETDIR)/$(TARGETREALNAME) $(addprefix -L,$(LIBDIRS))
82
83
84
#-----------------------------------
85
#   general commands and options
86
#-----------------------------------
87
88
CC          :=  gcc
89
CXX         :=  $(CC)
90
91
SOURCE     :=  $(wildcard *.c)  $(wildcard *.cpp)
92
93
OBJS       :=  $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
94
95
REMOVEFILE :=  rm -f
96
CREATELINK :=  ln -sf
97
98
99
#-----------------------------------
100
#   "make" rules
101
#-----------------------------------
102
103
.PHONY : default everything objs clean veryclean rebuild $(TARGET)
104
105
106
default : $(TARGET)
107
108
109
objs : $(OBJS)
110
111
112
clean :
113
	$(REMOVEFILE) *.o
114
115
116
veryclean: clean
117
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETLIB)
118
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETSONAME)
119
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETREALNAME)
120
121
122
rebuild: veryclean everything
123
124
125
$(TARGET) : $(OBJS)
126
	$(CC) $(LINKOPTS) $(OBJS) $(addprefix -l,$(LIBS))
127
	$(CREATELINK) $(TARGETREALNAME)  $(TARGETDIR)/$(TARGETSONAME)
128
	$(CREATELINK) $(TARGETSONAME)    $(TARGETDIR)/$(TARGETLIB)
129
(-)src-native-new/src/HCLauncher/launcher_os400.h (+28 lines)
Added Link Here
1
/**********************************************************************
2
Copyright (c) 2005 IBM Corporation and others.
3
All rights reserved.   This program and the accompanying materials
4
are made available under the terms of the Eclipse Public License v1.0
5
which accompanies this distribution, and is available at
6
http://www.eclipse.org/legal/epl-v10.html
7
$Id: launcher_os400.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 
9
Contributors:
10
    IBM Corporation - initial implementation
11
**********************************************************************/
12
13
14
/*
15
 * Function prototypes
16
 */
17
#ifdef __OS400__
18
19
#define AS400_CLASSPATH_LENGTH 8192
20
#define MAX_FD 256
21
#include <spawn.h>
22
23
PID hc_launchProcess_OS400(char *exe, char *cmdline, char *location, char *env, RA_HANDLE consoleChild[]);
24
void hc_initProcessStdioList();
25
void hc_addToProcessStdioList(PID pid, int in, int out, int err);
26
void hc_removeFromProcessStdioList(PID pid);
27
28
#endif
(-)src-native-new/src/agents/java/version.rc (+110 lines)
Added Link Here
1
#include "../../../include/tptp/version.h"
2
//Microsoft Developer Studio generated resource script.
3
//
4
#include "resource.h"
5
6
#define APSTUDIO_READONLY_SYMBOLS
7
/////////////////////////////////////////////////////////////////////////////
8
//
9
// Generated from the TEXTINCLUDE 2 resource.
10
//
11
#include "afxres.h"
12
13
/////////////////////////////////////////////////////////////////////////////
14
#undef APSTUDIO_READONLY_SYMBOLS
15
16
/////////////////////////////////////////////////////////////////////////////
17
// English (U.S.) resources
18
19
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20
#ifdef _WIN32
21
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
22
#pragma code_page(1252)
23
#endif //_WIN32
24
25
#ifndef _MAC
26
/////////////////////////////////////////////////////////////////////////////
27
//
28
// Version
29
//
30
31
VS_VERSION_INFO VERSIONINFO
32
 FILEVERSION _VERSION_WIN
33
 PRODUCTVERSION _VERSION_WIN
34
 FILEFLAGSMASK 0x3fL
35
#ifdef _DEBUG
36
 FILEFLAGS 0x1L
37
#else
38
 FILEFLAGS 0x0L
39
#endif
40
 FILEOS 0x40004L
41
 FILETYPE 0x2L
42
 FILESUBTYPE 0x0L
43
BEGIN
44
    BLOCK "StringFileInfo"
45
    BEGIN
46
        BLOCK "040904b0"
47
        BEGIN
48
            VALUE "Comments", "\0"
49
            VALUE "CompanyName", _COMPANY_NAME
50
            VALUE "FileDescription", "Logging Agent\0"
51
            VALUE "FileVersion", _VERSION
52
            VALUE "InternalName", "hcjbnd\0"
53
            VALUE "LegalCopyright", _COPYRIGHT
54
            VALUE "LegalTrademarks", "\0"
55
            VALUE "OriginalFilename", "hcjbnd.dll\0"
56
            VALUE "PrivateBuild", "\0"
57
            VALUE "ProductName", "\0"
58
            VALUE "ProductVersion", _VERSION
59
            VALUE "SpecialBuild", "\0"
60
        END
61
    END
62
    BLOCK "VarFileInfo"
63
    BEGIN
64
        VALUE "Translation", 0x409, 1200
65
    END
66
END
67
68
#endif    // !_MAC
69
70
71
#ifdef APSTUDIO_INVOKED
72
/////////////////////////////////////////////////////////////////////////////
73
//
74
// TEXTINCLUDE
75
//
76
77
1 TEXTINCLUDE DISCARDABLE 
78
BEGIN
79
    "resource.h\0"
80
END
81
82
2 TEXTINCLUDE DISCARDABLE 
83
BEGIN
84
    "#include ""afxres.h""\r\n"
85
    "\0"
86
END
87
88
3 TEXTINCLUDE DISCARDABLE 
89
BEGIN
90
    "\r\n"
91
    "\0"
92
END
93
94
#endif    // APSTUDIO_INVOKED
95
96
#endif    // English (U.S.) resources
97
/////////////////////////////////////////////////////////////////////////////
98
99
100
101
#ifndef APSTUDIO_INVOKED
102
/////////////////////////////////////////////////////////////////////////////
103
//
104
// Generated from the TEXTINCLUDE 3 resource.
105
//
106
107
108
/////////////////////////////////////////////////////////////////////////////
109
#endif    // not APSTUDIO_INVOKED
110
(-)src-native-new/src/HCLauncher/launcher_os400.c (+456 lines)
Added Link Here
1
/**********************************************************************
2
Copyright (c) 2005 IBM Corporation and others.
3
All rights reserved.   This program and the accompanying materials
4
are made available under the terms of the Eclipse Public License v1.0
5
which accompanies this distribution, and is available at
6
http://www.eclipse.org/legal/epl-v10.html
7
$Id: launcher_os400.c,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 
9
Contributors:
10
    IBM Corporation - initial implementation
11
**********************************************************************/
12
13
#ifdef __OS400__ /* 236501 */
14
15
#include "launcher_common.h"
16
#include "RAComm.h"
17
18
char* processAS400Arg2(char** parsedArgs, int numArgs);
19
char* processAS400Arg3(char** environment, int numEnv);
20
char* processAS400Arg4(char** parsedArgs, int* pNumArgs, int* intrepret, char** p_opt, char** p_chk);
21
22
23
/*
24
 * Launch a process
25
 */
26
PID hc_launchProcess_OS400(char *exe, char *cmdline, char *location, char *env, RA_HANDLE consoleChild[]) {
27
	PID childPID = 0;
28
	struct inheritance inherit;
29
	char *as400Args[9];
30
	int numAS400Args; /* Total number of AS/400 argumens, including JVM properties */
31
	int numAS400Env;  /* Total number of environment variables */
32
33
	char *parsedArgs[MAX_ARGS];
34
	char *environment[MAX_ENV+1];
35
	int fd_map[3];
36
	int *fdmap;
37
	int fdcount = 3;
38
	char *current, *next;
39
	int i, count;
40
41
	if((cmdline == NULL) || (env == NULL)) {
42
		return -1;
43
	}
44
45
	current=cmdline;
46
47
	/* 178427 begin */
48
	/* Move past any leading blanks */
49
	while (*current == ' ') {
50
		current++;
51
	}
52
53
	/* Parse out the args */
54
	for(i=0; (next=(char*)strchr(current, ' '))!=NULL; i++) {
55
		/* If this is a quoted arg we need to remove the quote and skip to the next quote */
56
		if(current[0]=='\"') {
57
			current++;
58
			next=(char*)strchr(current, '\"');
59
			if(next) {
60
				*next='\0';
61
			}
62
		}
63
		else {
64
			*next='\0';
65
		}
66
67
		parsedArgs[i]=current;
68
69
		/* move past blanks */
70
		do {
71
			next++;
72
		} while (*next == ' ');
73
		current=next;
74
	}
75
76
	/* check if there is another argument */
77
	if (strlen(current) > 0) {  /* 178427 - handles case of blank at end of cmd line */
78
79
		/* If this is a quoted arg we need to remove the quote and skip to the next quote */
80
		if(current[0]=='\"') {
81
			current++;
82
			next=(char*)strchr(current, '\"');
83
			if(next) {
84
				*next='\0';
85
			}
86
		}
87
88
		parsedArgs[i]=current;
89
		parsedArgs[i+1]='\0';
90
	}
91
	/* Else end the list of arguments */
92
	else {
93
		parsedArgs[i]='\0';
94
	}
95
96
	numAS400Args = i+1; /* Total number of JVM arguments, including trailing NULL (-D or -X) */
97
98
	/* 178427 end */
99
	/* Load the environment array */
100
	i=count=0;
101
	do{
102
			environment[count]=&env[i];
103
			i+=strlen(&env[i])+1;
104
			count++;
105
	} while(env[i]!='\0' && count<MAX_ENV);
106
107
	if(count==MAX_ENV) {
108
		exit(-1);
109
	}
110
	else {
111
		environment[count]='\0';
112
	}
113
114
	numAS400Env = count; /* Total number of environment variables */
115
116
	/* Set up file descriptor map for child process */
117
	if (consoleChild) {
118
		if ((fd_map[0]=dup(consoleChild[0])) < 0) {  /* child stdin is read end of pipe */
119
            //hc_logServiceMessage(__FILE__, __LINE__, RA_SEVERE, "Creating stdin for process failed.  Platform specific error is %d", errno);
120
		}
121
		if ((fd_map[1]=dup(consoleChild[1])) < 0) {  /* child stdout is write end of pipe */
122
	   		//hc_logServiceMessage(__FILE__, __LINE__, RA_SEVERE, "Creating stdout for process failed.  Platform specific error is %d", errno);
123
		}
124
		if ((fd_map[2]=dup(consoleChild[2])) < 0) {  /* child stderr is write end of pipe */
125
         	//hc_logServiceMessage(__FILE__, __LINE__, RA_SEVERE, "Creating stderr for process failed.  Platform specific error is %d", errno);
126
		}
127
		fdmap = fd_map;
128
	}
129
	else {
130
		fdcount = 0;
131
		fdmap = NULL;
132
	}
133
134
#if 0 /* Bug 68899 */
135
	/* Change directory to the one specified in the config file */
136
	if(chdir(location)) {
137
		childPID = 0;
138
		return childPID;
139
	}
140
#endif
141
142
	if(strstr(parsedArgs[0], "Q5BVAJVM") != 0) { /* 239022 */
143
		int intrepret = FALSE;
144
		char* opt = NULL;
145
		char* chk = NULL;
146
147
		/*                         */
148
		/* Processing iSeries args */
149
		/*                         */
150
		as400Args[4] = processAS400Arg4(parsedArgs, &numAS400Args, &intrepret, &opt, &chk); /* Step 4 goes first to remove all -D and -X parameters */
151
		as400Args[0] = parsedArgs[0];
152
		as400Args[1] = parsedArgs[1]; /* class name */
153
		as400Args[2] = processAS400Arg2(parsedArgs, numAS400Args);
154
		as400Args[3] = processAS400Arg3(environment, numAS400Env);
155
		as400Args[5] = opt; /* Optimization */
156
		as400Args[6] = chk; /* Path check level */
157
		if(intrepret)
158
			as400Args[7] = "*YES"; /* Interpret */
159
		else
160
			as400Args[7] = "*NO"; /* Interpret */
161
		as400Args[8] = "\0";
162
163
		environment[numAS400Env++] = "QIBM_USE_DESCRIPTOR_STDIO=Y";
164
		environment[numAS400Env++] = '\0';
165
		inherit.flags = SPAWN_SETTHREAD_NP; /* 232010 */
166
167
		/* Launch the java process */
168
		childPID = spawnp(as400Args[0], fdcount, fdmap, &inherit, as400Args, environment);
169
170
		free(as400Args[2]); /* program param */
171
		free(as400Args[3]); /* classpath */
172
		free(as400Args[4]); /* jvm prop */
173
	}
174
	else {
175
		environment[numAS400Env++] = "QIBM_USE_DESCRIPTOR_STDIO=Y";
176
		environment[numAS400Env++] = '\0';
177
		inherit.flags = SPAWN_SETTHREAD_NP;
178
179
		/* Launch the process */
180
		childPID = spawnp(parsedArgs[0], fdcount, fdmap, &inherit, parsedArgs, environment);
181
	}
182
183
	if(childPID < 0) {
184
		childPID = -1;
185
	}
186
187
	return childPID;
188
}
189
190
191
/*                        */
192
/* Processing arg 2       */
193
/* Command line arguments */
194
/*                        */
195
char* processAS400Arg2(char** parsedArgs, int numArgs) {
196
	char* as400arg2;
197
	int propLen = 0; /* Length of the string storing the command line args in AS/400 format */
198
	int i;
199
	char len[3];
200
	int numParam = 0; /* 238048 Number of ACTUAL (non-null) command line arg passed to program */
201
202
	if(numArgs > 2) {
203
		/* Calculate the length of the array required */
204
		for(i = 2; (i < numArgs) && (parsedArgs[i] != NULL); i++) { /* 238048 */
205
			propLen += 3; /* the 3 digits "xxx" showing the length of the arg name */
206
			propLen += strlen(parsedArgs[i]); /* the length of the arg */
207
			numParam++; /* 238048 we got one more arg */
208
		}
209
		propLen += 3; /* The 3 digit "nnn" show the number of JVM args */
210
211
		as400arg2 = (char*)malloc(sizeof(char) * propLen);
212
		BZERO(as400arg2, propLen);
213
		sprintf(as400arg2, "%03d", numParam); /* 238048 Total number of args */
214
		for(i = 2; (i < numArgs) && (parsedArgs[i] != NULL); i++) { /* 238048 */
215
			sprintf(len, "%03d", strlen(parsedArgs[i]));
216
			strcat(as400arg2, len);
217
			strcat(as400arg2, parsedArgs[i]);
218
		}
219
		strcat(as400arg2, "\0"); /* add a null to the end */
220
	}
221
	else { /* if(numAD400Args <= 2) */
222
		as400arg2 = "0";
223
	}
224
225
	return as400arg2;
226
}
227
228
229
/*                  */
230
/* Processing arg 3 */
231
/* CLASSPATH        */
232
/*                  */
233
char* processAS400Arg3(char** environment, int numEnv) {
234
	char* as400arg3;
235
	int cplength = 0; /* classpath length */
236
	int i, j;
237
238
	as400arg3 = (char*)malloc(sizeof(char) * AS400_CLASSPATH_LENGTH);
239
	BZERO(as400arg3, AS400_CLASSPATH_LENGTH);
240
241
	for(i = 0; i < numEnv; i++) {
242
		if(!strncmp(environment[i], "CLASSPATH=", 10)) {
243
			for(j = 10; j < strlen(environment[i]); j++) {
244
				as400arg3[cplength++] = environment[i][j];
245
			}
246
			as400arg3[cplength++] = ':';
247
		}
248
	}
249
	as400arg3[cplength-1] = '\0';
250
251
	return as400arg3;
252
}
253
254
255
/*                  */
256
/* Processing arg 4 */
257
/* JVM properties   */
258
/*                  */
259
char* processAS400Arg4(char** parsedArgs, int* pNumArgs, int* intrepret, char** p_opt, char** p_chk) {
260
	char* as400arg4;
261
	char* jvmPropBuf_X; /* 239249 */
262
	char* jvmPropBuf_D;
263
	int propLen = 0; /* Length of the string storing the JVM props in AS/400 format */
264
	int numProp = 0; /* Number of JVM properties processed */
265
	int i, j;
266
	BOOL endOfJvmArgs = FALSE;
267
268
	*p_opt = (char*)malloc(sizeof(char) * 3);
269
	*p_chk = (char*)malloc(sizeof(char) * 3);
270
	strcpy(*p_opt, "10"); /* default optimize level */
271
	strcpy(*p_chk, "10"); /* default path check level */
272
273
	propLen = 3; /* The 3 digit "nnn" show the number of JVM args */
274
	propLen += 26; /* 217412 workaround, stdin prop "019os400.stdin.allowed0011" */
275
	propLen += 21; /* Bug 68899 "012java.version0031.4" */
276
277
	/* Calculate the length of the array required */
278
	for(i = 0; (i < (*pNumArgs)) && (parsedArgs[i] != NULL); i++) { /* 238048 */
279
		propLen += 3; /* the 3 digits "xxx" showing the length of the property name */
280
		propLen += strlen(parsedArgs[i]); /* the length of the property */
281
		propLen += 3; /* the 3 digits "yyy" showing the length of the property value */
282
	}
283
284
	as400arg4 = (char*)malloc(sizeof(char) * propLen); /* Allocate  */
285
	BZERO(as400arg4, propLen);
286
287
	jvmPropBuf_X = (char*)malloc(sizeof(char) * (propLen - 3)); /* Not counting "nnn" */
288
	BZERO(jvmPropBuf_X, (propLen - 3));
289
290
	jvmPropBuf_D = (char*)malloc(sizeof(char) * (propLen - 3)); /* Not counting "nnn" */
291
	BZERO(jvmPropBuf_D, (propLen - 3));
292
293
	/* Rearrange the JVM arguments in AS/400 format */
294
	for(i = 1; (i < (*pNumArgs)) && (parsedArgs[i] != NULL); i++) { /* do not parse the 1st one since it is the program name */
295
		if(((!strncmp(parsedArgs[i], "-D", 2)) ||
296
			(!strncmp(parsedArgs[i], "-X", 2)) ||
297
			(!strncmp(parsedArgs[i], "-opt", 4)) ||
298
			(!strncmp(parsedArgs[i], "-chkpath", 8)) ||
299
			(!strncmp(parsedArgs[i], "-interpret", 10))) && (!endOfJvmArgs)) {
300
			if(!strncmp(parsedArgs[i], "-D", 2)) {
301
				const char delimiters[] = "=";
302
				char *value1, *value2;
303
				char *tmpbuf = (char*)malloc(sizeof(char) * (strlen(parsedArgs[i]) + 6)); /* adding "xxx" and "yyy" */
304
				BZERO(tmpbuf, (strlen(parsedArgs[i]) + 6));
305
306
				value1 = strtok(parsedArgs[i], delimiters);
307
				value1 += 2; /* skipping the "-D" */
308
				value2 = strtok(NULL, delimiters);
309
				if(value2 == NULL) {
310
					sprintf(tmpbuf, "%03d-D%s=000", strlen(value1)+3, value1); /* 237157 */ /* 239249 */
311
				}
312
				else {
313
					sprintf(tmpbuf, "%03d%s%03d%s", strlen(value1), value1, strlen(value2), value2);
314
				}
315
				//hc_logServiceMessage(__FILE__, __LINE__, RA_DEBUG, "iSeries JVM property \"%s\" encountered, convert it to \"%s\"", parsedArgs[i], tmpbuf);
316
				strcat(jvmPropBuf_D, tmpbuf);
317
				numProp++;
318
				free(tmpbuf);
319
			}
320
			else if(!strncmp(parsedArgs[i], "-X", 2)) {
321
				char *tmpbuf = (char*)malloc(sizeof(char) * (strlen(parsedArgs[i]) + 6)); /* adding "xxx" and "yyy" */
322
				BZERO(tmpbuf, (strlen(parsedArgs[i]) + 6));
323
324
				sprintf(tmpbuf, "%03d%s000", strlen(parsedArgs[i]), parsedArgs[i]); /* Do not skip -X */
325
				//hc_logServiceMessage(__FILE__, __LINE__, RA_DEBUG, "iSeries JVM property \"%s\" encountered, convert it to \"%s\"", parsedArgs[i], tmpbuf);
326
				strcat(jvmPropBuf_X, tmpbuf);
327
				numProp++;
328
				free(tmpbuf);
329
			}
330
			else if(!strncmp(parsedArgs[i], "-opt", 4)) {
331
				free(*p_opt);
332
				*p_opt = (char*)malloc(sizeof(char) * 3);
333
				BZERO(*p_opt, 3);
334
				strncpy(*p_opt, parsedArgs[i]+4, 2); /* skipping "-opt" */
335
			}
336
			else if(!strncmp(parsedArgs[i], "-chkpath", 8)) {
337
				free(*p_chk);
338
				*p_chk = (char*)malloc(sizeof(char) * 3);
339
				BZERO(*p_chk, 3);
340
				strncpy(*p_chk, parsedArgs[i]+8, 2); /* skipping "-chkpath" */
341
			}
342
			else if(!strncmp(parsedArgs[i], "-interpret", 10)) {
343
				*intrepret = TRUE;
344
			}
345
346
			/* free(parsedArgs[i]); */  /* JVM arg processes, remove it from the list */
347
			for(j = i; j < (*pNumArgs);  j++) {
348
					parsedArgs[j] = parsedArgs[j+1]; /* Move the string upward by 1 */
349
			}
350
			(*pNumArgs)--; /* Remove 1 from the total number of arguments */
351
			i--; /* Move the counter back since we've removed the args */
352
		}
353
		else if((!strncmp(parsedArgs[i], "-", 1)) && (!endOfJvmArgs)) { /* for "-verbose", "-noverify", etc. support */
354
				char *tmpbuf = (char*)malloc(sizeof(char) * (strlen(parsedArgs[i]) + 6)); /* adding "xxx" and "yyy" */
355
				BZERO(tmpbuf, (strlen(parsedArgs[i]) + 6));
356
357
				sprintf(tmpbuf, "%03d%s000", strlen(parsedArgs[i]), parsedArgs[i]);
358
				strcat(jvmPropBuf_X, tmpbuf);
359
				numProp++;
360
				free(tmpbuf);
361
362
				for(j = i; j < (*pNumArgs);  j++) {
363
						parsedArgs[j] = parsedArgs[j+1]; /* Move the string upward by 1 */
364
				}
365
				(*pNumArgs)--; /* Remove 1 from the total number of arguments */
366
				i--; /* Move the counter back since we've removed the args */
367
		}
368
		else {
369
			endOfJvmArgs = TRUE;
370
		}
371
	}
372
373
	/* Workaround for defect 217412 "stdin problem on iSeries" */
374
	numProp++; /* 239022 */
375
	strcat(jvmPropBuf_D, "019os400.stdin.allowed0011"); /* 26 chars */
376
	/* Workaround ends */
377
378
	/* Bug 68899 */
379
	numProp++;
380
	strcat(jvmPropBuf_D, "012java.version0031.4"); /* 21 chars */
381
	/* Bug 68899 */
382
383
	if(numProp == 0) {
384
		as400arg4 = "0"; /* If no JVM arg then set to zero */
385
	}
386
	else {
387
		sprintf(as400arg4, "%03d", numProp); /* Print the number of JVM args */
388
		strcat(as400arg4, jvmPropBuf_X); /* Append the actual AS/400 formatted JVM args */
389
		strcat(as400arg4, jvmPropBuf_D); /* Append the actual AS/400 formatted JVM args */
390
	}
391
	free(jvmPropBuf_X);
392
	free(jvmPropBuf_D);
393
394
	return as400arg4;
395
}
396
397
#if 0 /* Code to clean up file descriptors */
398
/* 239720 */
399
void hc_initProcessStdioList() {
400
	int i;
401
	for(i = 0; i < MAX_FD; i++) {
402
		processStdioList[i].pid = -1;
403
		processStdioList[i].in = -1;
404
		processStdioList[i].out = -1;
405
		processStdioList[i].err = -1;
406
	}
407
}
408
409
void hc_addToProcessStdioList(PID pid, int in, int out, int err) {
410
	int i = 0;
411
	BOOL done = FALSE;
412
413
	while((i < MAX_FD) && (!done)) {
414
		if(processStdioList[i].pid == -1) { /* found an empty spot */
415
			processStdioList[i].pid = pid;
416
			processStdioList[i].in = in;
417
			processStdioList[i].out = out;
418
			processStdioList[i].err = err;
419
			done = TRUE;
420
		}
421
		i++;
422
	}
423
	if(!done) {
424
	}
425
426
	return;
427
}
428
429
void hc_removeFromProcessStdioList(PID pid) {
430
	int i = 0;
431
	BOOL done = FALSE;
432
433
	while((i < MAX_FD) && (!done)) {
434
		if(processStdioList[i].pid == pid) { /* found the pid */
435
			close(processStdioList[i].in);
436
			close(processStdioList[i].out);
437
			close(processStdioList[i].err);
438
			processStdioList[i].pid = -1;
439
			processStdioList[i].in = -1;
440
			processStdioList[i].out = -1;
441
			processStdioList[i].err = -1;
442
			done = TRUE;
443
		}
444
		i++;
445
	}
446
	if(!done) {
447
	}
448
	else {
449
	}
450
451
	return;
452
}
453
/* 239720 */
454
#endif
455
456
#endif
(-)src-native-new/src/agents/perfmon/resutils/DataCollectionInterface.h (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: DataCollectionInterface.h,v 1.3 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
14
#ifndef __DATACOLLECTION_H__
15
#define __DATACOLLECTION_H__
16
17
#include "system.h"
18
#include "hashtable.h"
19
20
static char* DC_KEY_WAITTIME = "DC_WAITTIME";
21
static char* REGET_CHILDREN = "REGET_CHILDREN";
22
23
#ifdef __cplusplus
24
extern "C" {
25
#endif
26
27
#if defined(LINUX) || defined(SOLARIS)
28
char* DC_CollectionGetAgentName();
29
char** DC_CollectionGetTree	(int* numresults);
30
char** DC_CollectionGetResults (int* numresults);
31
int DC_CollectionStartup(HashTable* hasht_variables, HashTable* hasht_filters, HashTable* hasht_tree);
32
int DC_CollectionShutdown();
33
#else
34
__declspec(dllexport) char* DC_CollectionGetAgentName();
35
__declspec(dllexport) char** DC_CollectionGetTree	(int* numresults);
36
__declspec(dllexport) char** DC_CollectionGetResults (int* numresults);
37
__declspec(dllexport) int DC_CollectionStartup(HashTable* hasht_variables, HashTable* hasht_filters, HashTable* hasht_tree);
38
__declspec(dllexport) int DC_CollectionShutdown();
39
#endif
40
41
#ifdef __cplusplus
42
}
43
#endif
44
45
#endif
(-)src-native-new/src/agents/perfmon/PerfmonAgent/cominterface.h (+34 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: cominterface.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
//////////////////////////////////////////////////////////////
14
//	The function definitions for the communicationsDLL
15
//////////////////////////////////////////////////////////////
16
//
17
//	The four function defintions to be implemented by the custom
18
//	communications DLL.
19
//
20
//////////////////////////////////////////////////////////////
21
22
#ifndef __COM_INTERFACE__H__
23
#define __COM_INTERFACE__H__
24
25
#include "system.h"
26
#include "hashtable.h"
27
28
typedef int	(*LPCOMSTARTUP)(HashTable*, HashTable*, HashTable*);
29
typedef int	(*LPCOMSHUTDOWN)();
30
typedef int	(*LPCOMSENDMESSAGE)(char*, int, int);
31
typedef int (*LPCOMSETAGENTNAME)(char*);
32
33
#endif
34
(-)src-native-new/src/agents/perfmon/WinBuild/sysperf.dsp (+131 lines)
Added Link Here
1
# Microsoft Developer Studio Project File - Name="sysperf" - Package Owner=<4>
2
# Microsoft Developer Studio Generated Build File, Format Version 6.00
3
# ** DO NOT EDIT **
4
5
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
6
7
CFG=sysperf - Win32 Release
8
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9
!MESSAGE use the Export Makefile command and run
10
!MESSAGE 
11
!MESSAGE NMAKE /f "sysperf.mak".
12
!MESSAGE 
13
!MESSAGE You can specify a configuration when running NMAKE
14
!MESSAGE by defining the macro CFG on the command line. For example:
15
!MESSAGE 
16
!MESSAGE NMAKE /f "sysperf.mak" CFG="sysperf - Win32 Release"
17
!MESSAGE 
18
!MESSAGE Possible choices for configuration are:
19
!MESSAGE 
20
!MESSAGE "sysperf - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
21
!MESSAGE "sysperf - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
22
!MESSAGE 
23
24
# Begin Project
25
# PROP AllowPerConfigDependencies 0
26
# PROP Scc_ProjName ""
27
# PROP Scc_LocalPath ""
28
CPP=cl.exe
29
MTL=midl.exe
30
RSC=rc.exe
31
32
!IF  "$(CFG)" == "sysperf - Win32 Release"
33
34
# PROP BASE Use_MFC 0
35
# PROP BASE Use_Debug_Libraries 0
36
# PROP BASE Output_Dir "Release"
37
# PROP BASE Intermediate_Dir "Release"
38
# PROP BASE Target_Dir ""
39
# PROP Use_MFC 0
40
# PROP Use_Debug_Libraries 0
41
# PROP Output_Dir "..\..\..\..\lib"
42
# PROP Intermediate_Dir "Release"
43
# PROP Ignore_Export_Lib 0
44
# PROP Target_Dir ""
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYSPERF_EXPORTS" /YX /FD /c
46
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\resutils" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYSPERF_EXPORTS" /FD /c
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
49
# ADD BASE RSC /l 0x409 /d "NDEBUG"
50
# ADD RSC /l 0x409 /d "NDEBUG"
51
BSC32=bscmake.exe
52
# ADD BASE BSC32 /nologo
53
# ADD BSC32 /nologo
54
LINK32=link.exe
55
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
56
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib rac.lib mpr.lib /nologo /dll /machine:I386 /libpath:"..\..\..\..\lib" /out:"..\..\..\..\bin\sysperf.dll"
57
# SUBTRACT LINK32 /pdb:none
58
59
!ELSEIF  "$(CFG)" == "sysperf - Win32 Debug"
60
61
# PROP BASE Use_MFC 0
62
# PROP BASE Use_Debug_Libraries 0
63
# PROP BASE Output_Dir "sysperf___Win32_Debug"
64
# PROP BASE Intermediate_Dir "sysperf___Win32_Debug"
65
# PROP BASE Ignore_Export_Lib 0
66
# PROP BASE Target_Dir ""
67
# PROP Use_MFC 0
68
# PROP Use_Debug_Libraries 0
69
# PROP Output_Dir "..\..\..\..\lib"
70
# PROP Intermediate_Dir "Debug"
71
# PROP Ignore_Export_Lib 0
72
# PROP Target_Dir ""
73
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\resutils" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYSPERF_EXPORTS" /FD /c
74
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\resutils" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYSPERF_EXPORTS" /FD /c
75
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
76
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
77
# ADD BASE RSC /l 0x409 /d "NDEBUG"
78
# ADD RSC /l 0x409 /d "NDEBUG"
79
BSC32=bscmake.exe
80
# ADD BASE BSC32 /nologo
81
# ADD BSC32 /nologo
82
LINK32=link.exe
83
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib rac.lib /nologo /dll /machine:I386
84
# SUBTRACT BASE LINK32 /pdb:none
85
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib rac.lib mpr.lib /nologo /dll /machine:I386 /libpath:"..\..\..\..\lib" /out:"..\..\..\..\bin\sysperf.dll"
86
# SUBTRACT LINK32 /pdb:none
87
88
!ENDIF 
89
90
# Begin Target
91
92
# Name "sysperf - Win32 Release"
93
# Name "sysperf - Win32 Debug"
94
# Begin Group "Source Files"
95
96
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
97
# Begin Source File
98
99
SOURCE=..\sysperf\perfcalc.c
100
# End Source File
101
# Begin Source File
102
103
SOURCE=..\sysperf\perfcontrol.c
104
# End Source File
105
# End Group
106
# Begin Group "Header Files"
107
108
# PROP Default_Filter "h;hpp;hxx;hm;inl"
109
# Begin Source File
110
111
SOURCE=..\sysperf\perfcalc.h
112
# End Source File
113
# Begin Source File
114
115
SOURCE=..\sysperf\perfconstants.h
116
# End Source File
117
# Begin Source File
118
119
SOURCE=..\sysperf\perfcontrol.h
120
# End Source File
121
# End Group
122
# Begin Group "Resource Files"
123
124
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
125
# Begin Source File
126
127
SOURCE=..\sysperf\version.rc
128
# End Source File
129
# End Group
130
# End Target
131
# End Project
(-)src-native-new/src/agents/native/java_profiler/filters.h (+133 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: filters.h,v 1.2 2005/02/25 22:17:34 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef __FILTERS_H__
14
 #define __FILTERS_H__ 1
15
16
17
#define FILTER_LIST_INCREMENT 100
18
#define TRIGGER_LIST_INCREMENT 100
19
#define MAX_METHOD_FILTERS_PER_CLASS 5
20
21
enum FilterMode {EXCLUDE = 0, INCLUDE = 1};
22
enum GenericPattern {NONE, PREFIX, SUFFIX};
23
24
extern char	 _setPathDelimiter;
25
26
27
typedef struct {
28
	enum FilterMode mode;
29
	enum GenericPattern genericPattern;
30
	unsigned int patternLength;
31
	char * pattern;
32
}MethodFilter_t;
33
34
typedef struct {
35
	enum GenericPattern genericPattern;
36
	unsigned int methodDetailCount;
37
	MethodFilter_t methodDetails[MAX_METHOD_FILTERS_PER_CLASS];  /* Initial limit of specific methods per class */
38
	unsigned int patternLength;
39
	char * pattern;
40
}Filter;
41
42
43
typedef struct {
44
  unsigned int methodnameLength;
45
  char *methodname;
46
  unsigned int classnameLength;
47
  char *classname;
48
  int count;
49
}Trigger;
50
51
/* 174190 commented out because not necessary - not used in any other file
52
extern Filter *_jvmpiAgent_Filters;
53
*/
54
/*
55
 This function is used in standalone mode to read and parse a file containing a set of filter
56
 definitions.  It uses the jvmpiAgent_AddFilter and jvmpiAgent_ApplyFilters functions to
57
 actually set the active filter definitions for the agent.
58
*/
59
int jvmpiAgent_processFilters(char * fileName);
60
61
/** jvmpiAgent_checkMethodFilters *****************************************************************
62
  * This function determines whether a method is to be INCLUDED or EXCLUDED.  This can occur if
63
  * the class filter has a matching method filter, or if the class filter itself is NULL, i.e.,
64
  * the class does not match any existing filter.
65
  *
66
  * @param mthd_name    the method name to match
67
  * @param cls_fltr     the matching filter for this class
68
  * @returns    INCLUDE or EXCLUDE as is appropriate.
69
  */
70
int jvmpiAgent_checkMethodFilters(char *mthd_name, Filter *cls_fltr);
71
72
/** jvmpiAgent_getFilter **************************************************************************
73
  * This function returns the first class filtering that matches the class and method names.
74
  *
75
  * @param cls_name     the class name to match
76
  * @param mthd_name    the method name to match
77
  * @returns    the first matching class filter, or NULL if none is found.
78
  */
79
Filter *jvmpiAgent_getFilter(char *cls_name, char *mthd_name);
80
81
/*
82
 This function outputs the currently active filter definitions as elements in the trace.
83
*/
84
void jvmpiAgent_printFilters();
85
86
/*
87
 This function is takes the filter definitions accumulated using the jvmpiAgent_AddFilter function,
88
 and replaces the current set of active filter definitions.  In addition, the accumlated filter definitions
89
 are cleared.
90
 Note: It is recommended that the JVM be suspended during the execution of this function in order
91
 to avoid accessing the filter definitions while they are in an indeterminate state.
92
*/
93
void jvmpiAgent_applyFilters();
94
95
/** jvmpiAgent_addFilter **************************************************************************
96
  * This function appends a new filter using the class and method patterns with the filtering
97
  * mode.  The filters are saved in an ordered list, and the order in which they are inserted
98
  * makes a difference.  The filters will not be used until they are applied by calling
99
  * jvmpiAgent_ApplyFilters().  NULL, empty strings, and '*'s are all treated as wildcard
100
  * characters.
101
  *
102
  * @param cls_ptrn     the pattern to match a class
103
  * @param mthd_ptrn    the method pattern to match
104
  * @param mode         whether the method will be INCLUDED or EXCLUDED
105
  */
106
void jvmpiAgent_addFilter(char *classPattern, char *methodPattern, enum FilterMode mode);
107
108
/** jvmpiAgent_getClassFilterMode *****************************************************************
109
  * This function determines whether a class is to be INCLUDED or EXCLUDED.  This can occur if
110
  * the class filter has a wildcard method filter, or if the class filter itself is NULL, i.e.,
111
  * the class does not match any existing filter.
112
  *
113
  * @param cls_fltr the matching filter for this class
114
  * @returns    INCLUDE or EXCLUDE as is appropriate.
115
  */
116
enum FilterMode jvmpiAgent_getClassFilterMode(Filter *cls_fltr);
117
118
/* Initialize the Filter data structures */
119
void jvmpiAgent_initializeFilters(char pathChar);
120
121
void jvmpiAgent_initializeTriggers(char pathChar);
122
123
void jvmpiAgent_changeDelimiter(void);
124
125
int jvmpiAgent_processTriggers(char *filename);
126
127
int jvmpiAgent_checkTrigger(char *className, char *methodName);
128
129
int jvmpiAgent_addTrigger(char *methodname, char *classname, int count);
130
131
void jvmpiAgent_applyTriggers();
132
133
#endif
(-)src-native-new/src/agents/java/hcjbnd.def (+9 lines)
Added Link Here
1
LIBRARY hcjbnd
2
DESCRIPTION "Externalized LogAgent API"
3
EXPORTS
4
	logAgent_getCurrentProcessId @1
5
	logAgent_getCurrentThreadId @2
6
	logAgent_registerAgent @3
7
	logAgent_deregisterAgent @4
8
	logAgent_logMessage @5
9
	logAgent_logMessage_return @6
(-)src-native-new/src/agents/perfmon/WinBuild/resutils.mak (+249 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on resutils.dsp
2
!IF "$(CFG)" == ""
3
CFG=resutils - Win32 Release
4
!MESSAGE No configuration specified. Defaulting to resutils - Win32 Release.
5
!ENDIF 
6
7
!IF "$(CFG)" != "resutils - Win32 Release" && "$(CFG)" != "resutils - Win32 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "resutils.mak" CFG="resutils - Win32 Release"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "resutils - Win32 Release" (based on "Win32 (x86) Static Library")
17
!MESSAGE "resutils - Win32 Debug" (based on "Win32 (x86) Static Library")
18
!MESSAGE 
19
!ERROR An invalid configuration is specified.
20
!ENDIF 
21
22
!IF "$(OS)" == "Windows_NT"
23
NULL=
24
!ELSE 
25
NULL=nul
26
!ENDIF 
27
28
!IF  "$(CFG)" == "resutils - Win32 Release"
29
30
OUTDIR=.\bin
31
INTDIR=.\Release
32
# Begin Custom Macros
33
OutDir=.\bin
34
# End Custom Macros
35
36
ALL : "$(OUTDIR)\resutils.lib"
37
38
39
CLEAN :
40
	-@erase "$(INTDIR)\clock.obj"
41
	-@erase "$(INTDIR)\hashtable.obj"
42
	-@erase "$(INTDIR)\library.obj"
43
	-@erase "$(INTDIR)\mutex.obj"
44
	-@erase "$(INTDIR)\random.obj"
45
	-@erase "$(INTDIR)\streq.obj"
46
	-@erase "$(INTDIR)\thread.obj"
47
	-@erase "$(INTDIR)\vc60.idb"
48
	-@erase "$(OUTDIR)\resutils.lib"
49
50
"$(OUTDIR)" :
51
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
52
53
"$(INTDIR)" :
54
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
55
56
CPP=cl.exe
57
CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"$(INTDIR)\resutils.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
58
59
.c{$(INTDIR)}.obj::
60
   $(CPP) @<<
61
   $(CPP_PROJ) $< 
62
<<
63
64
.cpp{$(INTDIR)}.obj::
65
   $(CPP) @<<
66
   $(CPP_PROJ) $< 
67
<<
68
69
.cxx{$(INTDIR)}.obj::
70
   $(CPP) @<<
71
   $(CPP_PROJ) $< 
72
<<
73
74
.c{$(INTDIR)}.sbr::
75
   $(CPP) @<<
76
   $(CPP_PROJ) $< 
77
<<
78
79
.cpp{$(INTDIR)}.sbr::
80
   $(CPP) @<<
81
   $(CPP_PROJ) $< 
82
<<
83
84
.cxx{$(INTDIR)}.sbr::
85
   $(CPP) @<<
86
   $(CPP_PROJ) $< 
87
<<
88
89
RSC=rc.exe
90
BSC32=bscmake.exe
91
BSC32_FLAGS=/nologo /o"$(OUTDIR)\resutils.bsc" 
92
BSC32_SBRS= \
93
	
94
LIB32=link.exe -lib
95
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\resutils.lib" 
96
LIB32_OBJS= \
97
	"$(INTDIR)\clock.obj" \
98
	"$(INTDIR)\hashtable.obj" \
99
	"$(INTDIR)\library.obj" \
100
	"$(INTDIR)\mutex.obj" \
101
	"$(INTDIR)\random.obj" \
102
	"$(INTDIR)\streq.obj" \
103
	"$(INTDIR)\thread.obj"
104
105
"$(OUTDIR)\resutils.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
106
    $(LIB32) @<<
107
  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
108
<<
109
110
!ELSEIF  "$(CFG)" == "resutils - Win32 Debug"
111
112
OUTDIR=.\bin
113
INTDIR=.\Debug
114
# Begin Custom Macros
115
OutDir=.\bin
116
# End Custom Macros
117
118
ALL : "$(OUTDIR)\resutils.lib"
119
120
121
CLEAN :
122
	-@erase "$(INTDIR)\clock.obj"
123
	-@erase "$(INTDIR)\hashtable.obj"
124
	-@erase "$(INTDIR)\library.obj"
125
	-@erase "$(INTDIR)\mutex.obj"
126
	-@erase "$(INTDIR)\random.obj"
127
	-@erase "$(INTDIR)\streq.obj"
128
	-@erase "$(INTDIR)\thread.obj"
129
	-@erase "$(INTDIR)\vc60.idb"
130
	-@erase "$(OUTDIR)\resutils.lib"
131
132
"$(OUTDIR)" :
133
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
134
135
"$(INTDIR)" :
136
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
137
138
CPP=cl.exe
139
CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /Fp"$(INTDIR)\resutils.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
140
141
.c{$(INTDIR)}.obj::
142
   $(CPP) @<<
143
   $(CPP_PROJ) $< 
144
<<
145
146
.cpp{$(INTDIR)}.obj::
147
   $(CPP) @<<
148
   $(CPP_PROJ) $< 
149
<<
150
151
.cxx{$(INTDIR)}.obj::
152
   $(CPP) @<<
153
   $(CPP_PROJ) $< 
154
<<
155
156
.c{$(INTDIR)}.sbr::
157
   $(CPP) @<<
158
   $(CPP_PROJ) $< 
159
<<
160
161
.cpp{$(INTDIR)}.sbr::
162
   $(CPP) @<<
163
   $(CPP_PROJ) $< 
164
<<
165
166
.cxx{$(INTDIR)}.sbr::
167
   $(CPP) @<<
168
   $(CPP_PROJ) $< 
169
<<
170
171
RSC=rc.exe
172
BSC32=bscmake.exe
173
BSC32_FLAGS=/nologo /o"$(OUTDIR)\resutils.bsc" 
174
BSC32_SBRS= \
175
	
176
LIB32=link.exe -lib
177
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\resutils.lib" 
178
LIB32_OBJS= \
179
	"$(INTDIR)\clock.obj" \
180
	"$(INTDIR)\hashtable.obj" \
181
	"$(INTDIR)\library.obj" \
182
	"$(INTDIR)\mutex.obj" \
183
	"$(INTDIR)\random.obj" \
184
	"$(INTDIR)\streq.obj" \
185
	"$(INTDIR)\thread.obj"
186
187
"$(OUTDIR)\resutils.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
188
    $(LIB32) @<<
189
  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
190
<<
191
192
!ENDIF 
193
194
195
!IF "$(NO_EXTERNAL_DEPS)" != "1"
196
!IF EXISTS("resutils.dep")
197
!INCLUDE "resutils.dep"
198
!ELSE 
199
!MESSAGE Warning: cannot find "resutils.dep"
200
!ENDIF 
201
!ENDIF 
202
203
204
!IF "$(CFG)" == "resutils - Win32 Release" || "$(CFG)" == "resutils - Win32 Debug"
205
SOURCE=..\resutils\clock.c
206
207
"$(INTDIR)\clock.obj" : $(SOURCE) "$(INTDIR)"
208
	$(CPP) $(CPP_PROJ) $(SOURCE)
209
210
211
SOURCE=..\resutils\hashtable.c
212
213
"$(INTDIR)\hashtable.obj" : $(SOURCE) "$(INTDIR)"
214
	$(CPP) $(CPP_PROJ) $(SOURCE)
215
216
217
SOURCE=..\resutils\library.c
218
219
"$(INTDIR)\library.obj" : $(SOURCE) "$(INTDIR)"
220
	$(CPP) $(CPP_PROJ) $(SOURCE)
221
222
223
SOURCE=..\resutils\mutex.c
224
225
"$(INTDIR)\mutex.obj" : $(SOURCE) "$(INTDIR)"
226
	$(CPP) $(CPP_PROJ) $(SOURCE)
227
228
229
SOURCE=..\resutils\random.c
230
231
"$(INTDIR)\random.obj" : $(SOURCE) "$(INTDIR)"
232
	$(CPP) $(CPP_PROJ) $(SOURCE)
233
234
235
SOURCE=..\resutils\streq.c
236
237
"$(INTDIR)\streq.obj" : $(SOURCE) "$(INTDIR)"
238
	$(CPP) $(CPP_PROJ) $(SOURCE)
239
240
241
SOURCE=..\resutils\thread.c
242
243
"$(INTDIR)\thread.obj" : $(SOURCE) "$(INTDIR)"
244
	$(CPP) $(CPP_PROJ) $(SOURCE)
245
246
247
248
!ENDIF 
249
(-)src-native-new/src/agents/native/java_profiler/filters.c (+657 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: filters.c,v 1.4 2005/03/24 17:42:29 samwai Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
/*
14
 *
15
 * Source File Name = filters.c
16
 *
17
 * Descriptive Name = Profiling Agent filter handling code
18
 *
19
 * Function:
20
 *           jvmpiAgent_initializeFilters
21
 *           jvmpiAgent_checkFilters
22
 *           parseFilterPattern
23
 *           jvmpiAgent_addFilter
24
 *           jvmpiAgent_applyFilters
25
 *           jvmpiAgent_processFilters
26
 *           jvmpiAgent_printFilters
27
 *
28
 *    Defines:
29
 *
30
 * Dependencies:
31
 *    None
32
 *
33
 * Restrictions:
34
 *    None
35
 *
36
 * Change Activity:
37
 * Defect Date        Who Description
38
 * ====== =========== === ==============================================
39
 *               2001 rkd Initial drop
40
 * 173995 May/15/2001 dns Fixed bugs causing heap corruption
41
 * 174190 May/30/2001 dns 390 Porting changes
42
 *
43
 ******************************************************************************/
44
45
46
#if (defined _HPUX || defined _AIX || defined _SOLARIS)
47
	#include <inttypes.h>
48
#elif defined __linux__
49
	#include <stdint.h>
50
#else
51
	#define INT32_MAX 2147483647
52
#endif
53
54
55
#include <string.h>
56
#include <stdio.h>
57
#include <stdlib.h>
58
#include "filters.h"
59
#include "JvmpiWriter.h"
60
#include "print.h"
61
#include "utility.h"
62
63
static Filter *_jvmpiAgent_Filters = NULL;  /* Pointer to a list of active Filter elements 174190 made static */
64
static int _filterCount = 0; /* Number of active Filter elements in list */
65
static int _filterListSize = FILTER_LIST_INCREMENT; /* Current size (in # of Filter elements) of
66
                                                    the pending Filter element buffer */
67
static Filter *_filterListBuffer = 0; /* Pointer to a list of pending Filter elements */
68
static int _filterListBufferCount = 0; /* Number of pending Filter elements in list */
69
static char _pathDelimiter;
70
71
static Trigger    *_jvmpiAgent_Triggers     =NULL;
72
static Trigger    *_triggerListBuffer       =0;
73
static int         _triggerListBufferCount  =0;
74
static int         _triggerCount            =0;
75
static int         _triggerListSize         =TRIGGER_LIST_INCREMENT;
76
77
/* Start literal conversions from ebcdic to ascii for OS400 */ 
78
#ifdef __OS400__
79
#pragma convert(819) 
80
#endif
81
82
/*
83
 This function initializes the data structures used by the filter mechanism.
84
*/
85
void jvmpiAgent_initializeFilters(char pathDelimiter)
86
{
87
 _jvmpiAgent_Filters = (Filter *)jvmpiAgent_Calloc(sizeof(Filter)*FILTER_LIST_INCREMENT);
88
 _filterListBuffer = (Filter *)jvmpiAgent_Calloc(sizeof(Filter)*FILTER_LIST_INCREMENT);
89
 _pathDelimiter = pathDelimiter;
90
}
91
92
93
/** str_fits_ptrn *********************************************************************************
94
  * This function returns a non-zero value if the string matches the pattern, or a zero.  The
95
  * input pointers can be empty srings, but cannot be NULL.  All strings and patterns, including
96
  * the empty ones are handled properly.
97
  *
98
  * @param str          the string to match the pattern
99
  * @param ptrn         the pattern to match the string
100
  * @param ptrn_type    the type of the pattern
101
  * @param ptrn_len     the length of the pattern
102
  * @returns    a non-zero value if the string fits into the pattern, or zero otherwise.
103
  */
104
int str_fits_ptrn(const char* str, const char* ptrn, const int ptrn_type, const int ptrn_len) {
105
    int off; /* the offset of the start of comparison in a prefix match */
106
107
	if (str == 0 || ptrn == 0) {
108
		return 0; 
109
	}
110
111
    /* A zero-length (empty) pattern matches all strings including the empty ones.  Otherwise, an exact
112
       match, prefix, or suffix match will be performed.  The first case is really not really a special
113
       case as it has already been coverted under the other three.  So, this case is really included
114
       for clarity purposes only.  */
115
    return !ptrn_len ||
116
           (ptrn_type == NONE && !strcmp(ptrn, str)) ||
117
           (ptrn_type == PREFIX && (off = strlen(str) - ptrn_len) >= 0 && !strcmp(ptrn, str + off)) ||
118
           (ptrn_type == SUFFIX && !strncmp(ptrn, str, ptrn_len));
119
}
120
121
122
/** match_mthd_fltr *******************************************************************************
123
  * This function returns the first method filter from the class filter list, matching the method
124
  * name.
125
  *
126
  * @param mthd_fltr_lst        the method filter list from which a match is searched
127
  * @param mthd_fltr_lst_len    the length of the above list
128
  * @param mthd_name            the method name to match
129
  * @returns    the first matching method filter, or NULL if none is found.
130
  */
131
MethodFilter_t *match_mthd_fltr(MethodFilter_t *mthd_fltr_lst, const unsigned int mthd_fltr_lst_len, const char *mthd_name) {
132
    unsigned int i; /* the loop control variable */
133
    MethodFilter_t *mthd_fltr; /* a method filter from a class filter */
134
135
    /* Iterate through the method filter list to find the first matching method filter. */
136
    for (i = 0; i < mthd_fltr_lst_len; i++) {
137
138
        mthd_fltr = mthd_fltr_lst + i;
139
        if (str_fits_ptrn(mthd_name, mthd_fltr -> pattern, mthd_fltr -> genericPattern, mthd_fltr -> patternLength)) {
140
            return mthd_fltr;
141
        }
142
    }
143
    return NULL;
144
}
145
146
147
/** match_cls_mthd_fltr ***************************************************************************
148
  * This function returns the first class filter from the class filter list, matching the class
149
  * and method names.  If the method name supplied is an empty string, the first matching class
150
  * filter with a wildcard method filter will be picked.
151
  *
152
  * @param cls_fltr_lst     the class filter list from which a match is searched
153
  * @param cls_fltr_lst_len the length of the above list
154
  * @param cls_name         the class name to match
155
  * @param mthd_name        the method name to match
156
  * @returns    the first matching class filter, or NULL if none is found.
157
  */
158
Filter *match_cls_mthd_fltr(Filter *cls_fltr_lst, int cls_fltr_lst_len, char *cls_name, char *mthd_name) {
159
    int i; /* the loop control variable */
160
    Filter *cls_fltr; /* a class filter from the filter list */
161
    MethodFilter_t *mthd_fltr; /* a method filter from a class filter */
162
	char *reg_cls_name; /* the class name without JNI style array notation */ 
163
164
	/* bugzilla 70263 - remove the array notation from the front of a class name so we filter 
165
	array classes as well. For example, if the class name is '[[Ljava.lang.Thread', the
166
	following code will set reg_cls_name to 'java.lang.Thread'. */ 
167
168
#ifdef __OS400__
169
#pragma convert(819)
170
#endif 
171
	reg_cls_name = strrchr(cls_name,'['); /* returns the last occurence of '[' */ 
172
	if (reg_cls_name != NULL && reg_cls_name[1] == 'L') {
173
		reg_cls_name += 2; /* skip to the point after the 'L' */ 
174
	} else {
175
		reg_cls_name = cls_name; 
176
	}
177
#ifdef __OS400__
178
#pragma convert(0)
179
#endif 
180
181
182
    /* Iterate through the class filter list to find the first filter matching the class and method names. */
183
    for (i = 0; i < cls_fltr_lst_len; i++) {
184
185
        cls_fltr = cls_fltr_lst + i;
186
        if (!str_fits_ptrn(reg_cls_name, cls_fltr -> pattern, cls_fltr -> genericPattern, cls_fltr -> patternLength)) {
187
            continue;
188
        }
189
        mthd_fltr = match_mthd_fltr(cls_fltr -> methodDetails, cls_fltr -> methodDetailCount, mthd_name);
190
        if (mthd_fltr) {
191
            return cls_fltr;
192
        }
193
    }
194
    return NULL;
195
}
196
197
198
/** jvmpiAgent_getFilter **************************************************************************
199
  * This function returns the first class filter that matches the class and method names.
200
  *
201
  * @param cls_name     the class name to match
202
  * @param mthd_name    the method name to match
203
  * @returns    the first matching class filter, or NULL if none is found.
204
  */
205
Filter *jvmpiAgent_getFilter(char *cls_name, char *mthd_name) {
206
207
    return match_cls_mthd_fltr(_jvmpiAgent_Filters, _filterCount, cls_name, mthd_name);
208
}
209
210
211
/** jvmpiAgent_getClassFilterMode *****************************************************************
212
  * This function determines whether a class is to be INCLUDED or EXCLUDED.  This can occur if
213
  * the class filter has a wildcard method filter, or if the class filter itself is NULL, i.e.,
214
  * the class does not match any existing filter.
215
  *
216
  * @param cls_fltr the matching filter for this class
217
  * @returns    INCLUDE or EXCLUDE as is appropriate.
218
  */
219
enum FilterMode jvmpiAgent_getClassFilterMode(Filter *cls_fltr) {
220
    MethodFilter_t *mthd_fltr; /* the method filter for the default methods */
221
222
    mthd_fltr = cls_fltr ? match_mthd_fltr(cls_fltr -> methodDetails, cls_fltr -> methodDetailCount, "") : NULL;
223
    return mthd_fltr ? mthd_fltr -> mode : INCLUDE;
224
}
225
226
227
/** jvmpiAgent_checkMethodFilters *****************************************************************
228
  * This function determines whether a method is to be INCLUDED or EXCLUDED.  This can occur if
229
  * the class filter has a matching method filter, or if the class filter itself is NULL, i.e.,
230
  * the class does not match any existing filter.
231
  *
232
  * @param mthd_name    the method name to match
233
  * @param cls_fltr     the matching filter for this class
234
  * @returns    INCLUDE or EXCLUDE as is appropriate.
235
  */
236
int jvmpiAgent_checkMethodFilters(char *mthd_name, Filter *cls_fltr) {
237
    MethodFilter_t *mthd_fltr; /* the method filter for the default methods */
238
239
    mthd_fltr = cls_fltr ? match_mthd_fltr(cls_fltr -> methodDetails, cls_fltr -> methodDetailCount, mthd_name) : NULL;
240
    return (mthd_fltr ? mthd_fltr -> mode : INCLUDE);
241
}
242
243
244
/*
245
 This function takes a filterpattern and determines if it is a prefix (leading "*"), suffix (trailing "*"), or
246
 exact match (no "*") type pattern.  It returns the type and adjusts the pointer to the filterPattern buffer
247
 to exclude the "*")
248
*/
249
static enum GenericPattern parseFilterPattern(char ** filterPattern)
250
{
251
 enum GenericPattern genericPattern;
252
253
 char *p = strchr(*filterPattern, '*');
254
 if(_setPathDelimiter)
255
 {
256
	_pathDelimiter = _setPathDelimiter;
257
 }
258
 if (p == NULL)
259
 {
260
  genericPattern = NONE;
261
 }
262
 else if (p == *filterPattern)
263
 {
264
  genericPattern = PREFIX;
265
  (*filterPattern)++; /* Bump the buffer pointer past the "*" */
266
 }
267
 else if (p == (*filterPattern + strlen(*filterPattern)-1))
268
 {
269
  genericPattern = SUFFIX;
270
  *p = '\0'; /* Truncate the buffer to eliminate the "*" */
271
 }
272
 else
273
 {
274
  /* Error "*" found imbedded within pattern */
275
  genericPattern = NONE;
276
 }
277
278
 /*
279
  Translate the path delimiter character specified in the filterPattern to the path delimiter
280
  character used by the current JVM (this value was specified during filter initialization.
281
 */
282
 if (_pathDelimiter == '.')
283
 {
284
  int i;
285
  for (i=strlen(*filterPattern)-1; i >= 0; i--)
286
  {
287
   if ((*filterPattern)[i] == '/') (*filterPattern)[i] = '.';
288
  }
289
 }
290
 else if (_pathDelimiter == '/')
291
 {
292
  int i;
293
  for (i=strlen(*filterPattern)-1; i >= 0; i--)
294
  {
295
   if ((*filterPattern)[i] == '.') (*filterPattern)[i] = '/';
296
  }
297
 }
298
 return genericPattern;
299
300
}
301
302
303
/** get_cls_fltr **********************************************************************************
304
  * This function returns a matching class filtering from the class filter list provided,
305
  * or a NULL pointer if none is found.  Matching filters must share the same filter pattern,
306
  * type, and length.
307
  *
308
  * @param cls_fltr_lst     the class filter list from which a match is searched
309
  * @param cls_fltr_lst_len the length of the above list
310
  * @param cls_ptrn         the class pattern to match
311
  * @param cls_ptrn_type    the type of the class pattern to match
312
  * @param cls_ptrn_len     the length of the class pattern to match
313
  */
314
Filter *get_cls_fltr(Filter *cls_fltr_lst, unsigned int cls_fltr_lst_len,
315
                     char *cls_ptrn, enum GenericPattern cls_ptrn_type, unsigned int cls_ptrn_len) {
316
    unsigned int i; /* the loop control variable */
317
    Filter *cls_fltr; /* a class filter from the filter list */
318
319
    for (i = 0; i < cls_fltr_lst_len; i++) {
320
321
        cls_fltr = cls_fltr_lst + i;
322
        if (cls_fltr -> patternLength == cls_ptrn_len &&
323
            cls_fltr -> genericPattern == cls_ptrn_type &&
324
            !strcmp(cls_fltr -> pattern, cls_ptrn)) {
325
            return cls_fltr;
326
        }
327
    }
328
    return NULL;
329
}
330
331
332
/** get_mthd_fltr *********************************************************************************
333
  * This function returns a matching method filtering from the method filter list provided,
334
  * or a NULL pointer if none is found.  Matching filters must share the same filter pattern,
335
  * type, and length.
336
  *
337
  * @param mthd_fltr_lst        the method filter list from which a match is searched
338
  * @param mthd_fltr_lst_len    the length of the above list
339
  * @param mthd_ptrn            the method pattern to match
340
  * @param mthd_ptrn_type       the type of the method pattern to match
341
  * @param mthd_ptrn_len        the length of the method pattern to match
342
  */
343
MethodFilter_t *get_mthd_fltr(MethodFilter_t *mthd_fltr_lst, unsigned int mthd_fltr_lst_len,
344
                              char *mthd_ptrn, enum GenericPattern mthd_ptrn_type, unsigned int mthd_ptrn_len) {
345
    unsigned int i; /* the loop control variable */
346
    MethodFilter_t *mthd_fltr; /* a method filter from the filter list */
347
348
    for (i = 0; i < mthd_fltr_lst_len; i++) {
349
        mthd_fltr = mthd_fltr_lst + i;
350
        if (mthd_fltr -> patternLength == mthd_ptrn_len &&
351
            mthd_fltr -> genericPattern == mthd_ptrn_type &&
352
            !strcmp(mthd_fltr -> pattern, mthd_ptrn)) {
353
            return mthd_fltr;
354
        }
355
    }
356
    return NULL;
357
}
358
359
360
/** jvmpiAgent_addFilter **************************************************************************
361
  * This function appends a new filter using the class and method patterns with the filtering
362
  * mode.  The filters are saved in an ordered list, and the order in which they are inserted
363
  * makes a difference.  The filters will not be used until they are applied by calling
364
  * jvmpiAgent_ApplyFilters().  NULL, empty strings, and '*'s are all treated as wildcard
365
  * characters.
366
  *
367
  * @param cls_ptrn     the pattern to match a class
368
  * @param mthd_ptrn    the method pattern to match
369
  * @param mode         whether the method will be INCLUDED or EXCLUDED
370
  */
371
void jvmpiAgent_addFilter(char *cls_ptrn, char *mthd_ptrn, enum FilterMode mode) {
372
    Filter *cls_fltr; /* the class filter to add or modify */
373
    MethodFilter_t *mthd_fltr; /* the method filter to add or modify */
374
    enum GenericPattern cls_ptrn_type, mthd_ptrn_type; /* the class and method pattern types */
375
    unsigned int cls_ptrn_len, mthd_ptrn_len; /* the class and method pattern lengths */
376
377
#ifdef MVS                    /* 174190 */
378
    if (cls_ptrn != NULL) {
379
        __etoa(cls_ptrn);
380
    }
381
    if (mthd_ptrn != NULL) {
382
       __etoa(mthd_ptrn);
383
    }
384
#elif __OS400__
385
	if (cls_ptrn != NULL) {
386
       cls_ptrn = as400_etoa(cls_ptrn);
387
    }
388
    if (mthd_ptrn != NULL) {
389
       mthd_ptrn = as400_etoa(mthd_ptrn);
390
    }
391
#endif
392
393
    /* Ensure that NULL pointers are replaced with empty strings to eliminate special cases. */
394
    if (cls_ptrn == NULL) {
395
        cls_ptrn = "";
396
    }
397
    if (mthd_ptrn == NULL) {
398
        mthd_ptrn = "";
399
    }
400
401
    /* Try to locate an existing class filter.  Create a new class filter if none found. */
402
    cls_ptrn_type = parseFilterPattern(&cls_ptrn);
403
    cls_ptrn_len = strlen(cls_ptrn);
404
    cls_fltr = get_cls_fltr(_filterListBuffer, _filterListBufferCount, cls_ptrn, cls_ptrn_type, cls_ptrn_len);
405
    if (!cls_fltr) {
406
407
        /* Enlarge the filter buffer if necessary. */
408
        if (_filterListBufferCount >= _filterListSize) {
409
            _filterListSize += FILTER_LIST_INCREMENT;
410
            _filterListBuffer = (Filter *) realloc(_filterListBuffer, _filterListSize);
411
        }
412
413
        /* Create the class filter for this method. */
414
        cls_fltr = _filterListBuffer + _filterListBufferCount;
415
        cls_fltr -> genericPattern = cls_ptrn_type;
416
        cls_fltr -> patternLength = cls_ptrn_len;
417
        cls_fltr -> pattern = (char *) jvmpiAgent_Calloc(cls_ptrn_len + 1);
418
        strcpy(cls_fltr -> pattern, cls_ptrn);
419
        cls_fltr -> methodDetailCount = 0;
420
        _filterListBufferCount++;
421
422
    } else if (cls_fltr -> methodDetailCount >= MAX_METHOD_FILTERS_PER_CLASS) {
423
424
        /* If there is no more room for the method filter, the filter will be dropped. */
425
        return;
426
    }
427
428
    /* If there already exists an identical filter, then the new filter will be ignored. */
429
    mthd_ptrn_type = parseFilterPattern(&mthd_ptrn);
430
    mthd_ptrn_len = strlen(mthd_ptrn);
431
    mthd_fltr = get_mthd_fltr(cls_fltr -> methodDetails, cls_fltr -> methodDetailCount,
432
        mthd_ptrn, mthd_ptrn_type, mthd_ptrn_len);
433
    if (mthd_fltr) {
434
        return;
435
    }
436
437
    /* Insert the method filter into the class filter. */
438
    mthd_fltr = cls_fltr -> methodDetails + cls_fltr -> methodDetailCount;
439
    mthd_fltr -> genericPattern = mthd_ptrn_type;
440
    mthd_fltr -> patternLength = mthd_ptrn_len;
441
    strcpy((mthd_fltr -> pattern = (char *) jvmpiAgent_Calloc(mthd_ptrn_len + 1)), mthd_ptrn);
442
    mthd_fltr -> mode = mode;
443
    cls_fltr -> methodDetailCount++;
444
}
445
446
447
/* PR */
448
void jvmpiAgent_changeDelimiter()
449
{
450
451
 int i;
452
 char sunch = '.';
453
 char *tempFilterPattern;
454
 memcpy(_filterListBuffer, _jvmpiAgent_Filters, _filterCount * sizeof(Filter));
455
 for (i=0; i < _filterCount; i++)
456
 {
457
  int j = 0;
458
  tempFilterPattern = _filterListBuffer[i].pattern;
459
  for (j=strlen(tempFilterPattern)-1; j >= 0; j--)
460
  {
461
   if(_setPathDelimiter == sunch)
462
   {
463
	   if(tempFilterPattern[j] == '/')
464
	   {
465
		   (tempFilterPattern[j] = sunch);
466
	   }
467
   }
468
  }
469
   strcpy(_filterListBuffer[i].pattern, tempFilterPattern);
470
 }
471
 jvmpiAgent_applyFilters();
472
473
}
474
/* PR */
475
476
/*
477
 This function is used to replace the current set of filters with the pending set of filters.
478
*/
479
void jvmpiAgent_applyFilters()
480
{
481
 int i;
482
 if (!_filterListBufferCount) return; /* Empty list so this may be an extaneous apply, so ignore it */
483
484
 for (i=0; i < _filterCount; i++)  /* 173995 - replaced _filterListBufferCount with _filterCount for loop upper bound */
485
 {
486
#ifndef _DEBUG
487
  free(_jvmpiAgent_Filters[i].pattern);
488
#endif
489
  _jvmpiAgent_Filters[i].pattern=NULL;
490
 }
491
 free(_jvmpiAgent_Filters);
492
 _jvmpiAgent_Filters=NULL;
493
 _jvmpiAgent_Filters = (Filter *)jvmpiAgent_Calloc(sizeof(Filter)*_filterListSize);
494
 memcpy(_jvmpiAgent_Filters, _filterListBuffer, _filterListBufferCount * sizeof(Filter));
495
 _filterCount = _filterListBufferCount;
496
 _filterListBufferCount = 0;
497
 memset(_filterListBuffer, '\0', sizeof(Filter)*_filterListSize);
498
499
 /* After the filter process, we need to set the tracing flags of the primitive classes */
500
 jvmpiAgent_SetTracingFlagsOnPrimitives();
501
}
502
503
504
int jvmpiAgent_processFilters(char * fileName) {
505
	FILE * filterFile = NULL;
506
	char classPattern[250];
507
	char methodPattern[250];
508
	char mode[100];
509
510
#ifdef MVS                    /* 174190 */
511
#pragma convlit(suspend)
512
	__atoe(fileName);
513
#elif __OS400__
514
#pragma convert(0)
515
#endif
516
	filterFile = fopen(fileName, "r");
517
	if (!filterFile) return -1;
518
519
	while (fscanf(filterFile, "%s %s %s\n", classPattern, methodPattern, mode) != EOF) {
520
		jvmpiAgent_addFilter(classPattern, methodPattern, strcmp("INCLUDE", mode) == 0 ? INCLUDE : EXCLUDE);
521
	}
522
	fclose(filterFile);
523
#ifdef MVS                    /* 174190 */
524
#pragma convlit(resume)
525
#elif __OS400__
526
#pragma convert(819)
527
#endif
528
529
	jvmpiAgent_applyFilters();
530
	return 0;
531
}
532
533
534
void jvmpiAgent_printFilters()
535
{
536
 int i;
537
 for (i=0; i < _filterCount; i++)
538
 {
539
  jvmpiAgent_printFilter(jvmpiAgent_getThreadLocalStorage(0), &_jvmpiAgent_Filters[i]);
540
 }
541
}
542
543
544
void jvmpiAgent_initializeTriggers(char pathDelimiter) {
545
	_jvmpiAgent_Triggers = (Trigger *)jvmpiAgent_Calloc(sizeof(Trigger)*TRIGGER_LIST_INCREMENT);
546
	_triggerListBuffer = (Trigger *)jvmpiAgent_Calloc(sizeof(Trigger)*TRIGGER_LIST_INCREMENT);
547
	_pathDelimiter = pathDelimiter;
548
}
549
550
551
int jvmpiAgent_processTriggers(char *filename) {
552
	FILE * triggerFile = NULL;
553
	char methodname[256];
554
	char classname[1024];
555
	int count;
556
557
#ifdef MVS                    /* 174190 */
558
#pragma convlit(suspend)
559
	__atoe(filename);
560
#elif __OS400__
561
#pragma convert(0)
562
#endif
563
	triggerFile = fopen(filename, "r");
564
	if(!triggerFile) {
565
		return -1;
566
	}
567
568
	while (fscanf(triggerFile, "%s %s %d\n", methodname, classname, &count) != EOF)  {
569
	  /* printf("Processing Trigger: %s %s %d\n", methodname, classname, count); */
570
	  jvmpiAgent_addTrigger(methodname, classname, count);
571
	}
572
573
	fclose(triggerFile);
574
#ifdef MVS                    /* 174190 */
575
#pragma convlit(resume)
576
#elif __OS400__
577
#pragma convert(819) 
578
#endif
579
	jvmpiAgent_applyTriggers();
580
	return 0;
581
}
582
583
int jvmpiAgent_checkTrigger(char *classname, char *methodname) {
584
  int i;
585
  for (i=0; i < _triggerCount; i++)  {
586
    Trigger *tp = &_jvmpiAgent_Triggers[i];
587
    if ((tp->methodname[0] == '*' || !strcmp(tp->methodname, methodname))
588
	&& (tp->classname[0] == '*' || !strcmp(tp->classname, classname))) {
589
      
590
      return tp->count;
591
      
592
    }
593
  }
594
  return INT32_MAX;
595
}
596
597
int jvmpiAgent_addTrigger(char *methodname,
598
			  char *classname,
599
			  int count)
600
{
601
	if (_triggerListBufferCount >= _triggerListSize) {
602
		/* Reallocate a larger buffer for the filters */
603
		_triggerListSize += TRIGGER_LIST_INCREMENT;
604
		_triggerListBuffer = (Trigger *)realloc(_triggerListBuffer, _triggerListSize);
605
	}
606
607
#ifdef MVS                    /* 174190 */
608
	__etoa(methodname);
609
	__etoa(classname);
610
#elif __OS400__
611
	if (methodname != NULL) {
612
		methodname = as400_etoa(methodname);
613
	}
614
	if (classname != NULL) {
615
		classname = as400_etoa(classname); 
616
	}
617
#endif
618
619
	/* Set the length of the pattern and allocate and set the pattern into the list of pending filters */
620
  _triggerListBuffer[_triggerListBufferCount].methodnameLength =
621
    strlen(methodname);
622
  STRDUP(_triggerListBuffer[_triggerListBufferCount].methodname,
623
	 methodname); /* 236501 */
624
  _triggerListBuffer[_triggerListBufferCount].classnameLength =
625
    strlen(classname);
626
  STRDUP(_triggerListBuffer[_triggerListBufferCount].classname,
627
	 classname);
628
  _triggerListBuffer[_triggerListBufferCount].count = count;
629
  _triggerListBufferCount++;
630
	return 0;
631
}
632
633
void jvmpiAgent_applyTriggers() {
634
	int i;
635
	if (!_triggerListBufferCount) {
636
		return; /* Empty list so this may be an extaneous apply, so ignore it */
637
	}
638
639
	for (i=0; i < _triggerCount; i++) {
640
		free(_jvmpiAgent_Triggers[i].methodname);
641
		_jvmpiAgent_Triggers[i].methodname=NULL;
642
		free(_jvmpiAgent_Triggers[i].classname);
643
	    _jvmpiAgent_Triggers[i].classname=NULL;
644
	}
645
	free(_jvmpiAgent_Triggers);
646
	_jvmpiAgent_Triggers=NULL;
647
648
	_jvmpiAgent_Triggers = (Trigger*)jvmpiAgent_Calloc(sizeof(Trigger)*_triggerListSize);
649
	memcpy(_jvmpiAgent_Triggers, _triggerListBuffer, _triggerListBufferCount * sizeof(Trigger));
650
	_triggerCount = _triggerListBufferCount;
651
	_triggerListBufferCount = 0;
652
	BZERO(_triggerListBuffer, sizeof(Trigger)*_triggerListSize);
653
}
654
/* stop literal conversions from ebcdic to ascii for as400 */ 
655
#ifdef __OS400__
656
#pragma convert(0) 
657
#endif
(-)src-native-new/src/agents/native/java_profiler/agentDebug.h (+24 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: agentDebug.h,v 1.2 2005/02/25 22:17:34 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef __AGENT_DEBUG__
14
#define __AGENT_DEBUG__ 1
15
16
#include "hash.h"
17
18
19
void jvmpiAgent_dumpStack(ThreadPrivateStorage *tps, char * buffer);
20
21
void jvmpiAgent_dumpJVMStack(JNIEnv *thread, char * buffer);
22
23
#endif
24
(-)src-native-new/src/agents/perfmon/rac/rac.h (+203 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: rac.h,v 1.4 2006/05/05 18:10:56 hsuwanda Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef __RAC_H__
14
#define __RAC_H__
15
16
#include "DataTransferInterface.h"
17
#include "system.h"
18
19
#include "RASocket.h"
20
#include "RADataTransfer.h"
21
#include "RAShm.h"
22
#include "RABindings.h"
23
#include "hashtable.h"
24
25
//WINDOWS ONLY
26
#ifdef WIN32
27
	#include "winsock2.h" /* Bug 134924 */
28
	#include "windows.h"
29
	#include "winperf.h"
30
#endif
31
//END WINDOWS ONLY
32
33
#define RAC_HYADES_TYPED_EVENT          1
34
#define RAC_HYADES_MESSAGE_EVENT        2
35
#define RAC_HYADES_VERDICT_EVENT        3
36
#define RAC_HYADES_INVOCATION_EVENT     4
37
38
#ifdef __cplusplus
39
extern "C" {
40
#endif
41
42
43
//these two are not important - RACStartup and RACShutdown are all that are required
44
int RACLoadRacLibs();
45
int RACGetRacFuncs();
46
47
////////////////////////////
48
// Performance data related functions
49
////////////////////////////
50
51
typedef struct {
52
	char* name;
53
	int tracing;
54
	int index;
55
//	int type;
56
57
	//WINDOWS ONLY
58
  BOOL               enabled;
59
	#ifdef WIN32
60
	DWORD win_id;
61
62
    BOOL               isPrinted;
63
    int                type;
64
    int                id;
65
    LONGLONG           newTime;
66
    LONGLONG           oldTime;
67
    LONGLONG           perfFreq;
68
    LONGLONG           newTime100Ns ;
69
    LONGLONG           oldTime100Ns ;
70
    LONGLONG           counterValue[2];
71
    LONGLONG           oldCounterValue[2];
72
    PPERF_OBJECT_TYPE  perfObject;
73
    unsigned short     nameLength;
74
//    char              *name;
75
	LONGLONG		preservedOldTime100Ns;
76
	#endif
77
	//END WINDOWS ONLY
78
} PerformanceElement_t;
79
80
PerformanceElement_t* all_counters;
81
int all_counters_len;
82
83
int RACGetCounters(PerformanceElement_t** counters, int* counters_len);
84
int RACDestroyCountersArray(PerformanceElement_t* counters, int counters_len);
85
void RACPrintCounters(PerformanceElement_t* counters, int counters_len);
86
void RACSendAvailableCounters();
87
void RACSendCounterData();
88
void RACSetFrequency(int new_freq);
89
int RACGetFrequency();
90
91
//PRIVATE
92
int RACGetPerfNames(char** names);
93
int increaseBufferSize(char** buf, int* buflen);
94
void RACTraceCounters(PerformanceElement_t* counters, int counters_len);
95
int RACTraceStats(BOOL trace_counters);
96
97
//WINDOWS ONLY
98
#ifdef WIN32
99
int RACTracePerfData(PERF_DATA_BLOCK *perfData, XINT64 time, BOOL trace_counters);
100
101
void updateCounters(PerformanceElement_t* _perfElements, PERF_DATA_BLOCK *, PPERF_OBJECT_TYPE perfObj, PPERF_COUNTER_DEFINITION curCntr, PPERF_COUNTER_BLOCK ptrToCntr, BOOL instanceCounter, BOOL firstInstance, BOOL lastCounter);
102
void calculateCounters(PerformanceElement_t* _perfElements, PPERF_OBJECT_TYPE perfObj, PPERF_COUNTER_BLOCK ptrToCntr, char** buf, int* buf_ptr, int* buf_len, BOOL instanceCounter);
103
void calculate(PerformanceElement_t * element, char** buf, int* buf_ptr, int* buf_len);
104
void updatePerformanceElement(PerformanceElement_t* _perfElements,
105
							  PPERF_DATA_BLOCK perfData,
106
                              PPERF_OBJECT_TYPE perfObj,
107
                              PPERF_COUNTER_DEFINITION curCntr,
108
                              PPERF_COUNTER_BLOCK ptrToCntr,
109
                              BOOL instanceCounter, BOOL firstInstance, BOOL lastCounter);
110
#endif
111
//END WINDOWS ONLY
112
113
114
////////////////////////////
115
// RAC Bindings functions
116
////////////////////////////
117
118
typedef RA_AGENT_HANDLE (*ra_initializeBindings_t)(const char *name,
119
                                             const char *type,
120
                                             ra_commandHandler_t handler,
121
											 BOOL standalone);
122
123
typedef TID* (*ra_startListener_t)(RA_AGENT_HANDLE handle,
124
                             char block);
125
126
typedef void (*ra_stopListener_t)(RA_AGENT_HANDLE handle);
127
128
typedef void (*ra_finalizeBindings_t)(RA_AGENT_HANDLE handle);
129
130
typedef void (*ra_sendMessage_t)(RA_AGENT_HANDLE handle,
131
								 ra_message_t *message);
132
133
134
////////////////////////////
135
// RAC DataTransfer functions
136
////////////////////////////
137
138
typedef unsigned char* (*ra_allocateMessageBlock_t)(ra_uint_t length);
139
140
typedef unsigned char* (*ra_reallocateMessageBlock_t)(unsigned char *message, ra_uint_t length);
141
142
typedef void (*ra_freeMessageBlock_t)(unsigned char *message);
143
144
/** WRITE_MESSAGE_BLOCK *************************************************
145
  * DNS - replaced socket parm with target handle struct
146
  * Writes a message to the specified target using the specified format.
147
  * @param  handle - the handle of the target to write the data to.
148
  * @param  format - the format to use
149
  * @param message - the address of the start of the message.
150
  * @param  length - the number of bytes to write to fd.
151
  * @returns       - the number of bytes written to the socket.
152
  */
153
typedef ra_uint_t (*ra_writeMessageBlock_t)(ra_data_target_hdl_t *handle,
154
                                      ra_dataFormat_t format,
155
                                      unsigned char *message,
156
                                      ra_uint_t length);
157
158
/////////////////////////////
159
// RAC Shared memory
160
/////////////////////////////
161
162
typedef ra_shm_err_t (*ra_attachToShm_t)(char *name, ra_shm_handle_t **handle);
163
164
typedef ra_shm_err_t (*ra_stopFlushingShm_t)(ra_shm_handle_t **handle);
165
166
167
/////////////////////////////
168
// RAC Common
169
/////////////////////////////
170
171
typedef void (*ra_setLastError_t)(ra_uint_t major, ra_uint_t minor);
172
173
174
////////////////////////////
175
// Dynamically Loaded RAC functions
176
////////////////////////////
177
178
ra_initializeBindings_t ra_initializeBindings_f;
179
ra_finalizeBindings_t ra_finalizeBindings_f;
180
ra_startListener_t ra_startListener_f;
181
ra_stopListener_t ra_stopListener_f;
182
ra_sendMessage_t ra_sendMessage_f;
183
184
ra_allocateMessageBlock_t ra_allocateMessageBlock_f;
185
ra_reallocateMessageBlock_t ra_reallocateMessageBlock_f;
186
ra_freeMessageBlock_t ra_freeMessageBlock_f;
187
ra_writeMessageBlock_t ra_writeMessageBlock_f;
188
189
ra_attachToShm_t ra_attachToShm_f;
190
ra_stopFlushingShm_t ra_stopFlushingShm_f;
191
192
ra_setLastError_t ra_setLastError_f;
193
194
/***********************************************************************
195
 * EOF
196
 ***********************************************************************/
197
198
#ifdef __cplusplus
199
}
200
#endif
201
202
203
#endif
(-)src-native-new/src/agents/native/java_profiler/agentDebug.c (+85 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: agentDebug.c,v 1.2 2005/02/25 22:17:34 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include "agentDebug.h"
14
#include "JvmpiWriter.h"
15
#include "print.h"
16
17
#ifdef _SHOOTDEBUG
18
19
void jvmpiAgent_dumpStack(ThreadPrivateStorage *tps, char * buffer)
20
{
21
 unsigned long i;
22
 sprintf(buffer, "*****************************INTERNAL_STACK\n");
23
 jvmpiAgent_print(buffer);
24
25
 for (i=0; i < jvmpiAgent_TOS(tps); i++)
26
 {
27
  HashEntry *methodHashEntry = jvmpiAgent_Peek(tps, i)->methodHashEntry;
28
  if (methodHashEntry)
29
  {
30
   jvmpiAgent_printMethod(methodHashEntry->u.methodEntry, buffer);
31
  }
32
 }
33
}
34
35
36
37
void jvmpiAgent_dumpJVMStack(JNIEnv *thread, char * buffer)
38
{
39
 int i,j,tos;
40
 jint depth = 200;
41
 JVMPI_CallTrace *callTraceBuffer = jvmpiAgent_Calloc(sizeof(JVMPI_CallTrace));
42
 ThreadLocalStorage *tps = jvmpiAgent_getThreadLocalStorage(thread, FALSE);
43
44
 sprintf(buffer, "*****************************JVM_STACK   %d FRAMES\n",callTraceBuffer->num_frames);
45
 jvmpiAgent_print(buffer);
46
47
 callTraceBuffer->env_id = thread;
48
 callTraceBuffer->frames = jvmpiAgent_Calloc(depth *sizeof(JVMPI_CallFrame));
49
 _jvmpiAgent_jvmpiInterface->GetCallTrace(callTraceBuffer, depth);
50
51
 tos = jvmpiAgent_TOS(tps);
52
 for (i = 0; i<callTraceBuffer->num_frames; i++)
53
 {
54
  HashEntry *methodHashEntry = jvmpiAgent_FindSymbol(callTraceBuffer->frames[i].method_id, Method_t, FALSE);
55
  if (!methodHashEntry)
56
  {
57
   StackEntry *stackEntry;
58
   jobjectID class_id = _jvmpiAgent_jvmpiInterface->GetMethodClass(callTraceBuffer->frames[i].method_id);
59
   HashEntry *classHashEntry = jvmpiAgent_FindClassSymbol(class_id);
60
   assert(0);
61
   if (!classHashEntry && class_id != 0)
62
   {
63
    REQUEST_EVENT(JVMPI_EVENT_CLASS_LOAD, (void *)class_id);
64
   }
65
   methodHashEntry = jvmpiAgent_FindMethodSymbol(callTraceBuffer->frames[i].method_id);
66
   tos = jvmpiAgent_TOS(tps);
67
   for (j = 0; j < tos; j++)
68
   {
69
	stackEntry = jvmpiAgent_Peek(tps, j);
70
	assert(methodHashEntry == stackEntry->methodHashEntry);
71
   }
72
73
   jvmpiAgent_printMethod(methodHashEntry->u.methodEntry, buffer);
74
  }
75
  else
76
  {
77
   /* This is just a temporary path for debugging purposes. */
78
   /*jobjectID class_id = _jvmpiAgent_jvmpiInterface->GetMethodClass(callTraceBuffer->frames[i].method_id); */
79
   /*assert(class_id && methodHashEntry->u.methodEntry->classEntry->id == (jint)class_id); */
80
   jvmpiAgent_printMethod(methodHashEntry->u.methodEntry, buffer);
81
  }
82
 }
83
}
84
85
#endif  /* _DEBUG */
(-)src-native-new/src/agents/perfmon/WinBuild/rac.mak64 (+370 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on rac.dsp
2
!IF "$(CFG)" == ""
3
CFG=rac - IA64 Release
4
!MESSAGE No configuration specified. Defaulting to rac - IA64 Release.
5
!ENDIF 
6
7
!IF "$(CFG)" != "rac - IA64 Release" && "$(CFG)" != "rac - IA64 Debug" && "$(CFG)" != "rac - X64 Release" && "$(CFG)" != "rac - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "rac.mak64" CFG="rac - IA64 Release"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "rac - IA64 Release"
17
!MESSAGE "rac - IA64 Debug"
18
!MESSAGE "rac - X64 Release"
19
!MESSAGE "rac - X64 Debug"
20
!MESSAGE 
21
!ERROR An invalid configuration is specified.
22
!ENDIF 
23
24
!IF "$(OS)" == "Windows_NT"
25
NULL=
26
!ELSE 
27
NULL=nul
28
!ENDIF 
29
30
!IF  "$(CFG)" == "rac - IA64 Release"
31
32
OUTDIR=..\..\..\..\bin
33
INTDIR=.\Release
34
# Begin Custom Macros
35
OutDir=..\..\..\..\bin
36
# End Custom Macros
37
38
ALL : "$(OUTDIR)\rac.dll"
39
40
41
CLEAN :
42
	-@erase "$(INTDIR)\rac.obj"
43
	-@erase "$(INTDIR)\vc60.idb"
44
	-@erase "$(INTDIR)\version.res"
45
	-@erase "$(OUTDIR)\rac.dll"
46
	-@erase "$(OUTDIR)\..\lib\rac.exp"
47
	-@erase "$(OUTDIR)\..\lib\rac.lib"
48
49
"$(OUTDIR)" :
50
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
51
52
"$(INTDIR)" :
53
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
54
55
CPP=cl.exe
56
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /I "../resutils" /I "../../RABindings" /I "../../../transport/RACommon" /I "../../../transport/RASocket" /I "../../../transport/RADataTransfer" /I "../../../transport/RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAC_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
57
58
.c{$(INTDIR)}.obj::
59
   $(CPP) @<<
60
   $(CPP_PROJ) $< 
61
<<
62
63
.cpp{$(INTDIR)}.obj::
64
   $(CPP) @<<
65
   $(CPP_PROJ) $< 
66
<<
67
68
.cxx{$(INTDIR)}.obj::
69
   $(CPP) @<<
70
   $(CPP_PROJ) $< 
71
<<
72
73
.c{$(INTDIR)}.sbr::
74
   $(CPP) @<<
75
   $(CPP_PROJ) $< 
76
<<
77
78
.cpp{$(INTDIR)}.sbr::
79
   $(CPP) @<<
80
   $(CPP_PROJ) $< 
81
<<
82
83
.cxx{$(INTDIR)}.sbr::
84
   $(CPP) @<<
85
   $(CPP_PROJ) $< 
86
<<
87
88
MTL=midl.exe
89
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
90
RSC=rc.exe
91
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
92
93
LINK32=link.exe
94
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib resutils.lib bufferoverflowU.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\rac.pdb" /out:"$(OUTDIR)\rac.dll" /implib:"$(OUTDIR)\..\lib\rac.lib" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
95
LINK32_OBJS= \
96
	"$(INTDIR)\rac.obj" \
97
	"$(INTDIR)\version.res"
98
99
"$(OUTDIR)\rac.dll" : "$(OUTDIR)" $(LINK32_OBJS)
100
    $(LINK32) @<<
101
  $(LINK32_FLAGS) $(LINK32_OBJS)
102
<<
103
104
!ELSEIF  "$(CFG)" == "rac - IA64 Debug"
105
106
OUTDIR=..\..\..\..\bin
107
INTDIR=.\Debug
108
# Begin Custom Macros
109
OutDir=..\..\..\..\bin
110
# End Custom Macros
111
112
ALL : "$(OUTDIR)\rac.dll"
113
114
115
CLEAN :
116
	-@erase "$(INTDIR)\rac.obj"
117
	-@erase "$(INTDIR)\vc60.idb"
118
	-@erase "$(INTDIR)\version.res"
119
	-@erase "$(OUTDIR)\rac.dll"
120
	-@erase "$(OUTDIR)\..\lib\rac.exp"
121
	-@erase "$(OUTDIR)\..\lib\rac.lib"
122
123
"$(OUTDIR)" :
124
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
125
126
"$(INTDIR)" :
127
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
128
129
CPP=cl.exe
130
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /I "../resutils" /I "../../RABindings" /I "../../../transport/RACommon" /I "../../../transport/RASocket" /I "../../../transport/RADataTransfer" /I "../../../transport/RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAC_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
131
132
.c{$(INTDIR)}.obj::
133
   $(CPP) @<<
134
   $(CPP_PROJ) $< 
135
<<
136
137
.cpp{$(INTDIR)}.obj::
138
   $(CPP) @<<
139
   $(CPP_PROJ) $< 
140
<<
141
142
.cxx{$(INTDIR)}.obj::
143
   $(CPP) @<<
144
   $(CPP_PROJ) $< 
145
<<
146
147
.c{$(INTDIR)}.sbr::
148
   $(CPP) @<<
149
   $(CPP_PROJ) $< 
150
<<
151
152
.cpp{$(INTDIR)}.sbr::
153
   $(CPP) @<<
154
   $(CPP_PROJ) $< 
155
<<
156
157
.cxx{$(INTDIR)}.sbr::
158
   $(CPP) @<<
159
   $(CPP_PROJ) $< 
160
<<
161
162
MTL=midl.exe
163
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
164
RSC=rc.exe
165
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
166
167
LINK32=link.exe
168
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib resutils.lib bufferoverflowU.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\rac.pdb" /out:"$(OUTDIR)\rac.dll" /implib:"$(OUTDIR)\..\lib\rac.lib" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
169
LINK32_OBJS= \
170
	"$(INTDIR)\rac.obj" \
171
	"$(INTDIR)\version.res"
172
173
"$(OUTDIR)\rac.dll" : "$(OUTDIR)" $(LINK32_OBJS)
174
    $(LINK32) @<<
175
  $(LINK32_FLAGS) $(LINK32_OBJS)
176
<<
177
178
!ELSEIF  "$(CFG)" == "rac - X64 Release"
179
180
OUTDIR=..\..\..\..\bin
181
INTDIR=.\Release
182
# Begin Custom Macros
183
OutDir=..\..\..\..\bin
184
# End Custom Macros
185
186
ALL : "$(OUTDIR)\rac.dll"
187
188
189
CLEAN :
190
	-@erase "$(INTDIR)\rac.obj"
191
	-@erase "$(INTDIR)\vc60.idb"
192
	-@erase "$(INTDIR)\version.res"
193
	-@erase "$(OUTDIR)\rac.dll"
194
	-@erase "$(OUTDIR)\..\lib\rac.exp"
195
	-@erase "$(OUTDIR)\..\lib\rac.lib"
196
197
"$(OUTDIR)" :
198
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
199
200
"$(INTDIR)" :
201
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
202
203
CPP=cl.exe
204
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /I "../resutils" /I "../../RABindings" /I "../../../transport/RACommon" /I "../../../transport/RASocket" /I "../../../transport/RADataTransfer" /I "../../../transport/RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAC_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
205
206
.c{$(INTDIR)}.obj::
207
   $(CPP) @<<
208
   $(CPP_PROJ) $< 
209
<<
210
211
.cpp{$(INTDIR)}.obj::
212
   $(CPP) @<<
213
   $(CPP_PROJ) $< 
214
<<
215
216
.cxx{$(INTDIR)}.obj::
217
   $(CPP) @<<
218
   $(CPP_PROJ) $< 
219
<<
220
221
.c{$(INTDIR)}.sbr::
222
   $(CPP) @<<
223
   $(CPP_PROJ) $< 
224
<<
225
226
.cpp{$(INTDIR)}.sbr::
227
   $(CPP) @<<
228
   $(CPP_PROJ) $< 
229
<<
230
231
.cxx{$(INTDIR)}.sbr::
232
   $(CPP) @<<
233
   $(CPP_PROJ) $< 
234
<<
235
236
MTL=midl.exe
237
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
238
RSC=rc.exe
239
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
240
241
LINK32=link.exe
242
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib resutils.lib bufferoverflowU.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\rac.pdb" /out:"$(OUTDIR)\rac.dll" /implib:"$(OUTDIR)\..\lib\rac.lib" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
243
LINK32_OBJS= \
244
	"$(INTDIR)\rac.obj" \
245
	"$(INTDIR)\version.res"
246
247
"$(OUTDIR)\rac.dll" : "$(OUTDIR)" $(LINK32_OBJS)
248
    $(LINK32) @<<
249
  $(LINK32_FLAGS) $(LINK32_OBJS)
250
<<
251
252
!ELSEIF  "$(CFG)" == "rac - X64 Debug"
253
254
OUTDIR=..\..\..\..\bin
255
INTDIR=.\Debug
256
# Begin Custom Macros
257
OutDir=..\..\..\..\bin
258
# End Custom Macros
259
260
ALL : "$(OUTDIR)\rac.dll"
261
262
263
CLEAN :
264
	-@erase "$(INTDIR)\rac.obj"
265
	-@erase "$(INTDIR)\vc60.idb"
266
	-@erase "$(INTDIR)\version.res"
267
	-@erase "$(OUTDIR)\rac.dll"
268
	-@erase "$(OUTDIR)\..\lib\rac.exp"
269
	-@erase "$(OUTDIR)\..\lib\rac.lib"
270
271
"$(OUTDIR)" :
272
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
273
274
"$(INTDIR)" :
275
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
276
277
CPP=cl.exe
278
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /I "../resutils" /I "../../RABindings" /I "../../../transport/RACommon" /I "../../../transport/RASocket" /I "../../../transport/RADataTransfer" /I "../../../transport/RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAC_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
279
280
.c{$(INTDIR)}.obj::
281
   $(CPP) @<<
282
   $(CPP_PROJ) $< 
283
<<
284
285
.cpp{$(INTDIR)}.obj::
286
   $(CPP) @<<
287
   $(CPP_PROJ) $< 
288
<<
289
290
.cxx{$(INTDIR)}.obj::
291
   $(CPP) @<<
292
   $(CPP_PROJ) $< 
293
<<
294
295
.c{$(INTDIR)}.sbr::
296
   $(CPP) @<<
297
   $(CPP_PROJ) $< 
298
<<
299
300
.cpp{$(INTDIR)}.sbr::
301
   $(CPP) @<<
302
   $(CPP_PROJ) $< 
303
<<
304
305
.cxx{$(INTDIR)}.sbr::
306
   $(CPP) @<<
307
   $(CPP_PROJ) $< 
308
<<
309
310
MTL=midl.exe
311
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
312
RSC=rc.exe
313
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
314
315
LINK32=link.exe
316
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib resutils.lib bufferoverflowU.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\rac.pdb" /out:"$(OUTDIR)\rac.dll" /implib:"$(OUTDIR)\..\lib\rac.lib" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
317
LINK32_OBJS= \
318
	"$(INTDIR)\rac.obj" \
319
	"$(INTDIR)\version.res"
320
321
"$(OUTDIR)\rac.dll" : "$(OUTDIR)" $(LINK32_OBJS)
322
    $(LINK32) @<<
323
  $(LINK32_FLAGS) $(LINK32_OBJS)
324
<<
325
326
!ENDIF 
327
328
329
!IF "$(CFG)" == "rac - IA64 Release" || "$(CFG)" == "rac - IA64 Debug" || "$(CFG)" == "rac - X64 Release" || "$(CFG)" == "rac - X64 Debug"
330
SOURCE=..\rac\rac.c
331
332
"$(INTDIR)\rac.obj" : $(SOURCE) "$(INTDIR)"
333
	$(CPP) $(CPP_PROJ) $(SOURCE)
334
335
336
SOURCE=..\rac\version.rc
337
338
!IF  "$(CFG)" == "rac - IA64 Release"
339
340
341
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
342
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "..\rac" /d "NDEBUG" $(SOURCE)
343
344
345
!ELSEIF  "$(CFG)" == "rac - IA64 Debug"
346
347
348
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
349
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "..\rac" /d "NDEBUG" $(SOURCE)
350
351
352
!ELSEIF  "$(CFG)" == "rac - X64 Release"
353
354
355
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
356
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "..\rac" /d "NDEBUG" $(SOURCE)
357
358
359
!ELSEIF  "$(CFG)" == "rac - X64 Debug"
360
361
362
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
363
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "..\rac" /d "NDEBUG" $(SOURCE)
364
365
366
!ENDIF 
367
368
369
!ENDIF 
370
(-)src-native-new/src/agents/native/java_profiler/performance.h (+159 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: performance.h,v 1.4 2006/05/16 22:09:53 bduncan Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef _PERFORMANCE_H_
14
#define _PERFORMANCE_H_
15
16
#include "RAComm.h"
17
18
#if defined __cplusplus
19
 extern "C" {
20
#endif
21
22
#ifdef __cplusplus
23
  #ifdef MVS
24
    #define _inline inline
25
  #endif
26
#endif
27
28
#ifdef _HPUX
29
 #define _inline
30
#elif __linux__
31
 #include <stdint.h>
32
 #define _inline inline
33
#elif _SOLARIS
34
 #define _inline
35
#elif _AIX
36
 #define _inline
37
#elif __OS400__
38
 #define _inline
39
#endif
40
41
#ifdef _SOLARIS
42
 #ifndef _UINT64_T
43
  #define _UINT64_T
44
  typedef unsigned long long uint64_t;
45
 #endif
46
#endif
47
48
#ifdef _WIN32
49
 typedef unsigned __int64  Uint64;
50
#else
51
 #ifdef MVS
52
  /* 189110 - uint64_t is now defined on MVS but not as long long so we won't use it here */
53
  typedef unsigned long long Uint64;
54
 #elif __OS400__
55
  typedef unsigned long long Uint64;
56
 #elif _HPUX
57
   typedef unsigned long long Uint64;
58
 #else
59
  typedef uint64_t Uint64;
60
 #endif
61
#endif
62
63
64
/* typedef int	*atomic_p; */
65
66
/** The goal of this file is to define some inline performance code
67
  * for doing metrics on each of the processors supported.
68
  */
69
typedef Uint64 timestamp_t;
70
71
extern unsigned int _ticksPerMicrosecond;
72
extern double       _startTimeAsDouble;
73
extern timestamp_t  _startTimeAsTicks;
74
extern timestamp_t _startTime;
75
76
extern void determineTicksPerMicrosecond(int *bogus);
77
78
79
static _inline timestamp_t timeToTicks(Uint64 seconds, Uint64 microsecondsRemainder) {
80
  timestamp_t ticks;
81
  Uint64 microseconds = seconds;
82
  microseconds *= 1000000;
83
  microseconds += microsecondsRemainder;
84
85
  ticks =  microseconds * _ticksPerMicrosecond;
86
  return ticks;
87
}
88
89
static _inline double ticksToTime2(timestamp_t timestampInTicks, BOOL asInterval) {
90
  double microseconds = (double)(
91
#ifdef WIN32
92
				 (__int64)
93
#endif /* WIN32 */
94
				 timestampInTicks) / _ticksPerMicrosecond;
95
  if(asInterval) {
96
    return microseconds/1000000;
97
  }
98
  else {
99
    return microseconds/1000000 + _startTimeAsDouble;
100
  }
101
}
102
#define TIMESTAMP_GREATER(A,B) ((A)>(B))
103
#define TIMESTAMP_ADD(A,B) A=(A)+(B)
104
#define TIMESTAMP_ZERO(A) (*(A)) = 0
105
static _inline timestamp_t TIMESTAMP_SUB(timestamp_t A, timestamp_t B) {
106
  return A-B;
107
}
108
109
110
/** COLLECT_START_TIME_INFORMATION  *******************************************
111
  * Initialization routine for future use of jvmpiAgent_getCurrentTime().
112
  * This routine records the time at which this function was called and uses
113
  * this time to determine what the current time is.
114
  */
115
extern void jvmpiAgent_collectStartTimeInformation();
116
117
/* GET_START_TIME  ************************************************************
118
 * Returns a copy of the start time that was recorded with
119
 * jvmpiAgent_collectStartTimeInformation
120
 */
121
extern void jvmpiAgent_getStartTime(timestamp_t *time);
122
123
/* GET_CURRENT_TIME  **********************************************************
124
 * Determins the current clock time and fills the timestamp_t structure
125
 * with the data
126
 */
127
extern void jvmpiAgent_getCurrentTime(timestamp_t *time);
128
129
/** GET_CURRENT_THREAD_CPU_TIME  ***********************************************
130
  * Returns the amount of CPU time consumed by this thread as a 64 bit number.
131
  */
132
extern Uint64 jvmpiAgent_getCurrentThreadCPUTime();
133
134
/** GET_PROCESS_START_TIME  ***************************************************
135
  *  Returns the start time of the current process as a timestamp_t in UTC time.
136
  */
137
extern void jvmpiAgent_getProcessStartTime(timestamp_t *time);
138
139
/** GET_TIMEZONE  *************************************************************
140
  * Returns the current timezone as an offset, in minutes, working westward from
141
  * GMT.  ie.  GMT+5  would be 300 as there are 300 minutes in 5 hours.
142
  */
143
extern unsigned long jvmpiAgent_getTimezone();
144
145
/*********************************************************
146
 * DEBUG assists:
147
 */
148
#if defined(_DEBUG) && !defined (MVS) && !defined (__OS400__)
149
extern void debug_check_and_report_time_overflow(timestamp_t time, char *errMsg);  /* 134577 */
150
#define DBG_CHK_AND_REPORT_TIME_OVERFLOW(A,B) debug_check_and_report_time_overflow(A,B)
151
#else
152
#define DBG_CHK_AND_REPORT_TIME_OVERFLOW(A,B) 
153
#endif
154
155
#if defined __cplusplus
156
}
157
#endif
158
159
#endif
(-)src-native-new/src/agents/perfmon/rac/rac.c (+610 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: rac.c,v 1.14 2006/05/24 16:39:20 gchristelis Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
#ifdef WIN32
14
	#include <winsock2.h> /* Bug 134924 */
15
#endif
16
#include "rac.h"
17
#include "system.h"
18
#include "hashtable.h"
19
20
int available = 0;
21
int monitoring = 0;
22
23
unsigned char* msg_block;
24
int msg_block_len;
25
26
XLibrary rac_hcbnd;
27
XLibrary rac_hccldt;
28
XLibrary rac_hccls;
29
XLibrary rac_hcclsm;
30
XLibrary rac_hcjbnd;
31
XLibrary rac_hcclco;
32
33
//ra_commandHandler_t command_handler;
34
ra_data_target_hdl_t targetHdl;
35
36
RA_AGENT_HANDLE agent_handle;
37
TID* agent_tid;
38
39
PerformanceElement_t* counters;
40
int counters_len = -1;  //-1 = uninitialised
41
42
static memoryleak = 0;
43
static int first = 0;
44
45
char* agent_type;
46
47
int VERBOSE = FALSE;
48
int LOG_TO_FILE = FALSE;
49
50
////////////////////////////
51
// PERFMON SPECIFIC STUFF
52
////////////////////////////
53
HashTable* perf_filters;
54
HashTable* perf_variables;
55
HashTable* perf_tree;
56
////////////////////////////
57
// END PERFMON SPECIFIC STUFF
58
////////////////////////////
59
60
char digits[] = {
61
'0' , '1' , '2' , '3' , '4' , '5' ,
62
'6' , '7' , '8' , '9' , 'a' , 'b' ,
63
'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
64
'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
65
'o' , 'p' , 'q' , 'r' , 's' , 't' ,
66
'u' , 'v' , 'w' , 'x' , 'y' , 'z'
67
};
68
69
static FILE* f = NULL;
70
71
static char filename[] = "RACDll.log";
72
73
void logToFile(const char*, ...);
74
75
void logToFile(const char* temp, ...)
76
{
77
	if (!VERBOSE)
78
		return;
79
	if (LOG_TO_FILE)
80
	{
81
		va_list ap;
82
		if (f == NULL)
83
			f = fopen(filename,  "w");
84
		va_start (ap, temp);
85
		vfprintf (f, temp, ap);
86
//		printf(temp,ap);
87
		va_end (ap);
88
		fflush(f);
89
	}
90
}
91
92
void longToString(XINT64 i, char* str) {
93
	int radix = 10;
94
	char buf[65];
95
96
	int charPos = 64;
97
	int negative = (i < 0);
98
99
	if (!negative) {
100
	    i = -i;
101
	}
102
103
	while (i <= -radix) {
104
	    buf[charPos--] = digits[(int)(-(i % radix))];
105
	    i = i / radix;
106
	}
107
	buf[charPos] = digits[(int)(-i)];
108
109
	if (negative) {
110
	    buf[--charPos] = '-';
111
	}
112
113
	memcpy(str,&(buf[charPos]),(65 - charPos));
114
}
115
116
int StrEq(char* a, char* b) {
117
	int index = 0;
118
	char ch_a, ch_b;
119
120
	if (a == NULL) {
121
		return -1;
122
	} else if (b == NULL) {
123
		return -1;
124
	}
125
126
	while (0==0) {
127
		ch_a = a[index];
128
		ch_b = b[index];
129
130
		if (ch_a != ch_b) return index+1;
131
132
		//could get rid of the OR here?
133
		if (ch_a == '\0' || ch_b == '\0') {
134
			return 0;
135
		}
136
137
		index++;
138
	}
139
}
140
141
void handle(char* type, char* name, char* value)
142
{
143
	char* tmp;
144
	int len = strlen(value);
145
	//
146
	// This is how the filtering will work
147
	//
148
	logToFile("Received a RA_SET_NAME_VALUE_PAIR event, type %s, name %s, value %s\n", type, name, value);
149
150
151
	if (StrEq(type,"filter") == 0) {
152
		//this is a filter request
153
154
		if (StrEq(value,"true") == 0) {
155
			tablePut(perf_filters,name,(XINT64)1);
156
		} else {
157
			tablePut(perf_filters,name,(XINT64)NULL);
158
		}
159
160
		logToFile("FILTER REQUEST %s, %s (%d filters in place)\n",name,value,perf_filters->count);
161
162
	} else if (StrEq(type,"updatetree") == 0) {
163
164
		logToFile("Requested children of tree node %s\n", name);
165
166
		tablePut(perf_variables,DC_KEY_TREE_REQUESTED,TRUE);
167
		if (name == NULL)
168
			tablePut(perf_tree,"",1);
169
		else
170
			tablePut(perf_tree,name,1);
171
172
	} else if (StrEq(type,"var_int") == 0) {
173
174
		tablePut(perf_variables,name,atoi(value));
175
176
	} else if (StrEq(type,"var_boolean") == 0) {
177
178
		if (StrEq(value,"true") == 0) {
179
			tablePut(perf_variables,name,DC_VAL_TRUE);
180
		} else {
181
			tablePut(perf_variables,name,DC_VAL_FALSE);
182
		}
183
184
	} 
185
	else if (StrEq(type,"var_string") == 0) 
186
	{
187
		tmp = (char*)tableGet(perf_variables,name);
188
		if (tmp != NULL) free(tmp);
189
190
		//convert string NULL to actual NULL
191
		if (StrEq(value,"NULL") == 0 || StrEq(value,"null") == 0) {
192
			logToFile("FOUND NULL STRING %s\n",value);
193
			tmp = NULL;
194
		} else {
195
			logToFile("FOUND NON-NULL STRING %s\n",value);
196
			tmp = (char*)malloc(sizeof(char) * (len + 2));
197
			memcpy(tmp,value,len);
198
			tmp[len] = '\0';
199
		}
200
201
		tablePut(perf_variables,name,(XINT64)tmp);
202
203
	} else {
204
205
		logToFile("ERROR - UNRECOGNISED SETENV TYPE %s\n",type);
206
207
	}
208
}
209
210
void RACCommandHandler(ra_command_t *command) {
211
	int ret = 0;
212
213
	logToFile("RAC Command %08X\n",command->tag);
214
215
	switch (command->tag) {
216
	case RA_START_MONITORING_AGENT_LOCAL:
217
	case RA_START_MONITORING_AGENT_REMOTE:
218
		{
219
			monitoring = 1;
220
221
			targetHdl.dtarget = RA_SHAREDMEMORY;
222
223
			if (first == 0)
224
			{
225
				ret = (*ra_attachToShm_f)(command->info.start_monitor_local.file.data, &targetHdl.dtargetHdl.shmHdl);
226
				first = 1;
227
			}
228
229
			tablePut(perf_variables,DC_KEY_MONITORING,(XINT64)DC_VAL_TRUE);
230
231
			logToFile("RAC Agent Started Monitoring (%d)\n",ret);
232
233
			break;
234
		}
235
	case RA_STOP_MONITORING_AGENT:
236
		{
237
			monitoring = 0;
238
239
			tablePut(perf_variables,DC_KEY_MONITORING,(XINT64)DC_VAL_FALSE);
240
241
			logToFile("RAC Agent Stopped Monitoring\n");
242
			break;
243
		}
244
	case RA_ATTACH_TO_AGENT:
245
		{
246
			logToFile("RAC attach agent\n");
247
248
			// RA_ATTATCH_TO_AGENT never seems to get called. Therefore, I have changed start and stop monitoring to
249
			// reflect this befaviour.
250
/*
251
			targetHdl.dtarget = RA_SHAREDMEMORY;
252
253
			if (sharingmemory == 0)
254
			{
255
				ret = (*ra_attachToShm_f)(command->info.start_monitor_local.file.data, &targetHdl.dtargetHdl.shmHdl);
256
				sharingmemory = 1;
257
			}
258
259
			logToFile("RAC attach agent\n");
260
*/
261
			break;
262
263
		}
264
	case RA_DETACH_FROM_AGENT:
265
		{
266
//			tablePut(perf_variables,DC_KEY_FINISHED,(XINT64)DC_VAL_FALSE);
267
268
            if(targetHdl.dtarget == RA_SHAREDMEMORY) 
269
               ret = (*ra_stopFlushingShm_f)(&targetHdl.dtargetHdl.shmHdl);
270
			first = 0;
271
// Bug 131140
272
			tableClear(perf_tree);
273
			tableClear(perf_filters);
274
275
276
			logToFile("RAC detach agent (%d)\n",ret);
277
			break;
278
		}
279
	case RA_AGENT_CONTROLER_AVAILABLE:
280
		{
281
			available = 1;
282
			logToFile("RAC Agent Controller available\n");
283
			break;
284
		}
285
	case RA_AGENT_CONTROLER_UNAVAILABLE:
286
		{
287
		    // Bug 99153
288
			if (available == 1)
289
				tablePut(perf_variables,DC_AGENT_CONTROLLER_STOPPED,(XINT64)DC_VAL_TRUE);
290
		    // End Bug 99153
291
			available = 0;
292
			logToFile("RAC Agent Controller unavailable\n");
293
			break;
294
		}
295
    case RA_SET_NAME_VALUE_PAIR:
296
		{
297
			char* type = command->info.set_nv_pair.type.data;
298
			char* name = command->info.set_nv_pair.name.data;
299
			char* value = command->info.set_nv_pair.value.data;
300
301
			handle(type,name,value);
302
			break;
303
		}
304
	case RA_CUSTOM_COMMAND:
305
		{
306
			char valid = 1;
307
			int i;
308
			char ch;
309
310
			char* type;
311
			char* name; 
312
			char* value;
313
314
			type = command->info.custom_command.message.data;			
315
			if (StrEq(type,"RESUME") == 0 || StrEq(type,"APPLYFILTERS") == 0 || StrEq(type,"TRACE_OBJECTS") == 0 || (StrEq(type,"ENABLE") == 0))
316
				return;
317
318
			for (i = 0; TRUE; i++) 
319
			{
320
				ch = type[i];
321
				if (ch == 30) 
322
				{
323
					type[i] = '\0';
324
					name = &type[i+1];
325
					break;
326
				} 
327
				else if (ch == '\0')
328
				{
329
					valid = 0;
330
					break;
331
				}
332
			}
333
334
			for (i = 0; TRUE; i++) 
335
			{
336
				if (valid == 0)
337
					break;
338
				ch = name[i];
339
				if (ch == 30) 
340
				{
341
					name[i] = '\0';
342
					value = &name[i+1];
343
					break;
344
				} 
345
			}
346
347
			if (valid == 0)
348
			{
349
				logToFile("Received a invalid RA_CUSTOM_COMMAND, data=%s\n",command->info.custom_command.message.data);			
350
			}
351
			else
352
			{
353
				logToFile("Received a RA_CUSTOM_COMMAND event, type = %s, name=%s, value=%s\n",type,name,value);				
354
				handle(type,name,value);
355
			}
356
			break;
357
		}
358
	default:
359
			logToFile("Unhandled RAC Command %08X\n",command->tag);
360
	}
361
}
362
363
int RACLoadRacLibs() {
364
	int ret = 0;
365
	if ((ret = XLibraryCreate(&rac_hcbnd,"hcbnd")) != 0) {
366
		logToFile("Error loading RAC Bindings library\n");
367
		return ret;
368
	}
369
	if ((ret = XLibraryCreate(&rac_hccldt,"hccldt")) != 0) {
370
		logToFile("Error loading RAC Data Transfer library\n");
371
		return ret;
372
	}
373
	if ((ret = XLibraryCreate(&rac_hccls,"hccls")) != 0) {
374
		logToFile("Error loading RAC Socket library\n");
375
		return ret;
376
	}
377
	if ((ret = XLibraryCreate(&rac_hcjbnd,"hcjbnd")) != 0) {
378
		logToFile("Error loading RAC HCJ bindings library\n");
379
		return ret;
380
	}
381
	if ((ret = XLibraryCreate(&rac_hcclsm,"hcclsm")) != 0) {
382
		logToFile("Error loading RAC shared memory library\n");
383
		return ret;
384
	}
385
	if ((ret = XLibraryCreate(&rac_hcclco,"hcclco")) != 0) {
386
		logToFile("Error loading RAC Common library\n");
387
		return ret;
388
	}
389
	return 0;
390
}
391
392
int RACGetRacFuncs() {
393
	int ret = 0;
394
395
	if ((ret = XLibrarySymbol(&rac_hcbnd,"ra_initializeBindings",(void**)&ra_initializeBindings_f)) != 0) {
396
		logToFile("Error getting ra_initializeBindings symbol\n");
397
		return ret;
398
	}
399
	if ((ret = XLibrarySymbol(&rac_hcbnd,"ra_startListener",(void**)&ra_startListener_f)) != 0) {
400
		logToFile("Error getting ra_startListener symbol\n");
401
		return ret;
402
	}
403
	if ((ret = XLibrarySymbol(&rac_hcbnd,"ra_stopListener",(void**)&ra_stopListener_f)) != 0) {
404
		logToFile("Error getting ra_stopListener symbol\n");
405
		return ret;
406
	}
407
	if ((ret = XLibrarySymbol(&rac_hcbnd,"ra_finalizeBindings",(void**)&ra_finalizeBindings_f)) != 0) {
408
		logToFile("Error getting ra_finalizeBindings symbol\n");
409
		return ret;
410
	}
411
	if ((ret = XLibrarySymbol(&rac_hcbnd,"ra_sendMessage",(void**)&ra_sendMessage_f)) != 0) {
412
		logToFile("Error getting ra_sendMessage symbol\n");
413
		return ret;
414
	}
415
416
	if ((ret = XLibrarySymbol(&rac_hccldt,"ra_allocateMessageBlock",(void**)&ra_allocateMessageBlock_f)) != 0) {
417
		logToFile("Error getting ra_allocateMessageBlock symbol\n");
418
		return ret;
419
	}
420
	if ((ret = XLibrarySymbol(&rac_hccldt,"ra_freeMessageBlock",(void**)&ra_freeMessageBlock_f)) != 0) {
421
		logToFile("Error getting ra_freeMessageBlock symbol\n");
422
		return ret;
423
	}
424
	if ((ret = XLibrarySymbol(&rac_hccldt,"ra_writeMessageBlock",(void**)&ra_writeMessageBlock_f)) != 0) {
425
		logToFile("Error getting ra_writeMessageBlock symbol\n");
426
		return ret;
427
	}
428
429
	if ((ret = XLibrarySymbol(&rac_hcclsm,"ra_attachToShm",(void**)&ra_attachToShm_f)) != 0) {
430
		logToFile("Error getting ra_attachToShm symbol\n");
431
		return ret;
432
	}
433
	if ((ret = XLibrarySymbol(&rac_hcclsm,"ra_stopFlushingShm",(void**)&ra_stopFlushingShm_f)) != 0) {
434
		logToFile("Error getting ra_stopFlushingShm symbol\n");
435
		return ret;
436
	}
437
	
438
	if ((ret = XLibrarySymbol(&rac_hcclco,"ra_setLastError",(void**)&ra_setLastError_f)) != 0) {
439
		logToFile("Error getting ra_setLastError symbol\n");
440
		return ret;
441
	}
442
	return 0;
443
}
444
445
int RACInitBindings() 
446
{
447
	XINT64 clock;
448
449
	char agent_name[256];
450
	char agent_time[256];
451
	
452
	XClockMillis(&clock);
453
454
	memset(agent_name,'\0',256);
455
	memset(agent_time,'\0',256);
456
457
	longToString(clock,agent_time);
458
//	XSNPrintf(agent_name,255,"%s - %s",agent_type,agent_time);
459
	XSNPrintf(agent_name,255,"%s",agent_type);
460
	
461
	logToFile("Connecting to RAC - %s\n",agent_name);
462
463
	agent_handle =  (*ra_initializeBindings_f)(agent_name,"Statistical",RACCommandHandler,FALSE);
464
	if (agent_handle == NULL) {
465
466
		logToFile("Error initializing RAC bindings\n");
467
		return -1;
468
	}
469
470
	return 0;
471
}
472
473
int RACFiniBindings() {
474
	(*ra_finalizeBindings_f)(agent_handle);
475
	return 0;
476
}
477
478
479
int RACStartListener() {
480
	agent_tid = (*ra_startListener_f)(agent_handle,0);
481
	return 0;
482
}
483
484
int RACStopListener() {
485
	(*ra_stopListener_f)(agent_handle);
486
	return 0;
487
}
488
489
int RACAllocateMessageBlock(int siz) {
490
	msg_block = (*ra_allocateMessageBlock_f)(siz);
491
	msg_block_len = siz;
492
	if (msg_block == NULL) {
493
		msg_block_len = 0;
494
		return -1;
495
	}
496
	return 0;
497
}
498
499
int RACReallocateMessageBlock(int siz) {
500
	int ret = 0;
501
	(*ra_freeMessageBlock_f)(msg_block);
502
	if ((ret = RACAllocateMessageBlock(siz)) != 0) {
503
		msg_block_len = 0;
504
		return -1;
505
	}
506
	msg_block_len = siz;
507
	return 0;
508
}
509
510
int RACFreeMessageBlock() {
511
	(*ra_freeMessageBlock_f)(msg_block);
512
	return 0;
513
}
514
515
int DC_TransferSetAgentName(char* name)
516
{
517
	logToFile("Setting the agent name is the transfer DLL to %s\n",name);
518
	agent_type = name;
519
	return 0;
520
}
521
	
522
int DC_TransferStartup(HashTable* variables,
523
					   HashTable* filters,
524
					   HashTable* tree
525
					   ) {
526
	int ret = 0;
527
528
	perf_filters = filters;
529
	perf_variables = variables;
530
	perf_tree = tree;
531
532
	logToFile("Loading RAC libraries\n");
533
	if ((ret = RACLoadRacLibs()) != 0) {
534
		return ret;
535
	}
536
	logToFile("Getting RAC functions\n");
537
	if ((ret = RACGetRacFuncs()) != 0) {
538
		return ret;
539
	}
540
	logToFile("Initializing RAC bindings\n");
541
	if ((ret = RACInitBindings()) != 0) {
542
		return ret;
543
	}
544
	logToFile("Starting RAC listener\n");
545
	if ((ret = RACStartListener()) != 0) {
546
		return ret;
547
	}
548
	logToFile("Allocating message block\n");
549
	if ((ret = RACAllocateMessageBlock(1024)) != 0) {
550
		return ret;
551
	}
552
553
	logToFile("RAC Startup succesful\n");
554
	return 0;
555
}
556
557
int RACIsMonitoring() 
558
{
559
	return monitoring == 1;
560
}
561
562
int DC_SendMessage(char* msg, int off, int len) 
563
{
564
	//check the length and reallocate the message block if necessary
565
	if (len > msg_block_len-1) 
566
	{
567
		RACReallocateMessageBlock(len+1);
568
		len = msg_block_len-1;
569
	} 
570
571
	if (len == 0)
572
		return 0;
573
574
	//copy the message data over to the message block
575
	memset(msg_block,'\0',msg_block_len);
576
	memcpy(msg_block,&(msg[off]),len);
577
	msg_block[len] = '\0';
578
579
	//check if the agent is listening etc
580
	if (available != 1) 
581
	{
582
		return -1;
583
	}
584
585
	if (monitoring != 1) 
586
	{
587
		return -1;
588
	}
589
590
	logToFile("Sending message back...\n");
591
592
	//then just use ra_sendMessage
593
	(*ra_writeMessageBlock_f)(&targetHdl,RA_UTF8_STRING_DATA,msg_block,len);
594
595
	return 0;
596
}
597
598
int DC_TransferShutdown() {
599
	int ret = 0;
600
	logToFile("Stopping RAC Listener\n");
601
	if ((ret = RACStopListener()) != 0) {
602
		return ret;
603
	}
604
	logToFile("Finalising RAC bindings\n");
605
	if ((ret = RACFiniBindings()) != 0) {
606
		return ret;
607
	}
608
	return 0;
609
}
610
(-)src-native-new/src/agents/perfmon/resutils/hashtable.h (+60 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: hashtable.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef __HASHTABLE_H__
14
#define __HASHTABLE_H__
15
16
#include "system.h"
17
18
#ifdef __cplusplus
19
extern "C" {
20
#endif
21
22
//
23
// Hashtable collision list (user doesnt need to care about these - they're private)
24
//
25
typedef struct {
26
	long int hash;
27
	char* key;
28
	XINT64 value;
29
	void* next;
30
} Entry;
31
32
//
33
// Hashtable struct
34
//
35
typedef struct {
36
	Entry**	table;
37
	int table_len;
38
	int count;
39
	int threshold;
40
	XMutex mutex;
41
42
} HashTable;
43
44
BOOL containsKey(HashTable* table, char* key);
45
int tableKeysAsList(HashTable* table, char** list, int list_size);
46
HashTable* tableCreate();
47
void tableDelete(HashTable* hasht);
48
void tableClear(HashTable* hasht);
49
void tableFree(HashTable* hasht);		//frees all the entry values in a table
50
int tableSize(HashTable* hasht);
51
XINT64 tableGet(HashTable* hasht, char* key);
52
void tableRehash(HashTable* hasht);
53
void tableRemove(HashTable* hasht, char* key);
54
XINT64 tablePut(HashTable* hasht, char* key, XINT64 value);
55
long int getHash(char* key);
56
57
#ifdef __cplusplus
58
}
59
#endif
60
#endif
(-)src-native-new/src/agents/native/java_profiler/performance.c (+571 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: performance.c,v 1.12 2006/11/06 23:11:30 bduncan Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifdef _WIN32
14
#include <winsock2.h> /* Bug 134924 */
15
#include <windows.h>
16
#include <time.h>
17
#include <sys/timeb.h>
18
#include <sys/types.h>
19
#ifdef _M_IA64
20
#include <ia64reg.h>
21
#endif
22
#else
23
 #ifdef _AIX
24
  #include <sys/atomic_op.h>
25
  #include <sys/systemcfg.h>
26
 #elif __linux__
27
 	#if defined __i386__
28
		#include <asm/system.h>
29
 	#elif defined __s390__ || defined __powerpc64__
30
		#include <asm/atomic.h>
31
 	#endif
32
 #elif __OS400__
33
  #include <mih/cmpswp.h>
34
  #include <mih/mattod.h>                                            
35
 #else
36
 #endif
37
38
 #include <sys/time.h>
39
 #ifdef __OS400__
40
  #define TIMEB time_t
41
  #define FTIME(param) time(param)
42
 #else
43
  #include <sys/timeb.h>
44
 #endif
45
 #include <unistd.h>
46
#endif
47
48
#include <stdio.h>
49
50
#include "performance.h"
51
#include "RABindings.h"
52
#include "JvmpiWriter.h" 
53
54
#ifdef _WIN32									/* _WIN32 */
55
#define TIMEB  struct _timeb
56
#define FTIME(param)  _ftime(param)
57
#else											/* else */
58
#define TIMEB	struct timeb
59
#define FTIME(param)  ftime(param)
60
#endif											/* endif */
61
62
63
timestamp_t _startTime;
64
65
unsigned int _ticksPerMicrosecond;
66
double       _startTimeAsDouble;
67
timestamp_t  _startTimeAsTicks;
68
69
#if defined (_WIN32)  /* bug 160511 */
70
BOOL         _highResPerfAvailable=FALSE; /* high-resolution performance counter if facility available*/
71
unsigned int _tickBooster;                /* boosts tick frequency to at least 100 per microsec (3-digit accuracy) */
72
#endif
73
74
#ifdef MVS
75
#pragma option_override(determineTicksPerMicrosecond, "OPT(LEVEL, 0)")
76
#endif
77
78
void determineTicksPerMicrosecond(int *boggie)
79
{
80
#if defined (_WIN32) /* bug 160511 start */ 
81
	LARGE_INTEGER liHighResTicksPerSec; /* actual ticks per sec if high resolution performance counter available */
82
	if (QueryPerformanceFrequency(&liHighResTicksPerSec)) { 
83
		double exactTicksPerMicrosecond; /* exact ticks per microsecond (possibly with fractional part)*/
84
		
85
		_highResPerfAvailable=TRUE;
86
		exactTicksPerMicrosecond=liHighResTicksPerSec.QuadPart/1000000.0;
87
		
88
		/* Need to simulate an integral MHz tick rate with at least 3-digit accuracy for consistency with other 
89
		 * platforms. Calculate _tickBooster as multiplier that pushes both _ticksPerMicrosecond and the actual
90
		 * tick count obtained later into the right range.
91
		 */
92
		if (exactTicksPerMicrosecond < 1.0) { 
93
			_tickBooster=(unsigned int)(1+100.0/exactTicksPerMicrosecond); 
94
		} else if (exactTicksPerMicrosecond < 10.0) {
95
			_tickBooster=100;	
96
		} else if (exactTicksPerMicrosecond < 100.0) {
97
			_tickBooster=10;	
98
		} else {
99
			_tickBooster=1;	
100
		}
101
		/* _ticksPerMicrosecond will be recorded as a boosted rate via multiplication by _tickBooster.
102
		 * Actual ticks measured at jvmpiAgent_getCurrentTime will be equally boosted so it all works out.
103
		 */
104
		_ticksPerMicrosecond=(unsigned int)(_tickBooster*exactTicksPerMicrosecond);
105
#if defined(_DEBUG) && !defined (MVS) && !defined (__OS400__) 
106
		printf("Using high res perf counter: highResTicksPerSec=%I64d, exactTicksPerMicrosecond=%f, _tickBooster=%d, _ticksPerMicrosecond=%d \n",
107
				liHighResTicksPerSec.QuadPart, exactTicksPerMicrosecond, _tickBooster, _ticksPerMicrosecond);
108
#endif				
109
	} else {         /* bug 160511 end */
110
		HKEY    handle;
111
		DWORD   error;
112
		DWORD	valueType;
113
		DWORD   valueLength=4;
114
		char *valueName="~Mhz";
115
		char *key="HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0";
116
		unsigned long cpuMhz;
117
	
118
		error=RegOpenKeyEx(HKEY_LOCAL_MACHINE,	/* Registery tree */
119
						   key,					/* Key to look up */
120
						   0,					/* Reserved, must be 0 */
121
						   KEY_READ,			/* READ mode */
122
						   &handle);			/* Handle to the key */
123
		if(error!=ERROR_SUCCESS) {
124
			printf("Error opening CPU speed key 0x%x\n", error);
125
			fflush(stdout); 
126
		}
127
	
128
		error=RegQueryValueEx(handle,				/* Handle to the key */
129
							  valueName,			/* Value to query */
130
							  NULL,					/* Reserved, must be NULL */
131
							  &valueType,			/* Type of value */
132
							  (char*)&cpuMhz,		/* The result of the query */
133
							  &valueLength);		/* Length of the data */
134
	
135
	
136
		if(error!=ERROR_SUCCESS) {
137
			printf("Error getting CPU speed 0x%x\n", error);
138
			fflush(stdout); 
139
		}
140
		RegCloseKey(handle);
141
		_ticksPerMicrosecond=cpuMhz;
142
	}
143
144
#elif defined (__OS400__)
145
    /* There is always 4096 ticks per microsecond on AS400 */
146
    _ticksPerMicrosecond=4096;
147
#else
148
149
  volatile int j;
150
  volatile unsigned int ticks_per_microsecond = 0;
151
  volatile int A[4003];
152
153
  timestamp_t now;
154
  timestamp_t a,b,c,start;
155
  unsigned int jvmpiAgent_getCurrentTime_overhead;
156
  const int MM=10000;
157
158
  jvmpiAgent_getCurrentTime(&a);
159
  jvmpiAgent_getCurrentTime(&a);
160
  start = a;
161
  jvmpiAgent_getCurrentTime(&a);
162
  c = 0;
163
  for(j=0; j<MM; j++) {
164
    jvmpiAgent_getCurrentTime(&c);
165
  }
166
  jvmpiAgent_getCurrentTime(&b);
167
  jvmpiAgent_getCurrentTime_overhead = (unsigned int)(b-a)/MM;
168
169
  {
170
    unsigned int interval_microseconds;
171
    volatile unsigned int total = 0;
172
    timestamp_t start_ticks, end_ticks;
173
    const int M = 3;
174
    const int N = 2003;
175
    A[5] = 5; A[15] = 10;
176
    for(j=0; j<M; j++) {
177
      struct timeval start_clock, end_clock, interval_clock;
178
      gettimeofday(&start_clock, NULL);
179
      jvmpiAgent_getCurrentTime(&now);
180
      start_ticks = now-start;
181
182
      {
183
         int i,k=1, l=1;
184
         for(i=0; i<N; i++) {
185
            for(l=1; l<N; l++) {
186
               k += (i*i)/k/l;
187
            }
188
         }
189
         for(i=1; i<N; i++) {
190
            k += (i*i+i*2)/i ;
191
         }
192
      }
193
194
      jvmpiAgent_getCurrentTime(&now);
195
      end_ticks   = now-start;
196
      gettimeofday(&end_clock, NULL);
197
198
# define timersub(a, b, result)						      \
199
  do {									      \
200
    (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;			      \
201
    (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;			      \
202
    if ((result)->tv_usec < 0) {					      \
203
      --(result)->tv_sec;						      \
204
      (result)->tv_usec += 1000000;					      \
205
    }									      \
206
  } while (0)
207
208
      timersub(&end_clock, &start_clock, &interval_clock);
209
      {
210
         timestamp_t foo = interval_clock.tv_sec;
211
         foo *= 1000000;
212
         foo += interval_clock.tv_usec;
213
         interval_microseconds = (unsigned int)foo;
214
      }
215
216
      {
217
         unsigned int tick_interval = (unsigned int)(end_ticks-start_ticks);
218
         double temp = (1.0f * tick_interval)/interval_microseconds;
219
         unsigned int this_one      = (unsigned int) ( temp < 1 ? 1 : temp );
220
221
         total += this_one;
222
         if(this_one > ticks_per_microsecond) {
223
            ticks_per_microsecond = this_one;
224
         }
225
      }
226
    }
227
228
    ticks_per_microsecond = total/M;
229
  }
230
231
  *boggie = A[5]+A[15];
232
  _ticksPerMicrosecond = ticks_per_microsecond;
233
#endif
234
}
235
236
237
/** COLLECT_START_TIME_INFORMATION  ****************************************
238
  * Initialization routine for future use of jvmpiAgent_getCurrentTime().
239
  * This routine records the time at which this function was called and uses
240
  * this time to determine what the current time is.
241
  */
242
void jvmpiAgent_collectStartTimeInformation() {
243
#ifdef _WIN32
244
	TIMEB   time;
245
	
246
	FTIME(&time);
247
	_startTime=timeToTicks(time.time, time.millitm*1000);
248
249
#else
250
	{
251
	  struct timeval tv;
252
	  gettimeofday(&tv, NULL);
253
	  _startTime  = timeToTicks(tv.tv_sec, tv.tv_usec);
254
	}
255
#endif
256
	jvmpiAgent_getCurrentTime(&_startTimeAsTicks);
257
   if(_startTime < _startTimeAsTicks) {
258
       _startTimeAsDouble = -ticksToTime2(_startTimeAsTicks-_startTime, TRUE);
259
   }
260
   else {
261
       _startTimeAsDouble = ticksToTime2(_startTime-_startTimeAsTicks, TRUE);
262
   }
263
}
264
265
266
/* GET_START_TIME  ********************************************************
267
 * Returns a copy of the start time that was recorded with
268
 * jvmpiAgent_collectStartTimeInformation
269
 */
270
void jvmpiAgent_getStartTime(timestamp_t *time) {
271
  *time = _startTime;
272
}
273
274
/* GET_CURRENT_TIME  ******************************************************
275
 * Determins the current clock time and fills the timestamp_t structure
276
 * with the data
277
 */
278
void jvmpiAgent_getCurrentTime(timestamp_t *timestamp) {
279
/* 
280
 * Note: WIN32 designates Windows generally and is specified with or without _WIN64.
281
 * Therefore, when both are true, the _WIN64 case is desired (as in the following sequence).
282
 */
283
284
/* Windows */
285
#if defined(_WIN64) || defined(_WIN32)
286
287
	if (_highResPerfAvailable==TRUE) {  /* bug 160511 start */
288
		LARGE_INTEGER liHighResPerfCount;		
289
		if (QueryPerformanceCounter(&liHighResPerfCount)) {
290
			*timestamp=_tickBooster*liHighResPerfCount.QuadPart;
291
		} else {
292
			printf("Failed attempt to get highResperfCount\n");
293
		}		
294
	} else {  /* bug 160511 end */	
295
296
 #if defined(_WIN64)	/*ts. bug 120479*/
297
  #ifdef _M_IA64
298
		*timestamp = __getReg(CV_IA64_ApITC);
299
  #else
300
		*timestamp = __rdtsc();
301
  #endif
302
	}
303
 #else /* defined(_WIN32) */
304
  #define RDTSC(tsc_high,tsc_low) \
305
{                               \
306
        __asm rdtsc             \
307
        __asm mov tsc_high,edx  \
308
        __asm mov tsc_low,eax   \
309
}
310
311
  #define RDTSC_LL(time64)               \
312
{					                   \
313
		unsigned int tsc_high,tsc_low; \
314
		RDTSC(tsc_high, tsc_low);      \
315
		time64 = tsc_high;             \
316
	    time64 = time64 << 32;         \
317
		time64 = time64 | tsc_low;     \
318
}
319
320
		RDTSC_LL(*timestamp);
321
	}
322
 #endif
323
324
/* Linux */
325
#elif defined(__linux__) && defined(__s390__) /* bug 160511: deleted __i386__ clause*/
326
		/* for Linux/390, generate gcc assembler to use the STCK
327
			instruction, which provides the current cycle counter */
328
		asm ("STCK %0" : "=m" (*timestamp) );
329
330
/* OS/390 */
331
#elif defined(MVS)
332
/* for os/390, use a pre-defined macro to accomplish the
333
   same thing we did on Linux/390 */
334
        __stck(timestamp);
335
336
337
#elif defined(SOLARIS)
338
/* for Solaris, we don't yet use the most efficient method
339
   to acquire a high-res clock, but this one is pretty good */
340
       hrtime_t time = gethrtime();
341
       *timestamp=time;
342
343
#elif defined(_AIX)
344
/* AIX has built-in routines to handle this, but is somewhat
345
   chip-dependent (PowerPC versus POWER) */
346
      timebasestruct_t t;
347
      int i = read_real_time(&t, sizeof(timebasestruct_t));
348
349
      if(t.flag == RTC_POWER_PC) {
350
       /* then t contains the high-order
351
          and low-order 32 bits of the cycle counter. */
352
          Uint64 ticks64 = t.tb_high;
353
          ticks64  = ticks64 << 32;
354
          ticks64 |= t.tb_low;
355
          *timestamp=ticks64;
356
      }
357
      else {
358
       /* then t contains seconds and nanoseconds (a little more
359
          expensive in this case) */
360
          int32_t secs   = t.tb_high;
361
          int32_t n_secs = t.tb_low;
362
363
       /*
364
        * If there was a carry from low-order to high-order during
365
        * the measurement, we may have to undo it.
366
        */
367
        if (n_secs < 0)  {
368
          secs--;
369
          n_secs += 1000000000;
370
        }
371
372
        /* here we add the seconds and nonoseconds */
373
        *timestamp = secs + n_secs*1000000000;
374
      }
375
376
#elif defined (__OS400__)
377
      mattod((unsigned char*)timestamp); 
378
#elif defined (_HPUX)
379
      #include <machine/inline.h>
380
      register unsigned long long now;
381
      _MFCTL(16, now);
382
      *timestamp = now;
383
#else /* platform on which we don't support high-resolution timers */
384
	struct timeval tv;
385
	struct timezone tz;
386
	timestamp_t time;
387
	gettimeofday(&tv, &tz);
388
	time=tv.tv_sec*1000000;
389
	time+=tv.tv_usec;
390
	*timestamp = time;
391
#endif /* CHOOSE PLATFORM */
392
}
393
394
395
/** GET_CURRENT_THREAD_CPU_TIME  ************************************************
396
  * Retruns the amount of CPU time consumed by this thread as a 64 bit number.
397
  * This is returned in nanoseconds
398
  */
399
Uint64 jvmpiAgent_getCurrentThreadCPUTime() {
400
401
	if (_jvmpiAgent_jvmpiInterface) {
402
#ifdef __OS400__
403
		return (_jvmpiAgent_jvmpiInterface->GetCurrentThreadCpuTime()).unsigned_ll;
404
#else
405
		return _jvmpiAgent_jvmpiInterface->GetCurrentThreadCpuTime(); 
406
#endif 
407
	} else {
408
		return 0; 
409
	}
410
411
/** old code **/ 
412
#if 0 
413
	/* Get the current thread and then get its thread time
414
	   this could be improved by caching the handle in the
415
	   thread structure */
416
	FILETIME  start, end, kernal, user;
417
	Uint64 kernalTime, userTime;
418
	HANDLE handle=GetCurrentThread();
419
	GetThreadTimes(handle,
420
				   &start,	/* dont want start time */
421
				   &end,	/* dont want exit time */
422
				   &kernal,	/* kernal mode time */
423
				   &user);	/* user mode time */
424
425
	kernalTime=(kernal.dwHighDateTime<<32);
426
	kernalTime|=kernal.dwLowDateTime;
427
	userTime=(user.dwHighDateTime<<32);
428
	userTime|=user.dwLowDateTime;
429
	return (kernalTime+userTime);
430
/* #else */ 
431
	return 0;
432
#endif
433
434
}
435
436
/** GET_PROCESS_START_TIME  ***************************************************
437
  *  Returns the start time of the current process as a timestamp_t in UTC time.
438
  */
439
void jvmpiAgent_getProcessStartTime(timestamp_t *timestamp) {
440
#ifdef _WIN32
441
	
442
	FILETIME  start, end, kernal, user;
443
	Uint64 startTime, deltaTime;
444
	HANDLE handle;
445
	timestamp_t ticks;
446
	
447
	handle=OpenProcess(PROCESS_QUERY_INFORMATION,
448
					   FALSE,
449
					   ra_getProcessId());
450
	GetProcessTimes(handle,
451
				   &start,	/* start time */
452
				   &end,	/* dont want exit time */
453
				   &kernal,	/* dont want kernal mode time */
454
				   &user);	/* dont want user mode time */
455
456
457
	/* The filetime structure starts as of Janauary 1, 1601.  Subtract the passed time
458
	   between this and January 1, 1970
459
	*/
460
	startTime=((Uint64)(start.dwHighDateTime))<<32;
461
	startTime|=start.dwLowDateTime;
462
463
	deltaTime=((Uint64)(0x19db1de))<<32;
464
	deltaTime|=0xd53e8000;
465
466
	startTime-=deltaTime;
467
468
	/* The startTime is now a count of 100ns intervals since January 1, 1970.  We need to change this to
469
	 * seconds and microseconds.
470
	 */
471
	ticks = timeToTicks(startTime/10000000,(startTime%10000000)/10);
472
473
	/* The ticks variable has the real value that represents the process start time.
474
	 * Because all of the timestamps taken in the trace are actually corrected by the
475
	 * constant _startTime-_startTimeAsTicks we need to subtract it here.
476
	 */
477
	*timestamp = ticks - (_startTime-_startTimeAsTicks);
478
#else
479
	/* On Unix we don't know when the process was started.  We
480
	 * will specify the time the trace was started.
481
	 * Because all of the timestamps taken in the trace are actually corrected by the
482
	 * constant _startTime-_startTimeAsTicks we need to subtract it here.
483
	 */
484
	*timestamp = _startTime - (_startTime-_startTimeAsTicks);
485
#endif
486
}
487
488
/** GET_TIMEZONE  *************************************************************
489
  * Returns the current timezone as an offset, in minutes, working westward from
490
  * GMT.  ie.  GMT+5  would be 300 as there are 300 minutes in 5 hours.
491
  */
492
unsigned long jvmpiAgent_getTimezone() {
493
    /* The first version here may work on alll platforms. */
494
#ifdef __OS400__
495
    struct timeval time1;
496
    struct timezone time2;
497
    gettimeofday(&time1, &time2);
498
    return time2.tz_minuteswest;
499
#else
500
	TIMEB currenttime;
501
	FTIME(&currenttime);
502
	return currenttime.timezone;
503
#endif
504
}
505
506
507
/** RKD:  The functions below are 64bit INTEL assembler functions to test compiler
508
  * support and are not used anywhere in the code today.
509
  */
510
511
_inline Uint64 sub64(Uint64 op1, Uint64 op2) {
512
#if defined (_INTEL) && !defined(_WIN64) /*ts. bug 120479*/
513
	unsigned long result_high=0, result_low=0,
514
				  op1_high, op1_low,
515
				  op2_high, op2_low;
516
	op1_high=(unsigned long)(op1>>32 & 0x00000000ffffffff);
517
	op1_low=(unsigned long)op1;
518
	op2_high=(unsigned long)(op2>>32 & 0x00000000ffffffff);
519
	op2_low=(unsigned long)op2;
520
	__asm {
521
		pushad				/* Store all the general purpose registers */
522
		mov edx, op1_high	/* High order subtract first */
523
		sub edx, op2_high
524
		mov result_high, edx
525
		mov edx, op1_low	/* Low order subtract next */
526
		clc					/* Clear the carry flag */
527
		sub edx, op2_low
528
		mov result_low, edx
529
		jnc Noflow			/* Did we borrow? If so decrement the high order bits */
530
		dec result_high
531
Noflow: popad
532
	}
533
	return ((Uint64)result_high<<32) | result_low;
534
#else
535
	return 0;
536
#endif
537
}
538
539
540
_inline void div64(Uint64 op1, unsigned long op2, unsigned long *quotient, unsigned long remainder) {
541
#ifdef INTEL /* TO GET THIS TO COMPILE CHANGE TO "_INTEL" */
542
	unsigned long q, r, op1_high, op1_low;
543
	op1_high=(unsigned long)(op1>>32 & 0x00000000ffffffff);
544
	op1_low=(unsigned long)op1;
545
	__asm {
546
		pushad			/* Store all the general purpose registers */
547
		mov	edx, op1_high
548
		mov ead, op1_low
549
		div op2
550
		mov r, edx
551
		mov q, eax
552
		popad
553
	}
554
555
#else
556
#endif
557
}
558
559
/*********************************************************
560
 * DEBUG assists:
561
 */
562
#if defined(_DEBUG) && !defined (MVS) && !defined (__OS400__)
563
/* This function tests for a POTENTIAL/IMMINENT time accumulation overflow and prints if one is detected */
564
void debug_check_and_report_time_overflow (timestamp_t testTime, char *errMsg) {                /* 134577 */
565
	/* if time (in  seconds) is suspiciously high (over 1000 secs for testing), then print message */ 
566
	if (testTime/(_ticksPerMicrosecond*1000000) > 1000) {
567
		printf(errMsg);
568
		fflush(stdout); 
569
	}	
570
}
571
#endif
(-)src-native-new/src/agents/perfmon/WinBuild/WinBuild.dsw (+68 lines)
Added Link Here
1
Microsoft Developer Studio Workspace File, Format Version 6.00
2
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3
4
###############################################################################
5
6
Project: "PerfmonAgent"=.\PerfmonAgent.dsp - Package Owner=<4>
7
8
Package=<5>
9
{{{
10
}}}
11
12
Package=<4>
13
{{{
14
    Begin Project Dependency
15
    Project_Dep_Name resutils
16
    End Project Dependency
17
}}}
18
19
###############################################################################
20
21
Project: "rac"=.\rac.dsp - Package Owner=<4>
22
23
Package=<5>
24
{{{
25
}}}
26
27
Package=<4>
28
{{{
29
}}}
30
31
###############################################################################
32
33
Project: "resutils"=.\resutils.dsp - Package Owner=<4>
34
35
Package=<5>
36
{{{
37
}}}
38
39
Package=<4>
40
{{{
41
}}}
42
43
###############################################################################
44
45
Project: "sysperf"=.\sysperf.dsp - Package Owner=<4>
46
47
Package=<5>
48
{{{
49
}}}
50
51
Package=<4>
52
{{{
53
}}}
54
55
###############################################################################
56
57
Global:
58
59
Package=<5>
60
{{{
61
}}}
62
63
Package=<3>
64
{{{
65
}}}
66
67
###############################################################################
68
(-)src-native-new/src/agents/perfmon/resutils/hashtable.c (+370 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: hashtable.c,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
14
#include "stdio.h"
15
#include "stdlib.h"
16
#include "memory.h"
17
#include "string.h"
18
#include "hashtable.h"
19
#include "system.h"
20
21
22
#define LOAD_FACTOR 0.75f
23
24
//INTERNAL - UNSYNCHRONIZED
25
int match(Entry* entry, char* key) {
26
	int c = 0;
27
	while (entry->key[c] != '\0' && key[c] != '\0') {
28
		if (entry->key[c] != key[c]) return 0;
29
		c++;
30
	}
31
	if (entry->key[c] == key[c]) {
32
		return 1;
33
	}
34
	return 0;
35
}
36
37
//SYNCHRONIZED
38
BOOL containsKey(HashTable* hasht, char* key)
39
{
40
	Entry* entry;
41
	Entry** tab;
42
43
	long int hash;
44
	long int index;
45
46
	XMutexClaim(&hasht->mutex);
47
48
	tab = hasht->table;
49
50
	hash = getHash((char*)key);
51
	index = (hash & 0x7FFFFFFF) % hasht->table_len;
52
53
	for (entry = tab[index]; entry != NULL; entry = (Entry*)entry->next) 
54
	{
55
		if (hash == entry->hash) 
56
		{
57
			if (match(entry,key)) 
58
			{
59
				XMutexRelease(&hasht->mutex);
60
				return TRUE;
61
			}
62
		}
63
	}
64
65
	XMutexRelease(&hasht->mutex);
66
	return FALSE;
67
}
68
69
//SYNCHRONIZED
70
int tableKeysAsList(HashTable* table, char** list, int list_size) {
71
	int i;
72
	int n;
73
	Entry* next;
74
	Entry* e;
75
76
	n = 0;
77
78
	XMutexClaim(&table->mutex);
79
80
	for (i = 0; i < table->table_len; i++) {
81
		if (table->table[i] != NULL) {
82
83
			//run down the list of entries and add them to the list_size
84
			e = table->table[i];
85
			
86
			while (e != NULL) {
87
				next = e->next;
88
89
				//add entry e to the list
90
				list[n++] = e->key;
91
92
				if (n == list_size) {
93
					XMutexRelease(&table->mutex);
94
					return list_size*2;
95
				}
96
97
				e = next;
98
			}
99
100
		}
101
	}
102
103
	XMutexRelease(&table->mutex);
104
	return n;
105
}
106
107
//
108
// Allocate a new entry
109
//
110
//INTERNAL - UNSYNCHRONIZED
111
Entry* createEntry(long int hash, char* key, XINT64 value, Entry* next) {
112
	Entry* e;
113
	int len = strlen(key)+1;
114
115
	e = (Entry*)malloc(sizeof(Entry));
116
117
	if (e == NULL) return NULL;
118
119
	e->hash = hash;
120
	e->key = malloc(sizeof(char) * len);
121
	memcpy(e->key,key,len);
122
	e->value = value;
123
	e->next = next;
124
125
	return e;
126
}
127
128
//
129
// Deallocate an entry
130
//
131
//INTERNAL - UNSYNCHRONIZED
132
void deleteEntry(Entry* e) {
133
	Entry* next;
134
135
	while (e != NULL) {
136
		next = e->next;
137
138
		free(e->key);
139
		free(e);
140
141
		e = next;
142
	}
143
}	
144
145
//create - UNSYNCHRONIZED
146
HashTable* tableCreate() {
147
	int i = 0;
148
149
	HashTable* hasht;
150
	long int initialCapacity = 11;
151
152
	hasht = (HashTable*) malloc(sizeof(HashTable));
153
154
	hasht->table = (Entry**)malloc(initialCapacity * sizeof(Entry*));
155
	hasht->table_len = initialCapacity;
156
157
	memset(hasht->table,'\0',hasht->table_len * sizeof(Entry*));
158
159
	hasht->count = 0;
160
161
	hasht->threshold = (long int)(initialCapacity * LOAD_FACTOR);
162
163
	XMutexCreate(&hasht->mutex);
164
165
	return hasht;
166
}
167
168
//delete - UNSYNCHRONIZED
169
void tableDelete(HashTable* hasht) {
170
	int i = 0;
171
172
	XMutexDelete(&hasht->mutex);
173
174
	for (i = 0; i < hasht->table_len; i++) {
175
		if (hasht->table[i] != NULL) {
176
			deleteEntry(hasht->table[i]);
177
			hasht->table[i] = NULL;
178
		}
179
	}
180
181
	free(hasht->table);
182
	free(hasht);
183
184
}
185
186
//SYNCHRONIZED
187
void tableClear(HashTable* hasht) {
188
	int i = 0;
189
190
	XMutexClaim(&hasht->mutex);
191
192
	hasht->count = 0;
193
194
	for (i = 0; i < hasht->table_len; i++) {
195
		if (hasht->table[i] != NULL) {
196
			deleteEntry(hasht->table[i]);
197
			hasht->table[i] = NULL;
198
		}
199
	}
200
201
	XMutexRelease(&hasht->mutex);
202
}
203
204
//no modification - UNSYNCHRONIZED
205
int tableSize(HashTable* hasht) {
206
	return hasht->count;
207
}
208
209
//INTERNAL - UNSYNCHRONIZED
210
long int getHash(char* key) {
211
	long int n;
212
	long int hash = 0;
213
214
	for (n = 0; key[n] != '\0'; n++) {
215
		hash = (hash*n)+key[n];
216
	}
217
218
	return hash;
219
}
220
221
//SYNCHRONIZED
222
XINT64 tableGet(HashTable* hasht, char* key) {
223
	Entry* entry;
224
	Entry** tab;
225
226
//	long int hash = (long int)key;
227
	long int hash;
228
	long int index;
229
230
	XMutexClaim(&hasht->mutex);
231
232
	tab = hasht->table;
233
234
	hash = getHash((char*)key);
235
	index = (hash & 0x7FFFFFFF) % hasht->table_len;
236
237
	for (entry = tab[index]; entry != NULL; entry = (Entry*)entry->next) {
238
		if (hash == entry->hash) {
239
			if (match(entry,key)) {
240
241
				XMutexRelease(&hasht->mutex);
242
				return entry->value;
243
			}
244
		}
245
	}
246
247
	XMutexRelease(&hasht->mutex);
248
	return (XINT64)NULL;
249
}
250
251
//SYNCHRONIZED
252
void tableRehash(HashTable* hasht) {
253
	int i;
254
	Entry* old;
255
	Entry* ent;
256
	long int index;
257
258
	long int oldCapacity;
259
	Entry** oldMap;
260
261
	long int newCapacity;
262
	Entry** newMap;
263
264
	oldCapacity = hasht->table_len;
265
	oldMap = hasht->table;
266
267
	newCapacity = (oldCapacity * 2) + 1;
268
	newMap = (Entry**)malloc(newCapacity * sizeof(Entry*));
269
270
	hasht->threshold = (long int)(newCapacity * LOAD_FACTOR);
271
	hasht->table = newMap;
272
	hasht->table_len = newCapacity;
273
274
	memset(hasht->table,'\0',hasht->table_len * sizeof(Entry*));
275
276
	for (i = oldCapacity; i-- > 0;) {
277
		for (old = oldMap[i]; old != NULL; ) {
278
			ent = old;
279
			old = (Entry*)old->next;
280
281
			index = (ent->hash & 0x7FFFFFFF) % newCapacity;
282
			ent->next = newMap[index];
283
			newMap[index] = ent;
284
		}
285
		oldMap[i] = NULL;
286
	}
287
	free(oldMap);
288
}
289
290
//SYNCHRONIZED
291
XINT64 tablePut(HashTable* hasht, char* key, XINT64 value) {
292
	Entry** tab;
293
	Entry* ent;
294
//	long int hash = (long int)key;
295
	long int hash = getHash((char*)key);
296
	long int index;
297
298
	XMutexClaim(&hasht->mutex);
299
300
	tab = hasht->table;
301
302
	index = (hash & 0x7FFFFFFF) % hasht->table_len;
303
304
	for (ent = tab[index]; ent != NULL; ent = (Entry*)ent->next) {
305
		if (hash == ent->hash) {
306
			if (match(ent,key)) {
307
				XINT64 old = ent->value;
308
				ent->value = value;
309
310
				XMutexRelease(&hasht->mutex);
311
				return old;
312
			}
313
		}
314
	}
315
316
	if (hasht->count >= hasht->threshold) 
317
	{
318
		tableRehash(hasht);
319
		tab = hasht->table;
320
		index = (hash & 0x7FFFFFFF) % hasht->table_len;
321
	}
322
323
	ent = createEntry(hash,key,value,tab[index]);
324
	tab[index] = ent;
325
	
326
	hasht->count++;
327
328
	XMutexRelease(&hasht->mutex);
329
	return (XINT64)NULL;
330
}
331
332
//SYNCHRONIZED
333
void tableRemove(HashTable* hasht, char* key) 
334
{
335
	Entry* entry;
336
	Entry* prevEntry;
337
	Entry** tab;
338
339
	long int hash;
340
	long int index;
341
342
	XMutexClaim(&hasht->mutex);
343
344
	tab = hasht->table;
345
346
	hash = getHash((char*)key);
347
	index = (hash & 0x7FFFFFFF) % hasht->table_len;
348
349
	prevEntry = NULL;
350
	for (entry = tab[index]; entry != NULL; entry = (Entry*)entry->next) 
351
	{
352
		if (hash == entry->hash) 
353
		{
354
			if (match(entry,key)) 
355
			{
356
				if (prevEntry == NULL)
357
					tab[index] = entry->next;
358
				else
359
					prevEntry->next = entry->next;
360
361
				deleteEntry(entry);
362
				hasht->count--;
363
				XMutexRelease(&hasht->mutex);
364
				return;
365
			}
366
		}
367
		prevEntry = entry;
368
	}
369
	XMutexRelease(&hasht->mutex);
370
}
(-)src-native-new/src/agents/native/java_profiler/segmentedValue.h (+52 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: segmentedValue.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef __SEGMENTEDVALUE_H__
14
#define __SEGMENTEDVALUE_H__ 1
15
16
17
#if defined __cplusplus
18
 extern "C" {
19
#endif
20
/******************************
21
 * SegmentedValue types and methods
22
 ******************************/
23
24
/* RKD:  The segmented values were initially designed to be a multiworded value.  This turned out to
25
         be a severe bottleneck due to memory fragmentation so it was disabled.  Defining
26
		 SEGMENTED_VALUE_MULTIWORD will re-enable this function.
27
*/
28
#ifdef SEGMENTED_VALUE_MULTIWORD
29
typedef struct {
30
 unsigned long numberOfWords;
31
 unsigned long *values;
32
} SegmentedValue_t;
33
#else
34
typedef struct {
35
 unsigned long value;
36
} SegmentedValue_t;
37
#endif
38
39
void jvmpiAgent_incrementSegmentedValue(SegmentedValue_t *segValue,
40
										unsigned long count);
41
42
SegmentedValue_t * jvmpiAgent_copySegmentedValue(SegmentedValue_t *target,
43
												 SegmentedValue_t *source);
44
45
void jvmpiAgent_initializeSegmentedValue(SegmentedValue_t *segValue,
46
										 int freeFlag);
47
48
#if defined __cplusplus
49
 }
50
#endif
51
52
#endif
(-)src-native-new/src/agents/native/java_profiler/segmentedValue.c (+66 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: segmentedValue.c,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include <stdlib.h>
14
#include <string.h>
15
#include "segmentedValue.h"
16
#include "utility.h"
17
18
void jvmpiAgent_initializeSegmentedValue(SegmentedValue_t *segValue, int freeFlag)
19
{
20
#ifdef SEGMENTED_VALUE_MULTIWORD
21
 segValue->numberOfWords = 1;
22
 if (freeFlag)
23
 {
24
  free(segValue->values);
25
 }
26
 segValue->values = (unsigned long *)jvmpiAgent_Calloc(segValue->numberOfWords * sizeof(unsigned long));
27
 segValue->values[0] = 0;
28
#else
29
 segValue->value=0;
30
#endif
31
}
32
33
SegmentedValue_t * jvmpiAgent_copySegmentedValue(SegmentedValue_t *target, SegmentedValue_t *source)
34
{
35
#ifdef SEGMENTED_VALUE_MULTIWORD
36
 int size = source->numberOfWords * sizeof(unsigned long);
37
 *target = *source;
38
 target->values = (unsigned long *)jvmpiAgent_Calloc(size);
39
 memcpy(target->values, source->values, size);
40
#else
41
  *target = *source;
42
#endif
43
 return target;
44
}
45
46
void jvmpiAgent_incrementSegmentedValue(SegmentedValue_t *segValue, unsigned long count)
47
{
48
#ifdef SEGMENTED_VALUE_MULTIWORD
49
 if (segValue->values[count] == 0xFFFFFFFF) {
50
   /* Going to wrap the current value */
51
   if (count+1 == segValue->numberOfWords)
52
   {
53
	/* Need to increase the number of words in the collation values list */
54
	unsigned long *p = segValue->values;
55
	segValue->numberOfWords++;
56
	segValue->values = (unsigned long *)jvmpiAgent_Calloc(segValue->numberOfWords * sizeof(unsigned long));
57
	memcpy(segValue->values, p, (segValue->numberOfWords-1) * sizeof(unsigned long));
58
	free(p);
59
   }
60
   jvmpiAgent_incrementSegmentedValue(segValue, count+1);
61
 }
62
 segValue->values[count]++;
63
#else
64
 segValue->value++;
65
#endif
66
}
(-)src-native-new/src/HCLauncher/version.rc (+110 lines)
Added Link Here
1
#include "../../include/tptp/version.h"
2
//Microsoft Developer Studio generated resource script.
3
//
4
#include "resource.h"
5
6
#define APSTUDIO_READONLY_SYMBOLS
7
/////////////////////////////////////////////////////////////////////////////
8
//
9
// Generated from the TEXTINCLUDE 2 resource.
10
//
11
#include "afxres.h"
12
13
/////////////////////////////////////////////////////////////////////////////
14
#undef APSTUDIO_READONLY_SYMBOLS
15
16
/////////////////////////////////////////////////////////////////////////////
17
// English (U.S.) resources
18
19
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20
#ifdef _WIN32
21
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
22
#pragma code_page(1252)
23
#endif //_WIN32
24
25
#ifndef _MAC
26
/////////////////////////////////////////////////////////////////////////////
27
//
28
// Version
29
//
30
31
VS_VERSION_INFO VERSIONINFO
32
 FILEVERSION _VERSION_WIN
33
 PRODUCTVERSION _VERSION_WIN
34
 FILEFLAGSMASK 0x3fL
35
#ifdef _DEBUG
36
 FILEFLAGS 0x1L
37
#else
38
 FILEFLAGS 0x0L
39
#endif
40
 FILEOS 0x40004L
41
 FILETYPE 0x2L
42
 FILESUBTYPE 0x0L
43
BEGIN
44
    BLOCK "StringFileInfo"
45
    BEGIN
46
        BLOCK "040904b0"
47
        BEGIN
48
            VALUE "Comments", "\0"
49
            VALUE "CompanyName", _COMPANY_NAME
50
            VALUE "FileDescription", "Agent Controller Launcher Library\0"
51
            VALUE "FileVersion", _VERSION
52
            VALUE "InternalName", "hclaunch\0"
53
            VALUE "LegalCopyright", _COPYRIGHT
54
            VALUE "LegalTrademarks", "\0"
55
            VALUE "OriginalFilename", "HCLaunch.dll\0"
56
            VALUE "PrivateBuild", "\0"
57
            VALUE "ProductName", "\0"
58
            VALUE "ProductVersion", _VERSION
59
            VALUE "SpecialBuild", "\0"
60
        END
61
    END
62
    BLOCK "VarFileInfo"
63
    BEGIN
64
        VALUE "Translation", 0x409, 1200
65
    END
66
END
67
68
#endif    // !_MAC
69
70
71
#ifdef APSTUDIO_INVOKED
72
/////////////////////////////////////////////////////////////////////////////
73
//
74
// TEXTINCLUDE
75
//
76
77
1 TEXTINCLUDE DISCARDABLE 
78
BEGIN
79
    "resource.h\0"
80
END
81
82
2 TEXTINCLUDE DISCARDABLE 
83
BEGIN
84
    "#include ""afxres.h""\r\n"
85
    "\0"
86
END
87
88
3 TEXTINCLUDE DISCARDABLE 
89
BEGIN
90
    "\r\n"
91
    "\0"
92
END
93
94
#endif    // APSTUDIO_INVOKED
95
96
#endif    // English (U.S.) resources
97
/////////////////////////////////////////////////////////////////////////////
98
99
100
101
#ifndef APSTUDIO_INVOKED
102
/////////////////////////////////////////////////////////////////////////////
103
//
104
// Generated from the TEXTINCLUDE 3 resource.
105
//
106
107
108
/////////////////////////////////////////////////////////////////////////////
109
#endif    // not APSTUDIO_INVOKED
110
(-)src-native-new/src/agents/native/heapsnapshots/SnapshotFiller.h (+34 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: SnapshotFiller.h,v 1.4 2005/04/06 19:15:49 samwai Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef SNAPSHOT_FILLER_H
14
#define SNAPSHOT_FILLER_H
15
16
#include <jvmpi.h>
17
18
class SnapshotFiller {
19
 public:
20
  virtual void FillClassInfo(jobjectID   cls,
21
			     const char* className,
22
			     int         numStaticReferenceFields,
23
			     int         numInterfaces,
24
#ifdef __OS400__
25
				 int         instanceSize,
26
				 jobjectID*  classRefs) = 0;
27
#else
28
				 int         instanceSize) = 0;
29
#endif
30
31
  virtual void FillJvmpiSnapshot(char* begin, char* end) = 0;
32
};
33
34
#endif /* SNAPSHOT_FILLER_H */
(-)src-native-new/src/agents/native/java_profiler/options.h (+181 lines)
Added Link Here
1
 /**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: options.h,v 1.7 2006/05/05 03:21:22 bduncan Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
14
#ifndef __OPTIONS_H__
15
#define __OPTIONS_H__ 1
16
17
#if defined __cplusplus
18
 extern "C" {
19
#endif
20
21
/* DNS - added following include */
22
#include "RADataTransfer.h"
23
24
enum IdStyle {IdStyleStatic, IdStyleRelocatable, IdStyleStaticAndRelocatable};
25
26
enum ObjRefMode {RespectFilter, Filter4Owner, IgnoreFilter};
27
28
enum Gc {GcNone, GcDeletes, GcMoves, GcDeletesAndMoves};
29
30
enum StackInfo {StackInfoNone, StackInfoNormal, StackInfoContiguous, StackInfoBoundary, StackInfoBoundaryAndContiguous};
31
32
enum CompressLevel {CompressNone, CompressAggregate};
33
34
/*
35
HeapInfo is depreciated. Hoever, existing clients will keep working:
36
    HeapInfoNone == TraceModeNoObjectCorrelation, and
37
    HeapInfoAll == TraceModeFull
38
enum HeapInfo {HeapInfoNone, HeapInfoAll };
39
*/
40
41
/* 57681 don't add new tags at the beginning: leave it TraceModeFull.
42
 * Otherwise you'll change the agent's behavior 
43
 * when _jvmpiagent_Options.mode is never set, which is common.
44
 */
45
enum TraceMode {TraceModeFull, TraceModeNoObjectCorrelation, TraceModeStackSampling, TraceHeap, TraceOptimizedHeap, TraceModeNone };
46
47
enum TraceStartMode {TraceStartModeFilter, TraceStartModeTriggerSingleThreaded, TraceStartModeTriggerMultiThreaded};
48
49
enum BurstMode {BurstModeNone, BurstModeSeconds, BurstModeInvocations, BurstModeSecondsAndInvocations};
50
51
enum MonitorMode {MonitorNone, MonitorAll}; 
52
53
/* 60879 a structure used for storing options that the piAgent otherwise doesn't care about. 
54
  This is used mainly so that we can echo back these options to the UI. */ 
55
56
typedef struct gen_option {
57
	char *key; 
58
	char *value;
59
	struct gen_option *next;  
60
} generic_option; 
61
62
/** These are the global options specified on the command line and/or profile of the agent at
63
    invocation time.
64
  */
65
typedef struct {
66
 unsigned int unreferencedSymbols:1;		/* Print unreferenced symbols? (FALSE) */
67
 unsigned int timestamp:1;					/* Provide timestamps on all events (TRUE) */
68
 unsigned int debugHash:1;					/* Debug the hash table (FALSE) */
69
 unsigned int standalone:1;				    /* Standalone mode  (FALSE) */
70
 unsigned int application:1;				/* Application mode (FALSE) */
71
 unsigned int enabled:1;					/* Enabled mode  ie. attachable (TRUE)  */
72
 unsigned int traceExceptions:1;			/* Trace Exceptions  (FALSE) */
73
 unsigned int enableExceptionTracing:1;	    /* Place hooks for exception tracing (TRUE) */
74
 unsigned int enableLineCoverage:1;	        /* Place hooks for Line Coverage (TRUE) */
75
 unsigned int collationValues:1;            /* Print collation_value attribute on each element  */
76
 unsigned int filters:1;                    /* Print FILTER Elements (TRUE) */
77
 unsigned int options:1;                    /* Print OPTIONS Elements (TRUE) */
78
 unsigned int traceIdrefs:1;                /* Print trace_idref attribute on each element  */
79
 unsigned int gcDefault:1;                  /* GC default option */
80
 unsigned int methodCounts:1;               /* METHOD_COUNTS option  */
81
 unsigned int classLoadDetails:1;           /* CLASS_LOAD_DETAILS options */
82
 unsigned int methodDetails:1;				/* Provied a detailed descriptive about the methods (FALSE) */
83
 unsigned int objAllocIsArray:1;            /* OBJ_ALLOC_IS_ARRAY attribute option (TRUE) */
84
 unsigned int contextFlow:1;                /* CONTEXT_FLOW attribute option */
85
 unsigned int ticket:1;                     /* TICKET (TRUE) */
86
 unsigned int modeSet:1;					/* Was "mode" set on command line? */
87
 unsigned int exceptionTracingSet:1;		/* Was "exceptionTracing" set on the command line? */
88
 unsigned int lineCoverageSet:1;			/* Was "lineCoverage" set on the command line? */
89
 unsigned int gcSet:1;						/* Was "trackGCEvent" set on the command line? */
90
 unsigned int heapInfoCountSet:1;			/* Was "optHeapCount" set on the command line */
91
 unsigned int heapInfoFilePrefixSet:1;		/* Was "optHeapFilePrefix" set on the command line */
92
 unsigned int jinsightFormat:1;				/* I/O is in Jinsight format (FALSE)*/
93
 unsigned int cpuTime:1;					/* Are we emmiting thread cpuTime (FALSE) */
94
 unsigned int llDataEnabled:1;				/* Are we possibly emmiting line level data (FALSE) */
95
 enum IdStyle idStyle;
96
 enum ObjRefMode objRefMode;				/* RespectFilter, Filter4Owner, IgnoreFilter*/
97
 enum Gc gc;
98
 enum StackInfo stackInfo;					/* Stack maintenance mode  (StackInfoContiguous)*/
99
 enum CompressLevel compressLevel;          /* Compression level (CompressNone): controls pre-aggregate * 140009 */ 
100
 /* Depreciated: enum HeapInfo heapInfo; */	/* Object maintenence mode (HeapInfoAll) */
101
 enum TraceMode mode;						/* Mode to trace in (TraceModeFull) */
102
 enum TraceStartMode startMode;				/* When to start emiting trace info (TraceStartModeFilter) */
103
 enum BurstMode burstMode;					/* Whether we are tring in burst mode (BurstModeNone) */
104
 enum MonitorMode monitorMode;              /* Whether monitor events are being tracked */ 
105
 unsigned short burstInvocations;			/* The number of invocations to trace per monitoring session */
106
 unsigned short burstSeconds;				/* The number of seconds to trace per monitoring session */
107
 unsigned short boundaryDepth;				/* The depth to trace into filtered code */
108
 int heapInfoCount;							/* Number of heaps in each cycle, in TraceHeap and TraceOptimizedHeap modes (Default: 2) */
109
 ra_data_target_hdl_t targetHdl;
110
 char *invocationOptions;					/* The invocation options from the command line */
111
 char *filterFileName;						/* Name of the filters file (filters.txt)*/
112
 char *triggerFileName;						/* Name of the triggers file (triggers.txt)*/
113
 char *processName;							/* Name of the process */
114
 char *processType;							/* The type of process */
115
 char *outputFileName;						/* Output file for trace */
116
 char *heapInfoFilePrefix;					/* Filename prefix of the output trace in TraceHeap and TraceHeapOptimized modes (Default: heapinfo) */
117
 char *profileFile;							/* Name of the profile file */
118
 char *workDir;								/* Working directory (default is .) */
119
 char *extensionLibrary;					/* The Agent Extension library name to load (empty string means none) */
120
 generic_option *unknowns;					/* space to store the options the piAgent doesn't care about, but can echo back to the UI */ 
121
 unsigned int methodCountsOnly:1;			/* METHOD_COUNTS_ONLY indicates if we want to track _ONLY_ method counts (without methodEntry/exit events) */ 
122
} Options;
123
124
/* The structure to hold the invocation options for this process */
125
extern Options _jvmpiAgent_Options;
126
127
/** PROCESS_INVOCATION_OPTIONS *******************************************
128
  * Takes the command line parameters and populates the _jvmpiAgent_Options
129
  * with the correct values based upon the options specified.
130
  * @param   optionString - the command line args
131
  * @returns
132
  */
133
int jvmpiAgent_ProcessInvocationOptions(char *optionString);
134
135
/** PROCESS_PROFILE  ******************************************************
136
  * Process the specified profile and set the profile options within the
137
  * agent.
138
  * @param    profileName - the name of the profile file.
139
  * @returns
140
  */
141
int jvmpiAgent_processProfile(char *profileName);
142
143
/** SET_PROFILE_OPTION ****************************************************
144
  * Sets the profile option specified by key to the value specified by
145
  * value.
146
  * @param     key - the option that will be set
147
  * @param   value - the value that will be associated with the key.
148
  * @returns
149
  */
150
int jvmpiAgent_SetProfileOption(char * key, char * value);
151
152
/** CHECK_OPTIONS_CONSISTENCY ********************************************
153
  * Checks whether there is any conflict or inconsistency among various
154
  * options.
155
  * @returns -1 if error, 0 if no error
156
  */
157
int jvmpiAgent_CheckOptionsConsistency();
158
159
/** PRINT_OPTIONS ********************************************************
160
  * Prints the options
161
  */
162
void jvmpiAgent_printOptions();
163
unsigned int jvmpiAgent_isPrintObjId();
164
unsigned int jvmpiAgent_isPrintStaticId();
165
unsigned int jvmpiAgent_isPrintMethodId();
166
void printUsage();
167
168
/* initializeJvmpiAgentOptionsDefaults() - must be called at start up time */ 
169
void initializeJvmpiAgentOptionsDefaults();
170
171
unsigned int jvmpiAgent_isTracingHeap();
172
173
/* Piyush Agarwal */
174
/* If the piAgent is running in a controlled mode */
175
unsigned int jvmpiAgent_isControlled();
176
177
#if defined __cplusplus
178
 }
179
#endif
180
181
#endif
(-)src-native-new/src/agents/perfmon/WinBuild/rac.dsp (+119 lines)
Added Link Here
1
# Microsoft Developer Studio Project File - Name="rac" - Package Owner=<4>
2
# Microsoft Developer Studio Generated Build File, Format Version 6.00
3
# ** DO NOT EDIT **
4
5
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
6
7
CFG=rac - Win32 Release
8
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9
!MESSAGE use the Export Makefile command and run
10
!MESSAGE 
11
!MESSAGE NMAKE /f "rac.mak".
12
!MESSAGE 
13
!MESSAGE You can specify a configuration when running NMAKE
14
!MESSAGE by defining the macro CFG on the command line. For example:
15
!MESSAGE 
16
!MESSAGE NMAKE /f "rac.mak" CFG="rac - Win32 Release"
17
!MESSAGE 
18
!MESSAGE Possible choices for configuration are:
19
!MESSAGE 
20
!MESSAGE "rac - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
21
!MESSAGE "rac - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
22
!MESSAGE 
23
24
# Begin Project
25
# PROP AllowPerConfigDependencies 0
26
# PROP Scc_ProjName ""
27
# PROP Scc_LocalPath ""
28
CPP=cl.exe
29
MTL=midl.exe
30
RSC=rc.exe
31
32
!IF  "$(CFG)" == "rac - Win32 Release"
33
34
# PROP BASE Use_MFC 0
35
# PROP BASE Use_Debug_Libraries 0
36
# PROP BASE Output_Dir "rac___Win32_Release"
37
# PROP BASE Intermediate_Dir "rac___Win32_Release"
38
# PROP BASE Target_Dir ""
39
# PROP Use_MFC 0
40
# PROP Use_Debug_Libraries 0
41
# PROP Output_Dir "..\..\..\..\lib"
42
# PROP Intermediate_Dir "Release"
43
# PROP Ignore_Export_Lib 0
44
# PROP Target_Dir ""
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAC_EXPORTS" /YX /FD /c
46
# ADD CPP /nologo /MD /W3 /GX /O2 /I "../resutils" /I "../../RABindings" /I "../../../transport/RACommon" /I "../../../transport/RASocket" /I "../../../transport/RADataTransfer" /I "../../../transport/RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAC_EXPORTS" /FD /c
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
49
# ADD BASE RSC /l 0x409 /d "NDEBUG"
50
# ADD RSC /l 0x409 /d "NDEBUG"
51
BSC32=bscmake.exe
52
# ADD BASE BSC32 /nologo
53
# ADD BSC32 /nologo
54
LINK32=link.exe
55
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
56
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib /nologo /dll /machine:I386 /libpath:"../../../../lib" /implib:"../../../../lib/rac.lib" /out:"..\..\..\..\bin\rac.dll"
57
# SUBTRACT LINK32 /pdb:none
58
59
!ELSEIF  "$(CFG)" == "rac - Win32 Debug"
60
61
# PROP BASE Use_MFC 0
62
# PROP BASE Use_Debug_Libraries 0
63
# PROP BASE Output_Dir "rac___Win32_Debug"
64
# PROP BASE Intermediate_Dir "rac___Win32_Debug"
65
# PROP BASE Ignore_Export_Lib 0
66
# PROP BASE Target_Dir ""
67
# PROP Use_MFC 0
68
# PROP Use_Debug_Libraries 0
69
# PROP Output_Dir "..\..\..\..\lib"
70
# PROP Intermediate_Dir "Debug"
71
# PROP Ignore_Export_Lib 0
72
# PROP Target_Dir ""
73
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAC_EXPORTS" /FD /c
74
# ADD CPP /nologo /MD /W3 /GX /O2 /I "../resutils" /I "../../RABindings" /I "../../../transport/RACommon" /I "../../../transport/RASocket" /I "../../../transport/RADataTransfer" /I "../../../transport/RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAC_EXPORTS" /FD /c
75
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
76
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
77
# ADD BASE RSC /l 0x409 /d "NDEBUG"
78
# ADD RSC /l 0x409 /d "NDEBUG"
79
BSC32=bscmake.exe
80
# ADD BASE BSC32 /nologo
81
# ADD BSC32 /nologo
82
LINK32=link.exe
83
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib /nologo /dll /machine:I386
84
# SUBTRACT BASE LINK32 /pdb:none
85
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib /nologo /dll /machine:I386 /libpath:"../../../../lib" /implib:"../../../../lib/rac.lib" /out:"..\..\..\..\bin\rac.dll"
86
# SUBTRACT LINK32 /pdb:none
87
88
!ENDIF 
89
90
# Begin Target
91
92
# Name "rac - Win32 Release"
93
# Name "rac - Win32 Debug"
94
# Begin Group "Source Files"
95
96
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
97
# Begin Source File
98
99
SOURCE=..\rac\rac.c
100
# End Source File
101
# End Group
102
# Begin Group "Header Files"
103
104
# PROP Default_Filter "h;hpp;hxx;hm;inl"
105
# Begin Source File
106
107
SOURCE=..\rac\rac.h
108
# End Source File
109
# End Group
110
# Begin Group "Resource Files"
111
112
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
113
# Begin Source File
114
115
SOURCE=..\rac\version.rc
116
# End Source File
117
# End Group
118
# End Target
119
# End Project
(-)src-native-new/src/HCLauncher/WinBuild/HCLauncher.mak (+274 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on HCLauncher.dsp
2
!IF "$(CFG)" == ""
3
CFG=HCLaunch - Win32 Debug
4
!MESSAGE No configuration specified. Defaulting to HCLaunch - Win32 Debug.
5
!ENDIF 
6
7
!IF "$(CFG)" != "HCLaunch - Win32 Release" && "$(CFG)" != "HCLaunch - Win32 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "HCLauncher.mak" CFG="HCLaunch - Win32 Debug"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "HCLaunch - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
17
!MESSAGE "HCLaunch - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
18
!MESSAGE 
19
!ERROR An invalid configuration is specified.
20
!ENDIF 
21
22
!IF "$(OS)" == "Windows_NT"
23
NULL=
24
!ELSE 
25
NULL=nul
26
!ENDIF 
27
28
!IF  "$(CFG)" == "HCLaunch - Win32 Release"
29
30
OUTDIR=.\bin
31
INTDIR=.\Release
32
# Begin Custom Macros
33
OutDir=.\bin
34
# End Custom Macros
35
36
ALL : "$(OUTDIR)\hclaunch.dll"
37
38
39
CLEAN :
40
	-@erase "$(INTDIR)\hclaunch.obj"
41
	-@erase "$(INTDIR)\hclaunch.res"
42
	-@erase "$(INTDIR)\java.obj"
43
	-@erase "$(INTDIR)\launcher_common.obj"
44
	-@erase "$(INTDIR)\launcher_md.obj"
45
	-@erase "$(INTDIR)\launcher_os400.obj"
46
	-@erase "$(INTDIR)\RAComm.obj"
47
	-@erase "$(INTDIR)\vc60.idb"
48
	-@erase "$(OUTDIR)\hclaunch.dll"
49
	-@erase "$(OUTDIR)\hclaunch.exp"
50
	-@erase "$(OUTDIR)\hclaunch.lib"
51
52
"$(OUTDIR)" :
53
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
54
55
"$(INTDIR)" :
56
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
57
58
CPP=cl.exe
59
CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "..\RACommon" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCLaunch_EXPORTS" /Fp"$(INTDIR)\HCLauncher.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
60
61
.c{$(INTDIR)}.obj::
62
   $(CPP) @<<
63
   $(CPP_PROJ) $< 
64
<<
65
66
.cpp{$(INTDIR)}.obj::
67
   $(CPP) @<<
68
   $(CPP_PROJ) $< 
69
<<
70
71
.cxx{$(INTDIR)}.obj::
72
   $(CPP) @<<
73
   $(CPP_PROJ) $< 
74
<<
75
76
.c{$(INTDIR)}.sbr::
77
   $(CPP) @<<
78
   $(CPP_PROJ) $< 
79
<<
80
81
.cpp{$(INTDIR)}.sbr::
82
   $(CPP) @<<
83
   $(CPP_PROJ) $< 
84
<<
85
86
.cxx{$(INTDIR)}.sbr::
87
   $(CPP) @<<
88
   $(CPP_PROJ) $< 
89
<<
90
91
MTL=midl.exe
92
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
93
RSC=rc.exe
94
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hclaunch.res" /d "NDEBUG" 
95
BSC32=bscmake.exe
96
BSC32_FLAGS=/nologo /o"$(OUTDIR)\HCLauncher.bsc" 
97
BSC32_SBRS= \
98
	
99
LINK32=link.exe
100
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib rpcrt4.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\hclaunch.pdb" /machine:I386 /out:"$(OUTDIR)\hclaunch.dll" /implib:"$(OUTDIR)\hclaunch.lib" 
101
LINK32_OBJS= \
102
	"$(INTDIR)\hclaunch.obj" \
103
	"$(INTDIR)\launcher_common.obj" \
104
	"$(INTDIR)\launcher_md.obj" \
105
	"$(INTDIR)\launcher_os400.obj" \
106
	"$(INTDIR)\hclaunch.res" \
107
	"$(INTDIR)\java.obj" \
108
	"$(INTDIR)\RAComm.obj"
109
110
"$(OUTDIR)\hclaunch.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
111
    $(LINK32) @<<
112
  $(LINK32_FLAGS) $(LINK32_OBJS)
113
<<
114
115
!ELSEIF  "$(CFG)" == "HCLaunch - Win32 Debug"
116
117
OUTDIR=.\bin
118
INTDIR=.\Debug
119
# Begin Custom Macros
120
OutDir=.\bin
121
# End Custom Macros
122
123
ALL : "$(OUTDIR)\hclaunch.dll"
124
125
126
CLEAN :
127
	-@erase "$(INTDIR)\hclaunch.obj"
128
	-@erase "$(INTDIR)\hclaunch.res"
129
	-@erase "$(INTDIR)\java.obj"
130
	-@erase "$(INTDIR)\launcher_common.obj"
131
	-@erase "$(INTDIR)\launcher_md.obj"
132
	-@erase "$(INTDIR)\launcher_os400.obj"
133
	-@erase "$(INTDIR)\RAComm.obj"
134
	-@erase "$(INTDIR)\vc60.idb"
135
	-@erase "$(INTDIR)\vc60.pdb"
136
	-@erase "$(OUTDIR)\hclaunch.dll"
137
	-@erase "$(OUTDIR)\hclaunch.exp"
138
	-@erase "$(OUTDIR)\hclaunch.ilk"
139
	-@erase "$(OUTDIR)\hclaunch.lib"
140
	-@erase "$(OUTDIR)\hclaunch.pdb"
141
142
"$(OUTDIR)" :
143
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
144
145
"$(INTDIR)" :
146
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
147
148
CPP=cl.exe
149
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\RACommon" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HCLaunch_EXPORTS" /Fp"$(INTDIR)\HCLauncher.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
150
151
.c{$(INTDIR)}.obj::
152
   $(CPP) @<<
153
   $(CPP_PROJ) $< 
154
<<
155
156
.cpp{$(INTDIR)}.obj::
157
   $(CPP) @<<
158
   $(CPP_PROJ) $< 
159
<<
160
161
.cxx{$(INTDIR)}.obj::
162
   $(CPP) @<<
163
   $(CPP_PROJ) $< 
164
<<
165
166
.c{$(INTDIR)}.sbr::
167
   $(CPP) @<<
168
   $(CPP_PROJ) $< 
169
<<
170
171
.cpp{$(INTDIR)}.sbr::
172
   $(CPP) @<<
173
   $(CPP_PROJ) $< 
174
<<
175
176
.cxx{$(INTDIR)}.sbr::
177
   $(CPP) @<<
178
   $(CPP_PROJ) $< 
179
<<
180
181
MTL=midl.exe
182
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
183
RSC=rc.exe
184
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hclaunch.res" /d "_DEBUG" 
185
BSC32=bscmake.exe
186
BSC32_FLAGS=/nologo /o"$(OUTDIR)\HCLauncher.bsc" 
187
BSC32_SBRS= \
188
	
189
LINK32=link.exe
190
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib rpcrt4.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hclaunch.pdb" /debug /machine:I386 /out:"$(OUTDIR)\hclaunch.dll" /implib:"$(OUTDIR)\hclaunch.lib" /pdbtype:sept 
191
LINK32_OBJS= \
192
	"$(INTDIR)\hclaunch.obj" \
193
	"$(INTDIR)\launcher_common.obj" \
194
	"$(INTDIR)\launcher_md.obj" \
195
	"$(INTDIR)\launcher_os400.obj" \
196
	"$(INTDIR)\hclaunch.res" \
197
	"$(INTDIR)\java.obj" \
198
	"$(INTDIR)\RAComm.obj"
199
200
"$(OUTDIR)\hclaunch.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
201
    $(LINK32) @<<
202
  $(LINK32_FLAGS) $(LINK32_OBJS)
203
<<
204
205
!ENDIF 
206
207
208
!IF "$(NO_EXTERNAL_DEPS)" != "1"
209
!IF EXISTS("HCLauncher.dep")
210
!INCLUDE "HCLauncher.dep"
211
!ELSE 
212
!MESSAGE Warning: cannot find "HCLauncher.dep"
213
!ENDIF 
214
!ENDIF 
215
216
217
!IF "$(CFG)" == "HCLaunch - Win32 Release" || "$(CFG)" == "HCLaunch - Win32 Debug"
218
SOURCE=..\HCLauncher\hclaunch.c
219
220
"$(INTDIR)\hclaunch.obj" : $(SOURCE) "$(INTDIR)"
221
	$(CPP) $(CPP_PROJ) $(SOURCE)
222
223
224
SOURCE=..\RACommon\java.c
225
226
"$(INTDIR)\java.obj" : $(SOURCE) "$(INTDIR)"
227
	$(CPP) $(CPP_PROJ) $(SOURCE)
228
229
230
SOURCE=..\HCLauncher\launcher_common.c
231
232
"$(INTDIR)\launcher_common.obj" : $(SOURCE) "$(INTDIR)"
233
	$(CPP) $(CPP_PROJ) $(SOURCE)
234
235
236
SOURCE=..\HCLauncher\launcher_md.c
237
238
"$(INTDIR)\launcher_md.obj" : $(SOURCE) "$(INTDIR)"
239
	$(CPP) $(CPP_PROJ) $(SOURCE)
240
241
242
SOURCE=..\HCLauncher\launcher_os400.c
243
244
"$(INTDIR)\launcher_os400.obj" : $(SOURCE) "$(INTDIR)"
245
	$(CPP) $(CPP_PROJ) $(SOURCE)
246
247
248
SOURCE=..\RACommon\RAComm.c
249
250
"$(INTDIR)\RAComm.obj" : $(SOURCE) "$(INTDIR)"
251
	$(CPP) $(CPP_PROJ) $(SOURCE)
252
253
254
SOURCE=..\HCLauncher\version.rc
255
256
!IF  "$(CFG)" == "HCLaunch - Win32 Release"
257
258
259
"$(INTDIR)\hclaunch.res" : $(SOURCE) "$(INTDIR)"
260
	$(RSC) /l 0x409 /fo"$(INTDIR)\hclaunch.res" /i "\eclipse\head-workspace\org.eclipse.tptp.platform.agentcontroller\src-native\collection\framework\HCLauncher" /d "NDEBUG" $(SOURCE)
261
262
263
!ELSEIF  "$(CFG)" == "HCLaunch - Win32 Debug"
264
265
266
"$(INTDIR)\hclaunch.res" : $(SOURCE) "$(INTDIR)"
267
	$(RSC) /l 0x409 /fo"$(INTDIR)\hclaunch.res" /i "\eclipse\head-workspace\org.eclipse.tptp.platform.agentcontroller\src-native\collection\framework\HCLauncher" /d "_DEBUG" $(SOURCE)
268
269
270
!ENDIF 
271
272
273
!ENDIF 
274
(-)src-native-new/src/agents/java/WinBuild/log_agent.dsp (+123 lines)
Added Link Here
1
# Microsoft Developer Studio Project File - Name="log_agent" - Package Owner=<4>
2
# Microsoft Developer Studio Generated Build File, Format Version 6.00
3
# ** DO NOT EDIT **
4
5
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
6
7
CFG=log_agent - Win32 Debug
8
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9
!MESSAGE use the Export Makefile command and run
10
!MESSAGE 
11
!MESSAGE NMAKE /f "log_agent.mak".
12
!MESSAGE 
13
!MESSAGE You can specify a configuration when running NMAKE
14
!MESSAGE by defining the macro CFG on the command line. For example:
15
!MESSAGE 
16
!MESSAGE NMAKE /f "log_agent.mak" CFG="log_agent - Win32 Debug"
17
!MESSAGE 
18
!MESSAGE Possible choices for configuration are:
19
!MESSAGE 
20
!MESSAGE "log_agent - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
21
!MESSAGE "log_agent - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
22
!MESSAGE 
23
24
# Begin Project
25
# PROP AllowPerConfigDependencies 0
26
# PROP Scc_ProjName ""
27
# PROP Scc_LocalPath ""
28
CPP=cl.exe
29
MTL=midl.exe
30
RSC=rc.exe
31
32
!IF  "$(CFG)" == "log_agent - Win32 Release"
33
34
# PROP BASE Use_MFC 0
35
# PROP BASE Use_Debug_Libraries 0
36
# PROP BASE Output_Dir "Release"
37
# PROP BASE Intermediate_Dir "Release"
38
# PROP BASE Target_Dir ""
39
# PROP Use_MFC 0
40
# PROP Use_Debug_Libraries 0
41
# PROP Output_Dir "bin"
42
# PROP Intermediate_Dir "Release"
43
# PROP Ignore_Export_Lib 0
44
# PROP Target_Dir ""
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LOG_AGENT_EXPORTS" /YX /FD /c
46
# ADD CPP /nologo /MT /W3 /GX /O2 /Ob0 /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LOG_AGENT_EXPORTS" /YX /FD /c
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
49
# ADD BASE RSC /l 0x409 /d "NDEBUG"
50
# ADD RSC /l 0x409 /fo"Release/hcjbnd.res" /d "NDEBUG"
51
BSC32=bscmake.exe
52
# ADD BASE BSC32 /nologo
53
# ADD BSC32 /nologo
54
LINK32=link.exe
55
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
56
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hcclco.lib hccldt.lib hccls.lib hcbnd.lib hcclsm.lib /nologo /version:0.1 /dll /map /machine:I386 /out:"..\..\..\..\bin\hcjbnd.dll" /libpath:"..\..\..\..\lib"
57
58
!ELSEIF  "$(CFG)" == "log_agent - Win32 Debug"
59
60
# PROP BASE Use_MFC 0
61
# PROP BASE Use_Debug_Libraries 1
62
# PROP BASE Output_Dir "Debug"
63
# PROP BASE Intermediate_Dir "Debug"
64
# PROP BASE Target_Dir ""
65
# PROP Use_MFC 0
66
# PROP Use_Debug_Libraries 1
67
# PROP Output_Dir "bin"
68
# PROP Intermediate_Dir "Debug"
69
# PROP Ignore_Export_Lib 0
70
# PROP Target_Dir ""
71
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LOG_AGENT_EXPORTS" /YX /FD /GZ /c
72
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\RABindings" /I "..\..\..\transport\RACommon" /I "..\..\..\transport\RASocket" /I "..\..\..\transport\RADataTransfer" /I "..\..\..\transport\RASharedMemory" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LOG_AGENT_EXPORTS" /YX /FD /GZ /c
73
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
74
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
75
# ADD BASE RSC /l 0x409 /d "_DEBUG"
76
# ADD RSC /l 0x409 /fo"Debug/hcjbnd.res" /d "_DEBUG"
77
BSC32=bscmake.exe
78
# ADD BASE BSC32 /nologo
79
# ADD BSC32 /nologo
80
LINK32=link.exe
81
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
82
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib hcclco.lib hccldt.lib hccls.lib hcbnd.lib hcclsm.lib /nologo /dll /debug /machine:I386 /out:"..\..\..\..\bin\hcjbnd.dll" /pdbtype:sept /libpath:"..\..\..\..\lib"
83
84
!ENDIF 
85
86
# Begin Target
87
88
# Name "log_agent - Win32 Release"
89
# Name "log_agent - Win32 Debug"
90
# Begin Group "Source Files"
91
92
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
93
# Begin Source File
94
95
SOURCE=..\hcjbnd.c
96
# End Source File
97
# Begin Source File
98
99
SOURCE=..\hcjbnd.def
100
# End Source File
101
# End Group
102
# Begin Group "Header Files"
103
104
# PROP Default_Filter "h;hpp;hxx;hm;inl"
105
# Begin Source File
106
107
SOURCE=..\hcjbnd.h
108
# End Source File
109
# Begin Source File
110
111
SOURCE=..\resource.h
112
# End Source File
113
# End Group
114
# Begin Group "Resource Files"
115
116
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
117
# Begin Source File
118
119
SOURCE=..\version.rc
120
# End Source File
121
# End Group
122
# End Target
123
# End Project
(-)src-native-new/src/agents/native/java_profiler/options.c (+1373 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: options.c,v 1.11 2006/05/05 03:21:22 bduncan Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include <string.h>
14
#include <stdio.h>
15
#include <ctype.h>
16
#include <stdlib.h>
17
#include <errno.h>
18
#include <sys/types.h>
19
#include <sys/stat.h>
20
21
#ifdef _WIN32
22
#include <io.h>
23
#include <direct.h>
24
#define MKDIR(dirname) mkdir(dirname)
25
#else
26
#define MKDIR(dirname) mkdir((dirname), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
27
#endif
28
29
#include "options.h"
30
#include "filters.h"
31
#include "JvmpiWriter.h"
32
#include "eventmask.h"
33
#include "print.h"
34
#include "utility.h"
35
36
/**
37
  * MACROS
38
  * To make the code more readable ;-)
39
  */
40
#ifdef _WIN32
41
 #define STRICOLL _stricoll		/* Case insensitive on Windows */
42
#else
43
 #define STRICOLL strcoll		/* Case sensitive on other platforms */
44
#endif
45
46
/* following two undefs were added to avoid conflict from new java.h defs ... 135623 */
47
#undef ATTACH_THREAD
48
#undef DETACH_THREAD
49
50
#if defined __cplusplus && defined _HPUX
51
  #define ENV(e) e
52
 #define ATTACH_THREAD(env) (_jvmpiAgent_jvm)->AttachCurrentThread((void**)&env, NULL)
53
 #define DETACH_THREAD() (_jvmpiAgent_jvm)->DetachCurrentThread()
54
 #define ENVPARM(env)
55
#else
56
 #define ENV(e) (*e)
57
 #define ATTACH_THREAD(env) (*_jvmpiAgent_jvm)->AttachCurrentThread(_jvmpiAgent_jvm,  (void**)&env, NULL)
58
 #define DETACH_THREAD() (*_jvmpiAgent_jvm)->DetachCurrentThread(_jvmpiAgent_jvm)
59
  #define ENVPARM(env) env,
60
#endif
61
62
#define BOOLTOSTRING(b) (b ? "true" : "false")
63
64
65
#ifdef MVS
66
#pragma convlit(suspend)
67
#endif
68
static const char* piAgentVersion= "@(#)piAgent version 6.0.0.0";
69
#ifdef MVS
70
#pragma convlit(resume)
71
#endif
72
73
/** Globals
74
  */
75
Options _jvmpiAgent_Options =
76
{
77
  0							/* Do not output Unreferenced Symbols */
78
 ,1							/* Provide timestamps by default */
79
 ,0							/* Debug Hash table option */
80
 ,0							/* Standalone mode */
81
 ,0							/* Application mode */
82
 ,1							/* Enabled mode */
83
 ,0							/* TraceExceptions */
84
 ,0							/* EnableExceptions - MW Changed the default to "no" */
85
 ,0							/* enableLineCoverage -  */
86
 ,0                         /* CollationValues  */
87
 ,1                         /* Filters */
88
 ,1                         /* Options */
89
 ,0                         /* TraceIdrefs  */
90
 ,1                         /* GcDefaults */
91
 ,0                         /* MethodCounts  */
92
 ,0                         /* ClassLoadDetails */
93
 ,0 						/* MethodDetail */
94
 ,1                         /* OBJ_ALLOC_IS_ARRAY (default) */
95
 ,0                         /* CONTEXT_FLOW */
96
 ,1                         /* TICKET (default) */
97
 ,0							/* MODE SET */
98
 ,0							/* EXCEPTION TRACING SET */
99
 ,0							/* LINE COVERAGE SET */
100
 ,0							/* GC SET */
101
 ,0							/* HEAP INFO COUNT SET */
102
 ,0							/* HEAP INFO FILE PREFIX SET */
103
 ,0							/* Jinsight I/O */
104
 ,0							/* cpuTime */
105
 ,0							/* LLDATA_ENABLED */
106
 ,IdStyleStatic
107
 ,Filter4Owner				/* Heap dump preference (default) */
108
 ,GcDeletes
109
 ,StackInfoContiguous		/* Stack mode preference (default) */
110
 ,CompressNone              /* Compression level (default) */ /* 140009 */ 
111
 /* ,HeapInfoAll -- Depreciated */
112
 ,TraceModeFull
113
 ,TraceStartModeFilter	
114
 ,BurstModeNone	
115
 ,MonitorNone
116
 ,0							/* Burst timer */
117
 ,0							/* Burst invocations */
118
 ,1							/* boundary depth */
119
 ,2							/* heapInfoCount */
120
 #ifdef _HPUX
121
 ,{(enum _dataTarget)0,0}	/* Target Handle initialization - 171664 initialize to RA_SOCKET (0) type */
122
 #else
123
 ,{0,0}						/* Target Handle initialization - 171664 initialize to RA_SOCKET (0) type */
124
 #endif
125
 , NULL						/* The invocation options from the command line */
126
 , NULL						/* Filter File  (to be initialized) */
127
 , NULL						/* Triggers file (to be initialized) */
128
 , NULL						/* Default process name (to be initialized) */
129
 , NULL						/* Default process type (to be initialized) */
130
 , NULL						/* Default trace file name (to be initialized) */
131
 , NULL						/* heapInfoFilePrefix (to be initialized) */
132
 , NULL						/*Default profile file name (to be initialized) */
133
 , NULL						/* Defualt working dir (to be initialized) */
134
 , NULL						/* agent extension library name to load (empty means none) (to be initialized) */
135
 , NULL                     /* currently no unknown options */ 
136
 , 0                        /* method_counts_only is off by default */ 
137
};
138
139
#define DEFAULT_FILTER_FILENAME		"filters.txt"
140
#define DEFAULT_TRIGGER_FILENAME	"triggers.txt"
141
#define DEFAULT_PROCESS_NAME		"Java Profiling Agent"
142
#define DEFAULT_PROCESS_TYPE		"Profiler"
143
#define DEFAULT_OUTPUT_FILENAME		"trace.trcxml"
144
#define DEFAULT_HEAPINFO_FILEPREFIX "optHeap"
145
#define DEFAULT_PROFILE_FILE		"jvmpi.pro"
146
#define DEFAULT_WORK_DIR			"."
147
#define DEFAULT_EXTENSION_LIBRARY	""
148
149
void initializeJvmpiAgentOptionsDefaults() {
150
	/* initialize filterFileName */ 
151
	_jvmpiAgent_Options.filterFileName = (char *) malloc(strlen(DEFAULT_FILTER_FILENAME)+1);
152
	strcpy(_jvmpiAgent_Options.filterFileName,DEFAULT_FILTER_FILENAME);
153
154
	/* initialize trigger filename */ 
155
	_jvmpiAgent_Options.triggerFileName = (char *)malloc(strlen(DEFAULT_TRIGGER_FILENAME)+1);
156
	strcpy(_jvmpiAgent_Options.triggerFileName, DEFAULT_TRIGGER_FILENAME); 
157
158
	/* initialize process name */ 
159
	_jvmpiAgent_Options.processName = (char *)malloc(strlen(DEFAULT_PROCESS_NAME)+1); 
160
	strcpy(_jvmpiAgent_Options.processName,DEFAULT_PROCESS_NAME); 
161
162
	/* initialize process type */
163
	_jvmpiAgent_Options.processType = (char *)malloc(strlen(DEFAULT_PROCESS_TYPE)+1); 
164
	strcpy(_jvmpiAgent_Options.processType,DEFAULT_PROCESS_TYPE); 
165
166
	/* initialize output file */ 
167
	_jvmpiAgent_Options.outputFileName = (char *)malloc(strlen(DEFAULT_OUTPUT_FILENAME)+1);
168
	strcpy(_jvmpiAgent_Options.outputFileName,DEFAULT_OUTPUT_FILENAME);
169
170
	/* initialize the heap info file prefix */ 
171
	_jvmpiAgent_Options.heapInfoFilePrefix = (char *)malloc(strlen(DEFAULT_HEAPINFO_FILEPREFIX)+1);
172
	strcpy(_jvmpiAgent_Options.heapInfoFilePrefix,DEFAULT_HEAPINFO_FILEPREFIX); 
173
174
	/* intiialize the profile file */ 
175
	_jvmpiAgent_Options.profileFile = (char *)malloc(strlen(DEFAULT_PROFILE_FILE)+1); 
176
	strcpy(_jvmpiAgent_Options.profileFile,DEFAULT_PROFILE_FILE);
177
178
	/* initiailize the working dir */ 
179
	_jvmpiAgent_Options.workDir = (char *)malloc(strlen(DEFAULT_WORK_DIR)+1); 
180
	strcpy(_jvmpiAgent_Options.workDir,DEFAULT_WORK_DIR); 
181
182
	/* initialize the extension library */ 
183
	_jvmpiAgent_Options.extensionLibrary = (char *)malloc(strlen(DEFAULT_EXTENSION_LIBRARY)+1); 
184
	strcpy(_jvmpiAgent_Options.extensionLibrary,DEFAULT_EXTENSION_LIBRARY); 
185
186
}
187
188
static int getToken(char **src, char *buf, int buflen, char sep)
189
{
190
 int i;
191
 char *p = *src;
192
 for (i = 0; i < buflen; i++)
193
 {
194
   if (p[i] == 0 || p[i] == sep)
195
   {
196
     buf[i] = 0;
197
     if (p[i] == sep)
198
     {
199
       i++;
200
     }
201
	  *src += i;
202
	  return i;
203
   }
204
   buf[i] = p[i];
205
 }
206
 /* overflow */
207
 return 0;
208
}
209
210
211
/** PRINT_USAGE **********************************************************************
212
  * Print the command line useage of the program.
213
  */
214
void printUsage()
215
{
216
#ifdef MVS                    /* 174190 */
217
#pragma convlit(suspend)
218
#endif
219
	fprintf(stdout,
220
	"\n%s\n"
221
    "usage: -XrunpiAgent[:[help]|[<option>=<value>, ...]]\n"
222
    "\n"
223
    "Option Name and Values\tDescription (Default value)\n"
224
    "----------------------\t---------------------------\n"
225
    "file=<file>\t\tName of output file.  Only used when server=standalone.(trace.trcxml)\n"
226
    "filters=<file>\t\tName of filter definitions.  Only used when server=standalone.(filters.txt)\n"
227
#if 0
228
    "profile=<file>\t\tname of profile file.  Only used when server=standalone.(jvmpi.pro)\n"
229
#ifdef _DEBUG
230
    "debug=hash\t\toutputs the specified debugging information. (disabled in production build)\n"
231
#endif
232
#endif
233
	"mode=full|noObjectCorrelation|sampling|heap|optHeap\tCollect object execution information?.(full)\n"
234
	"server=standalone|enabled|controlled|application\tSpecifies how the Agent is to be run.(enabled)\n"
235
#if 0
236
    "enableExceptionTracing=yes|no\tEnable JVM Exception tracing.(no)\n"
237
	"enableLineCoverage=no|yes\tEnable Line coverage.(no)\n"
238
#endif
239
	"trackGcEvent=default|none|moves|frees|movesAndFrees\t Specifies the GC events that need to be tracked\n"
240
	"optHeapCount\tSpecifies the number of heap dumps in each cycle, default 2, maximum 50\n"
241
	"optHeapFilePrefix\tSpecifies the prefix of heap dump files (optHeap)\n"
242
	"extensionLibrary\tSpecifies an agent extension library path and name to load in stand-alone mode\n"
243
    "Example: java -XrunpiAgent:file=log.trcxml <classname>\n"
244
	"\n", piAgentVersion);
245
	fflush(stdout); 
246
#ifdef MVS                    /* 174190 */
247
#pragma convlit(resume)
248
#endif
249
}
250
251
/** STRIP_LEADING_BLANKS **************************************************************
252
  * Remove all spaces from the beginning of a buffer
253
  */
254
static char * stripLeadingBlanks(char * buffer)
255
{
256
 int i;
257
 int len = strlen(buffer);
258
 for (i = 0; i <= len; i++)
259
 {
260
  if (!isspace(buffer[i]))
261
  {
262
   return buffer+i;
263
  }
264
 }
265
 return buffer;
266
}
267
268
269
270
#ifdef MVS                    /* 174190 */
271
#pragma convlit(suspend)
272
#endif
273
274
static int setBooleanOption(char * value, char * key, int defaultValue)
275
{
276
 if (STRICOLL(value, "true") == 0)
277
  {
278
   return 1;
279
  }
280
  else if(STRICOLL(value, "false") == 0)
281
  {
282
   return 0;
283
  }
284
  else
285
  {
286
   fprintf(stderr, "Invalid %s option value \"%s\"\n", key, value);
287
   fflush(stderr); 
288
   return defaultValue;
289
  }
290
}
291
292
#ifdef MVS                    /* 174190 */
293
#pragma convlit(resume)
294
#endif
295
296
/* Piyush Agarwal 
297
   Get the absolute directory path for the optheap working dir*/
298
static void jvmpiAgent_getWorkDir(char* buf)
299
{
300
/* Bug 64476 */
301
#ifdef MVS
302
#pragma convlit(suspend)
303
#endif
304
#ifdef MVS
305
__atoe(_jvmpiAgent_Options.workDir) ;
306
#endif
307
	realpath(_jvmpiAgent_Options.workDir,buf);
308
	buf += strlen(buf);
309
#ifdef MVS
310
__etoa(_jvmpiAgent_Options.workDir) ;
311
#endif
312
#ifdef _WIN32
313
	*buf = '\\'; /* file delim in Windows */
314
#else
315
	*buf = '/'; /* file delim in Unix */
316
#endif
317
	buf += 1; *buf = '\0';
318
#ifdef MVS
319
#pragma convlit(resume)
320
#endif
321
322
}
323
324
/** PRINT_OPTIONS *********************************************************************
325
  *
326
  */
327
void jvmpiAgent_printOptions()
328
{
329
 char fulldirpath[PATH_MAX];
330
 ThreadPrivateStorage *tps=jvmpiAgent_getThreadLocalStorage(0);
331
332
 jvmpiAgent_PrintOption(tps, "CLASS_LOAD_DETAILS", BOOLTOSTRING(_jvmpiAgent_Options.classLoadDetails));
333
 jvmpiAgent_PrintOption(tps, "METHOD_DETAILS", BOOLTOSTRING(_jvmpiAgent_Options.methodDetails));
334
 jvmpiAgent_PrintOption(tps, "COLLATION_VALUES", BOOLTOSTRING(_jvmpiAgent_Options.collationValues));
335
 jvmpiAgent_PrintOption(tps, "CONTEXT_FLOW", BOOLTOSTRING(_jvmpiAgent_Options.contextFlow));
336
#if 0
337
 jvmpiAgent_PrintOption(tps, "EXCEPTION_TRACING", BOOLTOSTRING(_jvmpiAgent_Options.traceExceptions));
338
#endif
339
 jvmpiAgent_PrintOption(tps, "FILTERS", BOOLTOSTRING(_jvmpiAgent_Options.filters));
340
 /* "GC" is depreciated */
341
 jvmpiAgent_PrintOption(tps, "TRACK_GC_EVENT_TYPES", _jvmpiAgent_Options.gc == GcNone ? "none" : _jvmpiAgent_Options.gc == GcDeletes ? "frees" : _jvmpiAgent_Options.gc == GcMoves ? "moves" : "freesAndMoves");
342
 jvmpiAgent_PrintOption(tps, "ID_STYLE", _jvmpiAgent_Options.idStyle == IdStyleStatic ? "static" : _jvmpiAgent_Options.idStyle == IdStyleRelocatable ? "relocatable" : "staticAndRelocatable");
343
 jvmpiAgent_PrintOption(tps, "OBJ_REF_MODE", _jvmpiAgent_Options.objRefMode == RespectFilter ? "respectFilter" : _jvmpiAgent_Options.objRefMode == Filter4Owner ? "filterOwner" : "ignoreFilter");
344
 jvmpiAgent_PrintOption(tps, "METHOD_COUNTS", BOOLTOSTRING(_jvmpiAgent_Options.methodCounts));
345
 jvmpiAgent_PrintOption(tps, "OBJ_ALLOC_IS_ARRAY", BOOLTOSTRING(_jvmpiAgent_Options.objAllocIsArray));
346
 jvmpiAgent_PrintOption(tps, "OPTIONS", BOOLTOSTRING(_jvmpiAgent_Options.options));
347
 jvmpiAgent_PrintOption(tps, "STACK_INFORMATION", _jvmpiAgent_Options.stackInfo == StackInfoNone ? "none" : _jvmpiAgent_Options.stackInfo == StackInfoNormal ? "normal" : _jvmpiAgent_Options.stackInfo == StackInfoBoundary ? "boundary" : _jvmpiAgent_Options.stackInfo == StackInfoContiguous ? "contiguous" : "boundaryAndContiguous");
348
 jvmpiAgent_PrintOption(tps, "COMPRESS", _jvmpiAgent_Options.compressLevel == CompressNone ? "none" : "aggregate");  /* 140009 */
349
 /* Depreciated: jvmpiAgent_PrintOption(tps, "ALLOCATION_INFORMATION", _jvmpiAgent_Options.heapInfo == HeapInfoAll ? "all" : "none" ); */
350
 jvmpiAgent_PrintOption(tps, "TRACE_MODE", 
351
	 _jvmpiAgent_Options.mode == TraceModeFull ? "full" : 
352
	 _jvmpiAgent_Options.mode == TraceModeNoObjectCorrelation ? "noObjectCorrelation" : 
353
	 _jvmpiAgent_Options.mode == TraceModeStackSampling ? "sampling" : 
354
	 _jvmpiAgent_Options.mode == TraceHeap ? "heap" : 
355
	 _jvmpiAgent_Options.mode == TraceOptimizedHeap ? "optHeap" : 
356
	 _jvmpiAgent_Options.mode == TraceModeNone ? "none" : 
357
	 "unknown_mode_value");
358
 jvmpiAgent_PrintOption(tps, "TICKET", BOOLTOSTRING(_jvmpiAgent_Options.ticket));
359
 jvmpiAgent_PrintOption(tps, "TIMESTAMPS", BOOLTOSTRING(_jvmpiAgent_Options.timestamp));
360
 jvmpiAgent_PrintOption(tps, "TRACE_IDREFS", BOOLTOSTRING(_jvmpiAgent_Options.traceIdrefs));
361
 jvmpiAgent_PrintOption(tps, "UNREFERENCED_SYMBOLS", BOOLTOSTRING(_jvmpiAgent_Options.unreferencedSymbols));
362
 jvmpiAgent_PrintOption(tps, "CPU_TIME", BOOLTOSTRING(_jvmpiAgent_Options.cpuTime));
363
 jvmpiAgent_PrintOption(tps, "LLDATA_ENABLED", BOOLTOSTRING(_jvmpiAgent_Options.llDataEnabled));
364
 jvmpiAgent_PrintOption(tps, "HEAP_INFO_FILE_PREFIX", _jvmpiAgent_Options.heapInfoFilePrefix);
365
 jvmpiAgent_PrintOption(tps, "MONITOR_MODE",_jvmpiAgent_Options.monitorMode == MonitorAll ? "all" : "none");
366
 jvmpiAgent_PrintOption(tps, "METHOD_COUNTS_ONLY", BOOLTOSTRING(_jvmpiAgent_Options.methodCountsOnly)); 
367
368
 /* Piyush Agarwal */
369
 /* Send options specifying that this is an optimized heap and also the work dir */
370
  /* Giri: <Defect 64462> Added the check for standalone mode instead of controlled mode */
371
 if ( !_jvmpiAgent_Options.standalone && _jvmpiAgent_Options.mode == TraceOptimizedHeap )
372
 {
373
   jvmpiAgent_getWorkDir(fulldirpath) ;
374
/* Bug 64476 */
375
#ifdef MVS
376
   __etoa(fulldirpath) ;
377
#endif
378
   jvmpiAgent_PrintOption(tps, "WORK_DIR", fulldirpath);
379
   jvmpiAgent_PrintOption(tps, "HEAP_FILE_TYPE", "optHeap" );
380
   jvmpiAgent_PrintOption(tps, "MULTIPLE_HEAP_DUMPS", "true" );
381
   jvmpiAgent_PrintOption(tps, "HEAP_FILE_SOURCE", "RAC" );
382
   
383
 }
384
 jvmpiAgent_PrintOption(tps, "EXTENSION_LIBRARY", _jvmpiAgent_Options.extensionLibrary);
385
386
 /* 60879 print all the 'unknown' options. These are the options that the piAgent doesn't care about. Despite
387
 this, we need to echo these options back to the UI. */ 
388
 {
389
	 generic_option *cur_unknown = _jvmpiAgent_Options.unknowns; 
390
	 while (cur_unknown != NULL) {
391
		 jvmpiAgent_PrintOption(tps,cur_unknown->key,cur_unknown->value);
392
		 cur_unknown = cur_unknown->next; 
393
	 }
394
 }
395
}
396
397
/**
398
 * addUnknownOption - 60879 add a key,value pair that the piAgent doesn't care about
399
 * as an 'unknown' to the _jvmpiAgent_Options structure so that we can later echo
400
 * it back to the UI. 
401
 ***/ 
402
 static void addUnknownOption(char *key, char *value) {
403
	 /* _jvmpiAgent_Options.unknowns is essentially a linked list. We only expect to encounter a dozen 
404
	    or so unknown options, and moreover, we only do this processing once at start up. Hence the
405
		performance impact of not using a more sophisticated data structure is negligible.  */ 
406
		
407
408
	 /* find a spot in the linked list where we can add the new unknown */ 
409
	 generic_option *new_unknown = NULL; 
410
	 if (_jvmpiAgent_Options.unknowns == NULL) {
411
		 _jvmpiAgent_Options.unknowns = (generic_option *) malloc(sizeof(generic_option)); 
412
		 memset(_jvmpiAgent_Options.unknowns,0,sizeof(generic_option));
413
		 new_unknown = _jvmpiAgent_Options.unknowns; 
414
	 } else {
415
		 generic_option *cur_unknown = _jvmpiAgent_Options.unknowns; 
416
		 while (cur_unknown->next != NULL) {
417
			 cur_unknown = cur_unknown->next; 
418
		 }
419
		 new_unknown = (generic_option *) malloc(sizeof(generic_option)); 
420
		 memset(new_unknown,0,sizeof(generic_option)); 
421
		 cur_unknown->next = new_unknown; 
422
	 }
423
424
	 /* set the new unknown option */ 
425
	 new_unknown->key = (char *) malloc(strlen(key)*sizeof(char)+1); 
426
	 strcpy(new_unknown->key,key); 
427
	 new_unknown->value = (char *) malloc(strlen(value)*sizeof(char)+1); 
428
	 strcpy(new_unknown->value,value); 
429
	
430
 }
431
432
433
434
435
/** SET_PROFILE_OPTION *******************************************************************
436
  *
437
  */
438
#ifdef MVS                    /* 174190 */
439
#pragma convlit(suspend)
440
#endif
441
442
int jvmpiAgent_SetProfileOption(char * key, char * value)
443
{
444
445
	if (key == NULL || value == NULL) {
446
		return 0;
447
	}
448
449
 if (STRICOLL(key, "CLASS_LOAD_DETAILS") == 0)
450
 {
451
  _jvmpiAgent_Options.classLoadDetails = setBooleanOption(value, key, _jvmpiAgent_Options.classLoadDetails);
452
 }
453
454
 else if (STRICOLL(key,"METHOD_COUNTS_ONLY") == 0) 
455
 {
456
	 _jvmpiAgent_Options.methodCountsOnly = setBooleanOption(value, key, _jvmpiAgent_Options.methodCountsOnly);
457
	 /* turn on methodCounts option if methodCountsOnly option is turned on */ 
458
	 _jvmpiAgent_Options.methodCounts = setBooleanOption(value, key, _jvmpiAgent_Options.methodCountsOnly);
459
 }
460
461
 else if (STRICOLL(key, "METHOD_DETAILS") == 0)
462
 {
463
  _jvmpiAgent_Options.methodDetails = setBooleanOption(value, key, _jvmpiAgent_Options.methodDetails);
464
 }
465
466
 else if (STRICOLL(key, "COLLATION_VALUES") == 0)
467
 {
468
  _jvmpiAgent_Options.collationValues = setBooleanOption(value, key, _jvmpiAgent_Options.collationValues);
469
 }
470
 else if (STRICOLL(key, "CONTEXT_FLOW") == 0)
471
 {
472
  _jvmpiAgent_Options.contextFlow = setBooleanOption(value, key, _jvmpiAgent_Options.contextFlow);
473
 }
474
 else if (STRICOLL(key, "EXCEPTION_TRACING") == 0)
475
 {
476
  if(!_jvmpiAgent_Options.exceptionTracingSet)
477
  {
478
    _jvmpiAgent_Options.traceExceptions = setBooleanOption(value, key, _jvmpiAgent_Options.traceExceptions);
479
    /* Call the Java method to record the Exception Tracing state change */
480
    if (_jvmpiAgent_setExceptionTracing)
481
	{
482
      JNIEnv *env;
483
	  ATTACH_THREAD(env);
484
      ENV(env)->CallStaticVoidMethod(ENVPARM(env) _jvmpiAgent_JVMPIException, _jvmpiAgent_setExceptionTracing, (jboolean)_jvmpiAgent_Options.traceExceptions );
485
	  DETACH_THREAD();
486
	}
487
  }
488
 }
489
 else if (STRICOLL(key, "FILTERS") == 0)
490
 {
491
  _jvmpiAgent_Options.filters = setBooleanOption(value, key, _jvmpiAgent_Options.filters);
492
 }
493
 else if ((STRICOLL(key, "GC") == 0 || STRICOLL(key, "TRACK_GC_EVENT_TYPES") == 0)
494
			&& !_jvmpiAgent_Options.gcSet)
495
 {
496
  if (STRICOLL(value, "default") == 0)
497
  {
498
   _jvmpiAgent_Options.gcDefault = 1;
499
  }
500
  else
501
  {
502
   _jvmpiAgent_Options.gcDefault = 0;
503
   if (STRICOLL(value, "none") == 0)
504
   {
505
    _jvmpiAgent_Options.gc = GcNone;
506
   }
507
   else if (STRICOLL(value, "deletes") == 0 || STRICOLL(value, "frees") == 0)
508
   {
509
	/* "deletes" should be depreciated */
510
    _jvmpiAgent_Options.gc = GcDeletes;
511
   }
512
   else if (STRICOLL(value, "moves") == 0)
513
   {
514
    _jvmpiAgent_Options.gc = GcMoves;
515
   }
516
   else if (STRICOLL(value, "deletesAndMoves") == 0 || STRICOLL(value, "movesAndFrees") == 0)
517
   {
518
	/* "deletesAndMoves" should be depreciated */
519
    _jvmpiAgent_Options.gc = GcDeletesAndMoves;
520
   }
521
   else
522
   {
523
    fprintf(stderr, "Invalid %s option value \"%s\"\n", key, value);
524
	fflush(stderr); 
525
    return -1;
526
   }
527
  }
528
 }
529
 else if (STRICOLL(key, "ID_STYLE") == 0)
530
 {
531
  if (STRICOLL(value, "static") == 0)
532
  {
533
   _jvmpiAgent_Options.idStyle = IdStyleStatic;
534
  }
535
  else if (STRICOLL(value, "relocatable") == 0)
536
  {
537
   _jvmpiAgent_Options.idStyle = IdStyleRelocatable;
538
  }
539
  else if (STRICOLL(value, "staticAndRelocatable") == 0)
540
  {
541
   _jvmpiAgent_Options.idStyle = IdStyleStaticAndRelocatable;
542
  }
543
  else
544
  {
545
   fprintf(stderr, "Invalid %s option value \"%s\"\n", key, value);
546
   fflush(stderr); 
547
   return -1;
548
  }
549
 }
550
 else if (STRICOLL(key, "OBJ_REF_MODE") == 0)
551
 {
552
  if (STRICOLL(value, "respectFilter") == 0)
553
  {
554
   _jvmpiAgent_Options.objRefMode = RespectFilter;
555
  }
556
  else if (STRICOLL(value, "filterOwner") == 0)
557
  {
558
   _jvmpiAgent_Options.objRefMode = Filter4Owner;
559
  }
560
  else if (STRICOLL(value, "ignoreFilter") == 0)
561
  {
562
   _jvmpiAgent_Options.objRefMode = IgnoreFilter;
563
  }
564
  else
565
  {
566
   fprintf(stderr, "Invalid %s option value \"%s\"\n", key, value);
567
   fflush(stderr); 
568
   return -1;
569
  }
570
 }
571
 else if (STRICOLL(key, "TRACE_MODE") == 0)
572
 {
573
  if(!_jvmpiAgent_Options.modeSet)
574
  {
575
    if (STRICOLL(value, "full") == 0)
576
	{
577
      _jvmpiAgent_Options.mode = TraceModeFull;
578
	}
579
	else if (STRICOLL(value, "noObjectCorrelation") == 0)
580
	{
581
      _jvmpiAgent_Options.mode = TraceModeNoObjectCorrelation;
582
	}
583
    else if (STRICOLL(value, "sampling") == 0)
584
	{
585
       _jvmpiAgent_Options.mode = TraceModeStackSampling;
586
	}
587
	else if (STRICOLL(value, "heap") == 0)
588
	{
589
	  _jvmpiAgent_Options.mode = TraceHeap;
590
	  if ( _jvmpiAgent_Options.gcDefault )
591
	    _jvmpiAgent_Options.gc = GcMoves;
592
	}
593
	else if (STRICOLL(value, "optHeap") == 0)
594
	{
595
	  _jvmpiAgent_Options.mode = TraceOptimizedHeap;
596
	  if ( _jvmpiAgent_Options.gcDefault )
597
	    _jvmpiAgent_Options.gc = GcMoves;
598
	
599
	}
600
	else if (STRICOLL(value, "none") == 0)
601
	{
602
	  _jvmpiAgent_Options.mode = TraceModeNone;
603
	}
604
	else
605
	{
606
      fprintf(stderr, "Invalid %s option value \"%s\"\n", key, value);
607
	  fflush(stderr); 
608
      return -1;
609
	}
610
  }
611
 }
612
 else if(STRICOLL(key, "BURST_MODE")==0)
613
 {
614
	if(STRICOLL(value, "invocations")==0)
615
	{
616
		_jvmpiAgent_Options.burstMode=BurstModeInvocations;
617
	}
618
	else if(STRICOLL(value, "seconds")==0)
619
	{
620
		_jvmpiAgent_Options.burstMode=BurstModeSeconds;
621
	}
622
	else if(STRICOLL(value, "secondsAndInvocations")==0)
623
	{
624
		_jvmpiAgent_Options.burstMode=BurstModeSecondsAndInvocations;
625
	}
626
 }
627
 else if(STRICOLL(key, "MONITOR_MODE")==0)
628
 {
629
	 if(STRICOLL(value, "all")==0) {
630
		 _jvmpiAgent_Options.monitorMode = MonitorAll;
631
	 }
632
		
633
	 else 	
634
	 {
635
		 _jvmpiAgent_Options.monitorMode = MonitorNone;
636
	 }
637
 }
638
	
639
 else if(STRICOLL(key, "BURST_INVOCATIONS")==0)
640
 {
641
   _jvmpiAgent_Options.burstInvocations=atoi(value);
642
 }
643
 else if(STRICOLL(key, "BURST_SECONDS")==0)
644
 {
645
   _jvmpiAgent_Options.burstSeconds=atoi(value);
646
 }
647
 else if(STRICOLL(key, "TRACE_START_MODE")==0)
648
 {
649
	if(STRICOLL(value, "filter")==0)
650
	{
651
		 _jvmpiAgent_Options.startMode=TraceStartModeFilter;
652
	}
653
	else if(STRICOLL(value, "triggerSingleThreaded")==0)
654
	{
655
		_jvmpiAgent_Options.startMode=TraceStartModeTriggerSingleThreaded;
656
	}
657
	else if(STRICOLL(value, "triggerMultiThreaded")==0)
658
	{
659
		_jvmpiAgent_Options.startMode=TraceStartModeTriggerMultiThreaded;
660
	}
661
 }
662
 else if (STRICOLL(key, "METHOD_COUNTS") == 0)
663
 {
664
  _jvmpiAgent_Options.methodCounts = setBooleanOption(value, key, _jvmpiAgent_Options.methodCounts);
665
 }
666
 else if (STRICOLL(key, "OBJ_ALLOC_IS_ARRAY") == 0)
667
 {
668
  _jvmpiAgent_Options.objAllocIsArray = setBooleanOption(value, key, _jvmpiAgent_Options.objAllocIsArray);
669
 }
670
 else if (STRICOLL(key, "OPTIONS") == 0)
671
 {
672
  _jvmpiAgent_Options.options = setBooleanOption(value, key, _jvmpiAgent_Options.options);
673
 }
674
 else if (STRICOLL(key, "STACK_INFORMATION") == 0)
675
 {
676
  if (STRICOLL(value, "none") == 0)
677
  {
678
   _jvmpiAgent_Options.stackInfo = StackInfoNone;
679
  }
680
  else if (STRICOLL(value, "normal") == 0)
681
  {
682
   _jvmpiAgent_Options.stackInfo = StackInfoNormal;
683
  }
684
  else if (STRICOLL(value, "boundary") == 0)
685
  {
686
   _jvmpiAgent_Options.stackInfo = StackInfoBoundary;
687
  }
688
  else if (STRICOLL(value, "contiguous") == 0)
689
  {
690
   _jvmpiAgent_Options.stackInfo = StackInfoContiguous;
691
  }
692
  else if (STRICOLL(value, "boundaryAndContiguous") == 0)
693
  {
694
   _jvmpiAgent_Options.stackInfo = StackInfoBoundaryAndContiguous;
695
  }
696
  else
697
  {
698
   fprintf(stderr, "Invalid %s option value \"%s\"\n", key, value);
699
   fflush(stderr); 
700
   return -1;
701
  }
702
 }
703
 /* pre-aggregation: set compressLevel based on the option value */
704
 else if(STRICOLL(key, "COMPRESS")==0)   /* 140009 */
705
 {
706
  if (STRICOLL(value, "none") == 0)
707
  {
708
   _jvmpiAgent_Options.compressLevel=CompressNone;
709
  }
710
  else if (STRICOLL(value, "aggregate") == 0)
711
  {
712
   _jvmpiAgent_Options.compressLevel=CompressAggregate; 
713
  } 
714
  else 
715
  {
716
   fprintf(stderr, "Invalid %s option value \"%s\", it must be none or aggregate\n", key, value);
717
   fflush(stderr); 
718
   return -1;
719
  }	 
720
 }
721
 else if(STRICOLL(key, "ALLOCATION_INFORMATION") == 0)
722
 {
723
	  if (STRICOLL(value, "none") == 0)
724
	  {
725
	   /* Depreciated: _jvmpiAgent_Options.heapInfo = HeapInfoNone; */
726
	   _jvmpiAgent_Options.mode = TraceModeNoObjectCorrelation;
727
	  }
728
	  else if (STRICOLL(value, "optHeap") == 0) {
729
		_jvmpiAgent_Options.mode = TraceOptimizedHeap;
730
	  }
731
	  else
732
	  {
733
	   /* Depreciated _jvmpiAgent_Options.heapInfo = HeapInfoAll; */
734
	   _jvmpiAgent_Options.mode = TraceModeFull;
735
	  }
736
 }
737
 else if(STRICOLL(key, "BOUNDARY_DEPTH")==0)
738
 {
739
   _jvmpiAgent_Options.boundaryDepth=atoi(value);
740
 }
741
 else if (STRICOLL(key, "TICKET") == 0)
742
 {
743
  _jvmpiAgent_Options.ticket = setBooleanOption(value, key, _jvmpiAgent_Options.ticket);
744
 }
745
 else if (STRICOLL(key, "TIMESTAMPS") == 0)
746
 {
747
  _jvmpiAgent_Options.timestamp = setBooleanOption(value, key, _jvmpiAgent_Options.timestamp);
748
 }
749
 else if (STRICOLL(key, "TRACE_IDREFS") == 0)
750
 {
751
  _jvmpiAgent_Options.traceIdrefs = setBooleanOption(value, key, _jvmpiAgent_Options.traceIdrefs);
752
 }
753
 else if (STRICOLL(key, "UNREFERENCED_SYMBOLS") == 0)
754
 {
755
  _jvmpiAgent_Options.unreferencedSymbols = setBooleanOption(value, key, _jvmpiAgent_Options.unreferencedSymbols);
756
 }
757
 else if (STRICOLL(key, "THREAD_CPU_TIME") == 0 || STRICOLL(key, "CPU_TIME") == 0 )
758
 {
759
  _jvmpiAgent_Options.cpuTime = setBooleanOption(value, key, _jvmpiAgent_Options.cpuTime);
760
 }
761
 else if (STRICOLL(key, "LLDATA_ENABLED") == 0)
762
 {
763
  _jvmpiAgent_Options.llDataEnabled = setBooleanOption(value, key, _jvmpiAgent_Options.llDataEnabled);
764
 }
765
 else if (STRICOLL(key, "HEAP_INFO_COUNT") == 0 && !_jvmpiAgent_Options.heapInfoCountSet)
766
 {
767
  _jvmpiAgent_Options.heapInfoCount = atoi(value);
768
  if (_jvmpiAgent_Options.heapInfoCount<2 || _jvmpiAgent_Options.heapInfoCount>50)
769
  {
770
    fprintf(stderr, "Invalid %s option value \"%s\", it must be between 2 and 50\n", key, value);
771
	fflush(stderr); 
772
    return -1;
773
  }
774
 }
775
 else if (STRICOLL(key, "HEAP_INFO_FILE_PREFIX") == 0 && !_jvmpiAgent_Options.heapInfoFilePrefixSet)
776
 {
777
  strcpyrealloc(&_jvmpiAgent_Options.heapInfoFilePrefix, value);
778
 }
779
 else if (STRICOLL(key, "EXTENSION_LIBRARY") == 0) {
780
  strcpyrealloc(&_jvmpiAgent_Options.extensionLibrary, value);
781
 }
782
 else {
783
	 /* 60879 add the unknown profiling option to the 'unknowns' list so that we 
784
	 can echo it back to the UI */ 
785
	 addUnknownOption(key,value); 
786
 }
787
788
789
790
 /**** bugzilla_54553 - it is valid to send non-profiling options to the RAC. 
791
 else
792
 {
793
  fprintf(stderr, "Unknown Profile Option \"%s\"\n", key);
794
  return -1;
795
 }
796
 */ 
797
 return 0;
798
}
799
800
801
int jvmpiAgent_processProfile(char * fileName)
802
{
803
 int rc = 0, linelen;
804
 FILE * profileFile = NULL;
805
 fpos_t filepos; 
806
 char *buffer; 
807
 char *strippedBuffer; 
808
809
#ifdef MVS                    /* 174190 */
810
 __atoe(fileName);
811
#endif
812
 profileFile = fopen(fileName, "r");
813
 if (!profileFile) return -1;
814
 /* loop until we reach the end of file */ 
815
 while (feof(profileFile) == 0) {
816
	 int len, i, ch;
817
	 char *end;
818
	 char *key;
819
	 char *value; 
820
821
	 /* save current file position */ 
822
	 if (fgetpos(profileFile,&filepos) != 0) {
823
		 return -1; 
824
	 }
825
826
	 /* determine the length of the current line */ 
827
	 linelen = 0; 
828
	 do {
829
		 ch = fgetc(profileFile); 
830
		 linelen++; 
831
	 } while(ch != EOF && ch != '\n'); 
832
	 /* allocate enough buffer space for the current line */ 
833
	 buffer = (char *)malloc(linelen + 1); 
834
	 /* rewind to the beginning of the line */ 
835
	 if (fsetpos(profileFile,&filepos) != 0) {
836
		 free(buffer);
837
		 return -1;
838
	 }
839
840
	 /* read the line */ 
841
	 if (!fgets(buffer,linelen+1,profileFile)) {
842
		 /* loop termination condition */ 
843
		 free(buffer); 
844
		 break; 
845
	 }
846
	 /* Truncate the buffer at the start of a comment */
847
   
848
	 end = strchr(buffer, '*');
849
  
850
   
851
	 if (end) {
852
		 *end = '\0';
853
	 }
854
   
855
	 strippedBuffer = stripLeadingBlanks(buffer);
856
	 len = strlen(strippedBuffer);
857
	 if (!len) {
858
		 /* free the original buffer */
859
		 free(buffer);
860
		 continue;
861
	 }
862
863
   
864
	 /* Parse key */
865
   
866
	 for (i = 0; i < len; i++) {
867
	
868
		 if (isspace(strippedBuffer[i]) || strippedBuffer[i] == '=') {
869
			 key = (char *)malloc(i+1);
870
			 strncpy(key, strippedBuffer, i);
871
			 key[i] = '\0';
872
			 strippedBuffer = strippedBuffer+i;
873
			 break;
874
		 }
875
	 }  
876
	 strippedBuffer = stripLeadingBlanks(strippedBuffer);
877
   
878
	 if (strippedBuffer[0] != '=') {
879
         fprintf(stderr, "Syntax error in profile file\n");
880
		 fflush(stderr); 
881
         rc = -1;
882
		 /* free the original buffer */ 
883
		 free(buffer); 
884
		 break;
885
	 } else {
886
         strippedBuffer = strippedBuffer+1;
887
         strippedBuffer = stripLeadingBlanks(strippedBuffer);
888
		 /* Parse value */
889
		 for (i = 0; i <= len; i++) {
890
             if (isspace(strippedBuffer[i]) || strippedBuffer[i] == '\0') {
891
                 value = (char *)malloc(i+1); 
892
                 strncpy(value, strippedBuffer, i);
893
                 value[i] = '\0';
894
				 break;
895
			 }
896
		 }
897
	/*MW changed so that one bad option won't stop option processing */
898
/*	if ( */
899
		 jvmpiAgent_SetProfileOption(key,value);
900
/*	== -1)
901
	{
902
	 rc = -1;
903
	 break;
904
	}
905
*/ }
906
   
907
		 free(buffer); 
908
		 free(key);
909
		 free(value); 
910
 }
911
912
 if (_jvmpiAgent_Options.gcDefault) {
913
     if (_jvmpiAgent_Options.mode == TraceHeap || _jvmpiAgent_Options.mode == TraceOptimizedHeap) {
914
         _jvmpiAgent_Options.gc = GcMoves;
915
	 } else {
916
         _jvmpiAgent_Options.gc = _jvmpiAgent_Options.idStyle == IdStyleStatic ? GcDeletes : GcDeletesAndMoves;
917
	 }
918
 }
919
 fclose(profileFile);
920
 return rc;
921
}
922
923
#ifdef MVS                    /* 174190 */
924
#pragma convlit(resume)
925
#endif
926
927
/** PROCESS_INVOCATION_OPTIONS *******************************************
928
  * Takes the command line parameters and populates the _jvmpiAgent_Options
929
  * with the correct values based upon the options specified.
930
  * @param   optionString - the command line args
931
  * @returns
932
  */
933
934
int jvmpiAgent_ProcessInvocationOptions(char *str)
935
{
936
 char *buf = 0; 
937
 int buflen; 
938
 int outputSpecified = 0;
939
 if (str == NULL) str = "";
940
941
 /* if "help" is specified print out the useage */
942
 if ((STRICOLL(str, "help")) == 0)
943
  {
944
   return -1;
945
  }
946
947
 while (*str)
948
  {
949
   buflen= strlen(str)+1; 
950
   buf = (char *)malloc(buflen); 
951
   if (!buf) {
952
	   goto mem_error; 
953
   }
954
955
   /* All options contain an "=" */
956
   if (!getToken(&str, buf, buflen, '='))
957
    {
958
     goto bad_option;
959
    }
960
   /* Specied output file */
961
   if (STRICOLL(buf, "file") == 0)
962
    {
963
     if (outputSpecified || !getToken(&str, buf, buflen, ','))
964
      {
965
       goto bad_option;
966
      }
967
     strcpyrealloc(&_jvmpiAgent_Options.outputFileName, buf);
968
     outputSpecified = 1;
969
    }
970
   else if (STRICOLL(buf, "enableExceptionTracing") == 0)
971
   {
972
    if (!getToken(&str, buf, buflen, ','))
973
    {
974
     goto bad_option;
975
    }
976
    if (STRICOLL(buf, "yes") == 0)
977
    {
978
     _jvmpiAgent_Options.enableExceptionTracing = 1;
979
	 _jvmpiAgent_Options.exceptionTracingSet =1;
980
    }
981
    else if (STRICOLL(buf, "no") == 0)
982
    {
983
     _jvmpiAgent_Options.enableExceptionTracing = 0;
984
	 _jvmpiAgent_Options.exceptionTracingSet =1;
985
    }
986
    else
987
    {
988
     goto bad_option;
989
    }
990
   }
991
   else if (STRICOLL(buf, "enableLineCoverage") == 0)
992
   {
993
    if (!getToken(&str, buf, buflen, ','))
994
    {
995
     goto bad_option;
996
    }
997
    if (STRICOLL(buf, "yes") == 0)
998
    {
999
     _jvmpiAgent_Options.enableLineCoverage = 1;
1000
	 _jvmpiAgent_Options.lineCoverageSet = 1;
1001
    }
1002
    else if (STRICOLL(buf, "no") == 0)
1003
    {
1004
     _jvmpiAgent_Options.enableLineCoverage = 0;
1005
	 _jvmpiAgent_Options.lineCoverageSet = 1;
1006
    }
1007
    else
1008
    {
1009
     goto bad_option;
1010
    }
1011
   }
1012
   else if (STRICOLL(buf, "filters") == 0)
1013
    {
1014
     if (!getToken(&str, buf, buflen, ','))
1015
      {
1016
       goto bad_option;
1017
      }
1018
     strcpyrealloc(&_jvmpiAgent_Options.filterFileName,buf);
1019
    }
1020
   else if (STRICOLL(buf, "debug") == 0)
1021
    {
1022
     if (!getToken(&str, buf, buflen, ','))
1023
      {
1024
       goto bad_option;
1025
      }
1026
     if (STRICOLL(buf,"hash") == 0)
1027
      {
1028
       _jvmpiAgent_Options.debugHash = 1;
1029
	 }
1030
	 else
1031
	  {
1032
       goto bad_option;
1033
      }
1034
    }
1035
    /* Mode of operation */
1036
    else if (STRICOLL(buf, "server") == 0)
1037
    {
1038
     if (!getToken(&str, buf, buflen, ','))
1039
     {
1040
      goto bad_option;
1041
     }
1042
	 /* If standalone */
1043
     if (STRICOLL(buf,"standalone") == 0)
1044
     {
1045
      _jvmpiAgent_Options.standalone = 1;
1046
	  _jvmpiAgent_Options.enabled = 0;
1047
	 }
1048
	 /* If enabled */
1049
	 else if (STRICOLL(buf, "enabled") == 0)
1050
	 {
1051
	  _jvmpiAgent_Options.standalone = 0;
1052
	  _jvmpiAgent_Options.enabled = 1;
1053
	 }
1054
	 /* If controlled */
1055
     else if (STRICOLL(buf, "controlled") == 0)
1056
	 {
1057
	  _jvmpiAgent_Options.standalone = 0;
1058
	  _jvmpiAgent_Options.enabled = 0;
1059
	 }
1060
	 /* If application */
1061
	 else if (STRICOLL(buf, "application") == 0)
1062
	 {
1063
	  _jvmpiAgent_Options.standalone = 0;
1064
	  _jvmpiAgent_Options.enabled = 1;
1065
	  _jvmpiAgent_Options.application=1;
1066
	 }
1067
	 /* If application, partially controlled by the RAC itself */
1068
	 else if (STRICOLL(buf, "applicationControlled") == 0) /* 215066 */
1069
	 {
1070
	  _jvmpiAgent_Options.standalone = 0;
1071
	  _jvmpiAgent_Options.enabled = 0;
1072
	  _jvmpiAgent_Options.application=1;
1073
	 }
1074
	 else
1075
	  {
1076
       goto bad_option;
1077
      }
1078
    }
1079
    else if (STRICOLL(buf, "mode") == 0)
1080
    {
1081
     if (_jvmpiAgent_Options.modeSet || !getToken(&str, buf, buflen, ','))
1082
     {
1083
      goto bad_option;
1084
     }
1085
	 /* If standalone */
1086
     if (STRICOLL(buf,"full") == 0)
1087
     {
1088
      _jvmpiAgent_Options.mode = TraceModeFull;
1089
	  _jvmpiAgent_Options.modeSet = 1;
1090
	 }
1091
	 /* If enabled */
1092
	 else if (STRICOLL(buf, "noObjectCorrelation") == 0)
1093
	 {
1094
	  _jvmpiAgent_Options.mode = TraceModeNoObjectCorrelation;
1095
	  _jvmpiAgent_Options.modeSet = 1;
1096
	 }
1097
	 /* If controlled */
1098
     else if (STRICOLL(buf, "sampling") == 0)
1099
	 {
1100
	  _jvmpiAgent_Options.mode = TraceModeStackSampling;
1101
	  _jvmpiAgent_Options.modeSet = 1;
1102
	 }
1103
	 /* If heap */
1104
	 else if (STRICOLL(buf, "heap") == 0)
1105
	 {
1106
	  _jvmpiAgent_Options.mode = TraceHeap;
1107
	  _jvmpiAgent_Options.modeSet = 1;
1108
	 }
1109
	 /* If optimizedHeap */
1110
     else if (STRICOLL(buf, "optHeap") == 0)
1111
	 {
1112
	  _jvmpiAgent_Options.mode = TraceOptimizedHeap;
1113
	  _jvmpiAgent_Options.modeSet = 1;
1114
	 }
1115
	 else if (STRICOLL(buf, "none") == 0)
1116
	 {
1117
	  /* See Bugzilla 57136 for all use of TraceModeNone */
1118
	  _jvmpiAgent_Options.mode = TraceModeNone;
1119
	  _jvmpiAgent_Options.modeSet = 1;
1120
	 }
1121
	 else
1122
	 {
1123
       goto bad_option;
1124
     }
1125
    }
1126
	else if (STRICOLL(buf, "trackGcEvent") == 0)
1127
	{
1128
     if (_jvmpiAgent_Options.gcSet || !getToken(&str, buf, buflen, ','))
1129
     {
1130
       goto bad_option;
1131
     }
1132
1133
     if (STRICOLL(buf,"default") == 0)
1134
     {
1135
      _jvmpiAgent_Options.gcDefault = 1;
1136
	  _jvmpiAgent_Options.gcSet = 1;
1137
	 }
1138
	 else if (STRICOLL(buf, "none") == 0)
1139
	 {
1140
	  _jvmpiAgent_Options.gcDefault = 0;
1141
	  _jvmpiAgent_Options.gc = GcNone;
1142
	  _jvmpiAgent_Options.gcSet = 1;
1143
	 }
1144
     else if (STRICOLL(buf, "moves") == 0)
1145
	 {
1146
	  _jvmpiAgent_Options.gcDefault = 0;
1147
	  _jvmpiAgent_Options.gc = GcMoves;
1148
	  _jvmpiAgent_Options.gcSet = 1;
1149
	 }
1150
	 else if (STRICOLL(buf, "frees") == 0)
1151
	 {
1152
	  _jvmpiAgent_Options.gcDefault = 0;
1153
	  _jvmpiAgent_Options.gc = GcDeletes;
1154
	  _jvmpiAgent_Options.gcSet = 1;
1155
	 }
1156
     else if (STRICOLL(buf, "movesAndFrees") == 0)
1157
	 {
1158
	  _jvmpiAgent_Options.gcDefault = 0;
1159
	  _jvmpiAgent_Options.gc = GcDeletesAndMoves;
1160
	  _jvmpiAgent_Options.gcSet = 1;
1161
	 }
1162
	 else
1163
	 {
1164
       goto bad_option;
1165
     }
1166
	 /* end of GC */
1167
	}
1168
	else if (STRICOLL(buf, "workDir") == 0)
1169
	{
1170
	  if (!getToken(&str, buf, buflen, ','))
1171
      {
1172
       goto bad_option;
1173
      }
1174
     strcpyrealloc(&_jvmpiAgent_Options.workDir, buf);
1175
1176
	 /* create the directory */
1177
	 if (MKDIR(_jvmpiAgent_Options.workDir) != 0 && errno != EEXIST) {
1178
		 /* couldn't create the dir and it doesn't exists either */
1179
		 perror(_jvmpiAgent_Options.workDir);
1180
		 goto bad_option;
1181
	 }
1182
1183
	 /* end of workDir */
1184
	}
1185
    else if (STRICOLL(buf, "profile") == 0)
1186
    {
1187
     _jvmpiAgent_Options.profileFile;
1188
     if (!getToken(&str, buf, buflen, ','))
1189
      {
1190
       goto bad_option;
1191
      }
1192
     strcpyrealloc(&_jvmpiAgent_Options.profileFile,buf);
1193
    }
1194
	else if (STRICOLL(buf, "optHeapFilePrefix") == 0)
1195
    {
1196
     if (_jvmpiAgent_Options.heapInfoFilePrefixSet || !getToken(&str, buf, buflen, ','))
1197
      {
1198
       goto bad_option;
1199
      }
1200
     strcpyrealloc(&_jvmpiAgent_Options.heapInfoFilePrefix, buf);
1201
     _jvmpiAgent_Options.heapInfoFilePrefixSet = 1;
1202
    }
1203
	else if (STRICOLL(buf, "optHeapCount") == 0)
1204
	{
1205
	 if (_jvmpiAgent_Options.heapInfoCountSet || !getToken(&str, buf, buflen, ','))
1206
      {
1207
       goto bad_option;
1208
      }
1209
#ifdef MVS
1210
#pragma convlit(suspend)
1211
     __atoe(buf) ;
1212
     _jvmpiAgent_Options.heapInfoCount = atoi(buf);
1213
     __etoa(buf) ;
1214
#pragma convlit(resume)
1215
#else
1216
     _jvmpiAgent_Options.heapInfoCount = atoi(buf);
1217
#endif
1218
	 if (_jvmpiAgent_Options.heapInfoCount < 2 || _jvmpiAgent_Options.heapInfoCount > 50)
1219
      {
1220
#ifdef MVS
1221
#pragma convlit(suspend)
1222
       __atoe(buf); /* for fprintf's use */
1223
#endif
1224
       fprintf(stderr, "optHeapCount=%s, it must be between 2 and 50", buf);
1225
#ifdef MVS
1226
       __etoa(buf); /* undo previous conversion */
1227
#pragma convlit(resume)
1228
#endif
1229
	   fflush(stderr); 
1230
       goto bad_option;
1231
      }
1232
     _jvmpiAgent_Options.heapInfoCountSet = 1;
1233
	}
1234
	else if (STRICOLL(buf, "extensionLibrary") == 0)
1235
	{
1236
	 if (!getToken(&str, buf, buflen, ','))
1237
      {
1238
       goto bad_option;
1239
      }
1240
	 strcpyrealloc(&_jvmpiAgent_Options.extensionLibrary, buf);
1241
	}
1242
	else
1243
	{
1244
         /* 57110 Silently ignore options starting with "ext-"
1245
          * because they're destined for an agent extension.
1246
          * I would use STRNICOLL(buf, "ext-", 4) if there were one.
1247
          * Copy the bytes manually rather than trust in having
1248
          * memcpy on all platforms. (Sure it isn't called _memcpy...?)
1249
          */
1250
         char prefix[5];
1251
         prefix[0] = buf[0];
1252
         prefix[1] = buf[1];
1253
         prefix[2] = buf[2];
1254
         prefix[3] = buf[3];
1255
         prefix[4] = '\0';
1256
         if (STRICOLL(prefix, "ext-") == 0) {
1257
           /* consume up to the comma, error out if nothing after "=" */
1258
		   if (!getToken(&str, buf, buflen, ',')) {
1259
              goto bad_option;
1260
           }
1261
           else {
1262
           	  /* This is a well-formed ext- option. Do not error out. */
1263
           }
1264
         }
1265
         else {
1266
	   		/* unknown option */
1267
#ifdef MVS
1268
#pragma convlit(suspend)
1269
			__atoe(buf);
1270
#endif
1271
	   		fprintf(stderr, "Unknown option \"%s\"\n", buf);
1272
#ifdef MVS
1273
			__etoa(buf);
1274
#pragma convlit(resume)
1275
#endif
1276
			fflush(stderr); 
1277
	   		goto bad_option;
1278
	 	 }
1279
	}
1280
1281
  }
1282
1283
  if (_jvmpiAgent_Options.gcDefault
1284
      && (_jvmpiAgent_Options.mode == TraceHeap || _jvmpiAgent_Options.mode == TraceOptimizedHeap))
1285
  {
1286
    _jvmpiAgent_Options.gc = GcMoves;
1287
  }
1288
  if (buf) {
1289
	  free (buf); 
1290
  }
1291
  return 0;
1292
1293
bad_option:
1294
  if (buf) {
1295
	free(buf); 
1296
  }
1297
#ifdef MVS
1298
#pragma convlit(suspend)
1299
#endif
1300
  fprintf(stderr, "Bad PIAgent option\n");
1301
#ifdef MVS
1302
#pragma convlit(resume)
1303
#endif
1304
  fflush(stderr); 
1305
  /* printUsage(); (JvmpiWriter will print the usage()) */
1306
  return -1;
1307
mem_error:
1308
#ifdef MVS
1309
#pragma convlit(suspend)
1310
#endif
1311
  fprintf(stderr, "Memory allocation error\n"); 
1312
#ifdef MVS
1313
#pragma convlit(resume)
1314
#endif
1315
  fflush(stderr); 
1316
  return -1; 
1317
}
1318
1319
/** CHECK_OPTIONS_CONSISTENCY ********************************************
1320
  * Checks whether there is any conflict or inconsistency among various
1321
  * options.
1322
  * @returns -1 if error, 0 if no error
1323
  */
1324
int jvmpiAgent_CheckOptionsConsistency()
1325
{
1326
	/* The TraceOptimizedHeap trace-mode can be set only in stand-alone mode */
1327
	if (_jvmpiAgent_Options.mode == TraceOptimizedHeap) {
1328
#ifdef MVS
1329
#pragma convlit(suspend)
1330
#endif
1331
		if (!_jvmpiAgent_Options.standalone && 
1332
			!jvmpiAgent_isControlled() ) {
1333
			fprintf(stderr, "The TraceOptimizedHeap trace-mode can be set either in stand-alone or controlled mode.\n");
1334
			fflush(stderr); 
1335
			return -1;
1336
		}
1337
		if (_jvmpiAgent_Options.gc != GcMoves && _jvmpiAgent_Options.gc != GcNone) {
1338
			fprintf(stderr, "In TraceOptimizedHeap trace-mode, TrackGcEvent must be either Moves or None\n");
1339
			fflush(stderr); 
1340
			return -1;
1341
		}
1342
#ifdef MVS
1343
#pragma convlit(resume)
1344
#endif
1345
	}
1346
1347
	return 0;
1348
}
1349
1350
unsigned int jvmpiAgent_isPrintObjId()
1351
{
1352
 return (_jvmpiAgent_Options.idStyle == IdStyleRelocatable || _jvmpiAgent_Options.idStyle == IdStyleStaticAndRelocatable);
1353
}
1354
1355
unsigned int jvmpiAgent_isPrintStaticId()
1356
{
1357
 return (_jvmpiAgent_Options.idStyle == IdStyleStatic || _jvmpiAgent_Options.idStyle == IdStyleStaticAndRelocatable);
1358
}
1359
1360
unsigned int jvmpiAgent_isPrintMethodId()
1361
{
1362
 return (_jvmpiAgent_Options.idStyle == IdStyleRelocatable || _jvmpiAgent_Options.idStyle == IdStyleStaticAndRelocatable);
1363
}
1364
1365
unsigned int jvmpiAgent_isTracingHeap()
1366
{
1367
 return (_jvmpiAgent_Options.mode==TraceModeFull || _jvmpiAgent_Options.mode==TraceHeap || _jvmpiAgent_Options.mode==TraceOptimizedHeap );
1368
}
1369
1370
unsigned int jvmpiAgent_isControlled()
1371
{
1372
  return ( _jvmpiAgent_Options.standalone == 0 &&  _jvmpiAgent_Options.enabled ==0  ) ;
1373
}
(-)src-native-new/src/agents/RABindings/WinBuild/RABindings.mak (+316 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on RABinding.dsp
2
!IF "$(CFG)" == ""
3
CFG=RABinding - Win32 Debug
4
!MESSAGE No configuration specified. Defaulting to RABinding - Win32 Debug.
5
!ENDIF 
6
7
!IF "$(CFG)" != "RABinding - Win32 Release" && "$(CFG)" != "RABinding - Win32 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "RABinding.mak" CFG="RABinding - Win32 Debug"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "RABinding - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
17
!MESSAGE "RABinding - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
18
!MESSAGE 
19
!ERROR An invalid configuration is specified.
20
!ENDIF 
21
22
!IF "$(OS)" == "Windows_NT"
23
NULL=
24
!ELSE 
25
NULL=nul
26
!ENDIF 
27
28
!IF  "$(CFG)" == "RABinding - Win32 Release"
29
30
OUTDIR=.\bin
31
INTDIR=.\Release
32
# Begin Custom Macros
33
OutDir=.\bin
34
# End Custom Macros
35
36
!IF "$(RECURSE)" == "0" 
37
38
ALL : "$(OUTDIR)\hcbnd.dll"
39
40
!ELSE 
41
42
ALL : "RASocket - Win32 Release" "RACommon - Win32 Release" "$(OUTDIR)\hcbnd.dll"
43
44
!ENDIF 
45
46
!IF "$(RECURSE)" == "1" 
47
CLEAN :"RACommon - Win32 ReleaseCLEAN" "RASocket - Win32 ReleaseCLEAN" 
48
!ELSE 
49
CLEAN :
50
!ENDIF 
51
	-@erase "$(INTDIR)\hcbnd.res"
52
	-@erase "$(INTDIR)\lock3.obj"
53
	-@erase "$(INTDIR)\RABindings.obj"
54
	-@erase "$(INTDIR)\vc60.idb"
55
	-@erase "$(OUTDIR)\hcbnd.dll"
56
	-@erase "$(OUTDIR)\hcbnd.exp"
57
	-@erase "$(OUTDIR)\hcbnd.lib"
58
59
"$(OUTDIR)" :
60
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
61
62
"$(INTDIR)" :
63
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
64
65
CPP=cl.exe
66
CPP_PROJ=/nologo /MT /W3 /GX /O2 /Ob0 /I "..\RACommon" /I "..\RASocket" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RABINDING_EXPORTS" /Fp"$(INTDIR)\RABinding.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
67
68
.c{$(INTDIR)}.obj::
69
   $(CPP) @<<
70
   $(CPP_PROJ) $< 
71
<<
72
73
.cpp{$(INTDIR)}.obj::
74
   $(CPP) @<<
75
   $(CPP_PROJ) $< 
76
<<
77
78
.cxx{$(INTDIR)}.obj::
79
   $(CPP) @<<
80
   $(CPP_PROJ) $< 
81
<<
82
83
.c{$(INTDIR)}.sbr::
84
   $(CPP) @<<
85
   $(CPP_PROJ) $< 
86
<<
87
88
.cpp{$(INTDIR)}.sbr::
89
   $(CPP) @<<
90
   $(CPP_PROJ) $< 
91
<<
92
93
.cxx{$(INTDIR)}.sbr::
94
   $(CPP) @<<
95
   $(CPP_PROJ) $< 
96
<<
97
98
MTL=midl.exe
99
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
100
RSC=rc.exe
101
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcbnd.res" /d "NDEBUG" 
102
BSC32=bscmake.exe
103
BSC32_FLAGS=/nologo /o"$(OUTDIR)\RABinding.bsc" 
104
BSC32_SBRS= \
105
	
106
LINK32=link.exe
107
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib hcclco.lib /nologo /version:0.1 /dll /pdb:none /machine:I386 /def:"..\RABindings\RABindings.def" /out:"$(OUTDIR)\hcbnd.dll" /implib:"$(OUTDIR)\hcbnd.lib" /libpath:".\bin" 
108
DEF_FILE= \
109
	"..\RABindings\RABindings.def"
110
LINK32_OBJS= \
111
	"$(INTDIR)\lock3.obj" \
112
	"$(INTDIR)\RABindings.obj" \
113
	"$(INTDIR)\hcbnd.res" \
114
	"$(OUTDIR)\hcclco.lib" \
115
	"$(OUTDIR)\hccls.lib"
116
117
"$(OUTDIR)\hcbnd.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
118
    $(LINK32) @<<
119
  $(LINK32_FLAGS) $(LINK32_OBJS)
120
<<
121
122
!ELSEIF  "$(CFG)" == "RABinding - Win32 Debug"
123
124
OUTDIR=.\bin
125
INTDIR=.\Debug
126
# Begin Custom Macros
127
OutDir=.\bin
128
# End Custom Macros
129
130
!IF "$(RECURSE)" == "0" 
131
132
ALL : "$(OUTDIR)\hcbnd.dll"
133
134
!ELSE 
135
136
ALL : "RASocket - Win32 Debug" "RACommon - Win32 Debug" "$(OUTDIR)\hcbnd.dll"
137
138
!ENDIF 
139
140
!IF "$(RECURSE)" == "1" 
141
CLEAN :"RACommon - Win32 DebugCLEAN" "RASocket - Win32 DebugCLEAN" 
142
!ELSE 
143
CLEAN :
144
!ENDIF 
145
	-@erase "$(INTDIR)\hcbnd.res"
146
	-@erase "$(INTDIR)\lock3.obj"
147
	-@erase "$(INTDIR)\RABindings.obj"
148
	-@erase "$(INTDIR)\vc60.idb"
149
	-@erase "$(INTDIR)\vc60.pdb"
150
	-@erase "$(OUTDIR)\hcbnd.dll"
151
	-@erase "$(OUTDIR)\hcbnd.exp"
152
	-@erase "$(OUTDIR)\hcbnd.ilk"
153
	-@erase "$(OUTDIR)\hcbnd.lib"
154
	-@erase "$(OUTDIR)\hcbnd.pdb"
155
156
"$(OUTDIR)" :
157
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
158
159
"$(INTDIR)" :
160
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
161
162
CPP=cl.exe
163
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\RACommon" /I "..\RASocket" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RABINDING_EXPORTS" /Fp"$(INTDIR)\RABinding.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
164
165
.c{$(INTDIR)}.obj::
166
   $(CPP) @<<
167
   $(CPP_PROJ) $< 
168
<<
169
170
.cpp{$(INTDIR)}.obj::
171
   $(CPP) @<<
172
   $(CPP_PROJ) $< 
173
<<
174
175
.cxx{$(INTDIR)}.obj::
176
   $(CPP) @<<
177
   $(CPP_PROJ) $< 
178
<<
179
180
.c{$(INTDIR)}.sbr::
181
   $(CPP) @<<
182
   $(CPP_PROJ) $< 
183
<<
184
185
.cpp{$(INTDIR)}.sbr::
186
   $(CPP) @<<
187
   $(CPP_PROJ) $< 
188
<<
189
190
.cxx{$(INTDIR)}.sbr::
191
   $(CPP) @<<
192
   $(CPP_PROJ) $< 
193
<<
194
195
MTL=midl.exe
196
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
197
RSC=rc.exe
198
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\hcbnd.res" /d "_DEBUG" 
199
BSC32=bscmake.exe
200
BSC32_FLAGS=/nologo /o"$(OUTDIR)\RABinding.bsc" 
201
BSC32_SBRS= \
202
	
203
LINK32=link.exe
204
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib hcclco.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\hcbnd.pdb" /debug /machine:I386 /def:"..\RABindings\RABindings.def" /out:"$(OUTDIR)\hcbnd.dll" /implib:"$(OUTDIR)\hcbnd.lib" /pdbtype:sept /libpath:".\bin" 
205
DEF_FILE= \
206
	"..\RABindings\RABindings.def"
207
LINK32_OBJS= \
208
	"$(INTDIR)\lock3.obj" \
209
	"$(INTDIR)\RABindings.obj" \
210
	"$(INTDIR)\hcbnd.res" \
211
	"$(OUTDIR)\hcclco.lib" \
212
	"$(OUTDIR)\hccls.lib"
213
214
"$(OUTDIR)\hcbnd.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
215
    $(LINK32) @<<
216
  $(LINK32_FLAGS) $(LINK32_OBJS)
217
<<
218
219
!ENDIF 
220
221
222
!IF "$(NO_EXTERNAL_DEPS)" != "1"
223
!IF EXISTS("RABinding.dep")
224
!INCLUDE "RABinding.dep"
225
!ELSE 
226
!MESSAGE Warning: cannot find "RABinding.dep"
227
!ENDIF 
228
!ENDIF 
229
230
231
!IF "$(CFG)" == "RABinding - Win32 Release" || "$(CFG)" == "RABinding - Win32 Debug"
232
SOURCE=..\RABindings\lock3.c
233
234
"$(INTDIR)\lock3.obj" : $(SOURCE) "$(INTDIR)"
235
	$(CPP) $(CPP_PROJ) $(SOURCE)
236
237
238
SOURCE=..\RABindings\RABindings.c
239
240
"$(INTDIR)\RABindings.obj" : $(SOURCE) "$(INTDIR)"
241
	$(CPP) $(CPP_PROJ) $(SOURCE)
242
243
244
SOURCE=..\RABindings\version.rc
245
246
!IF  "$(CFG)" == "RABinding - Win32 Release"
247
248
249
"$(INTDIR)\hcbnd.res" : $(SOURCE) "$(INTDIR)"
250
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcbnd.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RABindings" /d "NDEBUG" $(SOURCE)
251
252
253
!ELSEIF  "$(CFG)" == "RABinding - Win32 Debug"
254
255
256
"$(INTDIR)\hcbnd.res" : $(SOURCE) "$(INTDIR)"
257
	$(RSC) /l 0x409 /fo"$(INTDIR)\hcbnd.res" /i "\Documents and Settings\Administrator\Desktop\org.eclipse.hyades.datacollection\org.eclipse.hyades.datacollection\collection\framework\RABindings" /d "_DEBUG" $(SOURCE)
258
259
260
!ENDIF 
261
262
!IF  "$(CFG)" == "RABinding - Win32 Release"
263
264
"RACommon - Win32 Release" : 
265
   cd "."
266
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak" CFG="RACommon - Win32 Release" 
267
   cd "."
268
269
"RACommon - Win32 ReleaseCLEAN" : 
270
   cd "."
271
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak" CFG="RACommon - Win32 Release" RECURSE=1 CLEAN 
272
   cd "."
273
274
!ELSEIF  "$(CFG)" == "RABinding - Win32 Debug"
275
276
"RACommon - Win32 Debug" : 
277
   cd "."
278
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak" CFG="RACommon - Win32 Debug" 
279
   cd "."
280
281
"RACommon - Win32 DebugCLEAN" : 
282
   cd "."
283
   $(MAKE) /$(MAKEFLAGS) /F ".\RACommon.mak" CFG="RACommon - Win32 Debug" RECURSE=1 CLEAN 
284
   cd "."
285
286
!ENDIF 
287
288
!IF  "$(CFG)" == "RABinding - Win32 Release"
289
290
"RASocket - Win32 Release" : 
291
   cd "."
292
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak" CFG="RASocket - Win32 Release" 
293
   cd "."
294
295
"RASocket - Win32 ReleaseCLEAN" : 
296
   cd "."
297
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak" CFG="RASocket - Win32 Release" RECURSE=1 CLEAN 
298
   cd "."
299
300
!ELSEIF  "$(CFG)" == "RABinding - Win32 Debug"
301
302
"RASocket - Win32 Debug" : 
303
   cd "."
304
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak" CFG="RASocket - Win32 Debug" 
305
   cd "."
306
307
"RASocket - Win32 DebugCLEAN" : 
308
   cd "."
309
   $(MAKE) /$(MAKEFLAGS) /F ".\RASocket.mak" CFG="RASocket - Win32 Debug" RECURSE=1 CLEAN 
310
   cd "."
311
312
!ENDIF 
313
314
315
!ENDIF 
316
(-)src-native-new/src/agents/perfmon/resutils/random.c (+153 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: random.c,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
/***********************************************************************
14
 *
15
 * File: random.c
16
 * Overview: random number generation
17
 *
18
 ***********************************************************************/
19
20
#include "system.h"
21
22
#define WARMUP 100
23
24
void XRandomSeed(XINT s)
25
{
26
  srand(s);
27
28
#ifdef WARMUP
29
  {
30
      int i;
31
32
      for (i = 0; i < WARMUP; i++)
33
      {
34
          (void) rand();
35
      }
36
  }
37
#endif
38
}
39
40
XDOUBLE XRandomUniform(void)
41
{
42
  return (double)(rand()) / (double)(RAND_MAX);
43
}
44
45
XDOUBLE XRandomNormal(void)
46
{
47
  static double a[32] = {
48
    0.0,3.917609E-2,7.841241E-2,0.11777,0.1573107,0.1970991,0.2372021,0.2776904,
49
    0.3186394,0.36013,0.4022501,0.4450965,0.4887764,0.5334097,0.5791322,
50
    0.626099,0.6744898,0.7245144,0.7764218,0.8305109,0.8871466,0.9467818,
51
    1.00999,1.077516,1.150349,1.229859,1.318011,1.417797,1.534121,1.67594,
52
    1.862732,2.153875
53
};
54
  static double d[31] = {
55
    0.0,0.0,0.0,0.0,0.0,0.2636843,0.2425085,0.2255674,0.2116342,0.1999243,
56
    0.1899108,0.1812252,0.1736014,0.1668419,0.1607967,0.1553497,0.1504094,
57
    0.1459026,0.14177,0.1379632,0.1344418,0.1311722,0.128126,0.1252791,
58
    0.1226109,0.1201036,0.1177417,0.1155119,0.1134023,0.1114027,0.1095039
59
};
60
  static double t[31] = {
61
    7.673828E-4,2.30687E-3,3.860618E-3,5.438454E-3,7.0507E-3,8.708396E-3,
62
    1.042357E-2,1.220953E-2,1.408125E-2,1.605579E-2,1.81529E-2,2.039573E-2,
63
    2.281177E-2,2.543407E-2,2.830296E-2,3.146822E-2,3.499233E-2,3.895483E-2,
64
    4.345878E-2,4.864035E-2,5.468334E-2,6.184222E-2,7.047983E-2,8.113195E-2,
65
    9.462444E-2,0.1123001,0.136498,0.1716886,0.2276241,0.330498,0.5847031
66
};
67
  static double h[31] = {
68
    3.920617E-2,3.932705E-2,3.951E-2,3.975703E-2,4.007093E-2,4.045533E-2,
69
    4.091481E-2,4.145507E-2,4.208311E-2,4.280748E-2,4.363863E-2,4.458932E-2,
70
    4.567523E-2,4.691571E-2,4.833487E-2,4.996298E-2,5.183859E-2,5.401138E-2,
71
    5.654656E-2,5.95313E-2,6.308489E-2,6.737503E-2,7.264544E-2,7.926471E-2,
72
    8.781922E-2,9.930398E-2,0.11556,0.1404344,0.1836142,0.2790016,0.7010474
73
};
74
  long i;
75
  double snorm,u,s,ustar,aa,w,y,tt;
76
77
  u = XRandomUniform();
78
  s = 0.0;
79
  if(u > 0.5) s = 1.0;
80
  u += (u-s);
81
  u = 32.0*u;
82
  i = (long) (u);
83
  if(i == 32) i = 31;
84
  if(i == 0) goto S100;
85
/*
86
                                START CENTER
87
*/
88
  ustar = u-(double)i;
89
  aa = *(a+i-1);
90
S40:
91
  if(ustar <= *(t+i-1)) goto S60;
92
  w = (ustar-*(t+i-1))**(h+i-1);
93
S50:
94
/*
95
                                EXIT   (BOTH CASES)
96
*/
97
  y = aa+w;
98
  snorm = y;
99
  if(s == 1.0) snorm = -y;
100
  goto S170;
101
S60:
102
/*
103
                                CENTER CONTINUED
104
*/
105
  u = XRandomUniform();
106
  w = u*(*(a+i)-aa);
107
  tt = (0.5*w+aa)*w;
108
  goto S80;
109
S70:
110
  tt = u;
111
  ustar = XRandomUniform();
112
S80:
113
  if(ustar > tt) goto S50;
114
  u = XRandomUniform();
115
  if(ustar >= u) goto S70;
116
  ustar = XRandomUniform();
117
  goto S40;
118
S100:
119
/*
120
                                START TAIL
121
*/
122
  i = 6;
123
  aa = *(a+31);
124
  goto S120;
125
S110:
126
  aa += *(d+i-1);
127
  i += 1;
128
S120:
129
  u += u;
130
  if(u < 1.0) goto S110;
131
  u -= 1.0;
132
S140:
133
  w = u**(d+i-1);
134
  tt = (0.5*w+aa)*w;
135
  goto S160;
136
S150:
137
  tt = u;
138
S160:
139
  ustar = XRandomUniform();
140
  if(ustar > tt) goto S50;
141
  u = XRandomUniform();
142
  if(ustar >= u) goto S150;
143
  u = XRandomUniform();
144
  goto S140;
145
146
S170:
147
148
  return snorm;
149
}
150
151
/***********************************************************************
152
 * EOF
153
 ***********************************************************************/
(-)src-native-new/src/agents/RABindings/lock3.h (+109 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: lock3.h,v 1.4 2006/04/24 13:29:36 samwai Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef _LOCK3_H_
14
#define _LOCK3_H_
15
16
17
#ifdef _WIN32
18
#include <winsock2.h> /* Bug 134924 */
19
#include <windows.h>
20
21
// The single-writer/multiple-reader guard
22
// compound synchronization object
23
typedef struct _SWMR {
24
   // This critical section guards access to the other objects
25
   // managed by this data structure and also indicates
26
   // whether any writer threads are writing.
27
   CRITICAL_SECTION cs;
28
29
   // This manual-reset event is signaled when
30
   // no reader threads are reading.
31
   HANDLE hEventNoReaders;
32
33
   LONG numReaders;
34
} Lock_t;
35
36
37
38
#else
39
  #include <pthread.h>
40
  #include "RAComm.h"
41
42
#if defined __linux__ || defined _HPUX
43
  typedef struct {
44
    pthread_mutex_t mutex;
45
    pthread_cond_t  rcond;
46
    pthread_cond_t  wcond;
47
    long readCount;
48
    short waiting_writers;
49
    short active_writers;
50
  } Lock_t;
51
  extern void rwlock_WaitingReaderCleanup(void *arg);
52
  extern void rwlock_WaitingWriterCleanup(void *arg);
53
#else
54
  typedef pthread_rwlock_t Lock_t;
55
#endif
56
57
#endif
58
59
60
#if defined __cplusplus && defined _HPUX
61
extern "C" {
62
#endif
63
64
/** Initializes a SWMRG structure. This structure must be
65
	initialized before any writer or reader threads attempt
66
	to wait on it.
67
	The structure must be allocated by the application and
68
	the structure's address is passed as the first parameter.
69
	The lpszName parameter is the name of the object. Pass
70
	NULL if you do not want to share the object.
71
  */
72
extern BOOL  ra_initializeLock (Lock_t *lock);
73
74
75
/** Deletes the system resources associated with a SWMRG
76
	structure. The structure must be deleted only when
77
	no writer or reader threads in the calling process
78
	will wait on it.
79
  */
80
extern void ra_deleteLock (Lock_t *lock);
81
82
/** A writer thread calls this function to know when
83
	it can successfully write to the shared data.
84
  */
85
extern int ra_getWriteLock (Lock_t *lock);
86
87
88
/** A writer thread calls this function to let other threads
89
	know that it no longer needs to write to the shared data.
90
  */
91
extern void ra_releaseWriteLock (Lock_t *lock);
92
93
94
/** A reader thread calls this function to know when
95
	it can successfully read the shared data.
96
  */
97
extern int ra_getReadLock(Lock_t *lock);
98
99
100
/** A reader thread calls this function to let other threads
101
	know when it no longer needs to read the shared data.
102
  */
103
extern void ra_releaseReadLock (Lock_t *lock);
104
105
#if defined __cplusplus && defined _HPUX
106
}
107
#endif
108
109
#endif
(-)src-native-new/src/agents/RABindings/RABindings.make (+129 lines)
Added Link Here
1
2
################################################################################
3
#                                       
4
#  makefile:  RABindings project  
5
#                                       
6
# $Id
7
################################################################################
8
9
10
#-----------------------------------
11
#
12
#   Customizable section
13
#
14
#   - The TARGETREALNAME variable specifies the name of the library file
15
#     that will be generated, this includes a base (TARGETLIB) plus	a 
16
#     version number plus a minor number plus a release number
17
#   - The TARGETSONAME variable specifies a file name that has just the
18
#     library name plus the major version number
19
#   - The TARGETLIB variable specifies the base library name
20
#   - The TARGETSONAME and TARGETLIB are generated as symbolic links
21
#     when the library is built
22
#
23
#-----------------------------------
24
TARGET         :=  libhcbnd
25
TARGETDIR      :=  ../../../lib
26
27
if [ x$VERSIONNUM = x ]; then export VERSIONNUM=0; fi
28
if [ x$MINORNUM = x ]; then export MINORNUM=0; fi
29
if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi
30
31
TARGETLIB      :=  $(TARGET).so
32
TARGETSONAME   :=  $(TARGETLIB).$(VERSIONNUM)
33
TARGETREALNAME :=  $(TARGETSONAME).$(MINORNUM).$(RELEASENUM)
34
35
36
#-----------------------------------
37
#   list of additional INCLUDE directories to search headers from
38
#      (separated by blanks)
39
#-----------------------------------
40
INCLUDEDIRS    :=  .  ../../../include $(JAVA_HOME)/include $(JAVA_HOME)/include/linux ../../transport/RACommon ../../transport/RASocket ../../transport/RASharedMemory ../../transport/RADataTransfer
41
42
43
#-----------------------------------
44
#   list of additional libraries to be linked with
45
#      (separated by blanks)
46
#-----------------------------------
47
LIBS       :=  dl hcclco hccls hcclsm hccldt pthread
48
49
#-----------------------------------
50
#   list of additional library directories to search from
51
#      (separated by blanks)
52
#-----------------------------------
53
LIBDIRS    :=  ../../../lib
54
55
56
#-----------------------------------
57
#
58
#   Compiler options
59
#
60
#      -g       produce debug info
61
#      -Wall    enable all types of warnings
62
#      -O3      highest level of code optimization
63
#      -fPIC    generate position-independent code (PIC).
64
#               This is required for building shared library.
65
#      -c       compile only
66
#
67
#   Linking options
68
#
69
#       -Wl       pass options to linker
70
#       -shared   produce shared library
71
#       -L        add the given directory to the search path for libraries
72
#
73
#-----------------------------------
74
75
DEFINES    := -DSQLUNIX -DSQLLinux -DENW -DREENTRANT -D_REENTRANT -DCONFIG_X86_CMPXCHG
76
77
CFLAGS     :=  $(C_FLAGS) $(DEBUGABLE) -Wall $(OPTIMIZABLE) -fPIC $(addprefix -I,$(INCLUDEDIRS))  -D_LINUX_X86  $(DEFINES)
78
79
CXXFLAGS   :=  $(CFLAGS)
80
81
LINKOPTS   :=  $(L_FLAGS) $(DEBUGABLE) -shared -Wl,-soname,$(TARGETSONAME) -o $(TARGETDIR)/$(TARGETREALNAME) $(addprefix -L,$(LIBDIRS))
82
83
84
#-----------------------------------
85
#   general commands and options
86
#-----------------------------------
87
88
CC          :=  gcc
89
CXX         :=  $(CC)
90
91
SOURCE     :=  $(wildcard *.c)  $(wildcard *.cpp)
92
93
OBJS       :=  $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
94
95
REMOVEFILE :=  rm -f
96
CREATELINK :=  ln -sf
97
98
99
#-----------------------------------
100
#   "make" rules
101
#-----------------------------------
102
103
.PHONY : default everything objs clean veryclean rebuild $(TARGET)
104
105
106
default : $(TARGET)
107
108
109
objs : $(OBJS)
110
111
112
clean :
113
	$(REMOVEFILE) *.o
114
115
116
veryclean: clean
117
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETLIB)
118
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETSONAME)
119
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETREALNAME)
120
121
122
rebuild: veryclean everything
123
124
125
$(TARGET) : $(OBJS)
126
	$(CC) $(LINKOPTS) $(OBJS) $(addprefix -l,$(LIBS))
127
	$(CREATELINK) $(TARGETREALNAME)  $(TARGETDIR)/$(TARGETSONAME)
128
	$(CREATELINK) $(TARGETSONAME)    $(TARGETDIR)/$(TARGETLIB)
129
(-)src-native-new/src/agents/perfmon/resutils/DataTransferInterface.h (+49 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 Scapa Technologies Limited and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: DataTransferInterface.h,v 1.3 2005/06/09 18:05:36 gchristelis Exp $
8
 * 
9
 * Contributors: 
10
 * Scapa Technologies Limited - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef __DATATRANSFER_H__
14
#define __DATATRANSFER_H__
15
16
#include "system.h"
17
#include "hashtable.h"
18
19
static char* DC_KEY_MONITORING = "DC_MONITORING";
20
//Bug 99153
21
static char* DC_AGENT_CONTROLLER_STOPPED = "DC_AGENT_CONTROLLER_STOPPED";
22
//End
23
static char* DC_KEY_FINISHED = "DC_FINISHED";
24
static char* DC_KEY_TREE_REQUESTED = "DC_TREE_REQUESTED";
25
static XINT64 DC_VAL_TRUE = TRUE;
26
static XINT64 DC_VAL_FALSE = FALSE;
27
28
#ifdef __cplusplus
29
extern "C" {
30
#endif
31
32
#if defined(LINUX) || defined(SOLARIS) 
33
int DC_TransferStartup(HashTable* variables, HashTable* filters, HashTable* tree);
34
int DC_TransferShutdown();
35
int DC_SendMessage(char* msg, int off, int len);
36
int DC_TransferSetAgentName(char* name);
37
#else
38
int __declspec(dllexport) DC_TransferSetAgentName(char* name);
39
int __declspec(dllexport) DC_TransferStartup(HashTable* variables, HashTable* filters, HashTable* tree);
40
int __declspec(dllexport) DC_TransferShutdown();
41
int __declspec(dllexport) DC_SendMessage(char* msg, int off, int len);
42
#endif
43
44
#ifdef __cplusplus
45
}
46
#endif
47
48
#endif
49
(-)src-native-new/src/agents/RABindings/lock3.c (+205 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: lock3.c,v 1.3 2005/03/24 17:42:29 samwai Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include <stddef.h>
14
#include "lock3.h"
15
16
BOOL ra_initializeLock(Lock_t *lock) {
17
	BOOL fOk;
18
#ifdef _WIN32
19
20
	// Initialize all data members to NULL so that we can
21
	// accurately check whether an error has occurred.
22
	lock->hEventNoReaders = NULL;
23
24
	// This critical section guards access to the other objects
25
	// managed by this data structure and also indicates
26
	// whether there are any writer threads writing.
27
	InitializeCriticalSection(&lock->cs);
28
	
29
	// Create the manual-reset event that is signalled when
30
	// no reader threads are reading.
31
	// Initially no reader threads are reading.
32
	lock->hEventNoReaders = CreateEvent(NULL,
33
										TRUE,
34
										TRUE,
35
										NULL);
36
37
38
	// Initialize the variable that indicates the number of
39
	// reader threads that are reading.
40
	lock->numReaders=0;
41
42
	if ((NULL == lock->hEventNoReaders)) {
43
		// If a synchronization object could not be created,
44
		// destroy any created objects and return failure.
45
		ra_deleteLock(lock);
46
		fOk = FALSE;
47
	} else {
48
		fOk = TRUE;
49
	}
50
51
	// Return TRUE upon success, FALSE upon failure.
52
	return(fOk);
53
54
#else
55
56
#if defined __linux__ || defined _HPUX
57
 pthread_mutex_init(&(lock->mutex), /* Create mutex */
58
					0);				/* Default behaviour (unlocked) */
59
60
 pthread_cond_init(&(lock->rcond),	/* Create read condition variable */
61
				   0);				/* Default behaviour */
62
63
 pthread_cond_init(&(lock->wcond),	/* Create write condition variable */
64
				   0);				/* Default behaviour */
65
66
 lock->waiting_writers=0;
67
 lock->readCount = 0;
68
 return TRUE;
69
#else
70
	pthread_rwlock_init(lock, NULL);
71
	return TRUE;
72
#endif
73
74
#endif
75
}
76
77
78
79
void ra_deleteLock(Lock_t *lock) {
80
#ifdef _WIN32
81
	if (NULL != lock->hEventNoReaders)
82
		CloseHandle(lock->hEventNoReaders);
83
#elif defined __linux__ || defined _HPUX
84
  /* do nothing */
85
#else
86
	pthread_rwlock_destroy(lock);
87
#endif
88
}
89
90
91
92
int ra_getWriteLock(Lock_t *lock) {
93
#ifdef _WIN32
94
	WaitForSingleObject(lock->hEventNoReaders, INFINITE);
95
	EnterCriticalSection(&lock->cs);
96
	return 0;
97
#elif defined __linux__ || defined _HPUX
98
	/*pthread_cleanup_push(rwlock_WaitingWriterCleanup, lock); */
99
	pthread_mutex_lock(&(lock->mutex));
100
	lock->waiting_writers++;
101
	while(lock->readCount || lock->active_writers ) {
102
		pthread_cond_wait(&(lock->wcond), &(lock->mutex));
103
	}
104
	lock->active_writers++;
105
	lock->waiting_writers--;
106
	/* pthread_cleanup_pop(1); */
107
	pthread_mutex_unlock(&(lock->mutex));
108
#else
109
	pthread_rwlock_wrlock(lock);
110
	return 0;
111
#endif
112
}
113
114
115
116
void ra_releaseWriteLock(Lock_t* lock) {
117
#ifdef _WIN32
118
	LeaveCriticalSection(&lock->cs);
119
#elif defined __linux__ || defined _HPUX
120
	pthread_mutex_lock(&(lock->mutex));
121
	if(!--lock->active_writers) {
122
		pthread_cond_broadcast(&lock->rcond);
123
	}
124
	else {
125
		pthread_cond_signal(&lock->wcond);
126
	}
127
	pthread_mutex_unlock(&(lock->mutex));
128
#else
129
	pthread_rwlock_unlock(lock);
130
#endif
131
}
132
133
134
135
int ra_getReadLock(Lock_t *lock) {
136
#ifdef _WIN32
137
	EnterCriticalSection(&lock->cs);
138
	if (lock->numReaders++==1) {
139
		// If this is the first reader thread,
140
		// set our event to reflect this.
141
		ResetEvent(lock->hEventNoReaders);
142
	}
143
	LeaveCriticalSection(&lock->cs);
144
	return 0;
145
#elif defined __linux__ || defined _HPUX
146
	/*pthread_cleanup_push(rwlock_WaitingReaderCleanup, lock); */
147
	pthread_mutex_lock(&(lock->mutex));
148
	if(lock->waiting_writers || lock->active_writers) {
149
		pthread_cond_wait(&(lock->rcond), &(lock->mutex));
150
	}
151
	lock->readCount++;
152
	/* pthread_cleanup_pop(1); */
153
	pthread_mutex_unlock(&(lock->mutex));
154
	return 0;
155
#else
156
	pthread_rwlock_rdlock(lock);
157
	return 0;
158
#endif
159
}
160
161
162
163
164
void ra_releaseReadLock (Lock_t *lock) {
165
#ifdef _WIN32
166
167
	EnterCriticalSection(&lock->cs);
168
	if (!--lock->numReaders) {
169
		SetEvent(lock->hEventNoReaders);
170
	}
171
	LeaveCriticalSection(&lock->cs);
172
#elif defined __linux__ || defined _HPUX
173
	pthread_mutex_lock(&(lock->mutex));
174
	if (!--lock->readCount) {
175
		pthread_cond_signal(&(lock->wcond));
176
	}
177
	pthread_mutex_unlock(&(lock->mutex));
178
#else
179
	pthread_rwlock_unlock(lock);
180
#endif
181
}
182
183
184
#if defined __linux__ || defined _HPUX
185
186
void rwlock_WaitingReaderCleanup(void *arg)
187
{
188
    Lock_t *rwl;
189
    rwl = (Lock_t*)arg;
190
/*	printf("Cleaning up reader\n"); */
191
    pthread_mutex_unlock(&(rwl->mutex));
192
/*	printf("Reader cleaned\n"); */
193
}
194
195
void rwlock_WaitingWriterCleanup(void *arg)
196
{
197
    Lock_t *rwl;
198
    rwl = (Lock_t*)arg;
199
/*	printf("Cleaning up writer\n"); */
200
    if( (rwl->readCount>= 0 && !rwl->waiting_writers) )
201
		pthread_cond_broadcast(&(rwl->wcond)); /*  This only happens if we have been cancelled */
202
/*	printf("Writer Cleaned\n"); */
203
    pthread_mutex_unlock(&(rwl->mutex));
204
}
205
#endif
(-)src-native-new/src/agents/thread/hcthread.h (+89 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: hcthread.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include <jni.h>
14
#include <stdio.h>
15
#include <stdarg.h>
16
#include <string.h>
17
18
#include "RABindings.h"
19
#include "RADataTransfer.h"
20
#include "RAShm.h"
21
#include "RASocket.h"
22
23
/* Strings */
24
#if defined(__OS400__)
25
	#pragma convert(819)
26
#elif defined(MVS)
27
	#pragma convlit(suspend)
28
#endif
29
30
#define THREAD_DUMP_AGENT_CLASS_NAME "org/eclipse/hyades/logging/jvm/threadanalysis/ThreadDumpAgentImpl"
31
#define THREAD_DUMP_AGENT_PROCESSOR "processDumpData"
32
#define THREAD_DUMP_AGENT_PROCESSOR_ARGS "(Ljava/lang/String;)Ljava/lang/String;"
33
#define AGENT_NAME "Thread Analysis Agent"
34
#define AGENT_TYPE "Logging"
35
36
#if defined(__OS400__)
37
	#pragma convert(0)
38
#elif defined(MVS)
39
	#pragma convlit(resume)
40
#endif
41
42
/* Macro to simplify the JNI code. */
43
#if defined __cplusplus && defined _HPUX
44
	#define ENV(e) e
45
	#define ENVPARM(e)
46
#else
47
	#define ENV(e) (*e)
48
	#define ENVPARM(e) e,
49
#endif
50
51
/* Macro for findind the current working directory */
52
#if defined(_WIN32)
53
	#include <direct.h>
54
	#include <signal.h>
55
	#include <process.h>
56
	#define getcwd _getcwd
57
	#define getpid _getpid
58
#else
59
	#include <unistd.h>
60
	#include <signal.h>
61
#endif
62
63
/* Macro for debug messages */
64
#if defined(MVS) || defined(__OS400__)
65
	#define vsnprintf(a,b,c,d) vsprintf(a,c,d)
66
#elif defined(_WIN32)
67
	#define vsnprintf _vsnprintf
68
#endif
69
70
void init(char* name, char* type);
71
void dump();
72
void deregister();
73
void hc_dumpThreads();
74
void autodump();
75
void getRunningDir(char* buffer);
76
void messageHandler(ra_command_t *command);
77
void processDumpData(char* path);
78
void debugTrace(char* msg, ...);
79
void autodump(int interval);
80
void *autoDumpThread(void *args);
81
82
#if defined(_WIN32)
83
DWORD WINAPI autoDumpProxy(LPVOID args);
84
void sleep(int sec);
85
#elif defined(__linux__)
86
void getProcessStat(int pid, char* value);
87
BOOL isProcessName(int pid, char* pname);
88
int getParentProcessId(int pid);
89
#endif
(-)src-native-new/src/agents/java/hcjbnd.make (+129 lines)
Added Link Here
1
2
################################################################################
3
#                                       
4
#  makefile:  hcjbnd project  
5
#                                       
6
# $Id
7
################################################################################
8
9
10
#-----------------------------------
11
#
12
#   Customizable section
13
#
14
#   - The TARGETREALNAME variable specifies the name of the library file
15
#     that will be generated, this includes a base (TARGETLIB) plus	a 
16
#     version number plus a minor number plus a release number
17
#   - The TARGETSONAME variable specifies a file name that has just the
18
#     library name plus the major version number
19
#   - The TARGETLIB variable specifies the base library name
20
#   - The TARGETSONAME and TARGETLIB are generated as symbolic links
21
#     when the library is built
22
#
23
#-----------------------------------
24
TARGET         :=  libhcjbnd
25
TARGETDIR      :=  ../../../lib
26
27
if [ x$VERSIONNUM = x ]; then export VERSIONNUM=0; fi
28
if [ x$MINORNUM = x ]; then export MINORNUM=0; fi
29
if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi
30
31
TARGETLIB      :=  $(TARGET).so
32
TARGETSONAME   :=  $(TARGETLIB).$(VERSIONNUM)
33
TARGETREALNAME :=  $(TARGETSONAME).$(MINORNUM).$(RELEASENUM)
34
35
36
#-----------------------------------
37
#   list of additional INCLUDE directories to search headers from
38
#      (separated by blanks)
39
#-----------------------------------
40
INCLUDEDIRS    :=  .  ../../../include $(JAVA_HOME)/include $(JAVA_HOME)/include/linux ../RABindings ../../transport/RACommon ../../transport/RASocket ../../transport/RASharedMemory ../../transport/RADataTransfer
41
42
43
#-----------------------------------
44
#   list of additional libraries to be linked with
45
#      (separated by blanks)
46
#-----------------------------------
47
LIBS       :=  dl hcbnd pthread
48
49
#-----------------------------------
50
#   list of additional library directories to search from
51
#      (separated by blanks)
52
#-----------------------------------
53
LIBDIRS    :=  ../../../lib
54
55
56
#-----------------------------------
57
#
58
#   Compiler options
59
#
60
#      -g       produce debug info
61
#      -Wall    enable all types of warnings
62
#      -O3      highest level of code optimization
63
#      -fPIC    generate position-independent code (PIC).
64
#               This is required for building shared library.
65
#      -c       compile only
66
#
67
#   Linking options
68
#
69
#       -Wl       pass options to linker
70
#       -shared   produce shared library
71
#       -L        add the given directory to the search path for libraries
72
#
73
#-----------------------------------
74
75
DEFINES    := -DSQLUNIX -DSQLLinux -DENW -DREENTRANT -D_REENTRANT -DCONFIG_X86_CMPXCHG
76
77
CFLAGS     :=  $(C_FLAGS) $(DEBUGABLE) -Wall $(OPTIMIZABLE) -fPIC $(addprefix -I,$(INCLUDEDIRS))  -D_LINUX_X86  $(DEFINES)
78
79
CXXFLAGS   :=  $(CFLAGS)
80
81
LINKOPTS   :=  $(L_FLAGS) $(DEBUGABLE) -shared -Wl,-soname,$(TARGETSONAME) -o $(TARGETDIR)/$(TARGETREALNAME) $(addprefix -L,$(LIBDIRS))
82
83
84
#-----------------------------------
85
#   general commands and options
86
#-----------------------------------
87
88
CC          :=  gcc
89
CXX         :=  $(CC)
90
91
SOURCE     :=  $(wildcard *.c)  $(wildcard *.cpp)
92
93
OBJS       :=  $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
94
95
REMOVEFILE :=  rm -f
96
CREATELINK :=  ln -sf
97
98
99
#-----------------------------------
100
#   "make" rules
101
#-----------------------------------
102
103
.PHONY : default everything objs clean veryclean rebuild $(TARGET)
104
105
106
default : $(TARGET)
107
108
109
objs : $(OBJS)
110
111
112
clean :
113
	$(REMOVEFILE) *.o
114
115
116
veryclean: clean
117
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETLIB)
118
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETSONAME)
119
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETREALNAME)
120
121
122
rebuild: veryclean everything
123
124
125
$(TARGET) : $(OBJS)
126
	$(CC) $(LINKOPTS) $(OBJS) $(addprefix -l,$(LIBS))
127
	$(CREATELINK) $(TARGETREALNAME)  $(TARGETDIR)/$(TARGETSONAME)
128
	$(CREATELINK) $(TARGETSONAME)    $(TARGETDIR)/$(TARGETLIB)
129
(-)src-native-new/src/agents/native/java_profiler/JvmpiWriter.h (+159 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: JvmpiWriter.h,v 1.3 2006/04/24 13:29:35 samwai Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef __JVMPIWRITER__
14
 #define __JVMPIWRITER__
15
16
17
/* This macro defines the XML4Profiling Specification level of the agent */
18
#define AGENT_VERSION "1.000"
19
20
#ifdef _WIN32
21
	#include <winsock2.h> /* Bug 134924 */
22
	#include <windows.h>
23
#else
24
	#include <pthread.h>
25
#endif
26
27
#include <stdio.h>
28
#include <string.h>
29
#include <jvmpi.h>
30
#include "filters.h"
31
32
#include "hash.h"
33
#include "stack.h"
34
#include "lock3.h"
35
#include "performance.h"    /* 183945 - changed uppercase p to lowercase */
36
37
#ifndef TRUE
38
 #ifdef _HPUX
39
  #define TRUE TRUE
40
 #else
41
  #define TRUE 1
42
 #endif
43
#endif
44
45
#ifndef FALSE
46
 #ifdef _HPUX
47
  #define FALSE FALSE
48
 #else
49
  #define FALSE 0
50
 #endif
51
#endif
52
53
54
enum ThrowOrCatch {Throw, Catch};
55
56
/* RKD:  Request event macro as this has a slightly different signature on OS/400 but this
57
         will be changing in the near future.
58
*/
59
#ifdef __OS400__
60
 #define REQUEST_EVENT(A, B) _jvmpiAgent_jvmpiInterface->RequestEvent(A, (void*)(B));
61
 #define REQUEST_EVENT2(A, B) _jvmpiAgent_jvmpiInterface->RequestEvent2(A, B); /* 232010 */
62
#else
63
 #define REQUEST_EVENT(A, B) _jvmpiAgent_jvmpiInterface->RequestEvent(A, B);
64
 #define REQUEST_EVENT2(A, B) _jvmpiAgent_jvmpiInterface->RequestEvent(A, B); /* 232010 */
65
#endif
66
67
/* 236501 - STRDUP now defined in RAComm.h
68
#ifdef __OS400__
69
  #define strdup(a) a
70
#endif
71
*/
72
73
typedef struct
74
{
75
 unsigned long traceMask;
76
} EventList;
77
78
typedef struct {
79
	unsigned long index;
80
	timestamp_t lastGenerationTime;
81
}GenerationInfo_t;
82
83
/* Bug 64476 Moved the #if defined above the typedef */
84
#if defined __cplusplus
85
 extern "C" {
86
#endif
87
88
/* Piyush Agarwal */
89
typedef void (*optHeapDumpFileInfoCallBackType)(char *filename);
90
typedef struct {
91
    optHeapDumpFileInfoCallBackType ohdcb ;
92
} OptHeapCallBack ;
93
94
95
enum JavaVendor {VendorIBM, VendorSun, VendorHP, VendorOther}; 
96
enum JavaVersion {Version13,Version140,Version141,Version142,VersionOther}; 
97
98
extern enum JavaVendor _javaVendor; 
99
extern enum JavaVersion _javaVersion; 
100
101
/* GLOBALS
102
 */
103
extern JVMPI_Interface * _jvmpiAgent_jvmpiInterface; /* JVMPI Interface pointer created in JVM_OnLoad */
104
extern jmethodID _jvmpiAgent_setExceptionTracing;
105
extern jclass _jvmpiAgent_JVMPIException;
106
extern JavaVM * _jvmpiAgent_jvm;            /* JVM Pointer passed in on JVM_OnLoad */
107
extern Lock_t _jvmpiAgent_synchLock;
108
extern char *_jvmpiAgent_trace_id;
109
extern const char *_jvmpiAgent_nodeUUID;
110
extern const char *_jvmpiAgent_processUUID;
111
extern GenerationInfo_t _heapDumpInfo;
112
extern RA_AGENT_HANDLE _jvmpiAgent_bindingStorage;	/* The Agent handle for the RAC */
113
114
extern SegmentedValue_t _jvmpiAgent_collation;
115
116
/* Call Back Functions */
117
extern OptHeapCallBack  _jvmpiAgent_optHeapCallBack ;
118
119
/* Function pointer definition for the JVM interface function that converts JNI
120
 object handles to JVMPI object identifiers.  This API is available as follows:
121
 Sun JDK 1.2.2 Classic as an undocumented entry point in the JVM
122
 Sun JDK 1.3 Classic as an undocumented entry point in the JVM
123
 Note: The Sun JDK 1.3 Hotspot JVM documents this API as part of the JVMPI
124
 interface, however they do not include the definition of this API in the JVMPI
125
 header file that they ship.  In addition, they have removed the entry point for
126
 this function from the Hotspot JVM. So at this time, this function is not
127
 available when running under the Sun Hotspot JVM.
128
 IBM JDK 1.2.2 as both an entry point in the JVM and as part of the JVMPI interface
129
 functions.
130
 IBM JDK 1.3 as both an entry point in the JVM and as part of the JVMPI interface
131
 functions.
132
*/
133
typedef jobjectID (*Jobject2jobjectID)(jobject obj);
134
135
136
137
extern void jvmpiAgent_outputMethodDeclaration(HashEntry *methodHashEntry, ThreadPrivateStorage *tps);
138
extern void jvmpiAgent_outputClassDeclaration(HashEntry *classHashEntry, ThreadPrivateStorage *tps);
139
140
extern void sendErrorMessage(RA_ERROR_LEVEL severity,
141
							 const char *errorId,
142
							 const char *errorString);
143
144
/** GET_THREAD_LOCAL_STORAGE  *************************************************
145
  * This function returns the address of the thread local storage for the
146
  * specified JNIEnv (aka thread).  A special thread local storage structure is
147
  * allocated for static references and is returned when the JNIEnv parameter is
148
  * 0 or if the JVM is in Garbage Collection or Shutdown mode. Garbage Collection
149
  * and Shutdown mode must be handled in this way because some versions of the
150
  * JVM use special threads to do this processing which cause the
151
  * GetThreadLocalStorage interface function to trap.
152
  */
153
extern ThreadPrivateStorage *jvmpiAgent_getThreadLocalStorage(JNIEnv *env_id);
154
155
156
#if defined __cplusplus
157
 }
158
#endif
159
#endif
(-)src-native-new/src/agents/thread/hcthread.c (+515 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: hcthread.c,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include "hcthread.h"
14
15
JavaVM *jvm = NULL;
16
RA_AGENT_HANDLE handle = NULL;
17
ra_data_target_hdl_t *targetHandle = NULL;
18
BOOL attached = FALSE;
19
BOOL isAuto = FALSE;
20
BOOL isNative = TRUE;
21
ra_critsec_t lock;
22
23
/*
24
 * Initialization called from the java layer
25
 */
26
JNIEXPORT void JNICALL Java_org_eclipse_hyades_logging_jvm_threadanalysis_ThreadDumpAgentImpl_init0(JNIEnv *env, jobject obj, jstring name, jstring type) {
27
	char *_name;
28
	char *_type;
29
30
	/* Retrieve the current JVM and store it */
31
	ENV(env)->GetJavaVM(ENVPARM(env) &jvm);
32
33
	/* Translate the java strings to native strings */
34
	_name = (char*)(ENV(env)->GetStringUTFChars(ENVPARM(env) name, NULL));
35
	_type = (char*)(ENV(env)->GetStringUTFChars(ENVPARM(env) type, NULL));
36
37
	isNative = FALSE;
38
	init(_name, _type);
39
}
40
41
/*
42
 * Deregister called from the java layer
43
 */
44
JNIEXPORT void JNICALL Java_org_eclipse_hyades_logging_jvm_threadanalysis_ThreadDumpAgentImpl_deregister0(JNIEnv *env, jobject obj) {
45
	deregister();
46
}
47
48
/*
49
 * Dump thread called from the java layer
50
 */
51
JNIEXPORT void JNICALL Java_org_eclipse_hyades_logging_jvm_threadanalysis_ThreadDumpAgentImpl_dumpThreads0(JNIEnv *env, jobject obj) {
52
	/* Return the location of the running java program which has just produced a thread dump */
53
	dump();
54
}
55
56
/*
57
 * Get process ID called from the java layer
58
 */
59
JNIEXPORT jint JNICALL Java_org_eclipse_hyades_logging_jvm_threadanalysis_ThreadDumpAgentImpl_getPid0(JNIEnv *env, jobject obj) {
60
	return getpid();
61
}
62
63
/*
64
 * JVMPI interface
65
 */
66
JNIEXPORT jint JNICALL JVM_OnLoad(JavaVM *_jvm, char *options, void *reserved) {
67
	jvm = _jvm;
68
69
	init(AGENT_NAME, AGENT_TYPE);
70
71
	return JNI_OK;
72
}
73
74
/*
75
 * Register the agent with the agent controller
76
 */
77
void init(char* name, char* type) {
78
/*
79
	JDK1_1InitArgs vm_args;
80
	JNIEnv *env;
81
*/
82
83
	/* Create a lock for the critical section */
84
	ra_mutexCreate(&lock);
85
86
	/* Initialize and register the agent with the agent controller */
87
	handle = ra_initializeBindings(name, type, messageHandler, FALSE);
88
89
	targetHandle = (ra_data_target_hdl_t*)malloc(sizeof(ra_data_target_hdl_t));
90
91
	/* Start the message handler */
92
	ra_startListener(handle, FALSE);
93
	debugTrace("Registered agent: \"%s\" of type: \"%s\"", name, type);
94
95
	/* If this is called by the native code (and not by -Xrun), it won't have a JVM associated */
96
	if(isNative && (jvm == NULL)) {
97
		debugTrace("Not supported");
98
/*
99
		JNI_GetDefaultJavaVMInitArgs(&vm_args);
100
		if(JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args) != 0) {
101
			debugTrace("Error creating Java VM");
102
			return;
103
		}
104
		else {
105
			debugTrace("Java VM created successfully");
106
		}
107
*/
108
	}
109
110
}
111
112
/*
113
 * Deregister the agent with the agent controller
114
 */
115
void deregister() {
116
	/* Deregister with the agent controller */
117
	ra_finalizeBindings(handle);
118
	debugTrace("Deregistered agent");
119
120
	/* Destroy the lock for the critical section */
121
	ra_mutexDestroy(&lock);
122
123
	if(isNative) {
124
		/* Destroy the JVM */
125
#if defined __cplusplus && defined _HPUX
126
		ENV(jvm)->DestroyJavaVM();
127
#else
128
		ENV(jvm)->DestroyJavaVM(jvm);
129
#endif
130
		debugTrace("Destroyed from the JVM");
131
	}
132
133
	free(targetHandle);
134
	targetHandle = NULL;
135
}
136
137
/*
138
 * Message handler for agent contorller messages
139
 */
140
void messageHandler(ra_command_t *command) {
141
	debugTrace("Command received, tag = 0x%x", command->tag);
142
	switch(command->tag) {
143
		case RA_CUSTOM_COMMAND:
144
			{
145
				debugTrace("Message received: RA_CUSTOM_COMMAND, data = %s", command->info.custom_command.message.data);
146
147
				if(strcmp(command->info.custom_command.message.data, "ANALYSEHEAP")==0) {
148
					dump();
149
					debugTrace("Manual thread dump");
150
				}
151
				else if(strcmp(command->info.custom_command.message.data, "RESUME")==0) {
152
					dump();
153
/*
154
					isAuto = TRUE;
155
					autodump(3);
156
*/
157
					debugTrace("Manual thread dump");
158
				}
159
				break;
160
			}
161
		case RA_START_MONITORING_AGENT_REMOTE:
162
		case RA_START_MONITORING_AGENT_LOCAL:
163
			{
164
				debugTrace("Message received: RA_START_MONITORING");
165
				if(!attached) {
166
					if(command->tag == RA_START_MONITORING_AGENT_LOCAL) {
167
						targetHandle->dtarget = RA_SHAREDMEMORY;
168
						ra_attachToShm(command->info.start_monitor_local.file.data, &targetHandle->dtargetHdl.shmHdl);
169
						debugTrace("Attached to shared memory");
170
					}
171
					else if(command->tag == RA_START_MONITORING_AGENT_REMOTE) {
172
						targetHandle->dtarget = RA_SOCKET;
173
						ra_connectToTCPServer(command->info.start_monitor_remote.ip, (unsigned short)command->info.start_monitor_remote.port, &targetHandle->dtargetHdl.socketFD);
174
						debugTrace("Connected to TCP server");
175
					}
176
					attached = TRUE;
177
				}
178
				break;
179
			}
180
		case RA_STOP_MONITORING_AGENT:
181
			{
182
				debugTrace("Message received: RA_STOP_MONITORING");
183
				isAuto = FALSE;
184
				break;
185
			}
186
		case RA_DETACH_FROM_AGENT:
187
			{
188
				debugTrace("Message received: RA_DETACH_FROM_AGENT");
189
				if(targetHandle->dtarget == RA_SHAREDMEMORY) {
190
					ra_stopFlushingShm(&targetHandle->dtargetHdl.shmHdl);
191
				}
192
				else if(targetHandle->dtarget == RA_SOCKET) {
193
					ra_closeSocket(targetHandle->dtargetHdl.socketFD);
194
				}
195
				isAuto = FALSE;
196
				attached = FALSE;
197
				break;
198
			}
199
		default:
200
			break;
201
	}
202
}
203
204
/*
205
 * Automatically performing a thread dump
206
 */
207
void autodump(int interval) {
208
	TID tid;
209
#ifdef _WIN32
210
	CreateThread(NULL, 0, autoDumpProxy, (LPVOID)(&interval), 0, &tid);
211
#else
212
	pthread_create(&tid, NULL, autoDumpThread, &interval);
213
#endif
214
	debugTrace("Auto dump thread created: ID = %d, interval = %d sec", tid, interval);
215
}
216
217
/*
218
 * Windows proxy for the thread
219
 */
220
#ifdef _WIN32
221
DWORD WINAPI autoDumpProxy(LPVOID args) {
222
	DWORD returnVal = 0;
223
	autoDumpThread(args);
224
	return returnVal;
225
}
226
#endif
227
228
/*
229
 * Thread for automatically dumping the threads at a certain time interval
230
 * Note: On Windows 2000 this thread will exit after the Ctrl-Break is sent. It will keep on running
231
 *       on Windows XP.
232
 */
233
void *autoDumpThread(void *args) {
234
	int interval = *((int*)args);
235
	while(isAuto) {
236
		dump();
237
		sleep(interval);
238
	}
239
	return NULL;
240
}
241
242
/*
243
 * Dump thread called from the native layer
244
 */
245
void dump() {
246
	char* currentPath = (char*)malloc(_MAX_PATH * sizeof(char));;
247
248
	/* Enter critical section */
249
	ra_mutexEnter(&lock);
250
251
	getRunningDir(currentPath);
252
	debugTrace("Current working directory: %s", currentPath);
253
254
	hc_dumpThreads();
255
	debugTrace("Finished native dump()");
256
257
	/* Pushing the filename into the Java layer to do the processing */
258
	processDumpData(currentPath);
259
	debugTrace("Finished native processDumpData()");
260
261
	/* Leave critical section */
262
	ra_mutexExit(&lock);
263
264
	free(currentPath);
265
266
	return;
267
}
268
269
/*
270
 * Retrieve the current working directory
271
 */
272
void getRunningDir(char* buffer) {
273
	getcwd(buffer, _MAX_PATH);
274
}
275
276
/*
277
 * Call the "kill -3" or "Ctrl-Break" to initiate the thread dump
278
 */
279
void hc_dumpThreads() {
280
	BOOL rc = FALSE;
281
#if defined(_WIN32)
282
	DWORD dw;
283
284
	rc = GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, 0);
285
/*
286
	if(raise(SIGBREAK) == 0) {
287
		debugTrace("Signal raised successfully: %d", SIGBREAK);
288
	}
289
	else {
290
		debugTrace("Problem raising signal: %d", SIGBREAK);
291
	}
292
*/
293
	if(rc == 0) {
294
		dw = GetLastError();
295
		debugTrace("Error sending console control event: %d to process: %d", dw, getpid());
296
	}
297
298
	debugTrace("Control-Break sent to process: %d", GetCurrentProcessId());
299
/* Since Linux threads are sub-processes so we need to send the signal to the main thread */
300
#elif defined(__linux__)
301
	int last = getpid();
302
	int pid = getppid(); /* start searching from the current pid's parent */
303
304
	while(isProcessName(pid, "java")) { /* Navigate until main thread is found */
305
		debugTrace("Parent is still java, going to its parent");
306
		last = pid;
307
		pid = getParentProcessId(last);
308
		debugTrace("Checking parent pid: %d", pid);
309
	}
310
311
	kill(last, SIGQUIT);
312
	debugTrace("Signal %d raised to process: %d", SIGQUIT, last);
313
314
#else
315
	if(raise(SIGQUIT) == 0) {
316
		debugTrace("Signal %d raised successfully to process: %d", SIGQUIT, getpid());
317
	}
318
	else {
319
		debugTrace("Problem raising signal %d to process %d", SIGQUIT, getpid());
320
	}
321
#endif
322
}
323
324
/*
325
 * Call the java code to process the javacore file
326
 */
327
void processDumpData(char* path) {
328
	JNIEnv *env;
329
	jclass cls;
330
	jmethodID method;
331
	jstring xmlString;
332
	char *localXmlString;
333
	unsigned char *copy;
334
	int length;
335
336
	debugTrace("Inside native processDumpData()");
337
338
	/* Attach to the current JVM */
339
	ENV(jvm)->AttachCurrentThread(ENVPARM(jvm) (void**)&env, NULL);
340
	debugTrace("Attached current thread to the JVM");
341
342
	/* Initialize the java class object */
343
	cls = ENV(env)->FindClass(ENVPARM(env) THREAD_DUMP_AGENT_CLASS_NAME);
344
345
	if(cls != NULL) {
346
		debugTrace("Found class \"%s\"", THREAD_DUMP_AGENT_CLASS_NAME);
347
		method = ENV(env)->GetStaticMethodID(ENVPARM(env) cls, THREAD_DUMP_AGENT_PROCESSOR, THREAD_DUMP_AGENT_PROCESSOR_ARGS);
348
349
		if(method != NULL) {
350
			debugTrace("Found method \"%s\"", THREAD_DUMP_AGENT_PROCESSOR);
351
			xmlString = (jstring)(ENV(env)->CallStaticObjectMethod(ENVPARM(env) cls, method, ENV(env)->NewStringUTF(ENVPARM(env) path)));
352
353
			if(xmlString != NULL) {
354
				debugTrace("Returned successfully from java layer processDumpData()");
355
				localXmlString = (char*)(ENV(env)->GetStringUTFChars(ENVPARM(env) xmlString, NULL));
356
357
				if(localXmlString != NULL) {
358
					debugTrace("Translated java string to local string: %s", localXmlString);
359
360
					length = strlen(localXmlString);
361
					copy = ra_allocateMessageBlock(length);
362
					memcpy(copy, localXmlString, length);
363
364
					if(targetHandle != NULL) {
365
						ra_writeMessageBlock(targetHandle, RA_BINARY_DATA, copy, length);
366
						debugTrace("Wrote XML fragments to target handle");
367
					}
368
					else {
369
						debugTrace("Cannot write to target handle");
370
					}
371
372
					ra_freeMessageBlock(copy);
373
					ENV(env)->ReleaseStringUTFChars(ENVPARM(env) xmlString, localXmlString);
374
					debugTrace("Released local XML string");
375
				}
376
				else {
377
					debugTrace("Cannot translate java string to local string");
378
				}
379
			}
380
			else {
381
				debugTrace("Problem getting XML string from java layer");
382
			}
383
		}
384
		else {
385
			debugTrace("Cannot find the method \"%s\" in the java layer", THREAD_DUMP_AGENT_PROCESSOR);
386
		}
387
	}
388
	else {
389
		debugTrace("Cannot find the class \"%s\" in the java layer", THREAD_DUMP_AGENT_CLASS_NAME);
390
	}
391
	/* Detach from the JVM */
392
#if defined __cplusplus && defined _HPUX
393
	ENV(jvm)->DetachCurrentThread();
394
#else
395
	ENV(jvm)->DetachCurrentThread(jvm);
396
#endif
397
	debugTrace("Detached from the JVM");
398
}
399
400
/*
401
 * Debugging output
402
 */
403
void debugTrace(char* msg, ...) {
404
#if _DEBUG
405
	va_list argp;
406
	int len;
407
    int bufferSize = 8192;
408
    char *buffer = NULL;
409
410
	va_start(argp, msg);
411
412
	buffer = (char*)malloc(bufferSize * sizeof(char));
413
	while((len = vsnprintf(buffer, bufferSize, msg, argp)) < 0) {
414
		bufferSize += 1024;
415
		buffer = (char*)malloc(bufferSize * sizeof(char));
416
	}
417
418
	va_end(argp);
419
420
	/* Check if local logging is enabled */
421
	printf("DEBUG(NATIVE): %s\n", buffer);
422
	free(buffer);
423
#endif
424
}
425
426
/*
427
 * Sleep in seconds
428
 */
429
#if defined(_WIN32)
430
void sleep(int sec) {
431
	Sleep(sec * 1000);
432
}
433
#endif
434
435
#if defined(__linux__)
436
/*
437
 * Get the process status from /proc
438
 */
439
void getProcessStat(int pid, char* value) {
440
	FILE *fp;
441
	char *proc;
442
	int rc;
443
444
	proc = (char*)malloc(sizeof(char) * _MAX_PATH);
445
446
	sprintf(proc, "/proc/%d/stat", pid); /* open the stat file of pid */
447
	debugTrace("Opening file %s for reading", proc);
448
449
	fp = fopen(proc, "r");
450
	rc = fread(value, sizeof(char), _MAX_PATH, fp);
451
	fclose(fp);
452
	debugTrace("%d bytes read from file %s", rc, proc);
453
454
	free(proc);
455
456
	return;
457
}
458
459
/*
460
 * Check if the process with this pid has the name specified
461
 */
462
BOOL isProcessName(int pid, char* pname) {
463
	char *stat;
464
	char *name;
465
	BOOL exist;
466
467
	debugTrace("Inside isProcessName(%d, %s)", pid, pname);
468
	stat = (char*)malloc(sizeof(char) * _MAX_PATH);
469
	getProcessStat(pid, stat);
470
471
	strtok(stat, " "); /* skip the 1st tok, process id */
472
	name = strtok(NULL, " "); /* got the 2nd tok, parent name */
473
474
	if(strstr(name, pname) != NULL) {
475
		debugTrace("String \"%s\" found in string \"%s\"", pname, name);
476
		exist = TRUE;
477
	}
478
	else {
479
		debugTrace("String \"%s\" not found in string \"%s\"", pname, name);
480
		exist = FALSE;
481
	}
482
483
	free(stat);
484
/*	free(name); /* is it an error? */
485
486
	return exist;
487
}
488
489
/*
490
 * Get the parent pid of a process
491
 */
492
int getParentProcessId(int pid) {
493
	char *stat;
494
	char *ppid_str;
495
	int ppid;
496
497
	debugTrace("Inside getParentProcessId(%d)", pid);
498
	stat = (char*)malloc(sizeof(char) * _MAX_PATH);
499
	getProcessStat(pid, stat);
500
501
	strtok(stat, " "); /* skip the 1st tok, process id */
502
	strtok(NULL, " "); /* skip the 2nd tok, process name */
503
	strtok(NULL, " "); /* skip the 3rd tok, process status */
504
	ppid_str = strtok(NULL, " "); /* got the 4th tok, parent process id */
505
506
	sscanf(ppid_str, "%d", &ppid);
507
	debugTrace("Parent process ID found is %d", ppid);
508
509
	free(stat);
510
/*	free(ppid_str); /* is it an error? */
511
512
	return ppid;
513
}
514
515
#endif
(-)src-native-new/src/transport/RADataTransfer/RADataTransfer.h (+116 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: RADataTransfer.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef _RADATATRANSFER_H
14
#define _RADATATRANSFER_H
15
16
#include "stdio.h"
17
#include "RASocket.h"
18
#include "RAShm.h"            /* 175248 - replaced RASharedMemory.h with this */
19
20
#ifdef __cplusplus
21
extern "C" {
22
#endif
23
24
/* This library provides a more rich set of data transfer
25
   functions then that provided by the RASocket library.
26
*/
27
28
/* The various message types that are supported by this library
29
   are.
30
31
		  BINARY_DATA  - data that is intended to be consumed byte by byte.
32
	  UTF8_STRING_DATA - string data where each character is represented
33
					     by one byte.
34
   UNICODE_STRING_DATA - string data where each character is represented
35
						 by two bytes
36
*/
37
38
enum _dataFormat {RA_BINARY_DATA,
39
				  RA_UTF8_STRING_DATA,
40
				  RA_UNICODE_STRING_DATA};
41
42
typedef  enum _dataFormat dataFormat_t;
43
44
typedef dataFormat_t ra_dataFormat_t;
45
46
/* DNS Definitions to make data transfer more general ie supports different targets
47
       for the data transfer */
48
49
enum _dataTarget { RA_SOCKET,
50
                   RA_FILE,
51
                   RA_SHAREDMEMORY };
52
53
typedef  enum _dataTarget dataTarget_t;
54
55
typedef  struct {
56
   dataTarget_t dtarget;
57
   union {
58
      SOCKET          socketFD;
59
      FILE            fileD;
60
      ra_shm_handle_t *shmHdl;        /* 175248 - changed to a pointer */
61
   } dtargetHdl;
62
} ra_data_target_hdl_t;
63
/* DNS end */
64
65
66
/** ALLOCATE_MESSAGE_BLOCK  ************************************************
67
  * Allocates a block of memory that can be used for a message and returns
68
  * the address where the caller can start adding data.
69
  * IMPORTANT:  must use ra_freeMessageBlock to free the memory when done
70
  * @param  length  - the number of bytes required for the message
71
  * @returns        - the address where the message can be written to.  NULL if
72
  *                   there is no available memory.
73
  */
74
extern unsigned char *ra_allocateMessageBlock(ra_uint_t length);
75
76
77
78
/** REALLOCATE_MESSAGE_BLOCK  ************************************************
79
  * Recieves an existing message block and allocates a block of memory with the
80
  * newley specified size.  The data in the existing message block is copied
81
  * to the new message block.
82
  * IMPORTANT:  must use ra_freeMessageBlock to free the memory when done
83
  * @param  message - the existing message block.
84
  * @param  length  - the number of bytes required for the new message
85
  * @returns        - the address where the message can be written to.  NULL if
86
  *                   there is no available memory.
87
  */
88
extern unsigned char *ra_reallocateMessageBlock(unsigned char *message, ra_uint_t length);
89
90
91
/** FREE_MESSAGE_BLOCK  ************************************************
92
  * Free's a block of message memory
93
  * @param message - the address returned by ra_allocateMessageBlock
94
  */
95
extern void ra_freeMessageBlock(unsigned char *message);
96
97
98
/** WRITE_MESSAGE_BLOCK *************************************************
99
  * DNS - replaced socket parm with target handle struct
100
  * Writes a message to the specified target using the specified format.
101
  * @param  handle - the handle of the target to write the data to.
102
  * @param  format - the format to use
103
  * @param message - the address of the start of the message.
104
  * @param  length - the number of bytes to write to fd.
105
  * @returns       - the number of bytes written to the socket.
106
  */
107
extern ra_uint_t ra_writeMessageBlock(ra_data_target_hdl_t *handle,
108
                                      ra_dataFormat_t format,
109
                                      unsigned char *message,
110
                                      ra_uint_t length);
111
112
#ifdef __cplusplus
113
}
114
#endif
115
116
#endif
(-)src-native-new/src/agents/perfmon/WinBuild/PerfmonAgent.mak (+213 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on PerfmonAgent.dsp
2
!IF "$(CFG)" == ""
3
CFG=PerfmonAgent - Win32 Release
4
!MESSAGE No configuration specified. Defaulting to PerfmonAgent - Win32 Release.
5
!ENDIF 
6
7
!IF "$(CFG)" != "PerfmonAgent - Win32 Release" && "$(CFG)" != "PerfmonAgent - Win32 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "PerfmonAgent.mak" CFG="PerfmonAgent - Win32 Release"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "PerfmonAgent - Win32 Release" (based on "Win32 (x86) Console Application")
17
!MESSAGE "PerfmonAgent - Win32 Debug" (based on "Win32 (x86) Console Application")
18
!MESSAGE 
19
!ERROR An invalid configuration is specified.
20
!ENDIF 
21
22
!IF "$(OS)" == "Windows_NT"
23
NULL=
24
!ELSE 
25
NULL=nul
26
!ENDIF 
27
28
!IF  "$(CFG)" == "PerfmonAgent - Win32 Release"
29
30
OUTDIR=.\bin
31
INTDIR=.\Release
32
# Begin Custom Macros
33
OutDir=.\bin
34
# End Custom Macros
35
36
ALL : "$(OUTDIR)\PerfmonAgent.exe"
37
38
39
CLEAN :
40
	-@erase "$(INTDIR)\PerfmonAgent.obj"
41
	-@erase "$(INTDIR)\vc60.idb"
42
	-@erase "$(INTDIR)\version.res"
43
	-@erase "$(OUTDIR)\PerfmonAgent.exe"
44
45
"$(OUTDIR)" :
46
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
47
48
"$(INTDIR)" :
49
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
50
51
CPP=cl.exe
52
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "../resutils" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\PerfmonAgent.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
53
54
.c{$(INTDIR)}.obj::
55
   $(CPP) @<<
56
   $(CPP_PROJ) $< 
57
<<
58
59
.cpp{$(INTDIR)}.obj::
60
   $(CPP) @<<
61
   $(CPP_PROJ) $< 
62
<<
63
64
.cxx{$(INTDIR)}.obj::
65
   $(CPP) @<<
66
   $(CPP_PROJ) $< 
67
<<
68
69
.c{$(INTDIR)}.sbr::
70
   $(CPP) @<<
71
   $(CPP_PROJ) $< 
72
<<
73
74
.cpp{$(INTDIR)}.sbr::
75
   $(CPP) @<<
76
   $(CPP_PROJ) $< 
77
<<
78
79
.cxx{$(INTDIR)}.sbr::
80
   $(CPP) @<<
81
   $(CPP_PROJ) $< 
82
<<
83
84
RSC=rc.exe
85
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
86
BSC32=bscmake.exe
87
BSC32_FLAGS=/nologo /o"$(OUTDIR)\PerfmonAgent.bsc" 
88
BSC32_SBRS= \
89
	
90
LINK32=link.exe
91
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\PerfmonAgent.pdb" /machine:I386 /out:"$(OUTDIR)\PerfmonAgent.exe" /libpath:"bin" 
92
LINK32_OBJS= \
93
	"$(INTDIR)\PerfmonAgent.obj" \
94
	"$(INTDIR)\version.res"
95
96
"$(OUTDIR)\PerfmonAgent.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
97
    $(LINK32) @<<
98
  $(LINK32_FLAGS) $(LINK32_OBJS)
99
<<
100
101
!ELSEIF  "$(CFG)" == "PerfmonAgent - Win32 Debug"
102
103
OUTDIR=.\bin
104
INTDIR=.\Debug
105
# Begin Custom Macros
106
OutDir=.\bin
107
# End Custom Macros
108
109
ALL : "$(OUTDIR)\PerfmonAgent.exe"
110
111
112
CLEAN :
113
	-@erase "$(INTDIR)\PerfmonAgent.obj"
114
	-@erase "$(INTDIR)\vc60.idb"
115
	-@erase "$(INTDIR)\version.res"
116
	-@erase "$(OUTDIR)\PerfmonAgent.exe"
117
118
"$(OUTDIR)" :
119
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
120
121
"$(INTDIR)" :
122
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
123
124
CPP=cl.exe
125
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "../resutils" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\PerfmonAgent.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
126
127
.c{$(INTDIR)}.obj::
128
   $(CPP) @<<
129
   $(CPP_PROJ) $< 
130
<<
131
132
.cpp{$(INTDIR)}.obj::
133
   $(CPP) @<<
134
   $(CPP_PROJ) $< 
135
<<
136
137
.cxx{$(INTDIR)}.obj::
138
   $(CPP) @<<
139
   $(CPP_PROJ) $< 
140
<<
141
142
.c{$(INTDIR)}.sbr::
143
   $(CPP) @<<
144
   $(CPP_PROJ) $< 
145
<<
146
147
.cpp{$(INTDIR)}.sbr::
148
   $(CPP) @<<
149
   $(CPP_PROJ) $< 
150
<<
151
152
.cxx{$(INTDIR)}.sbr::
153
   $(CPP) @<<
154
   $(CPP_PROJ) $< 
155
<<
156
157
RSC=rc.exe
158
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
159
BSC32=bscmake.exe
160
BSC32_FLAGS=/nologo /o"$(OUTDIR)\PerfmonAgent.bsc" 
161
BSC32_SBRS= \
162
	
163
LINK32=link.exe
164
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib resutils.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\PerfmonAgent.pdb" /machine:I386 /out:"$(OUTDIR)\PerfmonAgent.exe" /libpath:"bin" 
165
LINK32_OBJS= \
166
	"$(INTDIR)\PerfmonAgent.obj" \
167
	"$(INTDIR)\version.res"
168
169
"$(OUTDIR)\PerfmonAgent.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
170
    $(LINK32) @<<
171
  $(LINK32_FLAGS) $(LINK32_OBJS)
172
<<
173
174
!ENDIF 
175
176
177
!IF "$(NO_EXTERNAL_DEPS)" != "1"
178
!IF EXISTS("PerfmonAgent.dep")
179
!INCLUDE "PerfmonAgent.dep"
180
!ELSE 
181
!MESSAGE Warning: cannot find "PerfmonAgent.dep"
182
!ENDIF 
183
!ENDIF 
184
185
186
!IF "$(CFG)" == "PerfmonAgent - Win32 Release" || "$(CFG)" == "PerfmonAgent - Win32 Debug"
187
SOURCE=..\PerfmonAgent\PerfmonAgent.cpp
188
189
"$(INTDIR)\PerfmonAgent.obj" : $(SOURCE) "$(INTDIR)"
190
	$(CPP) $(CPP_PROJ) $(SOURCE)
191
192
193
SOURCE=..\PerfmonAgent\version.rc
194
195
!IF  "$(CFG)" == "PerfmonAgent - Win32 Release"
196
197
198
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
199
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "\perfmon\PerfmonAgent" /d "NDEBUG" $(SOURCE)
200
201
202
!ELSEIF  "$(CFG)" == "PerfmonAgent - Win32 Debug"
203
204
205
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
206
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "\perfmon\PerfmonAgent" /d "NDEBUG" $(SOURCE)
207
208
209
!ENDIF 
210
211
212
!ENDIF 
213
(-)src-native-new/src/agents/native/java_profiler/JvmpiWriter.c (+4903 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: JvmpiWriter.c,v 1.31 2007/01/22 19:14:31 nmehrega Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include <ctype.h>
14
#include <stddef.h>
15
#include <time.h>
16
#include <sys/types.h>
17
#include <jvmpi.h>
18
#include <stdlib.h>
19
#include <stdio.h>
20
#include <assert.h>
21
#include <signal.h>
22
#include <jni.h>
23
#ifndef __OS400__
24
#include <sys/timeb.h>
25
#endif
26
#include <sys/types.h>
27
#include <time.h>
28
#include "eventmask.h"
29
#include "hash.h"
30
#include "JvmpiWriter.h"
31
#include "piAgentExtension.h"
32
#include "options.h"
33
#include "filters.h"
34
#include "RABindings.h"
35
#include "JVMPIException.h"
36
#ifndef __OS400__
37
#endif
38
#include "RASocket.h"
39
#include "print.h"
40
#include "performance.h"
41
#include "strings.h"
42
#include "utility.h"
43
44
#include "StatelessHeapSnapshotManager_C.h"
45
46
#if defined __cplusplus && defined _HPUX
47
 #define ENV(e) e
48
 #define JOBJECT jclass
49
#else
50
 #define ENV(e) (*e)
51
 #define JOBJECT jobject
52
#endif
53
54
#ifdef _SHOOTDEBUG
55
 #include "agentDebug.h"
56
#endif
57
58
/*
59
 * A note about agent extensions:
60
 *
61
 * Allan Pratt of the Rational software division of IBM added a feature
62
 * to this agent on March 31, 2004: a simple extensibility system
63
 * that lets people write agent extensions. Instructions for building an agent
64
 * extension can be found in piAgentExtension.h.
65
 *
66
 * The system is quite limited: it doesn't solve any of the hard problems
67
 * related to sending JVMPI events to multiple agents. It is barely adequate
68
 * for an agent extension that wants JVM_INIT_DONE and CLASS_LOAD_HOOK,
69
 * which is all we need it for right now.
70
 *
71
 * Every code segment related to this extension system has the
72
 * words "agent extension" in a comment nearby.
73
 */
74
75
/**
76
  * MACROS
77
  *
78
  */
79
/* following two undefs were added to avoid conflict from new java.h defs ... 135623 */
80
#undef ATTACH_THREAD
81
#undef DETACH_THREAD
82
83
#ifdef _WIN32
84
 #define MODULE_REFERENCE HMODULE
85
 #define DLL_REFERENCE HINSTANCE
86
 #define DLL_NAME "jvm"
87
 #define RESOLVE_MODULE(name) GetModuleHandle(name)
88
 #define LOAD_LIBRARY(name) LoadLibrary(name)
89
 #define RESOLVE_ENTRY_POINT(mod, entry) GetProcAddress(mod, entry)
90
 #define ATTACH_THREAD(env) (*_jvmpiAgent_jvm)->AttachCurrentThread(_jvmpiAgent_jvm,  (void**)&env, NULL)
91
 #define DETACH_THREAD() (*_jvmpiAgent_jvm)->DetachCurrentThread(_jvmpiAgent_jvm)
92
 #ifndef CDECL
93
   #define CDECL __cdecl
94
 #endif
95
#elif MVS
96
 #include <dll.h>
97
 #define MODULE_REFERENCE dllhandle *
98
 #define DLL_REFERENCE dllhandle *
99
 #define DLL_NAME "libjava.so"
100
 #define RESOLVE_MODULE(name) dllload(name)
101
 #define LOAD_LIBRARY(name) dllload(name)
102
 #define RESOLVE_ENTRY_POINT(mod, entry) dllqueryfn(mod, entry)
103
 #define ATTACH_THREAD(env) (*_jvmpiAgent_jvm)->AttachCurrentThread(_jvmpiAgent_jvm,  (void**)&env, NULL)
104
 #define DETACH_THREAD() (*_jvmpiAgent_jvm)->DetachCurrentThread(_jvmpiAgent_jvm)
105
 #ifndef CDECL
106
  #define CDECL
107
 #endif
108
#elif _HPUX
109
 #include <dlfcn.h>
110
 #define MODULE_REFERENCE void *
111
 #define DLL_REFERENCE void *
112
 #define DLL_NAME "libjvm.sl"
113
 #define RESOLVE_MODULE(name) dlopen(name, RTLD_LAZY)
114
 #define LOAD_LIBRARY(name) dlopen(name, RTLD_LAZY)
115
 #define RESOLVE_ENTRY_POINT(mod, entry) dlsym(mod, entry)
116
 #define ATTACH_THREAD(env) (_jvmpiAgent_jvm)->AttachCurrentThread((void**)&env, NULL)
117
 #define DETACH_THREAD() (_jvmpiAgent_jvm)->DetachCurrentThread()
118
 #ifndef CDECL
119
  #define CDECL
120
 #endif
121
#elif __OS400__
122
 #define MODULE_REFERENCE void *
123
 #define DLL_REFERENCE void *
124
 #define DLL_NAME "libjvm"
125
 #define RESOLVE_MODULE(name) loadServicePgm(name)
126
 #define LOAD_LIBRARY(name) loadServicePgm(name)
127
 #define RESOLVE_ENTRY_POINT(mod, entry) findServicePgmEntry(mod, entry)
128
 #define ATTACH_THREAD(env) (*_jvmpiAgent_jvm)->AttachCurrentThread(_jvmpiAgent_jvm,  (void**)&env, NULL)
129
 #define DETACH_THREAD() (*_jvmpiAgent_jvm)->DetachCurrentThread(_jvmpiAgent_jvm)
130
 #ifndef CDECL
131
  #define CDECL
132
 #endif
133
#else
134
 #include <dlfcn.h>
135
 #define MODULE_REFERENCE void *
136
 #define DLL_REFERENCE void *
137
 #define DLL_NAME "libjvm.so"
138
 #define RESOLVE_MODULE(name) dlopen(name, RTLD_LAZY)
139
 #define LOAD_LIBRARY(name) dlopen(name, RTLD_LAZY)
140
 #define RESOLVE_ENTRY_POINT(mod, entry) dlsym(mod, entry)
141
 #define ATTACH_THREAD(env) (*_jvmpiAgent_jvm)->AttachCurrentThread(_jvmpiAgent_jvm,  (void**)&env, NULL)
142
 #define DETACH_THREAD() (*_jvmpiAgent_jvm)->DetachCurrentThread(_jvmpiAgent_jvm)
143
 #ifndef CDECL
144
  #define CDECL
145
 #endif
146
#endif
147
148
#define IBM_VENDOR_STRING "IBM"
149
#define IBM_VENDOR_STRING_LENGTH 3
150
#define SUN_VENDOR_STRING "Sun"
151
#define SUN_VENDOR_STRING_LENGTH 3
152
/* we only use the first 3 characters in HP's vendor string "Hewlett-Packard Co." */ 
153
#define HP_VENDOR_STRING "Hew"
154
#define HP_VENDOR_STRING_LENGTH 3 
155
156
#define org_eclipse_hyades_collection_profiler_Profiler_PROFILER_EXECUTION_ONLY 1L
157
#define org_eclipse_hyades_collection_profiler_Profiler_PROFILER_HEAP_ONLY 2L
158
#define org_eclipse_hyades_collection_profiler_Profiler_PROFILER_EXECUTION_AND_HEAP 3L
159
#define org_eclipse_hyades_collection_profiler_Profiler_PROFILER_OPTIMIZED_HEAP_ONLY 4L
160
#define org_eclipse_hyades_collection_profiler_Profiler_EMIT_XML_SUCCESS 0L
161
#define org_eclipse_hyades_collection_profiler_Profiler_EMIT_XML_SUSPENDED_IO 1L
162
#define org_eclipse_hyades_collection_profiler_Profiler_EMIT_XML_FAIL 2L
163
164
/**
165
  * TYPEDEFS
166
  */
167
168
/* TraceON - turn on tracing
169
   TracePause - Pause tracing (keeping in mind that hash tables are not scrubbed)
170
   TraceOFF - Turn off tracing completely 
171
*/ 
172
enum TraceToggleType {TraceON,TracePause,TraceOFF};
173
typedef enum TraceToggleType TraceToggle;   
174
175
/* This is the signature declaration for all the event handlers from JVMPI. With a common
176
   signature we can load the functions into an array and random access the proper
177
   handler based upon the event type.
178
*/
179
typedef void (*ProcessEventFunction)(JVMPI_Event *event, ThreadPrivateStorage *tps, BOOL isRequested, timestamp_t timestamp, timestamp_t cpu_timestamp);
180
181
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
182
void *prevMthdTps=NULL;
183
int  meCount=0;  /* methodEntryEvents count */
184
int  mxCount=0;  /* methodExitEvents count*/
185
186
void dumpMethodEventCounts(void) {/* dump MethodEvent counts */
187
	if (meCount>0 || mxCount>0) {
188
		printf("Method entries/exits on tps %8x = %5d/%5d\n", (void *)prevMthdTps, meCount, mxCount); fflush(stdout); 	
189
	}	
190
	meCount=mxCount=0;
191
}	
192
#endif
193
194
/* For pre-aggregation */
195
/* The threadsRoot list is a list of all "live" threads.
196
   I believe you could reach all the same elements using the thread hash table.
197
   This is an optimization opportunity.
198
 */
199
struct ThreadListElement {
200
	ThreadPrivateStorage * data;
201
	struct ThreadListElement * next;
202
	struct ThreadListElement * prev;
203
};
204
205
struct ThreadListElement * threadsRoot = 0;
206
207
/*
208
 * Locks for pre-aggregation logic.
209
 *
210
 * threadListLock is used when you are reading or writing the list starting at threadsRoot.
211
 *
212
 * stackFrameStructureLock is used when you are changing (but not just reading) 
213
 * the "next" and "child" pointers of any StackFrame object. This might seem unnecessary
214
 * since each thread has its own rooted StackFrame structure, but the killer is dumping:
215
 * during a dump, one thread reads all StackFrame structures, and having other threads
216
 * running and updating their "next" pointers could crash the dump.
217
 *
218
 * Technically, this lock could also be acquired when you update the field values
219
 * in any StackFrame, since the dump could see inconsistent data if it visits a node
220
 * at the same time you're updating it. But I don't want to do that - it's too expensive
221
 * to acquire this on every method entry and exit event.
222
 *
223
 * There is a no-lock alternative to stackFrameStructureLock: in the dumping logic,
224
 * use JNI to suspend all other Java threads. I think this will suspend them in Java,
225
 * not in the middle of a JVMPI event handler, so once they're all suspended the
226
 * thread doing the dumping will know it's safe. If you implement this, you can remove
227
 * all references to stackFrameStructureLock.
228
 *
229
 * Here's another no-lock trick: use the garbage collector instead. [Credit to Victor Havin 
230
 * for this one.] If you want to do a dump, you use JNI to cause a GC. In the handler for 
231
 * the "GC Started" notification from JVMPI, that's where you actually do the dump. 
232
 * When you're in that handler, you know that all other Java threads are suspended in 
233
 * safe states - definitely not executing handlers for other JVMPI events.
234
 */
235
236
static ra_critsec_t * stackFrameStructureLock = 0;
237
static ra_critsec_t * threadListLock = 0;
238
239
/* For pre-aggregation */
240
void getStackFrameStructureLock() {
241
	if (stackFrameStructureLock == 0 ) {
242
		stackFrameStructureLock = (ra_critsec_t *)jvmpiAgent_Calloc(sizeof(ra_critsec_t));
243
		ra_mutexCreate(stackFrameStructureLock);
244
	}
245
246
	ra_mutexEnter(stackFrameStructureLock);
247
}
248
249
/* For pre-aggregation */
250
void releaseStackFrameStructureLock() {
251
	if( stackFrameStructureLock == 0 ) {
252
		fprintf(stdout, "Error!! stackFrameStructureLock is NULL " );
253
		fflush(stdout);
254
	}
255
	ra_mutexExit(stackFrameStructureLock);
256
}
257
258
259
/* For pre-aggregation */
260
void getThreadListLock() {
261
	if (threadListLock == 0 ) {
262
		threadListLock = (ra_critsec_t *)jvmpiAgent_Calloc(sizeof(ra_critsec_t));
263
		ra_mutexCreate(threadListLock);
264
	}
265
266
	ra_mutexEnter(threadListLock);
267
}
268
269
/* For pre-aggregation */
270
void releaseThreadListLock() {
271
	if( threadListLock == 0 ) {
272
		fprintf(stdout, "Error!! threadListLock is NULL " );
273
		fflush(stdout);
274
	}
275
	ra_mutexExit(threadListLock);
276
}
277
278
static BOOL                   _traceResourcesGone = FALSE; /* Trace Hash Tables were cleaned up * pre-agg: 134635 */
279
280
extern int _requestClassObj; /* used to flag when a object_alloc is being performed on a class object */ 
281
282
/**
283
  * File Scope Variable Definitions
284
  */
285
static Jobject2jobjectID      _jobject2jobjectID = 0;   /* Function pointer to JVM interface function that converts JNI object handles to
286
																	  JVMPI object identifiers */
287
#ifdef __OS400__
288
#pragma convert(819)
289
#endif
290
static char	                  _heapDefName[8]	= "default";
291
#ifdef __OS400__
292
#pragma convert(0)
293
#endif 
294
295
296
static BOOL                   _jvmShutDown = FALSE;              /* JVM is in shut down mode*/
297
static BOOL                   _jvmpiAgent_isJVMInitDone=FALSE;   /* JVM has finished initialization */
298
static BOOL					  _jvmpiAgent_isListenerUnblocked=FALSE;	 /* Has ra_startListener returned? */
299
static BOOL                   _jvmpiAgent_isMonitored=FALSE;     /* Are we currently monitored?  */
300
static BOOL                   _jvmpiAgent_isSuspended=FALSE;     /* Are we currently suspended? */
301
static BOOL                   _jvmpiAgent_burstTimeoutSet=FALSE; /* Is our timout value set? */
302
303
/* In order to limit tracing to a single thread these variables are used */
304
static JNIEnv               *_jvmpiAgent_limitingThread=NULL;
305
static BOOL                  _jvmpiAgent_singleThreaded=FALSE;
306
307
static unsigned int          _invocationCountRemaining=0;        /* Used in burst tracing to count invocations */
308
static timestamp_t           _burstTimeout;
309
static BOOL                  _triggerSqueezed=FALSE;               /* Used in trigger tracing to indicate we have started */
310
311
static BOOL                  _stackSamplerActive=FALSE;          /* Stack sampler shutoff switch */
312
313
static BOOL                  _xmlHeadersPrinted=FALSE;
314
315
/* Piyush Agarwal */
316
static BOOL					 _analyseOptHeap = FALSE ; /* To determine if the analyse
317
																 message came from the RAC */
318
static int                   _optHeapError = 0 ;      /*58049 Handle Error if OptHeap files
319
													          cannot be written */
320
static int					 _unknownClassSuffix = 1;
321
static char					 _classNameBuffer[64]; /* "unknown" + "int" */
322
													          
323
/* Giri: <Defect 64462> */
324
static BOOL					_optHeapSetupDone = FALSE ; /* For tracking status of optHeap setup */
325
/*Bug 82214*/
326
static int optHeapContextId = -1 ;
327
													          
328
/*Bug 59544 SetConfig changes for opt heap dump location*/
329
/* Bug 64476  */
330
#ifdef MVS
331
#pragma convlit(suspend)
332
#endif
333
static char                    _tempDirOptionName[21] = "LOCAL_AGENT_TEMP_DIR" ;  
334
#ifdef MVS
335
#pragma convlit(resume)
336
#endif
337
338
/* Array of function pointers to the JVMPI event handling functions */
339
static ProcessEventFunction _processEventFunction[JVMPI_MAX_EVENT_TYPE_VAL + 1]; /* The defect number is 174948. */
340
341
/* Array of function pointers for our agent extension; the signature is slightly different */
342
static AgentExtensionEventHandler agent_extension_handlers[JVMPI_MAX_EVENT_TYPE_VAL + 1];
343
344
/* Pointer to handler function for the agent extension to handle RAC commands. */
345
/* Remains null unless an extension extension utilizes it. */
346
static void (*agent_extension_command_handler)(ra_command_t *command);
347
348
/**
349
  * FUNCTION PROTOTYPES
350
  */
351
static int enableJvmpiEvent(jint event_type,
352
                            ProcessEventFunction eventHandler);
353
354
static void processObjAllocEvent(JVMPI_Event *event,
355
								 ThreadPrivateStorage *tps,
356
                                 BOOL isRequested,
357
								 timestamp_t timestamp, 
358
								 timestamp_t cpu_timestamp);
359
360
static void processGcStartEvent(JVMPI_Event *event,
361
								ThreadPrivateStorage *tps,
362
                                BOOL isRequested,
363
								timestamp_t timestamp, 
364
								 timestamp_t cpu_timestamp);
365
366
static void processGcFinishEvent(JVMPI_Event *event,
367
								 ThreadPrivateStorage *tps,
368
                                 BOOL isRequested,
369
								 timestamp_t timestamp, 
370
								 timestamp_t cpu_timestamp);
371
372
static void processCountingMethodEntryEvent(JVMPI_Event *event, 
373
											ThreadLocalStorage *tps, 
374
											BOOL isRequested, 
375
											timestamp_t timestamp,
376
											timestamp_t cpu_timestamp); 
377
378
static void toggleActiveJvmpiEvents(TraceToggle toggle);
379
380
static void cleanUpAllTraceResources();
381
382
static void loadStack(ThreadPrivateStorage *tps);
383
384
static void startTracing(BOOL standalone);
385
386
static void suspendTracing(TraceToggle toggle);
387
388
static void resumeTracing();
389
390
static void stopTracing();
391
392
static void jvmpiAgent_PrintStartingXMLFragments();
393
394
static void setNowTimes(ThreadLocalStorage * tps, timestamp_t * nowTime_P, timestamp_t * nowCpuTime_P);
395
396
static void recordAgMethodEntry(ThreadLocalStorage * tps, StackEntry * stackEntry, StackEntry * caller);
397
398
/* Piyush Agarwal  */
399
static void sendHeapDumpInformation(char *filename) ;
400
static void sendHeapDumpEndMessage(RA_AGENT_HANDLE handle,ra_uint_t contextId,char* filename) ;
401
static void processRACDataDumpRequest(BOOL finalheap,ra_uint_t contextId) ;
402
/* Added Call Back Message */
403
OptHeapCallBack  _jvmpiAgent_optHeapCallBack = { sendHeapDumpInformation };
404
405
/* functions for agent extensions to call to enable events and command listening */
406
static void agentExtensionSetEventHandler(jint event_type,
407
									AgentExtensionEventHandler handler);
408
static void agentExtensionSetCommandHandler(void (*handler)(ra_command_t *command));
409
410
411
static void sendOptHeapErrorMessage(RA_AGENT_HANDLE handle,ra_uint_t contextId) ; /* Piyush 58049 */
412
413
/* Giri: Defect 64462 For performing opt heap related setup */
414
static void jvmpiAgent_DoOptHeapSetup();
415
416
/**
417
  * GLOBALS
418
  */
419
jclass                        _jvmpiAgent_JVMPIException = 0;      /* JNI hook to JVMPIException class */
420
jmethodID                     _jvmpiAgent_setExceptionTracing = 0; /* JNI hook to JVMPIException.setExceptionTracing method */
421
JavaVM *                      _jvmpiAgent_jvm = 0;                 /* JVM reference (established in JVM_OnLoad) */
422
JVMPI_Interface *             _jvmpiAgent_jvmpiInterface = 0;      /* JVMPI Interface pointer (established in JVM_OnLoad */
423
Lock_t                        _jvmpiAgent_synchLock;
424
char *                        _jvmpiAgent_trace_id;
425
SegmentedValue_t              _jvmpiAgent_collation;
426
GenerationInfo_t              _heapDumpInfo;						/* GENERATION Index for Object reference*/
427
RA_AGENT_HANDLE               _jvmpiAgent_bindingStorage;
428
char                          _setPathDelimiter = 0;
429
jobjectID					  _resolvedClassId = 0;					/* Used to store the class id for the associated class of an object being dumped */
430
enum JavaVendor				  _javaVendor = VendorOther; 
431
enum JavaVersion			  _javaVersion = VersionOther; 
432
433
434
/** ANALYSE_HEAP  **************************************************************
435
  * This is the function that must be called to request a heap dump.
436
  *
437
  */
438
jint analyseHeap(jint type) {
439
    jint result;
440
	JVMPI_HeapDumpArg arg;
441
442
443
	/* RKD:  When we are stack sampling or we have been told to ignore heap information
444
	         we don't want to be processing heap dump requests
445
	 */
446
	if(_jvmpiAgent_Options.mode==TraceModeStackSampling  || !jvmpiAgent_isTracingHeap()) {
447
		return -1;
448
	}
449
450
	/* If we get a heap dump level 0 we are marking the heap and we
451
	   mark the generation to be zero.
452
	   RKD:  Should we scrub the table here?
453
	*/
454
	if(type==JVMPI_DUMP_LEVEL_0) {
455
		_heapDumpInfo.index = 0;
456
	}
457
	/* Bug Number 71068*/
458
	/*else {
459
		_heapDumpInfo.index++;
460
461
	}*/
462
463
	/* To make sure that analyseheap is being called from TraceOptHeap methods only */
464
	if ( _jvmpiAgent_Options.mode == TraceOptimizedHeap && _analyseOptHeap == FALSE ) {
465
		/* Bug Number 71043 required for AS400 */
466
		if ( type == JVMPI_DUMP_LEVEL_0 ) 
467
			jvmpiAgent_getCurrentTime(&_heapDumpInfo.lastGenerationTime);
468
		return (jint)0 ;
469
	}
470
471
	/* Bug Number 71068*/
472
	if(type != JVMPI_DUMP_LEVEL_0) {
473
		_heapDumpInfo.index++;
474
	}
475
476
	arg.heap_dump_level=type;
477
478
	/* Because this can be invoked via JNI we need to check to
479
	   ensure we have the interface.  Someone may invoke the
480
	   dump but JVMPI may not be enabled.
481
	*/
482
	
483
	if(_jvmpiAgent_jvmpiInterface) {
484
		result = REQUEST_EVENT(JVMPI_EVENT_HEAP_DUMP, &arg);
485
	}
486
487
	/* Save the time we finished the dump at */
488
	jvmpiAgent_getCurrentTime(&_heapDumpInfo.lastGenerationTime);
489
490
	return result;
491
}
492
493
494
jint runGC() {
495
		jint result;
496
		JVMPI_HeapDumpArg arg;
497
		ThreadPrivateStorage *tps=jvmpiAgent_getThreadLocalStorage(0);	
498
		tps->scrubbingHeap=1;
499
		
500
		/* Scrub the heap */
501
		arg.heap_dump_level=JVMPI_DUMP_LEVEL_0;
502
		if(_jvmpiAgent_jvmpiInterface) {
503
			result = REQUEST_EVENT(JVMPI_EVENT_HEAP_DUMP, &arg);
504
		}
505
506
		tps->scrubbingHeap=0;
507
		return result;
508
}
509
510
511
/* bugzilla 71388 start - JNI methods need to be enclosed in a conditional 'extern "C"' declaration */ 
512
#if defined __cplusplus
513
extern "C" {
514
#endif
515
516
517
/*
518
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
519
 * Method:    initialize0
520
 * Signature: ()V
521
 */
522
JNIEXPORT jint JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_initialize0(JNIEnv *env,
523
                                                                                      JOBJECT obj) {
524
525
	/* We just need to check if we are running in application mode */
526
	if(_jvmpiAgent_jvm && _jvmpiAgent_Options.application) {
527
		return (jint)0;
528
	}
529
	else {
530
		return (jint)-1;
531
	}
532
}
533
534
																					  /*
535
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
536
 * Method:    setMode0
537
 * Signature: (I)V
538
 */
539
JNIEXPORT void JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_setMode0
540
(JNIEnv *env, jobject obj, jint mode) {
541
542
	/* call to OPTIMIZED HEAP DUMP CODE for method setMode0() goes here */
543
}
544
545
/*
546
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
547
 * Method:    startProfiling0
548
 * Signature: (ZZ)I
549
 */
550
JNIEXPORT jint JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_startProfiling0(JNIEnv *env,
551
                                                                                          JOBJECT obj,
552
                                                                                          jboolean currentThread,
553
																						  jint boundaryDepth) {
554
555
	if(_jvmpiAgent_jvm) {
556
		if(currentThread) {
557
			_jvmpiAgent_singleThreaded=TRUE;
558
			_jvmpiAgent_limitingThread=env;
559
		}
560
		else {
561
			_jvmpiAgent_singleThreaded=FALSE;
562
		}
563
564
565
		/* If we have a boundary depth we are tracing in boundary and contiguous mode.  Otherwise we
566
		   need to reset the stack info back to the orignal state in case this is a subsequent call
567
		   to start profiling.
568
		*/
569
		if(boundaryDepth>0) {
570
			_jvmpiAgent_Options.stackInfo=StackInfoBoundaryAndContiguous;
571
			_jvmpiAgent_Options.boundaryDepth=(unsigned short)boundaryDepth;
572
		}
573
		else {
574
			_jvmpiAgent_Options.stackInfo=StackInfoNormal;
575
			_jvmpiAgent_Options.boundaryDepth=0;
576
		}
577
578
		/* If someone is attached we start tracing now, otherwise we ignore this call */
579
		if(_jvmpiAgent_isMonitored) {
580
			if(_jvmpiAgent_isSuspended) {
581
				resumeTracing();
582
583
			}
584
			else {
585
				startTracing(TRUE);
586
			}
587
588
			/* Squeeze the trigger */
589
			_triggerSqueezed=TRUE;
590
591
			return (jint)0;
592
593
		}
594
	}
595
	return (jint)-1;
596
}
597
598
/*
599
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
600
 * Method:    stopProfiling0
601
 * Signature: ()V
602
 */
603
JNIEXPORT void JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_stopProfiling0(JNIEnv *env,
604
                                                                                         JOBJECT obj) {
605
606
	if(_jvmpiAgent_jvm) {
607
		suspendTracing(TracePause);
608
		_jvmpiAgent_limitingThread=NULL;
609
	}
610
}
611
612
/*
613
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
614
 * Method:    markHeap0
615
 * Signature: ()V
616
 */
617
JNIEXPORT void JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_markHeap0(JNIEnv *env,
618
                                                                                    JOBJECT obj) {
619
	if(_jvmpiAgent_jvm) {
620
		analyseHeap(JVMPI_DUMP_LEVEL_0);
621
	}
622
}
623
624
/*
625
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
626
 * Method:    analyzeHeap0
627
 * Signature: (Ljava/lang/String;)V
628
 */
629
JNIEXPORT void JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_analyzeHeap0(JNIEnv *env,
630
                                                                                       JOBJECT obj,
631
                                                                                       jstring name) {
632
	if(_jvmpiAgent_jvm) {
633
		analyseHeap(JVMPI_DUMP_LEVEL_1);
634
	}
635
}
636
637
/*
638
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
639
 * Method:    optimizedHeapDump0
640
 * Signature: ()Ljava/lang/String;
641
 */
642
JNIEXPORT jstring JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_optimizedHeapDump0
643
(JNIEnv *env, jobject obj) {
644
	
645
	/* call to OPTIMIZED HEAP DUMP CODE for method optimizedHeapDump0() goes here */
646
	processRACDataDumpRequest(FALSE,0) ;
647
	return (jstring)0;
648
649
}
650
651
/*
652
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
653
 * Method:    stopOptimizedHeapInfoSnapshot0
654
 * Signature: ()Ljava/lang/String;
655
 */
656
JNIEXPORT jstring JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_stopOptimizedHeapInfoSnapshot0
657
(JNIEnv *env, jobject obj) {
658
659
660
	/* call to OPTIMIZED HEAP DUMP CODE for method stopOptimizedHeapInfoSnapshot0()
661
	   goes here */
662
		processRACDataDumpRequest(TRUE,0) ;
663
        return (jstring)0; 	
664
665
}
666
667
668
/*
669
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
670
 * Method:    disableGC0
671
 * Signature: ()V
672
 */
673
JNIEXPORT void JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_disableGC0
674
(JNIEnv *env, jobject obj) {
675
676
	if (_jvmpiAgent_jvmpiInterface) {
677
		_jvmpiAgent_jvmpiInterface->DisableGC();
678
	}
679
	
680
681
}
682
683
/*
684
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
685
 * Method:    enableGC0
686
 * Signature: ()V
687
 */
688
JNIEXPORT void JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_enableGC0
689
(JNIEnv *env, jobject obj) {
690
691
	if (_jvmpiAgent_jvmpiInterface) {
692
		_jvmpiAgent_jvmpiInterface->EnableGC();
693
	}
694
695
}
696
697
698
/*
699
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
700
 * Method:    runGC0
701
 * Signature: ()V
702
 */
703
JNIEXPORT void JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_runGC0(JNIEnv *env,
704
																				 JOBJECT obj) {
705
	if(_jvmpiAgent_jvm) {
706
		runGC();
707
	}
708
}
709
																				
710
711
/*
712
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
713
 * Method:    release0
714
 * Signature: ()V
715
 */
716
JNIEXPORT void JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_release0
717
(JNIEnv *env, jobject obj) {
718
719
	/* RJD: currently the following is the body of the cleanupAndExit method. Other
720
	  cleanup may be necessary -- need to discuss */
721
722
	ThreadLocalStorage *tps=jvmpiAgent_getThreadLocalStorage(0);
723
724
	/* If the application is logging to a file */
725
	if (_jvmpiAgent_outFile) {
726
		jvmpiAgent_printStandaloneTraceTagClose(tps);
727
		jvmpiAgent_cleanupStandaloneIO();
728
	} else  if (_jvmpiAgent_Options.application) {  /*94955*/
729
		jvmpiAgent_printStandaloneTraceTagClose(tps);		 
730
	} 	
731
732
	/* If this application is being controlled/moitored remotely */
733
	if (!_jvmpiAgent_Options.standalone) {
734
735
		/* Wait until all the data is sent over the wire if there is a data connection */
736
		if(!_jvmpiAgent_suspendIO)  {
737
			if(_jvmpiAgent_Options.targetHdl.dtarget==RA_SOCKET && _jvmpiAgent_Options.targetHdl.dtargetHdl.socketFD>-1) {
738
				ra_closeSocket(_jvmpiAgent_Options.targetHdl.dtargetHdl.socketFD);
739
			}
740
			else if (_jvmpiAgent_Options.targetHdl.dtarget == RA_SHAREDMEMORY) {
741
				ra_stopFlushingShm(&_jvmpiAgent_Options.targetHdl.dtargetHdl.shmHdl); /* 175248 */
742
			}
743
744
			_jvmpiAgent_suspendIO=1;
745
		}
746
		ra_stopListener(_jvmpiAgent_bindingStorage);
747
	}
748
749
	
750
751
}
752
753
/*
754
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
755
 * Method:    emitXMLFragment0
756
 * Signature: ([BII)I
757
 */
758
JNIEXPORT jint JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_emitXMLFragment0
759
(JNIEnv *env, jclass clz, jbyteArray arr, jint offset, jint len) {
760
	char *carr; /* note that jbyte * is a signed char* on most platforms */ 
761
	char *outputBuffer; 
762
#ifdef __OS400__
763
	char *tmp, *tmp2; /* temporary storage used only for AS/400 */ 
764
#endif 
765
	jboolean iscopy;
766
	ThreadLocalStorage *tps; 
767
	iscopy = JNI_FALSE; 
768
769
	if (_jvmpiAgent_suspendIO) {
770
		return org_eclipse_hyades_collection_profiler_Profiler_EMIT_XML_SUSPENDED_IO;
771
	}
772
	
773
	carr = (char *) ENV(env)->GetByteArrayElements(ENVPARM(env) arr,&iscopy);
774
775
	if (carr == NULL) {
776
		/* NULL is returned by GetByteArrayElements only when an OutOfMemoryError occurs */ 
777
		return org_eclipse_hyades_collection_profiler_Profiler_EMIT_XML_FAIL; 
778
	}
779
780
	/* get the thread private storage */ 
781
	tps=jvmpiAgent_getThreadLocalStorage(env);
782
	
783
	if (tps == 0) {
784
		tps = jvmpiAgent_getThreadLocalStorage(0); 
785
	}
786
787
	/* Ensure that the output buffer is large enough. Note, the jvmpiAgent_print
788
	   method adds a '\n', and on zOS a '\0' to the buffer. We take this into account
789
	   when sizing the buffer.  */ 
790
	if (len > (ORIGINAL_MESSAGE_BUFFER_SIZE - 2)) {
791
		outputBuffer = (char *)ra_allocateMessageBlock((unsigned short)len+2);
792
#ifdef __OS400__
793
		/* we need to increase the size of the etoa scratch buffer */ 
794
		tmp = tps->buffer2; /* remember the normal buffer */ 
795
		tps->buffer2 = ra_allocateMessageBlock((unsigned short)len+2); 
796
#endif 
797
		if (!outputBuffer) {
798
			return org_eclipse_hyades_collection_profiler_Profiler_EMIT_XML_FAIL; 
799
		}
800
	}
801
	else {
802
		outputBuffer = tps->buffer; 
803
	}
804
805
#ifdef __OS400__
806
	/* on AS400 we assume the passed in string is in UTF-8. Convert it to EBCDIC before
807
	   putting it into the output buffer.  */ 
808
809
	/* this is ugly, but it's required: the as400_atoe routines require a null terminated string, 
810
	and that the 'from' buffer is not the same as the 'to' buffer */ 
811
	tmp2 = ra_malloc(sizeof(char)*(len+1)); 
812
	if (!tmp2) {
813
		return org_eclipse_hyades_collection_profiler_Profiler_EMIT_XML_FAIL; 
814
	}
815
	memcpy(tmp2,&carr[offset],len); 
816
	tmp2[len] = '\0';
817
	outputBuffer = as400_atoe_tobuffer(tmp2,outputBuffer); 
818
	ra_free(tmp2); 
819
#else
820
	/* copy the XML fragment into the tps->buffer for printing */ 
821
	memcpy(outputBuffer,&carr[offset],len); 
822
#endif
823
824
	jvmpiAgent_print(tps,outputBuffer,(unsigned short) len); 
825
826
	if (tps->buffer != outputBuffer) {
827
		ra_freeMessageBlock((unsigned char *)outputBuffer); 
828
#ifdef __OS400__
829
		ra_freeMessageBlock((unsigned char *)tps->buffer2); 
830
		tps->buffer2 = tmp; /* restore the normal buffer */ 
831
#endif 
832
	}
833
834
	ENV(env)->ReleaseByteArrayElements(ENVPARM(env) arr, (signed char *) carr, JNI_ABORT);
835
836
	return org_eclipse_hyades_collection_profiler_Profiler_EMIT_XML_SUCCESS; 
837
838
}
839
840
/*
841
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
842
 * Method:    getCurrentTime0()
843
 * Signature: ()D
844
 */
845
JNIEXPORT jdouble JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_getCurrentTime0
846
(JNIEnv *env, jclass clz) {
847
	timestamp_t timestamp;
848
849
	jvmpiAgent_getCurrentTime(&timestamp);
850
	return ticksToTime2(timestamp, TRUE);
851
}
852
853
/*
854
 * Class:     org_eclipse_hyades_collection_profiler_Profiler
855
 * Method:    getCurrentThreadCpuTime0()
856
 * Signature: ()D
857
 */
858
JNIEXPORT jdouble JNICALL Java_org_eclipse_hyades_collection_profiler_Profiler_getCurrentThreadCpuTime0
859
(JNIEnv *env, jclass clz) {
860
	timestamp_t cpu_timestamp; 
861
862
	cpu_timestamp = jvmpiAgent_getCurrentThreadCPUTime(); 
863
	return ((jdouble)
864
#ifdef WIN32
865
		(__int64)
866
#endif 		
867
		cpu_timestamp)/1000000000; /* nanoseconds but very fat grain, about 10 milliseconds!!! */
868
}
869
870
871
/* bugzilla 71388 end - JNI methods need to be enclosed in a conditional 'extern "C"' declaration */ 
872
#if defined __cplusplus
873
}
874
#endif
875
876
877
878
#ifndef __OS400__
879
/* Resolve to the jobject2jobjectID interface */
880
static jobjectID resolveJobject2jobjectID(jthrowable e, JNIEnv *env)
881
{
882
 static resolved = 0;
883
 if (_jobject2jobjectID)
884
 {
885
  return _jobject2jobjectID(e);
886
 }
887
 else if ( resolved )
888
 {
889
  return 0;
890
 }
891
 else
892
 {
893
  resolved = 1;
894
  /* jobject2jobjectID         IBM JDK 1.2.2	IBM JDK1.3	Sun JDK 1.2.2 Classic	Sun JDK 1.3 Classic	 Sun JDK 1.3 Hotspot
895
     JVM.dll entry point	   not available	yes	        yes	                    yes	                 no
896
     JVMPI interface pointer   not available	yes	        no	                    no	                 yes - but no header
897
  */
898
  /* First attempt to resolve the entry point directly from the JVM dll */
899
  _jobject2jobjectID = (Jobject2jobjectID)RESOLVE_ENTRY_POINT(RESOLVE_MODULE(DLL_NAME), "jobject2jobjectID");
900
901
  if (!_jobject2jobjectID)
902
  {
903
   /* We couldn't find the entry point exported from the JVM dll so now we check the JVM version
904
      to see if it is safe to retreive the entry point from the JVMPI interface structure.  We assume
905
      that any JVM above version 2.1 should support this interface... */
906
#if defined __cplusplus && defined _HPUX
907
   jint version = ENV(env)->GetVersion();
908
#else
909
   jint version = (*env)->GetVersion(env);
910
#endif
911
   unsigned short *p = (unsigned short *)&version;
912
   unsigned short major = *p;
913
   unsigned short minor = *(p+1);
914
   if (major >= 2 && minor >= 1)
915
   {
916
#ifndef _HPUX
917
    _jobject2jobjectID = _jvmpiAgent_jvmpiInterface->jobject2jobjectID;
918
#endif
919
   }
920
  }
921
  return _jobject2jobjectID ? _jobject2jobjectID(e) : 0;
922
 }
923
}
924
#endif /* __OS400__ */
925
926
927
/** GET_THREAD_LOCAL_STORAGE  *************************************************
928
  * This function returns the address of the thread local storage for the
929
  * specified JNIEnv (aka thread).  A special thread local storage structure is
930
  * allocated for static references and is returned when the JNIEnv parameter is
931
  * 0 or if the JVM is in Garbage Collection or Shutdown mode. Garbage Collection
932
  * and Shutdown mode must be handled in this way because some versions of the
933
  * JVM use special threads to do this processing which cause the
934
  * GetThreadLocalStorage interface function to trap.
935
  */
936
ThreadPrivateStorage *jvmpiAgent_getThreadLocalStorage(JNIEnv *env_id) {
937
	HashEntry *hashEntry = jvmpiAgent_FindThreadSymbol(env_id);
938
	if (hashEntry) {
939
		if (!hashEntry->printed && env_id && THREAD_ENTRY(hashEntry)->threadStartEventSeen && _xmlHeadersPrinted) {
940
			jvmpiAgent_printThreadStartElement(env_id, hashEntry);
941
		}
942
		return (ThreadPrivateStorage *)hashEntry->entry;
943
	}
944
	else {
945
		hashEntry = jvmpiAgent_CreateStack(env_id);
946
		return (ThreadPrivateStorage *)hashEntry->entry;
947
	}
948
}
949
950
951
/** SEND_ERROR_MESSAGE  *******************************************************************
952
  */
953
void sendErrorMessage(RA_ERROR_LEVEL severity,
954
							 const char *errorId,
955
							 const char *errorString)
956
{
957
#ifdef MVS
958
	__atoe(errorId);
959
	__atoe(errorString);
960
#endif
961
	if(!_jvmpiAgent_Options.standalone)
962
	{
963
		ra_logErrorMessage(_jvmpiAgent_bindingStorage, severity, errorId, errorString);
964
	}
965
	else
966
	{
967
		/* 60642 standalone mode - write to stderr if warning or worse */
968
		if (severity >= RA_WARNING)
969
		{
970
#ifdef MVS                   
971
#pragma convlit(suspend)
972
#endif
973
			fprintf(stderr, "%s: %s\n", errorId, errorString);
974
#ifdef MVS                   
975
#pragma convlit(resume)
976
#endif
977
			fflush(stderr);
978
		}
979
	}
980
/* we need to undo the conversion on 390 in case this method is called with the same
981
   string more than once */ 
982
#ifdef MVS
983
	__etoa(errorId);
984
	__etoa(errorString);
985
#endif
986
}
987
988
/** CLEANUP_AND_EXIT  **********************************************************
989
  * Flushes the I/O buffers, closes the data channel or file and shuts down the
990
  * RAC connection.
991
  */
992
static void CDECL cleanupAndExit(int sig) {
993
	ThreadLocalStorage *tps=jvmpiAgent_getThreadLocalStorage(0);
994
995
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
996
	printf("cleanupAndExit underway\n"); fflush(stdout);
997
#endif
998
	/* If the application is logging to a file */
999
	if (_jvmpiAgent_outFile) {
1000
		jvmpiAgent_printStandaloneTraceTagClose(tps);
1001
		jvmpiAgent_cleanupStandaloneIO();
1002
	} else  if (_jvmpiAgent_Options.application) {  /*94955*/
1003
		jvmpiAgent_printStandaloneTraceTagClose(tps);		 
1004
	} 	
1005
1006
	/* If this application is being controlled/moitored remotely */
1007
	if (!_jvmpiAgent_Options.standalone) {
1008
1009
		/* Wait until all the data is sent over the wire if there is a data connection */
1010
		if(!_jvmpiAgent_suspendIO)  {
1011
			if(_jvmpiAgent_Options.targetHdl.dtarget==RA_SOCKET && _jvmpiAgent_Options.targetHdl.dtargetHdl.socketFD>-1) {
1012
				ra_closeSocket(_jvmpiAgent_Options.targetHdl.dtargetHdl.socketFD);
1013
			}
1014
			else if (_jvmpiAgent_Options.targetHdl.dtarget == RA_SHAREDMEMORY) {
1015
				ra_stopFlushingShm(&_jvmpiAgent_Options.targetHdl.dtargetHdl.shmHdl); /* 175248 */
1016
			}
1017
1018
			_jvmpiAgent_suspendIO=1;
1019
		}
1020
		ra_stopListener(_jvmpiAgent_bindingStorage);
1021
	}
1022
}
1023
1024
1025
/** OUTPUT_CLASS_DECLARATION  **************************************************
1026
  * Conditionally outputs a classLoad element if it has not already been output.
1027
  */
1028
void jvmpiAgent_outputClassDeclaration(HashEntry *classEntry,
1029
                                       ThreadPrivateStorage *tps) {
1030
	/* RKD:  The testing for printing and the marking of printed elements is
1031
	         not good.  We need to mark the element as printed at the same
1032
			 time as we check to see if it is printed.  This is the only
1033
			 way to ensure we don't have a race condition and an element
1034
			 gets printed.
1035
	*/
1036
	if (!_jvmpiAgent_suspendIO && classEntry != NULL && !classEntry->printed) {
1037
1038
		/* Ensure that the class object and the java.lang.Class have been printed unless we are
1039
		   specifically not tracing heap information or we have been specified to ignore heap information */
1040
		if(CLASS_ENTRY(classEntry)->classObject!=NULL && jvmpiAgent_isTracingHeap()) {
1041
			if(!CLASS_ENTRY(classEntry)->classObject->printed) {
1042
				jvmpiAgent_printObjAllocElement(CLASS_ENTRY(classEntry)->classObject, tps->env, 0);
1043
			}
1044
		}
1045
		/* Have to check whether the class is printed already which is the case for java.lang.Class */
1046
		
1047
		if (!classEntry->printed && CLASS_ENTRY(classEntry)->classId) {   /* 218494 */
1048
			jvmpiAgent_printClass(classEntry, tps);
1049
   	    }
1050
        /* If this is a primative class there is no class object */
1051
        else if(CLASS_ENTRY(classEntry)->arrayClass) {
1052
            jvmpiAgent_printClass(classEntry, tps);
1053
        }
1054
1055
	}
1056
}
1057
1058
1059
1060
/**  OUTPUT_METHOD_DECLARATION  *********************************************************
1061
  *  Conditionally outputs a METHOD element (and any referenced CLASS_LOAD elements)
1062
  *  if it has not already been output.
1063
  *  Preconditions:  In order to avoid redundant testing this method does not test to
1064
  *                  determine if IO is suspended and hense should not be called when
1065
  *                  it is.
1066
  *  methodEntry  - the method you wish to print the declaration for.
1067
  *  buffer       - the buffer to flush the IO to.
1068
  */
1069
void jvmpiAgent_outputMethodDeclaration(HashEntry *methodHashEntry,
1070
                                        ThreadPrivateStorage *tps) {
1071
1072
	/* RKD:  The testing for printing and the marking of printed elements is
1073
	         not good.  We need to mark the element as printed at the same
1074
			 time as we check to see if it is printed.  This is the only
1075
			 way to ensure we don't have a race condition and an element
1076
			 gets printed.
1077
	*/
1078
	if (!methodHashEntry->printed) {
1079
		methodHashEntry->printed=1;
1080
		jvmpiAgent_outputClassDeclaration(METHOD_ENTRY(methodHashEntry)->classHashEntry, tps);
1081
		jvmpiAgent_printMethod(METHOD_ENTRY(methodHashEntry), tps);
1082
	}
1083
}
1084
1085
1086
/*
1087
 This function resolves to the JAVA method JVMPIException.setExceptionTracing if not already done, and then synchronizes the
1088
 state of the traceExceptions option with the Java class.
1089
 The function returns the current state of the traceExceptions option.
1090
*/
1091
static int isTracingExceptions(JNIEnv *env, jclass cls)
1092
{
1093
 if (!_jvmpiAgent_setExceptionTracing)
1094
 {
1095
#if defined __cplusplus && defined _HPUX
1096
  _jvmpiAgent_setExceptionTracing = ENV(env)->GetStaticMethodID(cls, "setExceptionTracing", "(Z)V");
1097
#else
1098
  _jvmpiAgent_setExceptionTracing = (*env)->GetStaticMethodID(env, cls, "setExceptionTracing", "(Z)V");
1099
#endif
1100
  _jvmpiAgent_JVMPIException = cls;
1101
 }
1102
 if (!_jvmpiAgent_Options.traceExceptions && _jvmpiAgent_setExceptionTracing)
1103
 {
1104
#if defined __cplusplus && defined _HPUX
1105
  ENV(env)->CallStaticVoidMethod(_jvmpiAgent_JVMPIException, _jvmpiAgent_setExceptionTracing, (jboolean)0 );
1106
#else
1107
  (*env)->CallStaticVoidMethod(env, _jvmpiAgent_JVMPIException, _jvmpiAgent_setExceptionTracing, (jboolean)0 );
1108
#endif
1109
 }
1110
 return _jvmpiAgent_Options.traceExceptions;
1111
}
1112
1113
1114
#ifndef __OS400__
1115
/** PROCESS_EXCEPTION_EVENT  **************************************************
1116
  */
1117
static void processExceptionEvent(JNIEnv *env, ThreadPrivateStorage *tps, jclass cls, jthrowable e, enum ThrowOrCatch type)
1118
{
1119
1120
 /* RKD:  We shouldn't be testing IO here. */
1121
 if (!_jvmpiAgent_suspendIO && isTracingExceptions(env, cls))
1122
 {
1123
  HashEntry * methodHashEntry = 0;
1124
  methodHashEntry = jvmpiAgent_Peek(tps,2)->methodHashEntry;
1125
  if (methodHashEntry && CLASS_ENTRY(METHOD_ENTRY(methodHashEntry)->classHashEntry)->traceFlag)
1126
  {
1127
   jobjectID objId = resolveJobject2jobjectID(e, env);
1128
   jvmpiAgent_printExceptionElement(env, tps, type, methodHashEntry, objId, e);
1129
  }
1130
 }
1131
}
1132
#endif /* __OS400__ */
1133
1134
/* bugzilla 71388 start - JNI methods need to be enclosed in a conditional 'extern "C"' declaration */ 
1135
#if defined __cplusplus
1136
extern "C" {
1137
#endif
1138
1139
/*
1140
 * Class:     JVMPIException
1141
 * Method:    JVMPICatch
1142
 * Signature: (Ljava/lang/Throwable;)V
1143
 */
1144
JNIEXPORT void JNICALL Java_com_ibm_etools_logging_tracing_agent_Callback_JVMPICatch0(JNIEnv *env, jclass cls, jthrowable e)
1145
{
1146
#ifndef __OS400__
1147
 processExceptionEvent(env, jvmpiAgent_getThreadLocalStorage(env), cls, e, Catch);
1148
#endif /* __OS400__ */
1149
}
1150
1151
1152
/*
1153
 * Class:     JVMPIException
1154
 * Method:    JVMPIThrow
1155
 * Signature: (Ljava/lang/Throwable;)V
1156
 */
1157
JNIEXPORT void JNICALL Java_com_ibm_etools_logging_tracing_agent_Callback_JVMPIThrow0(JNIEnv *env, jclass cls, jthrowable e)
1158
{
1159
#ifndef __OS400__
1160
 processExceptionEvent(env, jvmpiAgent_getThreadLocalStorage(env), cls, e, Throw);
1161
#endif
1162
}
1163
1164
/* bugzilla 71388 end - JNI methods need to be enclosed in a conditional 'extern "C"' declaration */ 
1165
#if defined __cplusplus
1166
}
1167
#endif
1168
1169
/** PROCESS_METHOD_EXIT_EVENT  ************************************************
1170
  *
1171
  */
1172
static void processMethodExitEvent(JVMPI_Event *event,
1173
								   ThreadPrivateStorage *tps,
1174
								   BOOL isRequested,
1175
								   timestamp_t timestamp,
1176
									timestamp_t cpu_timestamp) {
1177
	HashEntry *methodHashEntry;
1178
1179
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)	
1180
    if (tps!=prevMthdTps) {
1181
    	dumpMethodEventCounts(); prevMthdTps=tps;
1182
    }
1183
    mxCount++;
1184
#endif
1185
    if(_jvmpiAgent_Options.mode == TraceModeNone) {
1186
        return;
1187
    }
1188
1189
	if (_jvmpiAgent_Options.mode ==  TraceOptimizedHeap) {
1190
	  /* ToDo: remove. I know that, in TraceGcOptimizedHeap mode, it will never come
1191
	   * here because METHOD_EXIT event is disbled, but just to make sure that it
1192
	   * is not accidently causing lack of LeakCandidates.
1193
	   */
1194
	  /* do nothing */
1195
	  return;
1196
	}
1197
1198
	/* RKD:  If we don't know the stack for this thread
1199
           we will abort this event.
1200
	*/
1201
	if(!tps->threadStackKnown) {
1202
		return;
1203
	}
1204
1205
1206
	/* RKD:  It could be possible that the stack will be empty.  This happens
1207
          on various platforms with various JDK's due to bugs in the JVMPI
1208
		  implementation.  In order to avoid the almightly stack underflow
1209
		  that would result in us bringing down the JVM, I will check and
1210
		  see if the stack is empty.  It this is the case I will back out
1211
		  the profiler and allow the JVM to continue processing.
1212
	*/
1213
	if(!tps->tos) {
1214
		tps->threadStackKnown=0;
1215
		return;
1216
	}
1217
1218
	/* Compare the current method with that on the local stack */
1219
	methodHashEntry = tps->stackEntry[tps->tos].methodHashEntry;
1220
	/* 174190 - added check for non-NULL methodHashEntry in case there isn't one stored on the stack */
1221
	if(methodHashEntry && ((MethodHashKey *)methodHashEntry->id)->id != event->u.method.method_id) {
1222
		/* Stack is not synched, look up the method */
1223
		methodHashEntry = jvmpiAgent_FindMethodSymbol(event->u.method.method_id);
1224
	}
1225
1226
	/* 174190 - added check for non-NULL methodHashEntry in case there isn't one stored on the stack */
1227
	if (methodHashEntry) {
1228
		/* If not pre-aggregating, print the method-exit event for those where we printed the entry. */
1229
		if (_jvmpiAgent_Options.compressLevel==CompressNone) {
1230
			if (jvmpiAgent_Peek(tps, 0)->printed)  {
1231
				jvmpiAgent_printMethodExitElement(event, tps, methodHashEntry, timestamp,cpu_timestamp);
1232
			}
1233
		}
1234
		/* If this was a trigger that started tracing, stop tracing (only if trigger tracing) */
1235
		if(_jvmpiAgent_Options.startMode>TraceStartModeFilter && !_jvmpiAgent_Options.application && jvmpiAgent_Peek(tps, 0)->trigger) {
1236
			suspendTracing(TracePause);
1237
		}
1238
	}
1239
1240
	/* if pre-aggregation, accumulate time into this StackEntry (unless bad lastEntryTime), and set lastEntryTime of caller. */
1241
	if(_jvmpiAgent_Options.compressLevel==CompressAggregate)
1242
	{
1243
		StackEntry * top = jvmpiAgent_Peek(tps, 0);
1244
		StackEntry * caller = jvmpiAgent_Peek(tps, 1);
1245
		if( top != NULL && top->lastEntryTime!=0) { /* lastEntryTime is 0 for first stackEntry after loadstack * 139537 */
1246
			TIMESTAMP_ADD(top->baseTime , timestamp - top->lastEntryTime);
1247
			TIMESTAMP_ADD(top->baseCPUTime, cpu_timestamp - top->lastEntryCPUTime);
1248
			DBG_CHK_AND_REPORT_TIME_OVERFLOW(top->baseTime, "Time overflowed?! (MethodExit: top->baseTime)\n"); /* 134577 */
1249
		}
1250
		if( caller != NULL ) {
1251
			caller->lastEntryTime = timestamp;
1252
			caller->lastEntryCPUTime = cpu_timestamp;
1253
		}
1254
		/* The logic in jvmpiAgent_Pop will roll data from the StackEntry to the proper StackFrame. */
1255
	}
1256
	jvmpiAgent_Pop(tps);
1257
}
1258
1259
/* bugzilla 71388 start - JNI methods need to be enclosed in a conditional 'extern "C"' declaration */ 
1260
#if defined __cplusplus
1261
extern "C" {
1262
#endif
1263
1264
/*
1265
 * Class:     com_ibm_etools_logging_tracing_agent_Callback
1266
 * Method:    JVMPICoverage0
1267
 * Signature: (S)V
1268
 */
1269
JNIEXPORT void JNICALL Java_com_ibm_etools_logging_tracing_agent_Callback_JVMPICoverage0(JNIEnv *env, jclass cls, jshort e)
1270
{
1271
1272
 /* RKD:  We shouldn't be testing IO here */
1273
 if (!_jvmpiAgent_suspendIO && _jvmpiAgent_jvm) /* Only do this if the dll has been initialized correctly */
1274
 {
1275
  HashEntry * methodHashEntry = 0;
1276
  ThreadLocalStorage *tps;
1277
  tps = jvmpiAgent_getThreadLocalStorage(env);
1278
1279
  methodHashEntry = jvmpiAgent_Peek(tps,2)->methodHashEntry;
1280
  if (methodHashEntry && CLASS_ENTRY(METHOD_ENTRY(methodHashEntry)->classHashEntry)->traceFlag)
1281
  {
1282
   jvmpiAgent_printLineElement(env, tps, methodHashEntry, e);
1283
  }
1284
 }
1285
1286
}
1287
1288
/* bugzilla 71388 end - JNI methods need to be enclosed in a conditional 'extern "C"' declaration */ 
1289
#if defined __cplusplus
1290
}
1291
#endif
1292
1293
static int decrementInvocationCount() {
1294
	/* Decrement the burst count if necessary.
1295
	   RKD: This should be atomic.
1296
	*/
1297
	/* decrementInvocationCount() is called at the END of processMethodEntry, and so 
1298
	when the invocationCountRemaining is 1, this means that we've traced the number
1299
	of methods asked for by the user */ 
1300
	if(_invocationCountRemaining<=1) {
1301
		suspendTracing(TracePause);
1302
		return -1;
1303
	}
1304
	else {
1305
		_invocationCountRemaining--;
1306
		return 0;
1307
	}
1308
}
1309
1310
1311
static int incrementInvocationCount() {
1312
	_invocationCountRemaining--;
1313
}
1314
1315
/** PROCESS_MISSING_STACK_ENTRIES  ********************************************
1316
  *
1317
  */
1318
static void processMissingStackEntries(JVMPI_Event *event, ThreadLocalStorage *tps) {
1319
	StackEntry * se = 0;
1320
	int i = 1;
1321
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)	
1322
    dumpMethodEventCounts(); printf("processMissingStackEntries: tps = %8x\n", (void *)tps); fflush(stdout);
1323
#endif
1324
    if(_jvmpiAgent_Options.mode == TraceModeNone) {
1325
        return;
1326
    }
1327
	if (_jvmpiAgent_Options.mode ==  TraceOptimizedHeap) {
1328
	  /* ToDo: remove. I know that, in TraceGcOptimizedHeap mode, it will never come
1329
	   * here because it is called only from processMethodEntry() method, and
1330
	   * METHOD_ENTRY events are disabled. But just to make sure that it
1331
	   * is not accidently causing lack of LeakCandidates.
1332
	   */
1333
	  /* do nothing */
1334
	  return;
1335
	}
1336
1337
	/* Walk up the stack looking for the first non filtered out method.  This loop will leave
1338
	   i being the stack offset of the first unfiltered method on the stack and se points to this
1339
	   stackEntry.  If se is null then we walked off the beginning of the stack without finding
1340
	   an unfiltered method.
1341
	*/
1342
	for (se = jvmpiAgent_Peek(tps, i); se && !se->printed; se = jvmpiAgent_Peek(tps, ++i));
1343
	
1344
	
1345
	/* Now we walk through the filtered out stack entries producing METHOD_ENTRYs for each entry.*/
1346
	for (--i; se && i > 0; --i) {
1347
		se = jvmpiAgent_Peek(tps, i);
1348
		
1349
		/* If we are handling object collation we better ensure we know the object */
1350
		if(_jvmpiAgent_Options.mode == TraceModeFull) {
1351
			/* RKD:  If we know the object we should check our filter against it for inheritance reasons (only when filter tracing) */
1352
			if (se->objectHashEntry && _jvmpiAgent_Options.startMode==TraceStartModeFilter && !se->objectHashEntry->printed) {
1353
			    jvmpiAgent_printObjAllocElement(se->objectHashEntry, event->env_id, 0);
1354
			}
1355
		}
1356
1357
		/* Note: following if-else-if pattern repeats with variation in ProcessMethodEntry */
1358
		/* Test pre-aggregation mode */
1359
		if (_jvmpiAgent_Options.compressLevel==CompressNone) {
1360
			/* Full Trace: print the method entry for this stack frame */
1361
			jvmpiAgent_printMethodEntryEvent(event, tps, se, tps->tos-i);
1362
		}
1363
		else { /* 134635C - fix contiguous mode (besides detach/attach/pause) */
1364
			
1365
			/* pre-agg mode: print a methodDef if needed and create a stackFrame for this stackEntry. 
1366
			 *
1367
			 * We can safely create a stackFrame after the fact here. It is later than usual (normally
1368
			 * done on method entry) but still before it is needed (in the agPop invoked at method exit).
1369
			 * Note that the baseTime/baseCpuTime accumulations have already been done correctly for this 
1370
			 * stackEntry by the normal MethodEntryEvent operations which accumulate time the same way 
1371
			 * regardless of whether the method is filtered or not. It is the processing of MethodExitEvents 
1372
			 * (specifically the jvmpiAgent_agPop) that differentiates between filtered and not.
1373
			 */
1374
			StackEntry * caller;
1375
			caller = jvmpiAgent_Peek(tps, i+1); /* se is guaranteed to have a caller on the stack */
1376
			/* Pre-agg: print method def if needed & create/re-use StackFrame for method * 134577 */ 
1377
			/*        : set lastEntryTime (& lastEntryCpuTime as needed)                 * 134577 */
1378
			recordAgMethodEntry(tps, se, caller);                                       /* 134577 */
1379
		}
1380
		/* Deal with burst mode if we are running in that mode (ignore BurstModeSeconds here) */
1381
		if( _jvmpiAgent_Options.burstMode == BurstModeInvocations ||
1382
			_jvmpiAgent_Options.burstMode == BurstModeSecondsAndInvocations ) { 
1383
			decrementInvocationCount(); /* non-zero indicates count exhausted: tracing has suspended */ 
1384
		}
1385
1386
	}
1387
}
1388
1389
/**
1390
 * loadMethodHashEntry() 
1391
 * 
1392
 * Load the method hash entry for a given method_id, ensuring that a CLASS_LOAD
1393
 * is requested if the piAgent doesn't currently know about the method 
1394
 */ 
1395
static HashEntry *loadMethodHashEntry(jmethodID method_id) {
1396
	HashEntry *methodHashEntry = NULL; 
1397
	/* The JVM may give us a method_id of '0' */
1398
	if(method_id != 0) {
1399
		methodHashEntry = jvmpiAgent_FindMethodSymbol(method_id);
1400
1401
		/* If this is an unknown method we need to ask for the CLASS_LOAD event */
1402
		if(!methodHashEntry) {
1403
			jobjectID clazz;
1404
			jint result;
1405
			clazz=_jvmpiAgent_jvmpiInterface->GetMethodClass(method_id);
1406
			result=!JVMPI_SUCCESS;
1407
			
1408
			if(clazz) {
1409
				result=REQUEST_EVENT2(JVMPI_EVENT_CLASS_LOAD, clazz); /* 232010 */
1410
				/* If we found the class we should have the method */
1411
				if(result == JVMPI_SUCCESS) {
1412
					methodHashEntry = jvmpiAgent_FindMethodSymbol(method_id);
1413
				}
1414
			}
1415
		}
1416
	}
1417
	return methodHashEntry; 
1418
}
1419
1420
1421
/** PROCESS_COUNTING_METHOD_ENTRY_EVENT 
1422
 * 
1423
 * This version of processMethodEntryEvent is called when the METHOD_COUNTS_ONLY option is turned
1424
 * on. We don't want the overhead of the regular processMethodEntry event in this case. 
1425
 */ 
1426
1427
static void processCountingMethodEntryEvent(JVMPI_Event *event, ThreadLocalStorage *tps, BOOL isRequested, timestamp_t timestamp,
1428
									timestamp_t cpu_timestamp) {
1429
	HashEntry *methodHashEntry;
1430
1431
	methodHashEntry = loadMethodHashEntry(event->u.method.method_id);
1432
	if (methodHashEntry != NULL) {
1433
		METHOD_ENTRY(methodHashEntry)->methodCount++;
1434
	}
1435
}
1436
1437
/* For pre-aggregation */
1438
/* Recursively free stack frames.
1439
 * This function frees all children of the frame being passed in,
1440
 * then frees that frame itself. It returns the "next" (sibling) pointer
1441
 * from the frame being freed.
1442
 *
1443
 * OPTIMIZATION OPPORTUNITY HERE: use a chunky allocator for StackFrame
1444
 * objects, with one chunk chain per thread. Since the frames for a thread
1445
 * are always freed all at once, you could just free the chunks and not have
1446
 * to do this recursive descent.
1447
 */
1448
void freeStackFrames(StackFrame* frame)
1449
{
1450
	if (frame == NULL) return;
1451
1452
	/* first, free children */
1453
	freeStackFrames(frame->calledList);
1454
1455
	/* then, free the next sibling */
1456
	freeStackFrames(frame->next);
1457
1458
	/* finally, free this frame */
1459
	free(frame);
1460
}
1461
1462
/* For pre-aggregation */
1463
/*
1464
 * Add a thread to the list of live threads that the
1465
 * pre-aggregation logic is tracking.
1466
 *
1467
 * This may seem redundant - the list of live threads is also available
1468
 * in the ThreadHashTable data structure. But the timing and semantics
1469
 * adding and removing threads from that list and this one are different,
1470
 * and I didn't want to go poking around to make sure the right things would
1471
 * always happen in the right order, so I left this as a separate data
1472
 * structure just like the original prototype implementors had.
1473
 */
1474
void addThreadToList( ThreadPrivateStorage * tpsLocal )
1475
{
1476
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
1477
    dumpMethodEventCounts(); printf("addThreadToList (try): tpsLocal = %8x\n", (void *)tpsLocal); fflush(stdout);
1478
#endif
1479
    /* Get the thread list lock because we're managing that list here */
1480
    getThreadListLock();
1481
    {
1482
		/* It seems we are recieving duplicate events for thread starts. First, make
1483
		 * sure we don't already have the thread */
1484
		struct ThreadListElement * it = threadsRoot;
1485
		while (it) {
1486
			if (it->data == tpsLocal ) {
1487
				/* Thread already seen; exit with "it" != NULL */
1488
				break;
1489
			}
1490
			it = it->next;
1491
		}
1492
1493
		if (it == NULL ) {
1494
			/* usual case: we don't already have an entry for this thread */
1495
			struct ThreadListElement * newThreadElement = (struct ThreadListElement *)jvmpiAgent_Calloc( sizeof( struct ThreadListElement ) );
1496
			newThreadElement->data = tpsLocal;
1497
			newThreadElement->next = threadsRoot;
1498
			newThreadElement->prev = 0;
1499
			if( threadsRoot )
1500
				threadsRoot->prev = newThreadElement;
1501
			threadsRoot = newThreadElement;
1502
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
1503
			printf("addThreadToList (succeed)\n"); fflush(stdout);
1504
#endif
1505
		}	
1506
    }
1507
    releaseThreadListLock();
1508
}
1509
1510
/* For pre-aggregation */
1511
/*
1512
 * Remove a thread from the list of live threads being maintained
1513
 * by the pre-aggregation logic. See notes above for why this
1514
 * exists in parallel with the ThreadHashTable stuff.
1515
 *
1516
 * Frees all StackFrames associated with the thread being removed.
1517
 * Does not dump any data; this function assumes you did that already or you
1518
 * don't care.
1519
 */
1520
void removeThreadFromList( ThreadPrivateStorage * target_tps )
1521
{
1522
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
1523
	dumpMethodEventCounts(); printf("removeThreadFromList (try): target_tps = %8x\n", (void *)target_tps); fflush(stdout);
1524
#endif
1525
	/* get the thread list lock because we're managing that list here */
1526
    getThreadListLock();
1527
    {
1528
		struct ThreadListElement * it = threadsRoot;
1529
		while (it) {
1530
			if( it->data == target_tps )
1531
				break;
1532
			it = it->next;
1533
		}
1534
1535
		if (it) { /* If found */
1536
			/* Free all the elements from calledList, recursively */
1537
			freeStackFrames(it->data->calledList);
1538
			it->data->calledList = NULL;
1539
1540
			/* Now actually remove the thread from the list */
1541
			if( it->next ) 
1542
				it->next->prev = it->prev;
1543
			if( it->prev )
1544
				it->prev->next = it->next;
1545
			if( threadsRoot == it )
1546
				threadsRoot = it->next;
1547
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
1548
			printf("removeThreadFromList (succeed)\n"); fflush(stdout);
1549
#endif
1550
		}
1551
1552
		free(it);
1553
	}
1554
	target_tps->calledList = NULL;  /* 134635: frames are all gone so thread's calledList must be nulled */
1555
    releaseThreadListLock();
1556
}
1557
1558
/* For pre-aggregation */
1559
/*
1560
 * Recursively print the aggregated data for a single thread, 
1561
 * starting from a given StackFrame. Called from PrintAgThreadData.
1562
 */
1563
1564
void printAgData(ThreadPrivateStorage * tps, StackFrame * call) {
1565
1566
	if (call == NULL)
1567
		return;
1568
1569
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)		
1570
	dumpMethodEventCounts(); 
1571
	printf("printAgData: agMethodEntry, (children), agMethodExit\n"); fflush(stdout);
1572
	printf("           : tps, &stackframe, &methodHashEntry, MethodIdRef= %8x, %8x, %8x",
1573
		    (void *)tps, (void *)call, (void*)(METHOD_ENTRY(call->methodHashEntry)) ); fflush(stdout);
1574
	printf(", %5d\n", (jint)((METHOD_ENTRY(call->methodHashEntry))->static_id)); fflush(stdout);
1575
#endif
1576
1577
	jvmpiAgent_printAgMethodEntryEvent(tps, call);    /* 135437 */	
1578
	
1579
	/* Note: The following loop prints the call chains of the direct children of the current "call", 
1580
	 * depth first and then breadth. It terminates when the "next" ptr of one of the direct children 
1581
	 * of the current call is null. Thus it terminates after printing the call chains of the last
1582
	 * direct child of the current call frame. (The loop & recursion is compact but can confuse.)
1583
	 */  
1584
1585
	/* Dump this call's children */
1586
	{
1587
		StackFrame * it = call->calledList; /* select the first direct child of the current "call" */
1588
		while( it != NULL ) {               /* stop if there are no more direct children of the current caller */ 
1589
			printAgData(tps, it);           /* print the call chains of this direct child of the current caller */
1590
			it = it->next;                  /* select the next direct child of the current caller */ 
1591
		}
1592
	}
1593
	
1594
	jvmpiAgent_printAgMethodExitElement(tps, call);   /* 135457 */
1595
}
1596
1597
1598
1599
/* For pre-aggregation */
1600
/*
1601
 * Send the call chain counts for the indicated thread.
1602
 * This is called from two places: when a single thread dies,
1603
 * and when you do a full-process snapshot.
1604
 *
1605
 * This function calls getStackFrameStructureLock, but
1606
 * only if it's called from a place where you didn't already have it.
1607
 * This is conveyed by a boolean argument, true if the caller
1608
 * already has the lock. That's necessary because the
1609
 * ra_critsec_t implementation isn't reentrant on Linux.
1610
 *
1611
 * The reason we need to acquire StackFrameStructureLock even though
1612
 * we're only dumping a single thread is that another dump request
1613
 * (a snapshot or JVM shutdown) could come in on another thread
1614
 * while this dump is still going on. We don't want to have
1615
 * multiple dumps happening in parallel: they would cause
1616
 * duplicate data to be sent.
1617
 *
1618
 * This does mean that one thread's death will stall any other thread that 
1619
 * makes a unique call (and thus also needs StackFrameStructureLock)
1620
 * for the duration of the dump, even though they couldn't
1621
 * possibly step on each other. This makes me wish for a different 
1622
 * lock implementation, one that more completely expresses the possible collisions.
1623
 */
1624
void printThreadAgData ( ThreadLocalStorage * tps, int alreadyHasLock ) {
1625
	StackFrame * it;
1626
1627
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
1628
	dumpMethodEventCounts(); 
1629
	printf("printThreadAgData: tps, tps->calledList, _traceResourcesGone = %8x, %8x, %2d\n",
1630
			(void *)tps, (void *)tps->calledList, (int)_traceResourcesGone); fflush(stdout);
1631
#endif
1632
	/* pre-agg: 134635 
1633
	 * This test is necessary because it is possible for a print of agg data 
1634
	 * to be attempted after the underlying trace resources (esp. method hash table)
1635
	 * have been cleaned-up via cleanupAllTraceResources. This is known to occur at
1636
	 * least sometimes when a processThreadEndEvent occurs after DETACH_FROM_AGENT
1637
	 * has been processed. It is a harmless test  for the non-pre-agg case
1638
	 */
1639
	if (_traceResourcesGone) {  
1640
		return;
1641
	}	 
1642
1643
	if (!alreadyHasLock) {
1644
		getStackFrameStructureLock();
1645
	}
1646
	it = tps->calledList;
1647
	while( it != NULL ) {
1648
		printAgData(tps, it);
1649
		it = it->next;
1650
	}
1651
	if (!alreadyHasLock) {
1652
		releaseStackFrameStructureLock();
1653
	}
1654
}
1655
1656
/* For pre-aggregation */
1657
/*
1658
 * Send the call chain counts for all threads. This is a "snapshot"
1659
 * operation that acquires the StackFrameStructureLock
1660
 * and walks the StackFrames of all threads.
1661
 */
1662
void printAllThreadAgData() {
1663
1664
	/* Get the thread list lock because we walk the whole thread list here */
1665
  getThreadListLock();
1666
  {
1667
	struct ThreadListElement * it = threadsRoot;
1668
1669
	/*
1670
	 * Acquire this lock so we block out any other thread
1671
	 * that is trying to add new callers to frames.
1672
	 * See notes elsewhere about a no-lock alternative 
1673
	 * to stackFrameStructureLock.
1674
	 */
1675
	getStackFrameStructureLock();
1676
	{
1677
		while (it) {
1678
			printThreadAgData( it->data, TRUE );
1679
			it = it->next;
1680
		}
1681
	}
1682
	releaseStackFrameStructureLock();
1683
  }
1684
  releaseThreadListLock();
1685
}
1686
1687
/*
1688
 *  Return current time and (if options so indicate) current cpu time. As a side-effect,
1689
 *  tps->last_cpu_time is updated if cpu time is updated. This function is used in 
1690
 *  processMethodEntryEvent and processMissingStackEntries because they share a pattern
1691
 *  of usage where latest time/cpu_time are used for both stackEntry aggregation (if applicable)
1692
 *  and method entry overhead calculations.
1693
 */
1694
void setNowTimes(ThreadLocalStorage * tps, timestamp_t * nowTime_P, timestamp_t * nowCpuTime_P) { /* 134577 */
1695
	jvmpiAgent_getCurrentTime(nowTime_P);
1696
	if (_jvmpiAgent_Options.cpuTime) {
1697
		*nowCpuTime_P = jvmpiAgent_getCurrentThreadCPUTime(); 
1698
		tps->last_cpu_timestamp = *nowCpuTime_P;
1699
	}	
1700
}
1701
1702
/* For pre-aggregation */                                            
1703
/*
1704
 * Print method def if needed and create/re-use StackFrame for method along this chain since it 
1705
 * is not filtered out. Get latest time/cpuTime. Store them in stackEntry->lastEntryTime and 
1706
 * lastEntryCPUTime to allow for potential suspendTracing (which references these values) from 
1707
 * subsequent decrementInvocationCount calls and for later overhead calculations in the caller. 
1708
 * They are purposely calculated as late in this function as possible to eliminate overhjeas from method stats.
1709
 */
1710
void recordAgMethodEntry(ThreadLocalStorage * tps, StackEntry * stackEntry, StackEntry * caller) { /*134577 */
1711
 	timestamp_t nowTime; 
1712
 	timestamp_t nowCpuTime = 0;
1713
1714
	stackEntry->printed = 1; /* Indicate that this entry is "printed"=non-filtered - 134635C */  
1715
	jvmpiAgent_outputMethodDeclaration(stackEntry->methodHashEntry, tps);
1716
	jvmpiAgent_CreateStackFrame(tps, stackEntry->methodHashEntry, caller);
1717
	
1718
    setNowTimes(tps, &nowTime, &nowCpuTime);	
1719
	stackEntry->lastEntryTime = nowTime;  /* critical in case suspend occurs from burst mode before Method entry ends *134577 */
1720
	stackEntry->lastEntryCPUTime = nowCpuTime;
1721
}
1722
1723
1724
/** PROCESS_METHOD_ENTRY_EVENT  ***********************************************
1725
  *
1726
  */
1727
static void processMethodEntryEvent(JVMPI_Event *event, ThreadLocalStorage *tps, BOOL isRequested, timestamp_t timestamp,
1728
									timestamp_t cpu_timestamp) {
1729
	HashEntry *methodHashEntry, *objectHashEntry;
1730
	StackEntry * stackEntry, *caller;
1731
	int isPrinting;
1732
	jmethodID method_id;
1733
	jobjectID object_id;
1734
	BOOL triggeringEvent=FALSE;
1735
1736
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
1737
	if (tps!=prevMthdTps) {
1738
		dumpMethodEventCounts(); prevMthdTps=tps;
1739
	}
1740
	meCount++;
1741
#endif
1742
1743
    if(_jvmpiAgent_Options.mode == TraceModeNone) {
1744
        return;
1745
    }
1746
	if (_jvmpiAgent_Options.mode ==  TraceOptimizedHeap) {
1747
	  /* ToDo: remove. I know that, in TraceGcOptimizedHeap mode, it will never come
1748
	   * here because METHOD_ENTRY event is disbled, but just to make sure that it
1749
	   * is not accidently causing lack of LeakCandidates.
1750
	   */
1751
	  /* do nothing */
1752
	  return;
1753
	}
1754
1755
	objectHashEntry=methodHashEntry=NULL;
1756
	method_id = event->u.method.method_id;
1757
	object_id=(event->event_type==JVMPI_EVENT_METHOD_ENTRY2) ? event->u.method_entry2.obj_id : 0;
1758
1759
	/* RKD:  If we don't know the stack for this thread
1760
           we better materialize this stack now.
1761
	*/
1762
	if(!tps->threadStackKnown) {
1763
		/* Disable GC */
1764
		_jvmpiAgent_jvmpiInterface->DisableGC();
1765
		loadStack(tps);
1766
1767
		/* Re-enable GC */
1768
		_jvmpiAgent_jvmpiInterface->EnableGC();
1769
1770
		/* We are already on the stack from the load.  Pop us off */
1771
		jvmpiAgent_Pop(tps);
1772
1773
		/* RKD:  Do to problems we have with the JIT being enabled it may be possible that the
1774
                 thread stack is still not known.  If this case we abort this method
1775
		*/
1776
		if(!tps->threadStackKnown) {
1777
			return;
1778
		}
1779
1780
	}
1781
1782
	
1783
	methodHashEntry = loadMethodHashEntry(method_id); 
1784
1785
	/* Determine if we are supposed to print this method.  Depending upon the trace start mode will determine this test */
1786
	if(_jvmpiAgent_Options.startMode==TraceStartModeFilter) {
1787
		isPrinting = (methodHashEntry && METHOD_ENTRY(methodHashEntry)->traceFlag && _jvmpiAgent_Options.stackInfo > StackInfoNone);
1788
	}
1789
	/* Trigger tracing */
1790
	else {
1791
		/* If the trigger hasn't been squeezed yet check to see if we are the trigger and scope to thread if neccessary */
1792
		if(!_triggerSqueezed) {
1793
			isPrinting = (methodHashEntry
1794
				      && (METHOD_ENTRY(methodHashEntry)->trigger
1795
				          == METHOD_ENTRY(methodHashEntry)->methodCount));
1796
1797
			if(isPrinting) {
1798
				_triggerSqueezed=TRUE;
1799
				triggeringEvent=TRUE;
1800
				if(_jvmpiAgent_Options.startMode==TraceStartModeTriggerSingleThreaded) {
1801
					_jvmpiAgent_limitingThread=event->env_id;
1802
					_jvmpiAgent_singleThreaded=TRUE;	
1803
				}
1804
				if(_jvmpiAgent_isSuspended) {
1805
					resumeTracing();
1806
				}
1807
			}
1808
			isPrinting=isPrinting && _jvmpiAgent_Options.stackInfo > StackInfoNone;
1809
		}
1810
		else {
1811
			isPrinting = (methodHashEntry && _jvmpiAgent_Options.stackInfo > StackInfoNone);
1812
		}
1813
	}
1814
1815
	/* If we are handling object collation we better ensure we know the object */
1816
	if(_jvmpiAgent_Options.mode == TraceModeFull && object_id) {
1817
		/* Look for the object */
1818
1819
	  /* 226233: we can safely use the "fast", non-ref counting
1820
	     version here, since we'd only be here if this is an
1821
	     ENTRY2 event, in which case the heap is locked */
1822
		objectHashEntry = jvmpiAgent_FindObjectSymbolFast(object_id);
1823
1824
		/* If the object is not currently in the DB look it upo in the VM */
1825
		if(!objectHashEntry || !objectHashEntry->id || 
1826
			!((ObjectHashKey*)objectHashEntry->id)->id) {
1827
			int result;
1828
			/* RKD:  Disable the garbage collector while we get the object */
1829
			_jvmpiAgent_jvmpiInterface->DisableGC();
1830
			result=REQUEST_EVENT2(JVMPI_EVENT_OBJECT_ALLOC, event->u.method_entry2.obj_id); /* 232010 */
1831
			_jvmpiAgent_jvmpiInterface->EnableGC();
1832
1833
			/* We should now find the object without incident */
1834
			objectHashEntry = jvmpiAgent_FindObjectSymbolFast(object_id);
1835
		}
1836
1837
		/* RKD:  If we know the object we should check our filter against it for inheritance reasons (only when filter tracing) */
1838
		if ( objectHashEntry && _jvmpiAgent_Options.startMode==TraceStartModeFilter 
1839
			&& OBJECT_ENTRY(objectHashEntry)->traceFlag && !objectHashEntry->printed ) {
1840
			jvmpiAgent_printObjAllocElement(objectHashEntry, event->env_id, 0);
1841
			isPrinting=1;
1842
		}
1843
	}
1844
1845
	/* pre-aggregation mode: accumulate time into the caller (unless caller was added to stack by loadstack) */
1846
	if (_jvmpiAgent_Options.compressLevel==CompressAggregate) {
1847
		caller = jvmpiAgent_Peek(tps, 0);
1848
		if (caller != NULL && caller->lastEntryTime!=0) { /* lastEntryTime is 0 for first caller after loadstack * 139537 */
1849
			TIMESTAMP_ADD(caller->baseTime, timestamp - caller->lastEntryTime);
1850
			TIMESTAMP_ADD(caller->baseCPUTime, cpu_timestamp - caller->lastEntryCPUTime);
1851
			DBG_CHK_AND_REPORT_TIME_OVERFLOW(caller->baseTime, "Time overflowed?! (MethodEntry: caller->baseTime)\n"); /* 134577 */
1852
			caller->lastEntryTime = -1;	/* -1 means this frame active right now */
1853
			caller->lastEntryCPUTime = -1;
1854
		}
1855
	}
1856
	
1857
	/* Push the method on the stack. (Note: this initializes all pre-agg stackEntry fields to 0) */
1858
	stackEntry = jvmpiAgent_Push(tps, event->env_id, methodHashEntry, objectHashEntry, timestamp,cpu_timestamp);
1859
1860
	/* If we are in a pure trigger mode we need to indicate whether this frame is the trigger so we stop
1861
	   profiling when the frame is popped.
1862
	*/
1863
	stackEntry->trigger=triggeringEvent;
1864
1865
1866
	if (methodHashEntry) {
1867
		if (isPrinting) {
1868
			if(_jvmpiAgent_Options.startMode==TraceStartModeFilter && (_jvmpiAgent_Options.stackInfo==StackInfoContiguous || _jvmpiAgent_Options.stackInfo==StackInfoBoundaryAndContiguous)) {
1869
				processMissingStackEntries(event, tps);	
1870
			}
1871
1872
			/* When in filtering mode, reset the boundary depth every time we hit a traced method. */
1873
			if(_jvmpiAgent_Options.startMode==TraceStartModeFilter) {
1874
				stackEntry->currentBoundaryDepth=_jvmpiAgent_Options.boundaryDepth+1;
1875
			}
1876
1877
			/* If we are in application mode we need to set the boundary depth only when we did not see
1878
			   the entry event on the next frame up the stack.
1879
			*/
1880
			if(_jvmpiAgent_Options.application  && _jvmpiAgent_Options.boundaryDepth) {
1881
				StackEntry *invokerFrame=jvmpiAgent_Peek(tps,1);
1882
				if(invokerFrame && !invokerFrame->entryEventSeen) {
1883
					stackEntry->currentBoundaryDepth=_jvmpiAgent_Options.boundaryDepth;
1884
				}
1885
				
1886
				/* Application mode is a different then all the other modes in the fact that we
1887
				   don't keep tracing deeper if our boundaryDepth is
1888
				*/
1889
				if(!stackEntry->currentBoundaryDepth) {
1890
					return;
1891
				}
1892
			}
1893
			/* Note: following if-else-if pattern repeats below and with variation in ProcessMissingStackEntries */
1894
			if (_jvmpiAgent_Options.compressLevel==CompressNone) { 
1895
				/* Full trace: print the method entry for this event */
1896
				jvmpiAgent_printMethodEntryEvent(event, tps, stackEntry, tps->tos);
1897
			}
1898
			else {
1899
				/* Pre-agg: print method def if needed & create/re-use StackFrame for method * 134577 */ 
1900
				/*        : set lastEntryTime (& lastEntryCpuTime as needed)                 * 134577 */
1901
				recordAgMethodEntry(tps, stackEntry, caller);                               /* 134577 */
1902
			}
1903
			/* Deal with burst mode if we are running in that mode (ignore BurstModeSeconds here) */
1904
			if( _jvmpiAgent_Options.burstMode == BurstModeInvocations ||
1905
				_jvmpiAgent_Options.burstMode == BurstModeSecondsAndInvocations ) { 
1906
				if(decrementInvocationCount()) { /* non-zero indicates count exhausted: tracing has suspended */ 
1907
					return;                      /* don't count suspension time in entry overhead             */ 
1908
				}
1909
			}
1910
		}
1911
		else if(_jvmpiAgent_Options.stackInfo>=StackInfoBoundary && stackEntry->currentBoundaryDepth) {
1912
			/* Note: following if-else-if pattern repeats above and with variation in ProcessMissingStackEntries */
1913
			if (_jvmpiAgent_Options.compressLevel==CompressNone) {
1914
				/* Full trace: print the method entry for this event */
1915
				jvmpiAgent_printMethodEntryEvent(event, tps, stackEntry, tps->tos);
1916
			}
1917
			else {
1918
				/* Pre-agg: print method def if needed & create/re-use StackFrame for method * 134577 */
1919
				/*        : set lastEntryTime (& lastEntryCpuTime as needed)                 * 134577 */ 
1920
				recordAgMethodEntry(tps, stackEntry, caller);                                /*134577 */
1921
			}
1922
			/* Deal with burst mode if we are running in that mode (ignore BurstModeSeconds here) */
1923
			if( _jvmpiAgent_Options.burstMode == BurstModeInvocations ||
1924
				_jvmpiAgent_Options.burstMode == BurstModeSecondsAndInvocations ) { 
1925
				if(decrementInvocationCount()) { /* non-zero indicates count exhausted: tracing has suspended */ 
1926
					return;                      /* don't count suspension time in entry overhead             */ 
1927
				}
1928
			}
1929
		}
1930
	}
1931
1932
	{
1933
	  /* NMM: here is where we accumulate the tracing overhead due
1934
	     to method enter processing */
1935
		timestamp_t now;
1936
		timestamp_t cpu_now = 0; 
1937
		Uint64      enter_overhead;
1938
		Uint64      cpu_enter_overhead = 0;  
1939
		
1940
		/* Get new times that include our overhead in them */
1941
		if (_jvmpiAgent_Options.compressLevel==CompressNone) { 
1942
			setNowTimes(tps, &now, &cpu_now);
1943
		} else {		
1944
			/* 134577 *
1945
			 * Pre-agg: only set now & cpu_now here if they were not previously set by recordAgMethodEntry. 
1946
			 *          The difference in calculating them here and in an earlier recordAgMethod is 
1947
			 *          negligible. The intent is to conserve getCurrentTime & getCurrentThreadCPUtime
1948
			 *          calls because they are expensive and would skew the overhead calculation.
1949
			 */
1950
			if (stackEntry->lastEntryTime == 0) { /* not set by either previous recordAgMethodEntry */ 
1951
				setNowTimes(tps, &now, &cpu_now);
1952
				stackEntry->lastEntryTime = now;
1953
				stackEntry->lastEntryCPUTime = cpu_now;
1954
			} else {                              /* set by one of the previous recordAgMethodEntry */
1955
				now     = stackEntry->lastEntryTime;
1956
				cpu_now = stackEntry->lastEntryCPUTime;	
1957
			}	
1958
		}
1959
		
1960
		enter_overhead = TIMESTAMP_SUB(now,timestamp);
1961
		if (_jvmpiAgent_Options.cpuTime) {
1962
			cpu_enter_overhead = TIMESTAMP_SUB(cpu_now,cpu_timestamp); 
1963
		}	
1964
		
1965
		stackEntry->cumulative_overhead = enter_overhead;
1966
		stackEntry->cumulative_cpu_overhead = cpu_enter_overhead; 
1967
	}
1968
}
1969
1970
1971
/** SET_PATH_DELIMITER  ********************************************************
1972
  * Checks class name's provided by JVMPI to determine if this JVM uses the '.'
1973
  * package delimiter.  If it does, we will tell the filters checker to use
1974
  * change all it's strings to the '.' delimiter.
1975
  * RKD:  I hate the use of a global here.  I bet we can get around this.
1976
  */
1977
static void setPathDelimiter(char * str) {
1978
#ifdef __OS400__
1979
#pragma convert(819) 
1980
#endif
1981
1982
	/* The path delimiter on IBM's JDK */
1983
	char ibmch = '/';
1984
	/* The path delimiter on SUN's JDK */
1985
	char sunch = '.';
1986
	/* The location of the delimiter */
1987
	char *pdest;
1988
1989
	/* Look for the IBM delimiter in the given string */
1990
	pdest = strchr(str, ibmch );
1991
1992
	/* Set the global delimiter */
1993
	if(pdest)  {
1994
		_setPathDelimiter = ibmch;
1995
	}
1996
	else {
1997
		pdest = strchr(str, sunch );
1998
		if(pdest) {
1999
			_setPathDelimiter = sunch;
2000
			jvmpiAgent_changeDelimiter();
2001
		}
2002
	}
2003
#ifdef __OS400__
2004
#pragma convert(0) 
2005
#endif
2006
}
2007
2008
#ifdef __OS400__
2009
/** PROCESS_OBJECT_DUMP_EVENT  *************************************************
2010
  * Handles the output of a OBJECT_DUMP element and attributes along with any
2011
  * @param  event      - the event data provided by the JVM.
2012
  * @param isRequested - whether this event is generated as a result of a specific
2013
  *                      RequestEvent call.  If the event is requested it is assumed
2014
  *                      that the writelock is held for the hashtables.
2015
  */
2016
static void processObjectDumpEvent(JVMPI_Event *event,
2017
								  ThreadLocalStorage *tps,
2018
                                  BOOL isRequested,
2019
								  timestamp_t timestamp,
2020
								 timestamp_t cpu_timestamp) {
2021
2022
	if((_jvmpiAgent_Options.mode == TraceOptimizedHeap) && (event->u.object_dump.data_len > 0) &&
2023
		(event->u.object_dump.data[0] == JVMPI_GC_CLASS_DUMP)) {
2024
2025
		StatelessHeapSnapshotManager_objectDumpCallbackMethod(event);
2026
		return;
2027
	}
2028
2029
}
2030
#endif
2031
2032
/** PROCESS_CLASS_LOAD_EVENT  *************************************************
2033
  * Handles the output of a CLASS_LOAD element and attributes along with any
2034
  * associated METHOD, STATIC_FIELD and INSTANCE_FIELD elements.
2035
  * @param  event      - the event data provided by the JVM.
2036
  * @param isRequested - whether this event is generated as a result of a specific
2037
  *                      RequestEvent call.  If the event is requested it is assumed
2038
  *                      that the writelock is held for the hashtables.
2039
  */
2040
static void processClassLoadEvent(JVMPI_Event *event,
2041
								  ThreadLocalStorage *tps,
2042
                                  BOOL isRequested,
2043
								  timestamp_t timestamp,
2044
								  timestamp_t cpu_timestamp) {
2045
	char * buffer;
2046
	HashEntry *classHashEntry;
2047
2048
    if(_jvmpiAgent_Options.mode == TraceModeNone) {
2049
        return;
2050
    }
2051
	if(_jvmpiAgent_Options.mode == TraceOptimizedHeap) {
2052
		/* ToDo: We do not track callInfo currently
2053
		if (_jvmpiAgent_Options.classInfoCallback) {
2054
		*/
2055
		
2056
			/* Giri <Defect 78980/78981>: Sometimes, the IBM Classic VM sends
2057
			 * class load events with class_name set to NULL. Other fields are set correctly.
2058
			 * Handle these cases properly.
2059
			 *
2060
			 * Anandi Aug 2005 Fix Giri's fix, bugzilla 106779. 
2061
			 * Don't simply return when className is
2062
			 * NULL. Not calling StatelessHeapSnapshotManager_classInfoCallback leaves stale
2063
			 * values in the globals that the function sets and corrupts the parsing of
2064
			 * the heap. Anoint the class with a name and call 
2065
			 * StatelessHeapSnapshotManager_classInfoCallback. 
2066
			 * Also handle the empty string case. 
2067
			 *
2068
			 * Not thread-safe and that is OK. This code is conditional
2069
			 * on mode==TraceOptimizedHeap and that always runs in a single thread.
2070
			 * (JVMPI CLASS_LOAD events are not enabled from JVMPI; they only occur
2071
			 * when we ask for them, and we only ask from a single thread.)
2072
			 */
2073
			
2074
			if (event->u.class_load.class_name == NULL || 
2075
				(strlen(event->u.class_load.class_name) == 0)) {
2076
				sprintf(_classNameBuffer, "unknown%d", _unknownClassSuffix++);
2077
				StatelessHeapSnapshotManager_classInfoCallback(_classNameBuffer,
2078
						   event->u.class_load.num_interfaces,
2079
						   event->u.class_load.num_static_fields,
2080
						   event->u.class_load.statics);
2081
			} else {
2082
						
2083
				StatelessHeapSnapshotManager_classInfoCallback(event->u.class_load.class_name,
2084
						   event->u.class_load.num_interfaces,
2085
						   event->u.class_load.num_static_fields,
2086
						   event->u.class_load.statics);
2087
			}
2088
		/* } */
2089
		return;
2090
	}
2091
2092
	buffer = tps->buffer;
2093
2094
	
2095
	
2096
	/* If we haven't determined the path delimiter of this JVM try to use this
2097
	   class name to determine the delimiter.
2098
	*/
2099
	if(!_setPathDelimiter) {
2100
		setPathDelimiter((char*)event->u.class_load.class_name);
2101
	}
2102
2103
	
2104
2105
	/* Create the class symbol */
2106
	classHashEntry = jvmpiAgent_CreateClassSymbol(event, tps, jvmpiAgent_getFilter((char *)event->u.class_load.class_name, ""));
2107
2108
	
2109
2110
	/* RKD:  We print this class definition if we are traing this type or if we are asked
2111
	         to output classes irregardless of whether the are ever used.  Also, if this class
2112
			 has already had its class object printed then we should also print the class definition
2113
	*/
2114
	if (_jvmpiAgent_Options.unreferencedSymbols && CLASS_ENTRY(classHashEntry)->traceFlag) {
2115
		jvmpiAgent_outputClassDeclaration(classHashEntry, tps);
2116
		jvmpiAgent_printMethods((HashEntry **)CLASS_ENTRY(classHashEntry)->methods, CLASS_ENTRY(classHashEntry)->numMethods, tps);
2117
	}
2118
	/* DNS:  218494 - added this check back in so class is not output indiscrimantly */
2119
	else if(CLASS_ENTRY(classHashEntry)->classObject && CLASS_ENTRY(classHashEntry)->classObject->printed) {
2120
		jvmpiAgent_outputClassDeclaration(classHashEntry, tps);
2121
2122
	}
2123
2124
	if(!isRequested) {
2125
	  /* NMM: here is where we accumulate the tracing overhead due
2126
	     to classload processing */
2127
	  StackEntry* tos;
2128
	  if((tos=jvmpiAgent_Peek(tps, 0))
2129
	     && tos->entryEventSeen) {
2130
	    timestamp_t now;
2131
		timestamp_t cpu_now = 0;
2132
	    Uint64    classload_overhead;
2133
		Uint64    cpu_classload_overhead = 0; 
2134
2135
		if (_jvmpiAgent_Options.cpuTime) {
2136
			cpu_now = jvmpiAgent_getCurrentThreadCPUTime(); 
2137
			tps->last_cpu_timestamp = cpu_timestamp;	/* remember last known CPU time */
2138
			cpu_classload_overhead = TIMESTAMP_SUB(cpu_now,cpu_timestamp); 
2139
		}
2140
	    jvmpiAgent_getCurrentTime(&now);
2141
	    classload_overhead        = TIMESTAMP_SUB(now,timestamp);
2142
2143
	    tos->cumulative_overhead += classload_overhead;
2144
		tos->cumulative_cpu_overhead += cpu_classload_overhead; 
2145
2146
	  }
2147
	}
2148
2149
}
2150
2151
static void agRollUpStack(ThreadLocalStorage* tps,
2152
						  timestamp_t timestamp,
2153
						  timestamp_t cpu_timestamp)
2154
{
2155
	/* simulate an exit for the top frame - that is,
2156
	 * perform the same boookkeeping that a method exit would have.
2157
	 * All other frames have accurate baseTime already,
2158
	 * and agPop will update their cumulative times.
2159
	 */
2160
	int depth = 0;
2161
	StackEntry* stkentry = jvmpiAgent_Peek(tps, depth);
2162
	if (stkentry != NULL) {
2163
		TIMESTAMP_ADD(stkentry->baseTime, timestamp - stkentry->lastEntryTime);
2164
		DBG_CHK_AND_REPORT_TIME_OVERFLOW(stkentry->baseTime, "Time overflowed?! (agRollUpStack: stkentry->baseTime)\n"); /* 134577 */		
2165
2166
		/* Add last known CPU time on the thread to the frame's 
2167
		 * base CPU time, if it's greater. It might not be greater
2168
		 * because it's just a guess - the last time we updated
2169
		 * tps->last_cpu_timestamp for that thread. If the logic
2170
		 * that updates that value isn't perfect, then we
2171
		 * could be behind the times and we would add negative time.
2172
		 * In that case just don't add anything. 
2173
		 * 
2174
		 * This system always under-reports the CPU time of the top
2175
		 * frame on other threads, but we can't help that because we
2176
		 * don't have a platform-independent "get the CPU time on 
2177
		 * another thread" query.
2178
		 */
2179
		if (cpu_timestamp > stkentry->lastEntryCPUTime) {
2180
			TIMESTAMP_ADD(stkentry->baseCPUTime, cpu_timestamp - stkentry->lastEntryCPUTime);
2181
		}
2182
	}
2183
2184
	/* now call agPop for each active frame, to roll up data */
2185
	while ((stkentry = jvmpiAgent_Peek(tps, depth)) != NULL) {
2186
		jvmpiAgent_agPop(stkentry);
2187
		depth++;
2188
	}
2189
}
2190
2191
/** PROCESS_THREAD_END_EVENT  ***********************************************
2192
  * Handles thread end events from JVMPI.
2193
  */
2194
static void processThreadEndEvent(JVMPI_Event *event,
2195
								  ThreadLocalStorage *tps,
2196
                                  BOOL isRequested,
2197
								  timestamp_t timestamp,
2198
									timestamp_t cpu_timestamp) {
2199
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
2200
	dumpMethodEventCounts(); 
2201
	printf("processThreadEnd: tps, tps->calledList, _traceResourcesGone = %8x, %8x, %2d\n",
2202
			(void *)tps, (void *)tps->calledList, (int)_traceResourcesGone); fflush(stdout);
2203
#endif
2204
	/* In TraceTraceOptimizedHeap mode, we don't need any hashing */
2205
	if (_jvmpiAgent_Options.mode == TraceOptimizedHeap || _jvmpiAgent_Options.mode == TraceModeNone) {
2206
		/* do nothing */
2207
		return;
2208
	}
2209
2210
	if (_jvmpiAgent_Options.compressLevel==CompressAggregate) {
2211
		/* We are pre-aggregating: 
2212
		 * Roll up this stack, then report its data.
2213
		 *
2214
		 * We send the data now so the thread-exit notification occurs
2215
		 * in the proper sequence; if we saved up the data and sent
2216
		 * it later, we'd be sending agMethodEntry events on a thread
2217
		 * that had already been seen to exit.
2218
		 * 
2219
		 * Locking note: printThreadAgData will call getStackFrameStructureLock
2220
		 * because we're passing FALSE, saying we don't already have it.
2221
		 * See comments at printThreadAgData for why this is a shame.
2222
		 */
2223
		agRollUpStack(tps, timestamp, cpu_timestamp);
2224
		printThreadAgData(tps, FALSE);
2225
		removeThreadFromList(tps);
2226
	}
2227
2228
	jvmpiAgent_printThreadEndElement(event->env_id, tps);
2229
	jvmpiAgent_DestroyStack(event->env_id);
2230
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
2231
	printf("processThreadEnd: done!\n"); fflush(stdout);
2232
#endif
2233
}
2234
2235
2236
/** PROCESS_THREAD_START_EVENT  ***********************************************
2237
  * Handles thread start events from JVMPI.
2238
  */
2239
static void processThreadStartEvent(JVMPI_Event *event,
2240
									ThreadLocalStorage *tps,
2241
                                    BOOL isRequested,
2242
									timestamp_t timestamp,
2243
									timestamp_t cpu_timestamp) {
2244
	ThreadLocalStorage *tpsLocal = 0;
2245
	HashEntry *hashEntry;
2246
2247
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
2248
	dumpMethodEventCounts(); 
2249
	printf("processThreadStart: tps, tps->calledList, _traceResourcesGone = %8x, %8x, %2d\n",
2250
	(void *)tps, (void *)tps->calledList, (int)_traceResourcesGone); fflush(stdout);
2251
#endif
2252
2253
	/* In TraceTraceOptimizedHeap mode, we don't need any hashing */
2254
	if (_jvmpiAgent_Options.mode == TraceOptimizedHeap || _jvmpiAgent_Options.mode == TraceModeNone) {
2255
		/* do nothing */
2256
		return;
2257
	}
2258
2259
	/* Find the thread to determine if it already exists.  This should never happen. */
2260
	hashEntry = jvmpiAgent_FindThreadSymbol(event->env_id);
2261
2262
	/* If this is a new thread create a stack for it */
2263
	if (!hashEntry) {
2264
		hashEntry = jvmpiAgent_CreateStack(event->env_id);
2265
	}
2266
2267
2268
2269
2270
	tpsLocal = THREAD_ENTRY(hashEntry);
2271
2272
	/* 236501 begins */
2273
	tpsLocal->threadName = "";
2274
	tpsLocal->groupName = "";
2275
	tpsLocal->parentName = "" ;
2276
2277
	if(event->u.thread_start.thread_name) {
2278
		STRDUP(tps->threadName, event->u.thread_start.thread_name);
2279
	}
2280
	if(event->u.thread_start.group_name) {
2281
		STRDUP(tps->groupName, event->u.thread_start.group_name);
2282
	}
2283
	if(event->u.thread_start.parent_name) {
2284
		STRDUP(tps->parentName, event->u.thread_start.parent_name);
2285
	}
2286
	/* 236501 ends */
2287
2288
	tpsLocal->threadId = event->u.thread_start.thread_id;
2289
	tpsLocal->threadStartEventSeen = 1;
2290
	tpsLocal->threadStackKnown=0;
2291
    tpsLocal->disableEventsForThisThread=0;
2292
2293
	if(_jvmpiAgent_Options.compressLevel==CompressAggregate) {
2294
		/* we are pre-aggregating: add this thread to the list
2295
		 * of threads that we will want to dump data for when requested,
2296
		 * or when they die.
2297
		 */
2298
		addThreadToList(tpsLocal);
2299
	}
2300
2301
	if (hashEntry) { /* bugzilla 72292 */ 
2302
		if (!hashEntry->printed && event->env_id && THREAD_ENTRY(hashEntry)->threadStartEventSeen && _xmlHeadersPrinted) {
2303
			jvmpiAgent_printThreadStartElement(event->env_id, hashEntry);
2304
		}
2305
	}
2306
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
2307
	printf("processThreadStart: done!\n"); fflush(stdout);
2308
#endif
2309
}
2310
2311
/* pre-aggregation */
2312
2313
/* rollUpAndPrintAllThreadAgData
2314
 *
2315
 * This function rolls up all threads' stacks and prints their data.
2316
 * You use this when the JVM is shutting down, or as a final data dump
2317
 * when the user asks to detach from the target process.
2318
 *
2319
 * Note: I'm not sure what happens if you do this and then keep
2320
 * running the process and collecting more data. The live frame at the
2321
 * top of each stack will probably accumulate more baseTime, and when
2322
 * that frame exits the new baseTime will roll up into its callers AGAIN,
2323
 * so the time it had run before the first snapshot will get double-counted.
2324
 */
2325
void rollUpAndPrintAllThreadAgData(timestamp_t timestamp)
2326
{
2327
	/* Roll up stacks and emit data for living threads.
2328
	 * (Data for threads that have died has already been transmitted.)
2329
	 *
2330
	 * Notice that the cpu_timestamp we use for rolling up is the 
2331
	 * last_cpu_timestamp recorded for each thread.
2332
	 * That field in tps is updated for each event notification,
2333
	 * so we're acting like each thread has consumed zero
2334
	 * time since the last notification on that thread.
2335
	 * This is the best we can do because we can't ask
2336
	 * what the CPU time is on a thread other than the current thread.
2337
	 *
2338
	 * IMPORTANT LOCKING NOTE: the function dumpAllThreadStatistics
2339
	 * calls getThreadListLock, and on some platforms the lock 
2340
	 * implementation we get from the RAC shared libraries is the 
2341
	 * kind that you can't reenter. So we have to get that lock, 
2342
	 * roll up the live stack frames, then release it before calling
2343
	 * dumpAllThreadStatistics ... otherwise we'll deadlock on ourselves.
2344
	 * (The lock impl on Windows is reentrant, but not on Linux.)
2345
	 */
2346
	struct ThreadListElement * it;
2347
2348
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
2349
	dumpMethodEventCounts(); printf("rollUpAndPrintAllThreadAgData\n"); fflush(stdout);
2350
#endif
2351
	getThreadListLock();	/* see IMPORTANT LOCKING NOTE above */
2352
	it = threadsRoot;
2353
	while (it) {
2354
		ThreadPrivateStorage * target_tps = it->data;
2355
		if (target_tps != NULL) {
2356
			agRollUpStack(target_tps, timestamp, target_tps->last_cpu_timestamp);
2357
		}
2358
		it = it->next;
2359
	}
2360
	releaseThreadListLock();
2361
	printAllThreadAgData();
2362
}
2363
2364
/** PROCESSES_JVM_SHUTDOWN_EVENT  *********************************************
2365
  *
2366
  */
2367
static void processesJVMShutdownEvent(JVMPI_Event *event,
2368
									  ThreadLocalStorage *tps,
2369
                                      BOOL isRequested,
2370
									  timestamp_t timestamp,
2371
									timestamp_t cpu_timestamp) {
2372
	_jvmShutDown = (enum _BOOL)1;
2373
2374
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
2375
	dumpMethodEventCounts(); printf("processesJVMShutdownEvent\n"); fflush(stdout);
2376
#endif
2377
	/* If pre-aggregating, dump aggregated data for all living threads */
2378
	if (_jvmpiAgent_Options.compressLevel==CompressAggregate) {
2379
		rollUpAndPrintAllThreadAgData(timestamp);
2380
		/* Note: we leak StackFrames here for all living threads.
2381
		 * To fix this leak, call removeThreadFromList for all living threads.
2382
		 * But, in general, the process is coming down anyway,
2383
		 * so that would be a waste of time.
2384
		 */
2385
	}
2386
	jvmpiAgent_printJvmShutdownElement(event);
2387
#ifdef _DEBUG
2388
	if (_jvmpiAgent_Options.debugHash) {
2389
		jvmpiAgent_DumpHashTableStatistics();
2390
	}
2391
#endif
2392
2393
	cleanupAndExit(0);
2394
	ra_releaseVMLock();
2395
}
2396
2397
/** PROCESS_OBJ_MOVE_EVENT  ***************************************************
2398
  * Handler for object move events recieved during GC from JVMPI.
2399
  *
2400
  * The class id for the class associated with the object being moved is subject to change.
2401
  * In such cases, the hash entry for the associated class will also be moved.
2402
  */
2403
static void processObjMoveEvent(JVMPI_Event *event,
2404
								ThreadLocalStorage *tps,
2405
                                BOOL isRequested,
2406
								timestamp_t timestamp,
2407
									timestamp_t cpu_timestamp) {
2408
	
2409
	HashEntry *objectHashEntry;			/* Hash entry of the object being moved */
2410
	HashEntry *classHashEntry;			/* Hash entry of the class associated with the object being moved */
2411
2412
	if (_jvmpiAgent_Options.mode == TraceModeNone) {
2413
		return;
2414
	}
2415
2416
	if(_jvmpiAgent_Options.mode ==  TraceOptimizedHeap ) { /*58049*/
2417
	  return;
2418
	}
2419
	/* Find the object */
2420
	objectHashEntry = jvmpiAgent_FindObjectSymbol(event->u.obj_move.obj_id);
2421
2422
2423
	if (objectHashEntry) {
2424
		void *id; 
2425
		ObjectHashKey newId; 
2426
		newId.id = event->u.obj_move.new_obj_id; 
2427
		id = objectHashEntry->id; 
2428
2429
		/* Move the object hash entry and determine its associated class */
2430
		jvmpiAgent_MoveSymbol(objectHashEntry, Object_t, id, (void*)&newId);
2431
		
2432
		
2433
2434
		/* RJD- The following should be unnecessary. According to JVMPI spec, class id's 
2435
		   should also have their own object move events, and not be implicit as part of a regular
2436
		   object move. 
2437
		   
2438
		
2439
		classHashEntry = OBJECT_ENTRY(objectHashEntry)->classHashEntry;
2440
		if (classHashEntry)
2441
		{
2442
			// Mode 1: Resolve the class id for the object being requested.  The class id for
2443
			//   the object will be stored in the global variable '_resolvedClassId' 
2444
			tps->mode = 1;
2445
			REQUEST_EVENT2(JVMPI_EVENT_OBJECT_ALLOC, event->u.obj_move.new_obj_id);
2446
			tps->mode = 0;
2447
			
2448
			
2449
			// Move the class hash entry if necessary 
2450
			if (_resolvedClassId !=	CLASS_ENTRY(classHashEntry)->classId)
2451
				jvmpiAgent_MoveSymbol(classHashEntry, Class_t, (jint)_resolvedClassId);
2452
		}
2453
		*/ 
2454
2455
		/* We will only print object move for objects which we have already declared
2456
		   within the trace and if we have been asked to print object moves
2457
		*/
2458
2459
		if (objectHashEntry->printed && 
2460
			(_jvmpiAgent_Options.gc==GcMoves || _jvmpiAgent_Options.gc==GcDeletesAndMoves) &&
2461
			!_jvmpiAgent_suspendIO) {
2462
			jvmpiAgent_printObjMoveElement(event, objectHashEntry);
2463
		}
2464
	}
2465
	
2466
2467
	/* The object move may be that of a java.lang.Class instance, in which 
2468
	   case the class table must be updated as well */
2469
	classHashEntry = jvmpiAgent_FindClassSymbol(event->u.obj_move.obj_id);
2470
2471
	if (classHashEntry) {
2472
		void *id; 
2473
		ClassHashKey newId; 
2474
		newId.id = event->u.obj_move.new_obj_id; 
2475
		id = classHashEntry->id; 
2476
		jvmpiAgent_MoveSymbol(classHashEntry, Class_t, id,(void*)&newId); 
2477
	}
2478
2479
2480
2481
}
2482
2483
/** PROCESS_OBJ_FREE_EVENT  ***************************************************
2484
  * Handler for object free events recieved during GC from JVMPI.
2485
  */
2486
static void processObjFreeEvent(JVMPI_Event *event,
2487
								ThreadLocalStorage *tps,
2488
                                BOOL isRequested,
2489
								timestamp_t timestamp,
2490
								timestamp_t cpu_timestamp) {
2491
	HashEntry *objectHashEntry;
2492
2493
	if (_jvmpiAgent_Options.mode == TraceModeNone) {
2494
		return;
2495
	}
2496
2497
	if(_jvmpiAgent_Options.mode ==  TraceOptimizedHeap) { /*58049*/
2498
	  return;
2499
	}
2500
	/* Do we know of this object */
2501
	objectHashEntry = jvmpiAgent_FindObjectSymbol(event->u.obj_free.obj_id);
2502
	if (objectHashEntry) {
2503
		/* We will only print object move for objects which we have already declared
2504
		   within the trace and if we have been asked to print object free's
2505
		*/
2506
		if (objectHashEntry->printed && 
2507
			(_jvmpiAgent_Options.gc==GcDeletes || _jvmpiAgent_Options.gc==GcDeletesAndMoves) 
2508
			&& !_jvmpiAgent_suspendIO) { 
2509
				
2510
			jvmpiAgent_printObjFreeElement(jvmpiAgent_getThreadLocalStorage(event->env_id), objectHashEntry);
2511
		}
2512
2513
		/* Remove the object from the object hashtable */
2514
		jvmpiAgent_DeleteSymbol(objectHashEntry, Object_t);
2515
	}
2516
}
2517
2518
/** PROCESS_CLASS_UNLOAD_EVENT  ***********************************************
2519
  * Handle class unload events.
2520
  */
2521
static void processClassUnloadEvent(JVMPI_Event *event,
2522
									ThreadLocalStorage *tps,
2523
                                    BOOL isRequested,
2524
									timestamp_t timestamp,
2525
									timestamp_t cpu_timestamp) {
2526
	HashEntry *classHashEntry;
2527
	if (_jvmpiAgent_Options.mode == TraceModeNone) {
2528
		return;
2529
	}
2530
2531
	if(_jvmpiAgent_Options.mode ==  TraceOptimizedHeap ) {
2532
	  return;
2533
	}
2534
2535
	classHashEntry = jvmpiAgent_FindClassSymbol(event->u.class_unload.class_id);
2536
2537
	/* We will only print class unloads for classes which we have already declared
2538
	   within the trace
2539
	*/
2540
	if (classHashEntry) {
2541
		classHashEntry->deleted = 1; /* Mark as deleted */
2542
2543
		if (!_jvmpiAgent_suspendIO) {
2544
			jvmpiAgent_printClassUnloadElement(event, tps, classHashEntry);
2545
		}
2546
	}
2547
}
2548
2549
/** PROCESS_GC_START_EVENT  ***************************************************
2550
  * Handle GC start events.
2551
  */
2552
static void processGcStartEvent(JVMPI_Event *event,
2553
								ThreadLocalStorage *tps,
2554
                                BOOL isRequested,
2555
								timestamp_t timestamp,
2556
								timestamp_t cpu_timestamp) {
2557
	if (_jvmpiAgent_Options.mode == TraceModeNone) {
2558
		return;
2559
	}
2560
2561
	if(_jvmpiAgent_Options.mode ==  TraceOptimizedHeap) {
2562
	  /* do nothing */
2563
	  return;
2564
	}
2565
	if (!_jvmpiAgent_suspendIO) {
2566
		jvmpiAgent_printGcStartElement(event);
2567
	}
2568
}
2569
2570
/** PROCESS_GC_FINISH_EVENT  **************************************************
2571
  * Handle GC finish  events.
2572
  */
2573
static void processGcFinishEvent(JVMPI_Event *event,
2574
								 ThreadLocalStorage *tps,
2575
                                 BOOL isRequested,
2576
								 timestamp_t timestamp,
2577
									timestamp_t cpu_timestamp) {
2578
	if (_jvmpiAgent_Options.mode ==  TraceOptimizedHeap || _jvmpiAgent_Options.mode == TraceModeNone) {
2579
	  /* do nothing */
2580
	  return;
2581
	}
2582
	if (!_jvmpiAgent_suspendIO) {
2583
		jvmpiAgent_printGcFinishElement(event);
2584
	}
2585
}
2586
2587
/** PROCESS_OBJ_ALLOC_EVENT  **************************************************
2588
  *
2589
  */
2590
static void processObjAllocEvent(JVMPI_Event *event,
2591
								 ThreadLocalStorage *tps,
2592
								 BOOL isRequested,
2593
								 timestamp_t timestamp,
2594
								 timestamp_t cpu_timestamp)
2595
{
2596
 HashEntry *classHashEntry;
2597
 HashEntry *objectHashEntry;
2598
 BOOL allocatedOnTracedStackframe=FALSE;
2599
2600
 if (_jvmpiAgent_Options.mode ==  TraceOptimizedHeap || _jvmpiAgent_Options.mode == TraceModeNone) {
2601
	/* do nothing */
2602
	return;
2603
 }
2604
2605
 /* In case the mode of 'tps' is set to 1, then this handler will only need to resolve the class
2606
  * id of the object that has been dumped */
2607
 if (tps->mode == 1)
2608
 {
2609
	 _resolvedClassId = event->u.obj_alloc.class_id;
2610
	 return;
2611
 }
2612
2613
2614
 objectHashEntry = jvmpiAgent_FindObjectSymbol(event->u.obj_alloc.obj_id); 
2615
 if (objectHashEntry) {
2616
	 /* the object already exists, don't do anything */ 
2617
	 return; 
2618
 }
2619
2620
 /* RKD:  Determine if this object is being allocated on a traced stack frame
2621
  */
2622
  if(_jvmpiAgent_Options.stackInfo>StackInfoNone) {
2623
    StackEntry *tos;
2624
	if(tos=jvmpiAgent_Peek(tps, 0)) {
2625
	   allocatedOnTracedStackframe=(BOOL)(tos->printed);
2626
	}
2627
  }
2628
2629
2630
  /* RJD We normally shouldn't receive an OBJ_ALLOC with class_id == 0 and 
2631
     is_array = JVMPI_NORMAL_OBJECT; however, the Sun JVM seems to send 
2632
	 this for the object instance of java.lang.Class. 
2633
	 We handle this by assigning the class_id to the object_id (since the 
2634
	 object instance of java.lang.Class is clearly of type java.lang.Class).
2635
2636
	 Only do this when _requestClassObj is set (which should only be set 
2637
	 from a heap dump). Further, only do this when IsRequest bit is set to true. 
2638
	 This is a work around that may have some subtle concurrency issues crop up (because
2639
	 of bugs with different JVMs), so this should be kept in mind if examining a 
2640
	 future bug that seems to be a result of the following code. 
2641
	 bugzilla_57475 */ 
2642
2643
  if (!event->u.obj_alloc.class_id && 
2644
	  event->u.obj_alloc.is_array == JVMPI_NORMAL_OBJECT &&
2645
	  _requestClassObj && isRequested) {
2646
	  event->u.obj_alloc.class_id = event->u.obj_alloc.obj_id; 
2647
  }
2648
2649
2650
2651
 /* ##RKD:  We could have an object allocate and not know about it's class.  This
2652
            is a performance hit to look up the class whenever we get an object
2653
	        with unknown type..but I don't see any way around it right now.  Also
2654
			don't try and lookup primitive array classes as this fries the JVM.  As for
2655
			classes with a class id of "0", this is a documented limitation.  It
2656
			appears that the class id of all object arrays is always NULL.  If we have an
2657
			array object manually associate it with our spoofed  array class objects. We
2658
			only need to do this if the array object was explicitly asked for.
2659
 */
2660
 if(event->u.obj_alloc.class_id && (event->u.obj_alloc.is_array==JVMPI_NORMAL_OBJECT
2661
 #if !(defined  _HPUX || defined _SOLARIS)
2662
 || event->u.obj_alloc.is_array==JVMPI_CLASS) ) {
2663
 #else
2664
        )) {
2665
 #endif
2666
2667
	
2668
	classHashEntry = jvmpiAgent_FindClassSymbol(event->u.obj_alloc.class_id);
2669
	if(!classHashEntry) {
2670
		jint result;
2671
		result=REQUEST_EVENT2(JVMPI_EVENT_CLASS_LOAD, event->u.obj_alloc.class_id); /* 232010 */
2672
		/* Look up the class again*/
2673
		if(result == JVMPI_SUCCESS) {
2674
			classHashEntry = jvmpiAgent_FindClassSymbol(event->u.obj_alloc.class_id);
2675
		}
2676
	}
2677
2678
	/* Always add this object if we explicitly asked for it.  In filtered mode store it if
2679
	   we are tracing this type.  In triggered mode we will store it if it is on the stack.
2680
	*/
2681
	if(classHashEntry) {
2682
		if(_jvmpiAgent_Options.startMode==TraceStartModeFilter) {
2683
			if(CLASS_ENTRY(classHashEntry)->traceFlag || isRequested) {
2684
				objectHashEntry = jvmpiAgent_CreateObjectSymbol(event, (BOOL)(!isRequested), (BOOL)(!isRequested));
2685
				OBJECT_ENTRY(objectHashEntry)->classHashEntry=classHashEntry;
2686
2687
				/* Print this object only if we are tracing this type and we want object information */
2688
				if(OBJECT_ENTRY(objectHashEntry)->traceFlag && jvmpiAgent_isTracingHeap()) {
2689
				  jvmpiAgent_printObjAllocElement(objectHashEntry, event->env_id, 0);
2690
				}
2691
			}
2692
		}
2693
		else {
2694
			if(isRequested) {
2695
				objectHashEntry = jvmpiAgent_CreateObjectSymbol(event, FALSE, FALSE);
2696
				OBJECT_ENTRY(objectHashEntry)->classHashEntry=classHashEntry;
2697
			}
2698
			else if(allocatedOnTracedStackframe) {
2699
				objectHashEntry = jvmpiAgent_CreateObjectSymbol(event, TRUE, (BOOL)(!isRequested));
2700
				
2701
				OBJECT_ENTRY(objectHashEntry)->classHashEntry=classHashEntry;
2702
				jvmpiAgent_printObjAllocElement(objectHashEntry, event->env_id, 0);
2703
			}
2704
		}
2705
	}
2706
 }
2707
 /* This is a primative array. If we requested it's alloc event then create it's entries.  Also we print
2708
     primative array allocations if the current stack frame has been printed
2709
 */
2710
 else if(isRequested || allocatedOnTracedStackframe || _jvmpiAgent_Options.stackInfo==StackInfoNone) {
2711
    ObjectEntry *objectEntry;
2712
2713
/* RJD. The 1.3 JVM's on Solaris and HP crash when requesting a
2714
   JVMPI_EVENT_CLASS_LOAD event on class_id of array objects due to a bug in the JVM.
2715
   Thus, do not look up the
2716
   class in those cases. 
2717
   bugzilla_56189 */
2718
2719
2720
#if (defined  _HPUX || defined _SOLARIS)
2721
	if(event->u.obj_alloc.class_id && 
2722
		(_javaVersion != Version13 || event->u.obj_alloc.is_array!=JVMPI_CLASS)) {
2723
#else
2724
    if(event->u.obj_alloc.class_id) {
2725
#endif
2726
2727
        classHashEntry = jvmpiAgent_FindClassSymbol(event->u.obj_alloc.class_id);
2728
	    if(!classHashEntry) {
2729
		    jint result;
2730
		    result=REQUEST_EVENT2(JVMPI_EVENT_CLASS_LOAD, event->u.obj_alloc.class_id); /* 232010 */
2731
		    /* Look up the class again*/
2732
		    if(result == JVMPI_SUCCESS) {
2733
			    classHashEntry = jvmpiAgent_FindClassSymbol(event->u.obj_alloc.class_id);
2734
		    }
2735
2736
            objectHashEntry = jvmpiAgent_CreateObjectSymbol(event, FALSE, FALSE);
2737
			OBJECT_ENTRY(objectHashEntry)->classHashEntry=classHashEntry;
2738
	    }
2739
    }
2740
    else {
2741
        classHashEntry=jvmpiAgent_getPrimativeClassEntry(event->u.obj_alloc.is_array);
2742
        if(classHashEntry && CLASS_ENTRY(classHashEntry)->traceFlag && jvmpiAgent_isTracingHeap()) {
2743
            jvmpiAgent_outputClassDeclaration(classHashEntry, tps);
2744
            objectHashEntry = jvmpiAgent_CreateObjectSymbol(event, allocatedOnTracedStackframe, (BOOL)(!isRequested));
2745
	        objectEntry=OBJECT_ENTRY(objectHashEntry);
2746
            jvmpiAgent_printObjAllocElement(objectHashEntry, event->env_id, 0);
2747
         }
2748
    }
2749
 }
2750
2751
 if(!isRequested) {
2752
   /* NMM: here is where we accumulate the tracing overhead due to
2753
      object allocation processing */
2754
   StackEntry* tos;
2755
   if(tps
2756
      && (tos=jvmpiAgent_Peek(tps, 0))
2757
      && tos->entryEventSeen) {
2758
     timestamp_t now;
2759
	 timestamp_t cpu_now = 0; 
2760
     Uint64    objalloc_overhead;
2761
	 Uint64    cpu_objalloc_overhead = 0;
2762
	 	
2763
	 if (_jvmpiAgent_Options.cpuTime) {
2764
		 cpu_now = jvmpiAgent_getCurrentThreadCPUTime(); 		
2765
		 cpu_objalloc_overhead = TIMESTAMP_SUB(cpu_now,cpu_timestamp); 
2766
	 }
2767
2768
     jvmpiAgent_getCurrentTime(&now);
2769
     objalloc_overhead        = TIMESTAMP_SUB(now,timestamp);
2770
     tos->cumulative_overhead += objalloc_overhead;
2771
	 tos->cumulative_cpu_overhead += cpu_objalloc_overhead; 
2772
	 
2773
   }
2774
 }
2775
}
2776
2777
/** PROCESS_CLASS_LOAD_HOOK_EVENT  ********************************************
2778
  *
2779
  */
2780
static void processClassLoadHookEvent(JVMPI_Event *event,
2781
									  ThreadLocalStorage *tps,
2782
									  BOOL isRequested,
2783
									  timestamp_t timestamp,
2784
									  timestamp_t cpu_timestamp)
2785
{
2786
}
2787
2788
/** PROCESS_DATA_DUMP_REQUEST
2789
 * This is the kill-3 handler
2790
 */
2791
static void processDataDumpRequest(JVMPI_Event *event,
2792
				   ThreadLocalStorage *tps,
2793
				   BOOL isRequested,
2794
				   timestamp_t timestamp,
2795
					timestamp_t cpu_timestamp) {
2796
  if (_jvmpiAgent_Options.mode ==  TraceOptimizedHeap) {
2797
    /* status(KILL3_DUMP_REQUEST); */
2798
	_analyseOptHeap = TRUE ;
2799
    analyseHeap(JVMPI_DUMP_LEVEL_1);
2800
2801
	_analyseOptHeap = FALSE ;
2802
	_optHeapError = 0 ;
2803
  }
2804
  else if (_jvmpiAgent_Options.mode == TraceHeap) {
2805
    analyseHeap(JVMPI_DUMP_LEVEL_1);
2806
  }
2807
}
2808
2809
/* Piyush Agarwal */
2810
/* Optimized Heap Dump from RAC */
2811
/* We need to send the heapDumpFile Name to the RAC */
2812
static void sendHeapDumpInformation(char *filename){
2813
2814
	/* Giri: <Defect 64462> Added the standalone mode check, instead of isControlled check */
2815
	/* THe pring HD Start Element should be sent at the end after the heap dump is taken for optHeap */
2816
	
2817
	if ( _jvmpiAgent_Options.mode == TraceOptimizedHeap && !_jvmpiAgent_Options.standalone )
2818
	{
2819
		ThreadLocalStorage *tps=jvmpiAgent_getThreadLocalStorage(0);
2820
#ifdef __OS400__
2821
		/* Anandi  25 May 2004: The print routines expect ascii chars in 
2822
		   strings */
2823
		char *tmpname = as400_etoa(filename);
2824
		jvmpiAgent_printHDStartElement(tps,tmpname) ;
2825
		ra_free(tmpname);
2826
#else
2827
  /* Bug 64476 Added change for converting the name to ascii from ebcdic */
2828
  #ifdef MVS
2829
    __etoa(filename) ;
2830
  #endif
2831
		jvmpiAgent_printHDStartElement(tps,filename) ;
2832
  #ifdef MVS
2833
    __atoe(filename) ;
2834
  #endif
2835
#endif
2836
	/*Bug 82214*/
2837
	if (!_optHeapError && (optHeapContextId != -1)) {
2838
		sendHeapDumpEndMessage(_jvmpiAgent_bindingStorage,optHeapContextId,filename);
2839
	}
2840
	/*Bug 82214*/
2841
2842
	}
2843
}
2844
2845
static void processRACDataDumpRequest(BOOL finalheap,ra_uint_t contextId)
2846
{
2847
  optHeapContextId = contextId ;
2848
  if (_jvmpiAgent_Options.mode ==  TraceOptimizedHeap) {
2849
    /* Called From client */
2850
	/* We also need to send an empty heap dump header to the workbench */
2851
	_analyseOptHeap = TRUE ;
2852
	
2853
	analyseHeap(JVMPI_DUMP_LEVEL_1);
2854
	/* If this application is being controlled/moitored remotely */
2855
	if (!_jvmpiAgent_Options.standalone) {
2856
		if (_optHeapError)
2857
		{
2858
			sendOptHeapErrorMessage(_jvmpiAgent_bindingStorage, /* Piyush 58049 */
2859
				 			  contextId) ;
2860
		}
2861
		_optHeapError = 0 ;
2862
	}
2863
	_analyseOptHeap = FALSE ; 
2864
  }
2865
  optHeapContextId = -1 ;
2866
}
2867
2868
/* Send message to RAC which then sends it to the client */
2869
static void sendHeapDumpEndMessage(RA_AGENT_HANDLE handle,ra_uint_t contextId,char* filename)
2870
{
2871
	ra_message_t *message;
2872
	ra_command_t *command;
2873
	char *tmpMessageName ;
2874
2875
	message=ra_createMessage(RA_CONTROL_MESSAGE, 0);
2876
	command=ra_addCommandToMessage(message, NULL);
2877
2878
	/* Set the agent information */
2879
	command->tag= RA_CUSTOM_COMMAND ;
2880
	command->info.custom_command.context= contextId ;
2881
	command->info.custom_command.processId = ra_getProcessId();
2882
2883
/*Bug 64476*/
2884
#ifdef MVS
2885
#pragma convlit(suspend)
2886
#endif
2887
	tmpMessageName = (char *)malloc(sizeof("RA_OPT_HEAP_DUMP_DONE")+strlen(filename)+(2*sizeof(char))) ;
2888
	strcpy(tmpMessageName,"RA_OPT_HEAP_DUMP_DONE:") ;
2889
	strcat(tmpMessageName,filename) ;
2890
	ra_copyRASTRING(&command->info.custom_command.agent, &handle->agentName);
2891
	ra_createRASTRING(&command->info.custom_command.message,tmpMessageName);
2892
	free(tmpMessageName) ;
2893
#ifdef MVS
2894
#pragma convlit(resume)
2895
#endif
2896
2897
	/* Inform server about heap done */
2898
	ra_sendMessage(handle, message);
2899
	/* Clean up the allocated memory */
2900
	ra_destroyMessage(message, TRUE); 
2901
}
2902
2903
/* Send error message to RAC which then sends it to the client */
2904
/* Piyush 58049 */
2905
static void sendOptHeapErrorMessage(RA_AGENT_HANDLE handle,
2906
									ra_uint_t contextId)
2907
{
2908
	ra_message_t *message;
2909
	ra_command_t *command;
2910
2911
	message=ra_createMessage(RA_CONTROL_MESSAGE, 0);
2912
	command=ra_addCommandToMessage(message, NULL);
2913
2914
	/* Set the agent information */
2915
	command->tag= RA_CUSTOM_COMMAND ;
2916
	command->info.custom_command.context= contextId ;
2917
	command->info.custom_command.processId = ra_getProcessId();
2918
2919
/* Giri: Defect 70308 */
2920
#ifdef MVS
2921
#pragma convlit(suspend)
2922
#endif
2923
2924
	ra_copyRASTRING(&command->info.custom_command.agent, &handle->agentName);
2925
	switch (_optHeapError) {
2926
	  case RA_OPT_HEAP_DISK_FULL :
2927
		ra_createRASTRING(&command->info.custom_command.message, "RA_OPT_HEAP_DISK_FULL");
2928
		break ;
2929
	  case RA_OPT_HEAP_COULD_NOT_CREATE_FILE :
2930
		ra_createRASTRING(&command->info.custom_command.message, "RA_OPT_HEAP_COULD_NOT_CREATE_FILE");
2931
		break ;
2932
	}
2933
	
2934
/* Giri: Defect 70308 */	
2935
#ifdef MVS
2936
#pragma convlit(resume)
2937
#endif
2938
2939
	/* Inform server about heap done */
2940
	ra_sendMessage(handle, message);
2941
	/* Clean up the allocated memory */
2942
	ra_destroyMessage(message, TRUE); 
2943
}
2944
2945
/** PROCESS_HEAP_DUMP_EVENT  ***************************************************
2946
  * This is called by notify_event when we are getting a heap dump data as the
2947
  * result of a heap dump request.
2948
  */
2949
static void processHeapDumpEvent(JVMPI_Event *event,
2950
								 ThreadLocalStorage *tps,
2951
                                 BOOL isRequested,
2952
								 timestamp_t timestamp,
2953
									timestamp_t cpu_timestamp) {
2954
	
2955
        if (_jvmpiAgent_Options.mode == TraceModeNone) {
2956
                return;
2957
        }
2958
	
2959
	switch (event->u.heap_dump.dump_level) {
2960
		case JVMPI_DUMP_LEVEL_0:  /* we must have asked for a dump population */
2961
			if(_jvmpiAgent_Options.mode != TraceOptimizedHeap && _jvmpiAgent_isMonitored )
2962
			{
2963
				jvmpiAgent_markHeap(event);
2964
			}
2965
			break;
2966
		case JVMPI_DUMP_LEVEL_1:  /* we must have asked for a dump for references */
2967
			if(_jvmpiAgent_Options.mode ==  TraceOptimizedHeap && !_optHeapError ) { /*58049*/
2968
				_optHeapError = StatelessHeapSnapshotManager_handleHeapSnapshot_FromC(event->env_id,
2969
									  event->u.heap_dump.dump_level,
2970
									  event->u.heap_dump.begin,
2971
									  event->u.heap_dump.end);
2972
			} else {
2973
				jvmpiAgent_analyseHeap(event, _heapDefName);
2974
			}
2975
			break;
2976
		default:
2977
			break;
2978
	} /* dump_level switch */
2979
2980
}
2981
2982
2983
2984
2985
2986
/* long getOwnerThread(jobjectID object_id)
2987
2988
	Obtain the owner thread of the given monitor object
2989
2990
  args -
2991
    object_id - the object (monitor) whose thread owner is to be determined.
2992
	tps - thread local storage for storing monitor dump
2993
2994
  returns -
2995
    the thread that owns the given object
2996
*/
2997
2998
unsigned long getOwnerThread(jobjectID object_id, ThreadLocalStorage *tps) {
2999
3000
	int result = JVMPI_FAIL;
3001
3002
	tps->monitorObj = object_id; 
3003
	if (object_id != 0) {
3004
3005
		/* Requesting MONITOR_DUMP in IBM 1.4.x JVM's prior to 1.4.2 cause
3006
		   the JVM to crash. Do not  request a JVMPI_EVENT_MONITOR_DUMP in those cases */ 
3007
		if (!(_javaVendor == VendorIBM && 
3008
			 (_javaVersion == Version140 || _javaVersion == Version141))) {
3009
		
3010
				result = REQUEST_EVENT(JVMPI_EVENT_MONITOR_DUMP,0);
3011
		}
3012
3013
	}
3014
3015
	if (result == JVMPI_SUCCESS) {
3016
		/* the owner thread is set in the tps->ownerThread variable upon return
3017
		   from the monitor dump request */ 
3018
		return tps->ownerThread; 
3019
	}
3020
3021
	return 0;
3022
3023
}
3024
3025
3026
static void processMonitorDumpEvent(JVMPI_Event *event,
3027
								 ThreadLocalStorage *tps,
3028
                                 BOOL isRequested,
3029
								 timestamp_t timestamp,
3030
									timestamp_t cpu_timestamp) {
3031
	
3032
	tps->ownerThread = jvmpiAgent_analyseMonitorDump(event,tps->monitorObj); 
3033
}
3034
3035
static void processMonitorContendedEnter(JVMPI_Event *event,
3036
								 ThreadLocalStorage *tps,
3037
                                 BOOL isRequested,
3038
								 timestamp_t timestamp,
3039
									timestamp_t cpu_timestamp) {
3040
3041
	HashEntry *objectHashEntry = 0; /* hash entry corresponding to the monitor object */
3042
	unsigned long thread_owner = 0;
3043
3044
	/* determine the thread that currently owns the monitor */ 
3045
	thread_owner = getOwnerThread(event->u.monitor.object,tps);
3046
	
3047
	
3048
	/* lookup monitor object, ensuring that it exists in the trace */
3049
	objectHashEntry = jvmpiAgent_FindObjectSymbolWithAllocateAndPrint(event->env_id,
3050
		event->u.monitor.object);
3051
	
3052
3053
	if (objectHashEntry) {
3054
		jvmpiAgent_printMonitorContendedEnterElement(objectHashEntry, event,
3055
			thread_owner, timestamp);
3056
	}
3057
3058
}
3059
3060
static void processMonitorContendedEntered(JVMPI_Event *event,
3061
								 ThreadLocalStorage *tps,
3062
                                 BOOL isRequested,
3063
								 timestamp_t timestamp,
3064
									timestamp_t cpu_timestamp) {
3065
3066
	HashEntry *objectHashEntry = 0; /* hash entry corresponding to the monitor object */	
3067
	
3068
	/* lookup monitor object, ensuring that it exists in the trace */
3069
	objectHashEntry = jvmpiAgent_FindObjectSymbolWithAllocateAndPrint(event->env_id,
3070
		event->u.monitor.object);
3071
	
3072
3073
	if (objectHashEntry) {
3074
		jvmpiAgent_printMonitorContendedEnteredElement(objectHashEntry, event, timestamp);
3075
	}
3076
3077
}
3078
3079
static void processMonitorContendedExit(JVMPI_Event *event,
3080
								 ThreadLocalStorage *tps,
3081
                                 BOOL isRequested,
3082
								 timestamp_t timestamp) {
3083
	/* currently not required according to BlueRat specs; stub in place since it might
3084
	be useful */
3085
}
3086
3087
static void processMonitorWait(JVMPI_Event *event,
3088
								 ThreadLocalStorage *tps,
3089
                                 BOOL isRequested,
3090
								 timestamp_t timestamp,
3091
									timestamp_t cpu_timestamp) {
3092
3093
	HashEntry *objectHashEntry = 0; /* hash entry corresponding to the monitor object */
3094
	int isThreadSleep = 0;			/* boolean indicating if monitor wait occured in thread
3095
									   sleep */
3096
3097
3098
	
3099
	/* if the monitor object is NOT NULL, it is a regular object,
3100
	   if it is NULL, then it indicates that the wait is in Thread.sleep() */
3101
3102
	if ((void *) event->u.monitor_wait.object != NULL) {
3103
		/* lookup monitor object, ensuring that it exists in the trace */
3104
		objectHashEntry = jvmpiAgent_FindObjectSymbolWithAllocateAndPrint(event->env_id,
3105
			event->u.monitor.object);
3106
	}
3107
	else {
3108
		isThreadSleep = 1;
3109
	}
3110
3111
	/* print the element only if we managed to resolve the hash entry for the monitor
3112
	   object, or if the the monitor waited event was due to Thread.sleep(). */
3113
	if (objectHashEntry || isThreadSleep) {
3114
		jvmpiAgent_printMonitorWaitElement(objectHashEntry, event, timestamp, isThreadSleep);
3115
	}
3116
3117
3118
}
3119
3120
static void processMonitorWaited(JVMPI_Event *event,
3121
								 ThreadLocalStorage *tps,
3122
                                 BOOL isRequested,
3123
								 timestamp_t timestamp,
3124
									timestamp_t cpu_timestamp) {
3125
3126
3127
	HashEntry *objectHashEntry = 0; /* hash entry corresponding to the monitor object */
3128
	int isThreadSleep = 0;			/* boolean indicating if monitor wait occured in thread
3129
									   sleep */
3130
3131
	/* if the monitor object is not NULL, it is a regular object,
3132
	   if it is NULL, then it indicates that the wait is in Thread.sleep() */
3133
3134
	if ((void *) event->u.monitor_wait.object != NULL) {
3135
		/* lookup monitor object, ensuring that it exists in the trace */
3136
		objectHashEntry = jvmpiAgent_FindObjectSymbolWithAllocateAndPrint(event->env_id,
3137
			event->u.monitor.object);
3138
	}
3139
	else {
3140
		isThreadSleep = 1;
3141
	}
3142
	
3143
	/* print the element only if we managed to resolve the hash entry for the monitor
3144
	  object, or if the the monitor waited event was due to Thread.sleep(). */
3145
	if (objectHashEntry || isThreadSleep) {
3146
		jvmpiAgent_printMonitorWaitedElement(objectHashEntry, event, timestamp,isThreadSleep);
3147
	}
3148
3149
}
3150
3151
3152
/** NOTIFY_EVENT  -- JVMPI EVENT HANDLER FUNCTION  *****************************
3153
  * This is the entry point for all events from the JVMPI interface.  These
3154
  * events may be because of registered events or specific requested events.
3155
  * from here we jump to the specific handler for each event.
3156
  */
3157
static void notify_event(JVMPI_Event *event) {
3158
	BOOL isRequested=FALSE;
3159
	timestamp_t timestamp;
3160
	timestamp_t cpu_timestamp = 0; 
3161
	jint masked_event_type = event->event_type & (0xffffffff ^  JVMPI_REQUESTED_EVENT);
3162
3163
	/* Get the tps */
3164
	ThreadPrivateStorage *tps=jvmpiAgent_getThreadLocalStorage(event->env_id);
3165
3166
	/* Get the timestamp */
3167
	jvmpiAgent_getCurrentTime(&timestamp);
3168
	if (_jvmpiAgent_Options.cpuTime) {
3169
		cpu_timestamp = jvmpiAgent_getCurrentThreadCPUTime(); 
3170
3171
		/* record the last CPU timestamp on this thread; we'll need this later.
3172
		 * (Actually, it's only needed if pre-aggregating (CompressAggregate), but
3173
		 * testing that would slow this function down unnecessarily.)
3174
		 */
3175
		tps->last_cpu_timestamp = cpu_timestamp;
3176
	}
3177
3178
	/* Check for disablement. Note: today (3/29/04) no code disables events */
3179
	if(tps->disableEventsForThisThread) {
3180
        return;
3181
    }
3182
3183
	/*------------------------------------------------------------
3184
	 * Route this event to an agent extension if one is listening.
3185
	 * This is a simple dispatcher system with no advanced logic
3186
	 * for (e.g.) sending requested events to the requesting agent only.
3187
	 *
3188
	 * Agent extensions get events regardless of thread or burst timeout.
3189
	 * They get the event pointer plus their own thread local storage pointer.
3190
	 */
3191
	if (agent_extension_handlers[masked_event_type] != NULL) {
3192
		agent_extension_handlers[masked_event_type](event, &(tps->agent_extension_slot));
3193
	}
3194
	/*------------------------------------------------------------*/
3195
3196
	/* Just route the event to the appropriate event handler function */
3197
	if(event->event_type & JVMPI_REQUESTED_EVENT)  {
3198
		event->event_type=masked_event_type;
3199
		isRequested=TRUE;
3200
	}
3201
	else {
3202
		
3203
		/* If we are in burst timeout then stop tracing now */
3204
		if(_jvmpiAgent_burstTimeoutSet) {
3205
			if(TIMESTAMP_GREATER(timestamp,_burstTimeout)) {
3206
				suspendTracing(TracePause);
3207
			}
3208
		}
3209
3210
		/* If we are in single threaded tracing ignore this event if it isn't on the proper thread.  Can't do
3211
		   this if we are insturmenting code though
3212
		*/
3213
		if(event->event_type!=JVMPI_EVENT_CLASS_LOAD_HOOK
3214
			&& _jvmpiAgent_singleThreaded
3215
			&& _jvmpiAgent_limitingThread!=event->env_id) {
3216
			return;
3217
		}
3218
	}
3219
3220
	/* Check for null: maybe only an agent extension has a handler */
3221
	if (_processEventFunction[event->event_type] != NULL) {
3222
		_processEventFunction[event->event_type](event, tps, isRequested, timestamp,cpu_timestamp);
3223
	}
3224
}
3225
3226
3227
/** AGENT_EXTENSION_SET_EVENT_HANDLER *******************************************************
3228
  * Remember an agent extension's handler for an event.
3229
  *
3230
  * This function is called from agent extensions. The agent extension
3231
  * calls this function to set a handler and enable the corresponding
3232
  * JVMPI event.
3233
  * 
3234
  * In stand-alone mode, this function actually calls JVMPI to enable the event.
3235
  *
3236
  * But in non-standalone mode, if isJVMInitDone is still false,
3237
  * we don't enable the event. Instead, we just record the extension's
3238
  * desire to handle the event. Later we will loop through and enable
3239
  * the events that the extension asked for.
3240
  *
3241
  * Why? Because in non-standalone mode, the agent extension's init function
3242
  * is calling us from a different thread - not the main thread that JVM_OnLoad
3243
  * was called on. If you try to enable events from this other thread,
3244
  * the JVM crashes.
3245
  *
3246
  * Rather than needlessly attaching threads to the JVM (and risk having
3247
  * them stay attached too long, or detach too soon), I decided to queue 
3248
  * up the "enable" operations and process them in the main (OnLoad) thread 
3249
  * after the listener gets unblocked - that is, when Workbench sends RESUME.
3250
  *
3251
  * In standalone mode, this system is not necessary because the extension
3252
  * agent init function is called from the main thread, where OnLoad is running.
3253
  *
3254
  * This system isn't used in "enabled" or "application" mode. In those
3255
  * modes, ra_startListener doesn't block, so it doesn't work to queue the 
3256
  * requests and handle them when ra_startListener returns. But it's
3257
  * also not a standalone mode, meaning commands will come in on the
3258
  * listener thread (and calling enableEvent on a separate thread is bad).
3259
  *
3260
  * The agent_extension_init function gets a flag telling the extension
3261
  * whether it's safe to call enable_event_handler. It's safe in standalone
3262
  * mode, and in controlled mode, but not in application mode or enabled mode.
3263
  * 
3264
  * One way to make sure it's safe is to start a new thread, attach that
3265
  * thread to the JVM, make the SetEventHandler call, detach the thread,
3266
  * then let the thread die.
3267
  */
3268
static void agentExtensionSetEventHandler(jint event_type,
3269
									AgentExtensionEventHandler handler) {
3270
    agent_extension_handlers[event_type] = handler;
3271
	if (_jvmpiAgent_Options.standalone || _jvmpiAgent_isListenerUnblocked) {
3272
		_jvmpiAgent_jvmpiInterface->EnableEvent(event_type, 0);
3273
	}
3274
}
3275
3276
/** AGENT_EXTENSION_SET_COMMAND_HANDLER *******************************************************
3277
  * Records an agent extension's handler for RAC commands.
3278
  */
3279
static void agentExtensionSetCommandHandler(void (*handler)(ra_command_t *command)) {
3280
	agent_extension_command_handler = handler;
3281
}
3282
3283
3284
/** LOAD_STACK  ****************************************************************
3285
  * The intention of this method is to materialize a single thread stack
3286
  * within the JVM.  This would be used when doing stack sampling and when
3287
  * starting a trace at some arbitrary point during execution.  The problem is...
3288
  * the IBM JVM often returns the wrong stack.  Furthermore, it does not support
3289
  * asynchronous stack traversal so this needs to be called on the thread
3290
  * that is being loaded.
3291
  *
3292
  * The bug on IBM JDK's appears to be that information missing after a stack
3293
  * load is always at the top of the stack.  Broken stack frame links due to
3294
  * the JIT is the cause.
3295
  */
3296
static void loadStack(ThreadPrivateStorage *tps)
3297
{
3298
  int i;
3299
  JVMPI_CallTrace callTrace;
3300
  timestamp_t now;
3301
  timestamp_t cpu_now = 0; 
3302
  StackFrame *it, *calledListOfCaller; /* pre-agg: 134635 */
3303
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
3304
  dumpMethodEventCounts(); printf("LoadStack: tps = %8x\n", (void *)tps); fflush(stdout);
3305
#endif
3306
3307
  /* Ignore the Global thread */
3308
  if(!tps->env)
3309
  {
3310
	return;
3311
  }
3312
3313
3314
  jvmpiAgent_getCurrentTime(&now);
3315
  if (_jvmpiAgent_Options.cpuTime) {
3316
	  cpu_now = jvmpiAgent_getCurrentThreadCPUTime(); 
3317
	  tps->last_cpu_timestamp = cpu_now; 	/* remember last known CPU time */
3318
  }
3319
3320
  callTrace.frames=(JVMPI_CallFrame*)malloc(400*sizeof(JVMPI_CallFrame));
3321
  callTrace.env_id=tps->env;
3322
  _jvmpiAgent_jvmpiInterface->GetCallTrace(&callTrace, 400);
3323
  calledListOfCaller=tps->calledList;  /* pre-agg: 134635 */
3324
  for(i=callTrace.num_frames-1; i>=0; i--)
3325
  {
3326
	  HashEntry *methodHashEntry;
3327
	  StackEntry *stackEntry;
3328
	  methodHashEntry=jvmpiAgent_FindMethodSymbol((callTrace.frames[i].method_id));
3329
3330
	  /* If we don't know about the method we should get the class */
3331
	  if(!methodHashEntry)
3332
	  {
3333
		int result;
3334
		jobjectID clazz=_jvmpiAgent_jvmpiInterface->GetMethodClass(callTrace.frames[i].method_id);
3335
		result=REQUEST_EVENT2(JVMPI_EVENT_CLASS_LOAD, clazz); /* 232010 */
3336
		/* If we found the class we should have the method */
3337
		if(result == JVMPI_SUCCESS) {
3338
			methodHashEntry = jvmpiAgent_FindMethodSymbol((callTrace.frames[i].method_id));
3339
		}
3340
	  }
3341
	  stackEntry=jvmpiAgent_Push(tps, tps->env, methodHashEntry ,NULL, now,cpu_now);
3342
	  stackEntry->entryEventSeen=0;
3343
3344
      /* 134635 */
3345
      /* Note that, before pre-agg was supported, filtering was not tested for and methodEntryEvents 
3346
       * were not printed for these re-constructed method invocations. However, any 
3347
       * MethodEntryEvents emitted from a previous run of this thread were still in effect and 
3348
       * resumption of the thread picked-up where the last one left off. To get the same effect in 
3349
       * the pre-agg case, it's necessary to determine if any of the thread's pre-existing 
3350
       * calledList trees/sub-trees (from a previous run of the thread) has a record of the currrent 
3351
       * call sequence being loaded (or of any starting portion thereof). If so, those stackEntries 
3352
       * represented in the calledList tree will be connected to the corresponding stackFrames in 
3353
       * that tree (and are marked as "realFrames" and "printed"). This occurs after a resume that 
3354
       * follows a pause but *not* after an attach that follows a detach (because, in the 
3355
       * detach/attach case, the calledList tree will have been cleared/freed by the detach).
3356
       */
3357
      if (_jvmpiAgent_Options.compressLevel==CompressAggregate) {  /* pre-agg: 134635 */ 
3358
         /* search for current method in calledList of Caller: if found, it will be a non-null "it"              */
3359
         for (it=calledListOfCaller; it!=NULL && it->methodHashEntry!=methodHashEntry; it=it->next);  
3360
         
3361
         if (it != NULL) { /* if it!=NULL then the current method was found as a child of the caller frame        */
3362
         	stackEntry->stackFrame = it;          /* connect the current stack entry to the found frame           */
3363
           	stackEntry->realFrame = 1;            /* treat almost as a CreateStackFrame operation        * 139537 */
3364
        	stackEntry->printed = 1;              /* treat almost as a CreateStackFrame operation        * 139537 */
3365
            calledListOfCaller = it->calledList;  /* the next stack entry's method will need to one of this frame's    
3366
                                                   * children for the repeated starting call sequence to continue */
3367
         } else {                                                                                       /* 139537 */
3368
         	calledListOfCaller = NULL;            /* this terminates the repeated starting call sequence * 139537 */
3369
         }
3370
      }
3371
  }
3372
  free(callTrace.frames);
3373
3374
  /* RKD:  Mark this thread as a valid thread only if the thread stack is depth is greater then zero.  This check
3375
           needs to be here as the JIT in some IBM JDKS doesn't always give the stack information when you invoke
3376
           GetCallTrace()
3377
  */
3378
  if(callTrace.num_frames > 0)
3379
  {
3380
    tps->threadStackKnown=1;
3381
	/* pre-agg: add this thread to the list of threads that we will want to 
3382
	 * dump data for when requested, or when they die.
3383
	 */
3384
    if(_jvmpiAgent_Options.compressLevel==CompressAggregate) {  /* pre-agg: 134635 */
3385
		addThreadToList(tps);
3386
	}
3387
  }
3388
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
3389
  dumpMethodEventCounts(); printf("LoadStack: tps = %8x Done!\n", (void *)tps); fflush(stdout);
3390
#endif
3391
3392
3393
  return;
3394
}
3395
3396
/** STACK_CLEANER  ************************************************************
3397
  * Walk a stack and cleanup all the memory in use.
3398
  */
3399
int stackCleaner(HashEntry *hashEntry,
3400
                 void *parm) {
3401
	ThreadPrivateStorage *tps;
3402
	tps=(ThreadPrivateStorage*)THREAD_ENTRY(hashEntry);
3403
3404
	/* Pop all the entries on the stack */
3405
	while(tps->tos) {
3406
		jvmpiAgent_Pop(tps);
3407
	}
3408
	/* Mark this thread as an invalid thread */
3409
	tps->threadStackKnown=0;
3410
3411
	return 0;
3412
}
3413
3414
3415
/** DELETE_HASH_ENTRY  *********************************************************
3416
  *
3417
  */
3418
int deleteHashEntry(HashEntry *entry,
3419
                    void *param) {
3420
	jvmpiAgent_DeleteSymbol(entry, (*(enum EntryType*)param));
3421
	return 0;
3422
}
3423
3424
3425
3426
3427
/** CLEAN_UP_ALL_TRACE_ROSOURCES  **********************************************
3428
  * Cleanup all our resources that were allocated during a trace so that we have
3429
  * no history of events/objects to refer to.  With this done we can start a new
3430
  * trace.
3431
  */
3432
static void cleanUpAllTraceResources() {
3433
	enum EntryType type;
3434
3435
	_traceResourcesGone = TRUE;  /* pre-agg: 134635 */
3436
3437
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
3438
	printf("cleanUpAllTraceResources\n"); fflush(stdout);
3439
#endif
3440
	/* Delete each of the objects */
3441
	type=Object_t;
3442
	jvmpiAgent_ForAll(Object_t, deleteHashEntry, &type);
3443
3444
	/* 174841 - RKD:  Always keep the state of threads
3445
	   so that the stack can be re-materialized later if
3446
	   necessary
3447
	type=Thread_t;
3448
	jvmpiAgent_ForAll(Thread_t, deleteHashEntry, &type);
3449
	174841 end */
3450
3451
	/* pre-aggregation */
3452
	/* Remove all threads from the "threadsRoot" list of live threads.
3453
	 * This will free the StackFrames pointed to by the threads,
3454
	 * and set all tps->callerList to NULL.
3455
     *
3456
	 * Note that threadEnds sometimes occur even after Detach/cleanup.
3457
	 * Thus, removeThreadFromList could be underway on multiple "threads"
3458
	 * but the ThreadList lock combined with the traceResourcesGone flag
3459
	 * should be sufficient to provide correct operation even in that
3460
	 * scenario.
3461
	 */
3462
	if (_jvmpiAgent_Options.compressLevel==CompressAggregate) { /* 134635 */ 
3463
		while (threadsRoot != NULL) {
3464
			removeThreadFromList(threadsRoot->data);
3465
		}
3466
	}	
3467
3468
	/* Delete each of the classes */
3469
	type=Class_t;
3470
	jvmpiAgent_ForAll(Class_t, deleteHashEntry, &type);
3471
3472
	/* Delete each of the methods */
3473
	type=Method_t;
3474
	jvmpiAgent_ForAll(Method_t, deleteHashEntry, &type);
3475
3476
	/* deleting the class hashtable will have also removed the primitive types;
3477
	   if someone reattaches to the profiler, the primitive types will not be
3478
	   regenerated automatically. Hence, we must regenerate them now. */
3479
	
3480
	createPrimitiveTypes();
3481
}
3482
3483
3484
/** START_TRACING  *************************************************************
3485
  * This is the entry point which must be called to start a trace. It takes
3486
  * care of emitting all the header information and turning the JVMPI events
3487
  * on so we will start recieving events.
3488
  */
3489
static void startTracing(BOOL standalone) {
3490
3491
	_jvmpiAgent_suspendIO = 0;
3492
	_traceResourcesGone = FALSE;  /* pre-agg: 134635 */
3493
3494
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
3495
	printf("startTracing\n"); fflush(stdout);
3496
#endif
3497
	
3498
	/**	Giri: <Defect 64462> We need to do some optHeap related setup, before we can request opt Heap dumps
3499
	So we do the required set-up if the mode is TraceOptimizedHeap */
3500
3501
	if (_jvmpiAgent_Options.mode == TraceOptimizedHeap )	{
3502
		jvmpiAgent_DoOptHeapSetup();
3503
	}
3504
	
3505
	jvmpiAgent_PrintStartingXMLFragments();
3506
    _xmlHeadersPrinted=TRUE;
3507
3508
 	/* We need to ensure the entire sybmol table is "unreferenced" to ensure we get the references
3509
			   for all method invocations for this trace.
3510
	 */
3511
	jvmpiAgent_clearAllPrintFlags();
3512
3513
	/* Reset the trigger flag if we are not running in application mode. */
3514
	if(!_jvmpiAgent_Options.application) {
3515
		_triggerSqueezed=FALSE;
3516
	}
3517
	else {
3518
		_jvmpiAgent_Options.startMode=TraceStartModeTriggerMultiThreaded;
3519
	}
3520
3521
	resumeTracing();	
3522
}
3523
3524
static void resumeTracing() {
3525
3526
	/* Turn on IO */
3527
	_jvmpiAgent_suspendIO = 0;
3528
3529
	/* If we are burst tracing set the burst information */
3530
	if(_jvmpiAgent_Options.burstMode>BurstModeNone) {
3531
		switch(_jvmpiAgent_Options.burstMode) {
3532
		case BurstModeInvocations:
3533
			_invocationCountRemaining=_jvmpiAgent_Options.burstInvocations;
3534
			break;
3535
		case BurstModeSeconds:
3536
		  {
3537
		    timestamp_t ticks;
3538
			jvmpiAgent_getCurrentTime(&_burstTimeout);
3539
			ticks = timeToTicks(_jvmpiAgent_Options.burstSeconds, 0);
3540
			TIMESTAMP_ADD(_burstTimeout,ticks);
3541
			_jvmpiAgent_burstTimeoutSet=TRUE;
3542
			break;
3543
		  }
3544
		case BurstModeSecondsAndInvocations:
3545
		  {
3546
		  timestamp_t ticks;
3547
			_invocationCountRemaining=_jvmpiAgent_Options.burstInvocations;
3548
			ticks = timeToTicks(_jvmpiAgent_Options.burstSeconds, 0);
3549
			jvmpiAgent_getCurrentTime(&_burstTimeout);
3550
			TIMESTAMP_ADD(_burstTimeout,ticks);
3551
			_jvmpiAgent_burstTimeoutSet=TRUE;
3552
		  }
3553
		}	
3554
	}
3555
3556
	_jvmpiAgent_isSuspended=FALSE;
3557
3558
	/* Enable the events */
3559
  	toggleActiveJvmpiEvents(TraceON);
3560
}
3561
3562
3563
/** SUSPEND_TRACING  ***********************************************************
3564
  *
3565
  * toggle - TraceOFF - completely turning off tracing
3566
  *          TracePause - pausing tracing 
3567
  */
3568
static void suspendTracing(TraceToggle toggle) {
3569
3570
	/* pre-aggregation:  
3571
	 * Roll up stacks in live threads and report their data. This applies both 
3572
	 * to Pause (RA_STOP_MONITORING_AGENT) and to Detach (RA_DETACH_FROM_AGENT).
3573
	 * NB: the agPops triggered in this stack rollup break the links between the
3574
	 *     stackEntries and corresponding stackFrames. This ensures that the 
3575
	 *     agPops from the stackCleaner below do nothing and thus avoid a double
3576
	 *     rollup that would produce double counts. (See jvmpiAgent_agPop.)
3577
	 */
3578
	if (_jvmpiAgent_Options.compressLevel==CompressAggregate) {  /* 134635 */
3579
		/* pre-agg mode; roll up stacks and dump data */
3580
		timestamp_t now;
3581
		jvmpiAgent_getCurrentTime(&now);
3582
		rollUpAndPrintAllThreadAgData(now);
3583
	}
3584
3585
	/* Turn off IO */
3586
	_jvmpiAgent_suspendIO = 1;
3587
	
3588
	/* Disable the events */
3589
	toggleActiveJvmpiEvents(toggle);
3590
3591
	_jvmpiAgent_burstTimeoutSet=FALSE;
3592
3593
	_jvmpiAgent_isSuspended=TRUE;
3594
	_triggerSqueezed=FALSE;
3595
3596
	/* We need to destroy the stacks */
3597
	jvmpiAgent_ForAll(Thread_t, stackCleaner, NULL);
3598
}
3599
3600
/** STOP_TRACING  **************************************************************
3601
  * This is where a trace is stopped.
3602
  */
3603
static void stopTracing() {
3604
	/* Get the global buffer for IO */
3605
	ThreadLocalStorage *tps=jvmpiAgent_getThreadLocalStorage(0);
3606
3607
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
3608
	printf("stopTracing\n"); fflush(stdout);
3609
#endif
3610
3611
	/* Print the TRACE_END element */
3612
    jvmpiAgent_printTraceEndElement(tps);
3613
3614
	suspendTracing(TraceOFF);
3615
3616
	/* Clean up all our resources for this trace */
3617
	cleanUpAllTraceResources();
3618
3619
	_jvmpiAgent_isSuspended=FALSE;
3620
3621
}
3622
3623
3624
/** determineJavaVersion() **********************************************************
3625
 * Determine the java vendor and version so that we can disable certain functionality
3626
 * based on the runtime version to avoid jvm bugs. 
3627
 *
3628
 * @param env the JNIEnv * to use for the JNI calls 
3629
 */ 
3630
#ifdef __OS400__
3631
#pragma convert(819)
3632
#endif
3633
static void determineJavaVersion(JNIEnv *env) {
3634
	
3635
	/* The basic approach is to call System.getProperty("java.version") and
3636
	   System.getProperty("java.vendor") through JNI. If any sort of failure
3637
	   occurs while doing JNI, the behaviour of this method is to fail immediately
3638
	   and return to the caller. */ 
3639
3640
	jclass javaLangSystem;			/* java.lang.System class */ 
3641
	jmethodID getPropertyID;		/* System.getProperty() method */ 
3642
	jstring javaVersionProperty, javaVersionValue; 
3643
	jstring javaVendorProperty, javaVendorValue; 
3644
	int tmpStrLen; 
3645
	char *javaVersionChars;
3646
	char *javaVendorChars; 
3647
3648
	/* initialize javaVendor/Version to defaults */ 
3649
	_javaVendor = VendorOther;
3650
	_javaVersion = VersionOther; 
3651
3652
	/* first we need a reference to the class java.lang.System */ 
3653
3654
	javaLangSystem = FIND_CLASS(env, "java/lang/System");
3655
3656
	if (!javaLangSystem) {
3657
		return;
3658
	}
3659
3660
	/* next we need the jmethodID of the static getProperty() method in the
3661
	   System class */ 
3662
3663
	getPropertyID = GET_SMETHODID(env, javaLangSystem, "getProperty", 
3664
			"(Ljava/lang/String;)Ljava/lang/String;");
3665
3666
	if (!getPropertyID) {
3667
		return;
3668
	}
3669
3670
	/* we need to create a jstring version of the native string "java.version" */ 
3671
	javaVersionProperty = CREATE_JSTRING(env, "java.version");
3672
	if (!javaVersionProperty) {
3673
		return;
3674
	}
3675
3676
	/* we need to create a jstring version of the native string "java.vendor" */ 
3677
	javaVendorProperty = CREATE_JSTRING(env, "java.vendor");
3678
	if (!javaVendorProperty) {
3679
		return;
3680
	}
3681
3682
	/* Here we invoke System.getProperty("java.version") */ 
3683
	javaVersionValue = (jstring) CALL_OBJ_SMETHOD1(env, javaLangSystem, 
3684
		getPropertyID, javaVersionProperty);
3685
3686
	/* make sure there were no exceptions thrown during the preceding call */ 
3687
	if (CHECK_EXCEPTION(env)) {	
3688
		CLEAR_EXCEPTIONS(env);
3689
		return; 
3690
	}
3691
	if (!javaVersionValue) {
3692
		return;
3693
	}
3694
3695
	/* Here we invoke System.getProperty("java.vendor") */ 
3696
	javaVendorValue = (jstring) CALL_OBJ_SMETHOD1(env, javaLangSystem, 
3697
		getPropertyID, javaVendorProperty);
3698
	if (CHECK_EXCEPTION(env)) {	
3699
		CLEAR_EXCEPTIONS(env);
3700
		return; 
3701
	}
3702
	if (!javaVendorValue) {
3703
		return; 
3704
	}
3705
	
3706
	/* convert the jstring's into UTF-8 char arrays */ 
3707
	javaVersionChars = (char *)CONVERT_TO_UTF(env, javaVersionValue);
3708
	if (!javaVersionChars) {
3709
		return;
3710
	}
3711
3712
	javaVendorChars = (char *)CONVERT_TO_UTF(env, javaVendorValue); 
3713
	if (!javaVendorChars) {
3714
		RELEASE_UTF_CHARS(env,javaVersionValue,javaVersionChars); 
3715
		return;
3716
	}
3717
3718
3719
3720
	tmpStrLen = strlen(javaVersionChars); 
3721
	if (tmpStrLen >= 3 && strncmp(javaVersionChars,"1.3",3) == 0) {
3722
		_javaVersion = Version13;
3723
	}
3724
	else if (tmpStrLen >= 5 && strncmp(javaVersionChars,"1.4.0",5) == 0) {
3725
		_javaVersion = Version140; 
3726
	}
3727
	else if (tmpStrLen >= 5 && strncmp(javaVersionChars,"1.4.1",5) == 0) {
3728
		_javaVersion = Version141; 
3729
	}
3730
	else if (tmpStrLen >= 5 && strncmp(javaVersionChars,"1.4.2",5) == 0) {
3731
		_javaVersion = Version142; 
3732
	}
3733
	else {
3734
		_javaVersion = VersionOther; 
3735
	}
3736
3737
3738
	/* determine the vendor */ 
3739
	tmpStrLen = strlen(javaVendorChars); 
3740
	if (tmpStrLen >= IBM_VENDOR_STRING_LENGTH && 
3741
		strncmp(javaVendorChars,IBM_VENDOR_STRING,IBM_VENDOR_STRING_LENGTH) == 0) {
3742
		_javaVendor = VendorIBM; 
3743
	}
3744
	else  if (tmpStrLen >= SUN_VENDOR_STRING_LENGTH && 
3745
		strncmp(javaVendorChars,SUN_VENDOR_STRING,SUN_VENDOR_STRING_LENGTH) == 0) {
3746
		_javaVendor = VendorSun;
3747
	}
3748
	else if (tmpStrLen >= HP_VENDOR_STRING_LENGTH && 
3749
		strncmp(javaVendorChars,HP_VENDOR_STRING,HP_VENDOR_STRING_LENGTH) == 0) {
3750
		_javaVendor = VendorHP; 
3751
	}
3752
	else {
3753
		_javaVendor = VendorOther; 
3754
	}
3755
3756
	/* free up all the strings */ 
3757
	RELEASE_UTF_CHARS(env,javaVersionValue,javaVersionChars); 
3758
	RELEASE_UTF_CHARS(env,javaVendorValue,javaVendorChars); 
3759
3760
}
3761
#ifdef __OS400__
3762
#pragma convert(0)
3763
#endif 
3764
3765
3766
3767
/** PROCESS_JVM_INIT_DONE_EVENT  **********************************************
3768
  * Event called by the JVM when the JVM has completed all of it's
3769
  * initialization.  This is the earliest pont where we can start tracing.
3770
  */
3771
static void processJvmInitDoneEvent(JVMPI_Event *event,
3772
									ThreadLocalStorage *tps,
3773
                                    BOOL isRequested,
3774
									timestamp_t timestamp,
3775
									timestamp_t cpu_timestamp) {
3776
3777
3778
	int currentSuspendIO = _jvmpiAgent_suspendIO;
3779
	int isStarted = 0; 
3780
3781
	/* determine the java runtime vendor/version */ 
3782
	determineJavaVersion(event->env_id); 
3783
	
3784
	/* If we are actively profiling start the trace.  This cannot happen in any of the application mode, the
3785
	   additional test is neccessary as applicationControlled will be monitoing at this time.
3786
3787
	   We start tracing even though _jvmpiAgent_suspendIO may be true in order to be able
3788
	   to later monitor applications that were not monitored from the beginning (see
3789
	   bugzilla 49541 and the next comment.) 
3790
3791
	   We cannot do this trick if we are in enabled mode, however, since this causes
3792
	   problems with OS/400. Starting tracing actually tries forcing the RAC to write
3793
	   data, which, if premature, can result in the problems described in bugzilla 59667.
3794
	   There should be no need to do this trick anyhow when in enabled mode. 
3795
	*/
3796
	if(!_jvmpiAgent_Options.application 
3797
		&& !(currentSuspendIO && _jvmpiAgent_Options.enabled) ) {
3798
		startTracing(TRUE);
3799
		isStarted = 1; 
3800
	}
3801
3802
	/* This little trick is needed to be able to later on monitor 
3803
	 * Java applications that have been  resumed but not monitored */
3804
	
3805
	if (currentSuspendIO && isStarted)
3806
	{	
3807
		stopTracing();	
3808
		_jvmpiAgent_suspendIO = 1;
3809
	}
3810
	
3811
3812
	
3813
	/* MARK the heap now so we have a baseline to start from.  This is nice
3814
	   as the UI can just ask for an ANALYSE without a preceading MARK if
3815
	   desired
3816
	 */
3817
	analyseHeap(JVMPI_DUMP_LEVEL_0);
3818
3819
    /* Set the flag to say we can now trace if we wish */
3820
	_jvmpiAgent_isJVMInitDone=TRUE;
3821
3822
	if ( _jvmpiAgent_Options.mode != TraceModeNone || !_jvmpiAgent_Options.standalone ) {
3823
		jvmpiAgent_printJvmInitDoneElement(event);
3824
	}
3825
3826
3827
}
3828
3829
/** SET_DYNAMIC_EVENT_HANDLERS  *******************************************************
3830
  * Some events will be requested via the RequestEvent() call and hense we need to
3831
  * set the function pointers for these so we don't get burned.
3832
  */
3833
static void setDynamicEventHandlers() {
3834
	_processEventFunction[JVMPI_EVENT_CLASS_LOAD] = processClassLoadEvent;
3835
	_processEventFunction[JVMPI_EVENT_OBJECT_ALLOC] = processObjAllocEvent;
3836
#ifdef __OS400__
3837
	_processEventFunction[JVMPI_EVENT_OBJECT_DUMP] = processObjectDumpEvent;
3838
#endif
3839
}
3840
3841
/** ENABLE_JVMPI_EVENT  *******************************************************
3842
  * Enables an event in JVMPI so that we start recieving these types of
3843
  * events.
3844
  */
3845
static int enableJvmpiEvent(jint event_type,
3846
                            ProcessEventFunction eventHandler) {
3847
	_processEventFunction[event_type] = eventHandler;
3848
	return _jvmpiAgent_jvmpiInterface->EnableEvent(event_type, 0);
3849
}
3850
3851
3852
/** DISABLE_JVMPI_EVENT  ******************************************************
3853
  * Disables an event in JVMPI so that we stop recieving these types of
3854
  * events.
3855
  */
3856
static void disableJvmpiEvent(jint event_type) {
3857
	_jvmpiAgent_jvmpiInterface->DisableEvent(event_type, NULL);
3858
}
3859
3860
3861
/** ENABLE_GLOBAL_JVMPI_EVENTS  ***********************************************
3862
  * Enables all the JVMPI events that we need in order to start tracing at any
3863
  * point in time.  These are the obligitory events.
3864
  */
3865
static void enableGlobalJvmpiEvents(enum TraceMode mode) {
3866
3867
	/* If Exception tracing or line coverage is enabled then activate the class load hook event so that
3868
       we can instrument each class with our trace hooks.
3869
    */
3870
	if (_jvmpiAgent_Options.enableExceptionTracing || _jvmpiAgent_Options.enableLineCoverage) {
3871
		enableJvmpiEvent(JVMPI_EVENT_CLASS_LOAD_HOOK, processClassLoadHookEvent);
3872
	}
3873
3874
	/* Events we always need */
3875
	enableJvmpiEvent(JVMPI_EVENT_JVM_INIT_DONE, processJvmInitDoneEvent);
3876
	enableJvmpiEvent(JVMPI_EVENT_JVM_SHUT_DOWN, processesJVMShutdownEvent);
3877
	/* Bug 62852 - We do not need to track these events for TraceOptimizedHeap Mode */
3878
	if (_jvmpiAgent_Options.mode != TraceOptimizedHeap) {
3879
		enableJvmpiEvent(JVMPI_EVENT_THREAD_START,  processThreadStartEvent);
3880
		enableJvmpiEvent(JVMPI_EVENT_THREAD_END,    processThreadEndEvent);
3881
	}
3882
	_processEventFunction[JVMPI_EVENT_HEAP_DUMP] = processHeapDumpEvent;
3883
	enableJvmpiEvent(JVMPI_EVENT_MONITOR_DUMP, processMonitorDumpEvent); 
3884
	enableJvmpiEvent(JVMPI_EVENT_DATA_DUMP_REQUEST, processDataDumpRequest);
3885
}
3886
3887
3888
/** SAMPLE_STACK  **************************************************************
3889
  * Samples the contents of a stack.  In the current impl this cleans up the
3890
  * stack immediately after sampling its contents.  If we ever get the stack
3891
  * traversal stuff fixed in the JVM we should change loadStack to assign
3892
  * a weight to each stack frame so we can finish the job of providing
3893
  * a stack sampling profiler.
3894
  */
3895
int sampleStack(HashEntry * hashEntry, void *parm) {
3896
	JNIEnv *env=(JNIEnv*)parm;
3897
	ThreadPrivateStorage *tps=THREAD_ENTRY(hashEntry);
3898
	/* Ignore the global thread as it isn't part of the JVM threads.
3899
	   Also don't sample ourselves as this will deadlock.  Thi condition occurs
3900
	   because the thread is attached to the JVM
3901
	*/
3902
	if(tps->env  && tps->env!=env) {
3903
3904
		/* suspend the thread */
3905
		_jvmpiAgent_jvmpiInterface->SuspendThread(tps->env);
3906
3907
		/* Load the stack and then clean it up */
3908
		loadStack(tps);
3909
		stackCleaner(hashEntry, NULL);
3910
3911
		/* Resume the thread */
3912
		_jvmpiAgent_jvmpiInterface->ResumeThread(tps->env);
3913
	}
3914
	return 0;
3915
}
3916
3917
/** STACK_SAMPLER  *************************************************************
3918
  * This is the impl for the background thread that will sample each of the
3919
  * threads in the JVM when we are running in mode=sampling.
3920
  */
3921
void *stackSampler(void *args) {
3922
	JNIEnv *env;
3923
	if(!ATTACH_THREAD(env)) {
3924
		do {
3925
			/* Disable GC */
3926
			_jvmpiAgent_jvmpiInterface->DisableGC();
3927
3928
			/* Sample each of the threads in turn */
3929
			jvmpiAgent_ForAll(Thread_t, sampleStack, (void *)env);
3930
3931
			/* Re-enable GC */
3932
			_jvmpiAgent_jvmpiInterface->EnableGC();
3933
			SLEEP(10);				/* Hardcoded period of 10 milliseconds */
3934
		}
3935
		while(_stackSamplerActive);
3936
		DETACH_THREAD();
3937
	}
3938
	return 0;
3939
}
3940
3941
3942
/**
3943
  * Proxy to the stack sampler thread for porting ease
3944
  */
3945
#ifdef _WIN32
3946
DWORD WINAPI win32stackSamplerProxy(LPVOID args) {
3947
	DWORD returnVal=0;
3948
	stackSampler(args);
3949
	return returnVal;
3950
}
3951
#endif
3952
3953
/** TOGGLE_ACTIVE_JVMPI_EVENTS  ************************************************
3954
  * Toggles the optional JVMPI events on and off so that we can minimize our
3955
  * impact on an executing application when we are not profiling.  The events
3956
  * turned on are determined by the trace mode we are running.
3957
  */
3958
static void toggleActiveJvmpiEvents(TraceToggle toggle) {
3959
#if defined MVS || defined __OS400__
3960
	static TID stackSamplerTid;
3961
#else
3962
	static TID stackSamplerTid=0;
3963
#endif
3964
3965
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
3966
	printf("toggleActiveJvmpiEvents\n"); fflush(stdout);
3967
#endif
3968
3969
	/* Navid Mehregani - bugzilla 162754: Note that 'processClassLoadHookEvent' is an empty method
3970
	   It's the class load event handler in the agent extension that does the real work. */
3971
	if (toggle == TraceON)
3972
		enableJvmpiEvent(JVMPI_EVENT_CLASS_LOAD_HOOK, processClassLoadHookEvent);
3973
	else		
3974
		disableJvmpiEvent(JVMPI_EVENT_CLASS_LOAD_HOOK);	
3975
	/* End of bugzilla 162754 */
3976
3977
	/** the METHOD_COUNTS_ONLY option overrides all other options **/ 
3978
	if (_jvmpiAgent_Options.methodCountsOnly) {
3979
		if (toggle == TraceON) {
3980
			enableJvmpiEvent(JVMPI_EVENT_METHOD_ENTRY, processCountingMethodEntryEvent);
3981
		}
3982
		else {
3983
			disableJvmpiEvent(JVMPI_EVENT_METHOD_ENTRY); 
3984
		}
3985
		/* return immediately as methodCountsOnly overrides all other options */ 
3986
		return; 
3987
	}
3988
3989
3990
3991
  /* Register for the correct method events based upon trace mode */
3992
  /* RKD: We should only turn on stack events if our StackInfo > StackInfoNone */
3993
	if(_jvmpiAgent_Options.stackInfo > StackInfoNone) {
3994
		if(_jvmpiAgent_Options.mode == TraceModeFull) {
3995
			if(toggle == TraceON) {
3996
				enableJvmpiEvent(JVMPI_EVENT_METHOD_ENTRY2, processMethodEntryEvent);
3997
				enableJvmpiEvent(JVMPI_EVENT_METHOD_EXIT,   processMethodExitEvent);
3998
			}
3999
			else {
4000
				disableJvmpiEvent(JVMPI_EVENT_METHOD_ENTRY2);
4001
				disableJvmpiEvent(JVMPI_EVENT_METHOD_EXIT);
4002
			}
4003
		}
4004
		else if(_jvmpiAgent_Options.mode == TraceModeNoObjectCorrelation) {
4005
			if(toggle == TraceON) {
4006
				enableJvmpiEvent(JVMPI_EVENT_METHOD_ENTRY, processMethodEntryEvent);
4007
				enableJvmpiEvent(JVMPI_EVENT_METHOD_EXIT,   processMethodExitEvent);
4008
			}
4009
			else {
4010
				disableJvmpiEvent(JVMPI_EVENT_METHOD_ENTRY);
4011
				disableJvmpiEvent(JVMPI_EVENT_METHOD_EXIT);
4012
			}
4013
		}
4014
		/* RKD:  This is placed as a placeholder for a stack sampling profiler.
4015
		         This has not shipped due to problems with the IBM JDK with enumerating
4016
				 stack's.
4017
		*/
4018
		else if(_jvmpiAgent_Options.mode == TraceModeStackSampling)	{
4019
			if(toggle == TraceON) {
4020
				_stackSamplerActive=TRUE;
4021
#ifdef _WIN32
4022
				CreateThread(NULL,						/* default security attributes */
4023
					 0,							/* same stack size as current thread */
4024
					 win32stackSamplerProxy,	/* Thread entry point */
4025
					 NULL,						/* params */
4026
					 0,							/* start executing immediately */
4027
					 &stackSamplerTid);				/* the thread ID */
4028
#else
4029
				pthread_create(&stackSamplerTid,
4030
						  NULL,
4031
						  stackSampler, /* explicit cast to avoid HP compilation failure */
4032
						  NULL);
4033
#endif
4034
4035
			}
4036
			else {
4037
				_stackSamplerActive=FALSE;
4038
			}
4039
		}
4040
		else /* TraceHeap, TraceOptimizedHeap, or TraceModeNone */ {
4041
			disableJvmpiEvent(JVMPI_EVENT_METHOD_ENTRY);
4042
			disableJvmpiEvent(JVMPI_EVENT_METHOD_ENTRY2);
4043
			disableJvmpiEvent(JVMPI_EVENT_METHOD_EXIT);
4044
		}
4045
	}
4046
4047
	/* Do we want object heap information */
4048
	if (jvmpiAgent_isTracingHeap()) {
4049
		switch(toggle) {
4050
		case TraceON: 
4051
			/* RJD We *always* must instrument object free's/move's/and class unloads
4052
			   in this case, because otherwise our hash table
4053
			   may become inconsistent */ 
4054
4055
			/* PA - We need to disable move,free,class Unload events when we are running in
4056
			   TraceOptimized Mode - as in TraceOptimized mode we do not care
4057
			   about the hashtables. If the mode is not TraceOptimizedHeap then
4058
			   enable the moves and frees. 
4059
			*/
4060
			if ( _jvmpiAgent_Options.mode == TraceOptimizedHeap ) {
4061
					disableJvmpiEvent(JVMPI_EVENT_OBJECT_FREE); 
4062
					disableJvmpiEvent(JVMPI_EVENT_OBJECT_MOVE);
4063
					disableJvmpiEvent(JVMPI_EVENT_CLASS_UNLOAD); 
4064
			}
4065
			else /* Mode is not Optmized Heap */{
4066
				enableJvmpiEvent(JVMPI_EVENT_OBJECT_FREE, processObjFreeEvent); 
4067
				enableJvmpiEvent(JVMPI_EVENT_OBJECT_MOVE, processObjMoveEvent);
4068
				/*62852  The following events are not required to be tracked 
4069
				during optimized mode */
4070
				enableJvmpiEvent(JVMPI_EVENT_OBJECT_ALLOC,     processObjAllocEvent);
4071
				enableJvmpiEvent(JVMPI_EVENT_GC_START,      processGcStartEvent);
4072
				enableJvmpiEvent(JVMPI_EVENT_GC_FINISH,     processGcFinishEvent);
4073
				enableJvmpiEvent(JVMPI_EVENT_CLASS_UNLOAD, processClassUnloadEvent); 
4074
			}
4075
			
4076
			break; 
4077
		case TraceOFF: 
4078
			/* PA - We need to disable free events when we are running in
4079
			   TraceOptimized Mode - as in TraceOptimized mode we do not care
4080
			   about the hashtables. If the mode is not TraceOptimizedHeap then
4081
			   enable the moves and frees. If we are in TraceOptimizedHeap then 
4082
			   enable them depending on the gc options.
4083
			*/
4084
			if ( _jvmpiAgent_Options.mode == TraceOptimizedHeap ) {
4085
				/*62852  The following events are not required to be tracked 
4086
				during optimized mode */
4087
				disableJvmpiEvent(JVMPI_EVENT_OBJECT_ALLOC);
4088
			}
4089
			disableJvmpiEvent(JVMPI_EVENT_OBJECT_MOVE);
4090
			disableJvmpiEvent(JVMPI_EVENT_OBJECT_FREE); 
4091
			disableJvmpiEvent(JVMPI_EVENT_CLASS_UNLOAD); 
4092
			disableJvmpiEvent(JVMPI_EVENT_GC_START);
4093
			disableJvmpiEvent(JVMPI_EVENT_GC_FINISH);
4094
4095
			/* fall through to the TracePause case */ 
4096
		case TracePause: 
4097
			/* RJD We cannot disable object free's/move's/class unloads because
4098
			   we do not clean out the hash table; we can however disable the following
4099
			   events */ 
4100
			disableJvmpiEvent(JVMPI_EVENT_OBJECT_ALLOC);
4101
			break;
4102
		default:
4103
			break; 
4104
		}
4105
	}
4106
4107
	/* Do we want monitor information */
4108
	/* Events not dealt with currently:
4109
	             JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER,
4110
				 JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED,
4111
				 JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT
4112
				 (raw monitors aren't created anywhere in the profiler, so they aren't
4113
				 presently needed)
4114
4115
                 JVMPI_EVENT_MONITOR_CONTENDED_EXIT (not currently required according to
4116
			     Bluerat Specs)
4117
	*/
4118
4119
	if (_jvmpiAgent_Options.monitorMode > MonitorNone) {
4120
		if (toggle == TraceON) {
4121
			
4122
			enableJvmpiEvent(JVMPI_EVENT_MONITOR_CONTENDED_ENTER, processMonitorContendedEnter);		
4123
			enableJvmpiEvent(JVMPI_EVENT_MONITOR_CONTENDED_ENTERED, processMonitorContendedEntered);
4124
			/* enableJvmpiEvent(JVMPI_EVENT_MONITOR_CONTENDED_EXIT, processMonitorContendedExit); */
4125
			enableJvmpiEvent(JVMPI_EVENT_MONITOR_WAIT, processMonitorWait);
4126
			enableJvmpiEvent(JVMPI_EVENT_MONITOR_WAITED, processMonitorWaited);
4127
		}
4128
		else {
4129
			disableJvmpiEvent(JVMPI_EVENT_MONITOR_CONTENDED_ENTER);
4130
			disableJvmpiEvent(JVMPI_EVENT_MONITOR_CONTENDED_ENTERED);
4131
			/* disableJvmpiEvent(JVMPI_EVENT_MONITOR_CONTENDED_EXIT); */
4132
			disableJvmpiEvent(JVMPI_EVENT_MONITOR_WAIT);
4133
			disableJvmpiEvent(JVMPI_EVENT_MONITOR_WAITED);
4134
		}
4135
	}
4136
4137
4138
4139
}
4140
4141
/** startListenerShouldBlock -- ENCAPSULATES LOGIC FOR BLOCKING STARTLISTENER *************
4142
 *
4143
 * This function holds the logic telling whether the call to ra_startListener
4144
 * should block until a RAC connects to this agent.
4145
 * 
4146
 * This logic is used in two places, which is why I pulled it into this
4147
 * function rather than open-coding it. If anybody changes this logic,
4148
 * it'll change in all the places where it's used.
4149
 * 
4150
 * This answer this function gives does not make sense in standalone mode,
4151
 * because in that mode we never call ra_startListener.
4152
 */ 
4153
static char startListenerShouldBlock()
4154
{
4155
	return !_jvmpiAgent_Options.enabled;
4156
}
4157
4158
/** load_agent_extension_library -- AGENT EXTENSION LOADER *************
4159
  * This function loads whatever library is named by the 
4160
  * _jvmpiAgent.extensionLibrary option variable, unless it's the empty string.
4161
  */
4162
4163
static void load_agent_extension_library()
4164
{
4165
	char* extLib = _jvmpiAgent_Options.extensionLibrary;
4166
	if (extLib[0] != '\0') {
4167
		DLL_REFERENCE module;
4168
		module = LOAD_LIBRARY(extLib);
4169
#ifdef MVS
4170
		if (module == NULL) {
4171
			/* try converting ASCII to EBCDIC */
4172
			extLib = strdup(extLib);
4173
			__atoe(extLib);
4174
			module = LOAD_LIBRARY(extLib);
4175
			free(extLib);
4176
		}
4177
#endif
4178
4179
		if (module != NULL) {
4180
			AgentExtensionInitFunction agent_extension_init;
4181
#ifdef MVS
4182
#pragma convlit(suspend)
4183
#endif
4184
			agent_extension_init = (AgentExtensionInitFunction)RESOLVE_ENTRY_POINT(module, "agent_extension_init");
4185
#ifdef MVS
4186
#pragma convlit(resume)
4187
#endif
4188
			if (agent_extension_init != NULL) {
4189
				AgentExtensionInitArgs agent_extension_init_args;
4190
				agent_extension_init_args.api_version = 1;
4191
				agent_extension_init_args.options = _jvmpiAgent_Options.invocationOptions;
4192
				agent_extension_init_args.jvm = _jvmpiAgent_jvm;
4193
				agent_extension_init_args.jvmpi_interface = _jvmpiAgent_jvmpiInterface;
4194
				agent_extension_init_args.set_command_handler = agentExtensionSetCommandHandler;
4195
				agent_extension_init_args.set_event_handler = agentExtensionSetEventHandler;
4196
				agent_extension_init_args.agent_handle = _jvmpiAgent_bindingStorage;
4197
				
4198
				/* 
4199
				 * Compute the "safety flag."
4200
				 * This flag is true if it's safe for the agent extension 
4201
				 * to call "agentExtensionSetEventHandler" from inside
4202
				 * "agent_extension_init" or false if it's not safe.
4203
				 * 
4204
				 * It's safe if ra_startListener blocks until a RAC connects,
4205
				 * and it's safe in standalone mode, but otherwise it's not safe.
4206
				 * 
4207
				 * If the "blocking" flag passed to ra_startListener changes,
4208
				 * this code should change too.
4209
				 */
4210
				agent_extension_init_args.event_enable_safety_flag = 
4211
					(_jvmpiAgent_Options.standalone || startListenerShouldBlock());
4212
				
4213
4214
				/* Call the agent extension init function. */
4215
				/* See comments at agentExtensionSetEventHandler about this. */
4216
				agent_extension_init(&agent_extension_init_args);
4217
			}
4218
			else {
4219
				sendErrorMessage(RA_SEVERE, "IWAT5001E", "Profiler failed to find agent_extension_init entry point in library; continuing.\n");
4220
			}
4221
		}
4222
		else {
4223
			sendErrorMessage(RA_SEVERE, "IWAT5000E", "Profiler failed to load agent extension library; continuing.\n");
4224
		}
4225
	}
4226
}
4227
4228
4229
4230
/** _JVMPIAGENT_NOTIFY_MESSAGE  -- AGENT CONTROLLER MESSAGE PUMP  *************
4231
  * Callback function used to process messages from the Agent Controller.  This
4232
  * is the entry point for all control messages comming from the agent controler.
4233
  * It is the responsibility of the agent to react to these messages.
4234
  *
4235
  * This handler reacts to RA_AGENT_CONTROLER_AVAILABLE
4236
  * by checking the configuration for an extension library name,
4237
  * and loading and initializing that library if it's found.
4238
  */
4239
4240
#ifdef MVS                    /* 174190 */
4241
#pragma convlit(suspend)
4242
#endif
4243
4244
static void _jvmpiAgent_notify_message(ra_command_t *command) {
4245
	/*------------------------------------------------------------*
4246
	 * Route this message to an agent extension if one is configured and listening
4247
	 */
4248
	if (agent_extension_command_handler != NULL) {
4249
		agent_extension_command_handler(command);
4250
	}
4251
	/*------------------------------------------------------------*/
4252
4253
	/* Handle the command */
4254
	switch(command->tag) {
4255
4256
	case RA_AGENT_CONTROLER_AVAILABLE:
4257
	{
4258
		ra_agentConfigList_t* clist = ra_getDefaultConfiguration(_jvmpiAgent_bindingStorage);
4259
		ra_agentConfigListEntry_t* listEntry;
4260
		for (listEntry = clist->head; listEntry != NULL; listEntry = listEntry->next) {
4261
			ra_agentConfigEntry_t* e = &listEntry->entry;
4262
			const char* name, *type, *value;
4263
			if (e->name.length == 0) name = "";
4264
			else name = e->name.data;
4265
			if (e->type.length == 0) type = "";
4266
			else type= e->type.data;
4267
			if (e->value.length == 0) value = "";
4268
			else value = e->value.data;
4269
			if ((strcmp(name, "piAgentExtension") == 0) &&
4270
				(strcmp(type, "libraryName") == 0))
4271
			{
4272
				/*
4273
				 * An empty value string means "don't load anything"
4274
				 */
4275
				if (value[0] != '\0') { 
4276
					/* only load agent extensions if we could successfully copy 
4277
					   the value string */ 
4278
					if (strcpyrealloc(&_jvmpiAgent_Options.extensionLibrary, value) == 0) {
4279
						load_agent_extension_library();
4280
						/* bugzilla 66599 -- only load agent extension once */ 
4281
						break; 
4282
					}
4283
				}
4284
			}
4285
		}
4286
		break;
4287
	}
4288
		/* Called by the local monitor to start IO at this point */
4289
    case RA_START_MONITORING_AGENT_REMOTE:
4290
	case RA_START_MONITORING_AGENT_LOCAL:
4291
	{
4292
		int result, type=0; 
4293
		ThreadLocalStorage *tps = jvmpiAgent_getThreadLocalStorage(0);  /* Grab the I/O buffer from the static private storage   */
4294
		
4295
        if(!_jvmpiAgent_isMonitored && !_jvmpiAgent_isSuspended) {
4296
        /* Set target handle type - 171664 added this line*/
4297
4298
            result=-1;
4299
            if(command->tag==RA_START_MONITORING_AGENT_LOCAL) {
4300
4301
               _jvmpiAgent_Options.targetHdl.dtarget = RA_SHAREDMEMORY;
4302
               type=0;
4303
4304
               /* transfer data via shared memory */
4305
               result = ra_attachToShm(command->info.start_monitor_local.file.data,
4306
                                    &_jvmpiAgent_Options.targetHdl.dtargetHdl.shmHdl);
4307
            }
4308
            else if(command->tag==RA_START_MONITORING_AGENT_REMOTE) {
4309
                /* Set target handle type */
4310
                _jvmpiAgent_Options.targetHdl.dtarget = RA_SOCKET;
4311
               type=1;                
4312
4313
                /* Connect to the remote monitor's listening port as indicated in the message */
4314
                result=ra_connectToTCPServer(command->info.start_monitor_remote.ip,
4315
                                                                        (unsigned short)command->info.start_monitor_remote.port,
4316
                                                                        &_jvmpiAgent_Options.targetHdl.dtargetHdl.socketFD);
4317
            }
4318
4319
			if(result != 0) {
4320
#ifdef MVS      
4321
#pragma convlit(resume)
4322
#endif
4323
				char *connectType[2]={"SharedMemory","Socket"}; /* add type/returncode to error msg if connect failed * 139537 */
4324
				char errMsg[2000];
4325
				sprintf(errMsg,"Profiler unable to establish connection with Agent Controller via %s. Returncode from attempt is %d.",
4326
				        connectType[type], result);
4327
				sendErrorMessage(RA_SEVERE,"0",errMsg);
4328
#ifdef MVS                   
4329
#pragma convlit(suspend)
4330
#endif
4331
				break;
4332
			}
4333
			_jvmpiAgent_isMonitored=TRUE;
4334
		}
4335
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
4336
		dumpMethodEventCounts();  printf("Start Monitoring ... begin\n"); fflush(stdout);
4337
#endif
4338
4339
		/* In application mode we never turn on IO here */
4340
		if (_jvmpiAgent_suspendIO && !_jvmpiAgent_Options.application)  {
4341
4342
			if(_jvmpiAgent_isJVMInitDone) {
4343
				JNIEnv *env;
4344
				/* Attach the current thread to the JVM */
4345
				if(ATTACH_THREAD(env)) {
4346
					break;
4347
				}
4348
4349
				/* Start tracing the application now */
4350
				if(_jvmpiAgent_isSuspended) {
4351
					resumeTracing();
4352
				}
4353
				else {
4354
					startTracing(FALSE);
4355
				}
4356
4357
				DETACH_THREAD();
4358
			}
4359
			else {
4360
				/* Re-enable IO */
4361
				_jvmpiAgent_suspendIO = 0;
4362
			}
4363
		}
4364
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
4365
		printf("Start Monitoring ... done\n"); fflush(stdout);
4366
#endif
4367
		break;
4368
	}
4369
	/* Called by the remote monitor to turn off IO */
4370
	case RA_STOP_MONITORING_AGENT:
4371
	{
4372
		/* Don't do anything if IO is suspended */
4373
		if(!_jvmpiAgent_suspendIO) {
4374
			JNIEnv *env;
4375
			ThreadLocalStorage *tps=jvmpiAgent_getThreadLocalStorage(0);
4376
			
4377
			if(_jvmpiAgent_isJVMInitDone) {
4378
				if(ATTACH_THREAD(env))  {
4379
					break;
4380
				}
4381
4382
				suspendTracing(TracePause);
4383
4384
				DETACH_THREAD();
4385
			}
4386
			else {
4387
				/* In the case where we stop traing before we get the initDone event. We need to just set the
4388
				   IO to off so we don't start tracing when we get the initDone event
4389
				*/
4390
				_jvmpiAgent_suspendIO = 1;
4391
			}
4392
		}
4393
		break;
4394
	}
4395
	case RA_DETACH_FROM_AGENT:
4396
	{
4397
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
4398
		dumpMethodEventCounts(); 
4399
		printf("Detach_Agent ... begin: suspendIO=%d, isJVMInitDone=%d\n",
4400
			   _jvmpiAgent_suspendIO, _jvmpiAgent_isJVMInitDone); fflush(stdout);
4401
#endif                       
4402
		/* Don't do anything if IO is suspended */
4403
		if(!_jvmpiAgent_suspendIO) {
4404
			JNIEnv *env;
4405
			ThreadLocalStorage *tps=jvmpiAgent_getThreadLocalStorage(0);
4406
			
4407
			if(_jvmpiAgent_isJVMInitDone) {
4408
				if(ATTACH_THREAD(env))  {
4409
					break;
4410
				}
4411
4412
				stopTracing();
4413
4414
				DETACH_THREAD();
4415
			}
4416
			else {
4417
				/* In the case where we stop tracing before we get the initDone event. We need to just set the
4418
				   IO to off so we don't start tracing when we get the initDone event
4419
				*/
4420
				_jvmpiAgent_suspendIO = 1;
4421
			}
4422
		}
4423
        else {
4424
			JNIEnv *env;
4425
			ThreadLocalStorage *tps=jvmpiAgent_getThreadLocalStorage(0);
4426
			if(_jvmpiAgent_isJVMInitDone) {
4427
				if(ATTACH_THREAD(env))  {
4428
					break;
4429
				}
4430
				toggleActiveJvmpiEvents(TraceOFF); 
4431
				DETACH_THREAD();
4432
			}
4433
            /* Clean up all our resources for this trace */
4434
	        cleanUpAllTraceResources();
4435
        }
4436
4437
		/* If we have been monitoring THEN */
4438
		if (_jvmpiAgent_isMonitored) {
4439
4440
            if(_jvmpiAgent_Options.targetHdl.dtarget == RA_SHAREDMEMORY) {
4441
               /* Stop flushing shm buffer */
4442
               ra_stopFlushingShm(&_jvmpiAgent_Options.targetHdl.dtargetHdl.shmHdl); /* 175248 */
4443
            }
4444
            else if(_jvmpiAgent_Options.targetHdl.dtarget == RA_SOCKET) {
4445
                ra_closeSocket(_jvmpiAgent_Options.targetHdl.dtargetHdl.socketFD);
4446
            }
4447
			_jvmpiAgent_isMonitored=FALSE;
4448
			_jvmpiAgent_isSuspended=FALSE;
4449
		}
4450
#if defined (_DEBUG) && !defined (MVS) && !defined (__OS400__)
4451
		printf("Detach_Agent ... done\n"); fflush(stdout);
4452
#endif
4453
		break;
4454
	}
4455
	case RA_CUSTOM_COMMAND:
4456
	{
4457
		jint failed;
4458
		JNIEnv *env;
4459
		if(strcmp(command->info.custom_command.message.data, "RESUME")==0) {
4460
			/* Grab the I/O buffer from the static private storage   */
4461
			ThreadLocalStorage *tps = jvmpiAgent_getThreadLocalStorage(0);
4462
			/* RKD:  resume should be ignored from an IO standpoint.
4463
			jvmpiAgent_printVMResume(tps);
4464
			*/
4465
			ra_releaseVMLock();
4466
		}
4467
		else if(strcmp(command->info.custom_command.message.data, "MARKHEAP")==0) {
4468
			if(_jvmpiAgent_isJVMInitDone && !_jvmShutDown) {
4469
				failed=ATTACH_THREAD(env);
4470
				if(!failed)  {
4471
					failed=analyseHeap(JVMPI_DUMP_LEVEL_0);
4472
					DETACH_THREAD();
4473
				}
4474
			}
4475
		}
4476
		else if(strcmp(command->info.custom_command.message.data, "ANALYSEHEAP")==0) {
4477
			if(_jvmpiAgent_isJVMInitDone && !_jvmShutDown) {
4478
				failed=ATTACH_THREAD(env);
4479
				if(!failed) {
4480
					runGC();
4481
					failed=analyseHeap(JVMPI_DUMP_LEVEL_1);
4482
					DETACH_THREAD();
4483
				}
4484
			}
4485
		}
4486
		else if(strcmp(command->info.custom_command.message.data, "TERMINATE")==0) {
4487
			_jvmpiAgent_jvmpiInterface->ProfilerExit(0);
4488
		}
4489
		else if(strcmp(command->info.custom_command.message.data, "APPLYFILTERS")==0) {
4490
			jvmpiAgent_applyFilters();
4491
4492
			/* Check the current filter criteria against existing information */
4493
			jvmpiAgent_resetTraceFlags();
4494
		}
4495
		else if(strcmp(command->info.custom_command.message.data, "RUNGC")==0) {
4496
			if(_jvmpiAgent_isJVMInitDone && !_jvmShutDown) {
4497
				failed=ATTACH_THREAD(env);
4498
				if(!failed) {
4499
					runGC();
4500
					DETACH_THREAD();
4501
				}
4502
			}
4503
		}
4504
		/* Piyush  Agarwal */
4505
		/* Change made to enable RAC connected file transfer */
4506
		else if(strcmp(command->info.custom_command.message.data, "OPTHEAP")==0) {
4507
			if(_jvmpiAgent_isJVMInitDone && !_jvmShutDown) {
4508
				ThreadLocalStorage *tps=jvmpiAgent_getThreadLocalStorage(0);
4509
				failed=ATTACH_THREAD(env);
4510
				if(!failed) {
4511
					runGC();
4512
					processRACDataDumpRequest(FALSE,command->info.custom_command.context) ;
4513
					DETACH_THREAD();
4514
				}
4515
			}
4516
		}
4517
		else if(strcmp(command->info.custom_command.message.data, "FINAL_OPTHEAP")==0) {
4518
			if(_jvmpiAgent_isJVMInitDone && !_jvmShutDown) {
4519
				ThreadLocalStorage *tps=jvmpiAgent_getThreadLocalStorage(0);
4520
				failed=ATTACH_THREAD(env);
4521
				if(!failed) {
4522
					runGC();
4523
					processRACDataDumpRequest(TRUE,command->info.custom_command.context) ;
4524
					DETACH_THREAD();
4525
				}
4526
			}
4527
		}
4528
		/* Indicates a headless client.  We will only need to take an action if we are in
4529
		   application mode. */
4530
		else if(strcmp(command->info.custom_command.message.data, "HEADLESS")==0) {
4531
			/* Start profiling the agent (simulating the effect of a JNI call). */
4532
			if (_jvmpiAgent_Options.application) {
4533
				/* Bug 71507 : Do not start profiling if it is applicationControlled */
4534
				if(_jvmpiAgent_Options.enabled) {
4535
					Java_org_eclipse_hyades_collection_profiler_Profiler_startProfiling0((JNIEnv *)NULL, (JOBJECT)NULL, (jboolean)FALSE, 0);
4536
				}
4537
			}
4538
		}
4539
		/* Bug 64712 */
4540
		else if(strcmp(command->info.custom_command.message.data, "KILLED")==0) {
4541
			stopTracing();
4542
		}
4543
		/* Bug 64712 */
4544
		else if(strcmp(command->info.custom_command.message.data, "COLLECTDATA")==0) {
4545
			/* Pre-aggregation */
4546
			/* Dump all the threads' statistics */
4547
			if (_jvmpiAgent_Options.compressLevel==CompressAggregate) {  /* 134635 */
4548
				if (!_jvmpiAgent_suspendIO) {				
4549
					printAllThreadAgData();  /* 140009 */
4550
				}	
4551
			}	
4552
		}
4553
4554
		break;
4555
	}
4556
	case RA_SET_NAME_VALUE_PAIR:
4557
	{
4558
		if(strcmp(command->info.set_nv_pair.type.data, "SETOPTION")==0) {
4559
			jvmpiAgent_SetProfileOption(command->info.set_nv_pair.name.data,
4560
										command->info.set_nv_pair.value.data);
4561
		}
4562
		/* RKD:  The SETFILTER name value pair is ffor complicance with the V4 UI and V5 filters not containing method detail */
4563
		else if(strcmp(command->info.set_nv_pair.type.data, "SETFILTER")==0) {
4564
			jvmpiAgent_addFilter(command->info.set_nv_pair.name.data, NULL, !strcmp(command->info.set_nv_pair.value.data,"INCLUDE") ? INCLUDE : EXCLUDE);
4565
		}
4566
		else if(strcmp(command->info.set_nv_pair.type.data, "SETMETHODFILTER")==0) {
4567
			char *separator=strchr(command->info.set_nv_pair.name.data, ' ');
4568
			if(separator) {
4569
				*separator='\0';
4570
				jvmpiAgent_addFilter(command->info.set_nv_pair.name.data, separator+1, !strcmp(command->info.set_nv_pair.value.data,"INCLUDE") ? INCLUDE : EXCLUDE);
4571
			}
4572
		}
4573
		break;
4574
	}
4575
	default: break;
4576
	}
4577
}
4578
4579
#ifdef MVS                    /* 174190 */
4580
#pragma convlit(resume)
4581
#endif
4582
4583
4584
/** JVM_ON_LOAD  ***************************************************************
4585
  * The entry point for the profiler.  This function is called by the JVM if
4586
  * the .dll is provided on the -Xrun parameter when the JVM is launched.  This
4587
  * function is called at the very bootstrap level of the JVM before much
4588
  * has happened.
4589
  */
4590
4591
4592
4593
#if defined __cplusplus
4594
extern "C" {
4595
#endif
4596
JNIEXPORT jint JNICALL JVM_OnLoad(JavaVM *vm,
4597
                                  char *options,
4598
                                  void *reserved) {
4599
	int res;
4600
	char * buffer;
4601
	int bogus;
4602
4603
	initializeJvmpiAgentOptionsDefaults();
4604
4605
	determineTicksPerMicrosecond(&bogus);
4606
4607
	/* Turn IO off until we need to start tracing */
4608
	_jvmpiAgent_suspendIO = 1;
4609
4610
	
4611
	/* Establish panic exit handler */
4612
	signal(SIGABRT, cleanupAndExit);
4613
	signal(SIGINT, cleanupAndExit);
4614
	signal(SIGTERM, cleanupAndExit);
4615
4616
	/* Initialize the global collation value */
4617
	jvmpiAgent_initializeSegmentedValue(&_jvmpiAgent_collation, 0);
4618
4619
	/* Determine start time from here */
4620
	jvmpiAgent_collectStartTimeInformation();
4621
4622
	/* Create the filter tables.  We will assume that this JVM uses the '/' package
4623
	   separator.  This can be overriddden during tracing by the setpathDelimiter
4624
	   function.
4625
	*/
4626
#ifdef __OS400__
4627
#pragma convert(819) 
4628
#endif
4629
4630
	jvmpiAgent_initializeFilters('/');
4631
4632
	/* Create the trigger tables.  We will assume that this JVM uses the '/' package
4633
	   separator.  This can be overriddden during tracing by the setpathDelimiter
4634
	   function.
4635
	*/
4636
	jvmpiAgent_initializeTriggers('/');
4637
#ifdef __OS400__
4638
#pragma convert(0) 
4639
#endif
4640
4641
4642
	/* Tuck away the JVM pointer for future use */
4643
	_jvmpiAgent_jvm = vm;
4644
4645
	/* Resolve to the JVMPI environment */
4646
#if defined __cplusplus && defined _HPUX
4647
	res = ENV(_jvmpiAgent_jvm)->GetEnv((void **)&_jvmpiAgent_jvmpiInterface, JVMPI_VERSION_1);
4648
#else
4649
	res = (*_jvmpiAgent_jvm)->GetEnv(_jvmpiAgent_jvm, (void **)&_jvmpiAgent_jvmpiInterface, JVMPI_VERSION_1);
4650
#endif
4651
	if (res < 0 || !_jvmpiAgent_jvmpiInterface) {
4652
#ifdef MVS                    /* 174190 */
4653
#pragma convlit(suspend)
4654
#endif
4655
		fprintf(stderr, "  Could not resolve to JVMPI interface\n");
4656
		fflush(stderr); 
4657
#ifdef MVS                    /* 174190 */
4658
#pragma convlit(resume)
4659
#endif
4660
		return JNI_ERR;
4661
	}
4662
4663
	/* Make a global copy of the options for the agent to print later */
4664
	if (options) {
4665
		_jvmpiAgent_Options.invocationOptions = (char*)jvmpiAgent_Calloc(strlen(options)+1);
4666
		strcpy(_jvmpiAgent_Options.invocationOptions, options);
4667
	} else {
4668
		_jvmpiAgent_Options.invocationOptions = ""; /* 101734 */		
4669
	}	
4670
4671
	/* Process the command line options, continue initialization only if this is successful */
4672
	if (jvmpiAgent_ProcessInvocationOptions(options) == 0) {
4673
#ifdef MVS                    /* 174190 */
4674
		char *tmpname, *tmpType;
4675
#endif
4676
4677
		if (_jvmpiAgent_Options.standalone) {
4678
			jvmpiAgent_processProfile(_jvmpiAgent_Options.profileFile);
4679
			/* Satish: perhaps we should move following code from the bottom of this function
4680
			 * to here.
4681
			 */
4682
			/* jvmpiAgent_processFilters(_jvmpiAgent_Options.filterFileName); */
4683
			/* jvmpiAgent_processTriggers(_jvmpiAgent_Options.triggerFileName); */
4684
		}
4685
		
4686
		/* Now command-line options, as well as profile has been processed, check consistency */
4687
		if (jvmpiAgent_CheckOptionsConsistency() != 0) {
4688
#ifdef MVS                   
4689
#pragma convlit(suspend)
4690
#endif
4691
			fprintf(stderr, "Specified options are not consistent\n");
4692
#ifdef MVS                    
4693
#pragma convlit(resume)
4694
#endif
4695
			fflush(stderr); 
4696
			printUsage();
4697
			return JNI_ERR;
4698
		}
4699
	
4700
		/* Set up the symbol table */
4701
		jvmpiAgent_InitializeSymbolTable();
4702
4703
		/* Initialize the synchronization lock */
4704
		ra_initializeLock(&_jvmpiAgent_synchLock);
4705
4706
		/* Grab the I/O buffer from the static private storage   */
4707
		buffer = jvmpiAgent_getThreadLocalStorage(0)->buffer;
4708
4709
		/* Set the JVMPI pointer to the Agents notify_event handler function */
4710
		_jvmpiAgent_jvmpiInterface->NotifyEvent = notify_event;
4711
4712
		/* Enable all of the appropriate events depending upon our mode */
4713
		enableGlobalJvmpiEvents(_jvmpiAgent_Options.mode);
4714
4715
		/* Set the dynamic event pointers */
4716
		setDynamicEventHandlers();
4717
4718
		/* Initialize the communication layer bindings */
4719
#ifdef MVS                    /* 174190 */
4720
		tmpname = (char *)malloc(strlen(_jvmpiAgent_Options.processName) + 1);
4721
		strcpy(tmpname, _jvmpiAgent_Options.processName);
4722
		__atoe(tmpname);
4723
		tmpType = (char *)malloc(strlen(_jvmpiAgent_Options.processType) + 1);
4724
		strcpy(tmpType, _jvmpiAgent_Options.processType);
4725
		__atoe(tmpType);
4726
		_jvmpiAgent_bindingStorage = ra_initializeBindings(tmpname,
4727
                                                         tmpType,
4728
                                                         _jvmpiAgent_notify_message,
4729
                                                         _jvmpiAgent_Options.standalone);
4730
		free(tmpname);
4731
		free(tmpType);
4732
#else
4733
#ifdef  _HPUX
4734
		_jvmpiAgent_bindingStorage=ra_initializeBindings(_jvmpiAgent_Options.processName,
4735
                                                         _jvmpiAgent_Options.processType,
4736
                                                         _jvmpiAgent_notify_message,
4737
                                                         (enum _BOOL)_jvmpiAgent_Options.standalone);
4738
#else
4739
		_jvmpiAgent_bindingStorage=ra_initializeBindings(_jvmpiAgent_Options.processName,
4740
                                                         _jvmpiAgent_Options.processType,
4741
                                                         _jvmpiAgent_notify_message,
4742
                                                         _jvmpiAgent_Options.standalone);
4743
#endif
4744
#endif
4745
4746
		/* Do setup for Agent when being controlled by the "Agent Controller" */
4747
		if (!_jvmpiAgent_Options.standalone)  {
4748
			/*## probably need this global so that I can kill the thread on shutdown */
4749
			TID *tid;
4750
4751
			/* If the trace is "enabled" we don't want to block on invocation. Otherwise
4752
			   we are in "controlled" mode, wait until the controller sends a
4753
			   RA_CUSTOM_COMMAND with "RESUME" message.
4754
			*/
4755
			tid=ra_startListener(_jvmpiAgent_bindingStorage, startListenerShouldBlock());
4756
			_jvmpiAgent_isListenerUnblocked = TRUE;
4757
4758
			/*------------------------------------------------------------*
4759
			 * startListener returned. That means we have processed the
4760
			 * initial message from the RAC, RA_AGENT_CONTROLER_AVAILABLE.
4761
			 * And *that* means we have loaded and initialized the agent 
4762
			 * extension, if one was configured.
4763
			 *
4764
			 * See comments at agentExtensionSetEventHandler for more
4765
			 * about initializing agent extensions and having them
4766
			 * enable JVMPI events.
4767
			 */
4768
			{
4769
				/* Process the initial agent extension event enable requests */
4770
				int i;
4771
				for (i = 0; i < JVMPI_MAX_EVENT_TYPE_VAL; i++) {
4772
					if (agent_extension_handlers[i] != NULL) {
4773
						_jvmpiAgent_jvmpiInterface->EnableEvent(i, 0);
4774
					}
4775
				}
4776
			}
4777
		}
4778
		else {
4779
			/* Standalone mode */
4780
			ThreadLocalStorage *tps=jvmpiAgent_getThreadLocalStorage(0);
4781
4782
			/*------------------------------------------------------------*
4783
			 * If the extensionLibrary option is set, load and 
4784
			 * initialize an agent extension.
4785
			 *
4786
			 * In non-stand-alone mode, this will be done based on
4787
			 * the settings available when the RA_AGENT_CONTROLER_AVAILABLE
4788
			 * message arrives.
4789
			 *
4790
			 * In stand-alone mode, we don't need to worry about enabling
4791
			 * events after the agent extension initializes; see notes at
4792
			 * agentExtensionSetEventHandler for an explanation.
4793
			 */
4794
			if (_jvmpiAgent_Options.extensionLibrary[0] != '\0') {
4795
				load_agent_extension_library();
4796
			}
4797
4798
			ra_initializeVMLock();
4799
#ifdef MVS                    /* 174190 */
4800
#pragma convlit(suspend)
4801
			__atoe(_jvmpiAgent_Options.outputFileName);
4802
#endif
4803
			/* Open the output file if we are doing file I/O */
4804
			jvmpiAgent_initializeStandaloneIO();
4805
#ifdef MVS                    /* 174190 */
4806
#pragma convlit(resume)
4807
#endif
4808
			_jvmpiAgent_suspendIO = 0;
4809
4810
			/* Satish: As a principle, any configuartion file must be processed before, applying
4811
			 * any business logic. Perhaps, we should move these just processing command-line
4812
			 * options. I am moving the call jvmpiAgent_processProfile(_jvmpiAgent_Options.profileFile)
4813
			 * there, because profile specifications might create inconsistencies that must
4814
			 * be checked before doing anything.
4815
			 */
4816
			/* jvmpiAgent_processProfile(_jvmpiAgent_Options.profileFile); */
4817
			jvmpiAgent_processFilters(_jvmpiAgent_Options.filterFileName);
4818
			jvmpiAgent_processTriggers(_jvmpiAgent_Options.triggerFileName);
4819
4820
		}
4821
		
4822
		return JNI_OK;
4823
	}
4824
	else {
4825
		printUsage();
4826
		return JNI_ERR;
4827
	}
4828
}
4829
4830
/**	Giri: <Defect 64462> This method is performs all the optHeap related setup necessary within 
4831
	the agent. Previously, we were doing this set-up only within JVM_OnLoad(), so if we tried 
4832
	to attach a running process, and then tried to do optHeap related operations, the setup 
4833
	would not have happened, and the JVM would crash **/
4834
4835
static void jvmpiAgent_DoOptHeapSetup()	
4836
{
4837
	if (_optHeapSetupDone)	{
4838
		return;
4839
	}
4840
4841
	_optHeapSetupDone = TRUE;	/* We need to do this set-up only once */
4842
	_jvmpiAgent_optHeapCallBack.ohdcb = sendHeapDumpInformation ;
4843
4844
	StatelessHeapSnapshotManager_setup_FromC(_jvmpiAgent_jvmpiInterface, TRUE);
4845
4846
	/* Get the LOCAL_AGENT_TEMP_DIR */
4847
	/* Bug 59544 querying tempDir from RAC */
4848
	if (!_jvmpiAgent_Options.standalone) {
4849
		char tempDir[1024] ;
4850
		int result ;
4851
		result = ra_getEnvironmentVariable(_tempDirOptionName,tempDir,1024) ;
4852
        /* If "LOCAL_AGENT_TEMP_DIR" is not defined then get try to look
4853
		   for "TMP" */
4854
		if ( !result )
4855
			result = ra_getEnvironmentVariable("TMP",tempDir,1024) ; 
4856
		/* If tempDir is defined then set it as the workDir .
4857
		   else leave it as default */
4858
		if ( result ) {
4859
            strcpyrealloc(&_jvmpiAgent_Options.workDir,tempDir) ;
4860
/* 64476 Convert it to ascii for consistency */
4861
#ifdef MVS
4862
            __etoa(_jvmpiAgent_Options.workDir) ;
4863
#endif
4864
		}
4865
	}
4866
}
4867
4868
static void jvmpiAgent_PrintStartingXMLFragments()
4869
{
4870
	
4871
	ThreadLocalStorage *tps;
4872
4873
	/* Get the global buffer for IO */
4874
	tps=jvmpiAgent_getThreadLocalStorage(0);
4875
4876
	/* If we are in standalone print the required additional elements */
4877
	if((_jvmpiAgent_Options.standalone||_jvmpiAgent_Options.application))  /*94955*/
4878
	{
4879
		jvmpiAgent_printXMLStartElement(tps);
4880
        jvmpiAgent_printStandaloneTraceTagOpen(tps);
4881
	}
4882
4883
	/* Print the trace header */
4884
	jvmpiAgent_printNodeElement(tps);
4885
	jvmpiAgent_printProcessCreateElement(tps);
4886
	jvmpiAgent_printAgentCreateElement(tps, _jvmpiAgent_Options.invocationOptions);
4887
	jvmpiAgent_printTraceStartElement(tps, _jvmpiAgent_Options.invocationOptions);
4888
	
4889
	/* Print the filters and options only if the proper option is set */
4890
	if (_jvmpiAgent_Options.filters)
4891
	{
4892
		jvmpiAgent_printFilters();
4893
	}
4894
	if (_jvmpiAgent_Options.options)
4895
	{
4896
		jvmpiAgent_printOptions();
4897
	}
4898
}
4899
4900
4901
#if defined __cplusplus
4902
}
4903
#endif
(-)src-native-new/src/agents/perfmon/WinBuild/PerfmonAgent.mak64 (+354 lines)
Added Link Here
1
# Microsoft Developer Studio Generated NMAKE File, Based on PerfmonAgent.dsp
2
!IF "$(CFG)" == ""
3
CFG=PerfmonAgent - IA64 Release
4
!MESSAGE No configuration specified. Defaulting to PerfmonAgent - IA64 Release.
5
!ENDIF 
6
7
!IF "$(CFG)" != "PerfmonAgent - IA64 Release" && "$(CFG)" != "PerfmonAgent - IA64 Debug" && "$(CFG)" != "PerfmonAgent - X64 Release" && "$(CFG)" != "PerfmonAgent - X64 Debug"
8
!MESSAGE Invalid configuration "$(CFG)" specified.
9
!MESSAGE You can specify a configuration when running NMAKE
10
!MESSAGE by defining the macro CFG on the command line. For example:
11
!MESSAGE 
12
!MESSAGE NMAKE /f "PerfmonAgent.mak64" CFG="PerfmonAgent - IA64 Release"
13
!MESSAGE 
14
!MESSAGE Possible choices for configuration are:
15
!MESSAGE 
16
!MESSAGE "PerfmonAgent - IA64 Release"
17
!MESSAGE "PerfmonAgent - IA64 Debug"
18
!MESSAGE "PerfmonAgent - X64 Release"
19
!MESSAGE "PerfmonAgent - X64 Debug"
20
!MESSAGE 
21
!ERROR An invalid configuration is specified.
22
!ENDIF 
23
24
!IF "$(OS)" == "Windows_NT"
25
NULL=
26
!ELSE 
27
NULL=nul
28
!ENDIF 
29
30
!IF  "$(CFG)" == "PerfmonAgent - IA64 Release"
31
32
OUTDIR=..\..\..\..\bin
33
INTDIR=.\Release
34
# Begin Custom Macros
35
OutDir=..\..\..\..\bin
36
# End Custom Macros
37
38
ALL : "$(OUTDIR)\PerfmonAgent.exe"
39
40
41
CLEAN :
42
	-@erase "$(INTDIR)\PerfmonAgent.obj"
43
	-@erase "$(INTDIR)\vc60.idb"
44
	-@erase "$(INTDIR)\version.res"
45
	-@erase "$(OUTDIR)\PerfmonAgent.exe"
46
47
"$(OUTDIR)" :
48
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
49
50
"$(INTDIR)" :
51
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
52
53
CPP=cl.exe
54
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /I "../resutils" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\PerfmonAgent.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
55
56
.c{$(INTDIR)}.obj::
57
   $(CPP) @<<
58
   $(CPP_PROJ) $< 
59
<<
60
61
.cpp{$(INTDIR)}.obj::
62
   $(CPP) @<<
63
   $(CPP_PROJ) $< 
64
<<
65
66
.cxx{$(INTDIR)}.obj::
67
   $(CPP) @<<
68
   $(CPP_PROJ) $< 
69
<<
70
71
.c{$(INTDIR)}.sbr::
72
   $(CPP) @<<
73
   $(CPP_PROJ) $< 
74
<<
75
76
.cpp{$(INTDIR)}.sbr::
77
   $(CPP) @<<
78
   $(CPP_PROJ) $< 
79
<<
80
81
.cxx{$(INTDIR)}.sbr::
82
   $(CPP) @<<
83
   $(CPP_PROJ) $< 
84
<<
85
86
RSC=rc.exe
87
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
88
89
LINK32=link.exe
90
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib resutils.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\PerfmonAgent.pdb" /out:"$(OUTDIR)\PerfmonAgent.exe" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
91
LINK32_OBJS= \
92
	"$(INTDIR)\PerfmonAgent.obj" \
93
	"$(INTDIR)\version.res"
94
95
"$(OUTDIR)\PerfmonAgent.exe" : "$(OUTDIR)" $(LINK32_OBJS)
96
    $(LINK32) @<<
97
  $(LINK32_FLAGS) $(LINK32_OBJS)
98
<<
99
100
!ELSEIF  "$(CFG)" == "PerfmonAgent - IA64 Debug"
101
102
OUTDIR=..\..\..\..\bin
103
INTDIR=.\Debug
104
# Begin Custom Macros
105
OutDir=..\..\..\..\bin
106
# End Custom Macros
107
108
ALL : "$(OUTDIR)\PerfmonAgent.exe"
109
110
111
CLEAN :
112
	-@erase "$(INTDIR)\PerfmonAgent.obj"
113
	-@erase "$(INTDIR)\vc60.idb"
114
	-@erase "$(INTDIR)\version.res"
115
	-@erase "$(OUTDIR)\PerfmonAgent.exe"
116
117
"$(OUTDIR)" :
118
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
119
120
"$(INTDIR)" :
121
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
122
123
CPP=cl.exe
124
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /I "../resutils" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\PerfmonAgent.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
125
126
.c{$(INTDIR)}.obj::
127
   $(CPP) @<<
128
   $(CPP_PROJ) $< 
129
<<
130
131
.cpp{$(INTDIR)}.obj::
132
   $(CPP) @<<
133
   $(CPP_PROJ) $< 
134
<<
135
136
.cxx{$(INTDIR)}.obj::
137
   $(CPP) @<<
138
   $(CPP_PROJ) $< 
139
<<
140
141
.c{$(INTDIR)}.sbr::
142
   $(CPP) @<<
143
   $(CPP_PROJ) $< 
144
<<
145
146
.cpp{$(INTDIR)}.sbr::
147
   $(CPP) @<<
148
   $(CPP_PROJ) $< 
149
<<
150
151
.cxx{$(INTDIR)}.sbr::
152
   $(CPP) @<<
153
   $(CPP_PROJ) $< 
154
<<
155
156
RSC=rc.exe
157
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
158
159
LINK32=link.exe
160
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib resutils.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\PerfmonAgent.pdb" /out:"$(OUTDIR)\PerfmonAgent.exe" /libpath:"$(OUTDIR)\..\lib" /machine:IA64
161
LINK32_OBJS= \
162
	"$(INTDIR)\PerfmonAgent.obj" \
163
	"$(INTDIR)\version.res"
164
165
"$(OUTDIR)\PerfmonAgent.exe" : "$(OUTDIR)" $(LINK32_OBJS)
166
    $(LINK32) @<<
167
  $(LINK32_FLAGS) $(LINK32_OBJS)
168
<<
169
170
!ELSEIF  "$(CFG)" == "PerfmonAgent - X64 Release"
171
172
OUTDIR=..\..\..\..\bin
173
INTDIR=.\Release
174
# Begin Custom Macros
175
OutDir=..\..\..\..\bin
176
# End Custom Macros
177
178
ALL : "$(OUTDIR)\PerfmonAgent.exe"
179
180
181
CLEAN :
182
	-@erase "$(INTDIR)\PerfmonAgent.obj"
183
	-@erase "$(INTDIR)\vc60.idb"
184
	-@erase "$(INTDIR)\version.res"
185
	-@erase "$(OUTDIR)\PerfmonAgent.exe"
186
187
"$(OUTDIR)" :
188
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
189
190
"$(INTDIR)" :
191
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
192
193
CPP=cl.exe
194
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /I "../resutils" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\PerfmonAgent.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
195
196
.c{$(INTDIR)}.obj::
197
   $(CPP) @<<
198
   $(CPP_PROJ) $< 
199
<<
200
201
.cpp{$(INTDIR)}.obj::
202
   $(CPP) @<<
203
   $(CPP_PROJ) $< 
204
<<
205
206
.cxx{$(INTDIR)}.obj::
207
   $(CPP) @<<
208
   $(CPP_PROJ) $< 
209
<<
210
211
.c{$(INTDIR)}.sbr::
212
   $(CPP) @<<
213
   $(CPP_PROJ) $< 
214
<<
215
216
.cpp{$(INTDIR)}.sbr::
217
   $(CPP) @<<
218
   $(CPP_PROJ) $< 
219
<<
220
221
.cxx{$(INTDIR)}.sbr::
222
   $(CPP) @<<
223
   $(CPP_PROJ) $< 
224
<<
225
226
RSC=rc.exe
227
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
228
229
LINK32=link.exe
230
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib resutils.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\PerfmonAgent.pdb" /out:"$(OUTDIR)\PerfmonAgent.exe" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
231
LINK32_OBJS= \
232
	"$(INTDIR)\PerfmonAgent.obj" \
233
	"$(INTDIR)\version.res"
234
235
"$(OUTDIR)\PerfmonAgent.exe" : "$(OUTDIR)" $(LINK32_OBJS)
236
    $(LINK32) @<<
237
  $(LINK32_FLAGS) $(LINK32_OBJS)
238
<<
239
240
!ELSEIF  "$(CFG)" == "PerfmonAgent - X64 Debug"
241
242
OUTDIR=..\..\..\..\bin
243
INTDIR=.\Debug
244
# Begin Custom Macros
245
OutDir=..\..\..\..\bin
246
# End Custom Macros
247
248
ALL : "$(OUTDIR)\PerfmonAgent.exe"
249
250
251
CLEAN :
252
	-@erase "$(INTDIR)\PerfmonAgent.obj"
253
	-@erase "$(INTDIR)\vc60.idb"
254
	-@erase "$(INTDIR)\version.res"
255
	-@erase "$(OUTDIR)\PerfmonAgent.exe"
256
257
"$(OUTDIR)" :
258
    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
259
260
"$(INTDIR)" :
261
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
262
263
CPP=cl.exe
264
CPP_PROJ=/nologo /MD /W3 /EHsc /O2 /I "../resutils" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\PerfmonAgent.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
265
266
.c{$(INTDIR)}.obj::
267
   $(CPP) @<<
268
   $(CPP_PROJ) $< 
269
<<
270
271
.cpp{$(INTDIR)}.obj::
272
   $(CPP) @<<
273
   $(CPP_PROJ) $< 
274
<<
275
276
.cxx{$(INTDIR)}.obj::
277
   $(CPP) @<<
278
   $(CPP_PROJ) $< 
279
<<
280
281
.c{$(INTDIR)}.sbr::
282
   $(CPP) @<<
283
   $(CPP_PROJ) $< 
284
<<
285
286
.cpp{$(INTDIR)}.sbr::
287
   $(CPP) @<<
288
   $(CPP_PROJ) $< 
289
<<
290
291
.cxx{$(INTDIR)}.sbr::
292
   $(CPP) @<<
293
   $(CPP_PROJ) $< 
294
<<
295
296
RSC=rc.exe
297
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\version.res" /d "NDEBUG" 
298
299
LINK32=link.exe
300
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib resutils.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\PerfmonAgent.pdb" /out:"$(OUTDIR)\PerfmonAgent.exe" /libpath:"$(OUTDIR)\..\lib" /machine:AMD64
301
LINK32_OBJS= \
302
	"$(INTDIR)\PerfmonAgent.obj" \
303
	"$(INTDIR)\version.res"
304
305
"$(OUTDIR)\PerfmonAgent.exe" : "$(OUTDIR)" $(LINK32_OBJS)
306
    $(LINK32) @<<
307
  $(LINK32_FLAGS) $(LINK32_OBJS)
308
<<
309
310
!ENDIF 
311
312
313
!IF "$(CFG)" == "PerfmonAgent - IA64 Release" || "$(CFG)" == "PerfmonAgent - IA64 Debug" || "$(CFG)" == "PerfmonAgent - X64 Release" || "$(CFG)" == "PerfmonAgent - X64 Debug"
314
SOURCE=..\PerfmonAgent\PerfmonAgent.cpp
315
316
"$(INTDIR)\PerfmonAgent.obj" : $(SOURCE) "$(INTDIR)"
317
	$(CPP) $(CPP_PROJ) $(SOURCE)
318
319
320
SOURCE=..\PerfmonAgent\version.rc
321
322
!IF  "$(CFG)" == "PerfmonAgent - IA64 Release"
323
324
325
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
326
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "..\PerfmonAgent" /d "NDEBUG" $(SOURCE)
327
328
329
!ELSEIF  "$(CFG)" == "PerfmonAgent - IA64 Debug"
330
331
332
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
333
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "..\PerfmonAgent" /d "NDEBUG" $(SOURCE)
334
335
336
!ELSEIF  "$(CFG)" == "PerfmonAgent - X64 Release"
337
338
339
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
340
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "..\PerfmonAgent" /d "NDEBUG" $(SOURCE)
341
342
343
!ELSEIF  "$(CFG)" == "PerfmonAgent - X64 Debug"
344
345
346
"$(INTDIR)\version.res" : $(SOURCE) "$(INTDIR)"
347
	$(RSC) /l 0x409 /fo"$(INTDIR)\version.res" /i "..\PerfmonAgent" /d "NDEBUG" $(SOURCE)
348
349
350
!ENDIF 
351
352
353
!ENDIF 
354
(-)src-native-new/src/agents/native/java_profiler/eventmask.h (+20 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: eventmask.h,v 1.2 2005/02/25 22:17:34 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef __EVENTMASK_H__
14
	#define  __EVENTMASK_H__ 1
15
16
/* New Events */
17
#define JVMPI_EVENT_THROW                               JVMPI_MAX_EVENT_TYPE_VAL + 1
18
#define JVMPI_EVENT_CATCH                               JVMPI_MAX_EVENT_TYPE_VAL + 2
19
20
#endif
(-)src-native-new/src/agents/perfmon/pluginconfig_linux.xml (+6 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<PluginConfiguration>
3
        <Application configuration="default" executable="LinuxAgent" location="%RASERVER_HOME%/plugins/org.eclipse.hyades.perfmon.linux" path="%RASERVER_HOME%/plugins/org.eclipse.hyades.perfmon.linux/bin/LinuxAgent">
4
                <Variable name="LD_LIBRARY_PATH" position="prepend" value="%RASERVER_HOME%/plugins/org.eclipse.hyades.perfmon.linux/lib"/>
5
        </Application>
6
</PluginConfiguration>
(-)src-native-new/src/agents/thread/hcthread.exp (+6 lines)
Added Link Here
1
Java_org_eclipse_hyades_logging_jvm_threadanalysis_ThreadDumpAgentImpl_init0
2
Java_org_eclipse_hyades_logging_jvm_threadanalysis_ThreadDumpAgentImpl_dumpThreads0
3
Java_org_eclipse_hyades_logging_jvm_threadanalysis_ThreadDumpAgentImpl_deregister0
4
init
5
dump
6
deregister
(-)src-native-new/src/transport/RADataTransfer/RADataTransfer.c (+142 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: RADataTransfer.c,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#include "RADataTransfer.h"
14
#include "RASharedMemory.h"   /* 175248 - added */
15
16
#define RA_MESSAGE_HEADER_SIZE  0x000a
17
18
19
/** ALLOCATE_MESSAGE_BLOCK  ************************************************
20
  * Allocates a block of memory that can be used for a message and returns
21
  * the address where the caller can start adding data.
22
  * IMPORTANT:  must use ra_freeMessageBlock to free the memory when done
23
  * @param  length  - the number of bytes required for the message
24
  * @returns        - the address where the message can be written to.  NULL if
25
  *                   there is no available memory.
26
  */
27
unsigned char *ra_allocateMessageBlock(ra_uint_t length) {
28
	ra_uint_t size=length+RA_MESSAGE_HEADER_SIZE;
29
	void *p=(void*)malloc(size);
30
	if(p==NULL) {
31
		return NULL;
32
	}
33
	return ((unsigned char*)p+RA_MESSAGE_HEADER_SIZE);
34
}
35
36
/** REALLOCATE_MESSAGE_BLOCK  ************************************************
37
  * Recieves an existing message block and allocates a block of memory with the
38
  * newley specified size.  The data in the existing message block is copied
39
  * to the new message block.
40
  * IMPORTANT:  must use ra_freeMessageBlock to free the memory when done
41
  * @param  message - the existing message block.
42
  * @param  length  - the number of bytes required for the new message
43
  * @returns        - the address where the message can be written to.  NULL if
44
  *                   there is no available memory.
45
  */
46
unsigned char *ra_reallocateMessageBlock(unsigned char *message,
47
										 ra_uint_t length) {
48
	ra_uint_t size=length+RA_MESSAGE_HEADER_SIZE;
49
	void *p=(void*)realloc((void*)(message-RA_MESSAGE_HEADER_SIZE), size);
50
	if(p==NULL) {
51
		if(size==0) {
52
			return NULL;
53
		}
54
		return message;
55
	}
56
	return ((unsigned char*)p+RA_MESSAGE_HEADER_SIZE);
57
}
58
59
60
/** FREE_MESSAGE_BLOCK  ************************************************
61
  * Free's a block of message memory
62
  * @param message - the address returned by ra_allocateMessageBlock
63
  */
64
void ra_freeMessageBlock(unsigned char *message) {
65
	free((void*)(message-RA_MESSAGE_HEADER_SIZE));
66
}
67
68
69
/** WRITE_MESSAGE_BLOCK *************************************************
70
  * Writes a message to the specified target using the specified format.
71
  * DNS changed @param from fd - the target SOCKET object to the following
72
  * @param  dthdl  - the handle of the target to write the data to.
73
  * @param  format - the format to use
74
  * @param message - the address of the start of the message.
75
  * @param  length - the number of bytes to write to fd.
76
  * @returns       - the number of bytes written to the socket.
77
  */
78
/* DNS extern unsigned short ra_writeMessageBlock(SOCKET fd, */
79
ra_uint_t ra_writeMessageBlock(ra_data_target_hdl_t *dthdl,
80
										   dataFormat_t format,
81
										   unsigned char *message,
82
										   ra_uint_t length) {
83
	ra_uint_t bytesWritten=0;
84
85
	if (!dthdl || !message) {
86
		return 0; 
87
	}
88
	/* Place the majic header */
89
	message[-10]=(unsigned char)(RA_MAGIC>>24);
90
	message[-9]=(unsigned char)(RA_MAGIC>>16);
91
	message[-8]=(unsigned char)(RA_MAGIC>>8);
92
	message[-7]=(unsigned char)(RA_MAGIC);
93
94
	/* Place the endian bits in the header */
95
	message[-6]=0xff;
96
	
97
	/* Place the length in the header */
98
	message[-5]=(unsigned char)(length>>24 & 0x000000ff);
99
	message[-4]=(unsigned char)(length>>16 & 0x000000ff);
100
	message[-3]=(unsigned char)(length>>8  & 0x000000ff);
101
	message[-2]=(unsigned char)length;
102
103
	/* Place the format specifier in the message */
104
	message[-1]=format;
105
106
	/* Write to the proper device */
107
	if ( dthdl->dtarget == RA_SOCKET ) {
108
	   bytesWritten=ra_writeToSocket(dthdl->dtargetHdl.socketFD,
109
							(char*)&message[-RA_MESSAGE_HEADER_SIZE],
110
							(length+RA_MESSAGE_HEADER_SIZE));
111
112
/*    DNS changed return value by subtracting the header size
113
          because that is what the user expects */
114
	   if(bytesWritten>0) {
115
		   return bytesWritten-RA_MESSAGE_HEADER_SIZE;
116
	   }
117
	   else {
118
		   return 0;
119
	   }
120
	}
121
	else if ( dthdl->dtarget == RA_SHAREDMEMORY ) {
122
	   ra_uint_t length2 = length + RA_MESSAGE_HEADER_SIZE;
123
      ra_uint_t rc;   /* 194539 */
124
	   /* Write to the shared memory buffer */
125
	   rc = ra_writeToShm((OSSRambo *)dthdl->dtargetHdl.shmHdl,   /* 175248 */
126
					&message[-RA_MESSAGE_HEADER_SIZE],
127
  					(length2));
128
/* 194539 begin */
129
      if (0 != rc ) {
130
   		ra_setLastError(SHM_WRITE_FAILED, rc);
131
         return 0;
132
      }
133
      else {
134
/* 194539 end */
135
         return (length2 - RA_MESSAGE_HEADER_SIZE);
136
      }  /* 194539 */
137
   }
138
/* TO DO DNS - add code to write to a file */
139
	else {
140
      return 0;
141
	}
142
}
(-)src-native-new/src/agents/native/java_profiler/strings.h (+369 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: strings.h,v 1.6 2006/06/05 23:12:42 bduncan Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef _STRINGS_H_
14
#define _STRINGS_H_
15
16
/** This is a list of all the hardcoded strings that are used during IO
17
    operations on the agent and the length of each string.  This is used
18
	to streamline IO operations
19
  */
20
#define UNAVAILABLE								"-Unavailable-"
21
#define STRLEN_UNAVAILABLE						11
22
23
/* XML Elements */
24
25
#define METHOD_EXIT_ELEMENT						"methodExit"
26
#define STRLEN_METHOD_EXIT_ELEMENT				10
27
#define METHOD_RETURN_ELEMENT					"methodReturn"
28
#define STRLEN_METHOD_RETURN_ELEMENT			12
29
#define JVM_SHUT_DOWN_ELEMENT					"runtimeShutdown"
30
#define STRLEN_JVM_SHUT_DOWN_ELEMENT			15
31
#define TRACE_STOP_ELEMENT						"traceEnd"
32
#define STRLEN_TRACE_STOP_ELEMENT				8
33
#define CLASS_UNLOAD_ELEMENT					"classUnload"
34
#define STRLEN_CLASS_UNLOAD_ELEMENT				11
35
#define JVM_INIT_DONE_ELEMENT					"runtimeInitDone"
36
#define STRLEN_JVM_INIT_DONE_ELEMENT			15
37
#define OBJ_ALLOC_ELEMENT						"objAlloc"
38
#define STRLEN_OBJ_ALLOC_ELEMENT				8
39
#define GC_START_ELEMENT						"gcStart"
40
#define STRLEN_GC_START_ELEMENT					7
41
#define GC_FINISH_ELEMENT						"gcFinish"
42
#define STRLEN_GC_FINISH_ELEMENT				8
43
#define HD_START_ELEMENT						"heapDumpDef"
44
#define STRLEN_HD_START_ELEMENT					11
45
#define HD_FINISH_ELEMENT						"hdFinish"
46
#define STRLEN_HD_FINISH_ELEMENT				8
47
#define OBJ_FREE_ELEMENT						"objFree"
48
#define STRLEN_OBJ_FREE_ELEMENT					7
49
#define OBJ_MOVE_ELEMENT						"objMove"
50
#define STRLEN_OBJ_MOVE_ELEMENT					7
51
#define THREAD_END_ELEMENT						"threadEnd"
52
#define STRLEN_THREAD_END_ELEMENT				9
53
#define OPTION_ELEMENT							"option"
54
#define STRLEN_OPTION_ELEMENT					6
55
#define FILTER_ELEMENT							"filter"
56
#define STRLEN_FILTER_ELEMENT					6
57
#define THREAD_START_ELEMENT					"threadStart"
58
#define STRLEN_THREAD_START_ELEMENT				11
59
#define CLASS_ELEMENT							"CLASS"
60
#define STRLEN_CLASS_ELEMENT					5
61
#define CLASS_LOAD_ELEMENT						"classDef"
62
#define STRLEN_CLASS_LOAD_ELEMENT				8
63
#define METHOD_ELEMENT							"methodDef"
64
#define STRLEN_METHOD_ELEMENT					9
65
#define STATIC_FIELD_ELEMENT					"staticField"
66
#define STRLEN_STATIC_FIELD_ELEMENT				11
67
#define INSTANCE_FIELD_ELEMENT					"instanceField"
68
#define STRLEN_INSTANCE_FIELD_ELEMENT			13
69
#define METHOD_COUNT_ELEMENT					"methodCount"
70
#define STRLEN_METHOD_COUNT_ELEMENT				11
71
#define TRACE_START_ELEMENT						"traceStart"
72
#define STRLEN_TRACE_START_ELEMENT				10
73
#define PROCESS_SUSPEND_ELEMENT					"processSuspend"
74
#define STRLEN_PROCESS_SUSPEND_ELEMENT			14
75
#define PROCESS_RESUME_ELEMENT					"processResume"
76
#define STRLEN_PROCESS_RESUME_ELEMENT			13
77
#define TRACE_ELEMENT							"traceRoot"
78
#define STRLEN_TRACE_ELEMENT					9
79
#define CATCH_ELEMENT							"catch"
80
#define STRLEN_CATCH_ELEMENT					5
81
#define THROW_ELEMENT							"throw"
82
#define STRLEN_THROW_ELEMENT					5
83
#define METHOD_ENTRY_ATTRIBUTE					"methodEntry"
84
#define STRLEN_METHOD_ENTRY_ATTRIBUTE			11
85
#define METHOD_CALL_ATTRIBUTE					"methodCall"
86
#define STRLEN_METHOD_CALL_ATTRIBUTE			10
87
#define AGENT_CREATE_ELEMENT                    "agentCreate"
88
#define STRLEN_AGENT_CREATE_ELEMENT             11
89
#define AGENT_DESTROY_ELEMENT                   "agentDestroy"
90
#define STRLEN_AGENT_DESTROY_ELEMENT            12
91
#define NODE_ELEMENT                            "node"
92
#define STRLEN_NODE_ELEMENT                     4
93
#define PROCESS_CREATE_ELEMENT                  "processCreate"
94
#define STRLEN_PROCESS_CREATE_ELEMENT           13
95
#define LINE_ELEMENT							"line"
96
#define STRLEN_LINE_ELEMENT						4
97
#define OBJECT_REFERENCE_ATTRIBUTE				"objReference"
98
#define STRLEN_OBJECT_REFERENCE_ATTRIBUTE		12
99
#define STATIC_REFERENCE_ATTRIBUTE				"staticReference"
100
#define STRLEN_STATIC_REFERENCE_ATTRIBUTE       15
101
#define GC_ROOT_ELEMENT							"gcRoot"
102
#define STRLEN_GC_ROOT_ELEMENT					6
103
104
#define MONITOR_WAIT_ELEMENT					"monWait"
105
#define STRLEN_MONITOR_WAIT_ELEMENT				7
106
#define MONITOR_WAITED_ELEMENT					"monWaited"
107
#define STRLEN_MONITOR_WAITED_ELEMENT			9
108
#define MONITOR_STILL_OWNED_EVENT				"monStillOwned"
109
#define STRLEN_MONITOR_STILL_OWNED_EVENT		13
110
#define MONITOR_CONTENDED_ENTER_ELEMENT			"monContendedEnter"
111
#define STRLEN_MONITOR_CONTENDED_ENTER_ELEMENT	17
112
#define MONITOR_CONTENDED_ENTERED_ELEMENT		"monContendedEntered"
113
#define STRLEN_MONITOR_CONTENDED_ENTERED_ELEMENT 19
114
115
/* The following 2 constants were added for bug 135437 (preAgg piAgent). */
116
#define AG_METHOD_ENTRY_ELEMENT					"agMethodEntry"
117
#define STRLEN_AG_METHOD_ENTRY_ELEMENT			13
118
#define AG_METHOD_EXIT_ELEMENT					"agMethodExit"
119
#define STRLEN_AG_METHOD_EXIT_ELEMENT			12
120
121
122
123
/* XML Attributes */
124
125
#define CLASS_ID_ATTRIBUTE						"transientClassId"
126
#define STRLEN_CLASS_ID_ATTRIBUTE				16
127
#define CLASS_IDREF_ATTRIBUTE					"transientClassIdRef"
128
#define STRLEN_CLASS_IDREF_ATTRIBUTE			19
129
#define METHOD_ID_ATTRIBUTE						"transientMethodId"
130
#define STRLEN_METHOD_ID_ATTRIBUTE				17
131
#define METHOD_IDREF_ATTRIBUTE					"transientMethodIdRef"
132
#define STRLEN_METHOD_IDREF_ATTRIBUTE			20
133
#define OBJ_ID_ATTRIBUTE						"transientObjId"
134
#define STRLEN_OBJ_ID_ATTRIBUTE					14
135
#define OBJ_IDREF_ATTRIBUTE						"transientObjIdRef"
136
#define STRLEN_OBJ_IDREF_ATTRIBUTE				17
137
#define THREAD_ID_ATTRIBUTE						"transientThreadId"
138
#define STRLEN_THREAD_ID_ATTRIBUTE				17
139
#define STATIC_THREAD_ID_ATTRIBUTE				"threadId"
140
#define STRLEN_STATIC_THREAD_ID_ATTRIBUTE		8
141
#define THREAD_IDREF_ATTRIBUTE					"transientThreadIdRef"
142
#define STRLEN_THREAD_IDREF_ATTRIBUTE			20
143
#define STATIC_THREAD_IDREF_ATTRIBUTE			"threadIdRef"
144
#define STRLEN_STATIC_THREAD_IDREF_ATTRIBUTE	11
145
#define STATIC_CLASS_ID_ATTRIBUTE				"classId"
146
#define STRLEN_STATIC_CLASS_ID_ATTRIBUTE		7
147
#define STATIC_CLASS_IDREF_ATTRIBUTE			"classIdRef"
148
#define STRLEN_STATIC_CLASS_IDREF_ATTRIBUTE		10
149
#define STATIC_OBJ_ID_ATTRIBUTE					"objId"
150
#define STRLEN_STATIC_OBJ_ID_ATTRIBUTE			5
151
#define STATIC_OBJ_IDREF_ATTRIBUTE				"objIdRef"
152
#define STRLEN_STATIC_OBJ_IDREF_ATTRIBUTE		8
153
#define STATIC_METHOD_ID_ATTRIBUTE				"methodId"
154
#define STRLEN_STATIC_METHOD_ID_ATTRIBUTE		8
155
#define STATIC_METHOD_IDREF_ATTRIBUTE			"methodIdRef"
156
#define STRLEN_STATIC_METHOD_IDREF_ATTRIBUTE	11
157
158
/* Test  */
159
#define TRACE_FLAG4OWN_ATTRIBUTE 				"traceFlag4Own"
160
#define STRLEN_TRACE_FLAG4OWN_ATTRIBUTE			13
161
#define TRACE_FLAG4REF_ATTRIBUTE 				"traceFlag4Ref"
162
#define STRLEN_TRACE_FLAG4REF_ATTRIBUTE			13
163
/* Test  */
164
165
#define STATIC_ID_ATTRIBUTE						"static_id"
166
#define STRLEN_STATIC_ID_ATTRIBUTE				9
167
#define OBJ_HANDLE_ATTRIBUTE					"objHandle"
168
#define STRLEN_OBJ_HANDLE_ATTRIBUTE				9
169
#define TICKET_ATTRIBUTE						"ticket"
170
#define STRLEN_TICKET_ATTRIBUTE					6
171
#define ENV_ID_ATTRIBUTE						"env_id"
172
#define STRLEN_ENV_ID_ATTRIBUTE					6
173
#define STACK_DEPTH_ATTRIBUTE					"stackDepth"
174
#define STRLEN_STACK_DEPTH_ATTRIBUTE			10
175
#define ID_ATTRIBUTE							"id"
176
#define STRLEN_ID_ATTRIBUTE						2
177
#define USED_OBJECTS_ATTRIBUTE					"usedObjects"
178
#define STRLEN_USED_OBJECTS_ATTRIBUTE			11
179
#define USED_OBJECT_SPACE_ATTRIBUTE				"usedObjSpace"
180
#define STRLEN_USED_OBJECT_SPACE_ATTRIBUTE		12
181
#define TOTAL_OBJECT_SPACE_ATTRIBUTE			"totalObjSpace"
182
#define STRLEN_TOTAL_OBJECT_SPACE_ATTRIBUTE		13
183
#define ARENA_ID_ATTRIBUTE						"arena_id"
184
#define STRLEN_ARENA_ID_ATTRIBUTE				8
185
#define IS_ARRAY_ATTRIBUTE						"isArray"
186
#define STRLEN_IS_ARRAY_ATTRIBUTE				7
187
#define SIZE_ATTRIBUTE							"size"
188
#define STRLEN_SIZE_ATTRIBUTE					4
189
#define NEW_ARENA_ID_ATTRIBUTE					"new_arena_id"
190
#define STRLEN_NEW_ARENA_ID_ATTRIBUTE			12
191
#define NEW_OBJ_ID_ATTRIBUTE					"newObjId"
192
#define STRLEN_NEW_OBJ_ID_ATTRIBUTE				8
193
#define THREAD_NAME_ATTRIBUTE					"threadName"
194
#define STRLEN_THREAD_NAME_ATTRIBUTE			10
195
#define GROUP_NAME_ATTRIBUTE					"groupName"
196
#define STRLEN_GROUP_NAME_ATTRIBUTE				9
197
#define PARENT_NAME_ATTRIBUTE					"parentName"
198
#define STRLEN_PARENT_NAME_ATTRIBUTE			10
199
#define THREAD_OBJ_ID_ATTRIBUTE					"thread_obj_id"
200
#define STRLEN_THREAD_OBJ_ID_ATTRIBUTE			13
201
#define THREAD_ENV_ID_ATTRIBUTE					"thread_env_id"
202
#define STRLEN_THREAD_ENV_ID_ATTRIBUTE			13
203
#define KEY_ATTRIBUTE							"key"
204
#define STRLEN_KEY_ATTRIBUTE					3
205
#define VALUE_ATTRIBUTE							"value"
206
#define STRLEN_VALUE_ATTRIBUTE					5
207
#define TIME_ATTRIBUTE							"time"
208
#define STRLEN_TIME_ATTRIBUTE					4
209
#define THREAD_CPU_TIME_ATTRIBUTE				"cpuTime"
210
#define STRLEN_THREAD_CPU_TIME_ATTRIBUTE		7
211
#define TYPE_ATTRIBUTE							"type"
212
#define STRLEN_TYPE_ATTRIBUTE					4
213
#define CLASS_MODE_ATTRIBUTE					"mode"
214
#define STRLEN_CLASS_MODE_ATTRIBUTE				4
215
#define METHOD_MODE_ATTRIBUTE					"methodMode"
216
#define STRLEN_METHOD_MODE_ATTRIBUTE			10
217
#define PATTERN_ATTRIBUTE						"pattern"
218
#define STRLEN_PATTERN_ATTRIBUTE				7
219
#define METHOD_PATTERN_ATTRIBUTE				"methodPattern"
220
#define STRLEN_METHOD_PATTERN_ATTRIBUTE			13
221
#define GENERICPATTERN_ATTRIBUTE				"genericPattern"
222
#define STRLEN_GENERICPATTERN_ATTRIBUTE			14
223
#define METHOD_GENERICPATTERN_ATTRIBUTE			"methodGenericPattern"
224
#define STRLEN_METHOD_GENERICPATTERN_ATTRIBUTE	20
225
#define NAME_ATTRIBUTE							"name"
226
#define STRLEN_NAME_ATTRIBUTE					4
227
#define SIGNATURE_ATTRIBUTE						"signature"
228
#define STRLEN_SIGNATURE_ATTRIBUTE				9
229
#define START_LINENO_ATTRIBUTE					"startLineNumber"
230
#define STRLEN_START_LINENO_ATTRIBUTE			15
231
#define END_LINENO_ATTRIBUTE					"endLineNumber"
232
#define STRLEN_END_LINENO_ATTRIBUTE				13
233
#define IS_NATIVE_ATTRIBUTE						"isNative"
234
#define STRLEN_IS_NATIVE_ATTRIBUTE				8
235
#define IS_ABSTRACT_ATTRIBUTE					"isAbstract"
236
#define STRLEN_IS_ABSTRACT_ATTRIBUTE			10
237
#define IS_STATIC_ATTRIBUTE						"isStatic"
238
#define STRLEN_IS_STATIC_ATTRIBUTE				8
239
#define IS_SYNCHRONIZED_ATTRIBUTE				"isSynchronized"
240
#define STRLEN_IS_SYNCHRONIZED_ATTRIBUTE		14
241
#define VISIBILITY_ATTRIBUTE					"visibility"
242
#define STRLEN_VISIBILITY_ATTRIBUTE				10
243
#define EXCEPTIONS_ATTRIBUTE					"exceptions"
244
#define STRLEN_EXCEPTIONS_ATTRIBUTE				10
245
#define SOURCE_NAME_ATTRIBUTE					"sourceName"
246
#define STRLEN_SOURCE_NAME_ATTRIBUTE			10
247
#define NUM_INTERFACES_ATTRIBUTE				"numInterfaces"
248
#define STRLEN_NUM_INTERFACES_ATTRIBUTE			13
249
#define CLASS_LOADER_NAME						"classLoader"
250
#define STRLEN_CLASS_LOADER_NAME				11
251
#define SUPER_CLASS_NAME_ATTRIBUTE				"superclass"
252
#define STRLENT_SUPER_CLASS_NAME_ATTRIBUTE		10
253
#define INTERFACE_NAMES_ATTRIBUTE				"interfaceNames"
254
#define STRLEN_INTERFACE_NAMES_ATTRIBUTE		14
255
#define NUM_METHODS_ATTRIBUTE					"numMethods"
256
#define STRLEN_NUM_METHODS_ATTRIBUTE			10
257
#define FIELD_ID_ATTRIBUTE						"fieldId"
258
#define STRLEN_FIELD_ID_ATTRIBUTE				7
259
#define FIELD_IDREF_ATTRIBUTE					"fieldIdRef"
260
#define STRLEN_FIELD_IDREF_ATTRIBUTE			10
261
#define NUM_STATIC_FIELDS_ATTRIBUTE				"numStaticFields"
262
#define STRLEN_NUM_STATIC_FIELDS_ATTRIBUTE		15
263
#define NUM_INSTANCE_FIELDS_ATTRIBUTE			"numInstanceFields"
264
#define STRLEN_NUM_INSTANCE_FIELDS_ATTRIBUTE	17
265
#define COUNT_ATTRIBUTE							"count"
266
#define STRLEN_COUNT_ATTRIBUTE					5
267
#define PID_ATTRIBUTE							"pid"
268
#define STRLEN_PID_ATTRIBUTE					3
269
#define HOSTNAME_ATTRIBUTE						"hostname"
270
#define STRLEN_HOSTNAME_ATTRIBUTE				8
271
#define IPADDRESS_ATTRIBUTE						"ipaddress"
272
#define STRLEN_IPADDRESS_ATTRIBUTE				9
273
#define DATE_ATTRIBUTE							"date"
274
#define STRLEN_DATE_ATTRIBUTE					4
275
#define TIMEZONE_ATTRIBUTE						"timezone"
276
#define STRLEN_TIMEZONE_ATTRIBUTE				8
277
#define INVOCATIONOPTIONS_ATTRIBUTE				"invocationOptions"
278
#define STRLEN_INVOCATIONOPTIONS_ATTRIBUTE		17
279
#define TRACE_ID_ATTRIBUTE	                    "traceId"
280
#define STRLEN_TRACE_ID_ATTRIBUTE               7
281
#define TRACE_IDREF_ATTRIBUTE                   "traceIdRef"
282
#define STRLEN_TRACE_IDREF_ATTRIBUTE            10
283
#define AGENT_ID_ATTRIBUTE                      "agentId"
284
#define STRLEN_AGENT_ID_ATTRIBUTE               7
285
#define AGENT_IDREF_ATTRIBUTE                   "agentIdRef"
286
#define STRLEN_AGENT_IDREF_ATTRIBUTE            10
287
#define PROCESS_IDREF_ATTRIBUTE                 "processIdRef"
288
#define STRLEN_PROCESS_IDREF_ATTRIBUTE          12
289
#define AGENT_NAME_ATTRIBUTE                    "agentName"
290
#define STRLEN_AGENT_NAME_ATTRIBUTE             9
291
#define AGENT_PARAMETERS_ATTRIBUTE              "agentParameters"
292
#define STRLEN_AGENT_PARAMETERS_ATTRIBUTE       15
293
#define COLLATION_VALUE_ATTRIBUTE               "collationValue"
294
#define STRLEN_COLLATION_VALUE_ATTRIBUTE        14
295
#define NODE_ID_ATTRIBUTE                       "nodeId"
296
#define STRLEN_NODE_ID_ATTRIBUTE                6
297
#define NODE_IDREF_ATTRIBUTE                    "nodeIdRef"
298
#define STRLEN_NODE_IDREF_ATTRIBUTE             9
299
#define PROCESS_ID_ATTRIBUTE                    "processId"
300
#define STRLEN_PROCESS_ID_ATTRIBUTE             9
301
#define ENVIRONMENT_ATTRIBUTE                   "environment"
302
#define STRLEN_ENVIRONMENT_ATTRIBUTE            11
303
#define APPLICATION_PARMS_ATTRIBUTE             "application_parameters"
304
#define STRLEN_APPLICATION_PARMS_ATTRIBUTE      22
305
#define APPLICATION_NAME_ATTRIBUTE              "application_executable"
306
#define STRLEN_APPLICATION_NAME_ATTRIBUTE       22
307
#define PROCESS_OPTIONS_ATTRIBUTE               "process_options"
308
#define STRLEN_PROCESS_OPTIONS_ATTRIBUTE        15
309
#define SEQUENCE_COUNTER_ATTRIBUTE              "sequenceCounter"
310
#define STRLEN_SEQUENCE_COUNTER_ATTRIBUTE       15
311
#define CONTEXT_DATA_ATTRIBUTE                  "contextData"
312
#define STRLEN_CONTEXT_DATA_ATTRIBUTE           11
313
#define AGENT_VERSION_ATTRIBUTE		            "version"
314
#define STRLEN_AGENT_VERSION_ATTRIBUTE          7
315
#define LINE_NUMBER_ATTRIBUTE					"line_number"
316
#define STRLEN_LINE_NUMBER_ATTRIBUTE			11
317
#define OBJECT_OWNER_ATTRIBUTE					"ownerObjIdRef"
318
#define STRLEN_OBJECT_OWNER_ATTRIBUTE			13
319
#define OBJECT_TARGET_ATTRIBUTE					"targetObjIdRef"
320
#define STRLEN_OBJECT_TARGET_ATTRIBUTE			14
321
#define OBJECT_ARRAY_INDEX_ATTRIBUTE	    	"objArrayIndex"
322
#define STRLEN_OBJECT_ARRAY_INDEX_ATTRIBUTE	    13
323
#define OBJECT_FIELD_INDEX_ATTRIBUTE	    	"fieldIndex"
324
#define STRLEN_OBJECT_FIELD_INDEX_ATTRIBUTE	    10
325
#define HEAPDUMP_IDREF_ATTRIBUTE				"heapDumpIdRef"
326
#define STRLEN_HEAPDUMP_IDREF_ATTRIBUTE			13
327
#define HEAPDUMP_ID_ATTRIBUTE					"heapDumpId"
328
#define STRLEN_HEAPDUMP_ID_ATTRIBUTE			10
329
#define AGENT_TYPE_ATTRIBUTE					"agentType"
330
#define STRLEN_AGENT_TYPE_ATTRIBUTE				9
331
#define BASETIME_ATTRIBUTE						"basetime"
332
#define STRLEN_BASETIME_ATTRIBUTE				8
333
334
/* The following 3 constants were added for bug 135437 (preAgg piAgent).
335
 * A second version of bastetime (ie: baseTime) was added because that 
336
 * is the preferred casing of the loader going forward but the old 
337
 * casing is needed for backward compatability 
338
 */
339
#define BASETIME1_ATTRIBUTE						"baseTime"
340
#define STRLEN_BASETIME1_ATTRIBUTE				8
341
#define MAXTIME_ATTRIBUTE						"maxTime"
342
#define STRLEN_MAXTIME_ATTRIBUTE				7
343
#define MINTIME_ATTRIBUTE						"minTime"
344
#define STRLEN_MINTIME_ATTRIBUTE				7
345
346
#define CLASS_OWNER_ATTRIBUTE					"ownerClassIdRef"
347
#define STRLEN_CLASS_OWNER_ATTRIBUTE			15
348
#define OVERHEAD_ATTRIBUTE						"overhead"
349
#define STRLEN_OVERHEAD_ATTRIBUTE				8
350
#define GC_ROOT_TYPE_ATTRIBUTE					"type"
351
#define STRLEN_GC_ROOT_TYPE_ATTRIBUTE			4
352
#define HEAPDUMP_FIRST_SEEN_ATTRIBUTE			"firstSeenIndex"
353
#define STRLEN_HEAPDUMP_FIRST_SEEN_ATTRIBUTE	14
354
355
#define TIMEOUT_ATTRIBUTE						"timeout"
356
#define STRLEN_TIMEOUT_ATTRIBUTE				7
357
#define THREAD_OWNER_ATTRIBUTE					"threadOwner"
358
#define STRLEN_THREAD_OWNER_ATTRIBUTE			11
359
360
/* XML Attribute Values */
361
#define CLASS_VALUE								"CLASS"
362
#define METHOD_VALUE							"METHOD"
363
#define INCLUDE_VALUE							"INCLUDE"
364
#define EXCLUDE_VALUE							"EXCLUDE"
365
#define PREFIX_VALUE							"PREFIX"
366
#define SUFFIX_VALUE							"SUFFIX"
367
#define NONE_VALUE								"NONE"
368
369
#endif
(-)src-native-new/src/HCLauncher/hclaunch.h (+114 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: hclaunch.h,v 1.2 2005/02/25 22:17:35 hleung Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
/* DO NOT EDIT THIS FILE - it is machine generated */
14
#include <jni.h>
15
/* Header for class org_eclipse_hyades_execution_core_impl_ExecutionEnvironmentImpl */
16
17
#ifndef _Included_org_eclipse_hyades_execution_core_impl_ExecutionEnvironmentImpl
18
#define _Included_org_eclipse_hyades_execution_core_impl_ExecutionEnvironmentImpl
19
#ifdef __cplusplus
20
extern "C" {
21
#endif
22
/* Inaccessible static: originalProcessEnvironment */
23
/*
24
 * Class:     org_eclipse_hyades_execution_core_impl_ExecutionEnvironmentImpl
25
 * Method:    getNativeSystemEnvironment0
26
 * Signature: ()[Ljava/lang/Object;
27
 */
28
JNIEXPORT jobjectArray JNICALL Java_org_eclipse_hyades_execution_core_impl_ExecutionEnvironmentImpl_getNativeSystemEnvironment0
29
  (JNIEnv *, jobject);
30
31
#ifdef __cplusplus
32
}
33
#endif
34
#endif
35
/* Header for class org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl */
36
37
#ifndef _Included_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl
38
#define _Included_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl
39
#ifdef __cplusplus
40
extern "C" {
41
#endif
42
/*
43
 * Class:     org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl
44
 * Method:    startProcess0
45
 * Signature: ()I
46
 */
47
JNIEXPORT jint JNICALL Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_startProcess0
48
  (JNIEnv *, jobject);
49
50
/*
51
 * Class:     org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl
52
 * Method:    killProcess0
53
 * Signature: ()V
54
 */
55
JNIEXPORT void JNICALL Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_killProcess0
56
  (JNIEnv *, jobject);
57
58
/*
59
 * Class:     org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl
60
 * Method:    writeToProcess0
61
 * Signature: (C)V
62
 */
63
JNIEXPORT void JNICALL Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_writeToProcess0
64
  (JNIEnv *, jobject, jchar);
65
66
/*
67
 * Class:     org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl
68
 * Method:    readFromProcessOutput0
69
 * Signature: ()I
70
 */
71
JNIEXPORT jint JNICALL Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_readFromProcessOutput0
72
  (JNIEnv *, jobject);
73
74
/*
75
 * Class:     org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl
76
 * Method:    readFromProcessError0
77
 * Signature: ()I
78
 */
79
JNIEXPORT jint JNICALL Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_readFromProcessError0
80
  (JNIEnv *, jobject);
81
82
/*
83
 * Class:     org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl
84
 * Method:    getProcessStatus0
85
 * Signature: (I)I
86
 */
87
JNIEXPORT jint JNICALL Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_getProcessStatus0
88
  (JNIEnv *, jobject, jint);
89
90
#ifdef __cplusplus
91
}
92
#endif
93
#endif
94
/* Header for class org_eclipse_hyades_execution_core_IExecutionComponent */
95
96
#ifndef _Included_org_eclipse_hyades_execution_core_IExecutionComponent
97
#define _Included_org_eclipse_hyades_execution_core_IExecutionComponent
98
#ifdef __cplusplus
99
extern "C" {
100
#endif
101
#undef org_eclipse_hyades_execution_core_IExecutionComponent_INACTIVE
102
#define org_eclipse_hyades_execution_core_IExecutionComponent_INACTIVE 0L
103
#undef org_eclipse_hyades_execution_core_IExecutionComponent_NOT_CONFIGURED
104
#define org_eclipse_hyades_execution_core_IExecutionComponent_NOT_CONFIGURED 1L
105
#undef org_eclipse_hyades_execution_core_IExecutionComponent_READY
106
#define org_eclipse_hyades_execution_core_IExecutionComponent_READY 2L
107
#undef org_eclipse_hyades_execution_core_IExecutionComponent_SUSPENDED
108
#define org_eclipse_hyades_execution_core_IExecutionComponent_SUSPENDED 3L
109
#undef org_eclipse_hyades_execution_core_IExecutionComponent_DEAD
110
#define org_eclipse_hyades_execution_core_IExecutionComponent_DEAD 4L
111
#ifdef __cplusplus
112
}
113
#endif
114
#endif
(-)src-native-new/src/agents/perfmon/PerfmonAgent/PerfmonAgent.make (+107 lines)
Added Link Here
1
2
################################################################################
3
#                                       
4
#  makefile:  PerfmonAgent project   
5
#                                       
6
# $Id: PerfmonAgent.make,v 1.9 2007/03/22 00:00:00 samwai Exp $                                  
7
################################################################################
8
9
10
#-----------------------------------
11
#
12
#   Customizable section
13
#
14
#-----------------------------------
15
TARGET         :=  LinuxAgent
16
TARGETDIR      :=  ../../../../bin
17
18
19
#-----------------------------------
20
#   list of additional INCLUDE directories to search headers from
21
#      (separated by blanks)
22
#-----------------------------------
23
24
INCLUDEDIRS    :=  . ../resutils
25
26
27
#-----------------------------------
28
#   list of additional libraries to be linked with
29
#      (separated by blanks)
30
#-----------------------------------
31
32
LIBS       :=  dl pthread resutils
33
34
#-----------------------------------
35
#   list of additional library directories to search from
36
#      (separated by blanks)
37
#-----------------------------------
38
39
LIBDIRS    :=  ../../../../lib
40
41
42
#-----------------------------------
43
#
44
#   Compiler options
45
#
46
#      -g       produce debug info
47
#      -Wall    enable all types of warnings
48
#      -O3      highest level of code optimization
49
#      -fPIC    generate position-independent code (PIC).
50
#               This is required for building shared library.
51
#      -c       compile only
52
#
53
#   Linking options
54
#
55
#       -Wl       pass options to linker
56
#       -shared   produce shared library
57
#       -L        add the given directory to the search path for libraries
58
#
59
#-----------------------------------
60
61
CFLAGS     :=  $(C_FLAGS) $(DEBUGABLE) -Wall $(OPTIMIZABLE) -fPIC $(addprefix -I,$(INCLUDEDIRS))  -D_LINUX_X86 -D_TPTP_DIAGNOSTIC_ -DLINUX
62
63
CXXFLAGS   :=  $(CFLAGS)
64
65
LINKOPTS   :=  $(L_FLAGS) $(DEBUGABLE) -o $(TARGETDIR)/$(TARGET) $(addprefix -L,$(LIBDIRS)) -DLINUX
66
67
68
#-----------------------------------
69
#   general commands and options
70
#-----------------------------------
71
72
CC          :=  gcc
73
CXX         :=  $(CC)
74
75
SOURCE      :=  $(wildcard *.c) $(wildcard *.cpp)
76
77
OBJS        :=  $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
78
79
REMOVEFILE :=  rm -f
80
CREATELINK :=  ln -sf
81
82
83
#-----------------------------------
84
#   "make" rules
85
#-----------------------------------
86
87
.PHONY : default everything objs clean veryclean rebuild $(TARGET)
88
89
90
default : $(TARGET)
91
92
93
objs : $(OBJS)
94
95
96
clean :
97
	$(REMOVEFILE) *.o
98
99
veryclean: clean
100
	$(REMOVEFILE) $(TARGETDIR)/$(TARGET)
101
102
rebuild: veryclean everything
103
104
105
$(TARGET) : $(OBJS)
106
	$(CC) $(LINKOPTS) $(OBJS) $(addprefix -l,$(LIBS))
107
(-)src-native-new/src/HCLauncher/hclaunch.c (+922 lines)
Added Link Here
1
/**********************************************************************
2
Copyright (c) 2005, 2007 IBM Corporation and others.
3
All rights reserved.   This program and the accompanying materials
4
are made available under the terms of the Eclipse Public License v1.0
5
which accompanies this distribution, and is available at
6
http://www.eclipse.org/legal/epl-v10.html
7
$Id: hclaunch.c,v 1.10 2007/02/28 16:24:39 samwai Exp $
8
 
9
Contributors:
10
    IBM Corporation - initial implementation
11
**********************************************************************/
12
13
#include "hclaunch.h"
14
#include "launcher_common.h"
15
#include "RAComm.h"
16
17
#ifdef _DEBUG
18
FILE * trcFile;
19
#endif
20
21
/* Function declaration */
22
char* callJNIStringMethod(JNIEnv *jenv, jobject jobj, char *method);
23
long callJNILongMethod(JNIEnv *jenv, jobject jobj, char *method);
24
int callJNIIntMethod(JNIEnv *jenv, jobject jobj, char *method);
25
short callJNIShortMethod(JNIEnv *jenv, jobject jobj, char *method);
26
void callJNIVoidMethod(JNIEnv *jenv, jobject jobj, char *method);
27
jobject callJNIObjectMethod(JNIEnv *jenv, jobject jobj, char *method, int pos);
28
void cleanupChild(int sig);
29
30
/* we only need to keep track of the processes on platforms other than Windows. 
31
   The java code keeps track of processes on Windows platforms */ 
32
33
/* bugzilla 69642 start */ 
34
#ifndef _WIN32
35
#if defined(__linux__) && defined(__i386__)
36
	/* Bug 141033 */
37
#else
38
typedef struct child_process_list {
39
	PID childProcessID;		/* child process id of process launched */ 
40
	jobject processObject;  /* associated processObject */ 
41
	struct child_process_list *next; 
42
} child_process_list_t; 
43
44
child_process_list_t *child_processes = NULL; 
45
46
ra_critsec_t process_lock;
47
48
#endif /* __linux__ && __i386__ */
49
#endif /* _WIN32 */ 
50
/* bugzilla 69642 end */ 
51
52
/* Global reference to the JVM. */
53
static JavaVM *jvm = NULL; /* Bug 73453 */
54
55
/* Globals */
56
RemoteConsole_t console; /* User console for receiving input */
57
jobject exeObj;
58
59
/*
60
 * Called when JVM loads this DLL. This will register a signal handler for SIGCHLD on non-Windows platforms
61
 */
62
63
/* bugzilla 69642 -- do not #if 0 the code out */ 
64
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
65
#ifndef _WIN32
66
#if defined(__linux__) && defined(__i386__)
67
	/* Bug 141033 */
68
#else
69
	struct sigaction sigActSIGCHLD;
70
71
	/* Cleanup our children when they exit */
72
	BZERO(&sigActSIGCHLD, sizeof(struct sigaction));
73
	sigActSIGCHLD.sa_handler = &cleanupChild;
74
	sigaction(SIGCHLD, &sigActSIGCHLD, NULL);
75
76
	ra_mutexCreate(&process_lock); 
77
#endif /* __linux__ && __i386__ */
78
#endif /* _WIN32 */
79
80
	return JNI_VERSION_1_2;
81
}
82
83
84
/* bugzilla 69642 start */ 
85
#ifndef _WIN32
86
#if defined(__linux__) && defined(__i386__)
87
	/* Bug 141033 */
88
#else
89
static void addProcessToList(PID childPID, JNIEnv *jenv, jobject jobj) {
90
	child_process_list_t *entry = (child_process_list_t *)ra_malloc(sizeof(child_process_list_t));
91
	if (entry == NULL) {
92
		return;
93
	}
94
95
	entry->childProcessID = childPID;
96
	entry->processObject = ENV(jenv)->NewGlobalRef(ENVPARM(jenv) jobj);
97
	ra_mutexEnter(&process_lock); 
98
	entry->next = child_processes;
99
	child_processes = entry; 
100
	ra_mutexExit(&process_lock); 
101
}
102
103
static jobject removeProcessFromList(PID childPID) {
104
	child_process_list_t *cur; 
105
	child_process_list_t *prev = NULL; 
106
	jobject returnObj = (int)NULL; 
107
	ra_mutexEnter(&process_lock); 
108
	cur = child_processes; 
109
	while (cur != NULL) {
110
		if (cur->childProcessID == childPID) {
111
			if (prev != NULL) {
112
				prev->next = cur->next;
113
			}
114
			else {
115
				child_processes = cur->next; 
116
			}
117
			returnObj = cur->processObject; 
118
			ra_free(cur); 
119
			break; 
120
		}
121
		prev = cur; 
122
		cur = cur->next; 
123
	}
124
	ra_mutexExit(&process_lock); 
125
	return returnObj; 
126
}
127
#endif /* __linux__ && __i386__ */
128
#endif /* _WIN32 */
129
/* bugzilla 69642 end */ 
130
131
/*
132
 * This is called by the ProcessExecutorImpl to launch a process. The process object is obtained from the executor through JNI.
133
 */
134
JNIEXPORT jint JNICALL Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_startProcess0
135
	(JNIEnv *jenv, jobject jobj) {
136
137
	char *exe = NULL;
138
	char *cmdline = NULL;
139
	char *location = NULL;
140
	char *env = NULL;
141
	jclass jcls = (int)NULL;
142
	PID childPID = 0; /* The child process ID*/
143
144
	#ifdef _DEBUG
145
	#ifdef MVS                    
146
	#pragma convlit(suspend)
147
	#endif
148
    trcFile = fopen("startProcess.dbg", "w");
149
	fprintf(trcFile,"startProcess: start\n");
150
	fflush(trcFile);
151
	#ifdef MVS 
152
	#pragma convlit(resume)
153
	#endif
154
	#endif
155
156
	ENV(jenv)->GetJavaVM(ENVPARM(jenv) &jvm);
157
158
	jcls = ENV(jenv)->GetObjectClass(ENVPARM(jenv) jobj);
159
160
	/* TODO will fix up the package name once it is finalized */
161
	if(jcls != (int)NULL) {
162
/*		jobject exeObj = NULL;  */
163
		jfieldID exeObjID = (int)NULL;
164
		jfieldID envObjID = (int)NULL;
165
166
		/* Find the IExecutableObject and get the exe, cmdline, and location for launch */
167
#ifdef __OS400__
168
#pragma convert(819) /* Bug 68899 */
169
#endif
170
		exeObjID = ENV(jenv)->GetFieldID(ENVPARM(jenv) jcls, "exeObj", "Lorg/eclipse/hyades/execution/core/IExecutableObject;");
171
#ifdef __OS400__
172
#pragma convert(0) /* Bug 68899 */
173
#endif
174
		if(exeObjID != (int)NULL) {
175
			exeObj = ENV(jenv)->GetObjectField(ENVPARM(jenv) jobj, exeObjID);
176
			if(exeObj != (int)NULL) {
177
#ifdef __OS400__
178
	#pragma convert(819) /* Bug 68899 */
179
#endif
180
				/* The returned strings are already in the native encoding */
181
				exe = callJNIStringMethod(jenv, exeObj, "getExe");
182
				cmdline = callJNIStringMethod(jenv, exeObj, "getCommandLine");
183
				location = callJNIStringMethod(jenv, exeObj, "getLocation");
184
#ifdef __OS400__
185
	#pragma convert(0) /* Bug 68899 */
186
#endif
187
188
				if(exe == NULL) {
189
					return ERROR_JNI_LAUNCH_EXE_NAME; /* Can't resolve the exe name */
190
				}
191
				if(cmdline == NULL) {
192
					return ERROR_JNI_LAUNCH_CMD_LINE; /* Can't resolve the cmd line string */
193
				}
194
195
                /* RKD: If the location is NULL, we should just run in teh default location  
196
				if(location == NULL) {
197
					return ERROR_JNI_LAUNCH_LOCATION; /* Can't resolve the location string 
198
				}
199
                */
200
			}
201
			else {
202
				return ERROR_JNI_LAUNCH_EXE_OBJ; /* Can't find the exe obj */
203
			}
204
		}
205
 		else {
206
			return ERROR_JNI_LAUNCH_EXE_OBJ_ID; /* Can't find the exe obj id */
207
		}
208
209
		/* Find the processEnvironment array to construct the env parameter */
210
#ifdef __OS400__
211
#pragma convert(819) /* Bug 68899 */
212
#endif
213
		envObjID = ENV(jenv)->GetFieldID(ENVPARM(jenv) jcls, "processEnvironment", "[Lorg/eclipse/hyades/execution/core/IOrderedProperty;");
214
#ifdef __OS400__
215
#pragma convert(0) /* Bug 68899 */
216
#endif
217
		if(envObjID != (int)NULL) {
218
			jobjectArray envObjArray = (int)NULL;
219
220
			envObjArray = (jobjectArray)ENV(jenv)->GetObjectField(ENVPARM(jenv) jobj, envObjID);
221
			if(envObjArray != (int)NULL) {
222
				jsize numEnv;
223
				
224
225
				numEnv = ENV(jenv)->GetArrayLength(ENVPARM(jenv) envObjArray);
226
				if(numEnv) {
227
					char *current;
228
					jsize i;
229
					jsize envBufferSize;
230
231
					envBufferSize=sizeof(char)  * numEnv * 256; /* Estimate a max 256 char per environment */
232
					env = (char*)malloc(envBufferSize); 
233
					current = env; /* Pointer that moves to navigate the env block */
234
					BZERO(env,envBufferSize);
235
236
					for(i = 0; i < numEnv; i++) {
237
						jclass propClass = (int)NULL;
238
						jstring envName = (int)NULL;
239
						jfieldID envNameID = (int)NULL;
240
						jfieldID envValueID = (int)NULL;
241
						jobject envObj = (int)NULL;
242
						jobject envValues = (int)NULL;
243
244
#ifdef __OS400__
245
#pragma convert(819) /* Bug 68899 */
246
#endif
247
						propClass = ENV(jenv)->FindClass(ENVPARM(jenv) "org/eclipse/hyades/execution/core/impl/OrderedPropertyImpl");
248
#ifdef __OS400__
249
#pragma convert(0) /* Bug 68899 */
250
#endif
251
						if(propClass == (int)NULL) {
252
							return ERROR_JNI_LAUNCH_PROP_CLASSS; /* Can't find the property class */
253
					    }
254
255
					    envObj = ENV(jenv)->GetObjectArrayElement(ENVPARM(jenv) envObjArray, i); /* Get the object at index i */
256
					    if(envObj == (int)NULL) {
257
						    return ERROR_JNI_LAUNCH_ENV_OBJARRAY; /* Can't find the env obj array */
258
					    }
259
260
#ifdef __OS400__
261
#pragma convert(819) /* Bug 68899 */
262
#endif
263
					    envNameID = ENV(jenv)->GetFieldID(ENVPARM(jenv) propClass, "name", "Ljava/lang/String;");
264
#ifdef __OS400__
265
#pragma convert(0) /* Bug 68899 */
266
#endif
267
					    if(envNameID == (int)NULL) {
268
						    return ERROR_JNI_LAUNCH_ENV_NAME_ID; /* Can't find the env name id */
269
					    }
270
271
#ifdef __OS400__
272
#pragma convert(819) /* Bug 68899 */
273
#endif
274
					    envValueID = ENV(jenv)->GetFieldID(ENVPARM(jenv) propClass, "values", "Ljava/util/Vector;");
275
#ifdef __OS400__
276
#pragma convert(0) /* Bug 68899 */
277
#endif
278
					    if(envValueID == (int)NULL) {
279
						    return ERROR_JNI_LAUNCH_ENV_VALUE_ID; /* Can't find the env value id */
280
					    }
281
282
					    envName = (jstring)ENV(jenv)->GetObjectField(ENVPARM(jenv) envObj, envNameID);
283
					    if(envName == (int)NULL) {
284
							continue; /* Bug 143566 */
285
							/* return ERROR_JNI_LAUNCH_ENV_NAME; */ /* Can't find the env name */
286
					    }
287
288
					    envValues = ENV(jenv)->GetObjectField(ENVPARM(jenv) envObj, envValueID);
289
					    if(envValues == (int)NULL) {
290
						    return ERROR_JNI_LAUNCH_ENV_VALUE; /* Can't find the env value */
291
					    }
292
293
294
							if(envValues != (int)NULL) {
295
								jstring envStr;
296
								int j, size;
297
								char* envname;
298
								char* envvalue;
299
300
						    /* get the environment name */
301
							    envname = copyJavaStringToNative(jenv, envName);
302
								if(envname != NULL) {
303
									/* Ensure we have room in the buffer (include the '=' sign and null hense the 2) */
304
									while(current+strlen(envname)+2>env+envBufferSize) {
305
										char *tempEnv;
306
										jsize offset;
307
										jsize newSize=envBufferSize<<1;
308
										tempEnv=(char*)malloc(newSize);
309
	
310
										offset=current-env;
311
									
312
										memcpy(tempEnv, env, offset);
313
										current=tempEnv+offset;
314
										free(env);
315
										env=tempEnv;
316
										envBufferSize=newSize;
317
									}
318
									
319
									/* Copy the env name to the buffer */
320
									memcpy(current, envname, strlen(envname));
321
									current += strlen(envname);
322
#ifdef MVS
323
#pragma convlit(suspend)
324
#endif
325
									*current='=';
326
#ifdef MVS
327
#pragma convlit(resume)
328
#endif
329
									current += 1;
330
									ra_free(envname); /* Bug 103601 */
331
									envname=NULL;
332
333
#ifdef __OS400__
334
#pragma convert(819) /* Bug 68899 */
335
#endif
336
									size = callJNIIntMethod(jenv, envValues, "size");
337
#ifdef __OS400__
338
#pragma convert(0) /* Bug 68899 */
339
#endif
340
341
									/* Copy the values to the buffer */
342
									for(j = 0; j < size; j++) {
343
#ifdef __OS400__
344
#pragma convert(819) /* Bug 68899 */
345
#endif
346
										envStr = (jstring)callJNIObjectMethod(jenv, envValues, "elementAt", j);
347
#ifdef __OS400__
348
#pragma convert(0) /* Bug 68899 */
349
#endif
350
351
										envvalue = copyJavaStringToNative(jenv, envStr);
352
										if(envvalue != NULL) {
353
											/* Ensure we have room in the buffer (include the path separator and double null terminator hense the 3) */
354
											while(current+strlen(envvalue)+3>env+envBufferSize) {
355
												char *tempEnv;
356
												jsize offset;
357
												jsize newSize=envBufferSize<<1;
358
												tempEnv=(char*)malloc(newSize);
359
		
360
												offset=current-env;
361
		
362
												memcpy(tempEnv, env, offset);
363
												current=tempEnv+offset;
364
												env=tempEnv;
365
												envBufferSize=newSize;
366
											}
367
		
368
											if(j > 0) {
369
	#ifdef MVS
370
	#pragma convlit(suspend)
371
	#endif
372
												*current=FILE_PATH_SEPARATOR;
373
	#ifdef MVS
374
	#pragma convlit(resume)
375
	#endif
376
												current++;
377
											}
378
		
379
									    memcpy(current, envvalue, strlen(envvalue));
380
									    current += strlen(envvalue);
381
		
382
											ra_free(envvalue); /* Bug 103601 */
383
											envvalue=NULL;
384
								    } /* envvalue != NULL */
385
								    else {
386
								    	/* envvalue == NULL */
387
								    }
388
									} /* for */
389
									*current='\0'; /* Finished appending all values */
390
									current++;
391
								} /* envname != NULL */
392
								else {
393
									/* envname == NULL */
394
								}
395
							}
396
						}
397
				    /* Copy an ending null when all properties are processed */
398
						*current='\0';
399
						current++;
400
					}
401
			}
402
			else {
403
				return ERROR_JNI_LAUNCH_ENV_OBJARRAY_ID; /* Can't find the env obj array id */
404
			}
405
		}
406
		else {
407
			return ERROR_JNI_LAUNCH_ENV_OBJ_ID; /* Can't find the env obj id */
408
		}
409
	}
410
	else {
411
		return ERROR_JNI_LAUNCH_EXE_CLS; /* Can't find the class */
412
	}
413
414
	#ifdef _DEBUG
415
	#ifdef MVS                    
416
	#pragma convlit(suspend)
417
	#endif
418
	fprintf(trcFile,"startProcess: launch process by calling hc_startProcess\n");
419
	fprintf(trcFile,"startProcess: exe = %s\n", exe);
420
	fprintf(trcFile,"startProcess: cmdline = %s\n", cmdline);
421
	fprintf(trcFile,"startProcess: location = %s\n", location);
422
	fflush(trcFile);
423
	#ifdef MVS                    
424
	#pragma convlit(resume)
425
	#endif
426
	#endif
427
428
	/* Attempt to launch process only if all required information exists. These are already checked above. */
429
	childPID = hc_startProcess(exe, cmdline, location, env, &console);
430
431
	/* bugzilla 69642 start */ 
432
#ifndef _WIN32
433
#if defined(__linux__) && defined(__i386__)
434
	/* Bug 141033 */
435
#else
436
	addProcessToList(childPID,jenv,jobj); 
437
#endif /* __linux__ && __i386__ */
438
#endif /* _WIN32 */
439
	/* bugzilla 69642 end */ 
440
441
	#ifdef _DEBUG
442
	#ifdef MVS                    
443
	#pragma convlit(suspend)
444
	#endif
445
	fprintf(trcFile,"startProcess: started process - pid = %d\n", childPID);
446
	fflush(trcFile);
447
	fclose(trcFile);
448
	#ifdef MVS                  
449
	#pragma convlit(resume)
450
	#endif
451
	#endif
452
453
	return childPID;
454
}
455
456
/*
457
 * This is called by the ProcessExecutorImpl to kill a process. The pid to be kill is obtained from the executor through JNI.
458
 */
459
JNIEXPORT void JNICALL Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_killProcess0
460
	(JNIEnv *jenv, jobject jobj) {
461
462
	jclass jcls = (int)NULL;
463
464
	jcls = ENV(jenv)->GetObjectClass(ENVPARM(jenv) jobj);
465
466
	if(jcls != (int)NULL) {
467
		jfieldID pidField = (int)NULL;
468
469
		/* Find the IExecutableObject and get the exe, cmdline, and location for launch */
470
#ifdef __OS400__
471
#pragma convert(819) /* Bug 68899 */
472
#endif
473
		pidField = ENV(jenv)->GetFieldID(ENVPARM(jenv) jcls, "pid", "I");
474
#ifdef __OS400__
475
#pragma convert(0) /* Bug 68899 */
476
#endif
477
		if(pidField != (int)NULL) {
478
			jint pid = 0;
479
480
			pid = ENV(jenv)->GetIntField(ENVPARM(jenv) jobj, pidField);
481
			if(pid != 0) {
482
				hc_killProcess(pid);
483
			}
484
		}
485
	}
486
487
	return;
488
}
489
490
/*
491
 * This is called by the ProcessExecutorImpl to write a byte to the process's stdin stream.
492
 */
493
JNIEXPORT void JNICALL Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_writeToProcess0
494
	(JNIEnv *jenv, jobject jobj, jchar c) {
495
496
	hc_writeFileChar(console.in, (char)c);
497
498
	return;
499
}
500
501
/*
502
 * This is called by the ProcessExecutorImpl to read a byte from the process's stdout stream.
503
 */
504
JNIEXPORT jint JNICALL Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_readFromProcessOutput0
505
	(JNIEnv *jenv, jobject jobj) {
506
	char c[1];
507
508
	if(hc_readFile(console.out, c, 1) <= 0) {
509
		return (int)-1;
510
	}
511
512
	return (int)c[0];
513
}
514
515
/*
516
 * This is called by the ProcessExecutorImpl to read a byte from the process's stderr stream.
517
 */
518
JNIEXPORT jint JNICALL Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_readFromProcessError0
519
	(JNIEnv *jenv, jobject jobj) {
520
	char c[1];
521
522
	if(hc_readFile(console.err, c, 1) <= 0) {
523
		return (int)-1;
524
	}
525
526
	return (int)c[0];
527
}
528
529
530
/*
531
 * This is called by the ProcessExecutorImpl to get the current process status.
532
 */
533
JNIEXPORT jint JNICALL Java_org_eclipse_hyades_execution_core_impl_ProcessExecutorImpl_getProcessStatus0
534
	(JNIEnv *jenv, jobject jobj, jint pid) {
535
536
	return hc_getProcessStatus(pid);
537
}
538
539
540
/*
541
 * This is called by the ExecutionEnvironmentImpl to query the default system properties.
542
 */
543
JNIEXPORT jobjectArray JNICALL Java_org_eclipse_hyades_execution_core_impl_ExecutionEnvironmentImpl_getNativeSystemEnvironment0
544
	(JNIEnv *jenv, jobject jobj) {
545
	char sep[] = "=";
546
	char *envName;
547
	char *envValue;
548
	int index = 0;
549
	jclass envClass = (int)NULL;
550
	jclass strClass = (int)NULL;
551
	jobjectArray envArray = (int)NULL;
552
	jmethodID envCtor = (int)NULL;
553
	jmethodID appendValueID = (int)NULL;
554
	jfieldID envNameID = (int)NULL;
555
	jfieldID envValuesID = (int)NULL;
556
	jobject envObj = (int)NULL;
557
	jstring strObj = (int)NULL;
558
	void* envStr = NULL;
559
	int envOffset = 0;
560
561
	#ifdef _DEBUG
562
	#ifdef MVS                    
563
	#pragma convlit(suspend)
564
	#endif
565
    trcFile = fopen("getenv.dbg", "w");
566
	fprintf(trcFile,"getNativeSystemEnvironment: start\n");
567
	fflush(trcFile);
568
	#ifdef MVS      
569
	#pragma convlit(resume)
570
	#endif
571
	#endif
572
573
#ifdef __OS400__
574
#pragma convert(819) /* Bug 68899 */
575
#endif
576
	envClass = ENV(jenv)->FindClass(ENVPARM(jenv) "org/eclipse/hyades/execution/core/impl/OrderedPropertyImpl");
577
#ifdef __OS400__
578
#pragma convert(0) /* Bug 68899 */
579
#endif
580
	if(envClass == (int)NULL) {
581
		return (int)NULL;
582
	}
583
584
#ifdef __OS400__
585
#pragma convert(819) /* Bug 68899 */
586
#endif
587
	strClass = ENV(jenv)->FindClass(ENVPARM(jenv) "java/lang/String");
588
#ifdef __OS400__
589
#pragma convert(0) /* Bug 68899 */
590
#endif
591
	if(strClass == (int)NULL) {
592
		return (int)NULL;
593
	}
594
595
	envArray = ENV(jenv)->NewObjectArray(ENVPARM(jenv) MAX_ENV, envClass, (int)NULL);
596
	if(envArray == (int)NULL) {
597
		return (int)NULL;
598
	}
599
600
#ifdef __OS400__
601
#pragma convert(819) /* Bug 68899 */
602
#endif
603
	envCtor = ENV(jenv)->GetMethodID(ENVPARM(jenv) envClass, "<init>", "()V");
604
#ifdef __OS400__
605
#pragma convert(0) /* Bug 68899 */
606
#endif
607
	if(envCtor == (int)NULL) {
608
		return (int)NULL;
609
	}
610
611
#ifdef __OS400__
612
#pragma convert(819) /* Bug 68899 */
613
#endif
614
	appendValueID = ENV(jenv)->GetMethodID(ENVPARM(jenv) envClass, "appendValue", "(Ljava/lang/Object;)V");
615
#ifdef __OS400__
616
#pragma convert(0) /* Bug 68899 */
617
#endif
618
	if(appendValueID == (int)NULL) {
619
		return (int)NULL;
620
	}
621
622
#ifdef __OS400__
623
#pragma convert(819) /* Bug 68899 */
624
#endif
625
	envNameID = ENV(jenv)->GetFieldID(ENVPARM(jenv) envClass, "name", "Ljava/lang/String;");
626
#ifdef __OS400__
627
#pragma convert(0) /* Bug 68899 */
628
#endif
629
	if(envNameID == (int)NULL) {
630
		return (int)NULL;
631
	}
632
633
#ifdef __OS400__
634
#pragma convert(819) /* Bug 68899 */
635
#endif
636
	envValuesID = ENV(jenv)->GetFieldID(ENVPARM(jenv) envClass, "values", "Ljava/util/Vector;");
637
#ifdef __OS400__
638
#pragma convert(0) /* Bug 68899 */
639
#endif
640
	if(envValuesID == (int)NULL) {
641
		return (int)NULL;
642
	}
643
644
	#ifdef _DEBUG
645
	#ifdef MVS                    
646
	#pragma convlit(suspend)
647
	#endif
648
	fprintf(trcFile,"getNativeSystemEnvironment: about to get environment\n");
649
	fflush(trcFile);
650
	#ifdef MVS                    
651
	#pragma convlit(resume)
652
	#endif
653
	#endif
654
655
	/* Get the system environment */
656
	envStr = hc_getEnvironment();
657
658
	#ifdef _DEBUG
659
	#ifdef MVS                    
660
	#pragma convlit(suspend)
661
	#endif
662
	fprintf(trcFile,"getNativeSystemEnvironment: got environment %p\n", envStr);
663
	fflush(trcFile);
664
	#ifdef MVS                    
665
	#pragma convlit(resume)
666
	#endif
667
	#endif
668
669
	while(envOffset >= 0) {
670
		/* Get the next name-value pair */
671
		envOffset = hc_getEnvironmentVariable(envStr, envOffset, &envName, &envValue);
672
673
		#ifdef _DEBUG
674
		#ifdef MVS                    
675
		#pragma convlit(suspend)
676
		#endif
677
		fprintf(trcFile,"getNativeSystemEnvironment: next envOffset = %d \n", envOffset);
678
		fflush(trcFile);
679
		#ifdef MVS                    
680
		#pragma convlit(resume)
681
		#endif
682
		#endif
683
684
		if(envName != NULL) {
685
686
			/* Create the OrderedPropertyImpl object */
687
			envObj = ENV(jenv)->NewObject(ENVPARM(jenv) envClass, envCtor);
688
689
			/* Create a String object to store the property name and set it to the OrderedPropertyImpl object */
690
			strObj = ENV(jenv)->NewStringUTF(ENVPARM(jenv) envName);
691
			ENV(jenv)->SetObjectField(ENVPARM(jenv) envObj, envNameID, strObj);
692
693
			/* Create a String object to store the property value and append it to the OrderedPropertyImpl object */
694
			if(envValue == NULL || *envValue == '\0') {
695
				strObj = ENV(jenv)->NewStringUTF(ENVPARM(jenv) "\0"); /* Bug 68899 */
696
			}
697
			else {
698
				strObj = ENV(jenv)->NewStringUTF(ENVPARM(jenv) envValue);	    
699
			}
700
			ENV(jenv)->CallVoidMethod(ENVPARM(jenv) envObj, appendValueID, strObj);
701
702
			/* Add the completed OrderedPropertyImpl object to the array */
703
			ENV(jenv)->SetObjectArrayElement(ENVPARM(jenv) envArray, index, envObj);
704
705
			/* free the temporary space for the name and value */
706
			free(envName);
707
			free(envValue);
708
709
			index++;
710
		}
711
	}
712
713
	#ifdef _DEBUG
714
	#ifdef MVS                    
715
	#pragma convlit(suspend)
716
	#endif
717
	fprintf(trcFile,"getNativeSystemEnvironment: %d environment variables were found\n", index);
718
	fflush(trcFile);
719
	fclose(trcFile);
720
	#ifdef MVS          
721
	#pragma convlit(resume)
722
	#endif
723
	#endif
724
725
	return envArray;
726
}
727
728
729
/*
730
 * JNI helper functions
731
 */
732
733
/* Call the CallObjectMethod with object type String and no arg */
734
char* callJNIStringMethod(JNIEnv *jenv, jobject jobj, char *method) {
735
	char *rc = NULL;
736
	jclass jcls = (int)NULL;
737
	jmethodID jmethod = (int)NULL;
738
739
	jcls = ENV(jenv)->GetObjectClass(ENVPARM(jenv) jobj);
740
	if(jcls != (int)NULL) {
741
#ifdef __OS400__
742
#pragma convert(819) /* Bug 68899 */
743
#endif
744
		jmethod = ENV(jenv)->GetMethodID(ENVPARM(jenv) jcls, method, "()Ljava/lang/String;");
745
#ifdef __OS400__
746
#pragma convert(0) /* Bug 68899 */
747
#endif
748
		if(jmethod != (int)NULL) {
749
            jstring result=(jstring)ENV(jenv)->CallObjectMethod(ENVPARM(jenv) jobj, jmethod);
750
            if(result != (int)NULL) {
751
			    rc = copyJavaStringToNative(jenv, result);
752
            }
753
		}
754
	}
755
756
	return rc;
757
}
758
759
/* Call the CallLongMethod with object type long and no arg */
760
long callJNILongMethod(JNIEnv *jenv, jobject jobj, char *method) {
761
	long rc = 0;
762
	jclass jcls = (int)NULL;
763
	jmethodID jmethod = (int)NULL;
764
765
	jcls = ENV(jenv)->GetObjectClass(ENVPARM(jenv) jobj);
766
	if(jcls != (int)NULL) {
767
#ifdef __OS400__
768
#pragma convert(819) /* Bug 68899 */
769
#endif
770
		jmethod = ENV(jenv)->GetMethodID(ENVPARM(jenv) jcls, method, "()J");
771
#ifdef __OS400__
772
#pragma convert(0) /* Bug 68899 */
773
#endif
774
		if(jmethod != (int)NULL) {
775
#if defined (__OS400__)
776
			rc = (ENV(jenv)->CallLongMethod(ENVPARM(jenv) jobj, jmethod)).ll;
777
#else
778
			rc = (long)(ENV(jenv)->CallLongMethod(ENVPARM(jenv) jobj, jmethod));
779
#endif
780
		}
781
	}
782
783
	return rc;
784
}
785
786
/* Call the CallIntMethod with object type int and no arg */
787
int callJNIIntMethod(JNIEnv *jenv, jobject jobj, char *method) {
788
	int rc = 0;
789
	jclass jcls = (int)NULL;
790
	jmethodID jmethod = (int)NULL;
791
792
	jcls = ENV(jenv)->GetObjectClass(ENVPARM(jenv) jobj);
793
	if(jcls != (int)NULL) {
794
#ifdef __OS400__
795
#pragma convert(819) /* Bug 68899 */
796
#endif
797
		jmethod = ENV(jenv)->GetMethodID(ENVPARM(jenv) jcls, method, "()I");
798
#ifdef __OS400__
799
#pragma convert(0) /* Bug 68899 */
800
#endif
801
		if(jmethod != (int)NULL) {
802
			rc = (int)(ENV(jenv)->CallIntMethod(ENVPARM(jenv) jobj, jmethod));
803
		}
804
	}
805
806
	return rc;
807
}
808
809
/* Call the CallShortMethod with object type short and no arg */
810
short callJNIShortMethod(JNIEnv *jenv, jobject jobj, char *method) {
811
	short rc = 0;
812
	jclass jcls = (int)NULL;
813
	jmethodID jmethod = (int)NULL;
814
815
	jcls = ENV(jenv)->GetObjectClass(ENVPARM(jenv) jobj);
816
	if(jcls != (int)NULL) {
817
#ifdef __OS400__
818
#pragma convert(819) /* Bug 68899 */
819
#endif
820
		jmethod = ENV(jenv)->GetMethodID(ENVPARM(jenv) jcls, method, "()S");
821
#ifdef __OS400__
822
#pragma convert(0) /* Bug 68899 */
823
#endif
824
		if(jmethod != (int)NULL) {
825
			rc = (short)(ENV(jenv)->CallShortMethod(ENVPARM(jenv) jobj, jmethod));
826
		}
827
	}
828
829
	return rc;
830
}
831
832
/* Call the CallVoidMethod with object type void and no arg */
833
void callJNIVoidMethod(JNIEnv *jenv, jobject jobj, char *method) {
834
	jclass jcls = (int)NULL;
835
	jmethodID jmethod = (int)NULL;
836
837
	jcls = ENV(jenv)->GetObjectClass(ENVPARM(jenv) jobj);
838
	if(jcls != (int)NULL) {
839
#ifdef __OS400__
840
#pragma convert(819) /* Bug 68899 */
841
#endif
842
		jmethod = ENV(jenv)->GetMethodID(ENVPARM(jenv) jcls, method, "()V");
843
#ifdef __OS400__
844
#pragma convert(0) /* Bug 68899 */
845
#endif
846
		if(jmethod != (int)NULL) {
847
			ENV(jenv)->CallVoidMethod(ENVPARM(jenv) jobj, jmethod);
848
		}
849
	}
850
}
851
852
/* Call the CallObjectMethod with object type Object and 1 arg */
853
jobject callJNIObjectMethod(JNIEnv *jenv, jobject jobj, char *method, int pos) {
854
	jobject rc = 0;
855
	jclass jcls = (int)NULL;
856
	jmethodID jmethod = (int)NULL;
857
858
	jcls = ENV(jenv)->GetObjectClass(ENVPARM(jenv) jobj);
859
	if(jcls != (int)NULL) {
860
#ifdef __OS400__
861
#pragma convert(819) /* Bug 68899 */
862
#endif
863
		jmethod = ENV(jenv)->GetMethodID(ENVPARM(jenv) jcls, method, "(I)Ljava/lang/Object;");
864
#ifdef __OS400__
865
#pragma convert(0) /* Bug 68899 */
866
#endif
867
		if(jmethod != (int)NULL) {
868
			rc = (jobject)(ENV(jenv)->CallObjectMethod(ENVPARM(jenv) jobj, jmethod, pos));
869
		}
870
	}
871
872
	return rc;
873
}
874
875
/*
876
 * A signal handler routine. Called when a child exits.
877
 */
878
/* bugzilla 69642 start */ 
879
void cleanupChild(int sig) {
880
#ifndef _WIN32
881
#if defined(__linux__) && defined(__i386__)
882
	/* Bug 141033 */
883
#else
884
	JNIEnv *jenv;
885
	int result, status;
886
	PID childPID; 
887
	jobject processObj; 
888
889
	/* Bug 73453: If somehow the jvm is not initialized, skip this function */
890
	if(jvm == NULL) {
891
		return;
892
	}
893
894
	childPID = wait(&status); 
895
	processObj = removeProcessFromList(childPID); 
896
897
	/* Attach the current thread to the JVM */
898
#if defined __cplusplus && defined _HPUX
899
	result = ENV(jvm)->AttachCurrentThread((void**)&jenv, NULL);
900
#else
901
	result = (*jvm)->AttachCurrentThread(jvm, (void**)&jenv, NULL);
902
#endif
903
904
	if (processObj != (int)NULL) {
905
		if(result == 0) {
906
#ifdef __OS400__
907
#pragma convert(819) /* Bug 68899 */
908
#endif
909
			callJNIVoidMethod(jenv, processObj, "processExited");
910
#ifdef __OS400__
911
#pragma convert(0) /* Bug 68899 */
912
#endif
913
		}
914
		ENV(jenv)->DeleteGlobalRef(ENVPARM(jenv) processObj);
915
	}
916
917
#endif /* __linux__ && __i386__ */
918
#endif /* _WIN32 */
919
920
	return;
921
}
922
/* bugzilla 69642 end */ 
(-)src-native-new/src/agents/native/heapsnapshots/HeapSnapshotManager.h (+35 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: HeapSnapshotManager.h,v 1.3 2005/02/25 22:17:34 hleung Exp $
8
 *
9
 * Contributors:
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
#ifndef HEAP_SNAPSHOT_MANAGER_H
14
#define HEAP_SNAPSHOT_MANAGER_H
15
16
#include <jvmpi.h>
17
18
typedef enum HeapDumpMode {
19
  notAsking,
20
  askingForDumpPopulation,
21
  askingForDumpReferences,
22
  askingForMarkGeneration
23
} HeapDumpMode;
24
25
class HeapSnapshotManager {
26
 public:
27
  virtual char isStateless() const = 0;
28
  virtual void handleHeapSnapshot(JNIEnv*      env,
29
				  int          dump_level,
30
				  char*        begin,
31
				  char*        end,
32
				  HeapDumpMode heapDumpMode) = 0;
33
};
34
35
#endif /* HEAP_SNAPSHOT_MANAGER_H */

Return to bug 121658