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

Collapse All | Expand All

(-).classpath (-12 / +3 lines)
Lines 1-16 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src">
3
	<classpathentry kind="src" path="src"/>
4
		<attributes>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
		</attributes>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	</classpathentry>
7
	<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
8
		<attributes>
9
		</attributes>
10
	</classpathentry>
11
	<classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins">
12
		<attributes>
13
		</attributes>
14
	</classpathentry>
15
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
16
</classpath>
7
</classpath>
(-)src/org/eclipse/tptp/platform/jvmti/client/internal/launcher/TIDelegateHelper.java (-3 / +28 lines)
Lines 13-18 Link Here
13
import java.net.InetAddress;
13
import java.net.InetAddress;
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Hashtable;
15
import java.util.Hashtable;
16
import java.util.Iterator;
16
import java.util.List;
17
import java.util.List;
17
18
18
import org.eclipse.core.resources.IContainer;
19
import org.eclipse.core.resources.IContainer;
Lines 26-31 Link Here
26
import org.eclipse.debug.core.ILaunchConfiguration;
27
import org.eclipse.debug.core.ILaunchConfiguration;
27
import org.eclipse.emf.common.util.EList;
28
import org.eclipse.emf.common.util.EList;
28
import org.eclipse.emf.common.util.URI;
29
import org.eclipse.emf.common.util.URI;
30
31
import org.eclipse.hyades.internal.execution.local.control.AgentConfiguration;
29
import org.eclipse.hyades.loaders.util.LoadersUtils;
32
import org.eclipse.hyades.loaders.util.LoadersUtils;
30
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy;
33
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy;
31
import org.eclipse.hyades.models.hierarchy.TRCCollectionMode;
34
import org.eclipse.hyades.models.hierarchy.TRCCollectionMode;
Lines 156-161 Link Here
156
	/** The JVM argument used to launch a Java application with the JVMTI THREAD flag */
159
	/** The JVM argument used to launch a Java application with the JVMTI THREAD flag */
157
	protected static final String TI_THRD_JVM_FLAG = "-agentlib:JPIBootLoader=JPIAgent:server=controlled;ThreadProf";
160
	protected static final String TI_THRD_JVM_FLAG = "-agentlib:JPIBootLoader=JPIAgent:server=controlled;ThreadProf";
158
	
161
	
162
	/** The JVM argument used to launch a Java application with the JVMTI PROBE flag */
163
	protected static final String TI_PROBE_JVM_FLAG = "-agentlib:JPIBootLoader=JPIAgent:server=controlled;ProbekitAgent:ext-pk-BCILibraryName=BCIEngProbe";
164
	
159
	/** The JVM argument used to launch a Java application with the JVMTI flag */
165
	/** The JVM argument used to launch a Java application with the JVMTI flag */
160
	protected static String TI_JVM_FLAG = TI_CGPROF_JVM_FLAG;
166
	protected static String TI_JVM_FLAG = TI_CGPROF_JVM_FLAG;
161
	
167
	
Lines 205-213 Link Here
205
		isCGProf = true;
211
		isCGProf = true;
206
		for (int i = 0; i < mapsize; i++)
212
		for (int i = 0; i < mapsize; i++)
207
		{
213
		{
214
		
208
		  java.util.Map.Entry entry = (java.util.Map.Entry) keyValuePairs.next();
215
		  java.util.Map.Entry entry = (java.util.Map.Entry) keyValuePairs.next();
209
		  Object key = entry.getKey();
216
		  Object key = entry.getKey();
210
		  Object value = entry.getValue();
217
		  Object value = entry.getValue();
218
		  addOption(new StringBuffer(), key.toString(), value.toString());
211
		  
219
		  
212
		  //defaults to call graph profiler 
220
		  //defaults to call graph profiler 
213
		  TI_JVM_FLAG = TI_CGPROF_JVM_FLAG;
221
		  TI_JVM_FLAG = TI_CGPROF_JVM_FLAG;
Lines 235-240 Link Here
235
				isCGProf = false;
243
				isCGProf = false;
236
				break;
244
				break;
237
			}
245
			}
246
			// added for enhancement 141540
247
			// Liz Dancy
248
			if(value.toString().indexOf("probe") != -1)
249
			{
250
				TI_JVM_FLAG = TI_PROBE_JVM_FLAG;
251
				//TODO: call getJVM arguments to add helper classes
252
				isCGProf = false;
253
				break;
254
			}
238
		  }
255
		  }
239
		}
256
		}
240
		//If it is not Heap or thread check for the CGProf Alloc execdetails true
257
		//If it is not Heap or thread check for the CGProf Alloc execdetails true
Lines 468-480 Link Here
468
				return null;
485
				return null;
469
			}
486
			}
470
			
487
			
488
			/*Add a listener which can potentially give control to probekit to send probe files*/
489
						
490
			// added for enhancement 141540
491
			
492
			
493
			
494
			ProbeControlListener probeController = new ProbeControlListener(launchConfiguration);
495
			tiAgent.addAgentListener(probeController);
496
			
471
			/* Start Monitoring */
497
			/* Start Monitoring */
472
			tiAgent.startMonitoring(TPTPDataPath.DATA_PATH_TWO_WAY);
