@@ -24,6 +24,25 @@ Author: Daniel Kroening
24
24
25
25
#include " printf_formatter.h"
26
26
27
+ static optionalt<symbol_exprt> get_object_rec (const exprt &src)
28
+ {
29
+ if (src.id ()==ID_symbol)
30
+ return to_symbol_expr (src);
31
+ else if (src.id ()==ID_member)
32
+ return get_object_rec (to_member_expr (src).struct_op ());
33
+ else if (src.id ()==ID_index)
34
+ return get_object_rec (to_index_expr (src).array ());
35
+ else if (src.id ()==ID_typecast)
36
+ return get_object_rec (to_typecast_expr (src).op ());
37
+ else
38
+ return {}; // give up
39
+ }
40
+
41
+ optionalt<symbol_exprt> goto_trace_stept::get_lhs_object () const
42
+ {
43
+ return get_object_rec (full_lhs);
44
+ }
45
+
27
46
void goto_tracet::output (
28
47
const class namespacet &ns,
29
48
std::ostream &out) const
@@ -217,15 +236,15 @@ std::string trace_numeric_value(
217
236
void trace_value (
218
237
std::ostream &out,
219
238
const namespacet &ns,
220
- const ssa_exprt &lhs_object,
239
+ const optionalt<symbol_exprt> &lhs_object,
221
240
const exprt &full_lhs,
222
241
const exprt &value,
223
242
const trace_optionst &options)
224
243
{
225
244
irep_idt identifier;
226
245
227
- if (lhs_object.is_not_nil ())
228
- identifier=lhs_object. get_object_name ();
246
+ if (lhs_object.has_value ())
247
+ identifier=lhs_object-> get_identifier ();
229
248
230
249
std::string value_string;
231
250
@@ -346,7 +365,7 @@ void show_full_goto_trace(
346
365
if (step.pc ->is_assign () ||
347
366
step.pc ->is_return () || // returns have a lhs!
348
367
step.pc ->is_function_call () ||
349
- (step.pc ->is_other () && step.lhs_object .is_not_nil ()))
368
+ (step.pc ->is_other () && step.full_lhs .is_not_nil ()))
350
369
{
351
370
if (prev_step_nr!=step.step_nr || first_step)
352
371
{
@@ -356,23 +375,13 @@ void show_full_goto_trace(
356
375
out, ns, step, step.pc ->source_location , step.step_nr , options);
357
376
}
358
377
359
- // see if the full lhs is something clean
360
- if (is_index_member_symbol (step.full_lhs ))
361
- trace_value (
362
- out,
363
- ns,
364
- step.lhs_object ,
365
- step.full_lhs ,
366
- step.full_lhs_value ,
367
- options);
368
- else
369
- trace_value (
370
- out,
371
- ns,
372
- step.lhs_object ,
373
- step.lhs_object ,
374
- step.lhs_object_value ,
375
- options);
378
+ trace_value (
379
+ out,
380
+ ns,
381
+ step.get_lhs_object (),
382
+ step.full_lhs ,
383
+ step.full_lhs_value ,
384
+ options);
376
385
}
377
386
break ;
378
387
@@ -386,7 +395,7 @@ void show_full_goto_trace(
386
395
}
387
396
388
397
trace_value (
389
- out, ns, step.lhs_object , step.full_lhs , step.full_lhs_value , options);
398
+ out, ns, step.get_lhs_object () , step.full_lhs , step.full_lhs_value , options);
390
399
break ;
391
400
392
401
case goto_trace_stept::typet::OUTPUT:
0 commit comments