Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2013-01-15 18:59:57 -0500
committerEugene Tarassov2013-01-15 18:59:57 -0500
commit61435e0455753f81c20f42b9eef51f925da293ba (patch)
tree2beae5969e7345486136302b06cb9d8d0f9a7231 /plugins
parentfe794cf705bf7c2c179e616c184bfc1b33d9177a (diff)
downloadorg.eclipse.tcf-61435e0455753f81c20f42b9eef51f925da293ba.tar.gz
org.eclipse.tcf-61435e0455753f81c20f42b9eef51f925da293ba.tar.xz
org.eclipse.tcf-61435e0455753f81c20f42b9eef51f925da293ba.zip
TCF Debugger: added console for "dynamic printf"
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/setup/SetupWizardDialog.java2
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFConsole.java31
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java21
-rw-r--r--plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java82
4 files changed, 108 insertions, 28 deletions
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/setup/SetupWizardDialog.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/setup/SetupWizardDialog.java
index a99405c62..e85b22200 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/setup/SetupWizardDialog.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/launch/setup/SetupWizardDialog.java
@@ -53,7 +53,7 @@ public class SetupWizardDialog extends Wizard {
if (!canFinish()) return false;
IWizardPage page = getContainer().getCurrentPage();
if (page instanceof WizardPropsPage) {
- if (!((WizardPropsPage)page).performFinish()) return false;;
+ if (!((WizardPropsPage)page).performFinish()) return false;
}
return true;
}
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFConsole.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFConsole.java
index 4977940d2..015dc337a 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFConsole.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFConsole.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2013 Wind River Systems, 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
@@ -35,6 +35,11 @@ import org.eclipse.ui.console.IOConsoleInputStream;
import org.eclipse.ui.console.IOConsoleOutputStream;
class TCFConsole {
+ public static final int
+ TYPE_PROCESS = 1,
+ TYPE_CMD_LINE = 2,
+ TYPE_DPRINTF = 3;
+
private final TCFModel model;
private final IOConsole console;
private final Display display;
@@ -90,12 +95,12 @@ class TCFConsole {
}
}
}
- else {
+ else if (process_id != null) {
model.getLaunch().writeProcessInputStream(process_id, buf, 0, n);
}
}
catch (Exception x) {
- model.onProcessStreamError(process_id, 0, x, 0);
+ if (process_id != null) model.onProcessStreamError(process_id, 0, x, 0);
}
}
});
@@ -176,17 +181,27 @@ class TCFConsole {
}
};
- /* process_id == null means debug console */
- TCFConsole(final TCFModel model, String process_id) {
+ TCFConsole(final TCFModel model, int type, String process_id) {
this.model = model;
this.process_id = process_id;
display = model.getDisplay();
out_queue = new LinkedList<Message>();
String image = process_id != null ? ImageCache.IMG_PROCESS_RUNNING : ImageCache.IMG_TCF;
- console = new IOConsole(
- "TCF " + (process_id != null ? process_id : "Debugger"), null,
+ String title = "TCF";
+ switch (type) {
+ case TYPE_PROCESS:
+ title += " " + process_id;
+ break;
+ case TYPE_CMD_LINE:
+ title += " Debugger";
+ break;
+ case TYPE_DPRINTF:
+ title += " DPrintf";
+ break;
+ }
+ console = new IOConsole(title, null,
ImageCache.getImageDescriptor(image), "UTF-8", true);
- cmd_line = process_id != null ? null : new TCFCommandLine();
+ cmd_line = type == TYPE_CMD_LINE ? new TCFCommandLine() : null;
if (cmd_line != null) write(0, prompt);
display.asyncExec(new Runnable() {
public void run() {
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java
index a7892cc77..7ff893670 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java
@@ -303,8 +303,9 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab
private final Map<IWorkbenchPart,TCFSnapshot> locks = new HashMap<IWorkbenchPart,TCFSnapshot>();
private final Map<IWorkbenchPart,Integer> lock_policy = new HashMap<IWorkbenchPart,Integer>();
- private final Map<String,TCFConsole> process_consoles = new HashMap<String,TCFConsole>();;
+ private final Map<String,TCFConsole> process_consoles = new HashMap<String,TCFConsole>();
private final List<TCFConsole> debug_consoles = new ArrayList<TCFConsole>();
+ private TCFConsole dprintf_console;
private static final Map<ILaunchConfiguration,IEditorInput> editor_not_found =
new HashMap<ILaunchConfiguration,IEditorInput>();
@@ -820,9 +821,18 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab
}
void onProcessOutput(String process_id, final int stream_id, byte[] data) {
- TCFConsole c = process_consoles.get(process_id);
- if (c == null) process_consoles.put(process_id, c = new TCFConsole(this, process_id));
- c.write(stream_id, data);
+ if (process_id != null) {
+ TCFConsole c = process_consoles.get(process_id);
+ if (c == null) process_consoles.put(process_id,
+ c = new TCFConsole(this, TCFConsole.TYPE_PROCESS, process_id));
+ c.write(stream_id, data);
+ }
+ else {
+ if (dprintf_console == null) {
+ dprintf_console = new TCFConsole(TCFModel.this, TCFConsole.TYPE_DPRINTF, null);
+ }
+ dprintf_console.write(stream_id, data);
+ }
}
void onProcessStreamError(String process_id, int stream_id, Exception x, int lost_size) {
@@ -1022,6 +1032,7 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab
expr_manager.removeExpressionListener(expressions_listener);
for (TCFConsole c : process_consoles.values()) c.close();
for (TCFConsole c : debug_consoles) c.close();
+ if (dprintf_console != null) dprintf_console.close();
}
void addNode(String id, TCFNode node) {
@@ -1885,7 +1896,7 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab
* Open debugger console that provide command line UI for the debugger.
*/
public void showDebugConsole() {
- debug_consoles.add(new TCFConsole(this, null));
+ debug_consoles.add(new TCFConsole(this, TCFConsole.TYPE_CMD_LINE, null));
}
/**
diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java
index 90326566d..b926b9889 100644
--- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java
+++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java
@@ -47,6 +47,7 @@ import org.eclipse.tcf.services.IFileSystem.FileSystemException;
import org.eclipse.tcf.services.IFileSystem.IFileHandle;
import org.eclipse.tcf.services.IMemory;
import org.eclipse.tcf.services.IMemory.MemoryContext;
+import org.eclipse.tcf.services.IDPrintf;
import org.eclipse.tcf.services.IMemoryMap;
import org.eclipse.tcf.services.IPathMap;
import org.eclipse.tcf.services.IProcesses;
@@ -157,7 +158,7 @@ public class TCFLaunch extends Launch {
private final HashMap<String,TCFAction> active_actions = new HashMap<String,TCFAction>();
private final HashMap<String,LinkedList<TCFAction>> context_action_queue = new HashMap<String,LinkedList<TCFAction>>();
private final HashMap<String,Long> context_action_timestamps = new HashMap<String,Long>();
- private final HashMap<String,String> stream_ids = new HashMap<String,String>();
+ private final HashMap<String,String> process_stream_ids = new HashMap<String,String>();
private final LinkedList<LaunchStep> launch_steps = new LinkedList<LaunchStep>();
private final LinkedList<String> redirection_path = new LinkedList<String>();
@@ -172,10 +173,12 @@ public class TCFLaunch extends Launch {
private boolean supports_memory_map_preloading;
+ private String dprintf_stream_id;
+
private final IStreams.StreamsListener streams_listener = new IStreams.StreamsListener() {
public void created(String stream_type, String stream_id, String context_id) {
- stream_ids.put(stream_id, context_id);
+ process_stream_ids.put(stream_id, context_id);
if (process_start_command == null) {
disconnectStream(stream_id);
}
@@ -366,6 +369,47 @@ public class TCFLaunch extends Launch {
Activator.getBreakpointsModel().downloadBreakpoints(channel, this);
}
};
+ final IDPrintf dprintf = getService(IDPrintf.class);
+ if (dprintf != null) {
+ // Open dprintf stream:
+ final IStreams.DoneRead done_read = new IStreams.DoneRead() {
+ @Override
+ public void doneRead(IToken token, Exception error, int lost_size, byte[] data, boolean eos) {
+ if (data != null && data.length > 0) {
+ for (LaunchListener l : getListeners()) l.onProcessOutput(TCFLaunch.this, null, 0, data);
+ }
+ if (error == null && !eos) streams.read(dprintf_stream_id, 0x1000, this);
+ }
+ };
+ new LaunchStep() {
+ @Override
+ void start() throws Exception {
+ dprintf.open(null, new IDPrintf.DoneCommandOpen() {
+ @Override
+ public void doneCommandOpen(IToken token, Exception error, final String id) {
+ if (error != null) {
+ channel.terminate(error);
+ return;
+ }
+ dprintf_stream_id = id;
+ streams.connect(id, new IStreams.DoneConnect() {
+ @Override
+ public void doneConnect(IToken token, Exception error) {
+ if (error != null) {
+ channel.terminate(error);
+ return;
+ }
+ streams.read(id, 0x1000, done_read);
+ streams.read(id, 0x1000, done_read);
+ streams.read(id, 0x1000, done_read);
+ done();
+ }
+ });
+ }
+ });
+ }
+ };
+ }
}
// Call client launch sequence:
@@ -834,7 +878,7 @@ public class TCFLaunch extends Launch {
public void doneStart(IToken token, final Exception error, ProcessContext process) {
process_start_command = null;
if (error != null) {
- for (String id : new HashSet<String>(stream_ids.keySet())) disconnectStream(id);
+ for (String id : new HashSet<String>(process_stream_ids.keySet())) disconnectStream(id);
Protocol.sync(new Runnable() {
public void run() {
channel.terminate(error);
@@ -934,7 +978,7 @@ public class TCFLaunch extends Launch {
final String inp_id = (String)process.getProperties().get(IProcesses.PROP_STDIN_ID);
final String out_id = (String)process.getProperties().get(IProcesses.PROP_STDOUT_ID);
final String err_id = (String)process.getProperties().get(IProcesses.PROP_STDERR_ID);
- for (final String id : stream_ids.keySet().toArray(new String[stream_ids.size()])) {
+ for (final String id : process_stream_ids.keySet().toArray(new String[process_stream_ids.size()])) {
if (id.equals(inp_id)) {
process_input_stream_id = id;
}
@@ -955,7 +999,7 @@ public class TCFLaunch extends Launch {
final IStreams streams = getService(IStreams.class);
IStreams.DoneRead done = new IStreams.DoneRead() {
public void doneRead(IToken token, Exception error, int lost_size, byte[] data, boolean eos) {
- if (stream_ids.get(id) == null) return;
+ if (process_stream_ids.get(id) == null) return;
if (lost_size > 0) {
Exception x = new IOException("Process output data lost due buffer overflow");
for (LaunchListener l : getListeners()) l.onProcessStreamError(TCFLaunch.this, peocess_id, no, x, lost_size);
@@ -981,8 +1025,8 @@ public class TCFLaunch extends Launch {
}
private void disconnectStream(String id) {
- assert stream_ids.get(id) != null;
- stream_ids.remove(id);
+ assert process_stream_ids.get(id) != null;
+ process_stream_ids.remove(id);
if (channel.getState() != IChannel.STATE_OPEN) return;
IStreams streams = getService(IStreams.class);
streams.disconnect(id, new IStreams.DoneDisconnect() {
@@ -1126,11 +1170,11 @@ public class TCFLaunch extends Launch {
final String prs = process.getID();
IStreams streams = getService(IStreams.class);
if (streams == null) throw new IOException("Streams service not available");
- if (stream_ids.get(id) == null) throw new IOException("Input stream not available");
+ if (process_stream_ids.get(id) == null) throw new IOException("Input stream not available");
streams.write(id, buf, pos, len, new IStreams.DoneWrite() {
public void doneWrite(IToken token, Exception error) {
if (error == null) return;
- if (stream_ids.get(id) == null) return;
+ if (process_stream_ids.get(id) == null) return;
for (LaunchListener l : getListeners()) l.onProcessStreamError(TCFLaunch.this, prs, 0, error, len);
disconnectStream(id);
}
@@ -1153,14 +1197,14 @@ public class TCFLaunch extends Launch {
IProcesses processes = getService(IProcesses.class);
processes.removeListener(prs_listener);
IStreams streams = getService(IStreams.class);
- for (String id : stream_ids.keySet()) {
+ for (String id : process_stream_ids.keySet()) {
streams.disconnect(id, new IStreams.DoneDisconnect() {
public void doneDisconnect(IToken token, Exception error) {
if (error != null) channel.terminate(error);
}
});
}
- stream_ids.clear();
+ process_stream_ids.clear();
process_input_stream_id = null;
process = null;
}
@@ -1194,9 +1238,9 @@ public class TCFLaunch extends Launch {
}
}));
}
- if (stream_ids.size() > 0) {
+ if (process_stream_ids.size() > 0) {
IStreams streams = getService(IStreams.class);
- for (String id : stream_ids.keySet()) {
+ for (String id : process_stream_ids.keySet()) {
cmds.add(streams.disconnect(id, new IStreams.DoneDisconnect() {
public void doneDisconnect(IToken token, Exception error) {
cmds.remove(token);
@@ -1205,9 +1249,19 @@ public class TCFLaunch extends Launch {
}
}));
}
- stream_ids.clear();
+ process_stream_ids.clear();
}
process_input_stream_id = null;
+ if (dprintf_stream_id != null) {
+ IStreams streams = getService(IStreams.class);
+ cmds.add(streams.disconnect(dprintf_stream_id, new IStreams.DoneDisconnect() {
+ public void doneDisconnect(IToken token, Exception error) {
+ cmds.remove(token);
+ if (error != null) channel.terminate(error);
+ else if (cmds.isEmpty()) channel.close();
+ }
+ }));
+ }
if (cmds.isEmpty()) channel.close();
}

Back to the top