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 authored Aug 13, 2024
1 parent 0892bde commit b2c2fea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ final case class CantonConfig(
bootstrapScript: Option[String] = None,
targetScope: Option[String] = None,
disableUpgradeValidation: Boolean = false,
enableRemoteJavaDebugging: Boolean = false,
) {

lazy val tlsConfig =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,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 @@ -127,6 +135,7 @@ trait CantonFixtureWithResource[A]
bootstrapScript = bootstrapScript,
targetScope = targetScope,
disableUpgradeValidation = disableUpgradeValidation,
enableRemoteJavaDebugging = remoteJavaDebugging,
)

protected def info(msg: String): Unit =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,17 @@ object CantonRunner {
)
var outputBuffer = ""
val cmd = java ::
"-jar" ::
config.jarPath.toString ::
"daemon" ::
"-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" ::
"-c" ::
files.configFile.toString ::
"--bootstrap" ::
files.bootstrapFile.toString ::
debugOptions)
info(cmd.mkString("\\\n "))
for {
proc <- Future(
Expand Down

0 comments on commit b2c2fea

Please sign in to comment.