Skip to content

Commit ed85e3e

Browse files
author
lamb
committed
debug相关类全添加上 有些方法待实现
1 parent af672cd commit ed85e3e

5 files changed

Lines changed: 182 additions & 57 deletions

File tree

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

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
public class StackFrame extends NodeDebugElement implements IStackFrame {
1111

1212
private Thread thread;
13+
private IVariable[] variables;
1314

1415
public StackFrame(IDebugTarget target, Thread thread) {
1516
super(target);
@@ -19,110 +20,97 @@ public StackFrame(IDebugTarget target, Thread thread) {
1920

2021
@Override
2122
public boolean canStepInto() {
22-
// TODO Auto-generated method stub
2323
return thread.canStepInto();
2424
}
2525

2626
@Override
2727
public boolean canStepOver() {
28-
// TODO Auto-generated method stub
2928
return thread.canStepOver();
3029
}
3130

3231
@Override
3332
public boolean canStepReturn() {
34-
// TODO Auto-generated method stub
3533
return thread.canStepReturn();
3634
}
3735

3836
@Override
3937
public boolean isStepping() {
40-
// TODO Auto-generated method stub
41-
return false;
38+
return thread.isStepping();
4239
}
4340

4441
@Override
4542
public void stepInto() throws DebugException {
46-
// TODO Auto-generated method stub
47-
43+
thread.stepInto();
4844
}
4945

5046
@Override
5147
public void stepOver() throws DebugException {
52-
// TODO Auto-generated method stub
53-
48+
thread.stepOver();
5449
}
5550

5651
@Override
5752
public void stepReturn() throws DebugException {
58-
// TODO Auto-generated method stub
59-
53+
thread.stepReturn();
6054
}
6155

6256
@Override
6357
public boolean canResume() {
64-
// TODO Auto-generated method stub
65-
return false;
58+
return getDebugTarget().canResume();
6659
}
6760

6861
@Override
6962
public boolean canSuspend() {
70-
// TODO Auto-generated method stub
71-
return false;
63+
return getDebugTarget().canSuspend();
7264
}
7365

7466
@Override
7567
public boolean isSuspended() {
76-
// TODO Auto-generated method stub
77-
return false;
68+
return getDebugTarget().isSuspended();
7869
}
7970

8071
@Override
8172
public void resume() throws DebugException {
82-
// TODO Auto-generated method stub
83-
73+
getDebugTarget().resume();
8474
}
8575

8676
@Override
8777
public void suspend() throws DebugException {
88-
// TODO Auto-generated method stub
89-
78+
getDebugTarget().suspend();
9079
}
9180

9281
@Override
9382
public boolean canTerminate() {
94-
// TODO Auto-generated method stub
95-
return false;
83+
return getDebugTarget().canTerminate();
9684
}
9785

9886
@Override
9987
public boolean isTerminated() {
100-
// TODO Auto-generated method stub
101-
return false;
88+
return getDebugTarget().isTerminated();
10289
}
10390

10491
@Override
10592
public void terminate() throws DebugException {
106-
// TODO Auto-generated method stub
107-
93+
getDebugTarget().terminate();
10894
}
10995

11096
@Override
11197
public IThread getThread() {
112-
// TODO Auto-generated method stub
113-
return null;
98+
return thread;
11499
}
115100

116101
@Override
117102
public IVariable[] getVariables() throws DebugException {
118103
// TODO Auto-generated method stub
119-
return null;
104+
if (variables == null) {
105+
// variables = getVariablesImpl();
106+
}
107+
108+
return variables;
120109
}
121110

122111
@Override
123112
public boolean hasVariables() throws DebugException {
124-
// TODO Auto-generated method stub
125-
return false;
113+
return true;
126114
}
127115

128116
@Override

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

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
package org.nodeclipse.debug.model;
22

3+
import java.io.IOException;
4+
import java.util.ArrayList;
5+
import java.util.List;
36
import org.eclipse.debug.core.DebugException;
47
import org.eclipse.debug.core.model.IBreakpoint;
58
import org.eclipse.debug.core.model.IDebugTarget;
69
import org.eclipse.debug.core.model.IStackFrame;
10+
import org.eclipse.debug.core.model.IStreamsProxy;
711
import org.eclipse.debug.core.model.IThread;
12+
import org.nodeclipse.debug.util.Constants;
13+
import org.nodeclipse.debug.util.LogUtil;
814

915
public class Thread extends NodeDebugElement implements IThread {
16+
IStreamsProxy streamsProxy;
17+
private List<StackFrame> frames;
1018

11-
public Thread(IDebugTarget target) {
19+
public Thread(IDebugTarget target, Thread thread) {
1220
super(target);
13-
// TODO Auto-generated constructor stub
21+
streamsProxy = target.getProcess().getStreamsProxy();
1422
}
1523

1624
@Override
@@ -58,76 +66,86 @@ public boolean isStepping() {
5866
return false;
5967
}
6068

69+
public void sendCommand(String command) {
70+
try {
71+
if (!isTerminated()) {
72+
streamsProxy.write(command + Constants.EOL);
73+
}
74+
} catch (IOException e) {
75+
LogUtil.error(e);
76+
}
77+
}
78+
6179
@Override
6280
public void stepInto() throws DebugException {
63-
// TODO Auto-generated method stub
64-
81+
sendCommand(Constants.STEP);
6582
}
6683

6784
@Override
6885
public void stepOver() throws DebugException {
69-
// TODO Auto-generated method stub
70-
86+
sendCommand(Constants.NEXT);
7187
}
7288

7389
@Override
7490
public void stepReturn() throws DebugException {
75-
// TODO Auto-generated method stub
76-
91+
sendCommand(Constants.OUT);
7792
}
7893

7994
@Override
8095
public boolean canTerminate() {
81-
// TODO Auto-generated method stub
82-
return false;
96+
return getDebugTarget().canTerminate();
8397
}
8498

8599
@Override
86100
public boolean isTerminated() {
87-
// TODO Auto-generated method stub
88-
return false;
101+
return getDebugTarget().isTerminated();
89102
}
90103

91104
@Override
92105
public void terminate() throws DebugException {
93-
// TODO Auto-generated method stub
94-
106+
getDebugTarget().terminate();
95107
}
96108

97109
@Override
98110
public IStackFrame[] getStackFrames() throws DebugException {
99-
// TODO Auto-generated method stub
100-
return null;
111+
//TODO
112+
if (frames == null) {
113+
frames = new ArrayList<StackFrame>();
114+
115+
//for (StackFrame frame : frames) {
116+
StackFrame frame = new StackFrame(getDebugTarget(), this);
117+
118+
frames.add(frame);
119+
//}
120+
}
121+
122+
return frames.toArray(new IStackFrame[frames.size()]);
101123
}
102124

103125
@Override
104126
public boolean hasStackFrames() throws DebugException {
105-
// TODO Auto-generated method stub
106-
return false;
127+
return getStackFrames().length > 0;
107128
}
108129

109130
@Override
110131
public int getPriority() throws DebugException {
111-
// TODO Auto-generated method stub
112132
return 0;
113133
}
114134

115135
@Override
116136
public IStackFrame getTopStackFrame() throws DebugException {
117-
// TODO Auto-generated method stub
118-
return null;
137+
IStackFrame[] frames = getStackFrames();
138+
return frames.length > 0 ? frames[0] : null;
119139
}
120140

121141
@Override
122142
public String getName() throws DebugException {
123-
// TODO Auto-generated method stub
124-
return null;
143+
return "nodethread-" + this.toString();
125144
}
126145

127146
@Override
128147
public IBreakpoint[] getBreakpoints() {
129-
// TODO Auto-generated method stub
130-
return null;
148+
return new IBreakpoint[0];
131149
}
132150

133151
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.nodeclipse.debug.model;
2+
3+
import org.eclipse.debug.core.DebugException;
4+
import org.eclipse.debug.core.model.IDebugTarget;
5+
import org.eclipse.debug.core.model.IValue;
6+
import org.eclipse.debug.core.model.IVariable;
7+
8+
public class Value extends NodeDebugElement implements IValue {
9+
private String value;
10+
11+
public Value(IDebugTarget target, String value) {
12+
super(target);
13+
this.value = value;
14+
}
15+
16+
@Override
17+
public String getReferenceTypeName() throws DebugException {
18+
// TODO Auto-generated method stub
19+
return "string";
20+
}
21+
22+
@Override
23+
public String getValueString() throws DebugException {
24+
return value;
25+
}
26+
27+
@Override
28+
public boolean isAllocated() throws DebugException {
29+
// TODO Auto-generated method stub
30+
return true;
31+
}
32+
33+
@Override
34+
public IVariable[] getVariables() throws DebugException {
35+
// TODO Auto-generated method stub
36+
return new IVariable[0];
37+
}
38+
39+
@Override
40+
public boolean hasVariables() throws DebugException {
41+
// TODO Auto-generated method stub
42+
return false;
43+
}
44+
45+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package org.nodeclipse.debug.model;
2+
3+
import org.eclipse.debug.core.DebugException;
4+
import org.eclipse.debug.core.model.IDebugTarget;
5+
import org.eclipse.debug.core.model.IValue;
6+
import org.eclipse.debug.core.model.IVariable;
7+
8+
public class Variable extends NodeDebugElement implements IVariable {
9+
private Value value;
10+
11+
public Variable(IDebugTarget target) {
12+
super(target);
13+
// TODO Auto-generated method stub
14+
value = new Value(target, "value");
15+
}
16+
17+
@Override
18+
public void setValue(String expression) throws DebugException {
19+
// TODO Auto-generated method stub
20+
21+
}
22+
23+
@Override
24+
public void setValue(IValue value) throws DebugException {
25+
// TODO Auto-generated method stub
26+
27+
}
28+
29+
@Override
30+
public boolean supportsValueModification() {
31+
// TODO Auto-generated method stub
32+
return false;
33+
}
34+
35+
@Override
36+
public boolean verifyValue(String expression) throws DebugException {
37+
// TODO Auto-generated method stub
38+
return false;
39+
}
40+
41+
@Override
42+
public boolean verifyValue(IValue value) throws DebugException {
43+
// TODO Auto-generated method stub
44+
return false;
45+
}
46+
47+
@Override
48+
public IValue getValue() throws DebugException {
49+
// TODO Auto-generated method stub
50+
return value;
51+
}
52+
53+
@Override
54+
public String getName() throws DebugException {
55+
// TODO Auto-generated method stub
56+
return null;
57+
}
58+
59+
@Override
60+
public String getReferenceTypeName() throws DebugException {
61+
// TODO Auto-generated method stub
62+
return value.getReferenceTypeName();
63+
}
64+
65+
@Override
66+
public boolean hasValueChanged() throws DebugException {
67+
// TODO Auto-generated method stub
68+
return false;
69+
}
70+
71+
}

0 commit comments

Comments
 (0)