mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 350837: Need an interface to access the GDB error stream.
This commit is contained in:
parent
e912eb6f32
commit
2fb4b4feef
4 changed files with 72 additions and 11 deletions
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,6 +9,7 @@
|
|||
* Nokia - initial API and implementation with some code moved from GDBControl.
|
||||
* Wind River System
|
||||
* Ericsson
|
||||
* Marc Khouzam (Ericsson) - Use the new IMIBackend2 interface (Bug 350837)
|
||||
*******************************************************************************/
|
||||
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.service.command.GDBControl.InitializationShutdownStep;
|
||||
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.service.AbstractDsfService;
|
||||
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
|
||||
|
@ -74,7 +76,7 @@ import org.osgi.framework.BundleContext;
|
|||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
public class GDBBackend extends AbstractDsfService implements IGDBBackend {
|
||||
public class GDBBackend extends AbstractDsfService implements IGDBBackend, IMIBackend2 {
|
||||
|
||||
private final ILaunchConfiguration fLaunchConfiguration;
|
||||
|
||||
|
@ -389,7 +391,13 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend {
|
|||
public InputStream getMIInputStream() {
|
||||
return fProcess.getInputStream();
|
||||
};
|
||||
|
||||
|
||||
/** @since 4.1 */
|
||||
@Override
|
||||
public InputStream getMIErrorStream() {
|
||||
return fProcess.getErrorStream();
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return fBackendId;
|
||||
|
@ -689,6 +697,7 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend {
|
|||
public void initialize(final RequestMonitor requestMonitor) {
|
||||
register(
|
||||
new String[]{ IMIBackend.class.getName(),
|
||||
IMIBackend2.class.getName(),
|
||||
IGDBBackend.class.getName() },
|
||||
new Hashtable<String,String>());
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -12,10 +12,12 @@
|
|||
* Vladimir Prus (CodeSourcery) - Support for -data-read-memory-bytes (bug 322658)
|
||||
* Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
|
||||
* 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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
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.mi.service.IMIBackend;
|
||||
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.IMIRunControl;
|
||||
import org.eclipse.cdt.dsf.mi.service.MIProcesses;
|
||||
|
@ -376,7 +379,11 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
|
|||
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -10,6 +10,7 @@
|
|||
* Ericsson - Modified for handling of multiple stacks and threads
|
||||
* Nokia - create and use backend service.
|
||||
* 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;
|
||||
|
||||
|
@ -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.IEventListener;
|
||||
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.IMIContainerDMContext;
|
||||
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
|
||||
|
@ -208,21 +208,39 @@ public abstract class AbstractMIControl extends AbstractDsfService
|
|||
* Starts the threads that process the debugger input/output channels.
|
||||
* 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 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);
|
||||
fRxThread = new RxThread(inStream);
|
||||
|
||||
GDBBackend backend = getServicesTracker().getService(GDBBackend.class);
|
||||
fErrorThread = new ErrorThread(backend.getProcess().getErrorStream());
|
||||
if (errorStream != null) {
|
||||
fErrorThread = new ErrorThread(errorStream);
|
||||
}
|
||||
|
||||
fTxThread.start();
|
||||
fRxThread.start();
|
||||
fErrorThread.start();
|
||||
if (fErrorThread != null) {
|
||||
fErrorThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue