View | Details | Raw Unified | Return to bug 249227 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java (-1 / +14 lines)
Lines 50-55 Link Here
50
import org.eclipse.debug.core.Launch;
50
import org.eclipse.debug.core.Launch;
51
import org.eclipse.debug.core.model.IDisconnect;
51
import org.eclipse.debug.core.model.IDisconnect;
52
import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
52
import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
53
import org.eclipse.debug.core.model.IProcess;
53
import org.eclipse.debug.core.model.ISourceLocator;
54
import org.eclipse.debug.core.model.ISourceLocator;
54
import org.eclipse.debug.core.model.ITerminate;
55
import org.eclipse.debug.core.model.ITerminate;
55
56
Lines 177-183 Link Here
177
    				}
178
    				}
178
    			}).get();
179
    			}).get();
179
180
180
            DebugPlugin.newProcess(this, cliProc, label);
181
    		// This call cannot be part of an executor call or it will deadlock
182
            final IProcess gdbDebugProcess = DebugPlugin.newProcess(this, cliProc, label);
183
184
            // Now that we have the gdbDebugProcess that was just added to the launch
185
            // we can start the DebugTraces
186
			getDsfExecutor().submit( new Runnable() {
187
				public void run() {
188
					IGDBControl gdb = fTracker.getService(IGDBControl.class);
189
					if (gdb != null) {
190
						gdb.getTracingConsole().start(gdbDebugProcess);
191
					}
192
				}
193
			}).get();
181
        } catch (InterruptedException e) {
194
        } catch (InterruptedException e) {
182
            throw new CoreException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, 0, "Interrupted while waiting for get process callable.", e)); //$NON-NLS-1$
195
            throw new CoreException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, 0, "Interrupted while waiting for get process callable.", e)); //$NON-NLS-1$
