Skip to content

[GR-74746] Representation of call-stak in VSCode while debugging #13286

@marat-gainullin

Description

@marat-gainullin

Describe GraalVM and your environment :

  • GraalVM version or commit id if built from source: 25.0.2
  • JDK version: open-jdk25
  • OS and OS Version: 24.04.2-Ubuntu
  • Architecture: amd64
  • The output of java -Xinternalversion:
 OpenJDK 64-Bit Server VM (21.0.10+7-Ubuntu-124.04) for linux-amd64 JRE (21.0.10+7-Ubuntu-124.04), built on 2026-01-22T23:46:23Z by "buildd" with gcc 13.3.0

Have you verified this issue still happens when using the latest snapshot?
Yes

Describe the issue
Call-stack of a debugged program is not shown properly.

Code snippet or code repository that reproduces the issue

    @Test
    public void inspectorScriptTest() throws IOException {
        try (var context = Context
                .newBuilder(JS)
                .allowIO(IOAccess.ALL)
                .option("inspect", "8787")
                .option("inspect.Suspend", "true")
                .build()
        ) {
            context.eval(Source
                    .newBuilder(JS, """
                            function f1() {
                                console.log("test1")
                                console.log("test2")
                                console.log("test3")
                                f2()
                            }
                            
                            function f2() {
                                console.log("test5")
                                console.log("test6")
                                console.log("test7")
                                console.log("test8")
                                f3()
                            }
                            
                            function f3() {
                                console.log("test4")
                                console.log("test9")
                                console.log("test10")
                                console.log("test11")
                                console.log("test12")
                            }
                            
                            f1()
                            """, "stack-inspect")
                    .build()
            );
        }
    }
Image

Steps to reproduce the issue

  1. Launch the above JUnit test.
  2. Connect withe the script program using the following launch configuration:
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "GraalJS-Application",
      "type": "node",
      "request": "attach",
      "address": "localhost",
      "port": 8787,
      "showAsyncStacks": true
    }
  ]
}

  1. Inspect the call stack in the left panel of the VSCode's debugger

Expected behavior
Each item of the call-stack list should have be a name of the executed function or text :program.

Additional context

Details This happens, because VSCode uses internal sources with the following suffix:
//# sourceURL=eval-...

And the com.oracle.truffle.tools.chromeinspector.InspectorRuntime class makes some text handling to call this function in the context of the debugged program. It removes all the whitespace first and then adds ( and ).apply to the text of the function. Such handling ignores one line comments and therefore the function fails. Even if the text of the function from VSCode would not contain the at one line comment, the call-stack would show something like undefined.f1. This is undesired as well. Can you please investigate the incompatibilities there?

Metadata

Metadata

Labels

bugtoolsRelating to Truffle Tools (CPUSampler, Coverage tool, etc)truffle

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions