Skip to content

Commit 991c762

Browse files
author
lamb
committed
getThreads
1 parent ed85e3e commit 991c762

3 files changed

Lines changed: 23 additions & 21 deletions

File tree

org.nodeclipse.debug/src/org/nodeclipse/debug/model/DebugTarget.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,26 @@ public class DebugTarget extends NodeDebugElement implements IDebugTarget {
2020
private IProcess process;
2121
private Process p;
2222
private List<Thread> threads;
23+
private Thread thread;
24+
private boolean suspended;
2325

2426
public DebugTarget(ILaunch launch, IProcess process, Process p) {
2527
super(null);
2628
this.launch = launch;
2729
this.process = process;
2830
this.p = p;
31+
this.thread = new Thread(this);
32+
threads.add(this.thread);
2933
}
3034

3135
@Override
3236
public boolean canTerminate() {
33-
// TODO Auto-generated method stub
34-
return process.canTerminate();
37+
return !isTerminated();
3538
}
3639

3740
@Override
3841
public boolean isTerminated() {
39-
return process.isTerminated();
42+
return getProcess().isTerminated();
4043
}
4144

4245
@Override
@@ -57,26 +60,33 @@ public void terminate() throws DebugException {
5760

5861
@Override
5962
public boolean canResume() {
60-
// TODO Auto-generated method stub
61-
return false;
63+
return !isTerminated() && isSuspended();
6264
}
6365

6466
@Override
6567
public boolean canSuspend() {
66-
// TODO Auto-generated method stub
67-
return false;
68+
return !isTerminated() && !isSuspended();
6869
}
6970

7071
@Override
7172
public boolean isSuspended() {
72-
// TODO Auto-generated method stub
73-
return false;
73+
return suspended;
74+
}
75+
76+
public void sendCommand(String command) {
77+
IStreamsProxy streamsProxy = process.getStreamsProxy();
78+
try {
79+
if (!isTerminated()) {
80+
streamsProxy.write(command + Constants.EOL);
81+
}
82+
} catch (IOException e) {
83+
LogUtil.error(e);
84+
}
7485
}
7586

7687
@Override
7788
public void resume() throws DebugException {
78-
// TODO Auto-generated method stub
79-
89+
sendCommand(Constants.CONT);
8090
}
8191

8292
@Override
@@ -105,7 +115,6 @@ public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
105115

106116
@Override
107117
public boolean canDisconnect() {
108-
// TODO Auto-generated method stub
109118
return false;
110119
}
111120

@@ -117,7 +126,6 @@ public void disconnect() throws DebugException {
117126

118127
@Override
119128
public boolean isDisconnected() {
120-
// TODO Auto-generated method stub
121129
return false;
122130
}
123131

@@ -133,12 +141,6 @@ public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugE
133141
return null;
134142
}
135143

136-
@Override
137-
public String getModelIdentifier() {
138-
// TODO Auto-generated method stub
139-
return null;
140-
}
141-
142144
@Override
143145
public IDebugTarget getDebugTarget() {
144146
return this;
@@ -165,7 +167,6 @@ public IThread[] getThreads() throws DebugException {
165167

166168
@Override
167169
public boolean hasThreads() throws DebugException {
168-
// TODO Auto-generated method stub
169170
return true;
170171
}
171172

org.nodeclipse.debug/src/org/nodeclipse/debug/model/Thread.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class Thread extends NodeDebugElement implements IThread {
1616
IStreamsProxy streamsProxy;
1717
private List<StackFrame> frames;
1818

19-
public Thread(IDebugTarget target, Thread thread) {
19+
public Thread(IDebugTarget target) {
2020
super(target);
2121
streamsProxy = target.getProcess().getStreamsProxy();
2222
}

org.nodeclipse.debug/src/org/nodeclipse/debug/util/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ public class Constants {
2727
public static final String STEP = "step";
2828
public static final String NEXT = "next";
2929
public static final String OUT = "out";
30+
public static final String CONT = "cont";
3031

3132
}

0 commit comments

Comments
 (0)