You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sl...@apache.org on 2019/06/26 16:52:14 UTC
[incubator-daffodil] branch master updated: Add debugger
infosetParents config option and update trace mode
This is an automated email from the ASF dual-hosted git repository.
slawrence pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-daffodil.git
The following commit(s) were added to refs/heads/master by this push:
new ad83748 Add debugger infosetParents config option and update trace mode
ad83748 is described below
commit ad83748e95d17ecb1b8633d2bf3f117cb32dac2d
Author: Steve Lawrence <sl...@apache.org>
AuthorDate: Tue Jun 25 13:10:07 2019 -0400
Add debugger infosetParents config option and update trace mode
This new config option determines how many parent elements to include
when running the "info infoset" debugger command. A value of -1 will
show the entire inforset, which is the current and default behavior. A
value of zero or more will show 0 or more parent elements, in addition
to the current element.
Also modify the trace mode commands to set this property to "1" to show
a single parent and use "info infoset" so show the infoset. This
replaces the "eval .." command which gave unfriendly results going past
the root element.
DAFFODIL-1931
---
.../daffodil/debugger/InteractiveDebugger.scala | 39 ++++++++++++++++++++--
.../daffodil/debugger/TraceDebuggerRunner.scala | 7 ++--
2 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/debugger/InteractiveDebugger.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/debugger/InteractiveDebugger.scala
index 684817e..15bb26e 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/debugger/InteractiveDebugger.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/debugger/InteractiveDebugger.scala
@@ -91,6 +91,10 @@ class InteractiveDebugger(runner: InteractiveDebuggerRunner, eCompilers: Express
* everything */
var infosetLines: Int = -1
+ /* the number of parent elements to include when displaying the infoset. -1
+ * means show all parents. 0 or more means show 0 or more parent elements. */
+ var infosetParents: Int = -1
+
/* the max number of bytes to display when displaying data */
var dataLength: Int = 70
@@ -1499,8 +1503,18 @@ class InteractiveDebugger(runner: InteractiveDebuggerRunner, eCompilers: Express
def act(args: Seq[String], prestate: StateForDebugger, state: ParseOrUnparseState, processor: Processor): DebugState.Type = {
debugPrintln("%s:".format(name))
- val infoset = state.infoset.toRootDoc
- if (infoset.getRootElement != null) {
+ var infoset: DIElement = state.infoset
+ if (DebuggerConfig.infosetParents < 0) {
+ infoset = infoset.toRootDoc.getRootElement().asInstanceOf[DIElement]
+ } else {
+ (1 to DebuggerConfig.infosetParents).foreach { n =>
+ if (infoset.diParent != null) {
+ infoset = infoset.diParent
+ }
+ }
+ }
+
+ if (infoset != null) {
val bos = new java.io.ByteArrayOutputStream()
val xml = new XMLTextInfosetOutputter(bos, true)
infoset.visit(xml, DebuggerConfig.removeHidden)
@@ -1576,7 +1590,7 @@ class InteractiveDebugger(runner: InteractiveDebuggerRunner, eCompilers: Express
|
|Example: set breakOnlyOnCreation false
| set dataLength 100""".stripMargin
- override val subcommands = Seq(SetBreakOnFailure, SetBreakOnlyOnCreation, SetDataLength, SetInfosetLines, SetRemoveHidden, SetRepresentation, SetWrapLength)
+ override val subcommands = Seq(SetBreakOnFailure, SetBreakOnlyOnCreation, SetDataLength, SetInfosetLines, SetInfosetParents, SetRemoveHidden, SetRepresentation, SetWrapLength)
override lazy val short = "set"
def act(args: Seq[String], prestate: StateForDebugger, state: ParseOrUnparseState, processor: Processor): DebugState.Type = {
@@ -1674,6 +1688,25 @@ class InteractiveDebugger(runner: InteractiveDebuggerRunner, eCompilers: Express
}
}
+ object SetInfosetParents extends DebugCommand with DebugCommandValidateInt {
+ val name = "infosetParents"
+ val desc = "set the number of parent elements to show when displaying the infoset (default: -1)"
+ val longDesc = """|Usage: set infosetParents|ip <value>
+ |
+ |Set the number of parent elements to show when displaying the infoset.
+ |This only affects the 'info infoset' command. A value of zero will only
+ |show the current infoset element. A value of -1 will show the entire
+ |infoset. Defaults to -1.
+ |
+ |Example: set infosetParents 2""".stripMargin
+ override lazy val short = "ip"
+
+ def act(args: Seq[String], prestate: StateForDebugger, state: ParseOrUnparseState, processor: Processor): DebugState.Type = {
+ DebuggerConfig.infosetParents = args.head.toInt
+ DebugState.Pause
+ }
+ }
+
object SetRemoveHidden extends DebugCommand with DebugCommandValidateBoolean {
val name = "removeHidden"
val desc = "set whether or not to remove Daffodil internal attributes when displaying the infoset (default: false)"
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/debugger/TraceDebuggerRunner.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/debugger/TraceDebuggerRunner.scala
index 283a7aa..cbc432e 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/debugger/TraceDebuggerRunner.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/debugger/TraceDebuggerRunner.scala
@@ -18,11 +18,12 @@
package org.apache.daffodil.debugger
class TraceDebuggerRunner extends InteractiveDebuggerRunner {
- val traceIter = Seq("display info parser",
+ val traceIter = Seq(
+ "set infosetParents 1",
+ "display info parser",
"display info bitPosition",
"display info data",
- // "display info infoset", // entire infoset
- "display eval ..", // by default, just this node's parent on down.
+ "display info infoset",
"display info diff",
"trace").iterator