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 209343 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/tptp/platform/jvmti/client/internal/launcher/TIDelegateHelper.java (-8 / +83 lines)
Lines 32-37 Link Here
32
import org.eclipse.emf.common.util.EList;
32
import org.eclipse.emf.common.util.EList;
33
import org.eclipse.emf.common.util.URI;
33
import org.eclipse.emf.common.util.URI;
34
import org.eclipse.hyades.loaders.trace.TraceUtils;
34
import org.eclipse.hyades.loaders.trace.TraceUtils;
35
import org.eclipse.hyades.loaders.util.BinaryLoader;
35
import org.eclipse.hyades.loaders.util.LoadersUtils;
36
import org.eclipse.hyades.loaders.util.LoadersUtils;
36
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy;
37
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy;
37
import org.eclipse.hyades.models.hierarchy.TRCCollectionMode;
38
import org.eclipse.hyades.models.hierarchy.TRCCollectionMode;
Lines 91-96 Link Here
91
import org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.TIProcessControlProvider.TIProcessStateModifier;
92
import org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.TIProcessControlProvider.TIProcessStateModifier;
92
import org.eclipse.tptp.platform.jvmti.client.internal.launcher.util.AgentControllerDelegate;
93
import org.eclipse.tptp.platform.jvmti.client.internal.launcher.util.AgentControllerDelegate;
93
import org.eclipse.tptp.platform.jvmti.client.internal.launcher.util.RunCommand;
94
import org.eclipse.tptp.platform.jvmti.client.internal.launcher.util.RunCommand;
95
import org.eclipse.tptp.platform.jvmti.client.internal.launcher.util.SetOutputFormatCommand;
94
import org.eclipse.tptp.trace.ui.internal.launcher.core.AnalysisType;
96
import org.eclipse.tptp.trace.ui.internal.launcher.core.AnalysisType;
95
import org.eclipse.tptp.trace.ui.internal.launcher.core.AnalysisTypeManager;
97
import org.eclipse.tptp.trace.ui.internal.launcher.core.AnalysisTypeManager;
96
import org.eclipse.tptp.trace.ui.internal.launcher.core.DataCollectorManager;
98
import org.eclipse.tptp.trace.ui.internal.launcher.core.DataCollectorManager;
Lines 136-141 Link Here
136
	private static final String CMD_APPLY_FILTERS = "applyFilters";
138
	private static final String CMD_APPLY_FILTERS = "applyFilters";
137
	private static final String CMD_APPLY_OPTIONS = "applyOptions";
139
	private static final String CMD_APPLY_OPTIONS = "applyOptions";
138
	private static final String CMD_COLLECT_DATA = "CollectData";
140
	private static final String CMD_COLLECT_DATA = "CollectData";
141
	private static final String CMD_SET_OUTPUT_FORMAT = "setOutputFormat";
139
	
142
	
140
	/** Elements required to construct agent commands */
143
	/** Elements required to construct agent commands */
141
	private static final String ELEMENT_FILTER = "Filter";
144
	private static final String ELEMENT_FILTER = "Filter";
Lines 145-150 Link Here
145
	
148
	
146
	/** Attributes required to construct agent commands */
149
	/** Attributes required to construct agent commands */
147
	private static final String ATTRIBUTE_IID = "iid";
150
	private static final String ATTRIBUTE_IID = "iid";
151
148
	
152
	
149
	/** The executable that's run */
153
	/** The executable that's run */
150
	protected static final String EXEC_JAVA = "java.exe";
154
	protected static final String EXEC_JAVA = "java.exe";
Lines 732-747 Link Here
732
		return null;
736
		return null;
733
	}
737
	}
