WestCoastProjects
WestCoastProjects

Reputation: 63042

Can not see some local variables in debugger within intellij for some scala programs

As described in the title there are some cases that Intellij is not able to recognized/display some of the local variables.

enter image description here

As can be seen, some of the local variables e.g. outarr and arrptr are already set: but the debugger does not know about them.

I am running inside IJ 13.1.4 in a maven project and have enabled debugging info as follows:

      <configuration>
        <args>
                ..
          <arg>-feature</arg>
            <arg>-g:notc</arg>
          </args>
         ..

My question is about : does anyone recognize this problem and has come up with workaround(s) for it?

Update Per suggestion on an answer here is the result of trying Alt-F8

enter image description here

Upvotes: 8

Views: 16749

Answers (5)

roamer
roamer

Reputation: 163

  1. when i add the following code, issue appear
  2. use jdk8, idea2019.1.3
  3. in my case,just click this in variables, and you can see the value
def singlePassMultiFilter[T](
      rdd: RDD[T],
      f1: T => Boolean,
      f2: T => Boolean,
      level: StorageLevel = StorageLevel.MEMORY_ONLY
  ): (RDD[T], RDD[T], Boolean => Unit) = {
  val tempRDD = rdd mapPartitions { iter =>
    val abuf1 = ArrayBuffer.empty[T]
    val abuf2 = ArrayBuffer.empty[T]
    for (x <- iter) {
      if (f1(x)) abuf1 += x
      if (f2(x)) abuf2 += x
    }
    Iterator.single((abuf1, abuf2))
  }
  tempRDD.persist(level)
  val rdd1 = tempRDD.flatMap(_._1)
  val rdd2 = tempRDD.flatMap(_._2)
  (rdd1, rdd2, (blocking: Boolean) => tempRDD.unpersist(blocking))
}

idea debug

Upvotes: 0

lucidbrot
lucidbrot

Reputation: 6156

I had a similar problem in IJ 2017: I declared and initialized two local booleans, but only the second one was displayed in the debugger.

AltF8 allowed me to evaluate the expression used to initialize that boolean but did not find the value of the boolean itself either.

Changing the expression slightly by comparing the result to true before assigning it made it work. So in your case, maybe varying the initialisation might work too.

Upvotes: 1

Lee Andrew
Lee Andrew

Reputation: 1

It seem's jdk's bug, use jdk8 instead ,problems will resolves.For more info see: Debugger cannot see local variable in a Lambda

Upvotes: 0

Nader Ghanbari
Nader Ghanbari

Reputation: 4300

This is mainly because debugging anonymous functions is inherently a hard job!

What you can do is to try to open $outer in variables section in debugger which means the anonymous function containing current context.

By doing this repeatedly (find $outer of that $outer again) there is a good chance you can find your variables.

enter image description here

If $outer is not available just navigate to the previous stack frame by clicking on it on Frames tab in Debugger.

Upvotes: 3

Eugene Zhulenev
Eugene Zhulenev

Reputation: 9734

You can try Alt+F8 to jump into expression evaluator, usually from that window I can reach all variables that are reachable from breakpoint.

Upvotes: 1

Related Questions