498
			tiAgent.startMonitoring(TPTPDataPath.DATA_PATH_TWO_WAY);
473
			
499
			
474
			
475
			/* Create the model entities */
500
			/* Create the model entities */
476
			TRCAgentProxy tiAgentProxy = agentProxy == null ? createModelEntities(launchConfiguration, agentController, process, tiAgent) : createModelEntities(agentProxy, agentController, process, tiAgent);
501
			
477
					
502
			TRCAgentProxy tiAgentProxy = agentProxy == null ? createModelEntities(launchConfiguration, agentController, process, tiAgent) : createModelEntities(agentProxy, agentController, process, tiAgent);	
478
			
503
			
479
			final TRCAgentProxy trcAgentProxy = tiAgentProxy; 			
504
			final TRCAgentProxy trcAgentProxy = tiAgentProxy; 			
480
			
505
			
(-)src/org/eclipse/tptp/platform/jvmti/client/internal/analysistypes/TIProbeInsertionAnalysisUI.java (-8 / +36 lines)
Lines 71-76 Link Here
71
						probe.addProbeID(strValueID);
71
						probe.addProbeID(strValueID);
72
						if (items[i].getChecked()) 
72
						if (items[i].getChecked()) 
73
						{
73
						{
74
							String attributeKey = ProbeLaunchConfigString.AGENT_CONFIG_NAME_PREFIX + probeUI.PROBE_LAUNCH_UNIQUE_PROBESPEC_SUFFIX;
75
							
74
							boolean bMatchingSetFound = false;
76
							boolean bMatchingSetFound = false;
75
							FilterSetElement set = probeUI.getManager()
77
							FilterSetElement set = probeUI.getManager()
76
									.getDefaultFilterSet();
78
									.getDefaultFilterSet();
Lines 109-119 Link Here
109
									+ probeUI.PROBE_LAUNCH_UNIQUE_PROBESPEC_SUFFIX
111
									+ probeUI.PROBE_LAUNCH_UNIQUE_PROBESPEC_SUFFIX
110
									+ iCheckedCount;
112
									+ iCheckedCount;
111
							String strValueProbeLaunch = probe.toString();
113
							String strValueProbeLaunch = probe.toString();
114
							
115
							
112
116
113
							DataCollectionEngineAttribute attributeProbe = new DataCollectionEngineAttribute(
117
							DataCollectionEngineAttribute attributeProbe = new DataCollectionEngineAttribute(
114
									strName, strValueProbeLaunch);
118
									strName, strValueProbeLaunch);
115
							
119
							
116
							attributes.add(attributeProbe);
120
							attributes.add(attributeProbe);
121
							System.out.println("adding " + strName + " " + strValueProbeLaunch);
117
122
118
							iCheckedCount++;
123
							iCheckedCount++;
119
						}
124
						}
Lines 123-128 Link Here
123
		}
128
		}
124
			return attributes;
129
			return attributes;
125
	}
130
	}
131
			
126
				/**
132
				/**
127
			 * Here we set our own attributes to keep track of whether or not the
133
			 * Here we set our own attributes to keep track of whether or not the
128
			 * launch configuration was valid upon exiting the Edit Options
134
			 * launch configuration was valid upon exiting the Edit Options
Lines 132-152 Link Here
132
			 */
138
			 */
133
			public boolean storeAttributes (ILaunchConfigurationWorkingCopy configurationWC)
139
			public boolean storeAttributes (ILaunchConfigurationWorkingCopy configurationWC)
134
			{
140
			{
141
				Vector attributes = new Vector();
142
				int iCheckedCount = 0;
135
				boolean probesSelected = false;
143
				boolean probesSelected = false;
136
				int iSelectedProbes = 0;
144
				int iSelectedProbes = 0;
137
				int iAvailableProbes = probeUI.getProbeSets().getItemCount();
145
				int iAvailableProbes = probeUI.getProbeSets().getItemCount();
138
				List namesOfSelected = null ;
146
				List namesOfSelected = null ;
139
				if (iAvailableProbes > 0)
147
				if (probeUI.getProbeSets()!=null &&! probeUI.getProbeSets().isDisposed())
148
				{
149
				int iNumProbeSets = probeUI.getProbeSets().getItemCount();
150
				if (iNumProbeSets > 0 && iAvailableProbes >0) 
140
				{
151
				{
141
					TableItem[] items = probeUI.getProbeSets().getItems();
152
					TableItem[] items = probeUI.getProbeSets().getItems();
142
					for (int i = 0; i < iAvailableProbes; i++) 
153
					for (int i = 0; i < iNumProbeSets; i++) 
143
					{
154
					{
144
						if (items[i].getChecked()) 
155
						ProbeRegistryEntry entry = (ProbeRegistryEntry) items[i]
156
								.getData();
157
						if (entry != null) 
145
						{
158
						{
146
							iSelectedProbes++;
159
							String strValueID = entry.getId();
147
						}
160
							ProbeLaunchConfigString probe = new ProbeLaunchConfigString();
148
					}
161
							probe.addProbeID(strValueID);
149
				}
162
							if (items[i].getChecked()) 
163
							{
164
								String attributeKey = ProbeLaunchConfigString.AGENT_CONFIG_NAME_PREFIX + probeUI.PROBE_LAUNCH_UNIQUE_PROBESPEC_SUFFIX;
165
								configurationWC.setAttribute(attributeKey, probe.toString());
166
								System.out.println("adding in save " + probe.toString() + attributeKey);
167
								iSelectedProbes++;
168
							}
169
				
170
				
150
				if (iAvailableProbes == 0 || iSelectedProbes == 0) 
171
				if (iAvailableProbes == 0 || iSelectedProbes == 0) 
151
				{
172
				{
152
					// create a new attribute to keep track of whether any probes have 
173
					// create a new attribute to keep track of whether any probes have 
Lines 160-166 Link Here
160
					// and an approprite error message will be displayed
181
					// and an approprite error message will be displayed
161
					configurationWC.setAttribute("anyProbesSelected", true);
182
					configurationWC.setAttribute("anyProbesSelected", true);
162
					configurationWC.setAttribute("saved", true);
183
					configurationWC.setAttribute("saved", true);
163
					configurationWC.setAttribute("selectedItems",namesOfSelected );
184
					configurationWC.setAttribute("probeLaunch",true );
185
					
164
					probesSelected = true;
186
					probesSelected = true;
165
				}
187
				}
166
				probeUI.saveSelections();
188
				probeUI.saveSelections();
Lines 170-174 Link Here
170
			
192
			
171
				
193
				
172
		}
194
		}
195
				}
196
				}
197
		
198
			return true;
199
			}	
200
	}
