Skip to content

Commit

Permalink
add flag and instructions for attaching a java debugger to the canton…
Browse files Browse the repository at this point in the history
… fixture (#19763)

* add flag and instructions for attaching a java debugger to the canton fixture

* revert leftover debugging code
  • Loading branch information
paulbrauner-da committed Aug 13, 2024
1 parent adb7742 commit db87f49
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ final case class CantonConfig(
targetScope: Option[String] = None,
disableUpgradeValidation: Boolean = false,
maxPartiesPageSize: Option[Int] = None,
enableRemoteJavaDebugging: Boolean = false,
) {

lazy val tlsConfig =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ trait CantonFixtureWithResource[A]
// temporary files after a test is done running
protected val cantonFixtureDebugModeRemoveTmpFilesRegardless = false

// When true, the canton process is started with the necessary flags to enable remote debugging and is suspended until
// a debugger is attached. In order to use this feature, launch the test making use of the fixture from IntelliJ
// *in debug mode* and look for "Listening for transport dt_socket at address: 5005" in the console output. IntelliJ
// should display a clickable chip labelled "Attach debugger" next to this line. Clicking on this chip will attach the
// debugger to the canton process and resume execution. Breakpoints in the canton code under canton/* will then be
// taken into account by IntelliJ.
protected val remoteJavaDebugging: Boolean = false

final protected val logger = org.slf4j.LoggerFactory.getLogger(getClass)

if (cantonFixtureDebugModeIsDebug) {
Expand Down Expand Up @@ -129,6 +137,7 @@ trait CantonFixtureWithResource[A]
targetScope = targetScope,
disableUpgradeValidation = disableUpgradeValidation,
maxPartiesPageSize = maxPartiesPageSize,
enableRemoteJavaDebugging = remoteJavaDebugging,
)

protected def info(msg: String): Unit =
Expand Down
21 changes: 12 additions & 9 deletions sdk/test-common/canton/it-lib/src/main/com/daml/CantonRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,18 @@ object CantonRunner {
)
var outputBuffer = ""
val cmd = java ::
"-jar" ::
config.jarPath.toString ::
"daemon" ::
"--auto-connect-local" ::
"-c" ::
files.configFile.toString ::
"--bootstrap" ::
files.bootstrapFile.toString ::
debugOptions
(if (config.enableRemoteJavaDebugging)
List("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005")
else List.empty) ++
("-jar" ::
config.jarPath.toString ::
"daemon" ::
"--auto-connect-local" ::
"-c" ::
files.configFile.toString ::
"--bootstrap" ::
files.bootstrapFile.toString ::
debugOptions)
info(cmd.mkString("\\\n "))
for {
proc <- Future(
Expand Down

0 comments on commit db87f49

Please sign in to comment.