protected async stackTraceRequest()

in src/debug-adapter/client.ts [283:320]


  protected async stackTraceRequest(
    response: DebugProtocol.StackTraceResponse,
    args: DebugProtocol.StackTraceArguments,
  ) {
    const event = await this.bazelConnection.sendRequest({
      listFrames: skylark_debugging.ListFramesRequest.create({
        threadId: args.threadId,
      }),
    });

    if (event.listFrames) {
      const bazelFrames = event.listFrames.frame;
      const vsFrames = new Array<StackFrame>();
      for (const bazelFrame of bazelFrames) {
        const frameHandle = this.frameHandles.create(bazelFrame);
        this.frameThreadIds.set(frameHandle, args.threadId);

        const location = bazelFrame.location;
        const vsFrame = new StackFrame(
          frameHandle,
          bazelFrame.functionName || "<global scope>",
        );
        if (location) {
          // Resolve the real path to the file, which will make sure that when
          // the user interacts with the stack frame, VS Code loads the file
          // from it's actual path instead of from a location inside Bazel's
          // output base.
          const sourcePath = fs.realpathSync(location.path);
          vsFrame.source = new Source(path.basename(sourcePath), sourcePath);
          vsFrame.line = location.lineNumber;
        }
        vsFrames.push(vsFrame);
      }
      response.body = { stackFrames: vsFrames, totalFrames: vsFrames.length };
    }

    this.sendResponse(response);
  }