734
738
739
	static class SetOutputFormatHandler implements ICommandHandler {
740
		
741
		private final Object lock = new Object();
742
		
743
		private String format = SetOutputFormatCommand.XML_FORMAT;
744
		
745
		public String getFormat() {
746
			return format;
747
		}
748
		
749
		public Object getLock() {
750
			return lock;
751
		}
752
753
		public void incomingCommand(INode node, ICommandElement command) {
754
			String commandStr = new String(((CommandFragment) command)
755
					.getCommandData());
756
			if (Constants.TPTP_DEBUG)
757
				System.out.println("The Agent response - " + commandStr);
758
			TPTPXMLParse ParseObj = new TPTPXMLParse();
759
			ParseObj.setParser(commandStr);
760
			Hashtable CommandHash = ParseObj.getHashTable();
761
			if (CommandHash.containsKey(SetOutputFormatCommand.FORMAT_ELEMENT)) {
762
				format = (String) CommandHash.get(SetOutputFormatCommand.FORMAT_ELEMENT);
763
			} else {
764
				format = SetOutputFormatCommand.XML_FORMAT; 
765
			}
766
			
767
			synchronized(lock) {
768
				lock.notifyAll();
769
			}
770
		}
771
	}
772
735
	public static void configureDataProcessor(ILaunchConfiguration launchConfiguration, TRCAgentProxy agentProxy, ICollector tiAgent) throws CoreException
773
	public static void configureDataProcessor(ILaunchConfiguration launchConfiguration, TRCAgentProxy agentProxy, ICollector tiAgent) throws CoreException
736
	{
774
	{
737
		/* Start the data collection process */
775
		/* Start the data collection process */
738
		ACDataProcessorAdapter dataProcessor = (ACDataProcessorAdapter) LoadersUtils.locateDataProcessor(agentProxy);
739
		
776
		
740
      	if (dataProcessor == null) 
777
		ACDataProcessorAdapter dataProcessor;
741
        {
778
		SetOutputFormatHandler handler = new SetOutputFormatHandler(); 
742
      		dataProcessor = new ACDataProcessorAdapter(agentProxy);
779
		// Possible enhancement: let user choose the format from UI 
743
            LoadersUtils.registerDataProcessor(agentProxy, dataProcessor);                        
780
		SetOutputFormatCommand command = new SetOutputFormatCommand(SetOutputFormatCommand.XML_FORMAT);
744
        }
781
		
782
		synchronized(handler.getLock()) {
783
			try {
784
				tiAgent.sendCommand(command.buildCommand(), handler);
785
				handler.getLock().wait();
786
			} catch (InactiveAgentException e) {
787
				e.printStackTrace();
788
			} catch (NotConnectedException e) {
789
				e.printStackTrace();
790
			} catch (InterruptedException e) {
791
				e.printStackTrace();
792
			}
793
		}
794
		
795
		if (SetOutputFormatCommand.XML_FORMAT.equals(handler.getFormat())) {
796
			dataProcessor = (ACDataProcessorAdapter) LoadersUtils.locateDataProcessor(agentProxy);
797
	      	if (dataProcessor == null) 
798
	        {
799
	      		dataProcessor = new ACDataProcessorAdapter(agentProxy);
800
	            LoadersUtils.registerDataProcessor(agentProxy, dataProcessor);                        
801
	        }
802
		} else { // Binary format
803
			dataProcessor = new BFDataProcessorAdapter(agentProxy);
804
		}
745
      	
805
      	
746
      	/* Does the data need to be forwarded to a file? */
806
      	/* Does the data need to be forwarded to a file? */
747
      	boolean isProfileToLaunch = launchConfiguration == null ? agentProxy.isToProfileFile() : launchConfiguration.getAttribute(IProfileLaunchConfigurationConstants.ATTR_PROFILE_TO_FILE, false);
807
      	boolean isProfileToLaunch = launchConfiguration == null ? agentProxy.isToProfileFile() : launchConfiguration.getAttribute(IProfileLaunchConfigurationConstants.ATTR_PROFILE_TO_FILE, false);
Lines 1477-1482 Link Here
1477
			super(agentProxy);		
1537
			super(agentProxy);		
1478
			processAlive = true;
1538
			processAlive = true;
1479
			enabled = true;
1539
			enabled = true;
1540
			BinaryLoader bfLoader = this;
1541
			bfLoader.setLoadXml(true);
1480
		}
1542
		}
1481
1543
1482
		public void incomingData(byte[] buffer, int length, InetAddress peer)
1544
		public void incomingData(byte[] buffer, int length, InetAddress peer)
Lines 1495-1501 Link Here
1495
			super.incommingData(buffer, length, peer);
