Author Topic: Attach to Virtual Machine not working  (Read 1332 times)

kwilliams

  • Community Member
  • Posts: 28
  • Hero Points: 0
Attach to Virtual Machine not working
« on: July 14, 2021, 12:28:47 am »
Hi,

I have a Scala project that I want to debug. When I select Debug -> Attach Debugger -> Attach to Java Virtual Machine, nothing happens. I expected a dialog to ask for remote debugging information like the port.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1580
  • Hero Points: 140
Re: Attach to Virtual Machine not working
« Reply #1 on: July 14, 2021, 02:33:10 pm »
I'm assuming you've got the SBT project you mentioned in another post open.

It should pop up a modal dialog when you select that. And it looks like if there's an error before then, it should pop up a message box.  Very strange.

Can you still type in the editor window after that?  Is there any output in the "Build" tool window?  If you try it again, look in the status bar at the bottom left, is there any message there?

If you're on Linux, what window manager are you using?

kwilliams

  • Community Member
  • Posts: 28
  • Hero Points: 0
Re: Attach to Virtual Machine not working
« Reply #2 on: July 20, 2021, 09:00:10 pm »
Thanks for responding.

It turns out that I did not have my JDK configured in the SlickEdit project. So now, I get a pop-up that say: "could not find a 'tool.jar' for your configured JDK.".

I am using OpenJDK 11. Searching around, it sounds like OpenJdk may have moved things around a bit. The contents of tools.jar, rt.jar and a couple other have been moved to different jar files.

It sounds like Slickedit would need to update to account for this unless there is some way to tell it to look somewhere else.
« Last Edit: July 20, 2021, 09:11:38 pm by kwilliams »

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1580
  • Hero Points: 140
Re: Attach to Virtual Machine not working
« Reply #3 on: July 21, 2021, 01:54:35 pm »
Tools.jar got repackaged for Java 1.9 I think.  The debugger code should account for that, and it works for me on OpenJDK 11.0.11.   I suspect the version comparison, it's got a lot of cases from dealing with the version conventions of different JDK providers over the years, so there may be some corner case it's failing on that I'm not seeing.

What's the output you get for "java --version" on your system?  And if you go into the Tools -> Options dialog, and go to Languages -> Application Languages -> Java -> Compiler Properties, what's in the "Compiler Name" pulldown?

kwilliams

  • Community Member
  • Posts: 28
  • Hero Points: 0
Re: Attach to Virtual Machine not working
« Reply #4 on: July 21, 2021, 05:07:42 pm »
My Java version is Amazon Corretto-11.0.6 and compiler name is JDK 11.0.6

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1580
  • Hero Points: 140
Re: Attach to Virtual Machine not working
« Reply #5 on: July 21, 2021, 06:31:35 pm »
I can reproduce with JDK as well.  Taking a look at it, it should be hot-fixable.

kwilliams

  • Community Member
  • Posts: 28
  • Hero Points: 0
Re: Attach to Virtual Machine not working
« Reply #6 on: July 21, 2021, 08:04:16 pm »
Awesome!

thanks for looking into this.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1580
  • Hero Points: 140
Re: Attach to Virtual Machine not working
« Reply #7 on: July 23, 2021, 02:16:58 pm »
The fix for this will be in the next 25.0.2 hotfix. 

kwilliams

  • Community Member
  • Posts: 28
  • Hero Points: 0
Re: Attach to Virtual Machine not working
« Reply #8 on: August 27, 2021, 06:35:51 pm »
I applied the hotfix, but now I get “Error waiting for pydbgp connection: Socket timed out” (which is weird because I tried to attach to a java jvm and pydbg is a Python debugger).

It’s waiting for a connection on 127.0.0.1:55151.

I using the following menu: “Debug->Attach-Debugger->Attach to Java Virtual Machine”

I confirmed that I could attach to the VM with the JDB command line.

Am I doing it wrong?

Here is the text of the dbg.xml file:
<debug>
<logging v="0"/>
<setJDWPEnvironment v="0"/>
<jdwpHost v="127.0.0.1"/>
<jdwpPort v="5006"/>
<idePort v="55151"/>
<workingDir v="C:\Code\MI\7.5Exp\EnGen\Client\Library\"/>
</debug>

