The profile system in the Scala debugger API's way of distinguishing specific logic to handle breakpoints, steps, and other requests in Scala 2.10, Scala 2.11, Scala 2.12, the Scala REPL, Java, and other scenarios.
Currently, there is a profile for Java debugging and another profile for Scala debugging (targeting 2.10). Future plans include adding logic to better handle gotchas in Scala 2.10, 2.11, etc.
DebugProfile trait provides a collection of higher-level methods that
can be used to create JDI requests and process incoming events using the
Pipeline construct. Each profile implements the
ScalaVirtualMachine interface extends the
enable it to utilize different rules on demand.
The Java profile is the default profile for the
ScalaVirtualMachine. It adds
no custom logic for any of the Scala versions; therefore, it should be able to
work with Java code.
The Java profile adds support for caching requests, which means calls to
getOrCreateAccessWatchpointRequest, etc. with
the same arguments will use the same JDI request underneath. This allows you
to refer to the breakpoint in a more flowing manner like the following:
val s: ScalaVirtualMachine = /* some virtual machine */ // Creates the breakpoint request for the first time, creates a pipeline to // receive breakpoint events s.getOrCreateBreakpointRequest("myfile.scala", 37) .map(_.location.lineNumber) .foreach(l => println(s"Reached line number $l")) // Reuses the same breakpoint request, creates a pipeline to receive // breakpoint events s.getOrCreateBreakpointRequest("myfile.scala", 37) .map(_.location.sourcePath) .foreach(p => println(s"Breakpoint occurred in $p"))
You can specifically reference the profile using its name:
val s: ScalaVirtualMachine = /* some virtual machine */ import org.scaladebugger.api.profiles.java.JavaDebugProfile s.withProfile(JavaDebugProfile.Name) .getOrCreateBreakpointRequest("myfile.scala", 37)
The Scala 2.10 profile is another profile available to the
ScalaVirtualMachine. It adds custom logic targeting Scala 2.10 code, although
the majority of custom rules also work for Scala 2.11 and Scala 2.12.
Furthermore, the profile's rules typically do not affect normal Java debugging,
meaning that this profile can be used to debug a mixed Java/Scala project.
Like the Java profile, the Scala 2.10 profile supports caching requests that use the same arguments. This allows you to refer to the stream for an existing request.
The swappable profile is a different profile abstraction. Rather than
providing specific debugger logic, this profile allows you to change which
profile you are using automatically. The
ScalaVirtualMachine class inherits
SwappableDebugProfile trait, which is why
change between different profiles.
|use||Changes the current profile to the specified profile.|
|withCurrentProfile||Returns the current underlying profile.|
|withProfile||Returns the profile with the specified name.|
// Inherits the SwappableDebugProfile trait val s: ScalaVirtualMachine = /* some virtual machine */ s.use(JavaDebugProfile.Name) s.getOrCreateBreakpointRequest("file.scala", 37)
While default profiles are available in the
there may be times where you want/need to provide your own profile. This can be
done by invoking the
register function on the
// Inherits the ProfileManager trait val s: ScalaVirtualMachine = /* some virtual machine */ s.register("profile name", /* profile instance */)