scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.08k stars 330 forks source link

Breakpoints are ignored [update: for the default package] #4961

Open GiGurra opened 1 year ago

GiGurra commented 1 year ago

Describe the bug

image

The above breakpoints are ignored when pressing "debug". The program just executes until it is finished without stopping at any breakpoints.

Metals version tested:

sbt 1.8.2

Windows 11

Expected behavior

Breakpoints should be respected

Operating system

Windows

Editor/Extension

VS Code

Version of Metals

0.11.10

Extra context or search terms

No response

GiGurra commented 1 year ago
case class Person(a: Int, b: String)
case class Banana(a: Int, b: String)

trait CanEat[A, B]:
  def eat(eater: A, eatMe: B): Unit

extension[X] (x: X)
  def eat[Y](y: Y)(using CanEat[X, Y]): Unit =
    println("Yo")
    summon[CanEat[X, Y]].eat(x, y)

given CanEat[Person, Banana] with
  def eat(eater: Person, eatMe: Banana): Unit = println(s"$eater eating $eatMe")

@main def hello(): Unit =
  println("start sleeping")
  Thread.sleep(1000)
  println("done sleeping")
  Person(2, "3").eat(Banana(3, "2")) //
tgodzik commented 1 year ago

I tried reproducing on windows and it seems to work. What Java are you using? Do you see anything in .metals/metals.log ? Could you maybe create .metals/dap-server.trace.json and .metals/dap-client.trace.json? If you run the program again it should save all the json rpc traces there, which we could use to debug. More info about that is here https://scalameta.org/metals/docs/contributors/getting-started#json-rpc-trace

GiGurra commented 1 year ago

I get this in the metals output/log


2023.02.11 21:40:07 INFO  tracing is enabled: C:\Users\johan\git\zio-crit\.metals\dap-server.trace.json
2023.02.11 21:40:07 INFO  tracing is enabled: C:\Users\johan\git\zio-crit\.metals\dap-client.trace.json
2023.02.11 21:40:07 INFO  Starting debug proxy for [hello]
2023.02.11 21:40:07 INFO  Trying to attach to remote debuggee VM kubernetes.docker.internal:27110 .
2023.02.11 21:40:07 INFO  Attaching to debuggee VM succeeded.
2023.02.11 21:40:09 INFO  Canceling debug proxy for [hello]
2023.02.11 21:40:09 INFO  Closing debug server tcp://0.0.0.0:27106```

Trying to figure out how to attach the json files
GiGurra commented 1 year ago

dap.trace.zip

GiGurra commented 1 year ago

Bloop uses C:\Program Files\Microsoft\jdk-17.0.6.10-hotspot

GiGurra commented 1 year ago

After discussion with @tgodzik we got the debugger semi working by adding my main class to a package (instead of the default package)

However, it should be noted that some lines/some breakpoints are ignored at the beginning of the application it seems, presumably if the execution passes them before the debugger has time to connect

image