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 87410 Details for
Bug 200251
[enh] Add support for "application" mode in the Java 1.5+ (JVMTI) Profiler
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]
patch
200251.txt (text/plain), 34.97 KB, created by
Igor Alelekov
on 2008-01-21 10:38:56 EST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Igor Alelekov
Created:
2008-01-21 10:38:56 EST
Size:
34.97 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.platform.jvmti.runtime >Index: src-native/src/JPIAgent/ECWrapper.h >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/JPIAgent/ECWrapper.h,v >retrieving revision 1.8 >diff -u -r1.8 ECWrapper.h >--- src-native/src/JPIAgent/ECWrapper.h 25 Apr 2007 14:23:16 -0000 1.8 >+++ src-native/src/JPIAgent/ECWrapper.h 21 Jan 2008 15:35:10 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005 - 2007 IBM Corporation, Intel Corporation. >+ * Copyright (c) 2005 - 2008 IBM Corporation, Intel Corporation. > * 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 >@@ -32,8 +32,9 @@ > ECWrapper(CPrint* pCPrint, CFilters* pCFilters, COptions* pCOptions); > ~ECWrapper(void); > >- void InitACCollector(CEC_Callbacks* callbacks); >- >+ void InitACCollector(); >+ void RegisterMartiniCallbacks(CEC_Callbacks* callbacks); >+ > //protected: > static CPrint* m_pCPrint; > static CFilters* m_pCFilters; >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.26 >diff -u -r1.26 ECWrapper.cpp >--- src-native/src/JPIAgent/ECWrapper.cpp 24 Aug 2007 17:29:24 -0000 1.26 >+++ src-native/src/JPIAgent/ECWrapper.cpp 21 Jan 2008 15:35:10 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005 - 2007 IBM Corporation, Intel Corporation. >+ * Copyright (c) 2005 - 2008 IBM Corporation, Intel Corporation. > * 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 >@@ -47,68 +47,126 @@ > > //=== ACC_ENV =============================================================================================== > >+static boolean ACTracingStarted = false; >+static boolean appTracingStarted = false; >+static boolean tracingStarted = false; >+static boolean printingStarted = false; >+ >+static void startTracing(); >+static void start(); >+static void stopTracing(); >+static void stop(); >+ >+extern "C" int isApplicationMode() { >+ return (ECWrapper::m_pCOptions != NULL) && ECWrapper::m_pCOptions->isApplicationMode(); >+} >+ >+API_EXPORT void ACC_CALL ACStartTracing() { >+ LOG_TRACE("ACStartTracing command!"); >+ if (ACTracingStarted) return; >+ >+ ACTracingStarted = true; >+ startTracing(); >+} >+ >+extern "C" void appStartTracing() { >+ LOG_TRACE("appStartTracing command!"); >+ if (appTracingStarted) return; >+ >+ appTracingStarted = true; >+ startTracing(); >+} >+ > /** START_TRACING ************************************************************* > * This is the entry point which must be called to start a trace. It takes > * care of emitting all the header information. > */ >-API_EXPORT void ACC_CALL >-StartTracing() >-{ >- LOG_TRACE("StartTracing command!"); >- LOG_ASSERT(ECWrapper::m_pCPrint != 0); >- ECWrapper::m_pCPrint->m_jvmtiAgent_suspendIO = false; >- ECWrapper::m_pCPrint->PrintStartingFragments(); >-} >- >-/** STOP_TRACING ************************************************************** >-* This is where a trace is stopped. >-*/ >-API_EXPORT void ACC_CALL >-StopTracing() >-{ >- LOG_TRACE("StopTracing command!"); >- LOG_ASSERT(ECWrapper::m_pCPrint != 0); >- LOG_ASSERT(ECWrapper::m_pCOptions != 0); >- ECWrapper::m_pCPrint->printTraceEndElement(); >- ECWrapper::m_pCPrint->m_jvmtiAgent_suspendIO = true; >+static void startTracing() { >+ if (tracingStarted) return; >+ >+ boolean applicationMode = false; >+ boolean standaloneMode = false; >+ >+ if (ECWrapper::m_pCOptions != NULL) { >+ applicationMode = ECWrapper::m_pCOptions->isApplicationMode(); >+ standaloneMode = ECWrapper::m_pCOptions->isStandAlone(); >+ } >+ >+ boolean toTrace = (standaloneMode || ACTracingStarted) && (appTracingStarted || !applicationMode); >+ >+ if (!toTrace) return; >+ >+ start(); >+ tracingStarted = true; > } > >-API_EXPORT void ACC_CALL >-Start() >-{ >+static void start() { > LOG_TRACE("Start command!"); >+ >+ LOG_ASSERT(ECWrapper::m_pCPrint != 0); >+ ECWrapper::m_pCPrint->m_jvmtiAgent_suspendIO = false; >+ >+ if (!printingStarted) { >+ ECWrapper::m_pCPrint->PrintStartingFragments(); >+ printingStarted = true; >+ } >+ > LOG_ASSERT(ECWrapper::m_pCallbacks != 0); >+ > ECWrapper::m_pCallbacks->Start(); > } > >-API_EXPORT void ACC_CALL >-Stop() >-{ >- LOG_TRACE("Stop command!"); >- LOG_ASSERT(ECWrapper::m_pCallbacks != 0); >- ECWrapper::m_pCallbacks->Stop(); >+API_EXPORT void ACC_CALL ACStopTracing() { >+ LOG_TRACE("ACStop command!"); >+ if (!ACTracingStarted) return; >+ >+ ACTracingStarted = false; >+ stopTracing(); > } > >-API_EXPORT void ACC_CALL >-Resume() >-{ >- LOG_TRACE("Resume command!"); >- LOG_ASSERT(ECWrapper::m_pCallbacks != 0); >- LOG_ASSERT(ECWrapper::m_pCPrint != 0); >- ECWrapper::m_pCPrint->m_jvmtiAgent_suspendIO = false; >- ECWrapper::m_pCallbacks->Start(); >+extern "C" void appStopTracing() { >+ LOG_TRACE("appStop command!"); >+ if (!appTracingStarted) return; >+ >+ appTracingStarted = false; >+ stopTracing(); > } > >-API_EXPORT void ACC_CALL >-Pause() >-{ >- LOG_TRACE("Pause command!"); >+/** STOP_TRACING ************************************************************** >+* This is where a trace is stopped. >+*/ >+static void stopTracing() { >+ if (!tracingStarted) return; >+ >+ boolean applicationMode = false; >+ boolean standaloneMode = false; >+ >+ if (ECWrapper::m_pCOptions != NULL) { >+ applicationMode = ECWrapper::m_pCOptions->isApplicationMode(); >+ standaloneMode = ECWrapper::m_pCOptions->isStandAlone(); >+ } >+ >+ boolean toTrace = (standaloneMode || ACTracingStarted) && (appTracingStarted || !applicationMode); >+ if (toTrace) return; >+ >+ tracingStarted = false; >+ stop(); >+} >+ >+static void stop() { >+ LOG_TRACE("Stop command!"); >+ > LOG_ASSERT(ECWrapper::m_pCallbacks != 0); >- LOG_ASSERT(ECWrapper::m_pCPrint != 0); > ECWrapper::m_pCallbacks->Stop(); >+ LOG_ASSERT(ECWrapper::m_pCPrint != 0); > ECWrapper::m_pCPrint->m_jvmtiAgent_suspendIO = true; > } > >+extern "C" void printCustomElement(const char* str) { >+ LOG_ASSERT(ECWrapper::m_pCPrint != 0); >+ ECWrapper::m_pCPrint->printCustomElement(str); >+} >+ > API_EXPORT void ACC_CALL > Attach() > { >@@ -123,6 +181,15 @@ > LOG_TRACE("Detach command!"); > LOG_ASSERT(ECWrapper::m_pCallbacks != 0); > ECWrapper::m_pCallbacks->Detach(); >+ >+ LOG_ASSERT(ECWrapper::m_pCPrint != 0); >+ >+ if (printingStarted) { >+ ECWrapper::m_pCPrint->printTraceEndElement(); >+ printingStarted = false; >+ } >+ >+ ECWrapper::m_pCPrint->m_jvmtiAgent_suspendIO = true; > } > > API_EXPORT void ACC_CALL >@@ -164,7 +231,13 @@ > { > LOG_TRACE("RunGC command!"); > LOG_ASSERT(ECWrapper::m_pCallbacks != 0); >- ECWrapper::m_pCallbacks->CustomCommand(RUN_GC_COMMAND, 0); >+ if (ECWrapper::m_pCallbacks != NULL) { >+ ECWrapper::m_pCallbacks->CustomCommand(RUN_GC_COMMAND, 0); >+ } >+} >+ >+extern "C" void runGC() { >+ RunGC(); > } > > API_EXPORT void ACC_CALL >@@ -201,12 +274,9 @@ > ECWrapper::PrepareACCEnv() > { > static ACCFunctions_ functions; >- functions.StartTracing = &StartTracing; >- functions.StopTracing = &StopTracing; >- functions.Start = &Start; >- functions.Stop = &Stop; >- functions.Pause = &Pause; >- functions.Resume = &Resume; >+ functions.StartTracing = &ACStartTracing; >+ functions.StopTracing = &ACStopTracing; >+ > functions.Detach = &Detach; > functions.Attach = &Attach; > functions.AddFilter = &AddFilter; >@@ -223,10 +293,13 @@ > return &ac_env; > } > >+void ECWrapper::RegisterMartiniCallbacks(CEC_Callbacks* callbacks) { >+ m_pCallbacks = callbacks; >+} >+ > void >-ECWrapper::InitACCollector(CEC_Callbacks* callbacks) >+ECWrapper::InitACCollector() > { >- m_pCallbacks = callbacks; > ACC_ENV* ac_env = PrepareACCEnv(); > > Martini::OSA::ILibraryLoader* libraryLoader; >Index: src-native/src/JPIAgent/ECJvmtiAgent.cpp >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/src/JPIAgent/ECJvmtiAgent.cpp,v >retrieving revision 1.11 >diff -u -r1.11 ECJvmtiAgent.cpp >--- src-native/src/JPIAgent/ECJvmtiAgent.cpp 18 Apr 2007 15:02:24 -0000 1.11 >+++ src-native/src/JPIAgent/ECJvmtiAgent.cpp 21 Jan 2008 15:35:10 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005 - 2007 IBM Corporation, Intel Corporation. >+ * Copyright (c) 2005 - 2008 IBM Corporation, Intel Corporation. > * 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 >@@ -74,11 +74,20 @@ > bool static isInitACCollectorInvoked = false; > int res = m_Callbacks.RegisterMartiniCallback_(command, callback); > if (res == 1) { >- if ((command == CMD_START) && m_Options.isStandAlone()) { >+ if ((command == CMD_START) && m_Options.isStandAlone() && !m_Options.isApplicationMode()) { >+ m_Print.m_jvmtiAgent_suspendIO = false; >+ m_Print.PrintStartingFragments(); >+ > m_Callbacks.Start(); > } >- if (!isInitACCollectorInvoked && m_Callbacks.ProfCallbacksAvailable() && !m_Options.isStandAlone()) { >- m_ECWrapper.InitACCollector(&m_Callbacks); >+ >+ if (!isInitACCollectorInvoked && m_Callbacks.ProfCallbacksAvailable()) { >+ m_ECWrapper.RegisterMartiniCallbacks(&m_Callbacks); >+ >+ if (!m_Options.isStandAlone()) { >+ m_ECWrapper.InitACCollector(); >+ } >+ > isInitACCollectorInvoked = true; > } > } >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.18 >diff -u -r1.18 Options.cpp >--- src-native/src/JPIAgent/Options.cpp 23 Aug 2007 21:32:13 -0000 1.18 >+++ src-native/src/JPIAgent/Options.cpp 21 Jan 2008 15:35:10 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005 - 2007 IBM Corporation, Intel Corporation. >+ * Copyright (c) 2005 - 2008 IBM Corporation, Intel Corporation. > * 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 >@@ -57,7 +57,7 @@ > { > 1 /* Provide timestamps by default */ > ,0 /* Standalone mode */ >-// ,0 /* Application mode */ >+ ,0 /* Application mode */ > ,1 /* Enabled mode */ > ,1 /* Filters */ > ,1 /* Options */ >@@ -115,26 +115,6 @@ > strcpy(m_jvmtiAgent_Options.workDir, DEFAULT_WORK_DIR); > } > >-int >-COptions::getToken(const char **src, char *buf, int buflen, char sep) >-{ >- int i; >- const char *p = *src; >- for (i = 0; i < buflen; i++) { >- if (p[i] == 0 || p[i] == sep) { >- buf[i] = 0; >- if (p[i] == sep) { >- i++; >- } >- *src += i; >- return i; >- } >- buf[i] = p[i]; >- } >- /* overflow */ >- return 0; >-} >- > /** PRINT_USAGE ********************************************************************** > * Print the command line useage of the program. > */ >@@ -155,6 +135,7 @@ > "\n" > "Supported option names and values:\n" > " server=standalone|enabled|controlled\n" >+ " api=true|false\tProfiler API (default is false)\n" > " file=<file>\t\tOutput file (default is %s)\n" > " \t\t\tOnly applicable when server=standalone\n" > " filters=<file>\tFilter definition file (default is %s)\n" >@@ -434,130 +415,123 @@ > return rc; > } > >-/** PROCESS_INVOCATION_OPTIONS ******************************************* >-* Takes the command line parameters and populates the m_jvmtiAgent_Options >-* with the correct values based upon the options specified. >-* @param optionString - the command line args >-* @returns >-*/ >- >-int >-COptions::ProcessInvocationOptions(const char *str) >-{ >- char *buf = 0; >- int buflen; >- int outputSpecified = 0; >- if (str == 0) str = ""; >+int COptions::parseOptions(char* buf) { >+ int outputSpecified = 0; > >- /* if "help" is specified print out the useage */ >- if ((STRICOLL(str, "help")) == 0) { >- return -1; >- } >- >- while (*str) { >- buflen= strlen(str)+1; >- buf = (char *)malloc(buflen); >- if (!buf) { >- goto mem_error; >- } >+ char* pnext = buf; >+ while (pnext) { >+ char* pname = pnext; // current tag >+ >+ pnext = strchr(pnext, ','); >+ if (pnext != NULL) { >+ *pnext++ = '\0'; // next tag >+ } >+ >+ char* pvalue = strchr(pname, '='); >+ if (pvalue != NULL) { >+ *pvalue++ = '\0'; >+ } > >- /* All options contain an "=" */ >- if (!getToken(&str, buf, buflen, '=')) { >- goto bad_option; >- } > /* Specied output file */ >- if (STRICOLL(buf, "file") == 0) { >- if (outputSpecified || !getToken(&str, buf, buflen, ',')) { >- goto bad_option; >- } >- strcpyrealloc(&m_jvmtiAgent_Options.outputFileName, buf); >+ if (STRICOLL(pname, "file") == 0) { >+ if (outputSpecified || pvalue == NULL) return -1; >+ >+ strcpyrealloc(&m_jvmtiAgent_Options.outputFileName, pvalue); > outputSpecified = 1; >- } else if (STRICOLL(buf, "filters") == 0) { >- if (!getToken(&str, buf, buflen, ',')) { >- goto bad_option; >- } >- strcpyrealloc(&m_jvmtiAgent_Options.filterFileName,buf); >-// } else if (STRICOLL(buf, "debug") == 0) { >-// if (!getToken(&str, buf, buflen, ',')) { >-// goto bad_option; >-// } else { >-// goto bad_option; >-// } >+ } else if (STRICOLL(pname, "filters") == 0) { >+ if (pvalue == NULL) return -1; >+ >+ strcpyrealloc(&m_jvmtiAgent_Options.filterFileName, pvalue); > } > /* Mode of operation */ >- else if (STRICOLL(buf, "server") == 0) { >- if (!getToken(&str, buf, buflen, ',')) { >- goto bad_option; >- } >+ else if (STRICOLL(pname, "server") == 0) { >+ if (pvalue == NULL) return -1; >+ > /* If standalone */ >- if (STRICOLL(buf,"standalone") == 0) { >+ if (STRICOLL(pvalue,"standalone") == 0) { > m_jvmtiAgent_Options.standalone = 1; > m_jvmtiAgent_Options.enabled = 0; > } > /* If enabled */ >- else if (STRICOLL(buf, "enabled") == 0) { >+ else if (STRICOLL(pvalue, "enabled") == 0) { > m_jvmtiAgent_Options.standalone = 0; > m_jvmtiAgent_Options.enabled = 1; > } > /* If controlled */ >- else if (STRICOLL(buf, "controlled") == 0) { >+ else if (STRICOLL(pvalue, "controlled") == 0) { > m_jvmtiAgent_Options.standalone = 0; > m_jvmtiAgent_Options.enabled = 0; > } else { >- goto bad_option; >+ return -1; > } >- } else if (STRICOLL(buf, "workDir") == 0) { >- if (!getToken(&str, buf, buflen, ',')) { >- goto bad_option; >+ } else if (STRICOLL(pname, "api") == 0) { >+ if (pvalue == NULL) return -1; >+ >+ if (STRICOLL(pvalue, "true") == 0) { >+ m_jvmtiAgent_Options.application = 1; > } >- strcpyrealloc(&m_jvmtiAgent_Options.workDir, buf); >+ } else if (STRICOLL(pname, "workDir") == 0) { >+ if (pvalue == NULL) return -1; >+ >+ strcpyrealloc(&m_jvmtiAgent_Options.workDir, pvalue); > > /* create the directory */ > if (MKDIR(m_jvmtiAgent_Options.workDir) != 0 && errno != EEXIST) { > /* couldn't create the dir and it doesn't exists either */ > perror(m_jvmtiAgent_Options.workDir); >- goto bad_option; >+ return -1; > } > > /* end of workDir */ >- } else if (STRICOLL(buf, "profile") == 0) { >+ } else if (STRICOLL(pname, "profile") == 0) { > m_jvmtiAgent_Options.profileFile; >- if (!getToken(&str, buf, buflen, ',')) { >- goto bad_option; >- } >- strcpyrealloc(&m_jvmtiAgent_Options.profileFile, buf); >+ if (pvalue == NULL) return -1; >+ >+ strcpyrealloc(&m_jvmtiAgent_Options.profileFile, pvalue); > } else { >- char *buf2 = (char *)malloc(buflen); >- if (!getToken(&str, buf2, buflen, ',')) { >- free(buf2); >- return -1; >- } >- SetProfileOption(buf, buf2); >- free(buf2); >+ if (pvalue == NULL) return -1; >+ SetProfileOption(pname, pvalue); > } >-// } else { >-// /* unknown option */ >-// fprintf(stderr, "Unknown option \"%s\"\n", buf); >-// fflush(stderr); >-// goto bad_option; >-// } >- } >- if (buf) { >- free (buf); >+ } >+ >+ return 0; >+} >+ >+/** PROCESS_INVOCATION_OPTIONS ******************************************* >+* Takes the command line parameters and populates the m_jvmtiAgent_Options >+* with the correct values based upon the options specified. >+* @param optionString - the command line args >+* @returns >+*/ >+ >+int COptions::ProcessInvocationOptions(const char *str) { >+ char* buf; >+ >+ if (str == NULL) return 0; >+ >+ /* if "help" is specified print out the useage */ >+ if ((STRICOLL(str, "help")) == 0) { >+ return -1; > } >- return 0; > >-bad_option: >- if (buf) { >- free(buf); >+ buf = (char*) malloc(strlen(str) + 1); >+ if (buf == NULL) { >+ fprintf(stderr, "Memory allocation error\n"); >+ fflush(stderr); >+ return -1; >+ } >+ >+ strcpy(buf, str); >+ >+ int r = parseOptions(buf); >+ free(buf); >+ >+ if (r < 0) { >+ fprintf(stderr, "Illegal TIAgent option\n"); >+ fflush(stderr); > } >- fprintf(stderr, "Bad TIAgent option\n"); >- fflush(stderr); >- return -1; >-mem_error: >- fprintf(stderr, "Memory allocation error\n"); >- fflush(stderr); >- return -1; >+ >+ return r; > } > > /** CHECK_OPTIONS_CONSISTENCY ******************************************** >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.14 >diff -u -r1.14 Options.h >--- src-native/src/JPIAgent/Options.h 28 Jun 2007 07:17:32 -0000 1.14 >+++ src-native/src/JPIAgent/Options.h 21 Jan 2008 15:35:10 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005 - 2007 IBM Corporation, Intel Corporation. >+ * Copyright (c) 2005 - 2008 IBM Corporation, Intel Corporation. > * 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 >@@ -36,7 +36,7 @@ > typedef struct { > unsigned int timestamp:1; /* Provide timestamps on all events (TRUE) */ > unsigned int standalone:1; /* Standalone mode (FALSE) */ >-// unsigned int application:1; /* Application mode (FALSE) */ >+ unsigned int application:1; /* Application mode (FALSE) */ > unsigned int enabled:1; /* Enabled mode ie. attachable (TRUE) */ > unsigned int filters:1; /* Print FILTER Elements (TRUE) */ > unsigned int options:1; /* Print OPTIONS Elements (TRUE) */ >@@ -126,6 +126,10 @@ > return (m_jvmtiAgent_Options.enabled == 1) ; > } > >+ bool isApplicationMode() { >+ return (m_jvmtiAgent_Options.application == 1); >+ } >+ > // is CG pfofiler aggregated > bool isCGExecDetails() { > return (!isEnabled()) && (m_jvmtiAgent_Options.cgExecDetails == 1); //in enabled mode we support aggregated cg profiler only >@@ -154,7 +158,7 @@ > ***/ > void addUnknownOption(char *key, char *value); > >- int getToken(const char **src, char *buf, int buflen, char sep); >+ int parseOptions(char* buf); > > /* Get the absolute directory path for the optheap working dir*/ > void getWorkDir(char* buf); >Index: .classpath >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/.classpath,v >retrieving revision 1.2 >diff -u -r1.2 .classpath >--- .classpath 2 May 2007 15:30:26 -0000 1.2 >+++ .classpath 21 Jan 2008 15:35:10 -0000 >@@ -1,6 +1,7 @@ > <?xml version="1.0" encoding="UTF-8"?> > <classpath> > <classpathentry kind="src" path="src.config"/> >+ <classpathentry kind="src" path="src"/> > <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> > <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.tptp.platform.agentcontroller"/> > <classpathentry kind="output" path="bin"/> >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.15 >diff -u -r1.15 ACCollector.cpp >--- src-native/src/ACCollector/ACCollector.cpp 24 Aug 2007 17:29:24 -0000 1.15 >+++ src-native/src/ACCollector/ACCollector.cpp 21 Jan 2008 15:35:10 -0000 >@@ -1,5 +1,5 @@ > /************************************************************************ >- * Copyright (c) 2005, 2007 Intel Corporation. >+ * Copyright (c) 2005, 2008 Intel Corporation. > * 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 >@@ -135,17 +135,15 @@ > } > > if (m_isEnabledDataCollection) { >- m_ACC_env->StartTracing(); > m_ACC_env->Attach(); > m_isWaiting = false; >- m_ACC_env->Start(); >+ m_ACC_env->StartTracing(); > m_isTracing = true; > } > else { > m_ACC_env->Attach(); > m_isWaiting = false; >- m_isTracing = true; >- m_isFirstAfterStart = true; >+ m_isTracing = true; > } > // if (m_ACC_env->IsAgentInitialized()) { > // SendVMAgentInitializedCommand(); >@@ -163,7 +161,6 @@ > if (!isAgentInitialized(cmdBlock->getContextID())) { > return 0; > } >- m_ACC_env->Stop(); > m_ACC_env->Detach(); > m_ACC_env->StopTracing(); > m_isTracing = false; >@@ -178,17 +175,7 @@ > return 0; > } > >- >- if (m_isFirstAfterStart && !m_isEnabledDataCollection) { >- m_ACC_env->StartTracing(); >-// m_ACC_env->Start(); >- m_ACC_env->Resume(); >- m_isFirstAfterStart = false; >- } >- else { >- m_ACC_env->Resume(); >- } >- >+ m_ACC_env->StartTracing(); > > return BaseCollectorImpl::resume(cmdBlock); > } >@@ -203,7 +190,8 @@ > if (!isAgentInitialized(cmdBlock->getContextID())) { > return 0; > } >- m_ACC_env->Pause(); >+ >+ m_ACC_env->StopTracing(); > return BaseCollectorImpl::pause(cmdBlock); > } > >@@ -369,11 +357,13 @@ > this->processCommandLine(0, cargv); > > this->registerAgent(); >+ > if (isControlled) { > while(m_isWaiting) { > Sleep(100); > }; > } >+ > return 0; > } > >Index: src-native/include/JPIAgent/ACC_Env.h >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.runtime/src-native/include/JPIAgent/ACC_Env.h,v >retrieving revision 1.9 >diff -u -r1.9 ACC_Env.h >--- src-native/include/JPIAgent/ACC_Env.h 24 Aug 2007 17:29:24 -0000 1.9 >+++ src-native/include/JPIAgent/ACC_Env.h 21 Jan 2008 15:35:10 -0000 >@@ -1,5 +1,5 @@ > /************************************************************************ >- * Copyright (c) 2005 - 2007 Intel Corporation. >+ * Copyright (c) 2005 - 2008 Intel Corporation. > * 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 >@@ -38,10 +38,6 @@ > struct ACCFunctions_ { > void (ACC_CALL *StartTracing)(); > void (ACC_CALL *StopTracing)(); >- void (ACC_CALL *Start)(); >- void (ACC_CALL *Stop)(); >- void (ACC_CALL *Pause)(); >- void (ACC_CALL *Resume)(); > void (ACC_CALL *Detach)(); > void (ACC_CALL *Attach)(); > void (ACC_CALL *AddFilter)(char *iid, char *classPattern, char *methodPattern, char *filterMode);//strcmp("INCLUDE", mode) == 0 ? INCLUDE : EXCLUDE >@@ -66,22 +62,6 @@ > functions->StopTracing(); > } > >- void Start() { >- functions->Start(); >- } >- >- void Stop() { >- functions->Stop(); >- } >- >- void Pause() { >- functions->Pause(); >- } >- >- void Resume() { >- functions->Resume(); >- } >- > void Detach() { > functions->Detach(); > } >Index: src-native/src/JPIAgent/Profiler.c >=================================================================== >RCS file: src-native/src/JPIAgent/Profiler.c >diff -N src-native/src/JPIAgent/Profiler.c >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/JPIAgent/Profiler.c 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,73 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Intel Corporation. >+ * 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 >+ * >+ * $Id: Profiler.c,v 1.0 2008/01/21 21:32:13 ialelekov Exp $ >+ ***********************************************************************/ >+ >+#include "Profiler.h" >+ >+extern void appStartTracing(); // defined in ECWrapper.cpp >+extern void appStopTracing(); >+extern int isApplicationMode(); >+extern int runGC(); >+extern void printCustomElement(const char* str); >+ >+JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_initialize0 >+ (JNIEnv *env, jobject thisObj) { >+ >+ return isApplicationMode() ? 0 : -1; >+ } >+ >+/* >+ * Class: org_eclipse_tptp_profiler_Profiler >+ * Method: startProfiling0 >+ * Signature: ()I >+ */ >+JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_startProfiling0 >+ (JNIEnv *env, jobject thisObj) { >+ >+ appStartTracing(); >+ >+ return 0; >+ } >+ >+/* >+ * Class: org_eclipse_tptp_profiler_Profiler >+ * Method: stopProfiling0 >+ * Signature: ()I >+ */ >+JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_stopProfiling0 >+ (JNIEnv *env, jobject thisObj) { >+ >+ if (!isApplicationMode()) return -1; >+ >+ appStopTracing(); >+ >+ return 0; >+ } >+ >+/* >+ * Class: org_eclipse_tptp_profiler_Profiler >+ * Method: runGC0 >+ * Signature: ()I >+ */ >+JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_runGC0 >+ (JNIEnv *env, jobject thisObj) { >+ >+ runGC(); >+ >+ return 0; >+ } >+ >+ JNIEXPORT void JNICALL Java_org_eclipse_tptp_profiler_Profiler_emitXMLFragment0 >+ (JNIEnv *env, jobject thisObj, jstring xmlFragment) { >+ >+ const char *native = (*env)->GetStringUTFChars(env, xmlFragment, NULL); >+ printCustomElement(native); >+ (*env)->ReleaseStringUTFChars(env, xmlFragment, native); >+ } >+ >Index: src/org/eclipse/tptp/profiler/Profiler.java >=================================================================== >RCS file: src/org/eclipse/tptp/profiler/Profiler.java >diff -N src/org/eclipse/tptp/profiler/Profiler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/profiler/Profiler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,95 @@ >+package org.eclipse.tptp.profiler; >+ >+public class Profiler { >+ private final static String AGENT_NAME = "JPIAgent"; >+ private static Profiler instance = null; >+ private static boolean nativesAvailable = false; >+ >+ private boolean isProfiling = false; >+ private boolean isActive = false; >+ >+ static { >+ try { >+ System.loadLibrary(AGENT_NAME); >+ nativesAvailable = true; >+ } >+ catch(Throwable e) {} >+ } >+ >+ /** >+ * Native delegate to startup the profiler. Checks to see if profiling is possible. >+ */ >+ private native int initialize0(); >+ >+ private Profiler() { >+ isActive = initialize0() == 0; >+ } >+ >+ public static Profiler getProfiler() throws ProfilerNotAvailableException { >+ if (!nativesAvailable) throw new ProfilerNotAvailableException(); >+ >+ if (instance == null) instance = new Profiler(); >+ >+ if (!instance.isActive) throw new ProfilerAPINotAvailableException(); >+ >+ return instance; >+ } >+ >+ /** >+ * Native delegate of startProfiling(). >+ * @returns 0 - the profile session was created successfuly. >+ * >+ */ >+ private native int startProfiling0(); >+ >+ public boolean startProfiling() throws ProfilerNotAvailableException { >+ if (!isActive) throw new ProfilerAPINotAvailableException(); >+ >+ synchronized(this) { >+ if (!isProfiling) { >+ isProfiling = startProfiling0() == 0; >+ } >+ } >+ >+ return isProfiling; >+ } >+ >+ /** >+ * Native delgate to stopProfiling. >+ */ >+ private native int stopProfiling0(); >+ >+ public boolean stopProfiling() throws ProfilerNotAvailableException { >+ if (!isActive) throw new ProfilerAPINotAvailableException(); >+ >+ synchronized(this) { >+ if (isProfiling) { >+ isProfiling = !(stopProfiling0() == 0); >+ } >+ } >+ >+ return !isProfiling; >+ } >+ >+ /** >+ * Native delgate to runGC. >+ */ >+ private native int runGC0(); >+ >+ public void runGC() throws ProfilerNotAvailableException { >+ if (!isActive) throw new ProfilerAPINotAvailableException(); >+ >+ runGC0(); >+ } >+ >+ /** >+ * Native delgate to emitXMLFragment. >+ */ >+ private native void emitXMLFragment0(String xmlFragment); >+ >+ public void emitXMLFragment(String xmlFragment) throws ProfilerNotAvailableException { >+ if (!isActive) throw new ProfilerAPINotAvailableException(); >+ >+ emitXMLFragment0(xmlFragment); >+ } >+} >Index: src/org/eclipse/tptp/profiler/ProfilerNotAvailableException.java >=================================================================== >RCS file: src/org/eclipse/tptp/profiler/ProfilerNotAvailableException.java >diff -N src/org/eclipse/tptp/profiler/ProfilerNotAvailableException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/profiler/ProfilerNotAvailableException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+package org.eclipse.tptp.profiler; >+ >+public class ProfilerNotAvailableException extends Exception { >+ private static final long serialVersionUID = 1L; >+} >Index: src-native/src/JPIAgent/Profiler.h >=================================================================== >RCS file: src-native/src/JPIAgent/Profiler.h >diff -N src-native/src/JPIAgent/Profiler.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native/src/JPIAgent/Profiler.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Intel Corporation. >+ * 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 >+ * >+ * $Id: Profiler.h,v 1.0 2008/01/21 21:32:13 ialelekov Exp $ >+ ***********************************************************************/ >+ >+/* DO NOT EDIT THIS FILE - it is machine generated */ >+#include <jni.h> >+/* Header for class org_eclipse_tptp_platform_jvmti_runtime_profiler_Profiler */ >+ >+#ifndef _Included_org_eclipse_tptp_profiler_Profiler >+#define _Included_org_eclipse_tptp_profiler_Profiler >+#ifdef __cplusplus >+extern "C" { >+#endif >+/* >+ * Class: org_eclipse_tptp_profiler_Profiler >+ * Method: initialize0 >+ * Signature: ()I >+ */ >+JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_initialize0 >+ (JNIEnv *, jobject); >+ >+/* >+ * Class: org_eclipse_tptp_profiler_Profiler >+ * Method: startProfiling0 >+ * Signature: ()I >+ */ >+JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_startProfiling0 >+ (JNIEnv *, jobject); >+ >+/* >+ * Class: org_eclipse_tptp_profiler_Profiler >+ * Method: stopProfiling0 >+ * Signature: ()I >+ */ >+JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_stopProfiling0 >+ (JNIEnv *, jobject); >+ >+/* >+ * Class: org_eclipse_tptp_profiler_Profiler >+ * Method: runGC0 >+ * Signature: ()I >+ */ >+JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_runGC0 >+ (JNIEnv *, jobject); >+ >+/* >+ * Class: org_eclipse_tptp_profiler_Profiler >+ * Method: emitXMLFragment0 >+ * Signature: (Ljava/lang/String;)I >+ */ >+JNIEXPORT void JNICALL Java_org_eclipse_tptp_profiler_Profiler_emitXMLFragment0 >+ (JNIEnv *, jobject, jstring); >+ >+#ifdef __cplusplus >+} >+#endif >+#endif >Index: src/org/eclipse/tptp/profiler/ProfilerAPINotAvailableException.java >=================================================================== >RCS file: src/org/eclipse/tptp/profiler/ProfilerAPINotAvailableException.java >diff -N src/org/eclipse/tptp/profiler/ProfilerAPINotAvailableException.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/profiler/ProfilerAPINotAvailableException.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+package org.eclipse.tptp.profiler; >+ >+public class ProfilerAPINotAvailableException extends ProfilerNotAvailableException { >+ private static final long serialVersionUID = 1L; >+}
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 200251
:
81060
|
87048
|
87410
|
89022
|
89110