Author Topic: Scala debugger  (Read 1878 times)

xotrox

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Scala debugger
« on: January 31, 2020, 08:10:10 PM »
Hi,
I'd like to debug scala sbt playframework web application.

Steps:
1) start with sbt workspace,
2) import required application files,
3) set proper sbt, scala compiler etc.,
4) in terminal start application using sbt -jvm-debug 5005 - application starts,
5) from slickedit starts scala_debug (default option for debugging in build tools),
6) slickedit tires to connect with pydbg to local host on random port. It takes 30 sec.,
7) timeout connection error occurs,
8) slickedit changes perspective to debug and immediately returns to editor perspective with bad socket error.

I tried also different way via scala_attach macro or attach to jvm... from debug menu with host: localhost, port: 5005.

My question are:
- why does slickedit use pydbg connection?
- why does it set random port even if I set it explicitly?
- is something wrong with my steps maybe?
- how can I attach debugger to 5005 for my web app?

I noticed also, when I use sbt workspace template and other template for same project with same project settings (other is set manually),
sbt workspace gives me chance to set breakpoints, but other template does not.
I mean that project set with other workspace template returns errors, that it is not possible to set breakpoints because files are not in source.

Thank you.   



 

 

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Scala debugger
« Reply #1 on: January 31, 2020, 08:58:03 PM »
Hmm, the "pydbg" is a bug in the display for that dialog.  It's not really running the python debugger.

I'm going to take a look and see if something is broken with the SBT project there.  I'd like to have done that before posting a reply, but it's decided it needs to download the compiler again, and it's going pretty slow for me.

I'm surprised attaching via "Debug -> Attach Debugger -> Attach to Java Virtual Machine" didn't work either. 

Probably the easiest thing to do right now is turn the debugging logging, and have you try to attach to the process again.

1) At the SlickEdit command prompt, type "set-var def-debug-logging 1" and press return.
2) Try to attach via the Debug -> Attach Debugger -> Attach to Java Virtual Machine
3) The resulting log will be in your configuration directory, under logs/debug.log.  (If you're not sure where your configuration directory is, it is shown in Help -> About).

For your other questions
- It doesn't really use pydbg.  There's a string resource I need to fix.
- For the scala debugger, there's a debug adapter that we connect to, the separate port is for that.  The adapter connects to the JDWP 5005 port.
- I didn't see anything wrong with your steps.  A timeout like that would usually indicate something going wrong with the debug adapter. 

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Scala debugger
« Reply #2 on: January 31, 2020, 09:17:51 PM »
Actually, I finally got sbt going.  It does look like the SBT support got broken. It looks like the execute target isn't being set up, and it tries to debug anyway, some failures cascade, and you get the timeout.   I'm looking into it.

The attach steps with "Attach to Java Virtual Machine" should still work, so if they don't, go ahead and get the debug logging I mentioned in the last post.


xotrox

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Re: Scala debugger
« Reply #3 on: February 01, 2020, 07:07:58 AM »
Hi.
Thank you for answers. I checked debug logs as you suggested and it seems that even debugger is attached to jvm
it doesn't set host and port.
Steps:
1) run application
2) Debug/Attach debugger/Attach to jvm...
3) host: localhost, port:5005
4) pydbg tries to connect
5) wait or cancel
6) slickedit goes to debug mode
7) after a while returns Bad socket error

Logs:
debug[2020-02-01T07:58:55Z]DBGp initialize: host=
debug[2020-02-01T07:58:55Z]DBGp initialize: port=
debug[2020-02-01T07:58:55Z]DBGp initialize: timeout=30000
debug[2020-02-01T07:58:55Z]DBGp initialize: debugger_args=-run  -socket=-2038 -server-socket=12 -feature-set=show_hidden=1
debug[2020-02-01T07:58:55Z]DBGp initialize: status=-107

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Scala debugger
« Reply #4 on: February 03, 2020, 02:29:26 PM »
I haven't been able to reproduce the attach problem so far.  From the error code in the log snippet, it makes it sound like the debug adapter failed to start.  The message is still referring to port for the debug adapter, it would need to get further before a connection to the JDWP 5005 port is made.

So let me get some more information.

1) Post the contents of the Help -> About box.  That will give me platform information.
2) What JVM version are you using?  You can go to the Build tool window and type in java -version to show which one we'll pick up for the adapter.
3) There's more verbose logging we can turn on.  Clear out the existing debug log, and then on the SlickEdit command line, type in "set-var def-debug-logging 2", and press return.  And try to attach again.  You can attach the debug.log file to your post.  Also, copy and paste the contents of the Build tool window to a file, and attach that as well.
4) With that level of debugging, it will have left an XML file with some information for the debug adapter in the temp directory.  It's based on the project name, so if your project was named SomeProgram, then the xml file would be /tmp/SomeProgramdbg.xml on a Unix or MacOS, or %TEMP%\SomeProgramdbg.xml on Windows.



patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Scala debugger
« Reply #5 on: February 03, 2020, 06:50:19 PM »
There will be a fix in the next hotfix that makes it so SBT Scala projects can once again be executed and debugged via the Build -> Execute and Debug -> Start.  This is only for SBT projects that have a "run" task that actually runs the program.  After the hotfix is applied, runnning "Build -> SBT Options..." will update your project file so that works.

Unfortunately, this doesn't change anything with your attach case failing, so we'll still need to collect the information I listed in my last post.