1557
			super.incommingData(buffer, length, peer);
1496
		}
1558
		}
1497
		
1559
		
1498
		private void preIncomingData() 
1560
		protected void preIncomingData() 
1499
		{
1561
		{
1500
			if (!processAlive)
1562
			if (!processAlive)
1501
				activity++;
1563
				activity++;
Lines 1527-1532 Link Here
1527
		}
1589
		}
1528
	}
1590
	}
1529
	
1591
	
1592
	public static class BFDataProcessorAdapter extends ACDataProcessorAdapter {
1593
1594
		public BFDataProcessorAdapter(TRCAgentProxy agentProxy) {
1595
			super(agentProxy);
1596
			BinaryLoader bfLoader = this;
1597
			bfLoader.setLoadXml(false);
1598
		}
1599
1600
		protected void loadEventHook(byte[] buffer, int offset, int length) {
1601
			loadEvent(buffer, offset, length);
1602
		}
1603
		
1604
	}
1605
	
1530
	
1606
	
1531
	/**
1607
	/**
1532
	 * A dummy command handler that doesn't do anything in response to a command
1608
	 * A dummy command handler that doesn't do anything in response to a command
Lines 1688-1692 Link Here
1688
		}
1764
		}
1689
	}
1765
	}
1690
1766
1691
1692
}
1767
}
(-)src/org/eclipse/tptp/platform/jvmti/client/internal/launcher/util/SetOutputFormatCommand.java (+82 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 Intel 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
 *    Stanislav Polevic, Intel - Initial API and Implementation 
10
 * 	  
11
 * $Id: 
12
 *******************************************************************************/
13
package org.eclipse.tptp.platform.jvmti.client.internal.launcher.util;
14
15
import org.eclipse.tptp.platform.execution.util.internal.CommandElement;
16
import org.eclipse.tptp.platform.jvmti.client.internal.TIConstants;
17
18
/**
19
 * The run command is used to run agent.
20
 */
21
public class SetOutputFormatCommand extends CommandElement {
22
23
	/** Output formats */
24
	public static final String BINARY_FORMAT = "binary";
25
	public static final String XML_FORMAT = "xml";
26
27
	public static final String FORMAT_ELEMENT = "format";
28
	
29
	private static final String SET_OUTPUT_FORMAT_COMMAND = "setOutputFormat";
30
31
	
32
	private final String outputFormat;
33
	
34
	
35
	/**
36
	 * 
37
	 */
38
	public SetOutputFormatCommand(String outputFormat) {
39
		this.outputFormat = outputFormat;
40
	}
41
42
	/* (non-Javadoc)
43
	 * @see org.eclipse.tptp.platform.execution.util.internal.CommandElement#getSize()
44
	 */
45
	public int getSize() {
46
		return 0;
47
	}
48
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.tptp.platform.execution.util.internal.CommandElement#readFromBuffer(byte[], int)
51
	 */
52
	public int readFromBuffer(byte[] buffer, int offset) {
53
		return 0;
54
	}
55
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.tptp.platform.execution.util.internal.CommandElement#writeToBuffer(byte[], int)
58
	 */
59
	public int writeToBuffer(byte[] buffer, int offset) {
60
		return 0;
61
	}
62
63
	/* (non-Javadoc)
64
	 * @see org.eclipse.tptp.platform.execution.util.internal.CommandElement#buildCommand()
65
	 */
66
	public String buildCommand() {
67
		StringBuffer sbuf = new StringBuffer();
68
		sbuf.append("<");
69
		sbuf.append(SET_OUTPUT_FORMAT_COMMAND + " iid=\"");
70
		sbuf.append(TIConstants.TI_AGENT_NAME + "\"");
71
		sbuf.append("><");
72
		sbuf.append(FORMAT_ELEMENT);
73
		sbuf.append(">");
74
		sbuf.append(outputFormat);
75
		sbuf.append("</");
76
		sbuf.append(FORMAT_ELEMENT);
77
		sbuf.append(">");
78
		sbuf.append("</" + SET_OUTPUT_FORMAT_COMMAND + ">");
79
		return sbuf.toString();
80
	}
81
82
}

Return to bug 209343