Skip to content

xpath: add VM execution Tracer hook - #41

Draft
steiler wants to merge 1 commit into
mainfrom
feat/must-trace
Draft

steiler wants to merge 1 commit into
mainfrom
feat/must-trace

Conversation

@steiler

@steiler steiler commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds an opt-in execution tracer to the XPath VM so callers can observe each instruction, the evaluation stack, path stack and predicate keys, interleaved with host-side adapter calls.

  • xpath/tracer.go: Tracer interface, TraceEvent / TraceEventKind (vm_start, vm_instr, vm_instr_done, vm_end), FormatDatum, and stack/path/predicate snapshot helpers.
  • xpath/context.go: SetTracer(Tracer); the tracer propagates into predicate and function sub-contexts. Recovered VM panics are reported with Panicked: true.
  • xpath/datum.go, xpath/xutils/xpath_node.go: safe string rendering of all datum kinds, and <nil> guards for placeholder nodesets. Without these guards, debug printing panics on the [nil, ...] nodesets that data-server builds for list count().

No behaviour changes when no tracer is set.

Cross-references

Merge order

  1. this PR (yang-parser) → release a tag
  2. data-server PR (bumps github.com/sdcio/yang-parser to that tag)
  3. sdc-lite PR (bumps data-server and yang-parser)

Testing

  • go test -race ./xpath -run TestTracer
  • go test ./xpath/xutils
  • go vet ./xpath/...

Note: on origin/main, the legacy XpathNode tests (TestCodePredEndInMainProgram, xpath/grammars/expr, xpath/grammars/path_eval) and the xpath/grammars/leafref build already fail. They are not touched by this PR.

Signed-off-by: Markus Vahlenkamp <markus.vahlenkamp@nokia.com>
steiler added a commit to sdcio/sdc-lite that referenced this pull request Nov 26, 2026
Pseudo-versions track sdcio/data-server#566 and sdcio/yang-parser#41 until
those changes are released; released tags lack MustTracer and xpath.Tracer.

Signed-off-by: Markus Vahlenkamp <markus.vahlenkamp@nokia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant