3
* Created on Mar 23, 2004
4
* License: Common Public License v1.0
6
package org.python.pydev.debug.model;
8
import org.eclipse.core.runtime.IPath;
9
import org.eclipse.debug.core.DebugEvent;
10
import org.eclipse.debug.core.DebugException;
11
import org.eclipse.debug.core.DebugPlugin;
12
import org.eclipse.debug.core.IBreakpointManager;
13
import org.eclipse.debug.core.ILaunch;
14
import org.eclipse.debug.core.model.IProcess;
15
import org.eclipse.debug.core.model.IThread;
16
import org.python.pydev.debug.model.remote.RemoteDebugger;
18
* Debugger class that represents a single python process.
20
* It deals with events from RemoteDebugger.
21
* Breakpoint updating.
23
public class PyDebugTarget extends AbstractDebugTarget {
24
//private ILaunch launch;
25
private IProcess process;
27
public PyDebugTarget(ILaunch launch, IProcess process, IPath file, RemoteDebugger debugger) {
29
this.process = process;
31
this.debugger = debugger;
32
this.threads = new IThread[0];
33
launch.addDebugTarget(this);
34
debugger.setTarget(this);
35
IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
36
breakpointManager.addBreakpointListener(this);
37
// we have to know when we get removed, so that we can shut off the debugger
38
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
41
public void launchRemoved(ILaunch launch) {
42
// shut down the remote debugger when parent launch
43
if (launch == this.launch) {
44
IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
45
breakpointManager.removeBreakpointListener(this);
51
public IProcess getProcess() {
55
public boolean canTerminate() {
56
// We can always terminate, it does no harm
63
public boolean isTerminated() {
67
return process.isTerminated();
70
public void terminate() throws DebugException {
71
if (debugger != null){
72
debugger.disconnect();
75
threads = new IThread[0];
80
fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
84
public ILaunch getLaunch() {