Skip to content

Include SSA lhs and rhs in extended JSON trace #4914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions regression/cbmc/trace_options_json_extended/extended.desc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ test.c
^EXIT=10$
^SIGNAL=0$
rawLhs
"ssaLhs": "main::argc!0@1#1",
"ssaRhs": "argc'#0",
--
5 changes: 5 additions & 0 deletions src/goto-programs/goto_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ class goto_trace_stept
bool cond_value;
exprt cond_expr;

// for assignments and declarations (ssa_lhs only)
exprt ssa_lhs, ssa_rhs;

// for assert
irep_idt property_id;
std::string comment;
Expand Down Expand Up @@ -161,6 +164,8 @@ class goto_trace_stept
full_lhs.make_nil();
full_lhs_value.make_nil();
cond_expr.make_nil();
ssa_lhs.make_nil();
ssa_rhs.make_nil();
}
};

Expand Down
15 changes: 15 additions & 0 deletions src/goto-programs/json_goto_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ Author: Daniel Kroening
#include "json_goto_trace.h"

#include <langapi/language_util.h>

#include <util/arith_tools.h>
#include <util/config.h>
#include <util/format_expr.h>
#include <util/invariant.h>
#include <util/simplify_expr.h>

Expand Down Expand Up @@ -154,6 +156,19 @@ void convert_decl(
step.assignment_type == goto_trace_stept::assignment_typet::ACTUAL_PARAMETER
? "actual-parameter"
: "variable");

if(trace_options.json_full_lhs)
{
std::ostringstream oss;
oss << format(step.ssa_lhs);
json_assignment["ssaLhs"] = json_stringt(oss.str());
}
if(trace_options.json_full_lhs && step.ssa_rhs.is_not_nil())
{
std::ostringstream oss;
oss << format(step.ssa_rhs);
json_assignment["ssaRhs"] = json_stringt(oss.str());
}
}

/// Convert an OUTPUT goto_trace step.
Expand Down
9 changes: 9 additions & 0 deletions src/goto-symex/build_goto_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,15 @@ void build_goto_trace(
goto_trace_step.cond_value =
decision_procedure.get(SSA_step.cond_handle).is_true();
}
else if(SSA_step.is_assignment())
{
goto_trace_step.ssa_lhs = SSA_step.ssa_lhs;
goto_trace_step.ssa_rhs = SSA_step.ssa_rhs;
}
else if(SSA_step.is_decl())
{
goto_trace_step.ssa_lhs = SSA_step.ssa_lhs;
}

if(ssa_step_it == last_step_to_keep)
return;
Expand Down