Skip to content

Commit a7c1e66

Browse files
committed
dlv: add an ability to show var/params and eval symbol for all stack frames, not for the topmost one
1 parent 69f6201 commit a7c1e66

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

src/com/goide/dlv/DlvStackFrame.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
class DlvStackFrame extends XStackFrame {
5555
private final DlvApi.Location myLocation;
5656
private final DlvCommandProcessor myProcessor;
57-
private final boolean myTop;
57+
private final int myId;
5858
private static final Set<String> NUMBERS = ContainerUtil.newTroveSet(
5959
"int8",
6060
"uint8",
@@ -78,22 +78,21 @@ class DlvStackFrame extends XStackFrame {
7878
"rune"
7979
);
8080

81-
public DlvStackFrame(DlvApi.Location location, DlvCommandProcessor processor, boolean top) {
81+
public DlvStackFrame(DlvApi.Location location, DlvCommandProcessor processor, int id) {
8282
myLocation = location;
8383
myProcessor = processor;
84-
myTop = top;
84+
myId = id;
8585
}
8686

8787
@Nullable
8888
@Override
8989
public XDebuggerEvaluator getEvaluator() {
90-
if (!myTop) return null;
9190
return new XDebuggerEvaluator() {
9291
@Override
9392
public void evaluate(@NotNull String expression,
9493
@NotNull final XEvaluationCallback callback,
9594
@Nullable XSourcePosition expressionPosition) {
96-
myProcessor.send(new DlvRequest.EvalSymbol(expression))
95+
myProcessor.send(new DlvRequest.EvalSymbol(expression, myId))
9796
.done(new Consumer<DlvApi.Variable>() {
9897
@Override
9998
public void consume(@NotNull DlvApi.Variable variable) {
@@ -194,16 +193,12 @@ private <T> Promise<T> send(@NotNull DlvRequest<T> request) {
194193

195194
@Override
196195
public void computeChildren(@NotNull final XCompositeNode node) {
197-
if (!myTop) {
198-
super.computeChildren(node);
199-
return;
200-
}
201-
send(new DlvRequest.ListLocalVars()).done(new Consumer<List<DlvApi.Variable>>() {
196+
send(new DlvRequest.ListLocalVars(myId)).done(new Consumer<List<DlvApi.Variable>>() {
202197
@Override
203198
public void consume(@NotNull List<DlvApi.Variable> variables) {
204199
final XValueChildrenList xVars = new XValueChildrenList(variables.size());
205200
for (DlvApi.Variable v : variables) xVars.add(v.name, createXValue(v, GoIcons.VARIABLE));
206-
send(new DlvRequest.ListFunctionArgs()).done(new Consumer<List<DlvApi.Variable>>() {
201+
send(new DlvRequest.ListFunctionArgs(myId)).done(new Consumer<List<DlvApi.Variable>>() {
207202
@Override
208203
public void consume(@NotNull List<DlvApi.Variable> args) {
209204
for (DlvApi.Variable v : args) xVars.add(v.name, createXValue(v, GoIcons.PARAMETER));

src/com/goide/dlv/DlvSuspendContext.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public DlvExecutionStack(int threadId, @NotNull List<DlvApi.Location> locations,
5555
myLocations = locations;
5656
myProcessor = processor;
5757
myStack = ContainerUtil.newArrayListWithCapacity(locations.size());
58-
for (DlvApi.Location location : myLocations) {
59-
boolean top = myStack.isEmpty();
60-
if (!top) {
58+
for (int i = 0; i < myLocations.size(); i++) {
59+
DlvApi.Location location = myLocations.get(i);
60+
if (i != 0) {
6161
location.line -= 1; // todo: bizarre
6262
}
63-
myStack.add(new DlvStackFrame(location, myProcessor, top));
63+
myStack.add(new DlvStackFrame(location, myProcessor, i));
6464
}
6565
}
6666

src/com/goide/dlv/protocol/DlvRequest.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,22 @@ public StacktraceGoroutine() {
115115
}
116116

117117
private abstract static class Locals<T> extends DlvRequest<T> {
118-
private Locals() {
118+
Locals(int frameId) {
119119
writeInt("GoroutineID", -1);
120-
writeInt("Frame", 0);
120+
writeInt("Frame", frameId);
121121
}
122122
}
123123

124124
public final static class ListLocalVars extends Locals<List<DlvApi.Variable>> {
125+
public ListLocalVars(int frameId) {
126+
super(frameId);
127+
}
125128
}
126129

127130
public final static class ListFunctionArgs extends Locals<List<DlvApi.Variable>> {
131+
public ListFunctionArgs(int frameId) {
132+
super(frameId);
133+
}
128134
}
129135

130136
public final static class Command extends DlvRequest<DlvApi.DebuggerState> {
@@ -134,12 +140,12 @@ public Command(@Nullable String command) {
134140
}
135141

136142
public final static class EvalSymbol extends DlvRequest<DlvApi.Variable> {
137-
public EvalSymbol(@NotNull String symbol) {
143+
public EvalSymbol(@NotNull String symbol, int frameId) {
138144
try { // todo: ask vladimir how to simplify this
139145
writer.name(argumentsKeyName()).beginArray().beginObject()
140146
.name("Scope").beginObject()
141147
.name("GoroutineID").value(-1)
142-
.name("Frame").value(0).endObject()
148+
.name("Frame").value(frameId).endObject()
143149
.name("Symbol").value(symbol).endObject().endArray();
144150
}
145151
catch (IOException e) {

0 commit comments

Comments
 (0)