17
17
#include < ostream>
18
18
19
19
#include < util/arith_tools.h>
20
+ #include < util/config.h>
20
21
#include < util/symbol.h>
21
22
22
23
#include < ansi-c/printf_formatter.h>
@@ -61,22 +62,25 @@ void output_html_footer(std::ostream &out)
61
62
62
63
63
64
void show_html_state_header (
64
- std::ostream &out,
65
- const goto_trace_stept &state,
66
- const source_locationt &source_location,
67
- unsigned step_nr)
65
+ std::ostream &out,
66
+ const namespacet &ns,
67
+ const goto_trace_stept &state)
68
68
{
69
69
out << " \n <hr />\n " ;
70
70
out << " <p><strong><span style=\" color: Indigo;\" >" ;
71
71
72
- if (step_nr==0 )
72
+ if (state. step_nr ==0 )
73
73
out << " Initial State" ;
74
74
else
75
- out << " State " << step_nr << " </span>" ;
75
+ out << " State " << state. step_nr << " </span>" ;
76
76
77
- out << " " << source_location
77
+ out << " " << state. pc -> source_location
78
78
<< " thread " << state.thread_nr
79
79
<< " </strong>></p>\n " ;
80
+
81
+ if (config.trace_config .show_source_code )
82
+ out << " <p><span style=\" color: DarkGray;\" >Code:<em> "
83
+ << as_string (ns, *state.pc ) << " </em></span></p>\n " ;
80
84
}
81
85
82
86
@@ -88,7 +92,6 @@ void show_html_goto_trace(
88
92
unsigned prev_step_nr=0 ;
89
93
bool first_step=true ;
90
94
bool use_panel1=true ;
91
- bool use_hex=true ; // at some point this will become a cmd line argument
92
95
output_html_header (out);
93
96
94
97
for (const auto &step : goto_trace.steps )
@@ -110,8 +113,8 @@ void show_html_goto_trace(
110
113
out << " <p> " << step.comment << " </p>\n " ;
111
114
112
115
if (step.pc ->is_assert ())
113
- out << " <p> " << from_expr (ns, " " , step.pc ->guard ) << " \n " ;
114
- out<< " </p></div>\n " ;
116
+ out << " <p> " << from_expr (ns, " " , step.pc ->guard ) << ' \n ' ;
117
+ out << " </p></div>\n " ;
115
118
}
116
119
break ;
117
120
@@ -137,125 +140,120 @@ void show_html_goto_trace(
137
140
break ;
138
141
139
142
case goto_trace_stept::typet::ASSIGNMENT:
140
- if (step.pc ->is_assign () ||
141
- step.pc ->is_return () || // returns have a lhs!
142
- step.pc ->is_function_call () ||
143
- (step.pc ->is_other () && step.lhs_object .is_not_nil ()))
143
+ if (config.trace_config .show_value_assignments )
144
144
{
145
- if (prev_step_nr!=step.step_nr || first_step)
145
+ if (step.pc ->is_assign () || step.pc ->is_return ()
146
+ || // returns have a lhs!
147
+ step.pc ->is_function_call ()
148
+ || (step.pc ->is_other () && step.lhs_object .is_not_nil ()))
146
149
{
147
- first_step=false ;
148
- prev_step_nr=step.step_nr ;
149
- show_html_state_header (
150
- out, step, step.pc ->source_location , step.step_nr );
151
- out << " <p><span style=\" color: DarkGray;\" >Code:<em> "
152
- << as_string (ns, *step.pc ) << " </em></p>\n " ;
150
+ if (prev_step_nr != step.step_nr || first_step)
151
+ {
152
+ first_step = false ;
153
+ prev_step_nr = step.step_nr ;
154
+ show_html_state_header (out, ns, step);
155
+ }
156
+
157
+ trace_value (out, ns, step);
158
+ out << " </p>\n " ;
153
159
}
154
-
155
- // see if the full lhs is something clean
156
- if (is_index_member_symbol (step.full_lhs ))
157
- trace_value (
158
- out, ns, step.lhs_object , step.full_lhs ,
159
- step.full_lhs_value , use_hex);
160
- else
161
- trace_value (
162
- out, ns, step.lhs_object , step.lhs_object ,
163
- step.lhs_object_value , use_hex);
164
- out<<" </span></p>\n " ;
165
160
}
166
-
167
161
break ;
168
162
169
163
case goto_trace_stept::typet::DECL:
170
- if (prev_step_nr!=step. step_nr || first_step )
164
+ if (config. trace_config . show_value_assignments )
171
165
{
172
- first_step=false ;
173
- prev_step_nr=step.step_nr ;
174
- show_html_state_header (
175
- out, step, step.pc ->source_location , step.step_nr );
176
- out << " <p><span style=\" color: DarkGray;\" >Code:<em> "
177
- << as_string (ns, *step.pc ) << " </em></p>\n " ;
178
- }
166
+ if (prev_step_nr != step.step_nr || first_step)
167
+ {
168
+ first_step = false ;
169
+ prev_step_nr = step.step_nr ;
170
+ show_html_state_header (out, ns, step);
171
+ }
179
172
180
- trace_value (
181
- out, ns, step.lhs_object , step.full_lhs ,
182
- step.full_lhs_value , use_hex);
183
- out<<" </span></p>\n " ;
173
+ trace_value (out, ns, step);
174
+ out << " </span></p>\n " ;
175
+ }
184
176
break ;
185
177
186
178
case goto_trace_stept::typet::OUTPUT:
187
- if (step.formatted )
188
- {
189
- printf_formattert printf_formatter (ns);
190
- printf_formatter (id2string (step.format_string ), step.io_args );
191
- printf_formatter.print (out);
192
- }
193
- else
179
+ if (config.trace_config .show_outputs )
194
180
{
195
- show_html_state_header (
196
- out, step, step.pc ->source_location , step.step_nr );
197
- out << " <p><span style=\" color: DarkGray;\" >Code:<em> "
198
- << as_string (ns, *step.pc ) << " </em></p>\n " ;
199
-
200
- out << " <p> OUTPUT " << step.io_id << " :" ;
201
-
202
- for (std::list<exprt>::const_iterator
203
- l_it=step.io_args .begin ();
204
- l_it!=step.io_args .end ();
205
- l_it++)
181
+ if (step.formatted )
206
182
{
207
- if (l_it!=step.io_args .begin ())
208
- out << " ;" ;
209
- out << " " << from_expr (ns, " " , *l_it);
210
-
211
- // the hex representation
212
- out << " (" << trace_value_hex (*l_it, ns) << " )" ;
183
+ printf_formattert printf_formatter (ns);
184
+ printf_formatter (id2string (step.format_string ), step.io_args );
185
+ printf_formatter.print (out);
186
+ }
187
+ else
188
+ {
189
+ show_html_state_header (out, ns, step);
190
+ out << " <p> OUTPUT " << step.io_id << " :" ;
191
+
192
+ bool first_output = true ;
193
+ for (const auto &arg : step.io_args )
194
+ {
195
+ if (!first_output)
196
+ out << " ;" ;
197
+ out << " " << from_expr (ns, " " , arg);
198
+
199
+ if (config.trace_config .numeric_representation ==
200
+ configt::numeric_representationt::HEX)
201
+ out << " (" << trace_value_hex (arg, ns) << " )</p>\n " ;
202
+ else
203
+ out << " (" << trace_value_binary (arg, ns) << " )</p>\n " ;
204
+ first_output = false ;
205
+ }
213
206
}
214
207
}
215
- out<<" </span></p>\n " ;
216
208
break ;
217
209
218
210
case goto_trace_stept::typet::INPUT:
219
- show_html_state_header (out, step, step.pc ->source_location , step.step_nr );
220
- out << " <p><span style=\" color: DarkGray;\" >Code:<em> "
221
- << as_string (ns, *step.pc ) << " </em></p>\n " ;
222
- out << " <p> INPUT " << step.io_id << " :" ;
223
-
224
- for (std::list<exprt>::const_iterator
225
- l_it=step.io_args .begin ();
226
- l_it!=step.io_args .end ();
227
- l_it++)
211
+ if (!config.trace_config .show_inputs )
228
212
{
229
- if (l_it!=step.io_args .begin ())
230
- out << " ;" ;
231
- out << " " << from_expr (ns, " " , *l_it);
213
+ show_html_state_header (out, ns, step);
214
+ out << " <p> INPUT " << step.io_id << " :" ;
232
215
233
- // the binary representation
234
- out << " (" << trace_value_hex (*l_it, ns) << " )" ;
235
- }
216
+ bool first_input = true ;
217
+ for (const auto &arg : step.io_args )
218
+ {
219
+ if (!first_input)
220
+ out << " ;" ;
221
+ out << " " << from_expr (ns, " " , arg);
222
+
223
+ if (config.trace_config .numeric_representation ==
224
+ configt::numeric_representationt::HEX)
225
+ out << " (" << trace_value_hex (arg, ns) << " )" ;
226
+ else
227
+ out << " (" << trace_value_binary (arg, ns) << " )" ;
228
+ first_input = false ;
229
+ }
236
230
237
- out<<" </span></p>\n " ;
231
+ out << " </span></p>\n " ;
232
+ }
238
233
break ;
239
234
240
235
case goto_trace_stept::typet::FUNCTION_CALL:
241
- out << " \n " ;
242
- out << " <button class=\" function_call\" >" ;
243
- out << " <strong>FUNCTION CALL: </strong>" << as_string (ns, *step.pc );
244
- if (use_panel1)
236
+ if (config.trace_config .show_function_calls )
245
237
{
246
- out <<" </button>\n <div class=\" panel1\" >\n " ;
247
- use_panel1=false ;
248
- }
249
- else
250
- {
251
- out <<" </button>\n <div class=\" panel2\" >\n " ;
252
- use_panel1=true ;
238
+ out << ' \n ' ;
239
+ out << " <button class=\" function_call\" >" ;
240
+ out << " <strong>FUNCTION CALL: </strong>" << as_string (ns, *step.pc );
241
+ if (use_panel1)
242
+ {
243
+ out << " </button>\n <div class=\" panel1\" >\n " ;
244
+ use_panel1 = false ;
245
+ }
246
+ else
247
+ {
248
+ out << " </button>\n <div class=\" panel2\" >\n " ;
249
+ use_panel1 = true ;
250
+ }
253
251
}
254
-
255
252
break ;
256
253
257
254
case goto_trace_stept::typet::FUNCTION_RETURN:
258
- out<<" </div>\n " ;
255
+ if (config.trace_config .show_function_calls )
256
+ out << " </div>\n " ;
259
257
break ;
260
258
261
259
case goto_trace_stept::typet::SPAWN:
0 commit comments