microsoft / microsoft/debug-adapter-protocol

Allow resolving the source location of stack frames as needed

Open
#407 12 comments 4 reactions 1 assignee View on GitHub

@roblourens is already working on this.

Since Jun 26, 2023.

feature-request
Dominant language
HTML
Stars
1.8k
Forks
173
Avg merge
7d 7h
Merged PRs (30d)
2

Description

Use Case: When the debugger stops at a breakpoint, the DAP requests the stackTrace with the source and line information. This works fine when the source code comes from existing files, but it causes problems when the source code is missing and has to be generated from disassembly tools.

The problem is that the decompiled code has different line numbers than the original source code, which leads to a mismatch when debugging with the decompiled source. The current workaround for the Java debugger is to decompile the sources of all the stack frames of the paused thread before sending them to the client, and to adjust the original line numbers of the stack frames to match the decompiled ones. The drawback of this approach is that it requires decompiling all the stack frames beforehand, which makes the frames request much slower.

Proposal: A possible solution is to add a new DAP request called resolveStackTrace. If a stack frame is marked as resolved, it means that it has the correct source and line information. The client can open and view it as usual. If a stack frame is marked as unresolved, the client has to resolve it first before opening it.

interface StackFrame {
  ...
  /**
   * If true, the source and line has been resolved and you can view its source directly.
   * Otherwise, the client will send another request to resolve the
   * source line first when you opens it.
   */
 isResolved: boolean;
}

/**
 * Resolve the stack trace information such as source and line.
 */
interface ResolveStackTraceRequest extends Request {
  command: 'resolveStackTrace';
  arguments: ResolveStackTraceArguments;
}

interface ResolveStackTraceArguments {
  frameId: number;
}

interface ResolveStackTraceResponse extends Response {
  body: {
    stackFrame: StackFrame;
  };
}

// cc: @isidorn @akaroml @nickzhums @jdneo

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.