2424
2525import org.apache.commons.lang3.StringUtils;
2626
27+ import com.google.gson.JsonObject;
2728import com.microsoft.java.debug.core.AsyncJdwpUtils;
2829import com.microsoft.java.debug.core.DebugSettings;
2930import com.microsoft.java.debug.core.DebugUtility;
4142import com.microsoft.java.debug.core.protocol.Requests.StackTraceArguments;
4243import com.microsoft.java.debug.core.protocol.Responses;
4344import com.microsoft.java.debug.core.protocol.Types;
45+ import com.microsoft.java.debug.core.protocol.Events.TelemetryEvent;
4446import com.sun.jdi.AbsentInformationException;
4547import com.sun.jdi.IncompatibleThreadStateException;
4648import com.sun.jdi.LocalVariable;
5456import com.sun.jdi.request.BreakpointRequest;
5557
5658public class StackTraceRequestHandler implements IDebugRequestHandler {
59+ private ThreadLocal<Boolean> isDecompilerInvoked = new ThreadLocal<>();
5760
5861 @Override
5962 public List<Command> getTargetCommands() {
@@ -62,6 +65,8 @@ public List<Command> getTargetCommands() {
6265
6366 @Override
6467 public CompletableFuture<Response> handle(Command command, Arguments arguments, Response response, IDebugAdapterContext context) {
68+ final long startAt = System.currentTimeMillis();
69+ isDecompilerInvoked.set(false);
6570 StackTraceArguments stacktraceArgs = (StackTraceArguments) arguments;
6671 List<Types.StackFrame> result = new ArrayList<>();
6772 if (stacktraceArgs.startFrame < 0 || stacktraceArgs.levels < 0) {
@@ -108,6 +113,15 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments,
108113 }
109114 }
110115 response.body = new Responses.StackTraceResponseBody(result, totalFrames);
116+ long duration = System.currentTimeMillis() - startAt;
117+ JsonObject properties = new JsonObject();
118+ properties.addProperty("command", "stackTrace");
119+ properties.addProperty("duration", duration);
120+ properties.addProperty("decompileSupport", DebugSettings.getCurrent().debugSupportOnDecompiledSource.toString());
121+ if (isDecompilerInvoked.get() != null) {
122+ properties.addProperty("isDecompilerInvoked", Boolean.toString(isDecompilerInvoked.get()));
123+ }
124+ context.getProtocolServer().sendEvent(new TelemetryEvent("dap", properties));
111125 return CompletableFuture.completedFuture(response);
112126 }
113127
@@ -198,6 +212,7 @@ private Types.StackFrame convertDebuggerStackFrameToClient(StackFrameInfo jdiFra
198212 int[] renderLines = AdapterUtils.binarySearchMappedLines(lineMappings, clientLineNumber);
199213 if (renderLines != null && renderLines.length > 0) {
200214 clientLineNumber = renderLines[0];
215+ isDecompilerInvoked.set(true);
201216 }
202217 }
203218
0 commit comments