Skip to content

Honor --compact-trace in JSON trace output - #9135

Open
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:json-compact-trace
Open

Honor --compact-trace in JSON trace output#9135
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:json-compact-trace

Conversation

@tautschnig

Copy link
Copy Markdown
Collaborator

The --compact-trace option was silently ignored with --json-ui: the JSON trace converter received the trace options but only consulted them for the extended-LHS format, so JSON consumers always got the full trace including hidden steps and actual-parameter assignments.

Apply the same filtering as show_compact_goto_trace when the option is set: skip hidden steps and actual-parameter assignments, and keep only assignments, declarations, function calls/returns and violated assertions. On instrumentation-heavy programs this shrinks the JSON trace by orders of magnitude because the values of internal instrumentation steps dominate the output; on a Kani-generated verification harness for Rust's write_bytes intrinsic, the trace output shrinks from 427 MB to 3 MB while retaining all counterexample-relevant assignments.

  • 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 --compact-trace option was silently ignored with --json-ui: the
JSON trace converter received the trace options but only consulted
them for the extended-LHS format, so JSON consumers always got the
full trace including hidden steps and actual-parameter assignments.

Apply the same filtering as show_compact_goto_trace when the option is
set: skip hidden steps and actual-parameter assignments, and keep only
assignments, declarations, function calls/returns and violated
assertions. On instrumentation-heavy programs this shrinks the JSON
trace by orders of magnitude because the values of internal
instrumentation steps dominate the output; on a Kani-generated
verification harness for Rust's write_bytes intrinsic, the trace
output shrinks from 427 MB to 3 MB while retaining all
counterexample-relevant assignments.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@tautschnig tautschnig self-assigned this Jul 28, 2026
Copilot AI review requested due to automatic review settings July 28, 2026 01:12

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 fixes a user-visible inconsistency in CBMC’s JSON trace output: --compact-trace was previously ignored when using --json-ui. It adds compact-trace filtering to the JSON trace converter so JSON consumers can request a reduced counterexample trace similar to the console compact trace.

Changes:

  • Apply --compact-trace filtering in json_goto_trace.h to skip hidden steps and drop most non-essential step kinds (notably internal instrumentation-dominated steps).
  • Add regression coverage that compares JSON trace output with and without --compact-trace, checking that actual-parameter assignments are removed in compact mode.
  • Introduce a small C program that reliably generates actual-parameter trace steps for the regression.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/goto-programs/json_goto_trace.h Adds compact-trace filtering logic before converting trace steps to JSON.
regression/cbmc/trace_options_json_compact/test.c Test program designed to produce parameter-passing steps in the full trace.
regression/cbmc/trace_options_json_compact/non-compact.desc Baseline test asserting the full JSON trace contains actual-parameter assignments.
regression/cbmc/trace_options_json_compact/compact.desc Test asserting compact JSON trace excludes actual-parameter assignments and hidden steps.

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

Comment on lines +123 to +141
// With --compact-trace, apply the same filtering as
// show_compact_goto_trace: skip hidden steps, actual-parameter
// assignments, and everything but assignments, declarations, function
// calls/returns and violated assertions. This in particular drops the
// values of internal instrumentation steps, which can shrink the trace
// by orders of magnitude on instrumentation-heavy programs.
if(trace_options.compact_trace)
{
if(step.hidden)
continue;

switch(step.type)
{
case goto_trace_stept::typet::ASSERT:
case goto_trace_stept::typet::DECL:
case goto_trace_stept::typet::FUNCTION_CALL:
case goto_trace_stept::typet::FUNCTION_RETURN:
break;

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.83%. Comparing base (f71fdad) to head (9ab5a5e).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #9135      +/-   ##
===========================================
- Coverage    80.83%   80.83%   -0.01%     
===========================================
  Files         1715     1715              
  Lines       189948   189958      +10     
  Branches        73       73              
===========================================
+ Hits        153540   153547       +7     
- Misses       36408    36411       +3     

☔ 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.

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.

2 participants