183
        } catch (ExecutionException e) {
196
        } catch (ExecutionException e) {
(-)src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java (-5 / +33 lines)
Lines 132-141 Link Here
132
     * @param outStream
132
     * @param outStream
133
     */
133
     */
134
    
134
    
135
    protected void startCommandProcessing(InputStream inStream, OutputStream outStream) {
135
    protected void startCommandProcessing(InputStream inStream, OutputStream outStream, OutputStream tracingStream) {
136
    	
136
    	
137
        fTxThread = new TxThread(outStream);
137
    	fTxThread = new TxThread(outStream, tracingStream);
138
        fRxThread = new RxThread(inStream);
138
        fRxThread = new RxThread(inStream, tracingStream);
139
        fTxThread.start();
139
        fTxThread.start();
140
        fRxThread.start();
140
        fRxThread.start();
141
    }
141
    }
Lines 473-482 Link Here
473
    private class TxThread extends Thread {
473
    private class TxThread extends Thread {
474
474
475
        final private OutputStream fOutputStream; 
475
        final private OutputStream fOutputStream; 
476
        private OutputStream fTracingStream = null;
476
        
477
        
477
        public TxThread(OutputStream outStream) {
478
        public TxThread(OutputStream outStream, OutputStream tracingStream) {
478
            super("MI TX Thread"); //$NON-NLS-1$
479
            super("MI TX Thread"); //$NON-NLS-1$
479
            fOutputStream = outStream;
480
            fOutputStream = outStream;
481
            fTracingStream = tracingStream;
480
        }
482
        }
481
483
482
        @Override
484
        @Override
Lines 524-529 Link Here
524
                        fOutputStream.flush();
526
                        fOutputStream.flush();
525
527
526
                        GdbPlugin.debug(GdbPlugin.getDebugTime() + " " + str); //$NON-NLS-1$
528
                        GdbPlugin.debug(GdbPlugin.getDebugTime() + " " + str); //$NON-NLS-1$
529
                        if (fTracingStream != null) {
530
                        	try {
531
                               	fTracingStream.write(str.getBytes());
532
                               	fTracingStream.flush();
533
                        	} catch (IOException e) {
534
                        		// The tracing stream could be closed earlier than we
535
                        		// finish transmitting
536
                        		fTracingStream = null;
537
                        	}
538
                        }
539
527
                    }
540
                    }
528
                } catch (IOException e) {
541
                } catch (IOException e) {
529
                    // Shutdown thread in case of IO error.
542
                    // Shutdown thread in case of IO error.
Lines 535-540 Link Here
535
548
536
    private class RxThread extends Thread {
549
    private class RxThread extends Thread {
537
        private final InputStream fInputStream;
550
        private final InputStream fInputStream;
551
        private OutputStream fTracingStream = null;
552
538
        private final MIParser fMiParser = new MIParser();
553
        private final MIParser fMiParser = new MIParser();
539
554
540
        /** 
555
        /** 
Lines 543-551 Link Here
543
        */ 
558
        */ 
544
        private final List<MIOOBRecord> fAccumulatedOOBRecords = new ArrayList<MIOOBRecord>();
559
        private final List<MIOOBRecord> fAccumulatedOOBRecords = new ArrayList<MIOOBRecord>();
545
        
560
        
546
        public RxThread(InputStream inputStream) {
561
        public RxThread(InputStream inputStream, OutputStream tracingStream) {
547
            super("MI RX Thread"); //$NON-NLS-1$
562
            super("MI RX Thread"); //$NON-NLS-1$
548
            fInputStream = inputStream;
563
            fInputStream = inputStream;
564
            fTracingStream = tracingStream;
549
        }
565
        }
550
566
551
        @Override
567
        @Override
Lines 556-561 Link Here
556
                while ((line = reader.readLine()) != null) {
572
                while ((line = reader.readLine()) != null) {
557
                    if (line.length() != 0) {
573
                    if (line.length() != 0) {
558
                        GdbPlugin.debug(GdbPlugin.getDebugTime() + " " + line +"\n"); //$NON-NLS-1$ //$NON-NLS-2$
574
                        GdbPlugin.debug(GdbPlugin.getDebugTime() + " " + line +"\n"); //$NON-NLS-1$ //$NON-NLS-2$
575
                        if (fTracingStream != null) {
576
                        	try {
577
                        		fTracingStream.write(line.getBytes());
578
                        		fTracingStream.write('\n');
579
                        		fTracingStream.flush();
580
                        	} catch (IOException e) {
581
                        		// The tracing stream could be closed earlier than we
582
                        		// finish receiving
583
                        		fTracingStream = null;
584
                        	}
585
                        }
586
                        
559
                    	processMIOutput(line);
587
                    	processMIOutput(line);
560
                    }
588
                    }
561
                }
589
                }
(-)META-INF/MANIFEST.MF (-2 / +3 lines)
Lines 8-18 Link Here
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Require-Bundle: org.eclipse.core.runtime,
9
Require-Bundle: org.eclipse.core.runtime,
10
 org.eclipse.cdt.dsf,
10
 org.eclipse.cdt.dsf,
11
 org.eclipse.debug.core,
12
 org.eclipse.cdt.core,
11
 org.eclipse.cdt.core,
13
 org.eclipse.cdt.debug.core,
12
 org.eclipse.cdt.debug.core,
14
 org.eclipse.core.variables,
13
 org.eclipse.core.variables,
15
 org.eclipse.jface
14
 org.eclipse.ui.console,
15
 org.eclipse.debug.ui,
16
 org.eclipse.ui
16
Bundle-ActivationPolicy: lazy
17
Bundle-ActivationPolicy: lazy
17
Bundle-RequiredExecutionEnvironment: J2SE-1.5
18
Bundle-RequiredExecutionEnvironment: J2SE-1.5
18
Export-Package: org.eclipse.cdt.dsf.gdb,
19
Export-Package: org.eclipse.cdt.dsf.gdb,
(-)src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java (-3 / +24 lines)
Lines 13-18 Link Here
13
package org.eclipse.cdt.dsf.gdb.service.command;
13
package org.eclipse.cdt.dsf.gdb.service.command;
14
14
15
import java.io.IOException;
15
import java.io.IOException;
16
import java.io.OutputStream;
16
import java.util.Hashtable;
17
import java.util.Hashtable;
17
import java.util.concurrent.Future;
18
import java.util.concurrent.Future;
18
import java.util.concurrent.TimeUnit;
19
import java.util.concurrent.TimeUnit;
Lines 29-34 Link Here
29
import org.eclipse.cdt.dsf.debug.service.command.ICommandControl;
30
import org.eclipse.cdt.dsf.debug.service.command.ICommandControl;
30
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
31
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
31
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
32
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
33
import org.eclipse.cdt.dsf.gdb.launching.DebugTracingConsole;
32
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
34
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
33
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
35
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
34
import org.eclipse.cdt.dsf.gdb.service.SessionType;
36
import org.eclipse.cdt.dsf.gdb.service.SessionType;
Lines 105-110 Link Here
105
    private AbstractCLIProcess fCLIProcess;
107
    private AbstractCLIProcess fCLIProcess;
106
    private MIInferiorProcess fInferiorProcess = null;
108
    private MIInferiorProcess fInferiorProcess = null;
107
    
109
    
110
    private DebugTracingConsole fTracingConsole = null;
111
	private OutputStream fTracingStream = null;
112
108
    private PTY fPty;
113
    private PTY fPty;
109
114
110
    public GDBControl(DsfSession session, ILaunchConfiguration config) { 
115
    public GDBControl(DsfSession session, ILaunchConfiguration config) { 
Lines 175-180 Link Here
175
        return fControlDmc;
180
        return fControlDmc;
176
    }
181
    }
177
    
182
    
183
    public DebugTracingConsole getTracingConsole() { 
184
    	return fTracingConsole;
185
    }
186
178
    public void terminate(final RequestMonitor rm) {
187
    public void terminate(final RequestMonitor rm) {
179
        // Schedule a runnable to be executed 2 seconds from now.
188
        // Schedule a runnable to be executed 2 seconds from now.
180
        // If we don't get a response to the quit command, this 
189
        // If we don't get a response to the quit command, this 
Lines 415-434 Link Here
415
            requestMonitor.done();
424
            requestMonitor.done();
416
        }
425
        }
417
    }
426
    }
418
    
427
419
    protected class CommandMonitoringStep extends InitializationShutdownStep {
428
    protected class CommandMonitoringStep extends InitializationShutdownStep {
420
        CommandMonitoringStep(Direction direction) { super(direction); }
429
        CommandMonitoringStep(Direction direction) { super(direction); }
421
430
422
        @Override
431
        @Override
423
        protected void initialize(final RequestMonitor requestMonitor) {
432
        protected void initialize(final RequestMonitor requestMonitor) {
424
            startCommandProcessing(fMIBackend.getMIInputStream(), fMIBackend.getMIOutputStream());
433
            // Create the DebugTracing console and its stream
434
        	fTracingConsole = new DebugTracingConsole();
435
        	fTracingStream = fTracingConsole.newOutputStream();
436
437
            startCommandProcessing(fMIBackend.getMIInputStream(), 
438
            		               fMIBackend.getMIOutputStream(),
439
            		               fTracingStream);
425
            requestMonitor.done();
440
            requestMonitor.done();
426
        }
441
        }
427
442
428
        @Override
443
        @Override
429
        protected void shutdown(RequestMonitor requestMonitor) {
444
        protected void shutdown(RequestMonitor requestMonitor) {
430
            stopCommandProcessing();
445
            stopCommandProcessing();
431
            requestMonitor.done();
446
            try {
447
            	// Since we created the console stream, we are responsible to close it
448
				fTracingStream.close();
449
			} catch (IOException e) {
450
			}
451
452
			requestMonitor.done();
432
        }
453
        }
433
    }
454
    }
434
    
455
    
(-)src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java (+3 lines)
Lines 12-17 Link Here
12
12
13
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
13
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
14
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
14
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
15
import org.eclipse.cdt.dsf.gdb.launching.DebugTracingConsole;
15
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
16
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
16
import org.eclipse.cdt.dsf.mi.service.command.AbstractCLIProcess;
17
import org.eclipse.cdt.dsf.mi.service.command.AbstractCLIProcess;
17
import org.eclipse.cdt.dsf.mi.service.command.MIInferiorProcess;
18
import org.eclipse.cdt.dsf.mi.service.command.MIInferiorProcess;
Lines 33-36 Link Here
33
	AbstractCLIProcess getCLIProcess();
34
	AbstractCLIProcess getCLIProcess();
34
35
35
	MIInferiorProcess getInferiorProcess();
36
	MIInferiorProcess getInferiorProcess();
37
	
38
    DebugTracingConsole getTracingConsole();
36
}
39
}
(-)src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java (-1 / +22 lines)
Lines 13-18 Link Here
13
package org.eclipse.cdt.dsf.gdb.service.command;
13
package org.eclipse.cdt.dsf.gdb.service.command;
14
14
15
import java.io.IOException;
15
import java.io.IOException;
16
import java.io.OutputStream;
16
import java.util.Hashtable;
17
import java.util.Hashtable;
17
import java.util.concurrent.Future;
18
import java.util.concurrent.Future;
18
import java.util.concurrent.TimeUnit;
19
import java.util.concurrent.TimeUnit;
Lines 30-35 Link Here
30
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
31
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
31
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
32
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
32
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
33
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
34
import org.eclipse.cdt.dsf.gdb.launching.DebugTracingConsole;
33
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
35
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
34
import org.eclipse.cdt.dsf.gdb.service.GDBRunControl_7_0;
36
import org.eclipse.cdt.dsf.gdb.service.GDBRunControl_7_0;
35
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
37
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
Lines 107-112 Link Here
107
    private AbstractCLIProcess fCLIProcess;
