Wasm: fix issues in debugger

This commit is contained in:
Alexey Andreev 2022-12-14 16:50:18 +01:00
parent 6808d9e517
commit 6c91192794
2 changed files with 32 additions and 25 deletions

View File

@ -162,6 +162,17 @@ public class Debugger {
return Promise.allVoid(jsBreakpointPromises);
}
private Promise<Void> destroyTemporaryBreakpoints() {
var temporaryBreakpoints = new ArrayList<>(this.temporaryBreakpoints);
this.temporaryBreakpoints.clear();
var promises = new ArrayList<Promise<Void>>();
for (var jsBreakpoint : temporaryBreakpoints) {
promises.add(jsBreakpoint.destroy());
}
callStack = null;
return Promise.allVoid(promises);
}
private boolean addJsBreakpoints(CallFrame frame, JavaScriptScript script, boolean enterMethod,
Set<JavaScriptLocation> successors) {
var debugInfo = debugInformationMap.get(script);
@ -197,10 +208,10 @@ public class Debugger {
var callAddresses = IntHashSet.from(wasmStepLocationsFinder.getCallAddresses());
var result = createTemporaryBreakpoints(locations, br -> {
if (br != null && br.isValid() && callAddresses.contains(br.getLocation().getColumn())) {
javaScriptDebugger.stepInto();
return false;
destroyTemporaryBreakpoints().thenVoid(x -> javaScriptDebugger.stepInto());
return true;
}
return true;
return false;
});
return result.thenVoid(x -> javaScriptDebugger.stepOut());
}
@ -659,31 +670,26 @@ public class Debugger {
}
private void firePaused(JavaScriptBreakpoint breakpoint) {
var temporaryBreakpoints = new ArrayList<>(this.temporaryBreakpoints);
var handler = temporaryBreakpointHandler;
this.temporaryBreakpoints.clear();
temporaryBreakpointHandler = null;
var promises = new ArrayList<Promise<Void>>();
for (var jsBreakpoint : temporaryBreakpoints) {
promises.add(jsBreakpoint.destroy());
}
callStack = null;
Promise.allVoid(promises).thenVoid(v -> {
Breakpoint javaBreakpoint = null;
JavaScriptBreakpoint tmpBreakpoint = null;
if (breakpoint != null) {
if (temporaryBreakpoints.contains(breakpoint)) {
tmpBreakpoint = breakpoint;
} else {
javaBreakpoint = breakpointMap.get(breakpoint);
}
Breakpoint javaBreakpoint = null;
JavaScriptBreakpoint tmpBreakpoint = null;
if (breakpoint != null) {
if (temporaryBreakpoints.contains(breakpoint)) {
tmpBreakpoint = breakpoint;
} else {
javaBreakpoint = breakpointMap.get(breakpoint);
}
if (handler == null || !handler.test(tmpBreakpoint)) {
}
if (handler == null || !handler.test(tmpBreakpoint)) {
var pausedAtBreakpoint = javaBreakpoint;
destroyTemporaryBreakpoints().thenVoid(v -> {
for (var listener : getListeners()) {
listener.paused(javaBreakpoint);
listener.paused(pausedAtBreakpoint);
}
}
});
});
}
}
private void fireAttached() {

View File

@ -484,9 +484,10 @@ public class ChromeRDPDebugger extends BaseChromeRDPDebugger implements JavaScri
return new RDPValue(this, null, remoteValue.getType(), remoteValue.getObjectId(),
true);
}
default:
return new RDPValue(this, remoteValue.getValue().asText(), remoteValue.getType(),
remoteValue.getObjectId(), false);
default: {
var valueAsText = remoteValue.getValue() != null ? remoteValue.getValue().asText() : "null";
return new RDPValue(this, valueAsText, remoteValue.getType(), remoteValue.getObjectId(), false);
}
}
}