Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2013-03-22 19:46:40 +0000
committerEugene Tarassov2013-03-22 19:46:40 +0000
commit2d8c7f5147eaacd6fa0cb7dfcca96e9e47f53144 (patch)
tree8e0e67a568c34ad0d0a75734cb14b5ad03b939ea /plugins
parent77e246ad3765f794527364f781d172b106c35fed (diff)
downloadorg.eclipse.tcf-2d8c7f5147eaacd6fa0cb7dfcca96e9e47f53144.tar.gz
org.eclipse.tcf-2d8c7f5147eaacd6fa0cb7dfcca96e9e47f53144.tar.xz
org.eclipse.tcf-2d8c7f5147eaacd6fa0cb7dfcca96e9e47f53144.zip
TCF Core: new TCF service interface: Profiler.
The service allows to configure profiling and upload profile data - if supported by the target.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/remote/ProfilerProxy.java70
-rw-r--r--plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/services/IProfiler.java102
2 files changed, 172 insertions, 0 deletions
diff --git a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/remote/ProfilerProxy.java b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/remote/ProfilerProxy.java
new file mode 100644
index 000000000..a590841d5
--- /dev/null
+++ b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/remote/ProfilerProxy.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Xilinx, Inc. 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:
+ * Xilinx - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.internal.services.remote;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.eclipse.tcf.core.Command;
+import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.protocol.IToken;
+import org.eclipse.tcf.services.IProfiler;
+
+public class ProfilerProxy implements IProfiler {
+
+ private final IChannel channel;
+
+ public ProfilerProxy(IChannel channel) {
+ this.channel = channel;
+ }
+
+ @Override
+ public String getName() {
+ return NAME;
+ }
+
+ @Override
+ public IToken configure(String ctx, Map<String, Object> params, final DoneConfigure done) {
+ return new Command(channel, this, "configure", new Object[]{ ctx, params }) {
+ @Override
+ public void done(Exception error, Object[] args) {
+ if (error == null) {
+ assert args.length == 1;
+ error = toError(args[0]);
+ }
+ done.doneConfigure(token, error);
+ }
+ }.token;
+ }
+
+ @Override
+ public IToken read(String ctx, final DoneRead done) {
+ return new Command(channel, this, "read", new Object[]{ ctx }) {
+ @Override
+ public void done(Exception error, Object[] args) {
+ Map<String,Object>[] data = null;
+ if (error == null) {
+ assert args.length == 2;
+ error = toError(args[0]);
+ data = toDataArray(args[1]);
+ }
+ done.doneRead(token, error, data);
+ }
+ }.token;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Map<String,Object>[] toDataArray(Object o) {
+ if (o == null) return null;
+ Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)o;
+ return c.toArray(new Map[c.size()]);
+ }
+}
diff --git a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/services/IProfiler.java b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/services/IProfiler.java
new file mode 100644
index 000000000..aa3513688
--- /dev/null
+++ b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/services/IProfiler.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Xilinx, Inc. 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:
+ * Xilinx - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.services;
+
+import java.util.Map;
+
+import org.eclipse.tcf.protocol.IService;
+import org.eclipse.tcf.protocol.IToken;
+
+/**
+ * TCF Profiler service interface.
+ */
+public interface IProfiler extends IService {
+
+ /**
+ * Service name.
+ */
+ static final String NAME = "Profiler";
+
+ /** Profiler configuration parameters */
+ static final String
+ /**
+ * Number: size of stack traces in profiling samples,
+ * 0 means no profiling,
+ * 1 means no stack tracing.
+ */
+ PARAM_FRAME_CNT = "FrameCnt",
+
+ /**
+ * Number: size of profiling data buffer, in samples.
+ */
+ PARAM_MAX_SAMPLES = "MaxSamples";
+
+ /** Profile data properties */
+ static final String
+ /**
+ * Number: address size in bytes.
+ * Default is 4 bytes.
+ */
+ PROP_ADDR_SIZE = "AddrSize",
+
+ /**
+ * Sample endianess.
+ * Default is little-endian.
+ */
+ PROP_BIG_ENDIAN = "BigEndian",
+
+ /**
+ * Byte array of profile samples.
+ */
+ PROP_DATA = "Data";
+
+ /**
+ * Configure profiling of a debug context 'ctx'.
+ * Profiling is disabled (stopped) if 'params' is empty or null.
+ * @param ctx - debug context to profile.
+ * @param params - description of profiling method, see PARAM_*.
+ * @param done - command result call back object.
+ * @return - pending command handle.
+ */
+ IToken configure(String ctx, Map<String,Object> params, DoneConfigure done);
+
+ interface DoneConfigure {
+ /**
+ * Called when "configure" command is done.
+ * @param token - command handle.
+ * @param error - error object or null.
+ */
+ void doneConfigure(IToken token, Exception error);
+ }
+
+ /**
+ * Read profiling data buffers.
+ * Successful read clears the buffer.
+ * If a client has started profiling with "configure" command,
+ * it is expected to read and process profiling data periodically.
+ * The buffer has limited size, so profiling samples can be lost if they are not read timely.
+ * @param ctx - debug context that is being profiled.
+ * @param done - command result call back object.
+ * @return - pending command handle.
+ */
+ IToken read(String ctx, DoneRead done);
+
+ interface DoneRead {
+ /**
+ * Called when "read" command is done.
+ * @param token - command handle.
+ * @param error - error object or null.
+ * @param data - array of profile data buffers.
+ * Each buffer is collection of properties, see PROP_*.
+ */
+ void doneRead(IToken token, Exception error, Map<String,Object> data[]);
+ }
+}

Back to the top