This is an automated email from the ASF dual-hosted git repository.

olabusayo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git


The following commit(s) were added to refs/heads/main by this push:
     new 4c644bbd1 Refactor debugger runner API
4c644bbd1 is described below

commit 4c644bbd1e673eb7b67a43235e1ba7cb58e5d64a
Author: olabusayoT <[email protected]>
AuthorDate: Wed Aug 20 11:04:43 2025 -0400

    Refactor debugger runner API
    
    - Remove `DebuggerRunner`, `InteractiveDebuggerRunnerFactory`, and related 
interfaces.
    - rename Interactive in the api to Daffodil to more accurately represent 
both CLI/Trace Runners
    - Replace usage of the removed classes with `Debugger` interface and new 
factory methods in `Daffodil`.
    - Update tests and examples to use the new structure.
    - reformat Java files
    
    DAFFODIL-3032
---
 .../main/scala/org/apache/daffodil/cli/Main.scala  | 24 +++----
 .../daffodil/cli/debugger/CLIDebuggerRunner.scala  |  8 +--
 .../java/org/apache/daffodil/api/Daffodil.java     | 26 ++++++++
 .../org/apache/daffodil/api/DataProcessor.java     | 57 +++--------------
 ...ggerRunner.java => DaffodilDebuggerRunner.java} | 19 +++---
 .../org/apache/daffodil/api/debugger/Debugger.java |  2 +-
 .../api/debugger/InteractiveDebuggerRunner.java    | 49 ---------------
 .../debugger/InteractiveDebuggerRunnerFactory.java | 56 -----------------
 .../daffodil/api/debugger/TraceDebuggerRunner.java | 48 --------------
 .../apache/daffodil/api/debugger/package-info.java | 29 ++++-----
 .../org/apache/daffodil/core/util/TestUtils.scala  | 16 ++---
 ...activeDebugger.scala => DaffodilDebugger.scala} | 13 +++-
 .../daffodil/runtime1/debugger/Debugger.scala      | 22 -------
 .../debugger/InteractiveDebuggerRunnerImpl.scala   | 29 ---------
 .../runtime1/debugger/TraceDebuggerRunner.scala    | 10 +--
 .../runtime1/processors/DataProcessor.scala        | 12 ++--
 .../jexample/DebuggerRunnerForAPITest.java         | 24 +++----
 .../java/org/apache/daffodil/jexample/TestAPI.java | 73 +++++++++++-----------
 .../daffodil/jexample/TestCustomDebuggerAPI.java   | 43 +++++++------
 .../apache/daffodil/jexample/TestInfosetEvent.java | 28 ++++-----
 .../daffodil/jexample/TestInfosetOutputter.java    | 30 ++++-----
 .../daffodil/jexample/TestJavaMetadataAPI.java     | 65 ++++++++++---------
 .../sexample/DebuggerRunnerForAPITest.scala        |  7 ++-
 .../org/apache/daffodil/sexample/TestAPI.scala     | 68 ++++++++++----------
 .../daffodil/sexample/TestCustomDebuggerAPI.scala  |  1 -
 .../org/apache/daffodil/tdml/TDMLRunner.scala      |  2 +-
 .../tdml/processor/TDMLDFDLProcessor.scala         |  2 -
 .../tdml/DaffodilCTDMLDFDLProcessor.scala          |  1 -
 .../processor/tdml/DaffodilTDMLDFDLProcessor.scala | 21 ++-----
 .../usertests/TestUserSubmittedTests.scala         |  4 +-
 30 files changed, 276 insertions(+), 513 deletions(-)

diff --git a/daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala 
b/daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala
index 88ac16ee5..a075d6393 100644
--- a/daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala
+++ b/daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala
@@ -45,14 +45,13 @@ import scala.util.Using
 import scala.util.matching.Regex
 
 import org.apache.daffodil.api
-import org.apache.daffodil.api.debugger.InteractiveDebuggerRunnerFactory
+import org.apache.daffodil.api.Daffodil
 import org.apache.daffodil.api.exceptions.InvalidParserException
 import org.apache.daffodil.api.layers.exceptions.LayerFatalException
 import org.apache.daffodil.api.validation.ValidatorInitializationException
 import org.apache.daffodil.api.validation.ValidatorNotRegisteredException
 import org.apache.daffodil.cli.debugger.CLIDebuggerRunner
 import org.apache.daffodil.core.compiler.Compiler
-import org.apache.daffodil.core.dsom.ExpressionCompilers
 import org.apache.daffodil.io.DataDumper
 import org.apache.daffodil.io.FormatInfo
 import org.apache.daffodil.io.InputSourceDataInputStream
@@ -74,7 +73,6 @@ import org.apache.daffodil.lib.xml.QName
 import org.apache.daffodil.lib.xml.RefQName
 import org.apache.daffodil.lib.xml.XMLUtils
 import org.apache.daffodil.runtime1.debugger.DebuggerExitException
-import org.apache.daffodil.runtime1.debugger.InteractiveDebugger
 import org.apache.daffodil.runtime1.externalvars.ExternalVariablesLoader
 import org.apache.daffodil.runtime1.iapi.DFDL
 import org.apache.daffodil.runtime1.processors.DataLoc
@@ -1072,21 +1070,19 @@ class Main(
   ): api.DataProcessor = {
     (traceArg() || debugArg.isDefined) match {
       case true => {
-        val runner =
-          getTraceOrCLIDebuggerRunner(traceArg, debugArg)
-        val id = new InteractiveDebugger(runner, ExpressionCompilers)
-        proc.withDebugger(id).withDebugging(true)
+        val id = getTraceOrCLIDebugger(traceArg, debugArg)
+        proc.withDebugger(id)
       }
       case false => proc
     }
   }
 
