cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
json_goto_trace.h
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Traces of GOTO Programs
4
5
Author: Daniel Kroening
6
7
Date: November 2005
8
9
\*******************************************************************/
10
13
14
#ifndef CPROVER_GOTO_PROGRAMS_JSON_GOTO_TRACE_H
15
#define CPROVER_GOTO_PROGRAMS_JSON_GOTO_TRACE_H
16
17
#include "
goto_trace.h
"
18
#include "
structured_trace_util.h
"
19
20
#include <
util/json.h
>
21
#include <
util/json_irep.h
>
22
26
typedef
struct
27
{
28
const
jsont
&
location
;
29
const
goto_trace_stept
&
step
;
30
const
namespacet
&
ns
;
31
}
conversion_dependenciest
;
32
40
void
convert_assert
(
41
json_objectt
&json_failure,
42
const
conversion_dependenciest
&conversion_dependencies);
43
53
void
convert_decl
(
54
json_objectt
&json_assignment,
55
const
conversion_dependenciest
&conversion_dependencies,
56
const
trace_optionst
&trace_options);
57
65
void
convert_output
(
66
json_objectt
&json_output,
67
const
conversion_dependenciest
&conversion_dependencies);
68
76
void
convert_input
(
77
json_objectt
&json_input,
78
const
conversion_dependenciest
&conversion_dependencies);
79
87
void
convert_return
(
88
json_objectt
&json_call_return,
89
const
conversion_dependenciest
&conversion_dependencies);
90
98
void
convert_default
(
99
json_objectt
&json_location_only,
100
const
default_trace_stept
&
default_step
);
101
112
template
<
typename
json_arrayT>
113
void
convert
(
114
const
namespacet
&ns,
115
const
goto_tracet
&goto_trace,
116
json_arrayT &dest_array,
117
trace_optionst
trace_options =
trace_optionst::default_options
)
118
{
119
source_locationt
previous_source_location;
120
121
for
(
const
auto
&step : goto_trace.
steps
)
122
{
123
const
source_locationt
&source_location = step.pc->source_location();
124
125
jsont
json_location;
126
127
source_location.
is_not_nil
() && !source_location.
get_file
().
empty
()
128
? json_location =
json
(source_location)
129
: json_location =
json_nullt
();
130
131
// NOLINTNEXTLINE(whitespace/braces)
132
conversion_dependenciest
conversion_dependencies = {
133
json_location, step, ns};
134
135
switch
(step.type)
136
{
137
case
goto_trace_stept::typet::ASSERT
:
138
if
(!step.cond_value)
139
{
140
json_objectt
&json_failure = dest_array.push_back().
make_object
();
141
convert_assert
(json_failure, conversion_dependencies);
142
}
143
break
;
144
145
case
goto_trace_stept::typet::ASSIGNMENT
:
146
case
goto_trace_stept::typet::DECL
:
147
{
148
json_objectt
&json_assignment = dest_array.push_back().
make_object
();
149
convert_decl
(json_assignment, conversion_dependencies, trace_options);
150
}
151
break
;
152
153
case
goto_trace_stept::typet::OUTPUT
:
154
{
155
json_objectt
&json_output = dest_array.push_back().
make_object
();
156
convert_output
(json_output, conversion_dependencies);
157
}
158
break
;
159
160
case
goto_trace_stept::typet::INPUT
:
161
{
162
json_objectt
&json_input = dest_array.push_back().
make_object
();
163
convert_input
(json_input, conversion_dependencies);
164
}
165
break
;
166
167
case
goto_trace_stept::typet::FUNCTION_CALL
:
168
case
goto_trace_stept::typet::FUNCTION_RETURN
:
169
{
170
json_objectt
&json_call_return = dest_array.push_back().
make_object
();
171
convert_return
(json_call_return, conversion_dependencies);
172
}
173
break
;
174
175
case
goto_trace_stept::typet::ATOMIC_BEGIN
:
176
case
goto_trace_stept::typet::ATOMIC_END
:
177
case
goto_trace_stept::typet::DEAD
:
178
case
goto_trace_stept::typet::LOCATION
:
179
case
goto_trace_stept::typet::GOTO
:
180
case
goto_trace_stept::typet::ASSUME
:
181
case
goto_trace_stept::typet::MEMORY_BARRIER
:
182
case
goto_trace_stept::typet::SPAWN
:
183
case
goto_trace_stept::typet::SHARED_READ
:
184
case
goto_trace_stept::typet::SHARED_WRITE
:
185
case
goto_trace_stept::typet::CONSTRAINT
:
186
case
goto_trace_stept::typet::NONE
:
187
const
auto
default_step
=
::default_step
(step, previous_source_location);
188
if
(
default_step
)
189
{
190
json_objectt
&json_location_only = dest_array.push_back().
make_object
();
191
convert_default
(json_location_only, *
default_step
);
192
}
193
break
;
194
}
195
196
if
(source_location.
is_not_nil
() && !source_location.
get_file
().
empty
())
197
previous_source_location = source_location;
198
}
199
}
200
201
#endif
// CPROVER_GOTO_PROGRAMS_JSON_GOTO_TRACE_H
dstringt::empty
bool empty() const
Definition
dstring.h:89
goto_trace_stept
Step of the trace of a GOTO program.
Definition
goto_trace.h:50
goto_trace_stept::typet::SPAWN
@ SPAWN
Definition
goto_trace.h:91
goto_trace_stept::typet::ASSERT
@ ASSERT
Definition
goto_trace.h:79
goto_trace_stept::typet::ATOMIC_END
@ ATOMIC_END
Definition
goto_trace.h:94
goto_trace_stept::typet::GOTO
@ GOTO
Definition
goto_trace.h:80
goto_trace_stept::typet::OUTPUT
@ OUTPUT
Definition
goto_trace.h:83
goto_trace_stept::typet::MEMORY_BARRIER
@ MEMORY_BARRIER
Definition
goto_trace.h:92
goto_trace_stept::typet::SHARED_WRITE
@ SHARED_WRITE
Definition
goto_trace.h:90
goto_trace_stept::typet::SHARED_READ
@ SHARED_READ
Definition
goto_trace.h:89
goto_trace_stept::typet::LOCATION
@ LOCATION
Definition
goto_trace.h:81
goto_trace_stept::typet::DECL
@ DECL
Definition
goto_trace.h:84
goto_trace_stept::typet::ASSIGNMENT
@ ASSIGNMENT
Definition
goto_trace.h:77
goto_trace_stept::typet::INPUT
@ INPUT
Definition
goto_trace.h:82
goto_trace_stept::typet::NONE
@ NONE
Definition
goto_trace.h:76
goto_trace_stept::typet::DEAD
@ DEAD
Definition
goto_trace.h:85
goto_trace_stept::typet::FUNCTION_RETURN
@ FUNCTION_RETURN
Definition
goto_trace.h:87
goto_trace_stept::typet::ASSUME
@ ASSUME
Definition
goto_trace.h:78
goto_trace_stept::typet::CONSTRAINT
@ CONSTRAINT
Definition
goto_trace.h:88
goto_trace_stept::typet::ATOMIC_BEGIN
@ ATOMIC_BEGIN
Definition
goto_trace.h:93
goto_trace_stept::typet::FUNCTION_CALL
@ FUNCTION_CALL
Definition
goto_trace.h:86
goto_tracet
Trace of a GOTO program.
Definition
goto_trace.h:177
goto_tracet::steps
stepst steps
Definition
goto_trace.h:180
irept::is_not_nil
bool is_not_nil() const
Definition
irep.h:372
json_nullt
Definition
json.h:413
json_objectt
Definition
json.h:298
jsont
Definition
json.h:27
jsont::make_object
json_objectt & make_object()
Definition
json.h:436
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition
namespace.h:91
source_locationt
Definition
source_location.h:20
source_locationt::get_file
const irep_idt & get_file() const
Definition
source_location.h:36
goto_trace.h
Traces of GOTO Programs.
json.h
convert_assert
void convert_assert(json_objectt &json_failure, const conversion_dependenciest &conversion_dependencies)
Convert an ASSERT goto_trace step.
Definition
json_goto_trace.cpp:33
convert_output
void convert_output(json_objectt &json_output, const conversion_dependenciest &conversion_dependencies)
Convert an OUTPUT goto_trace step.
Definition
json_goto_trace.cpp:167
convert
void convert(const namespacet &ns, const goto_tracet &goto_trace, json_arrayT &dest_array, trace_optionst trace_options=trace_optionst::default_options)
Templated version of the conversion method.
Definition
json_goto_trace.h:113
convert_input
void convert_input(json_objectt &json_input, const conversion_dependenciest &conversion_dependencies)
Convert an INPUT goto_trace step.
Definition
json_goto_trace.cpp:209
convert_decl
void convert_decl(json_objectt &json_assignment, const conversion_dependenciest &conversion_dependencies, const trace_optionst &trace_options)
Convert a DECL goto_trace step.
Definition
json_goto_trace.cpp:60
convert_return
void convert_return(json_objectt &json_call_return, const conversion_dependenciest &conversion_dependencies)
Convert a FUNCTION_RETURN goto_trace step.
Definition
json_goto_trace.cpp:251
convert_default
void convert_default(json_objectt &json_location_only, const default_trace_stept &default_step)
Convert all other types of steps not already handled by the other conversion functions.
Definition
json_goto_trace.cpp:280
json_irep.h
Util.
json
static void json(json_objectT &result, const irep_idt &property_id, const property_infot &property_info)
Definition
properties.cpp:120
conversion_dependenciest
This is structure is here to facilitate passing arguments to the conversion functions.
Definition
json_goto_trace.h:27
conversion_dependenciest::step
const goto_trace_stept & step
Definition
json_goto_trace.h:29
conversion_dependenciest::ns
const namespacet & ns
Definition
json_goto_trace.h:30
conversion_dependenciest::location
const jsont & location
Definition
json_goto_trace.h:28
default_trace_stept
Definition
structured_trace_util.h:41
trace_optionst
Options for printing the trace using show_goto_trace.
Definition
goto_trace.h:221
trace_optionst::default_options
static const trace_optionst default_options
Definition
goto_trace.h:238
default_step
std::optional< default_trace_stept > default_step(const goto_trace_stept &step, const source_locationt &previous_source_location)
Definition
structured_trace_util.cpp:39
structured_trace_util.h
Utilities for printing location info steps in the trace in a format agnostic way.
goto-programs
json_goto_trace.h
Generated by
1.17.0