In subsequent attempts the attach dialog would not come up, even after restart.

btw, I'm running Windows 10.

Thank you.

Kurt

« Last Edit: August 27, 2021, 07:30:07 pm by kwilliams »

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1580
  • Hero Points: 140
Re: Attach to Virtual Machine not working
« Reply #9 on: August 27, 2021, 07:53:57 pm »
Hmm, the "pydbgp" reference is a UI mistake from sharing some of the setup UI, it's using the right protocol underneath.

Nothing looks obviously wrong with the dbg.xml.   With a timeout like that, it sounds like something that could have prevented the debuggee from connecting back to our debugger.  If the debuggee had died, we would pick up on that before a full timeout.

We can enable some debug logging.  Restart SlickEdit, go to the SlickEdit command line and type in "set-var def-debug-logging 2", and then try to attach the debugger.  This will produce some output in the Build window.  (and if it gets far enough, also some output will go into your configuration directory under logs/debug.log.  On windows, the default configuration directory is under Documents\My SlickEdit Config.   You can also see it in the Help -> About dialog).

Post the output from those two places.  And afterwards, run "set-var def-debug-logging 0", it's a persistent setting and can build up a large set of logs pretty fast.

It probably doesn't matter, but what version of SBT are you using?

kwilliams

  • Community Member
  • Posts: 28
  • Hero Points: 0
Re: Attach to Virtual Machine not working
« Reply #10 on: August 27, 2021, 08:10:00 pm »
Thanks for getting back to me.

I'm using SBT 1.4.7

I set the logging variable but I'm not seeing logs (I saw user.cfg.xml update with the set-var command).

I currently can't get the attach dialog to come up. Maybe I need to re-install?

<edit>
I re-installed but the "Attach to Java Virtual Machine" dialog does not come up when I select it. Others do (like "Debug Java Program")
« Last Edit: August 27, 2021, 08:22:39 pm by kwilliams »

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1580
  • Hero Points: 140
Re: Attach to Virtual Machine not working
« Reply #11 on: August 27, 2021, 08:22:22 pm »
In theory, you should either get an error dialog at this point, or the attach dialog, so I'm not sure why you don't get anything.  It does sound odd, if you go to the SlickEdit command line and just run scala-attach, do you get a dialog? 

You shouldn't need to re-install.  The install directory is read-only, only things in the configuration directory gets changed.  You can try starting with a clean config if you want to rule out a configuration problem.  Go to a cmd.exe or powershell prompt, and start SlickEdit like this:  c:\Program Files\SlickEdit Pro 2020\win\vs.exe -sc %TEMP%\seconfig     And you can open up your project and see if you can attach then.


kwilliams

  • Community Member
  • Posts: 28
  • Hero Points: 0
Re: Attach to Virtual Machine not working
« Reply #12 on: August 27, 2021, 08:31:49 pm »
scala-attach didn't show a dialog either.

running with a clean config gave me the old "can't find tools.jar" so I had to apply the hotfix. Then I was back to no attach dialog.

also nothing is logged when I use 'set-var def_debug_logging 2' as far as I can tell.
« Last Edit: August 27, 2021, 08:44:55 pm by kwilliams »

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1580
  • Hero Points: 140
Re: Attach to Virtual Machine not working
« Reply #13 on: August 27, 2021, 09:13:21 pm »
So not even any output in the Build window?

I'll trace through the codepath again, maybe I missed some way for you to get nothing.

kwilliams

  • Community Member
  • Posts: 28
  • Hero Points: 0
Re: Attach to Virtual Machine not working
« Reply #14 on: August 27, 2021, 09:22:26 pm »
nope. nothing. I tried again just to be sure. the build window was empty.

there doesn't seem to be any indication that the set-var command did anything (other than what showed up the the user.cfg.xml). Is there a get?

I tried some other debug related actions to see if any of those would induce a log message but so far nothing.
« Last Edit: August 27, 2021, 09:26:09 pm by kwilliams »