-  private def getTraceOrCLIDebuggerRunner(
+  private def getTraceOrCLIDebugger(
     trace: ScallopOption[Boolean],
     debug: ScallopOption[Option[String]]
   ) = {
     if (trace()) {
-      InteractiveDebuggerRunnerFactory.newTraceDebuggerRunner(STDOUT)
+      Daffodil.newTraceDebugger(STDOUT)
     } else {
       if (System.console == null) {
         Logger.log.warn(
@@ -1094,8 +1090,9 @@ class Main(
         )
       }
       debug() match {
-        case Some(f) => new CLIDebuggerRunner(new File(f), STDIN, STDOUT)
-        case None => new CLIDebuggerRunner(STDIN, STDOUT)
+        case Some(f) =>
+          Daffodil.newDaffodilDebugger(new CLIDebuggerRunner(new File(f), 
STDIN, STDOUT))
+        case None => Daffodil.newDaffodilDebugger(new CLIDebuggerRunner(STDIN, 
STDOUT))
       }
     }
   }
@@ -1703,9 +1700,8 @@ class Main(
         val tdmlRunnerInit = Runner(tdmlFile, optTDMLImplementation)
 
         val tdmlRunner = if (testOpts.trace() || testOpts.debug.isDefined) {
-          val db = getTraceOrCLIDebuggerRunner(testOpts.trace, testOpts.debug)
-          val id = new InteractiveDebugger(db, ExpressionCompilers)
-          tdmlRunnerInit.setDebugger(id)
+          val db = getTraceOrCLIDebugger(testOpts.trace, testOpts.debug)
+          tdmlRunnerInit.setDebugger(db)
           tdmlRunnerInit
         } else {
           tdmlRunnerInit
diff --git 
a/daffodil-cli/src/main/scala/org/apache/daffodil/cli/debugger/CLIDebuggerRunner.scala
 
b/daffodil-cli/src/main/scala/org/apache/daffodil/cli/debugger/CLIDebuggerRunner.scala
index 9723480a2..ae0882abc 100644
--- 
a/daffodil-cli/src/main/scala/org/apache/daffodil/cli/debugger/CLIDebuggerRunner.scala
+++ 
b/daffodil-cli/src/main/scala/org/apache/daffodil/cli/debugger/CLIDebuggerRunner.scala
@@ -23,7 +23,7 @@ import java.io.PrintStream
 import scala.io.Source
 import scala.jdk.CollectionConverters.*
 
-import org.apache.daffodil.api.debugger.InteractiveDebuggerRunner
+import org.apache.daffodil.api.debugger.DaffodilDebuggerRunner
 import org.apache.daffodil.runtime1.debugger.*
 
 import org.jline.reader.Candidate
@@ -37,7 +37,7 @@ import org.jline.terminal.TerminalBuilder
 import org.jline.terminal.impl.DumbTerminal
 
 class CLIDebuggerRunner(cmdsIter: Iterator[String], in: InputStream, out: 
PrintStream)
-  extends InteractiveDebuggerRunner {
+  extends DaffodilDebuggerRunner {
   private val prompt = "(debug) "
 
   def this(in: InputStream = System.in, out: PrintStream = System.out) = {
@@ -60,7 +60,7 @@ class CLIDebuggerRunner(cmdsIter: Iterator[String], in: 
InputStream, out: PrintS
     )
   }
 
-  def init(id: InteractiveDebugger): Unit = {
+  def init(id: DaffodilDebugger): Unit = {
     // if the in/out parameters aren't the normal stdin/stdout, it's likely
     // either some sort of integration test or something where a DumbTerminal
     // is needed. Otherwise, use the TerminalBuilder which detects OS
@@ -111,7 +111,7 @@ class CLIDebuggerRunner(cmdsIter: Iterator[String], in: 
InputStream, out: PrintS
   }
 }
 
-class CLIDebuggerCompleter(id: InteractiveDebugger) extends Completer {
+class CLIDebuggerCompleter(id: DaffodilDebugger) extends Completer {
 
   def complete(
     reader: LineReader,
diff --git a/daffodil-core/src/main/java/org/apache/daffodil/api/Daffodil.java 
b/daffodil-core/src/main/java/org/apache/daffodil/api/Daffodil.java
index 70a1e2b61..43629686d 100644
--- a/daffodil-core/src/main/java/org/apache/daffodil/api/Daffodil.java
+++ b/daffodil-core/src/main/java/org/apache/daffodil/api/Daffodil.java
@@ -17,17 +17,23 @@
 
 package org.apache.daffodil.api;
 
+import org.apache.daffodil.api.debugger.Debugger;
+import org.apache.daffodil.api.debugger.DaffodilDebuggerRunner;
 import org.apache.daffodil.api.infoset.InfosetInputter;
 import org.apache.daffodil.api.infoset.InfosetOutputter;
 import org.apache.daffodil.api.infoset.JDOMInfosetOutputter;
 import org.apache.daffodil.api.infoset.ScalaXMLInfosetOutputter;
 import org.apache.daffodil.api.infoset.W3CDOMInfosetOutputter;
 import org.apache.daffodil.api.infoset.XMLTextEscapeStyle;
+import org.apache.daffodil.core.dsom.ExpressionCompilers$;
+import org.apache.daffodil.runtime1.debugger.DaffodilDebugger;
+import org.apache.daffodil.runtime1.debugger.TraceDebuggerRunner;
 import org.apache.daffodil.runtime1.infoset.JsonInfosetOutputter;
 import org.apache.daffodil.runtime1.infoset.XMLTextInfosetOutputter;
 
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.PrintStream;
 import java.nio.ByteBuffer;
 
 /**
@@ -224,6 +230,26 @@ public class Daffodil {
     return org.apache.daffodil.io.InputSourceDataInputStream.apply(arr);
   }
 
+  /**
+   * Factory method to get a Debugger that is controlled by a 
DaffodilDebuggerRunner.
+   *
+   * @param dr debugger runner
+   * @return a Debugger that is controlled by a DaffodilDebuggerRunner
+   */
+  public static Debugger newDaffodilDebugger(DaffodilDebuggerRunner dr) {
+    return new DaffodilDebugger(dr, ExpressionCompilers$.MODULE$);
+  }
+
+  /**
+   * Factory method to get a debugger that provides verbose trace output to a 
PrintStream
+   *
+   * @param out stream to print trace to
+   * @return a debugger that provides verbose trace output to a PrintStream
+   */
+  public static Debugger newTraceDebugger(PrintStream out) {
+    return newDaffodilDebugger(new TraceDebuggerRunner(out));
+  }
+
   /**
    * These are the events that a derived specific InfosetInputter
    * creates.
diff --git 
a/daffodil-core/src/main/java/org/apache/daffodil/api/DataProcessor.java 
b/daffodil-core/src/main/java/org/apache/daffodil/api/DataProcessor.java
index 3a4522b98..99e6cb5ef 100644
--- a/daffodil-core/src/main/java/org/apache/daffodil/api/DataProcessor.java
+++ b/daffodil-core/src/main/java/org/apache/daffodil/api/DataProcessor.java
@@ -18,18 +18,12 @@
 package org.apache.daffodil.api;
 
 import org.apache.daffodil.api.debugger.Debugger;
-import org.apache.daffodil.api.debugger.DebuggerRunner;
-import org.apache.daffodil.api.debugger.InteractiveDebuggerRunner;
-import org.apache.daffodil.api.debugger.InteractiveDebuggerRunnerFactory;
-import org.apache.daffodil.api.debugger.TraceDebuggerRunner;
 import org.apache.daffodil.api.exceptions.ExternalVariableException;
 import org.apache.daffodil.api.infoset.InfosetInputter;
 import org.apache.daffodil.api.infoset.InfosetOutputter;
 import org.apache.daffodil.api.metadata.MetadataHandler;
 import org.apache.daffodil.api.validation.ValidatorInitializationException;
 import org.apache.daffodil.api.validation.ValidatorNotRegisteredException;
-import org.apache.daffodil.core.dsom.ExpressionCompilers$;
-import org.apache.daffodil.runtime1.debugger.InteractiveDebugger;
 
 import java.io.File;
 import java.io.Serializable;
@@ -42,43 +36,10 @@ import java.util.Map;
  */
 public interface DataProcessor extends WithDiagnostics, Serializable {
   /**
-   * Obtain a new {@link DataProcessor} instance with debugging enabled or 
disabled.
-   * <p>
-   * Before enabling, {@link DataProcessor#withDebugger} or {@link 
DataProcessor#withDebuggerRunner} must be called to obtain
-   * a {@link DataProcessor} with a non-null debugger.
-   *
-   * @param flag true to enable debugging, false to disabled
-   * @return a new {@link DataProcessor} instance with debugging enabled or 
disabled.
-   */
-  DataProcessor withDebugging(boolean flag);
-
-  /**
-   * Obtain a new {@link DataProcessor} with a specified debugger runner.
+   * Obtain a new {@link DataProcessor} with a specified debugger or null to 
disable
+   * debugging.
    *
-   * @param dr debugger runner
-   * @return a new {@link DataProcessor} with a specified debugger runner.
-   */
-  default DataProcessor withDebuggerRunner(DebuggerRunner dr) {
-    Debugger dbg = null;
-    InteractiveDebuggerRunner runner;
-    if (dr instanceof TraceDebuggerRunner) {
-      runner = 
InteractiveDebuggerRunnerFactory.newTraceDebuggerRunner(System.out);
-    } else if (dr != null) {
-      runner = InteractiveDebuggerRunnerFactory.get(dr);
-    } else {
-      runner = null;
-    }
-
-    if (runner != null) {
-      dbg = new InteractiveDebugger(runner, ExpressionCompilers$.MODULE$);
-    }
-    return withDebugger(dbg);
-  }
-
-  /**
-   * Obtain a new {@link DataProcessor} with a specified debugger.
-   *
-   * @param dbg debugger
+   * @param dbg debugger to use or null to disable debugging
    * @return a new {@link DataProcessor} with a specified debugger.
    */
   DataProcessor withDebugger(Debugger dbg);
@@ -90,7 +51,7 @@ public interface DataProcessor extends WithDiagnostics, 
Serializable {
    *             {@link org.apache.daffodil.api.validation.ValidatorFactory} 
SPI or one of the built-in validators
    *             ("xerces", "daffodil", "off", "schematron")
    * @return a new {@link DataProcessor} with a specified validator.
-   * @throws ValidatorNotRegisteredException if the validator cannot be found
+   * @throws ValidatorNotRegisteredException  if the validator cannot be found
    * @throws ValidatorInitializationException if initializing the validator 
fails
    */
   default DataProcessor withValidation(String kind) throws 
ValidatorNotRegisteredException, ValidatorInitializationException {
@@ -100,9 +61,9 @@ public interface DataProcessor extends WithDiagnostics, 
Serializable {
   /**
    * Obtain a new {@link DataProcessor} with validation using a URI for 
configuration.
    *
-   * @param kind Kind of validation to use. Can be a custom validator name 
available via the
-   *             {@link org.apache.daffodil.api.validation.ValidatorFactory} 
SPI or one of the built-in validators
-   *             ("xerces", "daffodil", "off", "schematron")
+   * @param kind   Kind of validation to use. Can be a custom validator name 
available via the
+   *               {@link org.apache.daffodil.api.validation.ValidatorFactory} 
SPI or one of the built-in validators
+   *               ("xerces", "daffodil", "off", "schematron")
    * @param config Absolute URI to use for validation configuration. If the 
URI ends with .conf
    *               or .properties it is treated as a java.util.Properties file 
that is loaded and
    *               provided to the validator. Otherwise, the URI is provided 
as a single property to
@@ -110,7 +71,7 @@ public interface DataProcessor extends WithDiagnostics, 
Serializable {
    *               additional configuration--this could cause an exception if 
a validator requires
    *               properties.
    * @return a new {@link DataProcessor} with a specified validator.
-   * @throws ValidatorNotRegisteredException if the validator cannot be found
+   * @throws ValidatorNotRegisteredException  if the validator cannot be found
    * @throws ValidatorInitializationException if initializing the validator 
fails
    */
   DataProcessor withValidation(String kind, URI config) throws 
ValidatorNotRegisteredException, ValidatorInitializationException;
@@ -144,7 +105,7 @@ public interface DataProcessor extends WithDiagnostics, 
Serializable {
    * <p>
    * The resulting output can be reloaded by {@code 
Compiler.reload(savedParser:java\.nio\.channels\.ReadableByteChannel)* 
Compiler.reload}.
    * Note that any changes due to withValidator, withDebugger, and any compile 
diagnostics are not saved
-   * 
+   *
    * @param output the byte channel to write the {@link DataProcessor} to. 
Note that external variable settings are not saved.
    */
   void save(WritableByteChannel output);
diff --git 
a/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/DebuggerRunner.java
 
b/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/DaffodilDebuggerRunner.java
similarity index 77%
rename from 
daffodil-core/src/main/java/org/apache/daffodil/api/debugger/DebuggerRunner.java
rename to 
daffodil-core/src/main/java/org/apache/daffodil/api/debugger/DaffodilDebuggerRunner.java
index 3beb47baf..d2263ebd8 100644
--- 
a/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/DebuggerRunner.java
+++ 
b/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/DaffodilDebuggerRunner.java
@@ -17,28 +17,31 @@
 
 package org.apache.daffodil.api.debugger;
 
+import org.apache.daffodil.runtime1.debugger.DaffodilDebugger;
+
 /**
- * Debugger runner interface
+ * Daffodil Debugger Runner interface to run the built-in Daffodil debugger.
  */
-public interface DebuggerRunner {
+public interface DaffodilDebuggerRunner {
   /**
-   * Called once at the beginning of a parse, allowing one to perform any
-   * initialization steps that may be necessary.
+   * initialize using an Daffodil Debugger
+   *
+   * @param dd Daffodil debugger
    */
-  void init();
-
+  void init(DaffodilDebugger dd);
+  
   /**
    * Called by Daffodil when there is a pause in parsing to determine what
    * debugger actions should be taken.
    *
    * @return a debugger command that tells the Daffodil debugger what step to
    * take next.
-   * @see <a target="_blank" 
href='https://daffodil.apache.org/debugger/'>Daffodil Interactive Debugger</a> 
- debugger commands
+   * @see <a target="_blank" 
href='https://daffodil.apache.org/debugger/'>Daffodil Debugger</a> - debugger 
commands
    */
   String getCommand();
 
   /**
-   * Called by Daffodil when a debugger command has produce output. This method
+   * Called by Daffodil when a debugger command has produced output. This 
method
    * is called once for every line produced by the Daffodil debugger.
    *
    * @param line a single line of output generated by the Daffodil debugger
diff --git 
a/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/Debugger.java 
b/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/Debugger.java
index 136deb77e..909d179c1 100644
--- a/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/Debugger.java
+++ b/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/Debugger.java
@@ -20,7 +20,7 @@ package org.apache.daffodil.api.debugger;
 import org.apache.daffodil.runtime1.events.EventHandler;
 
 /**
- * debugger interface
+ * Debugger interface for receiving debug events during Daffodil processing
  */
 public interface Debugger extends EventHandler {
 }
diff --git 
a/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/InteractiveDebuggerRunner.java
 
b/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/InteractiveDebuggerRunner.java
deleted file mode 100644
index cf7719905..000000000
--- 
a/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/InteractiveDebuggerRunner.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.daffodil.api.debugger;
-
-import org.apache.daffodil.runtime1.debugger.InteractiveDebugger;
-
-/**
- * Interactive Debugger Runner interface
- */
-public interface InteractiveDebuggerRunner extends DebuggerRunner {
-  /**
-   * initialize using an Interactive Debugger
-   *
-   * @param id interactive debugger
-   */
-  void init(InteractiveDebugger id);
-
-  /**
-   * @return interactive debugger command
-   */
-  String getCommand();
-
-  /**
-   * output line
-   *
-   * @param line a single line of output generated by the Daffodil debugger
-   */
-  void lineOutput(String line);
-
-  /**
-   * finalization actions
-   */
-  void fini();
-}
diff --git 
a/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/InteractiveDebuggerRunnerFactory.java
 
b/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/InteractiveDebuggerRunnerFactory.java
deleted file mode 100644
index 466168cbc..000000000
--- 
a/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/InteractiveDebuggerRunnerFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.daffodil.api.debugger;
-
-import org.apache.daffodil.runtime1.debugger.InteractiveDebuggerRunnerImpl;
-import org.apache.daffodil.runtime1.debugger.TraceDebuggerRunner;
-
-import java.io.PrintStream;
-
-/**
- * Factory for Interactive Debugger Runners
- */
-public class InteractiveDebuggerRunnerFactory {
-
-  /**
-   * private constructor to disable initialization. use 
InteractiveDebuggerRunnerFactory.get(...)
-   * instead
-   */
-  private InteractiveDebuggerRunnerFactory() {
-  }
-
-  /**
-   * Factory method to get an instance of InteractiveDebuggerRunnerImpl
-   *
-   * @param dr debugger runner
-   * @return instance of InteractiveDebuggerRunnerImpl
-   */
-  public static InteractiveDebuggerRunner get(DebuggerRunner dr) {
-    return new InteractiveDebuggerRunnerImpl(dr);
-  }
-
-  /**
-   * Factory method to get an instance of TraceDebuggerRunner
-   *
-   * @param out stream to print trace to
-   * @return instance of TraceDebuggerRunner
-   */
-  public static org.apache.daffodil.api.debugger.TraceDebuggerRunner 
newTraceDebuggerRunner(PrintStream out) {
-    return new TraceDebuggerRunner(out);
-  }
-}
diff --git 
a/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/TraceDebuggerRunner.java
 
b/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/TraceDebuggerRunner.java
deleted file mode 100644
index 4629c8800..000000000
--- 
a/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/TraceDebuggerRunner.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.daffodil.api.debugger;
-
-import org.apache.daffodil.runtime1.debugger.InteractiveDebugger;
-
-/**
- * Trace Debugger Runner interface
- */
-public interface TraceDebuggerRunner extends InteractiveDebuggerRunner {
-  /**
-   * initialize using an Interactive Debugger
-   *
-   * @param id interactive debugger
-   */
-  void init(InteractiveDebugger id);
-
-  /**
-   * @return the next trace debugger command
-   */
-  String getCommand();
-
-  /**
-   * output line
-   *
-   * @param line a single line of output generated by the Daffodil debugger
-   */
-  void lineOutput(String line);
-
-  /**
-   * finalization actions
-   */
-  void fini();
-}
diff --git 
a/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/package-info.java
 
b/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/package-info.java
index dd88d70af..228a4f1d4 100644
--- 
a/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/package-info.java
+++ 
b/daffodil-core/src/main/java/org/apache/daffodil/api/debugger/package-info.java
@@ -20,27 +20,24 @@
  *
  * <h2>Overview</h2>
  * <p>
- * Daffodil comes with one prebuilt debugger, the {@link 
org.apache.daffodil.api.debugger.TraceDebuggerRunner}, which outputs
- * verbose information during the parsing processes, which can be used to aid
- * in debugging a DFDL schema. For example, the {@link
- * org.apache.daffodil.api.debugger.TraceDebuggerRunner} can be used like so:
+ * Daffodil comes with one prebuilt debugger, the trace {@link 
org.apache.daffodil.api.debugger.Debugger},
+ * which outputs verbose information during the parsing processes, which can 
be used to aid
+ * in debugging a DFDL schema. For example, the trace {@link
+ * org.apache.daffodil.api.debugger.Debugger} can be used like so:
  *
  * <pre>
  * {@code
- * TraceDebuggerRunner tdr = 
InteractiveDebuggerRunnerFactory.getTraceDebuggerRunner(System.out);
- * Daffodil.setDebugger(tdr);
+ * Debugger td = Daffodil.newTraceDebugger(System.out);
+ * dp.setDebugger(td);
  * }</pre>
  * <p>
- * Additionally, one may create their own debugger runner by implementing the
- * methods in the {@link
- * org.apache.daffodil.api.debugger.DebuggerRunner}.
- * <p>
- * Once the debugger is set, it must then be turned on, like so:
- *
- * <pre>
- * {@code
- * Daffodil.setDebugging(true);
- * }</pre>
+ * Additionally, one may create their own debugger by creating a class that 
implements the {@link
+ * org.apache.daffodil.api.debugger.DaffodilDebuggerRunner} interface and then 
calling
+ * {@code Daffodil.newDaffodilDebugger(customRunner)} to get a debugger. 
+ * Or they can create a class that implements the {@link 
org.apache.daffodil.api.debugger.Debugger} 
+ * interface.
+ * 
+ * Then with either, they may call {@code 
DataProcessor.withDebugger(debugger)} to set the debugger.
  */
 
 package org.apache.daffodil.api.debugger;
diff --git 
a/daffodil-core/src/main/scala/org/apache/daffodil/core/util/TestUtils.scala 
b/daffodil-core/src/main/scala/org/apache/daffodil/core/util/TestUtils.scala
index 0ebb425ba..4ef44984c 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/core/util/TestUtils.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/util/TestUtils.scala
@@ -31,8 +31,8 @@ import scala.util.Try
 import scala.xml.*
 
 import org.apache.daffodil.api
+import org.apache.daffodil.api.Daffodil
 import org.apache.daffodil.api.ProcessorFactory
-import org.apache.daffodil.api.debugger.InteractiveDebuggerRunnerFactory
 import org.apache.daffodil.api.metadata.MetadataHandler
 import org.apache.daffodil.core.compiler.Compiler
 import org.apache.daffodil.core.dsom.*
@@ -42,7 +42,6 @@ import org.apache.daffodil.lib.externalvars.Binding
 import org.apache.daffodil.lib.iapi.*
 import org.apache.daffodil.lib.util.*
 import org.apache.daffodil.lib.xml.*
-import org.apache.daffodil.runtime1.debugger.*
 import org.apache.daffodil.runtime1.iapi.DFDL
 import org.apache.daffodil.runtime1.infoset.ScalaXMLInfosetInputter
 import org.apache.daffodil.runtime1.infoset.ScalaXMLInfosetOutputter
@@ -129,7 +128,7 @@ object TestUtils {
     val outputStream = new java.io.ByteArrayOutputStream()
     val out = java.nio.channels.Channels.newChannel(outputStream)
     u = if (areTracing) {
-      u.withDebugger(builtInTracer).withDebugging(true)
+      u.withDebugger(builtInTracer)
     } else u
     val inputter = new ScalaXMLInfosetInputter(infosetXML)
     val actual = u.unparse(inputter, out)
@@ -161,7 +160,7 @@ object TestUtils {
     val out = java.nio.channels.Channels.newChannel(outputStream)
     val inputter = new ScalaXMLInfosetInputter(infoset)
     u = if (areTracing) {
-      u.withDebugger(builtInTracer).withDebugging(true)
+      u.withDebugger(builtInTracer)
     } else u
     val actual = u.unparse(inputter, out)
     if (actual.isProcessingError) throwDiagnostics(actual.getDiagnostics)
@@ -173,11 +172,7 @@ object TestUtils {
     }
   }
 
-  private lazy val builtInTracer =
-    new InteractiveDebugger(
-      InteractiveDebuggerRunnerFactory.newTraceDebuggerRunner(System.out),
-      ExpressionCompilers
-    )
+  private lazy val builtInTracer = Daffodil.newTraceDebugger(System.out)
 
   private def saveAndReload(p: DataProcessor): DataProcessor = {
     // We want to serialize/deserialize here, to avoid strange debug artifacts
@@ -227,7 +222,7 @@ object TestUtils {
   ): (api.ParseResult, Node) = {
     val p1 =
       if (areTracing) {
-        dp.withDebugger(builtInTracer).withDebugging(true)
+        dp.withDebugger(builtInTracer)
       } else dp
 
     val p = p1.withValidation("daffodil")
@@ -366,7 +361,6 @@ class Fakes private () {
     ): DFDL.DataProcessor = this
     override def withValidation(kind: String, config: URI): DFDL.DataProcessor 
= this
     override def withDebugger(dbg: api.debugger.Debugger): DFDL.DataProcessor 
= this
-    override def withDebugging(flag: Boolean): DFDL.DataProcessor = this
 
     override def newXMLReaderInstance: api.DaffodilParseXMLReader = null
     override def newContentHandlerInstance(
diff --git 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/InteractiveDebugger.scala
 
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/DaffodilDebugger.scala
similarity index 99%
rename from 
daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/InteractiveDebugger.scala
rename to 
daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/DaffodilDebugger.scala
index c66230660..7ca5daf95 100644
--- 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/InteractiveDebugger.scala
+++ 
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/DaffodilDebugger.scala
@@ -22,6 +22,7 @@ import scala.collection.immutable.ArraySeq
 import scala.jdk.CollectionConverters.*
 
 import org.apache.daffodil.api
+import org.apache.daffodil.api.debugger.DaffodilDebuggerRunner
 import org.apache.daffodil.api.infoset.InfosetElement
 import org.apache.daffodil.lib.exceptions.Assert
 import org.apache.daffodil.lib.exceptions.UnsuppressableException
@@ -52,10 +53,16 @@ import 
org.apache.daffodil.runtime1.processors.unparsers.Unparser
 
 case class DebuggerExitException() extends UnsuppressableException("Debugger 
exit")
 
-class InteractiveDebugger(
-  runner: api.debugger.InteractiveDebuggerRunner,
+/**
+ * Receives events from daffodil and uses the provided DaffodilDebuggerRunner 
to
+ * determine how to handle those events
+ * @param runner used to figure out what to do while events are read
+ * @param eCompilers used in the evaluation of expressions
+ */
+class DaffodilDebugger(
+  runner: DaffodilDebuggerRunner,
   eCompilers: ExpressionCompilerClass
-) extends Debugger {
+) extends api.debugger.Debugger {
 
   object DebugState extends Enum {
     sealed abstract trait Type extends EnumValueType
diff --git 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/Debugger.scala
 
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/Debugger.scala
deleted file mode 100644
index 9423d7e0e..000000000
--- 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/Debugger.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.daffodil.runtime1.debugger
-
-import org.apache.daffodil.api.debugger.Debugger as JDebugger
-
-trait Debugger extends JDebugger
diff --git 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/InteractiveDebuggerRunnerImpl.scala
 
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/InteractiveDebuggerRunnerImpl.scala
deleted file mode 100644
index 0657907a7..000000000
--- 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/InteractiveDebuggerRunnerImpl.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.daffodil.runtime1.debugger
-
-import org.apache.daffodil.api
-
-class InteractiveDebuggerRunnerImpl(private[debugger] var dr: 
api.debugger.DebuggerRunner)
-  extends api.debugger.InteractiveDebuggerRunner {
-  override def init(id: InteractiveDebugger): Unit = { dr.init() }
-  override def init(): Unit = { dr.init() }
-  override def getCommand: String = dr.getCommand
-  override def lineOutput(line: String): Unit = { dr.lineOutput(line) }
-  override def fini(): Unit = { dr.fini() }
-}
diff --git 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/TraceDebuggerRunner.scala
 
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/TraceDebuggerRunner.scala
index 28a04afde..f06a65b78 100644
--- 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/TraceDebuggerRunner.scala
+++ 
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/debugger/TraceDebuggerRunner.scala
@@ -20,9 +20,9 @@ package org.apache.daffodil.runtime1.debugger
 import java.io.PrintStream
 
 import org.apache.daffodil.api
+import org.apache.daffodil.api.debugger.DaffodilDebuggerRunner
 
-class TraceDebuggerRunner(out: PrintStream = System.out)
-  extends api.debugger.TraceDebuggerRunner {
+class TraceDebuggerRunner(out: PrintStream = System.out) extends 
DaffodilDebuggerRunner {
   val traceIter = Seq(
     "set infosetParents 1",
     "display info parser",
@@ -33,7 +33,7 @@ class TraceDebuggerRunner(out: PrintStream = System.out)
     "trace"
   ).iterator
 
-  override def init(id: InteractiveDebugger): Unit = {
+  override def init(id: DaffodilDebugger): Unit = {
     // do nothing
   }
 
@@ -56,8 +56,4 @@ class TraceDebuggerRunner(out: PrintStream = System.out)
   override def fini(): Unit = {
     // do nothing
   }
-
-  override def init(): Unit = {
-    // do nothing
-  }
 }
diff --git 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/DataProcessor.scala
 
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/DataProcessor.scala
index 93909021e..51a2e1265 100644
--- 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/DataProcessor.scala
+++ 
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/DataProcessor.scala
@@ -162,12 +162,12 @@ class DataProcessor(
 
   override def withDebugger(dbg: api.debugger.Debugger): DataProcessor = {
     val optDbg = if (dbg eq null) None else Some(dbg)
-    copy(areDebugging = optDbg.isDefined, optDebugger = optDbg)
-  }
-
-  def withDebugging(flag: Boolean): DataProcessor = {
-    val newTunables = tunables.withTunable("allowExternalPathExpressions", 
flag.toString)
-    copy(areDebugging = flag, tunables = newTunables)
+    val newTunables: DaffodilTunables = if (optDbg.isDefined) {
+      tunables.withTunable("allowExternalPathExpressions", "true")
+    } else {
+      tunables
+    }
+    copy(areDebugging = optDbg.isDefined, optDebugger = optDbg, tunables = 
newTunables)
   }
 
   def withExternalVariables(extVars: java.util.Map[String, String]): 
DataProcessor = {
diff --git 
a/daffodil-core/src/test/java/org/apache/daffodil/jexample/DebuggerRunnerForAPITest.java
 
b/daffodil-core/src/test/java/org/apache/daffodil/jexample/DebuggerRunnerForAPITest.java
index 4574d1baa..77fd70b07 100644
--- 
a/daffodil-core/src/test/java/org/apache/daffodil/jexample/DebuggerRunnerForAPITest.java
+++ 
b/daffodil-core/src/test/java/org/apache/daffodil/jexample/DebuggerRunnerForAPITest.java
@@ -17,31 +17,33 @@
 
 package org.apache.daffodil.jexample;
 
-import org.apache.daffodil.api.debugger.DebuggerRunner;
+import org.apache.daffodil.api.debugger.DaffodilDebuggerRunner;
+import org.apache.daffodil.runtime1.debugger.DaffodilDebugger;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 
 
-public class DebuggerRunnerForAPITest implements DebuggerRunner {
+public class DebuggerRunnerForAPITest implements DaffodilDebuggerRunner {
   ArrayList<String> lines;
 
   ArrayList<String> commands = new ArrayList<>(Arrays.asList("display info 
parser",
-      "display info bitPosition",
-      "display info data",
-      "display eval ..",
-      "display info diff",
-      "trace"));
+    "display info bitPosition",
+    "display info data",
+    "display eval ..",
+    "display info diff",
+    "trace"));
 
   Iterator<String> commandsIter;
 
-  public void init() {
-    lines = new ArrayList<String>();
-    commandsIter = commands.iterator();
+  public void fini() {
   }
 
-  public void fini() {
+  @Override
+  public void init(DaffodilDebugger dd) {
+    lines = new ArrayList<String>();
+    commandsIter = commands.iterator();
   }
 
   public String getCommand() {
diff --git 
a/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestAPI.java 
b/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestAPI.java
index 3a2f1f1c7..5cf3216ee 100644
--- a/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestAPI.java
+++ b/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestAPI.java
@@ -49,6 +49,7 @@ import org.apache.daffodil.api.DataProcessor;
 import org.apache.daffodil.api.Diagnostic;
 import org.apache.daffodil.api.LocationInSchemaFile;
 import org.apache.daffodil.api.ParseResult;
+import org.apache.daffodil.api.debugger.Debugger;
 import org.apache.daffodil.api.validation.ValidatorInitializationException;
 import org.apache.daffodil.api.validation.ValidatorNotRegisteredException;
 import org.apache.daffodil.japi.SAXErrorHandlerForAPITest;
@@ -77,6 +78,9 @@ import java.nio.charset.StandardCharsets;
 
 
 public class TestAPI {
+  String SAX_NAMESPACES_FEATURE = "http://xml.org/sax/features/namespaces";;
+  String SAX_NAMESPACE_PREFIXES_FEATURE = 
"http://xml.org/sax/features/namespace-prefixes";;
+
   /**
    * Best practices for XML loading are to turn off anything that could lead to
    * insecurity.
@@ -94,9 +98,6 @@ public class TestAPI {
     
xmlReader.setFeature("http://xml.org/sax/features/external-general-entities";, 
false);
   }
 
-  String SAX_NAMESPACES_FEATURE = "http://xml.org/sax/features/namespaces";;
-  String SAX_NAMESPACE_PREFIXES_FEATURE = 
"http://xml.org/sax/features/namespace-prefixes";;
-
   private java.io.File getResource(String resPath) {
     try {
       return new java.io.File(this.getClass().getResource(resPath).toURI());
@@ -136,15 +137,15 @@ public class TestAPI {
 
   @Test
   public void testAPI1() throws IOException, ClassNotFoundException {
-    DebuggerRunnerForAPITest debugger = new DebuggerRunnerForAPITest();
+    DebuggerRunnerForAPITest customRunner = new DebuggerRunnerForAPITest();
+    Debugger debugger = Daffodil.newDaffodilDebugger(customRunner);
 
     org.apache.daffodil.api.Compiler c = Daffodil.compiler();
     java.io.File schemaFile = getResource("/test/api/mySchema1.dfdl.xsd");
     ProcessorFactory pf = c.compileFile(schemaFile);
     DataProcessor dp = pf.onPath("/");
     dp = reserializeDataProcessor(dp);
-    dp = dp.withDebuggerRunner(debugger);
-    dp = dp.withDebugging(true);
+    dp = dp.withDebugger(debugger);
 
     java.io.File file = getResource("/test/api/myData.dat");
     java.io.FileInputStream fis = new java.io.FileInputStream(file);
@@ -153,9 +154,9 @@ public class TestAPI {
       ParseResult res = dp.parse(dis, outputter);
       boolean err = res.isError();
       assertFalse(err);
-      assertTrue(debugger.lines.size() > 0);
-      
assertTrue(debugger.lines.contains("-----------------------------------------------------------------
 1\n"));
-      assertTrue(debugger.getCommand().equals("trace"));
+      assertFalse(customRunner.lines.isEmpty());
+      
assertTrue(customRunner.lines.contains("-----------------------------------------------------------------
 1\n"));
+      assertEquals("trace", customRunner.getCommand());
 
       java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
       java.nio.channels.WritableByteChannel wbc = 
java.nio.channels.Channels.newChannel(bos);
@@ -171,7 +172,8 @@ public class TestAPI {
   // before executing the test.
   @Test
   public void testAPI1_A() throws Exception {
-    DebuggerRunnerForAPITest debugger = new DebuggerRunnerForAPITest();
+    DebuggerRunnerForAPITest customRunner = new DebuggerRunnerForAPITest();
+    Debugger debugger = Daffodil.newDaffodilDebugger(customRunner);
 
     org.apache.daffodil.api.Compiler c = Daffodil.compiler();
     java.io.File schemaFile = getResource("/test/api/mySchema1.dfdl.xsd");
@@ -187,8 +189,7 @@ public class TestAPI {
     ReadableByteChannel input = Channels.newChannel(is);
     org.apache.daffodil.api.Compiler compiler = Daffodil.compiler();
     DataProcessor parser = compiler.reload(input);
-    parser = parser.withDebuggerRunner(debugger);
-    parser = parser.withDebugging(true);
+    parser = parser.withDebugger(debugger);
 
     File data = getResource("/test/api/myData.dat");
     // This test uses a byte array here, just so as to be sure to exercise
@@ -201,9 +202,9 @@ public class TestAPI {
       ParseResult res = parser.parse(dis, outputter);
       boolean err = res.isError();
       assertFalse(err);
-      assertTrue(debugger.lines.size() > 0);
-      
assertTrue(debugger.lines.contains("-----------------------------------------------------------------
 1\n"));
-      assertTrue(debugger.getCommand().equals("trace"));
+      assertFalse(customRunner.lines.isEmpty());
+      
assertTrue(customRunner.lines.contains("-----------------------------------------------------------------
 1\n"));
+      assertEquals("trace", customRunner.getCommand());
 
       java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
       java.nio.channels.WritableByteChannel wbc = 
java.nio.channels.Channels.newChannel(bos);
@@ -219,14 +220,14 @@ public class TestAPI {
   // before executing the test.
   @Test
   public void testAPI1_A_Full_SavedParser() throws Exception {
-    DebuggerRunnerForAPITest debugger = new DebuggerRunnerForAPITest();
+    DebuggerRunnerForAPITest customRunner = new DebuggerRunnerForAPITest();
+    Debugger debugger = Daffodil.newDaffodilDebugger(customRunner);
 
     org.apache.daffodil.api.Compiler c = Daffodil.compiler();
     java.io.File schemaFile = getResource("/test/api/mySchema1.dfdl.xsd");
     ProcessorFactory pf = c.compileFile(schemaFile);
     DataProcessor dp = pf.onPath("/");
-    dp = dp.withDebuggerRunner(debugger);
-    dp = dp.withDebugging(true);
+    dp = dp.withDebugger(debugger);
 
     // Serialize the parser to memory, then deserialize for parsing.
     ByteArrayOutputStream os = new ByteArrayOutputStream();
@@ -620,7 +621,8 @@ public class TestAPI {
 
   @Test
   public void testAPI12() throws IOException, ClassNotFoundException {
-    DebuggerRunnerForAPITest debugger = new DebuggerRunnerForAPITest();
+    DebuggerRunnerForAPITest customRunner = new DebuggerRunnerForAPITest();
+    Debugger debugger = Daffodil.newDaffodilDebugger(customRunner);
 
     org.apache.daffodil.api.Compiler c = Daffodil.compiler();
 
@@ -629,8 +631,7 @@ public class TestAPI {
     ProcessorFactory pf = c.compileFile(schemaFile);
     DataProcessor dp = pf.onPath("/");
     dp = reserializeDataProcessor(dp);
-    dp = dp.withDebuggerRunner(debugger);
-    dp = dp.withDebugging(true);
+    dp = dp.withDebugger(debugger);
 
     java.io.File file = getResource("/test/api/myData.dat");
     java.io.FileInputStream fis = new java.io.FileInputStream(file);
@@ -640,8 +641,8 @@ public class TestAPI {
       boolean err = res.isError();
       assertFalse(err);
 
-      assertTrue(debugger.lines.size() > 0);
-      
assertTrue(debugger.lines.contains("-----------------------------------------------------------------
 1\n"));
+      assertFalse(customRunner.lines.isEmpty());
+      
assertTrue(customRunner.lines.contains("-----------------------------------------------------------------
 1\n"));
     }
   }
 
@@ -649,7 +650,8 @@ public class TestAPI {
   public void testAPI13() throws IOException, ClassNotFoundException, 
ExternalVariableException {
     // Demonstrates here that we can set external variables
     // after compilation but before parsing via Compiler.
-    DebuggerRunnerForAPITest debugger = new DebuggerRunnerForAPITest();
+    DebuggerRunnerForAPITest customRunner = new DebuggerRunnerForAPITest();
+    Debugger debugger = Daffodil.newDaffodilDebugger(customRunner);
 
     org.apache.daffodil.api.Compiler c = Daffodil.compiler();
 
@@ -659,8 +661,7 @@ public class TestAPI {
 
     DataProcessor dp = pf.onPath("/");
     dp = reserializeDataProcessor(dp);
-    dp = dp.withDebuggerRunner(debugger);
-    dp = dp.withDebugging(true);
+    dp = dp.withDebugger(debugger);
     dp = dp.withExternalVariables(extVarsFile);
 
     java.io.File file = getResource("/test/api/myData.dat");
@@ -685,7 +686,8 @@ public class TestAPI {
   public void testAPI14() throws IOException, ClassNotFoundException, 
ExternalVariableException {
     // Demonstrates here that we can set external variables
     // after compilation but before parsing via DataProcessor.
-    DebuggerRunnerForAPITest debugger = new DebuggerRunnerForAPITest();
+    DebuggerRunnerForAPITest customRunner = new DebuggerRunnerForAPITest();
+    Debugger debugger = Daffodil.newDaffodilDebugger(customRunner);
 
     org.apache.daffodil.api.Compiler c = Daffodil.compiler();
 
@@ -694,8 +696,7 @@ public class TestAPI {
     ProcessorFactory pf = c.compileFile(schemaFile);
     DataProcessor dp = pf.onPath("/");
     dp = reserializeDataProcessor(dp);
-    dp = dp.withDebuggerRunner(debugger);
-    dp = dp.withDebugging(true);
+    dp = dp.withDebugger(debugger);
     dp = dp.withExternalVariables(extVarFile);
 
     java.io.File file = getResource("/test/api/myData.dat");
@@ -714,8 +715,8 @@ public class TestAPI {
       assertTrue(containsVar1);
       assertTrue(containsVar1Value);
 
-      assertTrue(debugger.lines.size() > 0);
-      
assertTrue(debugger.lines.contains("-----------------------------------------------------------------
 1\n"));
+      assertFalse(customRunner.lines.isEmpty());
+      
assertTrue(customRunner.lines.contains("-----------------------------------------------------------------
 1\n"));
     }
   }
 
@@ -1008,7 +1009,8 @@ public class TestAPI {
   public void testAPI22_withExternalVariablesUsingAbstractMap() throws 
IOException, ClassNotFoundException, ExternalVariableException {
     // Demonstrates here that we can set external variables using a
     // Java AbstractMap after compilation but before parsing via DataProcessor.
-    DebuggerRunnerForAPITest debugger = new DebuggerRunnerForAPITest();
+    DebuggerRunnerForAPITest customRunner = new DebuggerRunnerForAPITest();
+    Debugger debugger = Daffodil.newDaffodilDebugger(customRunner);
 
     org.apache.daffodil.api.Compiler c = Daffodil.compiler();
 
@@ -1016,8 +1018,7 @@ public class TestAPI {
     ProcessorFactory pf = c.compileFile(schemaFile);
     DataProcessor dp = pf.onPath("/");
     dp = reserializeDataProcessor(dp);
-    dp = dp.withDebuggerRunner(debugger);
-    dp = dp.withDebugging(true);
+    dp = dp.withDebugger(debugger);
 
     java.util.AbstractMap<String, String> extVarsMap = new 
java.util.HashMap<String, String>();
     extVarsMap.put("var1", "var1ValueFromMap");
@@ -1040,8 +1041,8 @@ public class TestAPI {
       assertTrue(containsVar1);
       assertTrue(containsVar1Value);
 
-      assertTrue(debugger.lines.size() > 0);
-      
assertTrue(debugger.lines.contains("-----------------------------------------------------------------
 1\n"));
+      assertFalse(customRunner.lines.isEmpty());
+      
assertTrue(customRunner.lines.contains("-----------------------------------------------------------------
 1\n"));
     }
   }
 
diff --git 
a/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestCustomDebuggerAPI.java
 
b/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestCustomDebuggerAPI.java
index e42803040..a8e3359b1 100644
--- 
a/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestCustomDebuggerAPI.java
+++ 
b/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestCustomDebuggerAPI.java
@@ -35,6 +35,27 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 public class TestCustomDebuggerAPI {
+  @Test
+  public void testCustomDebugger() throws IOException, ClassNotFoundException {
+    org.apache.daffodil.api.Compiler c = Daffodil.compiler();
+
+    CustomDebugger dbg = new CustomDebugger();
+    URI schemaFileName = 
Misc.getRequiredResource("/test/api/mySchema1.dfdl.xsd");
+    ProcessorFactory pf = c.compileSource(schemaFileName);
+    DataProcessor dp = pf.onPath("/")
+      .withDebugger(dbg);
+
+    String file = 
Misc.getRequiredResource("/test/api/myData2.dat").toURL().getFile();
+    java.io.FileInputStream fis = new java.io.FileInputStream(file);
+    try (InputSourceDataInputStream dis = 
Daffodil.newInputSourceDataInputStream(fis)) {
+      ParseResult res = dp.parse(dis, Daffodil.newNullInfosetOutputter());
+
+      assertEquals(6, dbg.nodes);
+      assertTrue(dbg.inited);
+      assertTrue(dbg.finished);
+    }
+  }
+
   static class CustomDebugger implements Debugger {
     public int nodes;
     public boolean inited;
@@ -55,26 +76,4 @@ public class TestCustomDebuggerAPI {
       finished = true;
     }
   }
-
-  @Test
-  public void testCustomDebugger() throws IOException, ClassNotFoundException {
-    org.apache.daffodil.api.Compiler c = Daffodil.compiler();
-
-    CustomDebugger dbg = new CustomDebugger();
-    URI schemaFileName = 
Misc.getRequiredResource("/test/api/mySchema1.dfdl.xsd");
-    ProcessorFactory pf = c.compileSource(schemaFileName);
-    DataProcessor dp = pf.onPath("/")
-      .withDebugger(dbg)
-      .withDebugging(true);
-
-    String file = 
Misc.getRequiredResource("/test/api/myData2.dat").toURL().getFile();
-    java.io.FileInputStream fis = new java.io.FileInputStream(file);
-    try (InputSourceDataInputStream dis = 
Daffodil.newInputSourceDataInputStream(fis)) {
-      ParseResult res = dp.parse(dis, Daffodil.newNullInfosetOutputter());
-
-      assertEquals(6, dbg.nodes);
-      assertTrue(dbg.inited);
-      assertTrue(dbg.finished);
-    }
-  }
 }
diff --git 
a/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestInfosetEvent.java
 
b/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestInfosetEvent.java
index 00af4c89d..b57d167b1 100644
--- 
a/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestInfosetEvent.java
+++ 
b/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestInfosetEvent.java
@@ -41,20 +41,6 @@ public class TestInfosetEvent {
     this.isNilled = _isNilled;
   }
 
-  public boolean equals(Object o) {
-    if (!(o instanceof TestInfosetEvent)) {
-      return false;
-    }
-    TestInfosetEvent that = (TestInfosetEvent) o;
-    return
-        this.eventType == that.eventType &&
-            java.util.Objects.equals(this.localName, that.localName) &&
-            java.util.Objects.equals(this.namespaceURI, that.namespaceURI) &&
-            java.util.Objects.equals(this.simpleText, that.simpleText) &&
-            java.util.Objects.equals(this.isNilled, that.isNilled);
-
-  }
-
   static TestInfosetEvent startDocument() {
     return new TestInfosetEvent(StartDocument, null, null, null, null);
   }
@@ -86,4 +72,18 @@ public class TestInfosetEvent {
   static TestInfosetEvent endDocument() {
     return new TestInfosetEvent(EndDocument, null, null, null, null);
   }
+
+  public boolean equals(Object o) {
+    if (!(o instanceof TestInfosetEvent)) {
+      return false;
+    }
+    TestInfosetEvent that = (TestInfosetEvent) o;
+    return
+      this.eventType == that.eventType &&
+        java.util.Objects.equals(this.localName, that.localName) &&
+        java.util.Objects.equals(this.namespaceURI, that.namespaceURI) &&
+        java.util.Objects.equals(this.simpleText, that.simpleText) &&
+        java.util.Objects.equals(this.isNilled, that.isNilled);
+
+  }
 }
diff --git 
a/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestInfosetOutputter.java
 
b/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestInfosetOutputter.java
index ecfc2f4f7..3617354b4 100644
--- 
a/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestInfosetOutputter.java
+++ 
b/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestInfosetOutputter.java
@@ -52,37 +52,37 @@ public class TestInfosetOutputter extends InfosetOutputter {
   @Override
   public void startSimple(InfosetSimpleElement simple) {
     events.add(
-        TestInfosetEvent.startSimple(
-            simple.metadata().name(),
-            simple.metadata().namespace(),
-            simple.getText(),
-            simple.metadata().isNillable() ? simple.isNilled() : null));
+      TestInfosetEvent.startSimple(
+        simple.metadata().name(),
+        simple.metadata().namespace(),
+        simple.getText(),
+        simple.metadata().isNillable() ? simple.isNilled() : null));
   }
 
   @Override
   public void endSimple(InfosetSimpleElement simple) {
     events.add(
-        TestInfosetEvent.endSimple(
-            simple.metadata().name(),
-            simple.metadata().namespace()));
+      TestInfosetEvent.endSimple(
+        simple.metadata().name(),
+        simple.metadata().namespace()));
   }
 
   @Override
   public void startComplex(InfosetComplexElement complex) throws Exception {
 
     events.add(
-        TestInfosetEvent.startComplex(
-            complex.metadata().name(),
-            complex.metadata().namespace(),
-            complex.metadata().isNillable() ? complex.isNilled() : null));
+      TestInfosetEvent.startComplex(
+        complex.metadata().name(),
+        complex.metadata().namespace(),
+        complex.metadata().isNillable() ? complex.isNilled() : null));
   }
 
   @Override
   public void endComplex(InfosetComplexElement complex) {
     events.add(
-        TestInfosetEvent.endComplex(
-            complex.metadata().name(),
-            complex.metadata().namespace()));
+      TestInfosetEvent.endComplex(
+        complex.metadata().name(),
+        complex.metadata().namespace()));
   }
 
   @Override
diff --git 
a/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestJavaMetadataAPI.java
 
b/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestJavaMetadataAPI.java
index b8b70cc8a..a1fe9b19d 100644
--- 
a/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestJavaMetadataAPI.java
+++ 
b/daffodil-core/src/test/java/org/apache/daffodil/jexample/TestJavaMetadataAPI.java
@@ -50,6 +50,38 @@ public class TestJavaMetadataAPI {
     }
   }
 
+  @Test
+  public void testMetadataWalkDataWalk01() throws IOException {
+    GatherMetadata gatherMetadata = new GatherMetadata();
+    org.apache.daffodil.api.Compiler c = Daffodil.compiler();
+    File schemaFile = getResource("/test/api/metadataTestSchema1.dfdl.xsd");
+    ProcessorFactory pf = c.compileFile(schemaFile);
+    if (pf.isError()) {
+      String diags = pf.getDiagnostics()
+        .stream()
+        .map(Diagnostic::getMessage)
+        .collect(Collectors.joining(System.lineSeparator()));
+      fail(diags);
+    }
+    DataProcessor dp = pf.onPath("/");
+    dp.walkMetadata(gatherMetadata);
+    List<Metadata> md = gatherMetadata.getResult();
+    List<String> mdQNames = md.stream().map(item -> {
+      if (item instanceof ElementMetadata) {
+        ElementMetadata em = ((ElementMetadata) item);
+        String res = em.toQName() + ((em.isArray()) ? "_array" : "");
+        return res;
+      } else if (item instanceof SequenceMetadata) {
+        return "seq";
+      } else if (item instanceof ChoiceMetadata) {
+        return "cho";
+      } else {
+        return "";
+      }
+    }).collect(Collectors.toList());
+    assertEquals("[ex:e1, cho, seq, seq, seq, s1_array, seq, cho, ex:e1]", 
mdQNames.toString());
+  }
+
   public static class GatherMetadata extends MetadataHandler {
 
     private final List<Metadata> buf = new ArrayList<>();
@@ -95,37 +127,4 @@ public class TestJavaMetadataAPI {
       buf.add(m);
     }
   }
-
-
-  @Test
-  public void testMetadataWalkDataWalk01() throws IOException {
-    GatherMetadata gatherMetadata = new GatherMetadata();
-    org.apache.daffodil.api.Compiler c = Daffodil.compiler();
-    File schemaFile = getResource("/test/api/metadataTestSchema1.dfdl.xsd");
-    ProcessorFactory pf = c.compileFile(schemaFile);
-    if (pf.isError()) {
-      String diags = pf.getDiagnostics()
-          .stream()
-          .map(Diagnostic::getMessage)
-          .collect(Collectors.joining(System.lineSeparator()));
-      fail(diags);
-    }
-    DataProcessor dp = pf.onPath("/");
-    dp.walkMetadata(gatherMetadata);
-    List<Metadata> md = gatherMetadata.getResult();
-    List<String> mdQNames = md.stream().map(item -> {
-      if (item instanceof ElementMetadata) {
-        ElementMetadata em = ((ElementMetadata) item);
-        String res = em.toQName() + ((em.isArray()) ? "_array" : "");
-        return res;
-      } else if (item instanceof SequenceMetadata) {
-        return "seq";
-      } else if (item instanceof ChoiceMetadata) {
-        return "cho";
-      } else {
-        return "";
-      }
-    }).collect(Collectors.toList());
-    assertEquals("[ex:e1, cho, seq, seq, seq, s1_array, seq, cho, ex:e1]", 
mdQNames.toString());
-  }
 }
diff --git 
a/daffodil-core/src/test/scala/org/apache/daffodil/sexample/DebuggerRunnerForAPITest.scala
 
b/daffodil-core/src/test/scala/org/apache/daffodil/sexample/DebuggerRunnerForAPITest.scala
index 400405c6a..0ba1eaa22 100644
--- 
a/daffodil-core/src/test/scala/org/apache/daffodil/sexample/DebuggerRunnerForAPITest.scala
+++ 
b/daffodil-core/src/test/scala/org/apache/daffodil/sexample/DebuggerRunnerForAPITest.scala
@@ -19,9 +19,10 @@ package org.apache.daffodil.sexample
 
 import scala.collection.mutable.ListBuffer
 
-import org.apache.daffodil.api.debugger.DebuggerRunner
+import org.apache.daffodil.api.debugger.DaffodilDebuggerRunner
+import org.apache.daffodil.runtime1.debugger.DaffodilDebugger
 
-class DebuggerRunnerForAPITest extends DebuggerRunner {
+class DebuggerRunnerForAPITest extends DaffodilDebuggerRunner {
   val lines = ListBuffer[String]()
 
   val commandsIter = Seq(
@@ -33,7 +34,7 @@ class DebuggerRunnerForAPITest extends DebuggerRunner {
     "trace"
   ).iterator
 
-  def init(): Unit = {}
+  def init(dd: DaffodilDebugger): Unit = {}
 
   def fini(): Unit = {}
 
diff --git 
a/daffodil-core/src/test/scala/org/apache/daffodil/sexample/TestAPI.scala 
b/daffodil-core/src/test/scala/org/apache/daffodil/sexample/TestAPI.scala
index d2f91d6d4..1b06c8f33 100644
--- a/daffodil-core/src/test/scala/org/apache/daffodil/sexample/TestAPI.scala
+++ b/daffodil-core/src/test/scala/org/apache/daffodil/sexample/TestAPI.scala
@@ -139,15 +139,15 @@ class TestAPI {
 
   @Test
   def testAPI1(): Unit = {
-    val debugger = new DebuggerRunnerForAPITest()
+    val customRunner = new DebuggerRunnerForAPITest()
+    val debugger = Daffodil.newDaffodilDebugger(customRunner)
 
     val c = Daffodil.compiler()
     val schemaFile = getResource("/test/api/mySchema1.dfdl.xsd")
     val pf = c.compileFile(schemaFile)
     val dp1 = pf.onPath("/")
     val dp = reserializeDataProcessor(dp1)
-      .withDebuggerRunner(debugger)
-      .withDebugging(true)
+      .withDebugger(debugger)
       .withValidation("off")
 
     val file = getResource("/test/api/myData.dat")
@@ -158,12 +158,12 @@ class TestAPI {
       val err = res.isError()
       assertFalse(err)
 
-      assertTrue(debugger.lines.size > 0)
+      assertTrue(customRunner.lines.nonEmpty)
       assertTrue(
-        debugger.lines
+        customRunner.lines
           
.contains("----------------------------------------------------------------- 
1\n")
       )
-      assertTrue(debugger.getCommand().equals("trace"))
+      assertTrue(customRunner.getCommand().equals("trace"))
 
       val bos = new java.io.ByteArrayOutputStream()
       val wbc = java.nio.channels.Channels.newChannel(bos)
@@ -178,7 +178,8 @@ class TestAPI {
   // before executing the test.
   @Test
   def testAPI1_A(): Unit = {
-    val debugger = new DebuggerRunnerForAPITest()
+    val customRunner = new DebuggerRunnerForAPITest()
+    val debugger = Daffodil.newDaffodilDebugger(customRunner)
 
     val c = Daffodil.compiler()
 
@@ -196,8 +197,7 @@ class TestAPI {
     val compiler = Daffodil.compiler()
     val parser = compiler
       .reload(savedParser)
-      .withDebuggerRunner(debugger)
-      .withDebugging(true)
+      .withDebugger(debugger)
       .withValidation("off")
     val file = getResource("/test/api/myData.dat")
     // This test uses a byte array here, just so as to be sure to exercise
@@ -211,12 +211,12 @@ class TestAPI {
       val err = res.isError()
       assertFalse(err)
 
-      assertTrue(debugger.lines.size > 0)
+      assertTrue(customRunner.lines.nonEmpty)
       assertTrue(
-        debugger.lines
+        customRunner.lines
           
.contains("----------------------------------------------------------------- 
1\n")
       )
-      assertTrue(debugger.getCommand().equals("trace"))
+      assertTrue(customRunner.getCommand().equals("trace"))
 
       val bos = new java.io.ByteArrayOutputStream()
       val wbc = java.nio.channels.Channels.newChannel(bos)
@@ -595,7 +595,8 @@ class TestAPI {
   }
   @Test
   def testAPI12(): Unit = {
-    val debugger = new DebuggerRunnerForAPITest()
+    val customRunner = new DebuggerRunnerForAPITest()
+    val debugger = Daffodil.newDaffodilDebugger(customRunner)
 
     val c = Daffodil.compiler()
 
@@ -603,8 +604,7 @@ class TestAPI {
     val pf = c.compileFile(schemaFile)
     val dp1 = pf.onPath("/")
     val dp = reserializeDataProcessor(dp1)
-      .withDebuggerRunner(debugger)
-      .withDebugging(true)
+      .withDebugger(debugger)
       .withValidation("off")
 
     val file = getResource("/test/api/myData.dat")
@@ -615,9 +615,9 @@ class TestAPI {
       val err = res.isError()
       assertFalse(err)
 
-      assertTrue(debugger.lines.size > 0)
+      assertTrue(customRunner.lines.nonEmpty)
       assertTrue(
-        debugger.lines
+        customRunner.lines
           
.contains("----------------------------------------------------------------- 
1\n")
       )
     }
@@ -626,7 +626,8 @@ class TestAPI {
   def testAPI13(): Unit = {
     // Demonstrates here that we can set external variables
     // after compilation but before parsing via Compiler.
-    val debugger = new DebuggerRunnerForAPITest()
+    val customRunner = new DebuggerRunnerForAPITest()
+    val debugger = Daffodil.newDaffodilDebugger(customRunner)
     val c = Daffodil.compiler()
 
     val extVarsFile = getResource("/test/api/external_vars_1.xml")
@@ -636,8 +637,7 @@ class TestAPI {
     val dp1 = pf.onPath("/")
     val dp = reserializeDataProcessor(dp1)
       .withExternalVariables(extVarsFile)
-      .withDebuggerRunner(debugger)
-      .withDebugging(true)
+      .withDebugger(debugger)
       .withValidation("off")
 
     val file = getResource("/test/api/myData.dat")
@@ -658,7 +658,8 @@ class TestAPI {
   def testAPI14(): Unit = {
     // Demonstrates here that we can set external variables
     // after compilation but before parsing via DataProcessor.
-    val debugger = new DebuggerRunnerForAPITest()
+    val customRunner = new DebuggerRunnerForAPITest()
+    val debugger = Daffodil.newDaffodilDebugger(customRunner)
 
     val c = Daffodil.compiler()
 
@@ -668,8 +669,7 @@ class TestAPI {
     val dp1 = pf.onPath("/")
     val dp = reserializeDataProcessor(dp1)
       .withExternalVariables(extVarFile)
-      .withDebuggerRunner(debugger)
-      .withDebugging(true)
+      .withDebugger(debugger)
       .withValidation("off")
 
     val file = getResource("/test/api/myData.dat")
@@ -685,9 +685,9 @@ class TestAPI {
       val var1ValueText = var1ValueNode.text
       assertTrue(var1ValueText == "externallySet")
 
-      assertTrue(debugger.lines.size > 0)
+      assertTrue(customRunner.lines.size > 0)
       assertTrue(
-        debugger.lines
+        customRunner.lines
           
.contains("----------------------------------------------------------------- 
1\n")
       )
     }
@@ -699,7 +699,8 @@ class TestAPI {
   //
   @Test
   def testAPI1_A_Full_SavedParser(): Unit = {
-    val debugger = new DebuggerRunnerForAPITest()
+    val customRunner = new DebuggerRunnerForAPITest()
+    val debugger = Daffodil.newDaffodilDebugger(customRunner)
 
     val c = Daffodil.compiler()
 
@@ -707,8 +708,7 @@ class TestAPI {
     val pf = c.compileFile(schemaFile)
     val dp = pf
       .onPath("/")
-      .withDebuggerRunner(debugger)
-      .withDebugging(true)
+      .withDebugger(debugger)
     // Serialize the parser to memory, then deserialize for parsing.
     val os = new ByteArrayOutputStream()
     val output = Channels.newChannel(os)
@@ -724,7 +724,8 @@ class TestAPI {
 
   @Test
   def testAPI15(): Unit = {
-    val debugger = new DebuggerRunnerForAPITest()
+    val customRunner = new DebuggerRunnerForAPITest()
+    val debugger = Daffodil.newDaffodilDebugger(customRunner)
 
     val c = Daffodil.compiler()
 
@@ -732,8 +733,7 @@ class TestAPI {
     val pf = c.compileFile(schemaFile)
     val dp1 = pf.onPath("/")
     val dp = reserializeDataProcessor(dp1)
-      .withDebuggerRunner(debugger)
-      .withDebugging(true)
+      .withDebugger(debugger)
 
     val file = getResource("/test/api/myInfosetBroken.xml")
     val xml = scala.xml.XML.loadFile(file)
@@ -1016,7 +1016,8 @@ class TestAPI {
   @Test
   def testAPI22(): Unit = {
     // Test SAX unparse with errors
-    val debugger = new DebuggerRunnerForAPITest()
+    val customRunner = new DebuggerRunnerForAPITest()
+    val debugger = Daffodil.newDaffodilDebugger(customRunner)
 
     val c = Daffodil.compiler()
 
@@ -1024,8 +1025,7 @@ class TestAPI {
     val pf = c.compileFile(schemaFile)
     val dp1 = pf.onPath("/")
     val dp = reserializeDataProcessor(dp1)
-      .withDebuggerRunner(debugger)
-      .withDebugging(true)
+      .withDebugger(debugger)
 
     val file = getResource("/test/api/myInfosetBroken.xml")
     val xml = scala.xml.XML.loadFile(file)
diff --git 
a/daffodil-core/src/test/scala/org/apache/daffodil/sexample/TestCustomDebuggerAPI.scala
 
b/daffodil-core/src/test/scala/org/apache/daffodil/sexample/TestCustomDebuggerAPI.scala
index d6ebf3734..f521e357d 100644
--- 
a/daffodil-core/src/test/scala/org/apache/daffodil/sexample/TestCustomDebuggerAPI.scala
+++ 
b/daffodil-core/src/test/scala/org/apache/daffodil/sexample/TestCustomDebuggerAPI.scala
@@ -50,7 +50,6 @@ class TestCustomDebuggerAPI {
     val dp = pf
       .onPath("/")
       .withDebugger(dbg)
-      .withDebugging(true)
 
     val file = Misc.getRequiredResource("/test/api/myData.dat")
     val fis = new java.io.FileInputStream(file.toURL.getFile)
diff --git 
a/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala 
b/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
index e74a2ce33..0549c61ac 100644
--- a/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
+++ b/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
@@ -945,7 +945,7 @@ abstract class TestCase(testCaseXML: NodeSeq, val parent: 
DFDLTestSuite) {
         case (diags, proc: TDMLDFDLProcessor) =>
           // warnings are checked elsewhere for expected ones.
           val newProc: TDMLDFDLProcessor =
-            
proc.withDebugging(parent.areDebugging).withTracing(parent.areTracing)
+            proc.withTracing(parent.areTracing)
           val newNewProc =
             if (
               parent.areDebugging &&
diff --git 
a/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/processor/TDMLDFDLProcessor.scala
 
b/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/processor/TDMLDFDLProcessor.scala
index 072093204..d2d3060e5 100644
--- 
a/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/processor/TDMLDFDLProcessor.scala
+++ 
b/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/processor/TDMLDFDLProcessor.scala
@@ -70,8 +70,6 @@ trait TDMLDFDLProcessor {
 
   protected type R <: TDMLDFDLProcessor
 
-  def withDebugging(onOff: Boolean): R
-
   def withTracing(onOff: Boolean): R
 
   def withDebugger(db: AnyRef): R
diff --git 
a/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/processor/tdml/DaffodilCTDMLDFDLProcessor.scala
 
b/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/processor/tdml/DaffodilCTDMLDFDLProcessor.scala
index a2bd73fc6..4acdff772 100644
--- 
a/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/processor/tdml/DaffodilCTDMLDFDLProcessor.scala
+++ 
b/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/processor/tdml/DaffodilCTDMLDFDLProcessor.scala
@@ -122,7 +122,6 @@ final class DaffodilCTDMLDFDLProcessor(executable: os.Path) 
extends TDMLDFDLProc
 
   // We don't pass any options to the executable
   override type R = DaffodilCTDMLDFDLProcessor
-  override def withDebugging(onOff: Boolean): R = this
   override def withTracing(onOff: Boolean): R = this
   override def withDebugger(db: AnyRef): R = this
   override def withValidation(validation: String): R = this
diff --git 
a/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/processor/tdml/DaffodilTDMLDFDLProcessor.scala
 
b/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/processor/tdml/DaffodilTDMLDFDLProcessor.scala
index 89f53430d..699d05276 100644
--- 
a/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/processor/tdml/DaffodilTDMLDFDLProcessor.scala
+++ 
b/daffodil-tdml-processor/src/main/scala/org/apache/daffodil/processor/tdml/DaffodilTDMLDFDLProcessor.scala
@@ -31,9 +31,8 @@ import scala.util.Using
 import scala.xml.Node
 
 import org.apache.daffodil.api
-import org.apache.daffodil.api.debugger.InteractiveDebuggerRunnerFactory
+import org.apache.daffodil.api.Daffodil
 import org.apache.daffodil.core.compiler.Compiler
-import org.apache.daffodil.core.dsom.ExpressionCompilers
 import org.apache.daffodil.io.InputSourceDataInputStream
 import org.apache.daffodil.lib.exceptions.Assert
 import org.apache.daffodil.lib.externalvars.Binding
@@ -42,8 +41,6 @@ import org.apache.daffodil.lib.util.MaybeULong
 import org.apache.daffodil.lib.xml.DaffodilSAXParserFactory
 import org.apache.daffodil.lib.xml.XMLUtils
 import org.apache.daffodil.lib.xml.XMLUtils.XMLDifferenceException
-import org.apache.daffodil.runtime1.debugger.Debugger
-import org.apache.daffodil.runtime1.debugger.InteractiveDebugger
 import org.apache.daffodil.runtime1.iapi.*
 import org.apache.daffodil.runtime1.iapi.DFDL.DaffodilUnhandledSAXException
 import org.apache.daffodil.runtime1.iapi.DFDL.DaffodilUnparseContentHandler
@@ -169,11 +166,7 @@ class DaffodilTDMLDFDLProcessor private[tdml] (
 
   private def copy(dp: api.DataProcessor = dp) = new 
DaffodilTDMLDFDLProcessor(dp, schemaURI)
 
-  private lazy val builtInTracer =
-    new InteractiveDebugger(
-      InteractiveDebuggerRunnerFactory.newTraceDebuggerRunner(System.out),
-      ExpressionCompilers
-    )
+  private lazy val builtInTracer = Daffodil.newTraceDebugger(System.out)
 
   private lazy val blobDir =
     Paths.get(System.getProperty("java.io.tmpdir"), "daffodil-tdml", "blobs")
@@ -182,23 +175,19 @@ class DaffodilTDMLDFDLProcessor private[tdml] (
 
   private lazy val tdmlApiInfosetsEnv = 
sys.env.getOrElse("DAFFODIL_TDML_API_INFOSETS", "scala")
 
-  override def withDebugging(b: Boolean): DaffodilTDMLDFDLProcessor =
-    copy(dp = dp.withDebugging(b))
-
   override def withTracing(bool: Boolean): DaffodilTDMLDFDLProcessor = {
     copy(dp = newTracing(bool))
   }
 
   private def newTracing(bool: Boolean) =
     if (bool) {
-      dp.withDebugger(builtInTracer).withDebugging(true)
+      dp.withDebugger(builtInTracer)
     } else {
-      dp.withDebugging(false)
+      dp.withDebugger(null)
     }
 
   override def withDebugger(debugger: AnyRef): DaffodilTDMLDFDLProcessor = {
-    Assert.usage(debugger ne null)
-    val d = debugger.asInstanceOf[Debugger]
+    val d = debugger.asInstanceOf[api.debugger.Debugger]
     copy(dp = dp.withDebugger(d))
   }
 
diff --git 
a/daffodil-test/src/test/scala/org/apache/daffodil/usertests/TestUserSubmittedTests.scala
 
b/daffodil-test/src/test/scala/org/apache/daffodil/usertests/TestUserSubmittedTests.scala
index a8aa55c28..6a77b7e45 100644
--- 
a/daffodil-test/src/test/scala/org/apache/daffodil/usertests/TestUserSubmittedTests.scala
+++ 
b/daffodil-test/src/test/scala/org/apache/daffodil/usertests/TestUserSubmittedTests.scala
@@ -20,7 +20,7 @@ package org.apache.daffodil.usertests
 import org.apache.daffodil.core.dsom.ExpressionCompilers
 import org.apache.daffodil.junit.tdml.TdmlSuite
 import org.apache.daffodil.junit.tdml.TdmlTests
-import org.apache.daffodil.runtime1.debugger.InteractiveDebugger
+import org.apache.daffodil.runtime1.debugger.DaffodilDebugger
 import org.apache.daffodil.runtime1.debugger.TraceDebuggerRunner
 
 import org.junit.Assert.assertTrue
@@ -55,7 +55,7 @@ class TestUserSubmittedTests extends TdmlTests {
 
   @Test def test_DFDL_782() = {
     val crunner = new CountTraceDebuggerRunner
-    val db = new InteractiveDebugger(crunner, ExpressionCompilers)
+    val db = new DaffodilDebugger(crunner, ExpressionCompilers)
 
     // sets the debugger and enables debugging
     tdmlSuite.runner.setDebugger(db)

Reply via email to