109
    private AbstractCLIProcess fCLIProcess;
108
    private MIInferiorProcess fInferiorProcess = null;
110
    private MIInferiorProcess fInferiorProcess = null;
109
    
111
    
112
    private DebugTracingConsole fTracingConsole = null;
113
	private OutputStream fTracingStream = null;
114
110
    private PTY fPty;
115
    private PTY fPty;
111
116
112
    public GDBControl_7_0(DsfSession session, ILaunchConfiguration config) { 
117
    public GDBControl_7_0(DsfSession session, ILaunchConfiguration config) { 
Lines 176-181 Link Here
176
        return fControlDmc;
181
        return fControlDmc;
177
    }
182
    }
178
    
183
    
184
    public DebugTracingConsole getTracingConsole() { 
185
    	return fTracingConsole;
186
    }
187
179
    public void terminate(final RequestMonitor rm) {
188
    public void terminate(final RequestMonitor rm) {
180
        // Schedule a runnable to be executed 2 seconds from now.
189
        // Schedule a runnable to be executed 2 seconds from now.
181
        // If we don't get a response to the quit command, this 
190
        // If we don't get a response to the quit command, this 
Lines 560-572 Link Here
560
569
561
        @Override
570
        @Override
562
        protected void initialize(final RequestMonitor requestMonitor) {
571
        protected void initialize(final RequestMonitor requestMonitor) {
563
            startCommandProcessing(fMIBackend.getMIInputStream(), fMIBackend.getMIOutputStream());
572
            // Create the DebugTracing console and its stream
573
        	fTracingConsole = new DebugTracingConsole();
574
        	fTracingStream = fTracingConsole.newOutputStream();
575
576
            startCommandProcessing(fMIBackend.getMIInputStream(), 
577
            		               fMIBackend.getMIOutputStream(),
578
            		               fTracingStream);
564
            requestMonitor.done();
579
            requestMonitor.done();
565
        }
580
        }
566
581
567
        @Override
582
        @Override
568
        protected void shutdown(RequestMonitor requestMonitor) {
583
        protected void shutdown(RequestMonitor requestMonitor) {
569
            stopCommandProcessing();
584
            stopCommandProcessing();
585
            try {
586
            	// Since we created the console stream, we are responsible to close it
587
				fTracingStream.close();
588
			} catch (IOException e) {
589
			}
590
570
            requestMonitor.done();
591
            requestMonitor.done();
571
        }
592
        }
572
    }
593
    }