173
	
201
	
174
	
202
	
(-)src/org/eclipse/tptp/platform/jvmti/client/internal/analysistypes/TIProbeInsertionConfPage.java (-1 / +2 lines)
Lines 107-113 Link Here
107
		 */
107
		 */
108
		public boolean storeAttributes(ILaunchConfigurationWorkingCopy configurationWC)
108
		public boolean storeAttributes(ILaunchConfigurationWorkingCopy configurationWC)
109
		{
109
		{
110
			
110
		
111
			return pr.storeAttributes(configurationWC);    
111
			return pr.storeAttributes(configurationWC);    
112
		}
112
		}
113
		/**
113
		/**
Lines 115-120 Link Here
115
		 */
115
		 */
116
		public Vector getAttributes()
116
		public Vector getAttributes()
117
		{
117
		{
118
			
118
			return pr.getAttributes();
119
			return pr.getAttributes();
119
		}
120
		}
120
121
(-)src/org/eclipse/tptp/platform/jvmti/client/internal/launcher/ProbeControlListener.java (+163 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2007 IBM Corporation.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.platform.jvmti.client.internal.launcher;
12
13
import java.util.HashMap;
14
import java.util.Map;
15
16
import org.eclipse.core.runtime.IConfigurationElement;
17
import org.eclipse.core.runtime.IExtensionPoint;
18
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.core.runtime.Status;
21
import org.eclipse.debug.core.ILaunchConfiguration;
22
import org.eclipse.hyades.loaders.util.LoadersUtils;
23
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy;
24
import org.eclipse.hyades.trace.ui.UIPlugin;
25
import org.eclipse.hyades.trace.ui.internal.launcher.IProfileLaunchConfigurationConstants;
26
import org.eclipse.hyades.trace.ui.launcher.ILauncherHandler;
27
import org.eclipse.tptp.platform.execution.client.agent.IAgent;
28
import org.eclipse.tptp.platform.execution.client.agent.IAgentListener;
29
import org.eclipse.tptp.platform.probekit.launch.launchpad.LaunchPadExtensionSlot;
30
/**
31
 * A listener class which waits for the AgentActive signal from the
32
 * monitored agent. Before the RESUME command is sent, we want to
33
 * give control to the Probekit Launcher so that the probe script
34
 * and probe class files can be sent. Once they are sent, RESUME is
35
 * called and the agent can run.
36
 * 
37
 * @author Liz Dancy
38
 *
39
 */
40
public class ProbeControlListener implements IAgentListener
41
{
42
	IAgent controlAgent =null;
43
	Map launcherHandlers;
44
	ILaunchConfiguration config;
45
	
46
	
47
	//necessary in order to retrieve the LauncherHandlers so we
48
	//can identify the probekit launchpad and give it control
49
	
50
	public ProbeControlListener( ILaunchConfiguration callingConfiguration)
51
	{
52
		config =callingConfiguration;
53
	
54
	}
55
	public void error(IAgent agent, String errorMessage)
56
	{
57
		//ignore for now
58
		//TODO
59
	}
60
	
61
	/**
62
	 * Called when an agent startsMonitoring
63
	 * This is a crucial time to give Control to probekit
64
	 * so that it can send its commands.
65
	 * Therefore, we use this notification to pass Control
66
	 * to the Probekit LaunchPad to send the necessary files beore the agent
67
	 * in question resumes.
68
	 */
69
	public void agentActive(IAgent agent)
70
	{
71
		try
72
		{
73
			String launchItemSelections = config.getAttribute(IProfileLaunchConfigurationConstants.ATTR_PROFILING_COLLECTOR_AND_ANALYSIS, (String)null);
74
			// we do not want to giveControl to the probekit if this type of analysis
75
			// has not been selected
76
			if (launchItemSelections.contains("org.eclipse.tptp.analysisType.jvmti.probe"))
77
			{
78
				initializeLauncherHandlers();
79
				Object[] launcherHandlersArray = launcherHandlers.values().toArray();
80
				LoadersUtils ld = new LoadersUtils();
81
    	
82
				for (int num = 0; num < launcherHandlersArray.length; num++)
83
				{
84
					ILauncherHandler type = (ILauncherHandler)launcherHandlersArray[num];
85
    		
86
					if (type instanceof org.eclipse.tptp.platform.probekit.launch.launchpad.LaunchPadExtensionSlot)
87
					{
88
						LaunchPadExtensionSlot extension = new LaunchPadExtensionSlot();
89
						extension.handlePreAgentActiveJVMTI(agent, config);
90
					}
91
					else
92
					{
93
						//inactive
94
						//TODO: implement the agent callback when it is inactive
95
					}
96
				}// end for
97
			}
98
		}
99
    	catch (Exception e)
100
		{
101
    		if(e.getMessage() != null)
102
    		{
103
    			IStatus status = new Status(IStatus.ERROR,UIPlugin.getPluginId(),IStatus.ERROR,e.getMessage(),e);
104
        		UIPlugin.getDefault().getLog().log(status);    				
105
    		}
106
    			//quietly catch any exceptions
107
    			//and ignore them
108
		}
109
	}
110
	/**
111
	 * Invoked when an agent becomes inactive.
112
	 * @param Agent
113
	 */
114
	public void agentInactive(IAgent agent)
115
	{
116
		//ignore for now
117
	}
118
	
119
	
120
	private void initializeLauncherHandlers()
121
    {
122
    	//reads the extension points, and creates instances of the GetControlType objects
123
    	//specified by the class attribute
124
		//taken from initializeLaunchHandlers in org.eclipse.hyades.trace.ui.internal.piclient.PIProcessListener
125
    	
126
		launcherHandlers = new HashMap();
127
		
128
		IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(UIPlugin.PLUGIN_ID, "launcherHandler");
129
130
		if (point != null) {
131
			IConfigurationElement[] elements = point.getConfigurationElements();
132
			for (int i = 0; i < elements.length; i++) {
133
				
134
				IConfigurationElement elem = elements[i];
135
136
				String id = elem.getAttribute("id");								
137
138
				ILauncherHandler getControlType = null;
139
				try
140
				{
141
					getControlType = (ILauncherHandler)elem.createExecutableExtension("class");
142
				}
143
				catch (Exception e)
144
				{
145
	    			if(e.getMessage() != null)
146
	    			{
147
	    				IStatus status = new Status(IStatus.ERROR,UIPlugin.getPluginId(),IStatus.ERROR,e.getMessage(),e);
148
	        			UIPlugin.getDefault().getLog().log(status);    				
149
	    			}
150
					
151
					e.printStackTrace();
152
				}
153
				
154
				if(getControlType != null)			
155
				{
156
					//put the instace of the class in a map
157
					launcherHandlers.put(id, getControlType);					
158
				}
159
			}
160
		}
161
    }
162
	
163
}
(-)src/org/eclipse/tptp/platform/probekit/launch/internal/ProbekitLaunchImages.java (+1 lines)
Lines 13-18 Link Here
13
13
14
import org.eclipse.hyades.ui.internal.util.ImageManager;
14
import org.eclipse.hyades.ui.internal.util.ImageManager;
15
15
16
16
/**
17
/**
17
 * Image manager for the Probekit Launch plugin.
18
 * Image manager for the Probekit Launch plugin.
18
 */
19
 */
(-)src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPad.java (-1 / +4 lines)
Lines 1-5 Link Here
1
/********************************************************************** 
1
/********************************************************************** 
2
 * Copyright (c) 2004, 2006 IBM Corporation and others. 
2
 * Copyright (c) 2004, 2007 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
5
 * which accompanies this distribution, and is available at 
Lines 801-817 Link Here
801
			
801
			
802
			String configName = config.getName();
802
			String configName = config.getName();
803
			EList options = config.getOptions();
803
			EList options = config.getOptions();
804
			
804
			Iterator itrOptions = options.iterator();
805
			Iterator itrOptions = options.iterator();
805
			
806
			
806
			while(itrOptions.hasNext())
807
			while(itrOptions.hasNext())
807
			{
808
			{
808
				TRCOption option = (TRCOption) itrOptions.next(); 
809
				TRCOption option = (TRCOption) itrOptions.next(); 
809
				String key = option.getKey();
810
				String key = option.getKey();
811
				
810
				if(!key.startsWith(ProbeLaunchConfigString.AGENT_CONFIG_NAME_PREFIX))
812
				if(!key.startsWith(ProbeLaunchConfigString.AGENT_CONFIG_NAME_PREFIX))
811
				{
813
				{
812
					continue;
814
					continue;
813
				}
815
				}
814
				String value = option.getValue();
816
				String value = option.getValue();
817
				
815
				String probeFilters;
818
				String probeFilters;
816
				ProbeLaunchConfigString probeConfig = ProbeLaunchConfigString.fromString(value);
819
				ProbeLaunchConfigString probeConfig = ProbeLaunchConfigString.fromString(value);
817
820
(-)src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadExtensionSlot.java (-2 / +21 lines)
Lines 1-5 Link Here
1
/********************************************************************** 
1
/********************************************************************** 
2
 * Copyright (c) 2004, 2006 IBM Corporation and others. 
2
 * Copyright (c) 2004, 2007 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
5
 * which accompanies this distribution, and is available at 
Lines 23-31 Link Here
23
 */
23
 */
24
package org.eclipse.tptp.platform.probekit.launch.launchpad;
24
package org.eclipse.tptp.platform.probekit.launch.launchpad;
25
25
26
import org.eclipse.core.runtime.CoreException;
27
import org.eclipse.debug.core.ILaunchConfiguration;
26
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy;
28
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy;
27
import org.eclipse.hyades.models.hierarchy.TRCProcessProxy;
29
import org.eclipse.hyades.models.hierarchy.TRCProcessProxy;
28
import org.eclipse.hyades.trace.ui.launcher.ILauncherHandler;
30
import org.eclipse.hyades.trace.ui.launcher.ILauncherHandler;
31
import org.eclipse.tptp.platform.execution.client.agent.IAgent;
32
import org.eclipse.tptp.platform.execution.client.agent.ICollector;
29
33
30
34
31
/**
35
/**
Lines 74-80 Link Here
74
		}
78
		}
75
	}
79
	}
76
80
77
81
	/**
82
	 * In the case of the JVMTI Agent we pass in the
83
	 * entire agent. This method overload is due to the different command
84
	 * formates in the old and new execution frameworks
85
	 * requiring different flows of control through the
86
	 * LaunchPad.
87
	 * 
88
	 * Created April, 2007
89
	 * @param agent
90
	 */
91
	public void handlePreAgentActiveJVMTI(IAgent agent, ILaunchConfiguration config)throws CoreException, LaunchPadException{
92
		
93
			LaunchPadJVMTI launchPad = new LaunchPadJVMTI();
94
			launchPad.agentActive((ICollector)agent, config);
95
		}
96
	
78
	/* (non-Javadoc)
97
	/* (non-Javadoc)
79
	 * @see org.eclipse.hyades.trace.ui.launcher.ILauncherHandler#handlePostAgentActive(org.eclipse.hyades.models.hierarchy.TRCAgentProxy)
98
	 * @see org.eclipse.hyades.trace.ui.launcher.ILauncherHandler#handlePostAgentActive(org.eclipse.hyades.models.hierarchy.TRCAgentProxy)
80
	 */
99
	 */
(-)META-INF/MANIFEST.MF (-1 / +4 lines)
Lines 8-13 Link Here
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Export-Package: org.eclipse.tptp.platform.probekit.launch.internal,
9
Export-Package: org.eclipse.tptp.platform.probekit.launch.internal,
10
 org.eclipse.tptp.platform.probekit.launch.internal.config,
10
 org.eclipse.tptp.platform.probekit.launch.internal.config,
11
 org.eclipse.tptp.platform.probekit.launch.internal.wizard,
11
 org.eclipse.tptp.platform.probekit.launch.launchpad
12
 org.eclipse.tptp.platform.probekit.launch.launchpad
12
Require-Bundle: org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)",
13
Require-Bundle: org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)",
13
 org.eclipse.jface.text;bundle-version="[3.2.0,4.0.0)",
