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 64938 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]
Patch for execution of JVMTI probekit (client side)
141540_execution_april25_patch.txt (text/plain), 37.30 KB, created by
Liz Dancy
on 2007-04-25 17:16:35 EDT
(
hide
)
Description:
Patch for execution of JVMTI probekit (client side)
Filename:
MIME Type:
Creator:
Liz Dancy
Created:
2007-04-25 17:16:35 EDT
Size:
37.30 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.platform.execution >Index: .classpath >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.execution/.classpath,v >retrieving revision 1.3 >diff -u -r1.3 .classpath >--- .classpath 14 Jun 2005 00:15:54 -0000 1.3 >+++ .classpath 25 Apr 2007 21:10:12 -0000 >@@ -1,16 +1,7 @@ > <?xml version="1.0" encoding="UTF-8"?> > <classpath> >- <classpathentry kind="src" path="src"> >- <attributes> >- </attributes> >- </classpathentry> >- <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> >- <attributes> >- </attributes> >- </classpathentry> >- <classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"> >- <attributes> >- </attributes> >- </classpathentry> >+ <classpathentry kind="src" path="src"/> >+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> >+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> > <classpathentry kind="output" path="bin"/> > </classpath> >#P org.eclipse.tptp.platform.jvmti.client >Index: src/org/eclipse/tptp/platform/jvmti/client/internal/launcher/TIDelegateHelper.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.client/src/org/eclipse/tptp/platform/jvmti/client/internal/launcher/TIDelegateHelper.java,v >retrieving revision 1.35 >diff -u -r1.35 TIDelegateHelper.java >--- src/org/eclipse/tptp/platform/jvmti/client/internal/launcher/TIDelegateHelper.java 24 Apr 2007 16:24:26 -0000 1.35 >+++ src/org/eclipse/tptp/platform/jvmti/client/internal/launcher/TIDelegateHelper.java 25 Apr 2007 21:10:13 -0000 >@@ -13,6 +13,7 @@ > import java.net.InetAddress; > import java.util.ArrayList; > import java.util.Hashtable; >+import java.util.Iterator; > import java.util.List; > > import org.eclipse.core.resources.IContainer; >@@ -26,6 +27,8 @@ > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.emf.common.util.EList; > import org.eclipse.emf.common.util.URI; >+ >+import org.eclipse.hyades.internal.execution.local.control.AgentConfiguration; > import org.eclipse.hyades.loaders.util.LoadersUtils; > import org.eclipse.hyades.models.hierarchy.TRCAgentProxy; > import org.eclipse.hyades.models.hierarchy.TRCCollectionMode; >@@ -156,6 +159,9 @@ > /** The JVM argument used to launch a Java application with the JVMTI THREAD flag */ > protected static final String TI_THRD_JVM_FLAG = "-agentlib:JPIBootLoader=JPIAgent:server=controlled;ThreadProf"; > >+ /** The JVM argument used to launch a Java application with the JVMTI PROBE flag */ >+ protected static final String TI_PROBE_JVM_FLAG = "-agentlib:JPIBootLoader=JPIAgent:server=controlled;ProbekitAgent:ext-pk-BCILibraryName=BCIEngProbe"; >+ > /** The JVM argument used to launch a Java application with the JVMTI flag */ > protected static String TI_JVM_FLAG = TI_CGPROF_JVM_FLAG; > >@@ -205,9 +211,11 @@ > isCGProf = true; > for (int i = 0; i < mapsize; i++) > { >+ > java.util.Map.Entry entry = (java.util.Map.Entry) keyValuePairs.next(); > Object key = entry.getKey(); > Object value = entry.getValue(); >+ addOption(new StringBuffer(), key.toString(), value.toString()); > > //defaults to call graph profiler > TI_JVM_FLAG = TI_CGPROF_JVM_FLAG; >@@ -235,6 +243,15 @@ > isCGProf = false; > break; > } >+ // added for enhancement 141540 >+ // Liz Dancy >+ if(value.toString().indexOf("probe") != -1) >+ { >+ TI_JVM_FLAG = TI_PROBE_JVM_FLAG; >+ //TODO: call getJVM arguments to add helper classes >+ isCGProf = false; >+ break; >+ } > } > } > //If it is not Heap or thread check for the CGProf Alloc execdetails true >@@ -468,13 +485,21 @@ > return null; > } > >+ /*Add a listener which can potentially give control to probekit to send probe files*/ >+ >+ // added for enhancement 141540 >+ >+ >+ >+ ProbeControlListener probeController = new ProbeControlListener(launchConfiguration); >+ tiAgent.addAgentListener(probeController); >+ > /* Start Monitoring */ > tiAgent.startMonitoring(TPTPDataPath.DATA_PATH_TWO_WAY); > >- > /* Create the model entities */ >- TRCAgentProxy tiAgentProxy = agentProxy == null ? createModelEntities(launchConfiguration, agentController, process, tiAgent) : createModelEntities(agentProxy, agentController, process, tiAgent); >- >+ >+ TRCAgentProxy tiAgentProxy = agentProxy == null ? createModelEntities(launchConfiguration, agentController, process, tiAgent) : createModelEntities(agentProxy, agentController, process, tiAgent); > > final TRCAgentProxy trcAgentProxy = tiAgentProxy; > >Index: src/org/eclipse/tptp/platform/jvmti/client/internal/analysistypes/TIProbeInsertionAnalysisUI.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.client/src/org/eclipse/tptp/platform/jvmti/client/internal/analysistypes/TIProbeInsertionAnalysisUI.java,v >retrieving revision 1.2 >diff -u -r1.2 TIProbeInsertionAnalysisUI.java >--- src/org/eclipse/tptp/platform/jvmti/client/internal/analysistypes/TIProbeInsertionAnalysisUI.java 20 Apr 2007 23:00:22 -0000 1.2 >+++ src/org/eclipse/tptp/platform/jvmti/client/internal/analysistypes/TIProbeInsertionAnalysisUI.java 25 Apr 2007 21:10:13 -0000 >@@ -71,6 +71,8 @@ > probe.addProbeID(strValueID); > if (items[i].getChecked()) > { >+ String attributeKey = ProbeLaunchConfigString.AGENT_CONFIG_NAME_PREFIX + probeUI.PROBE_LAUNCH_UNIQUE_PROBESPEC_SUFFIX; >+ > boolean bMatchingSetFound = false; > FilterSetElement set = probeUI.getManager() > .getDefaultFilterSet(); >@@ -109,11 +111,14 @@ > + probeUI.PROBE_LAUNCH_UNIQUE_PROBESPEC_SUFFIX > + iCheckedCount; > String strValueProbeLaunch = probe.toString(); >+ >+ > > DataCollectionEngineAttribute attributeProbe = new DataCollectionEngineAttribute( > strName, strValueProbeLaunch); > > attributes.add(attributeProbe); >+ System.out.println("adding " + strName + " " + strValueProbeLaunch); > > iCheckedCount++; > } >@@ -123,6 +128,7 @@ > } > return attributes; > } >+ > /** > * Here we set our own attributes to keep track of whether or not the > * launch configuration was valid upon exiting the Edit Options >@@ -132,21 +138,36 @@ > */ > public boolean storeAttributes (ILaunchConfigurationWorkingCopy configurationWC) > { >+ Vector attributes = new Vector(); >+ int iCheckedCount = 0; > boolean probesSelected = false; > int iSelectedProbes = 0; > int iAvailableProbes = probeUI.getProbeSets().getItemCount(); > List namesOfSelected = null ; >- if (iAvailableProbes > 0) >+ if (probeUI.getProbeSets()!=null &&! probeUI.getProbeSets().isDisposed()) >+ { >+ int iNumProbeSets = probeUI.getProbeSets().getItemCount(); >+ if (iNumProbeSets > 0 && iAvailableProbes >0) > { > TableItem[] items = probeUI.getProbeSets().getItems(); >- for (int i = 0; i < iAvailableProbes; i++) >+ for (int i = 0; i < iNumProbeSets; i++) > { >- if (items[i].getChecked()) >+ ProbeRegistryEntry entry = (ProbeRegistryEntry) items[i] >+ .getData(); >+ if (entry != null) > { >- iSelectedProbes++; >- } >- } >- } >+ String strValueID = entry.getId(); >+ ProbeLaunchConfigString probe = new ProbeLaunchConfigString(); >+ probe.addProbeID(strValueID); >+ if (items[i].getChecked()) >+ { >+ String attributeKey = ProbeLaunchConfigString.AGENT_CONFIG_NAME_PREFIX + probeUI.PROBE_LAUNCH_UNIQUE_PROBESPEC_SUFFIX; >+ configurationWC.setAttribute(attributeKey, probe.toString()); >+ System.out.println("adding in save " + probe.toString() + attributeKey); >+ iSelectedProbes++; >+ } >+ >+ > if (iAvailableProbes == 0 || iSelectedProbes == 0) > { > // create a new attribute to keep track of whether any probes have >@@ -160,7 +181,8 @@ > // and an approprite error message will be displayed > configurationWC.setAttribute("anyProbesSelected", true); > configurationWC.setAttribute("saved", true); >- configurationWC.setAttribute("selectedItems",namesOfSelected ); >+ configurationWC.setAttribute("probeLaunch",true ); >+ > probesSelected = true; > } > probeUI.saveSelections(); >@@ -170,5 +192,11 @@ > > > } >+ } >+ } >+ >+ return true; >+ } >+ } > > >Index: src/org/eclipse/tptp/platform/jvmti/client/internal/analysistypes/TIProbeInsertionConfPage.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.jvmti.client/src/org/eclipse/tptp/platform/jvmti/client/internal/analysistypes/TIProbeInsertionConfPage.java,v >retrieving revision 1.1 >diff -u -r1.1 TIProbeInsertionConfPage.java >--- src/org/eclipse/tptp/platform/jvmti/client/internal/analysistypes/TIProbeInsertionConfPage.java 20 Apr 2007 22:53:11 -0000 1.1 >+++ src/org/eclipse/tptp/platform/jvmti/client/internal/analysistypes/TIProbeInsertionConfPage.java 25 Apr 2007 21:10:13 -0000 >@@ -107,7 +107,7 @@ > */ > public boolean storeAttributes(ILaunchConfigurationWorkingCopy configurationWC) > { >- >+ > return pr.storeAttributes(configurationWC); > } > /** >@@ -115,6 +115,7 @@ > */ > public Vector getAttributes() > { >+ > return pr.getAttributes(); > } > >Index: src/org/eclipse/tptp/platform/jvmti/client/internal/launcher/ProbeControlListener.java >=================================================================== >RCS file: src/org/eclipse/tptp/platform/jvmti/client/internal/launcher/ProbeControlListener.java >diff -N src/org/eclipse/tptp/platform/jvmti/client/internal/launcher/ProbeControlListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/platform/jvmti/client/internal/launcher/ProbeControlListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,163 @@ >+/********************************************************************** >+ * Copyright (c) 2007 IBM 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 >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.tptp.platform.jvmti.client.internal.launcher; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.hyades.loaders.util.LoadersUtils; >+import org.eclipse.hyades.models.hierarchy.TRCAgentProxy; >+import org.eclipse.hyades.trace.ui.UIPlugin; >+import org.eclipse.hyades.trace.ui.internal.launcher.IProfileLaunchConfigurationConstants; >+import org.eclipse.hyades.trace.ui.launcher.ILauncherHandler; >+import org.eclipse.tptp.platform.execution.client.agent.IAgent; >+import org.eclipse.tptp.platform.execution.client.agent.IAgentListener; >+import org.eclipse.tptp.platform.probekit.launch.launchpad.LaunchPadExtensionSlot; >+/** >+ * A listener class which waits for the AgentActive signal from the >+ * monitored agent. Before the RESUME command is sent, we want to >+ * give control to the Probekit Launcher so that the probe script >+ * and probe class files can be sent. Once they are sent, RESUME is >+ * called and the agent can run. >+ * >+ * @author Liz Dancy >+ * >+ */ >+public class ProbeControlListener implements IAgentListener >+{ >+ IAgent controlAgent =null; >+ Map launcherHandlers; >+ ILaunchConfiguration config; >+ >+ >+ //necessary in order to retrieve the LauncherHandlers so we >+ //can identify the probekit launchpad and give it control >+ >+ public ProbeControlListener( ILaunchConfiguration callingConfiguration) >+ { >+ config =callingConfiguration; >+ >+ } >+ public void error(IAgent agent, String errorMessage) >+ { >+ //ignore for now >+ //TODO >+ } >+ >+ /** >+ * Called when an agent startsMonitoring >+ * This is a crucial time to give Control to probekit >+ * so that it can send its commands. >+ * Therefore, we use this notification to pass Control >+ * to the Probekit LaunchPad to send the necessary files beore the agent >+ * in question resumes. >+ */ >+ public void agentActive(IAgent agent) >+ { >+ try >+ { >+ String launchItemSelections = config.getAttribute(IProfileLaunchConfigurationConstants.ATTR_PROFILING_COLLECTOR_AND_ANALYSIS, (String)null); >+ // we do not want to giveControl to the probekit if this type of analysis >+ // has not been selected >+ if (launchItemSelections.contains("org.eclipse.tptp.analysisType.jvmti.probe")) >+ { >+ initializeLauncherHandlers(); >+ Object[] launcherHandlersArray = launcherHandlers.values().toArray(); >+ LoadersUtils ld = new LoadersUtils(); >+ >+ for (int num = 0; num < launcherHandlersArray.length; num++) >+ { >+ ILauncherHandler type = (ILauncherHandler)launcherHandlersArray[num]; >+ >+ if (type instanceof org.eclipse.tptp.platform.probekit.launch.launchpad.LaunchPadExtensionSlot) >+ { >+ LaunchPadExtensionSlot extension = new LaunchPadExtensionSlot(); >+ extension.handlePreAgentActiveJVMTI(agent, config); >+ } >+ else >+ { >+ //inactive >+ //TODO: implement the agent callback when it is inactive >+ } >+ }// end for >+ } >+ } >+ catch (Exception e) >+ { >+ if(e.getMessage() != null) >+ { >+ IStatus status = new Status(IStatus.ERROR,UIPlugin.getPluginId(),IStatus.ERROR,e.getMessage(),e); >+ UIPlugin.getDefault().getLog().log(status); >+ } >+ //quietly catch any exceptions >+ //and ignore them >+ } >+ } >+ /** >+ * Invoked when an agent becomes inactive. >+ * @param Agent >+ */ >+ public void agentInactive(IAgent agent) >+ { >+ //ignore for now >+ } >+ >+ >+ private void initializeLauncherHandlers() >+ { >+ //reads the extension points, and creates instances of the GetControlType objects >+ //specified by the class attribute >+ //taken from initializeLaunchHandlers in org.eclipse.hyades.trace.ui.internal.piclient.PIProcessListener >+ >+ launcherHandlers = new HashMap(); >+ >+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(UIPlugin.PLUGIN_ID, "launcherHandler"); >+ >+ if (point != null) { >+ IConfigurationElement[] elements = point.getConfigurationElements(); >+ for (int i = 0; i < elements.length; i++) { >+ >+ IConfigurationElement elem = elements[i]; >+ >+ String id = elem.getAttribute("id"); >+ >+ ILauncherHandler getControlType = null; >+ try >+ { >+ getControlType = (ILauncherHandler)elem.createExecutableExtension("class"); >+ } >+ catch (Exception e) >+ { >+ if(e.getMessage() != null) >+ { >+ IStatus status = new Status(IStatus.ERROR,UIPlugin.getPluginId(),IStatus.ERROR,e.getMessage(),e); >+ UIPlugin.getDefault().getLog().log(status); >+ } >+ >+ e.printStackTrace(); >+ } >+ >+ if(getControlType != null) >+ { >+ //put the instace of the class in a map >+ launcherHandlers.put(id, getControlType); >+ } >+ } >+ } >+ } >+ >+} >#P org.eclipse.tptp.platform.probekit.launch >Index: src/org/eclipse/tptp/platform/probekit/launch/internal/ProbekitLaunchImages.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.probekit.launch/src/org/eclipse/tptp/platform/probekit/launch/internal/ProbekitLaunchImages.java,v >retrieving revision 1.2 >diff -u -r1.2 ProbekitLaunchImages.java >--- src/org/eclipse/tptp/platform/probekit/launch/internal/ProbekitLaunchImages.java 10 Feb 2006 17:39:28 -0000 1.2 >+++ src/org/eclipse/tptp/platform/probekit/launch/internal/ProbekitLaunchImages.java 25 Apr 2007 21:10:13 -0000 >@@ -13,6 +13,7 @@ > > import org.eclipse.hyades.ui.internal.util.ImageManager; > >+ > /** > * Image manager for the Probekit Launch plugin. > */ >Index: src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPad.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.probekit.launch/src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPad.java,v >retrieving revision 1.1 >diff -u -r1.1 LaunchPad.java >--- src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPad.java 22 Feb 2006 16:41:43 -0000 1.1 >+++ src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPad.java 25 Apr 2007 21:10:13 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2004, 2006 IBM Corporation and others. >+ * Copyright (c) 2004, 2007 IBM Corporation and others. > * 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 >@@ -801,17 +801,20 @@ > > String configName = config.getName(); > EList options = config.getOptions(); >+ > Iterator itrOptions = options.iterator(); > > while(itrOptions.hasNext()) > { > TRCOption option = (TRCOption) itrOptions.next(); > String key = option.getKey(); >+ > if(!key.startsWith(ProbeLaunchConfigString.AGENT_CONFIG_NAME_PREFIX)) > { > continue; > } > String value = option.getValue(); >+ > String probeFilters; > ProbeLaunchConfigString probeConfig = ProbeLaunchConfigString.fromString(value); > >Index: src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadExtensionSlot.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.probekit.launch/src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadExtensionSlot.java,v >retrieving revision 1.1 >diff -u -r1.1 LaunchPadExtensionSlot.java >--- src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadExtensionSlot.java 22 Feb 2006 16:41:43 -0000 1.1 >+++ src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadExtensionSlot.java 25 Apr 2007 21:10:13 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2004, 2006 IBM Corporation and others. >+ * Copyright (c) 2004, 2007 IBM Corporation and others. > * 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 >@@ -23,9 +23,13 @@ > */ > package org.eclipse.tptp.platform.probekit.launch.launchpad; > >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.hyades.models.hierarchy.TRCAgentProxy; > import org.eclipse.hyades.models.hierarchy.TRCProcessProxy; > import org.eclipse.hyades.trace.ui.launcher.ILauncherHandler; >+import org.eclipse.tptp.platform.execution.client.agent.IAgent; >+import org.eclipse.tptp.platform.execution.client.agent.ICollector; > > > /** >@@ -74,7 +78,22 @@ > } > } > >- >+ /** >+ * In the case of the JVMTI Agent we pass in the >+ * entire agent. This method overload is due to the different command >+ * formates in the old and new execution frameworks >+ * requiring different flows of control through the >+ * LaunchPad. >+ * >+ * Created April, 2007 >+ * @param agent >+ */ >+ public void handlePreAgentActiveJVMTI(IAgent agent, ILaunchConfiguration config)throws CoreException, LaunchPadException{ >+ >+ LaunchPadJVMTI launchPad = new LaunchPadJVMTI(); >+ launchPad.agentActive((ICollector)agent, config); >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.hyades.trace.ui.launcher.ILauncherHandler#handlePostAgentActive(org.eclipse.hyades.models.hierarchy.TRCAgentProxy) > */ >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.probekit.launch/META-INF/MANIFEST.MF,v >retrieving revision 1.13 >diff -u -r1.13 MANIFEST.MF >--- META-INF/MANIFEST.MF 16 Apr 2007 21:09:11 -0000 1.13 >+++ META-INF/MANIFEST.MF 25 Apr 2007 21:10:13 -0000 >@@ -8,6 +8,7 @@ > Bundle-Localization: plugin > Export-Package: org.eclipse.tptp.platform.probekit.launch.internal, > org.eclipse.tptp.platform.probekit.launch.internal.config, >+ org.eclipse.tptp.platform.probekit.launch.internal.wizard, > org.eclipse.tptp.platform.probekit.launch.launchpad > Require-Bundle: org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)", > org.eclipse.jface.text;bundle-version="[3.2.0,4.0.0)", >@@ -21,6 +22,8 @@ > org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)", > org.eclipse.hyades.probekit.ui;bundle-version="[4.0.0,5.0.0)", > org.eclipse.hyades.probekit;bundle-version="[4.0.0,5.0.0)", >- org.eclipse.tptp.platform.models;bundle-version="[4.0.0,5.0.0)" >+ org.eclipse.tptp.platform.models;bundle-version="[4.0.0,5.0.0)", >+ org.eclipse.hyades.execution.correlation, >+ org.eclipse.tptp.platform.execution > Eclipse-LazyStart: true > Bundle-RequiredExecutionEnvironment: J2SE-1.4 >Index: src/org/eclipse/tptp/platform/probekit/launch/internal/wizard/CustomBase64Encoder.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.probekit.launch/src/org/eclipse/tptp/platform/probekit/launch/internal/wizard/CustomBase64Encoder.java,v >retrieving revision 1.1 >diff -u -r1.1 CustomBase64Encoder.java >--- src/org/eclipse/tptp/platform/probekit/launch/internal/wizard/CustomBase64Encoder.java 16 Mar 2006 15:56:15 -0000 1.1 >+++ src/org/eclipse/tptp/platform/probekit/launch/internal/wizard/CustomBase64Encoder.java 25 Apr 2007 21:10:13 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2006 IBM Corporation and others. >+ * Copyright (c) 2006, 2007 IBM Corporation and others. > * 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 >@@ -7,7 +7,7 @@ > * $Id: CustomBase64Encoder.java,v 1.1 2006/03/16 15:56:15 popescu Exp $ > * > * Contributors: >- * IBM - Initial API and implementation >+ * IBM and OCSystems - Initial API and implementation > **********************************************************************/ > package org.eclipse.tptp.platform.probekit.launch.internal.wizard; > >@@ -15,8 +15,9 @@ > * This utility class converts a passed byte array into a Base 64 encoded > * String according to the specification in RFC1521 section 5.2 > * See also org.eclipse.ui.wizards.datatransfer.CustomBase64Encoder. >+ * Class made public from package-private for enhancement 141540 > */ >-/*package*/ class CustomBase64Encoder { >+public class CustomBase64Encoder { > private static final String mappings = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";//$NON-NLS-1$ > private static final String filler = "=";//$NON-NLS-1$ > /** >Index: src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadUtils.java >=================================================================== >RCS file: src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadUtils.java >diff -N src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadUtils.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadUtils.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,61 @@ >+/********************************************************************** >+ * Copyright (c) 2004, 2007 IBM Corporation and others. >+ * 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: >+ * IBM and OCSystems- Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.tptp.platform.probekit.launch.launchpad; >+ >+import java.io.File; >+ >+import org.eclipse.tptp.platform.probekit.util.ProbekitConstants; >+import org.eclipse.tptp.platform.probekit.util.ProbekitDebugConfig; >+ >+/** >+ * A Utility class for the shared methods applicable to both the >+ * JVMPI and JVMTI implementations of the probekit >+ * Launch Pads. All code taken from LaunchPad.java >+ * @author Liz Dancy >+ * >+ */ >+public class LaunchPadUtils >+{ >+ >+ /** >+ * A simple tracing method to print errors >+ * @param message >+ */ >+ static void trace(String message) >+ { >+ if ( ProbekitDebugConfig.TRACE_LAUNCHPAD && message != null && >+ message.length() > 0) { >+ System.out.println("ProbeLaunchPad: " + message); >+ } >+ } >+ >+ /** >+ * A simple helper method to determine whether the file in question is >+ * a class file. We use this as a filter to make sure we only deploy the >+ * .class probe files >+ * @param file The given file >+ * @return true if the file is a class file and false otherwise >+ */ >+ public static boolean isClass(File file) >+ { >+ if(file.getName().endsWith(ProbekitConstants.CLASS_FILE_EXT)) >+ { >+ return true; >+ } >+ else >+ { >+ return false; >+ } >+ } >+ >+ >+} >Index: src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadJVMTI.java >=================================================================== >RCS file: src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadJVMTI.java >diff -N src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadJVMTI.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadJVMTI.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,319 @@ >+/********************************************************************** >+ * Copyright (c) 2007 IBM Corporation and others. >+ * 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: >+ * IBM and OCSystems- Initial API and implementation >+ **********************************************************************/ >+ >+ >+package org.eclipse.tptp.platform.probekit.launch.launchpad; >+ >+import java.io.BufferedWriter; >+import java.io.DataInputStream; >+import java.io.File; >+import java.io.FileInputStream; >+import java.io.FileNotFoundException; >+import java.io.FileWriter; >+import java.io.IOException; >+import java.nio.ByteBuffer; >+import java.util.Iterator; >+import java.util.Map; >+import java.util.Set; >+import java.util.Vector; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.hyades.models.hierarchy.TRCAgentProxy; >+import org.eclipse.tptp.platform.execution.client.agent.IAgent; >+import org.eclipse.tptp.platform.execution.client.agent.ICollector; >+import org.eclipse.tptp.platform.execution.client.core.INode; >+import org.eclipse.tptp.platform.execution.util.ICommandElement; >+import org.eclipse.tptp.platform.execution.util.ICommandHandler; >+import org.eclipse.tptp.platform.execution.util.internal.CommandFragment; >+import org.eclipse.tptp.platform.probekit.launch.internal.wizard.CustomBase64Encoder; >+import org.eclipse.tptp.platform.probekit.registry.ProbeRegistry; >+import org.eclipse.tptp.platform.probekit.registry.ProbeRegistryEntry; >+import org.eclipse.tptp.platform.probekit.util.InvalidProbeBundleException; >+import org.eclipse.tptp.platform.probekit.util.ProbeLaunchConfigString; >+import org.eclipse.tptp.platform.probekit.util.ProbekitConstants; >+import org.eclipse.tptp.platform.probekit.util.ProbekitDebugConfig; >+/** >+ * This class replaces LaunchPad.java for the JVMTI implementation >+ * of probekit profiling. After the agent attaches but before it calls >+ * RESUME there is a small window of time in which we can send Commands to >+ * the agent. This class is invoked during that time from the agentActive >+ * call to the ProbeControlListener, notified at the start of this crucial >+ * time. >+ * >+ * This class is used to first retrieve the ProbeID information stored >+ * as an attribute in the LaunchConfiguration which is passed in to >+ * agentActive. Once we have the ProbeIDs of all the selected probes, we >+ * can look up the probe information for these probes stored in the >+ * Probe Registry. >+ * >+ * Upon retrieving the registry entry, we have to wrap the class file >+ * and probescript information as a String using a Base64 encoder so that it >+ * can be sent as the commandData in the new execution framework >+ * command protocol. >+ * >+ * The command creation and invocation of agent.sendCommand happens during >+ * deployClasses() which uses the agent passed in to send a command >+ * containing all of the necessary probe file information to the agent. >+ * >+ * @author Liz Dancy >+ */ >+public class LaunchPadJVMTI >+ >+{ >+ /* The active agent which is being used to send Commands */ >+ private ICollector agent; >+ /* The encoding to use */ >+ private static final String ENCODING_NAME_UTF8 = "UTF-8"; >+ >+ /** >+ * >+ * @param currentAgent >+ * @param config >+ * @throws CoreException >+ * @throws LaunchPadException >+ */ >+ public void agentActive(ICollector currentAgent, ILaunchConfiguration config) throws CoreException, LaunchPadException >+ { >+ { >+ agent= currentAgent; >+ if(agent == null) >+ // if the agent is null we want to stop right away >+ { >+ throw new LaunchPadException("Agent not found"); >+ } >+ >+ String probeID; >+ ProbeRegistry registry = ProbeRegistry.getRegistry(); >+ Map m = config.getAttributes(); >+ >+ // Extract the stuff we need to launch a probe from the configuration: >+ // Right now we need the probe filter list and probe registry ID. >+ String key = " "; >+ >+ Set keys = m.keySet(); >+ Iterator iter = keys.iterator(); >+ while (iter.hasNext()){ >+ >+ key = (String)iter.next(); >+ >+ // We are looking for this key: org.eclipse.tptp.platform.probekit.Probespec >+ // Initially when we stored the attributes we stored each selected probe as a >+ // String with this key as the prefix >+ if(!key.startsWith(ProbeLaunchConfigString.AGENT_CONFIG_NAME_PREFIX)) >+ { >+ continue; >+ } >+ Object value = m.get((Object)key); >+ String probeFilters; >+ ProbeLaunchConfigString probeConfig = ProbeLaunchConfigString.fromString(value.toString()); >+ >+ if(probeConfig.getType() == ProbeLaunchConfigString.TYPE_REGISTRY_ID) >+ { >+ probeID = probeConfig.getRegistryId(); >+ ProbeRegistryEntry registryEntry = registry.lookupById(probeID); >+ if(null != registryEntry) >+ { >+ deployProbe(registryEntry); >+ } >+ } >+ } >+ } >+ >+}// end method >+ /** >+ * Depolys a probe given a probe registry entry. >+ * This method is usually called when somebody configures an application >+ * to be launched with probes. It can be called more than once if several >+ * probes were selected from the registry in the launch configuration. >+ * >+ * The right invokation point is the AgentActive callback (after the >+ * agent was activated but before it processed the resume command. >+ * >+ * @param probeRegistryEntry - Probe Registry Entry >+ * @throws LaunchPadException - Launchpad Exception >+ * >+ */ >+ public void deployProbe(ProbeRegistryEntry probeRegistryEntry) throws LaunchPadException >+ { >+ try { >+ //final String [] probeClassPath = new String [probeRegistryEntry.getFiles().length + 1];// used to hold the absolute path of the probe files >+ Vector classPathVector = new Vector(); >+ File probeScript = probeRegistryEntry.getProbescript(); >+ File probeFiles[] = probeRegistryEntry.getFiles(); >+ String probeScriptPath = probeScript.getAbsolutePath(); >+ classPathVector.add(probeScriptPath); >+ // add the probe script path first >+ >+ for(int i = 0; i < probeFiles.length; i++) >+ { >+ if(LaunchPadUtils.isClass(probeFiles[i])) >+ // then we want to add the classPath to probeClassPath >+ // so that we have the probescript followed by >+ // the probe class >+ // followed by the second class file >+ { >+ String filePath = ((File)probeFiles[i]).getAbsolutePath(); >+ classPathVector.add(filePath); >+ >+ } >+ >+ } >+ prepareFileArrays(classPathVector.toArray(), agent); >+ } >+ catch (InvalidProbeBundleException ex) >+ { >+ LaunchPadUtils.trace("InvalidProbeBundleException in deployProbe()"); >+ throw new LaunchPadException("Invalid registry entry:" + probeRegistryEntry.getId()); >+ } >+ } >+ >+ >+ >+ /** >+ * This method is used to read in the class files and create two >+ * arrays, one of the class files themselves and one of the file names >+ * to pass to the method which sends the probekit commands to the agent >+ */ >+ >+ public void prepareFileArrays(Object [] probeClassPath, ICollector agent) >+ { >+ try{ >+ Vector classNames = new Vector(); >+ Vector bytes = new Vector(); >+ >+ for (int i=0; i< probeClassPath.length; i++) >+ { >+ if (probeClassPath[i] instanceof String){ >+ String path = (String) probeClassPath[i]; >+ // and all of the entries in probeClassPath should be Strings >+ File f = new File(path); >+ classNames.add(f.getName().replaceAll(".class$", " ")); >+ bytes.add(readFileIntoBuffer(f)); >+ } >+ } >+ >+ >+ deployProbeClasses(bytes, classNames, agent); >+ } >+ catch(FileNotFoundException e) >+ { >+ // could be missing or invalid probes? >+ } >+ catch(IOException e){ >+ // IOException reading in file >+ } >+ }// end method >+ >+ /** >+ * A helper method to read a file into a buffer and produce an >+ * array of bytes >+ * @param file The give file >+ * @return >+ * @throws FileNotFoundException >+ * @throws IOException >+ */ >+ private static byte[] readFileIntoBuffer(File file) throws FileNotFoundException, IOException >+ { >+ FileInputStream fs; >+ byte buffer[]; >+ >+ fs = new FileInputStream(file); >+ DataInputStream probeStream = new DataInputStream(fs); >+ try { >+ int bufferSize = (int)file.length(); >+ buffer = new byte[bufferSize]; >+ probeStream.read(buffer); >+ } finally { >+ probeStream.close(); >+ } >+ return buffer; >+ } >+ >+ >+ public static void deployProbeClasses(Vector bytes, Vector classNames, IAgent agent) >+ { >+ try >+ { >+ int count = 4; // magic >+ for (int i = 0; i < bytes.size(); i++) >+ { >+ String className = (String)classNames.get(i); >+ byte[] classBytes =(byte[]) bytes.get(i); >+ byte classNameBytes[] = className.getBytes(ENCODING_NAME_UTF8); >+ count += 4 + classNameBytes.length + 4 + classBytes.length; >+ } >+ >+ // Allocate buffer >+ ByteBuffer buffer = ByteBuffer.allocate(count); // tmp >+ buffer.putInt(0xDECAECC0); >+ >+ for (int i = 0; i < bytes.size(); i++) >+ { >+ String className = (String)classNames.get(i); >+ byte[] classBytes =(byte[]) bytes.get(i); >+ byte classNameBytes[] = className.getBytes(ENCODING_NAME_UTF8); >+ /* >+ int commandSize =4 + // magic >+ 4 + // className length >+ classNameBytes.length + >+ 4 + // class size >+ classBytes.length >+ ; >+ */ >+ >+ // Populate buffer with data >+ buffer.putInt(classNameBytes.length).put(classNameBytes); >+ buffer.putInt(classBytes.length).put(classBytes); >+ } >+ >+ // Prepare RAC command >+ String commandData = new CustomBase64Encoder().encode(buffer.array()); >+ /// >+ try { >+ BufferedWriter out = new BufferedWriter(new FileWriter("C:/fileWriter2.txt")); >+ out.write(commandData); >+ out.close(); >+ } >+ catch (IOException e) >+ { >+ >+ } >+ /// >+ >+ CommandFragment command = new CommandFragment(); >+ command.setCommand( >+ "<applyOptions iid='org.eclipse.tptp.jvmti'>" + >+ "<option><name>PROBEKIT_CLASS</name>" + >+ "<value>" + commandData + "</value><option></applyOptions>"); >+ >+ // Invoke RAC command- this is using the new sendCommand from the new execution framework >+ agent.sendCommand(command.buildCommand(), new ICommandHandler() { >+ public void incomingCommand(INode node, ICommandElement element) >+ { >+ //Handler goes here >+ } >+ } >+ ); >+ }// end try >+ catch (Exception e) >+ { >+ System.out.println(e.getMessage() + "is the error message"); >+ } >+ }// end method deployProbeClasses >+}// end class >+ >+ >+ >+ >+ >+ >+
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