Skip to content

Commit d66ccf8

Browse files
Merge pull request #4075 from romainbrenguier/doc/symex_trace
Clean-up and document goto_trace.h/cpp [DOC-136]
2 parents 7d71afd + b88944d commit d66ccf8

File tree

2 files changed

+45
-48
lines changed

2 files changed

+45
-48
lines changed

src/goto-programs/goto_trace.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ std::string trace_numeric_value(
253253
return "?";
254254
}
255255

256-
void trace_value(
256+
static void trace_value(
257257
messaget::mstreamt &out,
258258
const namespacet &ns,
259259
const optionalt<symbol_exprt> &lhs_object,
@@ -768,14 +768,6 @@ void show_goto_trace(
768768
show_full_goto_trace(out, ns, goto_trace, options);
769769
}
770770

771-
void show_goto_trace(
772-
messaget::mstreamt &out,
773-
const namespacet &ns,
774-
const goto_tracet &goto_trace)
775-
{
776-
show_goto_trace(out, ns, goto_trace, trace_optionst::default_options);
777-
}
778-
779771
const trace_optionst trace_optionst::default_options = trace_optionst();
780772

781773
std::vector<irep_idt> goto_tracet::get_all_property_ids() const

src/goto-programs/goto_trace.h

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,32 @@ Date: July 2005
2424

2525
#include <goto-programs/goto_program.h>
2626

27-
/*! \brief TO_BE_DOCUMENTED
28-
* \ingroup gr_goto_symex
29-
*/
27+
/// Step of the trace of a GOTO program
28+
///
29+
/// A step is either:
30+
/// - an assignment
31+
/// - an assume statement
32+
/// - an assertion
33+
/// - a goto instruction
34+
/// - a constraint (unused)
35+
/// - a function call
36+
/// - a function return
37+
/// - a location (unused)
38+
/// - an output
39+
/// - an input
40+
/// - a declaration
41+
/// - a dead statement
42+
/// - a shared read (unused)
43+
/// - a shared write (unused)
44+
/// - a spawn statement
45+
/// - a memory barrier
46+
/// - an atomic begin (unused)
47+
/// - an atomic end (unused)
48+
/// \ingroup gr_goto_symex
3049
class goto_trace_stept
3150
{
3251
public:
52+
/// Number of the step in the trace
3353
std::size_t step_nr;
3454

3555
bool is_assignment() const { return type==typet::ASSIGNMENT; }
@@ -123,8 +143,7 @@ class goto_trace_stept
123143
// for function call
124144
std::vector<exprt> function_arguments;
125145

126-
/*! \brief outputs the trace step in ASCII to a given stream
127-
*/
146+
/// Outputs the trace step in ASCII to a given stream
128147
void output(
129148
const class namespacet &ns,
130149
std::ostream &out) const;
@@ -145,66 +164,64 @@ class goto_trace_stept
145164
}
146165
};
147166

148-
/*! \brief TO_BE_DOCUMENTED
149-
* \ingroup gr_goto_symex
150-
*/
167+
/// Trace of a GOTO program.
168+
/// This is a wrapper for a list of steps.
169+
/// \ingroup gr_goto_symex
151170
class goto_tracet
152171
{
153172
public:
154173
typedef std::list<goto_trace_stept> stepst;
155174
stepst steps;
156175

157-
irep_idt mode;
158-
159176
void clear()
160177
{
161-
mode.clear();
162178
steps.clear();
163179
}
164180

165-
/*! \brief outputs the trace in ASCII to a given stream
166-
*/
181+
/// Outputs the trace in ASCII to a given stream
167182
void output(
168183
const class namespacet &ns,
169184
std::ostream &out) const;
170185

171186
void swap(goto_tracet &other)
172187
{
173188
other.steps.swap(steps);
174-
other.mode.swap(mode);
175189
}
176190

191+
/// Add a step at the end of the trace
177192
void add_step(const goto_trace_stept &step)
178193
{
179194
steps.push_back(step);
180195
}
181196

182-
// retrieves the final step in the trace for manipulation
183-
// (used to fill a trace from code, hence non-const)
197+
/// Retrieves the final step in the trace for manipulation
198+
/// (used to fill a trace from code, hence non-const)
184199
goto_trace_stept &get_last_step()
185200
{
186201
return steps.back();
187202
}
188203

189204
/// Returns the property IDs of all assertions in the trace
190205
std::vector<irep_idt> get_all_property_ids() const;
191-
192-
// delete all steps after (not including) s
193-
void trim_after(stepst::iterator s)
194-
{
195-
PRECONDITION(s != steps.end());
196-
steps.erase(++s, steps.end());
197-
}
198206
};
199207

208+
/// Options for printing the trace using show_goto_trace
200209
struct trace_optionst
201210
{
211+
/// Add rawLhs property to trace
202212
bool json_full_lhs;
213+
/// Represent plain trace values in hex
203214
bool hex_representation;
215+
/// Use prefix (`0b` or `0x`) for distinguishing the base of the
216+
/// representation.
204217
bool base_prefix;
218+
/// Show function calls in plain text trace
205219
bool show_function_calls;
220+
/// Show original code in plain text trace
206221
bool show_code;
222+
/// Give a compact trace
207223
bool compact_trace;
224+
/// Give a stack trace only
208225
bool stack_trace;
209226

210227
static const trace_optionst default_options;
@@ -233,24 +250,12 @@ struct trace_optionst
233250
};
234251
};
235252

253+
/// Output the trace on the given stream \p out
236254
void show_goto_trace(
237255
messaget::mstreamt &out,
238-
const namespacet &,
239-
const goto_tracet &);
240-
241-
void show_goto_trace(
242-
messaget::mstreamt &out,
243-
const namespacet &,
244-
const goto_tracet &,
245-
const trace_optionst &);
246-
247-
void trace_value(
248-
messaget::mstreamt &out,
249-
const namespacet &,
250-
const optionalt<symbol_exprt> &lhs_object,
251-
const exprt &full_lhs,
252-
const exprt &value,
253-
const trace_optionst &);
256+
const namespacet &ns,
257+
const goto_tracet &goto_trace,
258+
const trace_optionst &trace_options = trace_optionst::default_options);
254259

255260
#define OPT_GOTO_TRACE \
256261
"(trace-json-extended)" \

0 commit comments

Comments
 (0)