14
 org.eclipse.jface.text;bundle-version="[3.2.0,4.0.0)",
Lines 21-26 Link Here
21
 org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)",
22
 org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)",
22
 org.eclipse.hyades.probekit.ui;bundle-version="[4.0.0,5.0.0)",
23
 org.eclipse.hyades.probekit.ui;bundle-version="[4.0.0,5.0.0)",
23
 org.eclipse.hyades.probekit;bundle-version="[4.0.0,5.0.0)",
24
 org.eclipse.hyades.probekit;bundle-version="[4.0.0,5.0.0)",
24
 org.eclipse.tptp.platform.models;bundle-version="[4.0.0,5.0.0)"
25
 org.eclipse.tptp.platform.models;bundle-version="[4.0.0,5.0.0)",
26
 org.eclipse.hyades.execution.correlation,
27
 org.eclipse.tptp.platform.execution
25
Eclipse-LazyStart: true
28
Eclipse-LazyStart: true
26
Bundle-RequiredExecutionEnvironment: J2SE-1.4
29
Bundle-RequiredExecutionEnvironment: J2SE-1.4
(-)src/org/eclipse/tptp/platform/probekit/launch/internal/wizard/CustomBase64Encoder.java (-3 / +4 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-13 Link Here
7
 * $Id: CustomBase64Encoder.java,v 1.1 2006/03/16 15:56:15 popescu Exp $
7
 * $Id: CustomBase64Encoder.java,v 1.1 2006/03/16 15:56:15 popescu Exp $
8
 * 
8
 * 
9
 * Contributors: 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
10
 * IBM and OCSystems - Initial API and implementation
11
 **********************************************************************/ 
11
 **********************************************************************/ 
12
package org.eclipse.tptp.platform.probekit.launch.internal.wizard;
12
package org.eclipse.tptp.platform.probekit.launch.internal.wizard;
13
13
Lines 15-22 Link Here
15
 *	This utility class converts a passed byte array into a Base 64 encoded
15
 *	This utility class converts a passed byte array into a Base 64 encoded
16
 *	String according to the specification in RFC1521 section 5.2
16
 *	String according to the specification in RFC1521 section 5.2
17
 *  See also org.eclipse.ui.wizards.datatransfer.CustomBase64Encoder.
17
 *  See also org.eclipse.ui.wizards.datatransfer.CustomBase64Encoder.
18
 *  Class made public from package-private for enhancement 141540
18
 */
19
 */
19
/*package*/ class CustomBase64Encoder {
20
public class CustomBase64Encoder {
20
	private static final String mappings = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";//$NON-NLS-1$
21
	private static final String mappings = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";//$NON-NLS-1$
21
	private static final String filler = "=";//$NON-NLS-1$
22
	private static final String filler = "=";//$NON-NLS-1$
22
	/**
23
	/**
(-)src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadUtils.java (+61 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2004, 2007 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * 
8
 * Contributors: 
9
 * IBM and OCSystems- Initial API and implementation 
10
 **********************************************************************/ 
11
12
package org.eclipse.tptp.platform.probekit.launch.launchpad;
13
14
import java.io.File;
15
16
import org.eclipse.tptp.platform.probekit.util.ProbekitConstants;
17
import org.eclipse.tptp.platform.probekit.util.ProbekitDebugConfig;
18
19
/**
20
 * A Utility class for the shared methods applicable to both the
21
 * JVMPI and JVMTI implementations of the probekit
22
 * Launch Pads. All code taken from LaunchPad.java
23
 * @author Liz Dancy
24
 *
25
 */
26
public class LaunchPadUtils 
27
{
28
29
	/**
30
	 * A simple tracing method to print errors
31
	 * @param message
32
	 */
33
	static void trace(String message)
34
	{
35
		if ( ProbekitDebugConfig.TRACE_LAUNCHPAD && message != null &&
36
				message.length() > 0) {
37
			System.out.println("ProbeLaunchPad: " + message);
38
		}
39
	}
40
	
41
	/**
42
	 * A simple helper method to determine whether the file in question is
43
	 * a class file. We use this as a filter to make sure we only deploy the
44
	 * .class probe files
45
	 * @param file The given file
46
	 * @return true if the file is a class file and false otherwise
47
	 */
48
	public static boolean isClass(File file) 
49
	{
50
		if(file.getName().endsWith(ProbekitConstants.CLASS_FILE_EXT))
51
		{
52
			return true;
53
		}
54
		else
55
		{
56
			return false;
57
		}
58
	}
59
60
	
61
}
(-)src/org/eclipse/tptp/platform/probekit/launch/launchpad/LaunchPadJVMTI.java (+319 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2007 IBM Corporation and others. 
3
 * All rights reserved.   This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html         
7
 * 
8
 * Contributors: 
9
 * IBM and OCSystems- Initial API and implementation 
10
 **********************************************************************/ 
11
12
13
package org.eclipse.tptp.platform.probekit.launch.launchpad;
14
15
import java.io.BufferedWriter;
16
import java.io.DataInputStream;
17
import java.io.File;
18
import java.io.FileInputStream;
19
import java.io.FileNotFoundException;
20
import java.io.FileWriter;
21
import java.io.IOException;
22
import java.nio.ByteBuffer;
23
import java.util.Iterator;
24
import java.util.Map;
25
import java.util.Set;
26
import java.util.Vector;
27
28
import org.eclipse.core.runtime.CoreException;
29
import org.eclipse.debug.core.ILaunchConfiguration;
30
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy;
31
import org.eclipse.tptp.platform.execution.client.agent.IAgent;
32
import org.eclipse.tptp.platform.execution.client.agent.ICollector;
33
import org.eclipse.tptp.platform.execution.client.core.INode;
34
import org.eclipse.tptp.platform.execution.util.ICommandElement;
35
import org.eclipse.tptp.platform.execution.util.ICommandHandler;
36
import org.eclipse.tptp.platform.execution.util.internal.CommandFragment;
37
import org.eclipse.tptp.platform.probekit.launch.internal.wizard.CustomBase64Encoder;
38
import org.eclipse.tptp.platform.probekit.registry.ProbeRegistry;
39
import org.eclipse.tptp.platform.probekit.registry.ProbeRegistryEntry;
40
import org.eclipse.tptp.platform.probekit.util.InvalidProbeBundleException;
41
import org.eclipse.tptp.platform.probekit.util.ProbeLaunchConfigString;
42
import org.eclipse.tptp.platform.probekit.util.ProbekitConstants;
43
import org.eclipse.tptp.platform.probekit.util.ProbekitDebugConfig;
44
/**
45
 * This class replaces LaunchPad.java for the JVMTI implementation
46
 * of probekit profiling. After the agent attaches but before it calls
47
 * RESUME there is a small window of time in which we can send Commands to
48
 * the agent. This class is invoked during that time from the agentActive
49
 * call to the ProbeControlListener, notified at the start of this crucial
50
 * time.
51
 * 
52
 * This class is used to first retrieve the ProbeID information stored
53
 * as an attribute in the LaunchConfiguration which is passed in to
54
 * agentActive. Once we have the ProbeIDs of all the selected probes, we
55
 * can look up the probe information for these probes stored in the
56
 * Probe Registry.
57
 * 
58
 * Upon retrieving the registry entry, we have to wrap the class file
59
 * and probescript information as a String using a Base64 encoder so that it
60
 * can be sent as the commandData in the new execution framework
61
 * command protocol.
62
 * 
63
 * The command creation and invocation of agent.sendCommand happens during
64
 * deployClasses() which uses the agent passed in to send a command
65
 * containing all of the necessary probe file information to the agent.
66
 * 
67
 * @author Liz Dancy
68
 */
69
public class LaunchPadJVMTI 
70
71
{
72
	/* The active agent which is being used to send Commands */
73
	private ICollector agent;
74
	/* The encoding to use */
75
	private static final String ENCODING_NAME_UTF8 = "UTF-8";
76
	
77
	/**
78
	 * 
79
	 * @param currentAgent
80
	 * @param config
81
	 * @throws CoreException
82
	 * @throws LaunchPadException
83
	 */
84
	public void agentActive(ICollector currentAgent, ILaunchConfiguration config) throws CoreException, LaunchPadException
85
	{
86
		{
87
			agent= currentAgent;
88
			if(agent == null)
89
			// if the agent is null we want to stop right away
90
			{
91
				throw new LaunchPadException("Agent not found");
92
			}
93
			
94
			String probeID;
95
			ProbeRegistry registry = ProbeRegistry.getRegistry();
96
			Map m = config.getAttributes();
97
			
98
			// Extract the stuff we need to launch a probe from the configuration:
99
			// Right now we need the probe filter list and probe registry ID.
100
			String key = " ";
101
			
102
				Set keys = m.keySet();
103
					Iterator iter = keys.iterator();
104
					while (iter.hasNext()){
105
					
106
					 key = (String)iter.next();
107
					
108
					// We are looking for this key: org.eclipse.tptp.platform.probekit.Probespec
109
					// Initially when we stored the attributes we stored each selected probe as a
110
					// String with this key as the prefix
111
					if(!key.startsWith(ProbeLaunchConfigString.AGENT_CONFIG_NAME_PREFIX))
112
					{
113
						continue;
114
					}
115
			Object value = m.get((Object)key);
116
			String probeFilters;
117
			ProbeLaunchConfigString probeConfig = ProbeLaunchConfigString.fromString(value.toString());
118
			
119
			if(probeConfig.getType() == ProbeLaunchConfigString.TYPE_REGISTRY_ID)
120
			{
121
				probeID = probeConfig.getRegistryId();
122
				ProbeRegistryEntry registryEntry = registry.lookupById(probeID);
123
				if(null != registryEntry)
124
				{
125
					deployProbe(registryEntry);
126
				}
127
			}
128
		}
129
	}
130
	
131
}// end method
132
	/**
133
	 * Depolys a probe given a probe registry entry.
134
	 * This method is usually called when somebody configures an application
135
	 * to be launched with probes. It can be called more than once if several
136
	 * probes were selected from the registry in the launch configuration.
137
	 * 
138
	 * The right invokation point is the AgentActive callback (after the 
139
	 * agent was activated but before it processed the resume command.  
140
	 * 
141
	 * @param probeRegistryEntry - Probe Registry Entry
142
	 * @throws LaunchPadException - Launchpad Exception
143
	 * 
144
	 */
145
	public void deployProbe(ProbeRegistryEntry probeRegistryEntry) throws LaunchPadException
146
	{
147
		try {
148
			//final String [] probeClassPath = new String [probeRegistryEntry.getFiles().length + 1];// used to hold the absolute path of the probe files
149
			Vector classPathVector = new Vector();
150
			File probeScript = probeRegistryEntry.getProbescript();
151
			File probeFiles[] = probeRegistryEntry.getFiles();
152
			String probeScriptPath = probeScript.getAbsolutePath();
153
			classPathVector.add(probeScriptPath);
154
			// add the probe script path first
155
			
156
			for(int i = 0; i < probeFiles.length; i++)
157
			{
158
				if(LaunchPadUtils.isClass(probeFiles[i]))
159
					// then we want to add the classPath to probeClassPath
160
					// so that we have the probescript followed by
161
					// the probe class
162
					// followed by the second class file
163
				{
164
					String filePath = ((File)probeFiles[i]).getAbsolutePath();
165
					classPathVector.add(filePath);
166
					
167
				}
168
				
169
			}
170
			prepareFileArrays(classPathVector.toArray(), agent);
171
		} 
172
		catch (InvalidProbeBundleException ex)
173
		{
174
			LaunchPadUtils.trace("InvalidProbeBundleException in deployProbe()");
175
			throw new LaunchPadException("Invalid registry entry:" + probeRegistryEntry.getId());
176
		}
177
	}
178
	
179
180
	
181
	/**
182
	 * This method is used to read in the class files and create two
183
	 * arrays, one of the class files themselves and one of the file names
184
	 * to pass to the method which sends the probekit commands to the agent
185
	 */
186
	
187
	public void prepareFileArrays(Object [] probeClassPath, ICollector agent)
188
	{
189
		try{
190
			Vector classNames = new Vector();
191
			Vector bytes = new Vector();
192
			
193
			for (int i=0; i< probeClassPath.length; i++)
194
			{
195
				if (probeClassPath[i] instanceof String){
196
					String path = (String) probeClassPath[i];
197
					// and all of the entries in probeClassPath should be Strings
198
					File f = new File(path);
199
					classNames.add(f.getName().replaceAll(".class$", " "));
200
					bytes.add(readFileIntoBuffer(f));
201
				}
202
			}
203
			
204
			
205
			deployProbeClasses(bytes, classNames, agent);
206
		}
207
		catch(FileNotFoundException e)
208
		{
209
			// could be missing or invalid probes?
210
		}
211
		catch(IOException e){
212
			// IOException reading in file
213
		}
214
	}// end method
215
	
216
	/**
217
	 * A helper method to read a file into a buffer and produce an
218
	 * array of bytes
219
	 * @param file The give file
220
	 * @return
221
	 * @throws FileNotFoundException
222
	 * @throws IOException
223
	 */
224
	 private static byte[] readFileIntoBuffer(File file) throws FileNotFoundException, IOException
225
		 {
226
		 		 FileInputStream fs;
227
		 		 byte buffer[];
228
		 		 
229
		 		 fs = new FileInputStream(file);
230
		 		 DataInputStream probeStream = new DataInputStream(fs);
231
		 		 try {
232
		 		 		 int bufferSize = (int)file.length();
233
		 		 		 buffer = new byte[bufferSize];
234
		 		 		 probeStream.read(buffer);
235
		 		 } finally {
236
		 		 		 probeStream.close();
237
		 		 }
238
		 		 return buffer;
239
		 }
240
	
241
	 
242
	 public static void deployProbeClasses(Vector bytes, Vector classNames, IAgent agent) 
243
	 {
244
	   try 
245
	   {		 		 		   
246
	 		   int count = 4; // magic
247
	 		   for (int i = 0; i < bytes.size(); i++) 
248
	 		   {
249
	 		 		   String className = (String)classNames.get(i);
250
	 		 		   byte[] classBytes =(byte[]) bytes.get(i);
251
	 		 		   byte classNameBytes[] = className.getBytes(ENCODING_NAME_UTF8);
252
	 		 		   count += 4 + classNameBytes.length + 4 + classBytes.length;
253
	 		   }
254
	 		   
255
	 		 // Allocate buffer
256
	 		   ByteBuffer buffer = ByteBuffer.allocate(count); // tmp
257
	 		   buffer.putInt(0xDECAECC0);
258
	 		   
259
	 		   for (int i = 0; i < bytes.size(); i++) 
260
	 		   {
261
	 			   	   String className = (String)classNames.get(i);
262
	 		 		   byte[] classBytes =(byte[]) bytes.get(i);
263
	 		 		   byte classNameBytes[] = className.getBytes(ENCODING_NAME_UTF8);
264
	 		 		   /*
265
	 		 		 int commandSize =4 + // magic
266
	 		 		 		 		 4 + // className length
267
	 		 		 		 		 classNameBytes.length +
268
	 		 		 		 		 4 + // class size
269
	 		 		 		 		 classBytes.length
270
	 		 		 		 		 ;
271
	 		 		    */
272
273
	 		 		   // Populate buffer with data		 		 		 		 
274
	 		 		   buffer.putInt(classNameBytes.length).put(classNameBytes);
275
	 		 		   buffer.putInt(classBytes.length).put(classBytes);		 		 		 		   
276
	 		   }
277
	 		   
278
	 		   // Prepare RAC command
279
	 		   String commandData = new CustomBase64Encoder().encode(buffer.array());
280
	 		   ///
281
	 		   try {
282
	 		         BufferedWriter out = new BufferedWriter(new FileWriter("C:/fileWriter2.txt"));
283
	 		         out.write(commandData);
284
	 		         out.close();
285
	 		     } 
286
	 		   catch (IOException e) 
287
	 		   {
288
	 		     
289
	 		   }
290
	 		     ///
291
292
	 		   CommandFragment command = new CommandFragment();
293
	 		   command.setCommand(
294
	 		 		 		   "<applyOptions iid='org.eclipse.tptp.jvmti'>" +
295
	 		 		 		   "<option><name>PROBEKIT_CLASS</name>" + 
296
	 		 		 		   "<value>" + commandData + "</value><option></applyOptions>");
297
298
	 		   // Invoke RAC command- this is using the new sendCommand from the new execution framework
299
	 		   agent.sendCommand(command.buildCommand(), new ICommandHandler() {
300
	 		 		   public void incomingCommand(INode node, ICommandElement element) 
301
	 		 		   {
302
	 		 		 		   //Handler goes here
303
	 		 		   }
304
	 		   }
305
	 		   );
306
	   }// end try
307
	   catch (Exception e)
308
	   {
309
	 		   System.out.println(e.getMessage() + "is the error message");
310
	   }
311
	 }// end method deployProbeClasses		 
312
}// end class
313
	
314
315
			
316
		
317
		
318
	
319

Return to bug 141540