Skip to content

Make trace generation opt-in for all user interfaces - #9150

Open
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:trace-opt-in
Open

Make trace generation opt-in for all user interfaces#9150
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:trace-opt-in

Conversation

@tautschnig

Copy link
Copy Markdown
Collaborator

The JSON and XML interfaces enabled counterexample-trace generation unconditionally, while the plain interface requires --trace. Consumers of the structured interfaces that only need property verdicts pay a very large cost for traces they discard: for a Kani-generated standard library harness with 611 properties, of which 63 are expected-failure reachability (cover-style) checks, CBMC with --json-ui spends 296 seconds wall-clock where the same invocation with the plain interface takes 34 seconds. 82% of total CPU time goes to BigInt::as_string via integer2binary, serialising ~2 MB of JSON trace - dominated by the "binary" fields of constant values - for each expected failure.

Make trace generation opt-in uniformly across the plain, JSON and XML interfaces, for both cbmc and jbmc: traces are generated when requested explicitly (--trace, --compact-trace, --stack-trace) or when a mode whose purpose is trace output is active (--stop-on-fail, --graphml-witness, --validate-trace). This is a behavioural change for JSON/XML consumers that relied on implicit traces; they need to pass --trace (as the plain interface always required). The --cover mode already disabled the implicit trace default, so the previous behaviour was not even uniform within the structured interfaces.

Regression tests that relied on implicit traces under --xml-ui now pass --trace explicitly (xml-trace, xml-trace2, Float24, function-return-no-body1); a new test checks both that --json-ui alone produces no trace elements and that --json-ui --trace does.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

The JSON and XML interfaces enabled counterexample-trace generation
unconditionally, while the plain interface requires --trace. Consumers
of the structured interfaces that only need property verdicts pay a
very large cost for traces they discard: for a Kani-generated standard
library harness with 611 properties, of which 63 are expected-failure
reachability (cover-style) checks, CBMC with --json-ui spends 296
seconds wall-clock where the same invocation with the plain interface
takes 34 seconds. 82% of total CPU time goes to BigInt::as_string via
integer2binary, serialising ~2 MB of JSON trace - dominated by the
"binary" fields of constant values - for each expected failure.

Make trace generation opt-in uniformly across the plain, JSON and XML
interfaces, for both cbmc and jbmc: traces are generated when requested
explicitly (--trace, --compact-trace, --stack-trace) or when a mode
whose purpose is trace output is active (--stop-on-fail,
--graphml-witness, --validate-trace). This is a behavioural change for
JSON/XML consumers that relied on implicit traces; they need to pass
--trace (as the plain interface always required). The --cover mode
already disabled the implicit trace default, so the previous behaviour
was not even uniform within the structured interfaces.

Regression tests that relied on implicit traces under --xml-ui now pass
--trace explicitly (xml-trace, xml-trace2, Float24,
function-return-no-body1); a new test checks both that --json-ui alone
produces no trace elements and that --json-ui --trace does.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@tautschnig tautschnig self-assigned this Aug 4, 2026
Copilot AI review requested due to automatic review settings August 4, 2026 11:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes CBMC/JBMC CLI option handling so counterexample trace generation becomes opt-in consistently across the plain, JSON, and XML UIs, addressing major performance overhead for structured-output consumers that only need verdicts.

Changes:

  • Remove the previous implicit “JSON/XML UI implies traces” behavior; traces are now enabled only by explicit trace flags (or trace-focused modes such as --stop-on-fail / --graphml-witness / --validate-trace where applicable).
  • Update existing XML regression tests to pass --trace explicitly.
  • Add new CBMC regression tests to assert --json-ui produces no "trace" output unless --trace is provided.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/cbmc/cbmc_parse_options.cpp Removes implicit trace enabling for non-plain UIs; keeps trace opt-in via explicit flags / trace-oriented modes.
jbmc/src/jbmc/jbmc_parse_options.cpp Mirrors CBMC’s opt-in trace behavior for JBMC, including --validate-trace.
regression/cbmc/xml-trace2/test.desc Adds --trace to reflect new opt-in trace behavior for XML UI.
regression/cbmc/xml-trace/test.desc Adds --trace to reflect new opt-in trace behavior for XML UI.
regression/cbmc/function-return-no-body1/test.desc Adds --trace to reflect new opt-in trace behavior for XML UI.
regression/cbmc/Float24/test.desc Adds --trace to reflect new opt-in trace behavior for XML UI.
regression/cbmc/json-ui-trace-opt-in/main.c New minimal failing program used to exercise JSON trace presence/absence.
regression/cbmc/json-ui-trace-opt-in/test.desc New test asserting --json-ui output does not include trace data unless requested.
regression/cbmc/json-ui-trace-opt-in/trace.desc New test asserting --json-ui --trace includes trace data.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 313 to 317
if(
cmdline.isset("trace") || cmdline.isset("compact-trace") ||
cmdline.isset("stack-trace") || cmdline.isset("stop-on-fail") ||
(ui_message_handler.get_ui() != ui_message_handlert::uit::PLAIN &&
!cmdline.isset("cover")))
cmdline.isset("stack-trace") || cmdline.isset("stop-on-fail"))
{
options.set_option("trace", true);
Comment on lines 172 to 176
if(
cmdline.isset("trace") || cmdline.isset("compact-trace") ||
cmdline.isset("stack-trace") || cmdline.isset("stop-on-fail") ||
(ui_message_handler.get_ui() != ui_message_handlert::uit::PLAIN &&
!cmdline.isset("cover")))
cmdline.isset("stack-trace") || cmdline.isset("stop-on-fail"))
{
options.set_option("trace", true);
Comment on lines +1 to +6
int main()
{
int x;
__CPROVER_assert(x != 42, "should fail with a counterexample");
return 0;
}
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.84%. Comparing base (f71fdad) to head (d7caa9d).
⚠️ Report is 4 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #9150   +/-   ##
========================================
  Coverage    80.83%   80.84%           
========================================
  Files         1715     1715           
  Lines       189948   189985   +37     
  Branches        73       73           
========================================
+ Hits        153540   153584   +44     
+ Misses       36408    36401    -7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kroening

kroening commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

This is very much a breaking change; let's consider it for CBMC 7.

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.

3 participants