Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 65909 Details for
Bug 141540
Use JVMTI instead of JVMPI to get event notification
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Dynamic Probekit support patch for JVMTI Runtime component
patch3.txt (text/plain), 110.70 KB, created by
Asaf Yaffe
on 2007-05-04 08:09:58 EDT
(
hide
)
Description:
Dynamic Probekit support patch for JVMTI Runtime component
Filename:
MIME Type:
Creator:
Asaf Yaffe
Created:
2007-05-04 08:09:58 EDT
Size:
110.70 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.platform.jvmti.runtime >Index: src-native/build/build_tptp_profiler.script >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/build/build_tptp_profiler.script,v >retrieving revision 1.6 >diff -u -r1.6 build_tptp_profiler.script >--- src-native/build/build_tptp_profiler.script 19 Sep 2006 14:48:16 -0000 1.6 >+++ src-native/build/build_tptp_profiler.script 3 May 2007 22:36:38 -0000 >@@ -48,3 +48,7 @@ > make -C ../src/ThreadProf -f Makefile $1 > > echo "----------------------------------------------" >+ >+make -C ../src/ProbekitAgent -f Makefile $1 >+ >+echo "----------------------------------------------" >Index: src-native/build/build_tptp_profiler.bat >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/build/build_tptp_profiler.bat,v >retrieving revision 1.4 >diff -u -r1.4 build_tptp_profiler.bat >--- src-native/build/build_tptp_profiler.bat 19 Sep 2006 12:38:04 -0000 1.4 >+++ src-native/build/build_tptp_profiler.bat 3 May 2007 22:36:38 -0000 >@@ -40,6 +40,8 @@ > set MAKE_CFG4=BuildHeapProf32 - Win32 %MAKE_MODE% > set MAKE_FILE5=BuildThreadProf32.mak > set MAKE_CFG5=BuildThreadProf32 - Win32 %MAKE_MODE% >+set MAKE_FILE6=BuildProbekitAgent32.mak >+set MAKE_CFG6=BuildProbekitAgent32 - Win32 %MAKE_MODE% > goto make > > :em64t >@@ -123,6 +125,16 @@ > > echo ============================================================= > >+echo Executing: NMAKE /F %MAKE_FILE6% CFG="%MAKE_CFG6%" %MAKE_OPTIONS% >+NMAKE /F %MAKE_FILE6% CFG="%MAKE_CFG6%" %MAKE_OPTIONS% >+if %errorlevel% == 0 ( >+ echo BUILD OK >+) else ( >+ echo BUILD ERRORS >+) >+ >+echo ============================================================= >+ > goto end > > :error_acsdk_home >Index: src-native/build/tptp_profiler.dsw >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/build/tptp_profiler.dsw,v >retrieving revision 1.2 >diff -u -r1.2 tptp_profiler.dsw >--- src-native/build/tptp_profiler.dsw 27 Sep 2006 11:53:11 -0000 1.2 >+++ src-native/build/tptp_profiler.dsw 3 May 2007 22:36:38 -0000 >@@ -51,6 +51,18 @@ > > ############################################################################### > >+Project: "BuildProbekitAgent32"=".\BuildProbekitAgent32.dsp" - Package Owner=<4> >+ >+Package=<5> >+{{{ >+}}} >+ >+Package=<4> >+{{{ >+}}} >+ >+############################################################################### >+ > Project: "BuildThreadProf32"=".\BuildThreadProf32.dsp" - Package Owner=<4> > > Package=<5> >Index: src-native/src/ACCollector/ACCollector.cpp >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/ACCollector/ACCollector.cpp,v >retrieving revision 1.11 >diff -u -r1.11 ACCollector.cpp >--- src-native/src/ACCollector/ACCollector.cpp 3 May 2007 13:04:41 -0000 1.11 >+++ src-native/src/ACCollector/ACCollector.cpp 3 May 2007 22:36:38 -0000 >@@ -38,6 +38,71 @@ > return ACCollector::GetInstance().SendVMAgentInitializedCommand(); > } > >+///////////////////////////////////////////////////////////////// >+ >+// implementation util >+ >+// caller must free output name and value >+static >+void parseOption( const char* param_name, const char* param_value, >+ char*& name, char*& value ) >+{ >+ char NAME_START[] = "<name>"; >+ char NAME_END[] = "</name>"; >+ char VALUE_START[] = "<value>"; >+ char VALUE_END[] = "</value>"; >+ >+ #define SSIZE(str) (sizeof(str) - 1) >+ #define BAD_OPTION(msg) { LOG_ERROR(msg); return; } >+ >+ // reset output >+ name = 0; >+ value = 0; >+ >+ // parse string >+ int len = strlen(param_value); >+ if( len < SSIZE(NAME_START) + SSIZE(NAME_END) + >+ SSIZE(VALUE_START) + SSIZE(VALUE_END) ) >+ BAD_OPTION("value too short"); >+ >+ const char* ns = strstr( param_value, NAME_START); >+ if( !ns ) BAD_OPTION("invalid syntax"); >+ ns += SSIZE(NAME_START); >+ >+ const char* ne = strstr( ns, NAME_END); >+ if( !ne ) BAD_OPTION("invalid syntax"); >+ >+ const char* vs = strstr( ne, VALUE_START); >+ if( !vs ) BAD_OPTION("invalid syntax"); >+ vs += SSIZE(VALUE_START); >+ >+ /* string must end with </value> */ >+ const char* ve = param_value + len - SSIZE(VALUE_END); >+ if( ve <= vs ) BAD_OPTION("invalid syntax"); >+ if( strstr( ve, VALUE_END ) != ve ) >+ BAD_OPTION("invalid syntax: option doesn't end with \"</value>\""); >+ >+ /* name */ >+ len = ne - ns; >+ name = (char*)malloc( len + 1 ); >+ if( name == 0 ) >+ return; >+ strncpy( name, ns, len ); >+ name[ len ] = 0; >+ >+ /* value */ >+ len = ve - vs; >+ value = (char*)malloc( len + 1 ); >+ if( value == 0 ) >+ return; >+ strncpy( value, vs, len ); >+ value[ len ] = 0; >+ >+ return; >+} >+ >+///////////////////////////////////////////////////////////////// >+ > static char* profileName = "org.eclipse.tptp.jvmti"; > > ACCollector::ACCollector() : BaseCollectorImpl(profileName), BaseAgentImpl(profileName) >@@ -194,22 +259,34 @@ > // } > > } else if (isEqualString(cmdName, "applyOptions")) { >- char name[250]; >- char value[250]; >+ // TODO: this code doens't limit the option size; >+ // add some limitation for security purposes? >+ m_dataListenerID = cmdBlock->getSourceID(); > tptp_list_t* paramList = cmdBlock->getParamList(); > _tptp_node_t* node = paramList->head; > for (int i = 0; i < paramList->count; i++) { > tptp_param_t* param = (tptp_param_t*)(node->data); > node = node->next; >- if (strcmp("option", param->name) == 0) { >- if (sscanf(param->value, "<name>%250[^<]</name><value>%250[^<]</value>", name, value) == EOF) { >- //TODO >- } >- // TODO Add check for agg profiler options and iid >- m_ACC_env->SetProfileOption(iid, name, value); >- LOG_TRACE("Options: name=" << name << " value=" << value); >- } >- } >+ >+ if (param->name && param->value && >+ strcmp("option", param->name) == 0) { >+ >+ char* name; >+ char* value; >+ parseOption( param->name, param->value, name, value ); >+ >+ // TODO Add check for agg profiler options and iid >+ >+ // name or value null means string not formed properly >+ if( name && value ) { >+ LOG_TRACE("Options: name='" << name >+ << "' value='" << value << "'" << std::endl); >+ m_ACC_env->SetProfileOption(iid, name, value); >+ } >+ free( name ); >+ free( value ); >+ } >+ } > > } else if (isEqualString(cmdName, "AnalyseHeap")) { > m_ACC_env->AnalyseHeap(); >Index: src-native/include/JPIAgent/EC_Env.h >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/include/JPIAgent/EC_Env.h,v >retrieving revision 1.19 >diff -u -r1.19 EC_Env.h >--- src-native/include/JPIAgent/EC_Env.h 25 Apr 2007 14:23:16 -0000 1.19 >+++ src-native/include/JPIAgent/EC_Env.h 3 May 2007 22:36:38 -0000 >@@ -94,6 +94,7 @@ > bool (ECCALL *isControlled)(EC_Env* env); > bool (ECCALL *isEnabled)(EC_Env* env); > bool (ECCALL *isAllocSitesSupported)(EC_Env* env); >+ const char*(ECCALL *getUnknownOptionByName)(EC_Env* env, const char* name); > > void (ECCALL *VMInitDone)(EC_Env* env); > }; >@@ -228,7 +229,11 @@ > bool isAllocSitesSupported() { > return functions->isAllocSitesSupported(this); > } >- >+ >+ const char* getUnknownOptionByName( const char* name ) { >+ return functions->getUnknownOptionByName(this, name); >+ } >+ > void VMInitDone() { > functions->VMInitDone(this); > } >Index: src-native/src/JPIAgent/Options.h >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/JPIAgent/Options.h,v >retrieving revision 1.12 >diff -u -r1.12 Options.h >--- src-native/src/JPIAgent/Options.h 23 Mar 2007 14:04:44 -0000 1.12 >+++ src-native/src/JPIAgent/Options.h 3 May 2007 22:36:39 -0000 >@@ -143,6 +143,8 @@ > bool isAllocSitesSupported() { > return m_jvmtiAgent_Options.allocSites == 1; > } >+ >+ const char* getUnknownOptionByName( const char* name ); > > private: > /** >Index: src-native/src/JPIAgent/Options.cpp >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/JPIAgent/Options.cpp,v >retrieving revision 1.16 >diff -u -r1.16 Options.cpp >--- src-native/src/JPIAgent/Options.cpp 3 May 2007 13:04:40 -0000 1.16 >+++ src-native/src/JPIAgent/Options.cpp 3 May 2007 22:36:39 -0000 >@@ -570,3 +570,16 @@ > { > return 0; > } >+ >+const char* >+COptions::getUnknownOptionByName( const char* name ) >+{ >+ generic_option* opt = m_jvmtiAgent_Options.unknowns; >+ while( opt ) { >+ if( opt->key && STRICOLL( opt->key, name ) == 0 ) { >+ return opt->value; >+ } >+ opt = opt->next; >+ } >+ return 0; >+} >Index: src-native/src/JPIAgent/ECWrapper.cpp >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/JPIAgent/ECWrapper.cpp,v >retrieving revision 1.24 >diff -u -r1.24 ECWrapper.cpp >--- src-native/src/JPIAgent/ECWrapper.cpp 3 May 2007 13:04:41 -0000 1.24 >+++ src-native/src/JPIAgent/ECWrapper.cpp 3 May 2007 22:36:38 -0000 >@@ -486,6 +486,12 @@ > return ECWrapper::m_pCOptions->isAllocSitesSupported(); > } > >+EC_EXPORT const char* ECCALL >+getUnknownOptionByName(EC_Env* env, const char* name) >+{ >+ return ECWrapper::m_pCOptions->getUnknownOptionByName(name); >+} >+ > EC_EXPORT void ECCALL > VMInitDone(EC_Env* env) > { >@@ -531,6 +537,7 @@ > ECWrapper::m_ECFunctions.isControlled = &isControlled; > ECWrapper::m_ECFunctions.isEnabled = &isEnabled; > ECWrapper::m_ECFunctions.isAllocSitesSupported = &isAllocSitesSupported; >+ ECWrapper::m_ECFunctions.getUnknownOptionByName = &getUnknownOptionByName; > ECWrapper::m_ECFunctions.VMInitDone = &VMInitDone; > ECWrapper::m_EC_Env.functions = &ECWrapper::m_ECFunctions; > *env = &ECWrapper::m_EC_Env; >Index: src-native/src/ProbekitAgent/Instrumenter.cpp >=================================================================== >RCS file: src-native/src/ProbekitAgent/Instrumenter.cpp >diff -N src-native/src/ProbekitAgent/Instrumenter.cpp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/Instrumenter.cpp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,524 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#include "Instrumenter.h" >+#include "Globals.h" >+#include "ProbekitAgent.h" >+#include "Util.h" >+ >+#include <stdio.h> >+#include <assert.h> >+ >+#ifdef WIN32 >+#include <Winsock2.h> // for htons >+#endif >+ >+#ifdef _UNIX_ >+#include <dlfcn.h> // for dlopen >+#include <netinet/in.h> // for htons >+#endif >+ >+// Martini >+#include <OSA.h> >+#include "log.h" >+ >+using namespace Martini::OSA; >+using namespace std; >+ >+// Old BCI >+ >+#define PROBESCRIPT_FILE_EXTENSION ".probescript" >+#define PROBESCRIPT_CLASS_EXTENSION ".class" >+ >+#include <BCI/BCIEng/BCIEngInterface.h> >+ >+using namespace Martini::ProbekitAgent; >+ >+// BCI function types >+typedef unsigned (*CreateBCIEngine_t)(pbcieng_t* o_eng); >+typedef unsigned (*DestroyBCIEngine_t)(pbcieng_t i_eng); >+typedef unsigned (*Initialize_t)(pbcieng_t i_pbcieng, const char* i_pchOptions, size_t i_cbOptions); >+typedef unsigned (*SetAllocator_t)(pbcieng_t i_pbcieng, pfnMalloc_t i_pfnMalloc); >+typedef unsigned (*SetCallback_t)(pbcieng_t i_pbcieng, pfnCallback_t i_pfnCallback, unsigned i_uFlags); >+typedef unsigned (*Instrument_t)(pbcieng_t i_pbcieng, >+ const char* i_pInClass, size_t i_cbInClass, >+ char** o_ppOutClass, size_t* o_pcbOutClass); >+ >+// BCI functions >+ >+static CreateBCIEngine_t CreateBCIEngine_fn; >+static DestroyBCIEngine_t DestroyBCIEngine_fn; >+static Initialize_t Initialize_fn; >+static SetAllocator_t SetAllocator_fn; >+static SetCallback_t SetCallback_fn; >+static Instrument_t Instrument_fn; >+ >+#define RESOLVE_FUNCTION(F) \ >+F##_fn = (F##_t)pLibrary->GetEntry(#F); \ >+if (F##_fn == NULL) { \ >+ LOG_ERROR("can't resolve " #F); \ >+ result = MRTE_ERROR_FAIL; \ >+ goto out; \ >+} >+ >+static pbcieng_t BCIEngine = NULL; >+ >+#define DEFAULT_BCI_LIBRARY "BCIEngProbe" >+ >+#define CMDLINE_PARAM_BCI "ext-pk-BCILibraryName" >+#define CMDLINE_PARAM_PROBESCRIPT "ext-pk-probescript" >+#define CMDLINE_PARAM_DUMP "ext-pk-dump" >+ >+///////////////////////////////////////////////////////////////// >+ >+static Martini::OSA::IThreadSync* lockBCI = Martini::OSA::CreateThreadSync(); >+ >+static const char* logLocation = 0; // path to dump debug files >+ >+///////////////////////////////////////////////////////////////// >+ >+// >+// Probe classes support >+// >+ >+struct SDelayedClass { >+ SDelayedClass( char* pname, // 0 terminated >+ char* pdata, // binary data >+ int plen ) >+ : name( strdup(pname) ), data( pdata ), len(plen), next( 0 ) >+ {} >+ >+ ~SDelayedClass() >+ { >+ free( (void*)name ); >+ free( (void*)data ); >+ } >+ >+ char* name; >+ char* data; >+ int len; >+ >+ SDelayedClass* next; >+ >+ static SDelayedClass* head; >+ static SDelayedClass* tail; >+ >+ static void AddClass( SDelayedClass* newClass ); >+ static void FreeAllClasses(); >+ >+}; >+ >+SDelayedClass* SDelayedClass::head = 0; >+SDelayedClass* SDelayedClass::tail = SDelayedClass::head; >+ >+// add new class in the list >+void SDelayedClass::AddClass( SDelayedClass* newClass ) >+{ >+ if( SDelayedClass::head == 0 ) { >+ SDelayedClass::head = newClass; >+ } >+ >+ if( SDelayedClass::tail == 0 ) { >+ SDelayedClass::tail = newClass; >+ } else { >+ SDelayedClass::tail->next = newClass; >+ SDelayedClass::tail = newClass; >+ } >+} >+ >+// clear list >+void SDelayedClass::FreeAllClasses() >+{ >+ SDelayedClass* clsNext; >+ SDelayedClass* cls = SDelayedClass::head; >+ >+ while( cls ) { >+ clsNext = cls->next; >+ delete cls; >+ cls = clsNext; >+ } >+ >+ SDelayedClass::head = 0; >+ SDelayedClass::tail = 0; >+} >+ >+// >+// util >+// >+ >+// Load shared library that implements BCI >+static TResult LoadBCI(const char* options) >+{ >+ TResult result = MRTE_RESULT_OK; >+ char* BCIEngineName = Util::GetCmdlineOption( options, CMDLINE_PARAM_BCI ); >+ if( BCIEngineName == NULL ) { >+ LOG_MESSAGE( PROFILER_NAME " BCI engine not defined, using default " >+ DEFAULT_BCI_LIBRARY ); >+ BCIEngineName = strdup( DEFAULT_BCI_LIBRARY ); >+ } >+ LOG_TRACE( PROFILER_NAME " BCIEngine=" << BCIEngineName ); >+ >+ ILibraryLoader *pLibrary = CreateLibraryLoader( BCIEngineName, "", true ); >+ >+ if (pLibrary == NULL) { >+#ifdef __unix >+ LOG_ERROR( PROFILER_NAME " Instrumenter error: " << dlerror()); >+#endif >+ LOG_ERROR( PROFILER_NAME "Could not load " << BCIEngineName ); >+ free( BCIEngineName ); >+ return MRTE_ERROR_FAIL; >+ } >+ >+ RESOLVE_FUNCTION(CreateBCIEngine); >+ RESOLVE_FUNCTION(DestroyBCIEngine); >+ RESOLVE_FUNCTION(Initialize); >+ RESOLVE_FUNCTION(SetAllocator); >+ RESOLVE_FUNCTION(SetCallback); >+ RESOLVE_FUNCTION(Instrument); >+ >+ if( CreateBCIEngine_fn((pbcieng_t*)&BCIEngine) != 0 ) { >+ LOG_ERROR( PROFILER_NAME " Can't initialize BCI engine implementation"); >+ result = MRTE_ERROR_FAIL; >+ } >+ >+out: >+ pLibrary->Destroy(); >+ free( BCIEngineName ); >+ >+ return result; >+} >+ >+// send probescript to BCI >+static TResult SendProbescriptToBCI( const char* probescript, int len ) >+{ >+ TResult result = MRTE_RESULT_OK; >+ >+ LOG_TRACE( PROFILER_NAME " content starts with " << (probescript ? probescript : "") ); >+ if( probescript ) { >+ int errCode = Initialize_fn(BCIEngine, probescript, len); >+ >+ if (errCode == 0) { >+ LOG_TRACE( PROFILER_NAME " probe script file processed successfully"); >+ } else { >+ LOG_ERROR( PROFILER_NAME " error processing probe script file"); >+ result = MRTE_ERROR_FAIL; >+ } >+ } >+ return result; >+} >+ >+static TResult LoadProbeScriptFromOptions(const char* options) >+{ >+ LOG_ASSERT(BCIEngine); >+ TResult result = MRTE_RESULT_OK; >+ >+ char* probeScriptName = Util::GetCmdlineOption( options, CMDLINE_PARAM_PROBESCRIPT ); >+ >+ if( probeScriptName ) { >+ >+ LOG_TRACE( PROFILER_NAME " probeScriptName=" << probeScriptName ); >+ >+ char* content; >+ int len; >+ Util::ReadFile( probeScriptName, content, len ); >+ >+ result = SendProbescriptToBCI( content, len ); >+ >+ free( content ); >+ free( probeScriptName ); >+ } >+ >+ return result; >+} >+ >+ >+// BCI callback >+int BCICallback(const char* i_pInfo, size_t i_cbInfo, unsigned i_wFlags) >+{ >+ int result = 1; >+ >+ if(!CGlobals::Instance()->m_VMInitSeen) >+ { >+ result = 0; >+ } >+ else if(i_wFlags == BCIENGINTERFACE_CALLBACK_MODULE) >+ { >+ // let it instrument >+ // NOTE: is this is a probekit class, the condition above >+ // (m_VMInitSeen) disables its instrumentation >+ } >+ else if ( >+ i_wFlags == BCIENGINTERFACE_CALLBACK_MODULE_INSTR || >+ i_wFlags == BCIENGINTERFACE_CALLBACK_METHOD_INSTR ) { >+ >+ /* >+ * This is a report that this class or method was actually instrumented. >+ * */ >+#if defined(DEBUG) || defined(_DEBUG) >+ char* nameBuf = Util::StrNDup( i_pInfo, (int)i_cbInfo ); >+ if( nameBuf ) { >+ LOG_TRACE( PROFILER_NAME " instrumented " << nameBuf ); >+ free( nameBuf ); >+ } else { >+ LOG_ERROR( PROFILER_NAME " out of memory" ); >+ } >+#endif >+ } >+ >+ return result; >+} >+ >+// process data sent by client - it's either probescript or .class >+static >+TResult ProcessClientFile( const char* name, const char* data, int len ) >+{ >+ TResult retVal = MRTE_RESULT_OK; >+ >+ // name is either a class name or something.probescript >+ if( strstr( name, PROBESCRIPT_FILE_EXTENSION ) ) { >+ // probescript >+ retVal = SendProbescriptToBCI( data, len ); >+ } else if( const char* ext = strstr( name, PROBESCRIPT_CLASS_EXTENSION ) ) { >+ // assume class >+ char* nameBuf = Util::StrNDup( name, ext - name ); // strip extension >+ if( nameBuf == 0 ) { >+ return MRTE_ERROR_FAIL; >+ } >+ char* dataBuf = Util::StrNDup( data, len ); >+ if( dataBuf == 0 ) { >+ return MRTE_ERROR_FAIL; >+ } >+ SDelayedClass* delayedClass = new SDelayedClass( nameBuf, dataBuf, len ); >+ SDelayedClass::AddClass( delayedClass ); >+ free( nameBuf ); >+ } else { >+ LOG_ERROR( PROFILER_NAME " unsupported file " << name ); >+ retVal = MRTE_ERROR_FAIL; >+ } >+ return retVal; >+} >+ >+// read probekit settings from EC; return MRTE_RESULT_TRUE if such >+// settings found, MRTE_RESULT_FALSE if not found, an error code >+// otherwise. >+static TResult ReadClientProbekitData() >+{ >+ TResult retVal = MRTE_RESULT_FALSE; >+ >+ // read probekit options >+ CProbekitAgent* agent = CProbekitAgent::getInstance(); >+ >+ // iterate and find all probekit options >+ for( int count = 0;; count++ ) { >+ char optName[64]; >+ sprintf( optName, "PROBEKIT_DATA_%d", count ); >+ >+ const char* data = agent->getEC()->getUnknownOptionByName( optName ); >+ >+ if( data == 0 ) { >+ break; >+ } >+ >+ LOG_TRACE( PROFILER_NAME " " << optName << "=" << data ); >+ >+ int len = strlen( data ); >+ LOG_TRACE( PROFILER_NAME " total len = " << len ); >+ Util::DumpBuffer( logLocation, "base64", data, len ); >+ >+ char* out = (char*)malloc( len+1 ); >+ int decoded = Util::DecodeBuffer( data, len, out ); >+ >+ // java is big-endian (i.e. network byte order) >+ int magic = ntohl(*(int*)out); >+ >+ char* ptr = out + sizeof(magic); >+ >+ LOG_TRACE( PROFILER_NAME " decoded " << decoded << >+ " bytes, magic=" << magic); >+ >+ // ptr alignment may be inefficient >+ >+ while( ptr < out + decoded ) { >+ >+ int nameLen = ntohl(*(int*)ptr ); >+ ptr += sizeof( nameLen ); >+ >+ char* name = Util::StrNDup( ptr, nameLen ); >+ if( name == 0 ) { >+ return MRTE_ERROR_FAIL; >+ } >+ ptr += nameLen; >+ >+ int dataLen = ntohl(*(int*)ptr); >+ ptr += sizeof(dataLen); >+ >+ // read data >+ LOG_TRACE( PROFILER_NAME " nameLen=" << nameLen >+ << " name = " << name >+ << " dataLen = " << dataLen ); >+ >+ retVal = ProcessClientFile( name, ptr, dataLen ); >+ free( name ); >+ if( MRTE_FAILED(retVal) ) { >+ return retVal; >+ } >+ >+ ptr += dataLen; >+ } >+ >+ free(out); >+ >+ // read at least one option block >+ retVal = MRTE_RESULT_TRUE; >+ } // for >+ >+ return retVal; >+} >+ >+// >+// CBCIInstrumenter >+// >+ >+ >+CBCIInstrumenter::CBCIInstrumenter() >+ : m_initialized(false) >+{} >+ >+CBCIInstrumenter::~CBCIInstrumenter() >+{ >+ if( m_initialized && BCIEngine ) { >+ DestroyBCIEngine_fn( BCIEngine ); >+ } >+} >+ >+TResult CBCIInstrumenter::Initialize(const char* options) >+{ >+ TResult retVal = MRTE_RESULT_OK; >+ >+ LOG_TRACE( PROFILER_NAME " Initialize BCI Instrumenter, options=" << options); >+ >+ if( m_initialized ) { >+ LOG_MESSAGE( PROFILER_NAME " Instrumenter already initialized"); >+ return retVal; >+ } >+ >+ // load BCI library >+ retVal = LoadBCI(options); >+ if( MRTE_FAILED( retVal ) ) { >+ LOG_ERROR( PROFILER_NAME " Can't load BCI engine, error=" << retVal ); >+ return retVal; >+ } >+ >+ SetCallback_fn(BCIEngine, BCICallback, 0xFFFF); >+ >+ logLocation = Util::GetCmdlineOption( options, CMDLINE_PARAM_DUMP ); >+ >+ // read and process probekit settings from EC first >+ retVal = ReadClientProbekitData(); >+ if( MRTE_FAILED(retVal) ) { >+ LOG_ERROR( PROFILER_NAME " Can't load probescript data from EC" ); >+ return retVal; >+ } >+ if( retVal == MRTE_RESULT_FALSE ) { >+ // didn't find probescript data in EC - read options >+ retVal = LoadProbeScriptFromOptions(options); >+ } >+ if( MRTE_FAILED( retVal ) ) { >+ LOG_ERROR( PROFILER_NAME " Can't load probescript from options" ); >+ return retVal; >+ } >+ >+ m_initialized = true; >+ return retVal; >+} >+ >+TResult CBCIInstrumenter::Instrument( >+ TMemoryAllocatorFunc memAllocFunc, >+ const char* className, >+ const char* inClass, size_t inClassLength, >+ char** outClass, size_t* outClassLength) >+{ >+ TResult result = MRTE_RESULT_FALSE; >+ >+ if( !m_initialized ) { >+ LOG_ERROR( PROFILER_NAME " BCI engine is not initialized" ); >+ return ( result = MRTE_ERROR_FAIL ); >+ } >+ >+ char* outClassTmp = 0; >+ size_t outClassLengthTmp = 0; >+ >+ lockBCI->Enter(); // lock >+ >+ SetAllocator_fn( BCIEngine, memAllocFunc ); >+ Instrument_fn( BCIEngine, inClass, inClassLength, >+ &outClassTmp, &outClassLengthTmp); >+ SetAllocator_fn( BCIEngine, 0 ); >+ >+ lockBCI->Leave(); // unlock >+ >+ if( outClassLengthTmp == inClassLength ) { >+ ; // did nothing >+ } else { >+ // instrumented >+ >+ Util::DumpBuffer( logLocation, className, >+ (const char*)outClassTmp, outClassLengthTmp ); >+ >+ *outClass = outClassTmp; >+ *outClassLength = outClassLengthTmp; >+ >+ result = MRTE_RESULT_TRUE; >+ } >+ >+ return result; >+} >+ >+void CBCIInstrumenter::OnVMInit() >+{ >+ JNIEnv *pEnv = 0; >+ bool bAttached = false; >+ >+ LOG_TRACE( PROFILER_NAME " CBCIInstrumenter::OnVMInit" ); >+ >+ TResult res = CGlobals::Instance()->pfnJPI_AttachCurrentThread( >+ (JNIEnv**)&pEnv, &bAttached); >+ if (MRTE_SUCCEEDED(res)) >+ { >+ SDelayedClass* cls = SDelayedClass::head; >+ while( cls ) { >+ >+ LOG_TRACE( PROFILER_NAME " process delayed class " << cls->name ); >+ >+ Util::DumpBuffer( logLocation, cls->name, cls->data, cls->len ); >+ >+ jclass c = pEnv->DefineClass( >+ cls->name, (jobject)NULL, (const jbyte*)cls->data, cls->len); >+ LOG_TRACE( PROFILER_NAME " DefineClass returned " << (void*)c ); >+ if(c != 0 ) { >+ pEnv->NewGlobalRef(c); >+ } >+ >+ cls = cls->next; >+ >+ } // while >+ >+ SDelayedClass::FreeAllClasses(); >+ >+ if (bAttached) >+ { >+ // Need to detach the thread from the JVM for proper cleanup >+ CGlobals::Instance()->pfnJPI_DetachCurrentThread(); >+ } >+ } // if >+} >Index: src-native/src/ProbekitAgent/ECStartEvent.h >=================================================================== >RCS file: src-native/src/ProbekitAgent/ECStartEvent.h >diff -N src-native/src/ProbekitAgent/ECStartEvent.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/ECStartEvent.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#ifndef PROBEKIT_ECSTART_EVENT_H_ >+#define PROBEKIT_ECSTART_EVENT_H_ >+ >+#include "MpiAPI.h" >+ >+namespace Martini { namespace ProbekitAgent { >+ >+ // CStartEvent - represents a Start event >+ class CECStartEvent : public MPI::IEcStartEventObserver >+ { >+ public: >+ // Constructor >+ CECStartEvent(); >+ // Destructor >+ ~CECStartEvent(); >+ // Initialization - Register to event >+ TResult Init(MPI::IMpi *pMpiApi, MPI::TId clientId); >+ // Inherited methods >+ void HandleEvent(); >+ }; >+ >+} /*namespace Martini*/ } /*namespace ProbekitAgent*/ >+ >+#endif // PROBEKIT_ECSTART_EVENT_H_ >Index: src-native/src/ProbekitAgent/ClassFileLoadHookEvent.cpp >=================================================================== >RCS file: src-native/src/ProbekitAgent/ClassFileLoadHookEvent.cpp >diff -N src-native/src/ProbekitAgent/ClassFileLoadHookEvent.cpp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/ClassFileLoadHookEvent.cpp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,72 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#include "ClassFileLoadHookEvent.h" >+#include "InstrumenterFactory.h" >+#include "Instrumenter.h" >+ >+using namespace Martini::ProbekitAgent; >+using namespace Martini::MPI; >+ >+/* >+ * CClassFileLoadHookEvent >+ */ >+ >+CClassFileLoadHookEvent::CClassFileLoadHookEvent(){} >+ >+CClassFileLoadHookEvent::~CClassFileLoadHookEvent(){} >+ >+/* >+ * Init - initializes internal data and registers event >+ */ >+TResult CClassFileLoadHookEvent::Init(IMpi *pMpiApi, TId clientId) >+{ >+ m_pMpiApi = pMpiApi; >+ m_clientId = clientId; >+ >+ // Register event >+ TResult res; >+ res = m_pMpiApi->RegisterEvent(m_clientId, *this); >+ >+ return res; >+} >+ >+/* >+ * HandleEvent - callback function for Class File Load Hook event >+ */ >+ >+ // Here the agent can instrument the class. >+ // Class data is stored in the 'data' argument. >+ >+ // If the agent instrumented the class, it needs to allocate a new buffer in >+ // newClassData using memAllocFunc, and then set the new class data length in >+ // newClassDataLength. >+ >+ // If the agent did not instrument the class, it should leave newClassData untouched, >+ >+void CClassFileLoadHookEvent::HandleEvent(SClassFileLoadHookEventData &data, >+ TMemoryAllocatorFunc memAllocFunc, >+ unsigned char **newClassData, >+ S32 *newClassDataLength) >+{ >+ CInstrumenterFactory::getInstrumenter()->Instrument( >+ memAllocFunc, >+ data.className, >+ (const char*)data.classData, >+ (size_t)data.classDataLength, >+ (char**)newClassData, >+ (size_t*)newClassDataLength ); >+} >+ >+ >+ >Index: src-native/src/ProbekitAgent/ECStopEvent.cpp >=================================================================== >RCS file: src-native/src/ProbekitAgent/ECStopEvent.cpp >diff -N src-native/src/ProbekitAgent/ECStopEvent.cpp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/ECStopEvent.cpp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#include "ECStopEvent.h" >+#include "Globals.h" >+#include <log.h> >+ >+using namespace Martini; >+using namespace Martini::MPI; >+using namespace Martini::ProbekitAgent; >+ >+CECStopEvent::CECStopEvent(){} >+CECStopEvent::~CECStopEvent(){} >+ >+/* >+ * Init - initializes internal data and registers for Stop event >+ */ >+TResult >+CECStopEvent::Init(MPI::IMpi *pMpiApi, MPI::TId clientId) >+{ >+ TResult res = pMpiApi->RegisterEvent(clientId, *this); >+ return res; >+} >+ >+/* >+ * HandleEvent - callback function for Stop event >+ */ >+void >+CECStopEvent::HandleEvent() >+{ >+ LOG_TRACE( PROFILER_NAME " EC Stop" ); >+} >Index: src-native/src/ProbekitAgent/ClassFileLoadHookEvent.h >=================================================================== >RCS file: src-native/src/ProbekitAgent/ClassFileLoadHookEvent.h >diff -N src-native/src/ProbekitAgent/ClassFileLoadHookEvent.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/ClassFileLoadHookEvent.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#ifndef PROBEKIT_CLASS_FILE_LOAD_HOOK_EVENT_H >+#define PROBEKIT_CLASS_FILE_LOAD_HOOK_EVENT_H >+ >+#include "MpiAPI.h" >+ >+namespace Martini { namespace ProbekitAgent { >+ >+ // CClassFileLoadHookEvent - represents a Class File Load Hook event >+ class CClassFileLoadHookEvent : public MPI::IJavaClassFileLoadHookEventObserver >+ { >+ public: >+ CClassFileLoadHookEvent(); >+ ~CClassFileLoadHookEvent(); >+ >+ // Initialization - Register to event >+ TResult Init(MPI::IMpi *pMpiApi, MPI::TId clientId); >+ >+ // Event handler >+ void HandleEvent(MPI::SClassFileLoadHookEventData &data, >+ TMemoryAllocatorFunc memAllocFunc, >+ unsigned char **newClassData, >+ S32 *newClassDataLength); >+ >+ private: >+ // Pointer to the MPI implementation >+ MPI::IMpi *m_pMpiApi; >+ >+ // Client id for MPI requests >+ MPI::TId m_clientId; >+ }; >+ >+} /*namespace Martini*/ } /*namespace ProbekitAgent*/ >+ >+#endif // PROBEKIT_CLASS_FILE_LOAD_HOOK_EVENT_H >+ >Index: src-native/src/ProbekitAgent/InstrumenterFactory.h >=================================================================== >RCS file: src-native/src/ProbekitAgent/InstrumenterFactory.h >diff -N src-native/src/ProbekitAgent/InstrumenterFactory.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/InstrumenterFactory.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#ifndef PROBEKIT_INSTRUMENTER_FACTORY_H >+#define PROBEKIT_INSTRUMENTER_FACTORY_H >+ >+namespace Martini { namespace ProbekitAgent { >+ >+class IInstrumenter; >+ >+class CInstrumenterFactory >+{ >+public: >+ >+ static IInstrumenter* getInstrumenter(); >+ >+private: >+ >+ CInstrumenterFactory(); >+ CInstrumenterFactory( const CInstrumenterFactory& ); >+ >+ static IInstrumenter* m_instrumenter; >+}; >+ >+} /*namespace Martini*/ } /*namespace ProbekitAgent*/ >+ >+#endif // PROBEKIT_INSTRUMENTER_FACTORY_H >Index: src-native/src/ProbekitAgent/InstrumenterFactory.cpp >=================================================================== >RCS file: src-native/src/ProbekitAgent/InstrumenterFactory.cpp >diff -N src-native/src/ProbekitAgent/InstrumenterFactory.cpp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/InstrumenterFactory.cpp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#include "InstrumenterFactory.h" >+#include "Instrumenter.h" >+ >+using namespace Martini::ProbekitAgent; >+ >+IInstrumenter* CInstrumenterFactory::m_instrumenter = 0; >+ >+IInstrumenter* CInstrumenterFactory::getInstrumenter() >+{ >+ if( m_instrumenter == 0 ) { >+ m_instrumenter = new CBCIInstrumenter(); >+ } >+ >+ return m_instrumenter; >+} >Index: src-native/src/ProbekitAgent/ProbekitAgent.ver >=================================================================== >RCS file: src-native/src/ProbekitAgent/ProbekitAgent.ver >diff -N src-native/src/ProbekitAgent/ProbekitAgent.ver >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/ProbekitAgent.ver 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,8 @@ >+{ >+ global: >+ MPICL_Instantiate; >+ local: >+ *; >+}; >+ >+ >Index: src-native/src/ProbekitAgent/b64.c >=================================================================== >RCS file: src-native/src/ProbekitAgent/b64.c >diff -N src-native/src/ProbekitAgent/b64.c >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/b64.c 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,551 @@ >+/*********************************************************************\ >+ >+MODULE NAME: b64.c >+ >+AUTHOR: Bob Trower 08/04/01 >+ >+PROJECT: Crypt Data Packaging >+ >+COPYRIGHT: Copyright (c) Trantor Standard Systems Inc., 2001 >+ >+NOTE: This source code may be used as you wish, subject to >+ the MIT license. See the LICENCE section below. >+ >+DESCRIPTION: >+ This little utility implements the Base64 >+ Content-Transfer-Encoding standard described in >+ RFC1113 (http://www.faqs.org/rfcs/rfc1113.html). >+ >+ This is the coding scheme used by MIME to allow >+ binary data to be transferred by SMTP mail. >+ >+ Groups of 3 bytes from a binary stream are coded as >+ groups of 4 bytes in a text stream. >+ >+ The input stream is 'padded' with zeros to create >+ an input that is an even multiple of 3. >+ >+ A special character ('=') is used to denote padding so >+ that the stream can be decoded back to its exact size. >+ >+ Encoded output is formatted in lines which should >+ be a maximum of 72 characters to conform to the >+ specification. This program defaults to 72 characters, >+ but will allow more or less through the use of a >+ switch. The program enforces a minimum line size >+ of 4 characters. >+ >+ Example encoding: >+ >+ The stream 'ABCD' is 32 bits long. It is mapped as >+ follows: >+ >+ ABCD >+ >+ A (65) B (66) C (67) D (68) (None) (None) >+ 01000001 01000010 01000011 01000100 >+ >+ 16 (Q) 20 (U) 9 (J) 3 (D) 17 (R) 0 (A) NA (=) NA (=) >+ 010000 010100 001001 000011 010001 000000 000000 000000 >+ >+ >+ QUJDRA== >+ >+ Decoding is the process in reverse. A 'decode' lookup >+ table has been created to avoid string scans. >+ >+DESIGN GOALS: Specifically: >+ Code is a stand-alone utility to perform base64 >+ encoding/decoding. It should be genuinely useful >+ when the need arises and it meets a need that is >+ likely to occur for some users. >+ Code acts as sample code to show the author's >+ design and coding style. >+ >+ Generally: >+ This program is designed to survive: >+ Everything you need is in a single source file. >+ It compiles cleanly using a vanilla ANSI C compiler. >+ It does its job correctly with a minimum of fuss. >+ The code is not overly clever, not overly simplistic >+ and not overly verbose. >+ Access is 'cut and paste' from a web page. >+ Terms of use are reasonable. >+ >+VALIDATION: Non-trivial code is never without errors. This >+ file likely has some problems, since it has only >+ been tested by the author. It is expected with most >+ source code that there is a period of 'burn-in' when >+ problems are identified and corrected. That being >+ said, it is possible to have 'reasonably correct' >+ code by following a regime of unit test that covers >+ the most likely cases and regression testing prior >+ to release. This has been done with this code and >+ it has a good probability of performing as expected. >+ >+ Unit Test Cases: >+ >+ case 0:empty file: >+ CASE0.DAT -> -> >+ (Zero length target file created >+ on both encode and decode.) >+ >+ case 1:One input character: >+ CASE1.DAT A -> QQ== -> A >+ >+ case 2:Two input characters: >+ CASE2.DAT AB -> QUJD -> AB >+ >+ case 3:Three input characters: >+ CASE3.DAT ABC -> QUJD -> ABC >+ >+ case 4:Four input characters: >+ case4.dat ABCD -> QUJDRA== -> ABCD >+ >+ case 5:All chars from 0 to ff, linesize set to 50: >+ >+ AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIj >+ JCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZH >+ SElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWpr >+ bG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6P >+ kJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKz >+ tLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX >+ 2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7 >+ /P3+/w== >+ >+ case 6:Mime Block from e-mail: >+ (Data same as test case 5) >+ >+ case 7: Large files: >+ Tested 28 MB file in/out. >+ >+ case 8: Random Binary Integrity: >+ This binary program (b64.exe) was encoded to base64, >+ back to binary and then executed. >+ >+ case 9 Stress: >+ All files in a working directory encoded/decoded >+ and compared with file comparison utility to >+ ensure that multiple runs do not cause problems >+ such as exhausting file handles, tmp storage, etc. >+ >+ ------------- >+ >+ Syntax, operation and failure: >+ All options/switches tested. Performs as >+ expected. >+ >+ case 10: >+ No Args -- Shows Usage Screen >+ Return Code 1 (Invalid Syntax) >+ case 11: >+ One Arg (invalid) -- Shows Usage Screen >+ Return Code 1 (Invalid Syntax) >+ case 12: >+ One Arg Help (-?) -- Shows detailed Usage Screen. >+ Return Code 0 (Success -- help request is valid). >+ case 13: >+ One Arg Help (-h) -- Shows detailed Usage Screen. >+ Return Code 0 (Success -- help request is valid). >+ case 14: >+ One Arg (valid) -- Uses stdin/stdout (filter) >+ Return Code 0 (Sucess) >+ case 15: >+ Two Args (invalid file) -- shows system error. >+ Return Code 2 (File Error) >+ case 16: >+ Encode non-existent file -- shows system error. >+ Return Code 2 (File Error) >+ case 17: >+ Out of disk space -- shows system error. >+ Return Code 3 (File I/O Error) >+ >+ ------------- >+ >+ Compile/Regression test: >+ gcc compiled binary under Cygwin >+ Microsoft Visual Studio under Windows 2000 >+ Microsoft Version 6.0 C under Windows 2000 >+ >+DEPENDENCIES: None >+ >+LICENCE: Copyright (c) 2001 Bob Trower, Trantor Standard Systems Inc. >+ >+ Permission is hereby granted, free of charge, to any person >+ obtaining a copy of this software and associated >+ documentation files (the "Software"), to deal in the >+ Software without restriction, including without limitation >+ the rights to use, copy, modify, merge, publish, distribute, >+ sublicense, and/or sell copies of the Software, and to >+ permit persons to whom the Software is furnished to do so, >+ subject to the following conditions: >+ >+ The above copyright notice and this permission notice shall >+ be included in all copies or substantial portions of the >+ Software. >+ >+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY >+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE >+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR >+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS >+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR >+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR >+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE >+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. >+ >+VERSION HISTORY: >+ Bob Trower 08/04/01 -- Create Version 0.00.00B >+ vss 04/25/01 -- Added decode_buffer >+ >+\******************************************************************* */ >+ >+#include <stdio.h> >+#include <stdlib.h> >+ >+/* >+** Translation Table as described in RFC1113 >+*/ >+static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; >+ >+/* >+** Translation Table to decode (created by author) >+*/ >+static const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq"; >+ >+/* >+** encodeblock >+** >+** encode 3 8-bit binary bytes as 4 '6-bit' characters >+*/ >+void encodeblock( unsigned char in[3], unsigned char out[4], int len ) >+{ >+ out[0] = cb64[ in[0] >> 2 ]; >+ out[1] = cb64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ]; >+ out[2] = (unsigned char) (len > 1 ? cb64[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] : '='); >+ out[3] = (unsigned char) (len > 2 ? cb64[ in[2] & 0x3f ] : '='); >+} >+ >+/* >+** encode >+** >+** base64 encode a stream adding padding and line breaks as per spec. >+*/ >+void encode( FILE *infile, FILE *outfile, int linesize ) >+{ >+ unsigned char in[3], out[4]; >+ int i, len, blocksout = 0; >+ >+ while( !feof( infile ) ) { >+ len = 0; >+ for( i = 0; i < 3; i++ ) { >+ in[i] = (unsigned char) getc( infile ); >+ if( !feof( infile ) ) { >+ len++; >+ } >+ else { >+ in[i] = 0; >+ } >+ } >+ if( len ) { >+ encodeblock( in, out, len ); >+ for( i = 0; i < 4; i++ ) { >+ putc( out[i], outfile ); >+ } >+ blocksout++; >+ } >+ if( blocksout >= (linesize/4) || feof( infile ) ) { >+ if( blocksout ) { >+ fprintf( outfile, "\r\n" ); >+ } >+ blocksout = 0; >+ } >+ } >+} >+ >+/* >+** decodeblock >+** >+** decode 4 '6-bit' characters into 3 8-bit binary bytes >+*/ >+void decodeblock( unsigned char in[4], unsigned char out[3] ) >+{ >+ out[ 0 ] = (unsigned char ) (in[0] << 2 | in[1] >> 4); >+ out[ 1 ] = (unsigned char ) (in[1] << 4 | in[2] >> 2); >+ out[ 2 ] = (unsigned char ) (((in[2] << 6) & 0xc0) | in[3]); >+} >+ >+/* >+** decode >+** >+** decode a base64 encoded stream discarding padding, line breaks and noise >+*/ >+void decode( FILE *infile, FILE *outfile ) >+{ >+ unsigned char in[4], out[3], v; >+ int i, len; >+ >+ while( !feof( infile ) ) { >+ for( len = 0, i = 0; i < 4 && !feof( infile ); i++ ) { >+ v = 0; >+ while( !feof( infile ) && v == 0 ) { >+ v = (unsigned char) getc( infile ); >+ v = (unsigned char) ((v < 43 || v > 122) ? 0 : cd64[ v - 43 ]); >+ if( v ) { >+ v = (unsigned char) ((v == '$') ? 0 : v - 61); >+ } >+ } >+ if( !feof( infile ) ) { >+ len++; >+ if( v ) { >+ in[ i ] = (unsigned char) (v - 1); >+ } >+ } >+ else { >+ in[i] = 0; >+ } >+ } >+ if( len ) { >+ decodeblock( in, out ); >+ for( i = 0; i < len - 1; i++ ) { >+ putc( out[i], outfile ); >+ } >+ } >+ } >+} >+ >+// tmp >+#ifdef __cplusplus >+extern "C" >+#endif >+int decode_buffer( const char* inBuffer, int inLen, char* outBuffer) >+{ >+ unsigned char in[4], out[3], v; >+ int i, len; >+ int inp = 0, outp = 0; >+ >+ while( inp < inLen ) { >+ for( len = 0, i = 0; i < 4 && inp < inLen; i++ ) { >+ v = 0; >+ while( inp < inLen && v == 0 ) { >+ v = (unsigned char) inBuffer[ inp++ ]; >+ v = (unsigned char) ((v < 43 || v > 122) ? 0 : cd64[ v - 43 ]); >+ if( v ) { >+ v = (unsigned char) ((v == '$') ? 0 : v - 61); >+ } >+ } >+ if( inp < inLen ) { >+ len++; >+ if( v ) { >+ in[ i ] = (unsigned char) (v - 1); >+ } >+ } >+ else { >+ in[i] = 0; >+ } >+ } >+ if( len ) { >+ decodeblock( in, out ); >+ for( i = 0; i < len - 1; i++ ) { >+ outBuffer[ outp++ ] = out[i]; >+ } >+ } >+ } >+ return outp; >+} >+ >+/* >+** returnable errors >+** >+** Error codes returned to the operating system. >+** >+*/ >+#define B64_SYNTAX_ERROR 1 >+#define B64_FILE_ERROR 2 >+#define B64_FILE_IO_ERROR 3 >+#define B64_ERROR_OUT_CLOSE 4 >+#define B64_LINE_SIZE_TO_MIN 5 >+ >+/* >+** b64_message >+** >+** Gather text messages in one place. >+** >+*/ >+char *b64_message( int errcode ) >+{ >+ #define B64_MAX_MESSAGES 6 >+ char *msgs[ B64_MAX_MESSAGES ] = { >+ "b64:000:Invalid Message Code.", >+ "b64:001:Syntax Error -- check help for usage.", >+ "b64:002:File Error Opening/Creating Files.", >+ "b64:003:File I/O Error -- Note: output file not removed.", >+ "b64:004:Error on output file close.", >+ "b64:004:linesize set to minimum." >+ }; >+ char *msg = msgs[ 0 ]; >+ >+ if( errcode > 0 && errcode < B64_MAX_MESSAGES ) { >+ msg = msgs[ errcode ]; >+ } >+ >+ return( msg ); >+} >+ >+/* >+** b64 >+** >+** 'engine' that opens streams and calls encode/decode >+*/ >+ >+int b64( int opt, char *infilename, char *outfilename, int linesize ) >+{ >+ FILE *infile; >+ int retcode = B64_FILE_ERROR; >+ >+ if( !infilename ) { >+ infile = stdin; >+ } >+ else { >+ infile = fopen( infilename, "rb" ); >+ } >+ if( !infile ) { >+ perror( infilename ); >+ } >+ else { >+ FILE *outfile; >+ if( !outfilename ) { >+ outfile = stdout; >+ } >+ else { >+ outfile = fopen( outfilename, "wb" ); >+ } >+ if( !outfile ) { >+ perror( outfilename ); >+ } >+ else { >+ if( opt == 'e' ) { >+ encode( infile, outfile, linesize ); >+ } >+ else { >+ decode( infile, outfile ); >+ } >+ if (ferror( infile ) || ferror( outfile )) { >+ retcode = B64_FILE_IO_ERROR; >+ } >+ else { >+ retcode = 0; >+ } >+ if( outfile != stdout ) { >+ if( fclose( outfile ) != 0 ) { >+ perror( b64_message( B64_ERROR_OUT_CLOSE ) ); >+ retcode = B64_FILE_IO_ERROR; >+ } >+ } >+ } >+ if( infile != stdin ) { >+ fclose( infile ); >+ } >+ } >+ >+ return( retcode ); >+} >+ >+/* >+** showuse >+** >+** display usage information, help, version info >+*/ >+void showuse( int morehelp ) >+{ >+ { >+ printf( "\n" ); >+ printf( " b64 (Base64 Encode/Decode) Bob Trower 08/03/01 \n" ); >+ printf( " (C) Copr Bob Trower 1986-01. Version 0.00B \n" ); >+ printf( " Usage: b64 -option [ -l num ] [<FileIn> [<FileOut>]] \n" ); >+ printf( " Purpose: This program is a simple utility that implements\n" ); >+ printf( " Base64 Content-Transfer-Encoding (RFC1113). \n" ); >+ } >+ if( !morehelp ) { >+ printf( " Use -h option for additional help. \n" ); >+ } >+ else { >+ printf( " Options: -e encode to Base64 -h This help text. \n" ); >+ printf( " -d decode from Base64 -? This help text. \n" ); >+ printf( " Note: -l use to change line size (from 72 characters)\n" ); >+ printf( " Returns: 0 = success. Non-zero is an error code. \n" ); >+ printf( " ErrCode: 1 = Bad Syntax, 2 = File Open, 3 = File I/O \n" ); >+ printf( " Example: b64 -e binfile b64file <- Encode to b64 \n" ); >+ printf( " b64 -d b64file binfile <- Decode from b64 \n" ); >+ printf( " b64 -e -l40 infile outfile <- Line Length of 40 \n" ); >+ printf( " Note: Will act as a filter, but this should only be \n" ); >+ printf( " used on text files due to translations made by \n" ); >+ printf( " operating systems. \n" ); >+ printf( " Release: 0.00.00, Tue Aug 7 2:00:00 2001, ANSI-SOURCE C\n" ); >+ } >+} >+ >+#define B64_DEF_LINE_SIZE 72 >+#define B64_MIN_LINE_SIZE 4 >+ >+#define THIS_OPT(ac, av) (ac > 1 ? av[1][0] == '-' ? av[1][1] : 0 : 0) >+ >+/* >+** main >+** >+** parse and validate arguments and call b64 engine or help >+*/ >+ >+#ifdef BASE64_MAIN >+int main( int argc, char **argv ) >+{ >+ int opt = 0; >+ int retcode = 0; >+ int linesize = B64_DEF_LINE_SIZE; >+ char *infilename = NULL, *outfilename = NULL; >+ >+ while( THIS_OPT( argc, argv ) ) { >+ switch( THIS_OPT(argc, argv) ) { >+ case 'l': >+ linesize = atoi( &(argv[1][2]) ); >+ if( linesize < B64_MIN_LINE_SIZE ) { >+ linesize = B64_MIN_LINE_SIZE; >+ printf( "%s\n", b64_message( B64_LINE_SIZE_TO_MIN ) ); >+ } >+ break; >+ case '?': >+ case 'h': >+ opt = 'h'; >+ break; >+ case 'e': >+ case 'd': >+ opt = THIS_OPT(argc, argv); >+ break; >+ default: >+ opt = 0; >+ break; >+ } >+ argv++; >+ argc--; >+ } >+ switch( opt ) { >+ case 'e': >+ case 'd': >+ infilename = argc > 1 ? argv[1] : NULL; >+ outfilename = argc > 2 ? argv[2] : NULL; >+ retcode = b64( opt, infilename, outfilename, linesize ); >+ break; >+ case 0: >+ retcode = B64_SYNTAX_ERROR; >+ case 'h': >+ showuse( opt ); >+ break; >+ >+ } >+ if( retcode ) { >+ printf( "%s\n", b64_message( retcode ) ); >+ } >+ >+ return( retcode ); >+} >+ >+#endif >Index: src-native/src/ProbekitAgent/Instrumenter.h >=================================================================== >RCS file: src-native/src/ProbekitAgent/Instrumenter.h >diff -N src-native/src/ProbekitAgent/Instrumenter.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/Instrumenter.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#ifndef PROBEKIT_INSTRUMENTER_H >+#define PROBEKIT_INSTRUMENTER_H >+ >+#include <malloc.h> >+#include <MRTEResults.h> >+ >+namespace Martini { namespace ProbekitAgent { >+ >+class IInstrumenter >+{ >+public: >+ >+ typedef void* (*TMemoryAllocatorFunc)(unsigned int); >+ >+ virtual ~IInstrumenter() {} >+ >+ virtual TResult Initialize(const char* options) = 0; >+ >+ virtual TResult Instrument(TMemoryAllocatorFunc memAllocFunc, >+ const char* className, >+ const char* inClass, size_t inClassLength, >+ char** outClass, size_t* outClassLength) = 0; >+ >+ virtual void OnVMInit() = 0; >+}; >+ >+class CBCIInstrumenter : public IInstrumenter >+{ >+ bool m_initialized; >+ >+public: >+ >+ CBCIInstrumenter(); >+ virtual ~CBCIInstrumenter(); >+ >+ virtual TResult Initialize(const char* options); >+ >+ // Instrument returns MRTE_RESULT_TRUE if instrumented, >+ // MRTE_RESULT_FALSE if not instrumented, an error code >+ // otherwise. >+ virtual TResult Instrument(TMemoryAllocatorFunc memAllocFunc, >+ const char* className, >+ const char* inClass, size_t inClassLength, >+ char** outClass, size_t* outClassLength); >+ >+ virtual void OnVMInit(); >+}; >+ >+ >+} /*namespace Martini*/ } /*namespace ProbekitAgent*/ >+ >+#endif // PROBEKIT_INSTRUMENTER_H >Index: src-native/src/ProbekitAgent/VMInitEvent.cpp >=================================================================== >RCS file: src-native/src/ProbekitAgent/VMInitEvent.cpp >diff -N src-native/src/ProbekitAgent/VMInitEvent.cpp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/VMInitEvent.cpp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#include "VMInitEvent.h" >+#include "Globals.h" >+#include "InstrumenterFactory.h" >+#include "Instrumenter.h" >+#include <log.h> >+ >+using namespace Martini::ProbekitAgent; >+using namespace Martini::MPI; >+ >+CVMInitEvent::CVMInitEvent() >+{} >+ >+CVMInitEvent::~CVMInitEvent() >+{} >+ >+/* >+ * Init - initializes internal data and registers for VM init event >+ */ >+TResult CVMInitEvent::Init(IMpi *pMpiApi, TId clientId) >+{ >+ m_pMpiApi = pMpiApi; >+ m_clientId = clientId; >+ >+ // register for VM init event >+ TResult res = m_pMpiApi->RegisterEvent(m_clientId, *this); >+ return res; >+} >+ >+/* >+ * HandleEvent - callback function for VM init event >+ */ >+void CVMInitEvent::HandleEvent(SVmInitEventData &data) >+{ >+ LOG_TRACE( PROFILER_NAME " VM Init" ); >+ >+ CInstrumenterFactory::getInstrumenter()->OnVMInit(); >+ CGlobals::Instance()->m_VMInitSeen = true; >+} >Index: src-native/build/BuildProbekitAgent32.mak >=================================================================== >RCS file: src-native/build/BuildProbekitAgent32.mak >diff -N src-native/build/BuildProbekitAgent32.mak >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/build/BuildProbekitAgent32.mak 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,275 @@ >+# Microsoft Developer Studio Generated NMAKE File, Based on BuildProbekitAgent32.dsp >+!IF "$(CFG)" == "" >+CFG=BuildProbekitAgent32 - Win32 Debug >+!MESSAGE No configuration specified. Defaulting to BuildProbekitAgent32 - Win32 Debug. >+!ENDIF >+ >+!IF "$(CFG)" != "BuildProbekitAgent32 - Win32 Release" && "$(CFG)" != "BuildProbekitAgent32 - Win32 Debug" >+!MESSAGE Invalid configuration "$(CFG)" specified. >+!MESSAGE You can specify a configuration when running NMAKE >+!MESSAGE by defining the macro CFG on the command line. For example: >+!MESSAGE >+!MESSAGE NMAKE /f "BuildProbekitAgent32.mak" CFG="BuildProbekitAgent32 - Win32 Debug" >+!MESSAGE >+!MESSAGE Possible choices for configuration are: >+!MESSAGE >+!MESSAGE "BuildProbekitAgent32 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") >+!MESSAGE "BuildProbekitAgent32 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") >+!MESSAGE >+!ERROR An invalid configuration is specified. >+!ENDIF >+ >+!IF "$(OS)" == "Windows_NT" >+NULL= >+!ELSE >+NULL=nul >+!ENDIF >+ >+CPP=cl.exe >+MTL=midl.exe >+RSC=rc.exe >+ >+!IF "$(CFG)" == "BuildProbekitAgent32 - Win32 Release" >+ >+OUTDIR=.\..\bin\windows\release\IA-32 >+INTDIR=.\release\IA-32\ProbekitAgent >+# Begin Custom Macros >+OutDir=.\..\bin\windows\release\IA-32 >+# End Custom Macros >+ >+ALL : "$(OUTDIR)\ProbekitAgent.dll" >+ >+ >+CLEAN : >+ -@erase "$(INTDIR)\b64.obj" >+ -@erase "$(INTDIR)\ClassFileLoadHookEvent.obj" >+ -@erase "$(INTDIR)\ECAttachEvent.obj" >+ -@erase "$(INTDIR)\ECDetachEvent.obj" >+ -@erase "$(INTDIR)\ECStartEvent.obj" >+ -@erase "$(INTDIR)\ECStopEvent.obj" >+ -@erase "$(INTDIR)\Globals.obj" >+ -@erase "$(INTDIR)\Instrumenter.obj" >+ -@erase "$(INTDIR)\InstrumenterFactory.obj" >+ -@erase "$(INTDIR)\ProbekitAgent.obj" >+ -@erase "$(INTDIR)\Util.obj" >+ -@erase "$(INTDIR)\vc60.idb" >+ -@erase "$(INTDIR)\VMInitEvent.obj" >+ -@erase "$(OUTDIR)\ProbekitAgent.dll" >+ -@erase "$(OUTDIR)\ProbekitAgent.exp" >+ -@erase "$(OUTDIR)\ProbekitAgent.lib" >+ >+"$(OUTDIR)" : >+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" >+ >+"$(INTDIR)" : >+ if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" >+ >+CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "./../src/Martini/Infrastructure/Include" /I "./../include/JPIAgent" /I "./../include/Martini" /I "./../src/BaseProf" /I "./../src/Martini/Include" /I "../../../org.eclipse.hyades.probekit/src-native" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BUILDPROBEKITAGENT32_EXPORTS" /D "IA32_ARCH" /Fp"$(INTDIR)\BuildProbekitAgent32.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c >+MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 >+BSC32=bscmake.exe >+BSC32_FLAGS=/nologo /o"$(OUTDIR)\BuildProbekitAgent32.bsc" >+BSC32_SBRS= \ >+ >+LINK32=link.exe >+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 LibraryLoader.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\ProbekitAgent.pdb" /machine:I386 /out:"$(OUTDIR)\ProbekitAgent.dll" /implib:"$(OUTDIR)\ProbekitAgent.lib" /libpath:"..\bin\windows\release\IA-32" >+LINK32_OBJS= \ >+ "$(INTDIR)\VMInitEvent.obj" \ >+ "$(INTDIR)\Util.obj" \ >+ "$(INTDIR)\ProbekitAgent.obj" \ >+ "$(INTDIR)\InstrumenterFactory.obj" \ >+ "$(INTDIR)\Instrumenter.obj" \ >+ "$(INTDIR)\Globals.obj" \ >+ "$(INTDIR)\ClassFileLoadHookEvent.obj" \ >+ "$(INTDIR)\b64.obj" \ >+ "$(INTDIR)\ECStopEvent.obj" \ >+ "$(INTDIR)\ECStartEvent.obj" \ >+ "$(INTDIR)\ECAttachEvent.obj" \ >+ "$(INTDIR)\ECDetachEvent.obj" >+ >+"$(OUTDIR)\ProbekitAgent.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) >+ $(LINK32) @<< >+ $(LINK32_FLAGS) $(LINK32_OBJS) >+<< >+ >+!ELSEIF "$(CFG)" == "BuildProbekitAgent32 - Win32 Debug" >+ >+OUTDIR=.\..\bin\windows\debug\IA-32 >+INTDIR=.\debug\IA-32\ProbekitAgent >+# Begin Custom Macros >+OutDir=.\..\bin\windows\debug\IA-32 >+# End Custom Macros >+ >+ALL : "$(OUTDIR)\ProbekitAgent.dll" >+ >+ >+CLEAN : >+ -@erase "$(INTDIR)\b64.obj" >+ -@erase "$(INTDIR)\ClassFileLoadHookEvent.obj" >+ -@erase "$(INTDIR)\ECAttachEvent.obj" >+ -@erase "$(INTDIR)\ECDetachEvent.obj" >+ -@erase "$(INTDIR)\ECStartEvent.obj" >+ -@erase "$(INTDIR)\ECStopEvent.obj" >+ -@erase "$(INTDIR)\Globals.obj" >+ -@erase "$(INTDIR)\Instrumenter.obj" >+ -@erase "$(INTDIR)\InstrumenterFactory.obj" >+ -@erase "$(INTDIR)\ProbekitAgent.obj" >+ -@erase "$(INTDIR)\Util.obj" >+ -@erase "$(INTDIR)\vc60.idb" >+ -@erase "$(INTDIR)\vc60.pdb" >+ -@erase "$(INTDIR)\VMInitEvent.obj" >+ -@erase "$(OUTDIR)\ProbekitAgent.dll" >+ -@erase "$(OUTDIR)\ProbekitAgent.exp" >+ -@erase "$(OUTDIR)\ProbekitAgent.lib" >+ -@erase "$(OUTDIR)\ProbekitAgent.pdb" >+ >+"$(OUTDIR)" : >+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" >+ >+"$(INTDIR)" : >+ if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" >+ >+CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "./../src/Martini/Infrastructure/Include" /I "./../include/JPIAgent" /I "./../include/Martini" /I "./../src/BaseProf" /I "./../src/Martini/Include" /I "../../../org.eclipse.hyades.probekit/src-native" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IA32_ARCH" /Fp"$(INTDIR)\BuildProbekitAgent32.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c >+MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 >+BSC32=bscmake.exe >+BSC32_FLAGS=/nologo /o"$(OUTDIR)\BuildProbekitAgent32.bsc" >+BSC32_SBRS= \ >+ >+LINK32=link.exe >+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib MartiniOSA.lib Ws2_32.lib LibraryLoader.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\ProbekitAgent.pdb" /debug /machine:I386 /out:"$(OUTDIR)\ProbekitAgent.dll" /implib:"$(OUTDIR)\ProbekitAgent.lib" /pdbtype:sept /libpath:"..\bin\windows\debug\IA-32" >+LINK32_OBJS= \ >+ "$(INTDIR)\VMInitEvent.obj" \ >+ "$(INTDIR)\Util.obj" \ >+ "$(INTDIR)\ProbekitAgent.obj" \ >+ "$(INTDIR)\InstrumenterFactory.obj" \ >+ "$(INTDIR)\Instrumenter.obj" \ >+ "$(INTDIR)\Globals.obj" \ >+ "$(INTDIR)\ClassFileLoadHookEvent.obj" \ >+ "$(INTDIR)\b64.obj" \ >+ "$(INTDIR)\ECStopEvent.obj" \ >+ "$(INTDIR)\ECStartEvent.obj" \ >+ "$(INTDIR)\ECAttachEvent.obj" \ >+ "$(INTDIR)\ECDetachEvent.obj" >+ >+"$(OUTDIR)\ProbekitAgent.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) >+ $(LINK32) @<< >+ $(LINK32_FLAGS) $(LINK32_OBJS) >+<< >+ >+!ENDIF >+ >+.c{$(INTDIR)}.obj:: >+ $(CPP) @<< >+ $(CPP_PROJ) $< >+<< >+ >+.cpp{$(INTDIR)}.obj:: >+ $(CPP) @<< >+ $(CPP_PROJ) $< >+<< >+ >+.cxx{$(INTDIR)}.obj:: >+ $(CPP) @<< >+ $(CPP_PROJ) $< >+<< >+ >+.c{$(INTDIR)}.sbr:: >+ $(CPP) @<< >+ $(CPP_PROJ) $< >+<< >+ >+.cpp{$(INTDIR)}.sbr:: >+ $(CPP) @<< >+ $(CPP_PROJ) $< >+<< >+ >+.cxx{$(INTDIR)}.sbr:: >+ $(CPP) @<< >+ $(CPP_PROJ) $< >+<< >+ >+ >+!IF "$(NO_EXTERNAL_DEPS)" != "1" >+!IF EXISTS("BuildProbekitAgent32.dep") >+!INCLUDE "BuildProbekitAgent32.dep" >+!ELSE >+!MESSAGE Warning: cannot find "BuildProbekitAgent32.dep" >+!ENDIF >+!ENDIF >+ >+ >+!IF "$(CFG)" == "BuildProbekitAgent32 - Win32 Release" || "$(CFG)" == "BuildProbekitAgent32 - Win32 Debug" >+SOURCE=..\src\ProbekitAgent\b64.c >+ >+"$(INTDIR)\b64.obj" : $(SOURCE) "$(INTDIR)" >+ $(CPP) $(CPP_PROJ) $(SOURCE) >+ >+ >+SOURCE=..\src\ProbekitAgent\ClassFileLoadHookEvent.cpp >+ >+"$(INTDIR)\ClassFileLoadHookEvent.obj" : $(SOURCE) "$(INTDIR)" >+ $(CPP) $(CPP_PROJ) $(SOURCE) >+ >+ >+SOURCE=..\src\ProbekitAgent\ECAttachEvent.cpp >+ >+"$(INTDIR)\ECAttachEvent.obj" : $(SOURCE) "$(INTDIR)" >+ $(CPP) $(CPP_PROJ) $(SOURCE) >+ >+ >+SOURCE=..\src\ProbekitAgent\ECDetachEvent.cpp >+ >+"$(INTDIR)\ECDetachEvent.obj" : $(SOURCE) "$(INTDIR)" >+ $(CPP) $(CPP_PROJ) $(SOURCE) >+ >+ >+SOURCE=..\src\ProbekitAgent\ECStartEvent.cpp >+ >+"$(INTDIR)\ECStartEvent.obj" : $(SOURCE) "$(INTDIR)" >+ $(CPP) $(CPP_PROJ) $(SOURCE) >+ >+ >+SOURCE=..\src\ProbekitAgent\ECStopEvent.cpp >+ >+"$(INTDIR)\ECStopEvent.obj" : $(SOURCE) "$(INTDIR)" >+ $(CPP) $(CPP_PROJ) $(SOURCE) >+ >+ >+SOURCE=..\src\ProbekitAgent\Globals.cpp >+ >+"$(INTDIR)\Globals.obj" : $(SOURCE) "$(INTDIR)" >+ $(CPP) $(CPP_PROJ) $(SOURCE) >+ >+ >+SOURCE=..\src\ProbekitAgent\Instrumenter.cpp >+ >+"$(INTDIR)\Instrumenter.obj" : $(SOURCE) "$(INTDIR)" >+ $(CPP) $(CPP_PROJ) $(SOURCE) >+ >+ >+SOURCE=..\src\ProbekitAgent\InstrumenterFactory.cpp >+ >+"$(INTDIR)\InstrumenterFactory.obj" : $(SOURCE) "$(INTDIR)" >+ $(CPP) $(CPP_PROJ) $(SOURCE) >+ >+ >+SOURCE=..\src\ProbekitAgent\ProbekitAgent.cpp >+ >+"$(INTDIR)\ProbekitAgent.obj" : $(SOURCE) "$(INTDIR)" >+ $(CPP) $(CPP_PROJ) $(SOURCE) >+ >+ >+SOURCE=..\src\ProbekitAgent\Util.cpp >+ >+"$(INTDIR)\Util.obj" : $(SOURCE) "$(INTDIR)" >+ $(CPP) $(CPP_PROJ) $(SOURCE) >+ >+ >+SOURCE=..\src\ProbekitAgent\VMInitEvent.cpp >+ >+"$(INTDIR)\VMInitEvent.obj" : $(SOURCE) "$(INTDIR)" >+ $(CPP) $(CPP_PROJ) $(SOURCE) >+ >+ >+ >+!ENDIF >+ >Index: src-native/src/ProbekitAgent/b64test.cpp >=================================================================== >RCS file: src-native/src/ProbekitAgent/b64test.cpp >diff -N src-native/src/ProbekitAgent/b64test.cpp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/b64test.cpp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+#include "tptp/TPTPUtils.h" >+#include <stdio.h> >+#include <string.h> >+#include <malloc.h> >+#include <assert.h> >+ >+char buff[] = >+"3srswAAAAA1tLnByb2Jlc2NyaXB0AAAAblJFTSB1bm5hbWVkX3Byb2JlClBST0JFClJVTEUgKiBK\n" >+"VGVzdCAqICogaW5jbHVkZQpSVUxFICogKiAqICogZXhjbHVkZQpSRUYgT05FTlRSWSBtX3Byb2Jl\n" >+"JFByb2JlXzAgX2VudHJ5ICgpViAKAAAAB21fcHJvYmUAAAD+yv66vgAAADEAEQoAAwANBwAOBwAP\n" >+"BwAQAQAHUHJvYmVfMAEADElubmVyQ2xhc3NlcwEABjxpbml0PgEAAygpVgEABENvZGUBAA9MaW5l\n" >+"TnVtYmVyVGFibGUBAApTb3VyY2VGaWxlAQAMbV9wcm9iZS5qYXZhDAAHAAgBAAdtX3Byb2JlAQAQ\n" >+"amF2YS9sYW5nL09iamVjdAEAD21fcHJvYmUkUHJvYmVfMAAgAAIAAwAAAAAAAQAAAAcACAABAAkA\n" >+"AAAhAAEAAQAAAAUqtwABsQAAAAEACgAAAAoAAgAAAAcABAAJAAIACwAAAAIADAAGAAAACgABAAQA\n" >+"AgAFAAkAAAAPbV9wcm9iZSRQcm9iZV8wAAAB0cr+ur4AAAAxACAKAAYADgkADwAQCAARCgASABMH\n" >+"ABUHABgBAAY8aW5pdD4BAAMoKVYBAARDb2RlAQAPTGluZU51bWJlclRhYmxlAQAGX2VudHJ5AQAK\n" >+"U291cmNlRmlsZQEADG1fcHJvYmUuamF2YQwABwAIBwAZDAAaABsBABJIZWxsbyBmcm9tIHByb2Jl\n" >+"IQoHABwMAB0AHgcAHwEAD21fcHJvYmUkUHJvYmVfMAEAB1Byb2JlXzABAAxJbm5lckNsYXNzZXMB\n" >+"ABBqYXZhL2xhbmcvT2JqZWN0AQAQamF2YS9sYW5nL1N5c3RlbQEAA291dAEAFUxqYXZhL2lvL1By\n" >+"aW50U3RyZWFtOwEAE2phdmEvaW8vUHJpbnRTdHJlYW0BAAdwcmludGxuAQAVKExqYXZhL2xhbmcv\n" >+"U3RyaW5nOylWAQAHbV9wcm9iZQAhAAUABgAAAAAAAgABAAcACAABAAkAAAAdAAEAAQAAAAUqtwAB\n" >+"sQAAAAEACgAAAAYAAQAAAAkACQALAAgAAQAJAAAAJQACAAAAAAAJsgACEgO2AASxAAAAAQAKAAAA\n" >+"CgACAAAADgAIABAAAgAMAAAAAgANABcAAAAKAAEABQAUABYACQ=="; >+ >+ >+int main() >+{ >+ int len = strlen( buff ); >+ >+ char* out = (char*)malloc( len ); >+ int decoded = >+ tptp_decodeBase64( (tptp_string*)buff, len, (unsigned char*)out, len ); >+ >+ printf("base64 len = %d, decoded: %d\n", len, decoded ); >+ >+ assert( decoded == 892 ); >+ //fwrite( out, decoded, 1, stdout ); >+ >+ return 0; >+ >+} >Index: src-native/src/ProbekitAgent/Util.cpp >=================================================================== >RCS file: src-native/src/ProbekitAgent/Util.cpp >diff -N src-native/src/ProbekitAgent/Util.cpp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/Util.cpp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,137 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#include "Util.h" >+#include "ProbekitAgent.h" >+ >+#include <log.h> >+ >+#ifdef _UNIX_ >+#define FILE_SEPARATOR '/' >+#else >+#define FILE_SEPARATOR '\\' >+#endif >+ >+// tmp - use b64.c until tptp_decodeBase64() starts working >+extern "C" int decode_buffer( const char* inBuffer, int inLen, char* outBuffer); >+ >+namespace Martini { namespace ProbekitAgent { namespace Util { >+ >+void DumpBuffer( const char* dir, const char* fileName, >+ const char* buffer, int len ) >+{ >+ if( dir ) { >+ char* fileNameClean = strdup( fileName ); >+ >+ // replace all slashes >+ char* p = fileNameClean; >+ while( *p ) { >+ if( *p == FILE_SEPARATOR ) *p = '_'; >+ p++; >+ } >+ >+ char* path = (char*)malloc( strlen(dir) + strlen(fileName) + 16 ); >+ sprintf( path, "%s%c%s.dump", dir, FILE_SEPARATOR, fileNameClean ); >+ >+ FILE* handle = fopen( path, "wb+" ); >+ if( handle == 0 ) { >+ LOG_ERROR( PROFILER_NAME " can't create dump file " << path ); >+ free( path ); >+ return; >+ } >+ fwrite( buffer, len, 1, handle ); >+ fclose( handle ); >+ >+ free( fileNameClean ); >+ free( path ); >+ } >+} >+ >+// caller must free result >+void ReadFile( const char* fname, char*& result, int& resultLen ) >+{ >+ resultLen = 0; >+ >+ FILE* handle = fopen( fname, "r" ); >+ if( handle == 0 ) { >+ LOG_ERROR( PROFILER_NAME " can't open " << fname ); >+ return; >+ } >+ >+ fseek(handle, 0L, SEEK_END); >+ long len = ftell( handle ); >+ LOG_TRACE( PROFILER_NAME " length of probescript file is " << len ); >+ if( len < 1 ) { >+ fclose( handle ); >+ return; >+ } >+ fseek(handle, 0L, SEEK_SET); >+ >+ result = (char*)malloc( len + 1 ); >+ resultLen = fread( result, 1, len, handle ); >+ LOG_TRACE( PROFILER_NAME " read " << resultLen ); >+ result[ resultLen ] = 0; >+ >+ // remove >+ char* ptr = result; >+ while( *ptr ) { >+ if( *ptr == '\n') { >+ *ptr = 0; >+ } >+ ptr++; >+ } >+ >+ fclose( handle ); >+ return; >+} >+ >+ >+#define CMDLINE_PARAM_NAME_SEPARATOR '=' >+#define CMDLINE_PARAM_SEPARATOR ',' >+ >+// caller must free result >+char* GetCmdlineOption( const char* options, const char* name ) >+{ >+ char* result = NULL; >+ const char* p0 = strstr( options, name ); >+ if( p0 ) { >+ p0 = strchr( p0, CMDLINE_PARAM_NAME_SEPARATOR ); >+ if( p0 && *(++p0) ) { >+ const char* p1 = strchr( p0, CMDLINE_PARAM_SEPARATOR ); >+ int len = p1 ? (p1 - p0) : strlen(p0); >+ result = (char*)malloc( len + 1 ); >+ strncpy( result, p0, len ); >+ result[ len ] = 0; >+ } >+ } >+ >+ return result; >+} >+// tmp - use b64.c until tptp_decodeBase64() starts working >+int DecodeBuffer( const char* inBuffer, int inLen, char* outBuffer) >+{ >+ return decode_buffer( inBuffer, inLen, outBuffer ); >+} >+ >+char* StrNDup( const char* src, int len ) >+{ >+ char* dst = (char*)malloc( len + 1 ); >+ if( dst == 0 ) { >+ return 0; >+ } >+ memcpy( dst, src, len ); >+ dst[ len ] = 0; >+ return dst; >+} >+ >+} /*namespace Martini*/ } /*namespace ProbekitAgent*/ } /*namespace Util*/ >Index: src-native/src/ProbekitAgent/ProbekitAgent.cpp >=================================================================== >RCS file: src-native/src/ProbekitAgent/ProbekitAgent.cpp >diff -N src-native/src/ProbekitAgent/ProbekitAgent.cpp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/ProbekitAgent.cpp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,219 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#include "ProbekitAgent.h" >+#include "InstrumenterFactory.h" >+#include "Instrumenter.h" >+ >+// Martini >+#include "LibraryLoader.h" >+#include "log.h" >+ >+using namespace Martini; >+using namespace Martini::MPI; >+using namespace Martini::OSA; >+using namespace Martini::JPIAgent; >+using namespace Martini::ProbekitAgent; >+ >+using namespace std; >+ >+static Martini::ProbekitAgent::CProbekitAgent probekitAgent; >+ >+///////////////////////////////////////////////////////////////// >+ >+Martini::OSA::IThreadSync* lockObject = Martini::OSA::CreateThreadSync(); >+ >+///////////////////////////////////////////////////////////////// >+ >+ >+/* >+ * MPICL_Instantiate - The profiler initialization method. >+ * The profiler initializes itself and registers for MPI events >+ */ >+extern "C" API_EXPORT TResult >+MPICL_Instantiate(IMpi *pMpiApi, TId clientId, const char *szOptions) >+{ >+ LOG_TRACE(PROFILER_NAME " MPICL_Instantiate"); >+ >+ LOG_ASSERT(pMpiApi != 0); >+ LOG_ASSERT(clientId != 0); >+ >+ TResult retVal = probekitAgent.Init(pMpiApi, clientId, szOptions); >+ if (MRTE_FAILED(retVal)) >+ { >+ return MRTE_ERROR_FAIL; >+ } >+ >+ IInstrumenter* instrumenter = >+ CInstrumenterFactory::getInstrumenter(); >+ if( instrumenter ) { >+ retVal = instrumenter->Initialize(szOptions); >+ } else { >+ >+ LOG_ERROR( "Can't create instrumenter" ); >+ retVal = MRTE_ERROR_FAIL; >+ >+ } >+ LOG_TRACE(PROFILER_NAME " MPICL_Instantiate done"); >+ return retVal; >+} >+ >+//======================================================================================= >+ >+CProbekitAgent* CProbekitAgent::getInstance() >+{ >+ return &probekitAgent; >+} >+ >+CProbekitAgent::CProbekitAgent() >+ : ec_env( NULL ) >+{ >+} >+ >+CProbekitAgent::~CProbekitAgent() >+{ >+} >+ >+/* >+ * InitEvents - initialize object event - register events >+ */ >+ >+TResult CProbekitAgent::Init(MPI::IMpi *pMpiApi, MPI::TId clientId, >+ const char *szOptions) >+{ >+ TResult retVal; >+ >+ m_pMpiApi = pMpiApi; >+ m_clientId = clientId; >+ >+ retVal = InitEC(); >+ if (MRTE_FAILED(retVal)) >+ { >+ LOG_ERROR( PROFILER_NAME " error initializing EC"); >+ return retVal; >+ } >+ >+ retVal = InitEvents(); >+ if (MRTE_FAILED(retVal)) >+ { >+ LOG_ERROR( PROFILER_NAME " error registering events"); >+ return retVal; >+ } >+ >+ retVal = BindJpiFunctions(); >+ if (MRTE_FAILED(retVal)) >+ { >+ LOG_ERROR( PROFILER_NAME " failed to bind JPI exported functions"); >+ } >+ >+ return retVal; >+} >+ >+/* >+ * InitEvents - initialize object event - register events >+ */ >+TResult CProbekitAgent::InitEvents() >+{ >+ TResult retVal; >+ >+ // EC stop event; Martini RT will sleep >+ // in this event initialization >+ retVal = m_ECAttachHandler.Init(m_pMpiApi, m_clientId); >+ if (MRTE_FAILED(retVal)) >+ { >+ return retVal; >+ } >+ >+ retVal = m_ECDetachHandler.Init(m_pMpiApi, m_clientId); >+ if (MRTE_FAILED(retVal)) >+ { >+ return retVal; >+ } >+ >+ retVal = m_ECStartHandler.Init(m_pMpiApi, m_clientId); >+ if (MRTE_FAILED(retVal)) >+ { >+ return retVal; >+ } >+ >+ retVal = m_ECStopHandler.Init(m_pMpiApi, m_clientId); >+ if (MRTE_FAILED(retVal)) >+ { >+ return retVal; >+ } >+ >+ retVal = m_ClassFileLoadHookHandler.Init(m_pMpiApi, m_clientId); >+ if (MRTE_FAILED(retVal)) >+ { >+ return retVal; >+ } >+ >+ retVal = m_VMInitHandler.Init(m_pMpiApi, m_clientId); >+ if (MRTE_FAILED(retVal)) >+ { >+ return retVal; >+ } >+ >+ return MRTE_RESULT_OK; >+} >+ >+/* >+ * BindJpiFunctions - bind required exported JPI functions >+ */ >+TResult CProbekitAgent::BindJpiFunctions() >+{ >+ ILibraryLoader *pJpiLoader = LoadBistroLibrary("JPI"); >+ if (!pJpiLoader) >+ { >+ return MRTE_ERROR_FAIL; >+ } >+ >+ CGlobals::Instance()->pfnJPI_AttachCurrentThread = >+ (TJpiAttachCurrentThread)pJpiLoader->GetEntry("JPI_AttachCurrentThread"); >+ if (!CGlobals::Instance()->pfnJPI_AttachCurrentThread) >+ { >+ return MRTE_ERROR_FAIL; >+ } >+ >+ CGlobals::Instance()->pfnJPI_DetachCurrentThread = >+ (TJpiDetachCurrentThread)pJpiLoader->GetEntry("JPI_DetachCurrentThread"); >+ if (!CGlobals::Instance()->pfnJPI_DetachCurrentThread) >+ { >+ return MRTE_ERROR_FAIL; >+ } >+ >+ pJpiLoader->Destroy(); >+ >+ return MRTE_RESULT_OK; >+} >+ >+TResult CProbekitAgent::InitEC() >+{ >+ LOG_TRACE( PROFILER_NAME " InitEC"); >+ >+ Martini::OSA::ILibraryLoader* libraryLoader; >+ libraryLoader = CreateLibraryLoader("JPIAgent", 0); >+ if (libraryLoader == 0) { >+ return MRTE_ERROR_OSA_FAILURE; >+ } >+ GetEC_Env_t ecpEnv = (GetEC_Env_t)(libraryLoader->GetEntry("GetEC_Env")); >+ if (ecpEnv == 0) { >+ return MRTE_ERROR_OSA_FAILURE; >+ } >+ >+ (*ecpEnv)(PROFILER_NAME, &ec_env); >+ >+ libraryLoader->Destroy(); >+ >+ return MRTE_RESULT_OK; >+} >Index: src-native/build/BuildProbekitAgent32.dsp >=================================================================== >RCS file: src-native/build/BuildProbekitAgent32.dsp >diff -N src-native/build/BuildProbekitAgent32.dsp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/build/BuildProbekitAgent32.dsp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,195 @@ >+# Microsoft Developer Studio Project File - Name="BuildProbekitAgent32" - Package Owner=<4> >+# Microsoft Developer Studio Generated Build File, Format Version 6.00 >+# ** DO NOT EDIT ** >+ >+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 >+ >+CFG=BuildProbekitAgent32 - Win32 Debug >+!MESSAGE This is not a valid makefile. To build this project using NMAKE, >+!MESSAGE use the Export Makefile command and run >+!MESSAGE >+!MESSAGE NMAKE /f "BuildProbekitAgent32.mak". >+!MESSAGE >+!MESSAGE You can specify a configuration when running NMAKE >+!MESSAGE by defining the macro CFG on the command line. For example: >+!MESSAGE >+!MESSAGE NMAKE /f "BuildProbekitAgent32.mak" CFG="BuildProbekitAgent32 - Win32 Debug" >+!MESSAGE >+!MESSAGE Possible choices for configuration are: >+!MESSAGE >+!MESSAGE "BuildProbekitAgent32 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") >+!MESSAGE "BuildProbekitAgent32 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") >+!MESSAGE >+ >+# Begin Project >+# PROP AllowPerConfigDependencies 0 >+# PROP Scc_ProjName "" >+# PROP Scc_LocalPath "" >+CPP=cl.exe >+MTL=midl.exe >+RSC=rc.exe >+ >+!IF "$(CFG)" == "BuildProbekitAgent32 - Win32 Release" >+ >+# PROP BASE Use_MFC 0 >+# PROP BASE Use_Debug_Libraries 0 >+# PROP BASE Output_Dir "Release" >+# PROP BASE Intermediate_Dir "Release" >+# PROP BASE Target_Dir "" >+# PROP Use_MFC 0 >+# PROP Use_Debug_Libraries 0 >+# PROP Output_Dir "..\bin\windows\release\IA-32" >+# PROP Intermediate_Dir "release\IA-32\ProbekitAgent" >+# PROP Ignore_Export_Lib 0 >+# PROP Target_Dir "" >+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BUILDPROBEKITAGENT32_EXPORTS" /YX /FD /c >+# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "./../src/Martini/Infrastructure/Include" /I "./../include/JPIAgent" /I "./../include/Martini" /I "./../src/BaseProf" /I "./../src/Martini/Include" /I "../../../org.eclipse.hyades.probekit/src-native" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BUILDPROBEKITAGENT32_EXPORTS" /D "IA32_ARCH" /YX /FD /c >+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 >+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 >+# ADD BASE RSC /l 0x409 /d "NDEBUG" >+# ADD RSC /l 0x409 /d "NDEBUG" >+BSC32=bscmake.exe >+# ADD BASE BSC32 /nologo >+# ADD BSC32 /nologo >+LINK32=link.exe >+# 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 >+# 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 LibraryLoader.lib /nologo /dll /machine:I386 /out:"..\bin\windows\release\IA-32\ProbekitAgent.dll" /libpath:"..\bin\windows\release\IA-32" >+ >+!ELSEIF "$(CFG)" == "BuildProbekitAgent32 - Win32 Debug" >+ >+# PROP BASE Use_MFC 0 >+# PROP BASE Use_Debug_Libraries 1 >+# PROP BASE Output_Dir "BuildProbekitAgent32___Win32_Debug" >+# PROP BASE Intermediate_Dir "BuildProbekitAgent32___Win32_Debug" >+# PROP BASE Target_Dir "" >+# PROP Use_MFC 0 >+# PROP Use_Debug_Libraries 1 >+# PROP Output_Dir "..\bin\windows\debug\IA-32" >+# PROP Intermediate_Dir "debug\IA-32\ProbekitAgent" >+# PROP Ignore_Export_Lib 0 >+# PROP Target_Dir "" >+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BUILDPROBEKITAGENT32_EXPORTS" /YX /FD /GZ /c >+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "./../src/Martini/Infrastructure/Include" /I "./../include/JPIAgent" /I "./../include/Martini" /I "./../src/BaseProf" /I "./../src/Martini/Include" /I "../../../org.eclipse.hyades.probekit/src-native" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IA32_ARCH" /YX /FD /GZ /c >+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 >+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 >+# ADD BASE RSC /l 0x409 /d "_DEBUG" >+# ADD RSC /l 0x409 /d "_DEBUG" >+BSC32=bscmake.exe >+# ADD BASE BSC32 /nologo >+# ADD BSC32 /nologo >+LINK32=link.exe >+# 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 >+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib MartiniOSA.lib Ws2_32.lib LibraryLoader.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"..\bin\windows\debug\IA-32\ProbekitAgent.dll" /pdbtype:sept /libpath:"..\bin\windows\debug\IA-32" >+ >+!ENDIF >+ >+# Begin Target >+ >+# Name "BuildProbekitAgent32 - Win32 Release" >+# Name "BuildProbekitAgent32 - Win32 Debug" >+# Begin Group "Source Files" >+ >+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\b64.c >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\ClassFileLoadHookEvent.cpp >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\ECAttachEvent.cpp >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\ECDetachEvent.cpp >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\ECStartEvent.cpp >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\ECStopEvent.cpp >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\Globals.cpp >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\Instrumenter.cpp >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\InstrumenterFactory.cpp >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\ProbekitAgent.cpp >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\Util.cpp >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\VMInitEvent.cpp >+# End Source File >+# End Group >+# Begin Group "Header Files" >+ >+# PROP Default_Filter "h;hpp;hxx;hm;inl" >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\ClassFileLoadHookEvent.h >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\ECAttachEvent.h >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\ECDetachEvent.h >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\ECStartEvent.h >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\ECStopEvent.h >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\Globals.h >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\Instrumenter.h >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\InstrumenterFactory.h >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\ProbekitAgent.h >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\Util.h >+# End Source File >+# Begin Source File >+ >+SOURCE=..\src\ProbekitAgent\VMInitEvent.h >+# End Source File >+# End Group >+# Begin Group "Resource Files" >+ >+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" >+# End Group >+# End Target >+# End Project >Index: src-native/src/ProbekitAgent/Makefile >=================================================================== >RCS file: src-native/src/ProbekitAgent/Makefile >diff -N src-native/src/ProbekitAgent/Makefile >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/Makefile 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,62 @@ >+#/************************************************************************ >+# * Copyright (c) 2007 OC Systems Inc. >+# * All rights reserved. This program and the accompanying materials >+# * are made available under the terms of the Eclipse Public License v1.0 >+# * which accompanies this distribution, and is available at >+# * http://www.eclipse.org/legal/epl-v10.html >+# * >+# * Contributors: >+# * Vsevolod Sandomirskiy, OC Systems - Probekit support >+# * >+# * $Id:$ >+# ************************************************************************/ >+ >+ROOTDIR = ../.. >+ >+include $(ROOTDIR)/src/makefile.inc >+ >+INCLUDES = -I ../../include/JPIAgent \ >+ -I ../../include/Martini \ >+ -I ../../src/BaseProf \ >+ -I ../../src/Martini/Include \ >+ -I ../../src/Martini/Infrastructure/Include \ >+ -I ../../../../org.eclipse.hyades.probekit/src-native \ >+ -I $(TPTP_ACSDK_HOME)/include \ >+ -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux >+ >+OBJS = \ >+ $(OBJDIR)/b64.o \ >+ $(OBJDIR)/ProbekitAgent.o \ >+ $(OBJDIR)/InstrumenterFactory.o \ >+ $(OBJDIR)/Instrumenter.o \ >+ $(OBJDIR)/ClassFileLoadHookEvent.o \ >+ $(OBJDIR)/VMInitEvent.o \ >+ $(OBJDIR)/Globals.o \ >+ $(OBJDIR)/ECAttachEvent.o \ >+ $(OBJDIR)/ECDetachEvent.o \ >+ $(OBJDIR)/ECStartEvent.o \ >+ $(OBJDIR)/ECStopEvent.o \ >+ $(OBJDIR)/Util.o >+ >+LIB = libProbekitAgent.so >+ >+VER_FILE = ProbekitAgent.ver >+ >+all: release >+ >+release: $(OBJDIR) $(OUTDIR)/$(LIB) >+ >+$(OBJDIR): >+ mkdir -p $(OBJDIR) ; mkdir -p $(OUTDIR) >+ >+clean: >+ rm -rf $(OBJS) $(OUTDIR)/$(LIB) >+ >+include ./Makefile.dep >+ >+$(OUTDIR)/$(LIB): $(OBJS) >+ $(CPP_LINK) $(OBJS) -Wall -o $@ -L../../bin/linux/release/IA-32 -L$(OUTDIR) -lMartiniOSA \ >+ ../../bin/linux/release/IA-32/LibraryLoader.a \ >+ -L $(TPTP_ACSDK_HOME)/lib -ltptpUtils \ >+ -lpthread -ldl $(STD_LIBS) $(VER_SCR) >+ >Index: src-native/src/ProbekitAgent/VMInitEvent.h >=================================================================== >RCS file: src-native/src/ProbekitAgent/VMInitEvent.h >diff -N src-native/src/ProbekitAgent/VMInitEvent.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/VMInitEvent.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,45 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#ifndef PROBEKIT_VM_INIT_H >+#define PROBEKIT_VM_INIT_H >+ >+#include "MpiAPI.h" >+ >+namespace Martini { namespace ProbekitAgent { >+ >+ // CVMInitEvent - represents a VM init event >+ class CVMInitEvent : public MPI::IVmInitEventObserver >+ { >+ public: >+ CVMInitEvent(); >+ ~CVMInitEvent(); >+ >+ // Initialization - Register to event >+ TResult Init(MPI::IMpi *pMpiApi, MPI::TId clientId); >+ >+ // Event handler >+ void HandleEvent(MPI::SVmInitEventData &data); >+ >+ private: >+ // Pointer to the MPI implementation >+ MPI::IMpi *m_pMpiApi; >+ >+ // Client id for MPI requests >+ MPI::TId m_clientId; >+ }; >+ >+} /*namespace Martini*/ } /*namespace ProbekitAgent*/ >+ >+#endif // PROBEKIT_VM_INIT_H >+ >Index: src-native/src/ProbekitAgent/Globals.cpp >=================================================================== >RCS file: src-native/src/ProbekitAgent/Globals.cpp >diff -N src-native/src/ProbekitAgent/Globals.cpp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/Globals.cpp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,16 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#include "Globals.h" >+ >+Martini::ProbekitAgent::CGlobals* Martini::ProbekitAgent::CGlobals::s_pInstance = 0; >Index: src-native/src/ProbekitAgent/ECStopEvent.h >=================================================================== >RCS file: src-native/src/ProbekitAgent/ECStopEvent.h >diff -N src-native/src/ProbekitAgent/ECStopEvent.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/ECStopEvent.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#ifndef PROBEKIT_ECStop_EVENT_H_ >+#define PROBEKIT_ECStop_EVENT_H_ >+ >+#include "MpiAPI.h" >+ >+namespace Martini { namespace ProbekitAgent { >+ >+ // CStopEvent - represents a Stop event >+ class CECStopEvent : public MPI::IEcStopEventObserver >+ { >+ public: >+ // Constructor >+ CECStopEvent(); >+ // Destructor >+ ~CECStopEvent(); >+ >+ // Initialization - Register to event >+ TResult Init(MPI::IMpi *pMpiApi, MPI::TId clientId); >+ // Inherited methods >+ void HandleEvent(); >+ }; >+ >+} /*namespace Martini*/ } /*namespace ProbekitAgent*/ >+ >+#endif // PROBEKIT_ECStop_EVENT_H_ >Index: src-native/src/ProbekitAgent/README >=================================================================== >RCS file: src-native/src/ProbekitAgent/README >diff -N src-native/src/ProbekitAgent/README >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/README 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+ProbekitAgent implements load-time instrumentation using the old >+TPTP BCI engine. >+ >+Invocation: >+ >+#java -cp ".;C:\Documents and Settings\Vsevolod\Desktop\tptp\probe" "-agentlib:JPIBootLoader=JPIAgent:server=standalone;ProbekitAgent:ext-pk-BCILibraryName=BCIEngProbe,ext-pk-probescript=..\..\probe\m.probescript" JTest >+ >+#java "-agentlib:JPIBootLoader=JPIAgent:server=controlled;ProbekitAgent" JTest >+ >+Command line parameters: >+ >+ext-pk-BCILibraryName >+ optional; specifies base name of BCI library, >+ default value "BCIEngProbe" >+ext-pk-probescript >+ optional; standalone mode; specifies >+ .probescript file >+ext-pk-dump >+ optional; specifies location to write temporary dump files >+ >+Built and tested on linux x86 and windows ia32. >+ >+ >+ >Index: src-native/src/ProbekitAgent/Util.h >=================================================================== >RCS file: src-native/src/ProbekitAgent/Util.h >diff -N src-native/src/ProbekitAgent/Util.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/Util.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#ifndef _PROBEKIT_UTIL_H >+#define _PROBEKIT_UTIL_H >+ >+#define PROFILER_NAME "PROBEKIT" >+ >+namespace Martini { namespace ProbekitAgent { namespace Util { >+ >+ // Dump buffer to location specified by dir; >+ // Do nothing if the location is null. >+ void DumpBuffer( const char* dir, const char* fileName, >+ const char* buffer, int len ); >+ >+ // Read file into a buffer; caller must free result >+ void ReadFile( const char* fname, char*& result, int& resultLen ); >+ >+ // parse options, look for specified name >+ char* GetCmdlineOption( const char* options, const char* name ); >+ >+ // return decoded length >+ int DecodeBuffer( const char* inBuffer, int inLen, char* outBuffer); >+ >+ // malloc a new string, strcpy len bytes, add zero >+ char* StrNDup( const char* src, int len ); >+ >+} /*namespace Martini*/ } /*namespace ProbekitAgent*/ } /*namespace Util*/ >+ >+#endif // _PROBEKIT_UTIL_H >Index: src-native/src/ProbekitAgent/Globals.h >=================================================================== >RCS file: src-native/src/ProbekitAgent/Globals.h >diff -N src-native/src/ProbekitAgent/Globals.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/Globals.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#ifndef PROBEKIT_GLOBALS_H >+#define PROBEKIT_GLOBALS_H >+ >+#include "JPI.H" >+ >+#define PROFILER_NAME "PROBEKIT" >+ >+namespace Martini { namespace ProbekitAgent { >+ >+ class CGlobals >+ { >+ public: >+ static CGlobals* Instance() >+ { >+ if (0 == s_pInstance) >+ { >+ s_pInstance = new CGlobals(); >+ } >+ return s_pInstance; >+ } >+ >+ TJpiAttachCurrentThread pfnJPI_AttachCurrentThread; >+ TJpiDetachCurrentThread pfnJPI_DetachCurrentThread; >+ >+ bool m_VMInitSeen; >+ >+ protected: >+ static CGlobals* s_pInstance; >+ >+ CGlobals(): >+ pfnJPI_AttachCurrentThread(0), pfnJPI_DetachCurrentThread(0), >+ m_VMInitSeen(false) >+ {} >+ >+ }; >+}} >+#endif // PROBEKIT_GLOBALS_H >+ >Index: src-native/src/ProbekitAgent/ECDetachEvent.cpp >=================================================================== >RCS file: src-native/src/ProbekitAgent/ECDetachEvent.cpp >diff -N src-native/src/ProbekitAgent/ECDetachEvent.cpp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/ECDetachEvent.cpp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#include "ECDetachEvent.h" >+#include "Globals.h" >+#include <log.h> >+ >+using namespace Martini::ProbekitAgent; >+using namespace Martini::MPI; >+ >+CECDetachEvent::CECDetachEvent(){} >+ >+CECDetachEvent::~CECDetachEvent(){} >+ >+TResult CECDetachEvent::Init(IMpi *pMpiApi, TId clientId) >+{ >+ TResult res = pMpiApi->RegisterEvent(clientId, *this); >+ return res; >+} >+ >+/* >+ * HandleEvent - callback function >+ */ >+void CECDetachEvent::HandleEvent() >+{ >+ LOG_TRACE( PROFILER_NAME " EC Detach" ); >+} >Index: src-native/src/ProbekitAgent/ECAttachEvent.cpp >=================================================================== >RCS file: src-native/src/ProbekitAgent/ECAttachEvent.cpp >diff -N src-native/src/ProbekitAgent/ECAttachEvent.cpp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/ECAttachEvent.cpp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#include "ECAttachEvent.h" >+#include "Globals.h" >+#include <log.h> >+ >+using namespace Martini::ProbekitAgent; >+using namespace Martini::MPI; >+ >+CECAttachEvent::CECAttachEvent(){} >+ >+CECAttachEvent::~CECAttachEvent(){} >+ >+/* >+ * Init - initializes internal data and registers for VM init event >+ */ >+TResult CECAttachEvent::Init(IMpi *pMpiApi, TId clientId) >+{ >+ TResult res = pMpiApi->RegisterEvent(clientId, *this); >+ return res; >+} >+ >+/* >+ * HandleEvent - callback function >+ */ >+void CECAttachEvent::HandleEvent() >+{ >+ LOG_TRACE( PROFILER_NAME " EC Attach" ); >+} >Index: src-native/src/ProbekitAgent/ProbekitAgent.h >=================================================================== >RCS file: src-native/src/ProbekitAgent/ProbekitAgent.h >diff -N src-native/src/ProbekitAgent/ProbekitAgent.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/ProbekitAgent.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,84 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#ifndef _PROBEKIT_AGENT_H >+#define _PROBEKIT_AGENT_H >+ >+#include "MpiAPI.h" >+#include "OSA.h" >+#include "MRTEResults.h" >+ >+#include "VMInitEvent.h" >+#include "ECAttachEvent.h" >+#include "ECDetachEvent.h" >+#include "ECStartEvent.h" >+#include "ECStopEvent.h" >+#include "ClassFileLoadHookEvent.h" >+#include "Globals.h" >+#include "EC_Env.h" >+ >+namespace Martini { namespace ProbekitAgent { >+ >+ class CProbekitAgent //: public BaseProf::CBaseProfiler >+ { >+ public: >+ CProbekitAgent(); >+ virtual ~CProbekitAgent(); >+ >+ static CProbekitAgent* getInstance(); >+ >+ TResult Init(MPI::IMpi *pMpiApi, MPI::TId clientId, const char *szOptions); >+ >+ JPIAgent::EC_Env* getEC() >+ { return ec_env; } >+ >+ private: >+ >+ // Initializes internal data and registers for VM shutdown event >+ TResult InitEvents(); >+ >+ // Bind required JPI exported functions >+ TResult BindJpiFunctions(); >+ >+ // Initialize EC environment >+ TResult InitEC(); >+ >+ private: >+ >+ // VM init event object >+ CVMInitEvent m_VMInitHandler; >+ >+ // the agent doesn't use EC events but they seem >+ // necessary to make Martini RT sleep in controlled mode. >+ >+ CECAttachEvent m_ECAttachHandler; >+ CECDetachEvent m_ECDetachHandler; >+ CECStartEvent m_ECStartHandler; >+ CECStopEvent m_ECStopHandler; >+ >+ // Class File Load Hook event object >+ CClassFileLoadHookEvent m_ClassFileLoadHookHandler; >+ >+ // EC environment >+ JPIAgent::EC_Env* ec_env; >+ >+ // Pointer to the MPI implementation >+ MPI::IMpi* m_pMpiApi; >+ >+ // Client id for MPI requests >+ MPI::TId m_clientId; >+ }; >+ >+} /*namespace Martini*/ } /*namespace ProbekitAgent*/ >+ >+#endif // _PROBEKIT_AGENT_H >Index: src-native/src/ProbekitAgent/ECAttachEvent.h >=================================================================== >RCS file: src-native/src/ProbekitAgent/ECAttachEvent.h >diff -N src-native/src/ProbekitAgent/ECAttachEvent.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/ECAttachEvent.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#ifndef PROBEKIT_EC_ATTACH_EVENT_H >+#define PROBEKIT_EC_ATTACH_EVENT_H >+ >+#include "MpiAPI.h" >+ >+namespace Martini { namespace ProbekitAgent { >+ >+ class CECAttachEvent : public MPI::IEcAttachEventObserver >+ { >+ public: >+ CECAttachEvent(); >+ ~CECAttachEvent(); >+ >+ // Initialization - Register to event >+ TResult Init(MPI::IMpi *pMpiApi, MPI::TId clientId); >+ >+ virtual void HandleEvent(); >+ >+ }; >+ >+} /*namespace Martini*/ } /*namespace ProbekitAgent*/ >+ >+#endif // PROBEKIT_EC_ATTACH_EVENT_H >+ >Index: src-native/src/ProbekitAgent/Makefile.dep >=================================================================== >RCS file: src-native/src/ProbekitAgent/Makefile.dep >diff -N src-native/src/ProbekitAgent/Makefile.dep >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/Makefile.dep 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,35 @@ >+$(OBJDIR)/ProbekitAgent.o: ProbekitAgent.cpp >+ $(CPP_COMPILE) >+ >+$(OBJDIR)/Instrumenter.o: Instrumenter.cpp >+ $(CPP_COMPILE) >+ >+$(OBJDIR)/InstrumenterFactory.o: InstrumenterFactory.cpp >+ $(CPP_COMPILE) >+ >+$(OBJDIR)/ClassFileLoadHookEvent.o: ClassFileLoadHookEvent.cpp >+ $(CPP_COMPILE) >+ >+$(OBJDIR)/VMInitEvent.o: VMInitEvent.cpp >+ $(CPP_COMPILE) >+ >+$(OBJDIR)/Globals.o: Globals.cpp >+ $(CPP_COMPILE) >+ >+$(OBJDIR)/ECAttachEvent.o: ECAttachEvent.cpp >+ $(CPP_COMPILE) >+ >+$(OBJDIR)/ECDetachEvent.o: ECDetachEvent.cpp >+ $(CPP_COMPILE) >+ >+$(OBJDIR)/ECStartEvent.o: ECStartEvent.cpp >+ $(CPP_COMPILE) >+ >+$(OBJDIR)/ECStopEvent.o: ECStopEvent.cpp >+ $(CPP_COMPILE) >+ >+$(OBJDIR)/Util.o: Util.cpp >+ $(CPP_COMPILE) >+ >+$(OBJDIR)/b64.o: b64.c >+ $(CPP_COMPILE) >Index: src-native/src/ProbekitAgent/ECStartEvent.cpp >=================================================================== >RCS file: src-native/src/ProbekitAgent/ECStartEvent.cpp >diff -N src-native/src/ProbekitAgent/ECStartEvent.cpp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/ECStartEvent.cpp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#include "ECStartEvent.h" >+#include "Globals.h" >+#include <log.h> >+ >+using namespace Martini; >+using namespace Martini::MPI; >+using namespace Martini::ProbekitAgent; >+ >+CECStartEvent::CECStartEvent(){} >+CECStartEvent::~CECStartEvent(){} >+ >+/* >+ * Init - initializes internal data and registers for Start event >+ */ >+TResult >+CECStartEvent::Init(MPI::IMpi *pMpiApi, MPI::TId clientId) >+{ >+ TResult res = pMpiApi->RegisterEvent(clientId, *this); >+ return res; >+} >+ >+/* >+ * HandleEvent - callback function for Start event >+ */ >+void >+CECStartEvent::HandleEvent() >+{ >+ LOG_TRACE( PROFILER_NAME " EC Start" ); >+} >Index: src-native/src/ProbekitAgent/ECDetachEvent.h >=================================================================== >RCS file: src-native/src/ProbekitAgent/ECDetachEvent.h >diff -N src-native/src/ProbekitAgent/ECDetachEvent.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/ProbekitAgent/ECDetachEvent.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,37 @@ >+/************************************************************************ >+ * Copyright (c) 2007 OC Systems Inc. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Vsevolod Sandomirskiy, OC Systems - Probekit support >+ * >+ * $Id:$ >+ ************************************************************************/ >+ >+#ifndef PROBEKIT_EC_DETACH_EVENT_H >+#define PROBEKIT_EC_DETACH_EVENT_H >+ >+#include "MpiAPI.h" >+ >+namespace Martini { namespace ProbekitAgent { >+ >+ class CECDetachEvent : public MPI::IEcDetachEventObserver >+ { >+ public: >+ CECDetachEvent(); >+ ~CECDetachEvent(); >+ >+ // Initialization - Register to event >+ TResult Init(MPI::IMpi *pMpiApi, MPI::TId clientId); >+ >+ virtual void HandleEvent(); >+ >+ }; >+ >+} /*namespace Martini*/ } /*namespace ProbekitAgent*/ >+ >+#endif // PROBEKIT_EC_DETACH_EVENT_H >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 141540
:
64054
|
64200
|
64202
|
64210
|
64938
|
65067
|
65068
|
65838
|
65909
|
65934