(-)src/org/eclipse/cdt/dsf/gdb/launching/DebugTracingConsole.java (+106 lines)
Added Link Here
1
package org.eclipse.cdt.dsf.gdb.launching;
2
3
import java.text.MessageFormat;
4
5
import org.eclipse.core.runtime.CoreException;
6
import org.eclipse.debug.core.DebugEvent;
7
import org.eclipse.debug.core.DebugPlugin;
8
import org.eclipse.debug.core.IDebugEventSetListener;
9
import org.eclipse.debug.core.ILaunch;
10
import org.eclipse.debug.core.ILaunchConfiguration;
11
import org.eclipse.debug.core.ILaunchListener;
12
import org.eclipse.debug.core.model.IProcess;
13
import org.eclipse.debug.internal.ui.DebugUIPlugin;
14
import org.eclipse.debug.internal.ui.views.console.ConsoleMessages;
15
import org.eclipse.debug.ui.DebugUITools;
16
import org.eclipse.ui.console.ConsolePlugin;
17
import org.eclipse.ui.console.IConsole;
18
import org.eclipse.ui.console.IOConsole;
19
20
public class DebugTracingConsole extends IOConsole implements IDebugEventSetListener, ILaunchListener {
21
	private IProcess fProcess = null;
22
	
23
	public DebugTracingConsole() {
24
		super("", null, null, null, false); //$NON-NLS-1$
25
	}
26
27
	/**
28
	 * Start the tracing console.
29
	 * 
30
	 * @param process The GDB process instance part of the launch.
31
	 */
32
	public void start(IProcess process) {
33
		fProcess = process;
34
		resetName();
35
		
36
        DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
37
        DebugPlugin.getDefault().addDebugEventListener(this);
38
		ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{this});
39
	}
