1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 03:53:21 +02:00

Bug 350837: Need an interface to access the GDB error stream.

This commit is contained in:
Marc Khouzam 2012-03-05 08:05:07 -05:00
parent e912eb6f32
commit 2fb4b4feef
4 changed files with 72 additions and 11 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2010 Wind River Systems, Nokia and others. * Copyright (c) 2006, 2012 Wind River Systems, Nokia and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Nokia - initial API and implementation with some code moved from GDBControl. * Nokia - initial API and implementation with some code moved from GDBControl.
* Wind River System * Wind River System
* Ericsson * Ericsson
* Marc Khouzam (Ericsson) - Use the new IMIBackend2 interface (Bug 350837)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service; package org.eclipse.cdt.dsf.gdb.service;
@ -39,6 +40,7 @@ import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils; import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils;
import org.eclipse.cdt.dsf.gdb.service.command.GDBControl.InitializationShutdownStep; import org.eclipse.cdt.dsf.gdb.service.command.GDBControl.InitializationShutdownStep;
import org.eclipse.cdt.dsf.mi.service.IMIBackend; import org.eclipse.cdt.dsf.mi.service.IMIBackend;
import org.eclipse.cdt.dsf.mi.service.IMIBackend2;
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent; import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
import org.eclipse.cdt.dsf.service.AbstractDsfService; import org.eclipse.cdt.dsf.service.AbstractDsfService;
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
@ -74,7 +76,7 @@ import org.osgi.framework.BundleContext;
* *
* @since 1.1 * @since 1.1
*/ */
public class GDBBackend extends AbstractDsfService implements IGDBBackend { public class GDBBackend extends AbstractDsfService implements IGDBBackend, IMIBackend2 {
private final ILaunchConfiguration fLaunchConfiguration; private final ILaunchConfiguration fLaunchConfiguration;
@ -390,6 +392,12 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend {
return fProcess.getInputStream(); return fProcess.getInputStream();
}; };
/** @since 4.1 */
@Override
public InputStream getMIErrorStream() {
return fProcess.getErrorStream();
};
@Override @Override
public String getId() { public String getId() {
return fBackendId; return fBackendId;
@ -689,6 +697,7 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend {
public void initialize(final RequestMonitor requestMonitor) { public void initialize(final RequestMonitor requestMonitor) {
register( register(
new String[]{ IMIBackend.class.getName(), new String[]{ IMIBackend.class.getName(),
IMIBackend2.class.getName(),
IGDBBackend.class.getName() }, IGDBBackend.class.getName() },
new Hashtable<String,String>()); new Hashtable<String,String>());

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2011 Wind River Systems and others. * Copyright (c) 2006, 2012 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -12,10 +12,12 @@
* Vladimir Prus (CodeSourcery) - Support for -data-read-memory-bytes (bug 322658) * Vladimir Prus (CodeSourcery) - Support for -data-read-memory-bytes (bug 322658)
* Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) * Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
* Mikhail Khodjaiants (Mentor Graphics) - Refactor common code in GDBControl* classes (bug 372795) * Mikhail Khodjaiants (Mentor Graphics) - Refactor common code in GDBControl* classes (bug 372795)
* Marc Khouzam (Ericsson) - Pass errorStream to startCommandProcessing() (Bug 350837)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service.command; package org.eclipse.cdt.dsf.gdb.service.command;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Hashtable; import java.util.Hashtable;
@ -45,6 +47,7 @@ import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses; import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses;
import org.eclipse.cdt.dsf.mi.service.IMIBackend; import org.eclipse.cdt.dsf.mi.service.IMIBackend;
import org.eclipse.cdt.dsf.mi.service.IMIBackend.BackendStateChangedEvent; import org.eclipse.cdt.dsf.mi.service.IMIBackend.BackendStateChangedEvent;
import org.eclipse.cdt.dsf.mi.service.IMIBackend2;
import org.eclipse.cdt.dsf.mi.service.IMICommandControl; import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
import org.eclipse.cdt.dsf.mi.service.IMIRunControl; import org.eclipse.cdt.dsf.mi.service.IMIRunControl;
import org.eclipse.cdt.dsf.mi.service.MIProcesses; import org.eclipse.cdt.dsf.mi.service.MIProcesses;
@ -376,7 +379,11 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
@Override @Override
protected void initialize(final RequestMonitor requestMonitor) { protected void initialize(final RequestMonitor requestMonitor) {
startCommandProcessing(fMIBackend.getMIInputStream(), fMIBackend.getMIOutputStream()); InputStream errorStream = null;
if (fMIBackend instanceof IMIBackend2) {
errorStream = ((IMIBackend2)fMIBackend).getMIErrorStream();
}
startCommandProcessing(fMIBackend.getMIInputStream(), fMIBackend.getMIOutputStream(), errorStream);
requestMonitor.done(); requestMonitor.done();
} }

View file

@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.mi.service;
import java.io.InputStream;
/**
* This interface extends the IMIBackend service to obtain the error
* stream of the backend process. (Bug 350837)
* @since 4.1
*/
public interface IMIBackend2 extends IMIBackend {
/**
* Returns the backend error stream.
*/
public InputStream getMIErrorStream();
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2010 Wind River Systems and others. * Copyright (c) 2006, 2012 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,6 +10,7 @@
* Ericsson - Modified for handling of multiple stacks and threads * Ericsson - Modified for handling of multiple stacks and threads
* Nokia - create and use backend service. * Nokia - create and use backend service.
* Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306) * Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
* Marc Khouzam (Ericsson) - New method to properly created ErrorThread (Bug 350837)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.mi.service.command; package org.eclipse.cdt.dsf.mi.service.command;
@ -40,7 +41,6 @@ import org.eclipse.cdt.dsf.debug.service.command.ICommandResult;
import org.eclipse.cdt.dsf.debug.service.command.ICommandToken; import org.eclipse.cdt.dsf.debug.service.command.ICommandToken;
import org.eclipse.cdt.dsf.debug.service.command.IEventListener; import org.eclipse.cdt.dsf.debug.service.command.IEventListener;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.gdb.service.GDBBackend;
import org.eclipse.cdt.dsf.mi.service.IMICommandControl; import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext; import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
@ -208,22 +208,40 @@ public abstract class AbstractMIControl extends AbstractDsfService
* Starts the threads that process the debugger input/output channels. * Starts the threads that process the debugger input/output channels.
* To be invoked by the initialization routine of the extending class. * To be invoked by the initialization routine of the extending class.
* *
* This version of the method will not start a thread for the error stream.
*
* @param inStream * @param inStream
* @param outStream * @param outStream
*/ */
protected void startCommandProcessing(InputStream inStream, OutputStream outStream) { protected void startCommandProcessing(InputStream inStream, OutputStream outStream) {
startCommandProcessing(inStream, outStream, null);
}
/**
* Starts the threads that process the debugger input/output/error channels.
* To be invoked by the initialization routine of the extending class.
*
*
* @param inStream
* @param outStream
* @param errorStream
* @since 4.1
*/
protected void startCommandProcessing(InputStream inStream, OutputStream outStream, InputStream errorStream) {
fTxThread = new TxThread(outStream); fTxThread = new TxThread(outStream);
fRxThread = new RxThread(inStream); fRxThread = new RxThread(inStream);
GDBBackend backend = getServicesTracker().getService(GDBBackend.class); if (errorStream != null) {
fErrorThread = new ErrorThread(backend.getProcess().getErrorStream()); fErrorThread = new ErrorThread(errorStream);
}
fTxThread.start(); fTxThread.start();
fRxThread.start(); fRxThread.start();
if (fErrorThread != null) {
fErrorThread.start(); fErrorThread.start();
} }
}
/** /**
* Stops the threads that process the debugger input/output channels, and notifies the * Stops the threads that process the debugger input/output channels, and notifies the