provegard / ncdbg

A debugger for Nashorn that uses Chrome DevTools as frontend
BSD 3-Clause "New" or "Revised" License
31 stars 5 forks source link

Stack trace shown for warning message #69

Closed JayBerlin closed 7 years ago

JayBerlin commented 7 years ago

In NashornDebuggerHost.scala:435, the stack is being logged for a warning and does not provide much useful information:

      log.warn(s"Failed to get line locations for ${refType.name}", t)

I would like to suggest that this be changed to not log the stack:

      log.warn(s"Failed to get line locations for ${refType.name}")

I can create a PR for this if you want.

provegard commented 7 years ago

Actually, I included the exception here because I thought it might be interesting to see the actual reason. There is a case right above this one for AbsentInformationException where the exception is excluded since it doesn't contribute anything.

Are you seeing an error here? If so, which one?

JayBerlin commented 7 years ago

Here is an example of an error with the stack trace:

08:57:07.723 [pool-1-thread-1] DEBUG c.p.ncd.nashorn.NashornDebuggerHost - Script reference type: jdk.nashorn.internal.scripts.Script$102$\^function\_ (5 attempts left)
08:57:07.728 [pool-1-thread-1] WARN  c.p.ncd.nashorn.NashornDebuggerHost - Failed to get line locations for jdk.nashorn.internal.scripts.Script$102$\^function\_
com.sun.jdi.AbsentInformationException: null
    at com.sun.tools.jdi.ReferenceTypeImpl.allLineLocations(ReferenceTypeImpl.java:862)
    at com.sun.tools.jdi.ReferenceTypeImpl.allLineLocations(ReferenceTypeImpl.java:838)
    at com.programmaticallyspeaking.ncd.nashorn.NashornDebuggerHost.$anonfun$considerReferenceType$4(NashornDebuggerHost.scala:415)
    at scala.util.Try$.apply(Try.scala:209)
    at com.programmaticallyspeaking.ncd.nashorn.NashornDebuggerHost.considerReferenceType(NashornDebuggerHost.scala:415)
    at com.programmaticallyspeaking.ncd.nashorn.NashornDebuggerHost.scanOutstandingClasses(NashornDebuggerHost.scala:486)
    at com.programmaticallyspeaking.ncd.nashorn.NashornDebuggerHost.scanClasses(NashornDebuggerHost.scala:472)
    at com.programmaticallyspeaking.ncd.nashorn.NashornDebuggerHost.handleOperation(NashornDebuggerHost.scala:754)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.programmaticallyspeaking.ncd.infra.ExecutorProxy$Handler.$anonfun$invoke$3(ExecutorProxy.scala:42)
    at scala.util.Try$.apply(Try.scala:209)
    at com.programmaticallyspeaking.ncd.infra.ExecutorProxy$Handler.$anonfun$invoke$2(ExecutorProxy.scala:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
provegard commented 7 years ago

Huh, weird that you're not hitting this case:

    case Failure(t: AbsentInformationException) =>
      // Don't log the exception in this case, it's not useful.
      log.warn(s"Failed to get line locations for ${refType.name}")
      None
provegard commented 7 years ago

I specifically added that failure case because I came to the same conclusion as you - the AIE stack trace is useless. When I added it, I got rid of the stack trace. Let me check again.

JayBerlin commented 7 years ago

Hmmm. Good point, now that I go back and look at the code it should have been caught above.

provegard commented 7 years ago

I just checked again to make sure. Without the AIE case, I get the stack trace. With it, I don't. The target is running on Java 9 and so is NCDbg. What's your setup?

JayBerlin commented 7 years ago

Ah. I am running Java 8 for both. I don't have Java 9 installed on my Mac.

provegard commented 7 years ago

Which version? I don't recall getting that error with Java 8, but I will test it.

provegard commented 7 years ago

I tried NCDbg with 144 and the debug target with 131 and didn't get the stack trace.

JayBerlin commented 7 years ago

I was running 74 (must have been left setup from some previous testing). I set to 131 and did not have the issue.

Thanks!

provegard commented 7 years ago

Ok, good! Closing this then.