40
41
    public void handleDebugEvents(DebugEvent[] events) {
42
        for (int i = 0; i < events.length; i++) {
43
            DebugEvent event = events[i];
44
            if (event.getSource().equals(fProcess)) {
45
                if (event.getKind() == DebugEvent.TERMINATE) {
46
                    DebugPlugin.getDefault().removeDebugEventListener(this);
47
                }
48
49
                resetName();
50
            }
51
        }
52
    }
53
	
54
    protected String computeName() {
55
        String label = "Debug Tracing";
56
57
    	ILaunchConfiguration config = fProcess.getLaunch().getLaunchConfiguration();
58
        if (config != null && !DebugUITools.isPrivate(config)) {
59
        	String type = null;
60
        	try {
61
        		type = config.getType().getName();
62
        	} catch (CoreException e) {
63
        	}
64
        	StringBuffer buffer = new StringBuffer();
65
        	buffer.append(config.getName());
66
        	if (type != null) {
67
        		buffer.append(" ["); //$NON-NLS-1$
68
        		buffer.append(type);
69
        		buffer.append("] "); //$NON-NLS-1$
70
        	}
71
        	buffer.append(label);
72
        	label = buffer.toString();
73
        }
74
75
        if (fProcess.isTerminated()) {
76
        	return MessageFormat.format(ConsoleMessages.ProcessConsole_0, new String[] { label }); 
77
        }
78
        return label;
79
    }
80
    
81
    private void resetName() {
82
        final String newName = computeName();
83
        String name = getName();
84
        if (!name.equals(newName)) {
85
            Runnable r = new Runnable() {
86
                public void run() {
87
                	setName(newName);
88
                }
89
            };
90
            DebugUIPlugin.getStandardDisplay().asyncExec(r);
91
        }
92
    }
93
94
	public void launchAdded(ILaunch launch) {
95
	}
96
97
	public void launchChanged(ILaunch launch) {
98
	}
99
100
	public void launchRemoved(ILaunch launch) {
101
		if (fProcess.getLaunch().equals(launch)) {
102
        	DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
103
			ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[]{this});
104
		}		
105
	}
106
}

Return to bug 249227