@@ -24,6 +24,25 @@ Author: Daniel Kroening
2424
2525#include " printf_formatter.h"
2626
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+
2746void goto_tracet::output (
2847 const class namespacet &ns,
2948 std::ostream &out) const
@@ -217,15 +236,15 @@ std::string trace_numeric_value(
217236void trace_value (
218237 std::ostream &out,
219238 const namespacet &ns,
220- const ssa_exprt &lhs_object,
239+ const optionalt<symbol_exprt> &lhs_object,
221240 const exprt &full_lhs,
222241 const exprt &value,
223242 const trace_optionst &options)
224243{
225244 irep_idt identifier;
226245
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 ();
229248
230249 std::string value_string;
231250
@@ -346,7 +365,7 @@ void show_full_goto_trace(
346365 if (step.pc ->is_assign () ||
347366 step.pc ->is_return () || // returns have a lhs!
348367 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 ()))
350369 {
351370 if (prev_step_nr!=step.step_nr || first_step)
352371 {
@@ -356,23 +375,13 @@ void show_full_goto_trace(
356375 out, ns, step, step.pc ->source_location , step.step_nr , options);
357376 }
358377
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);
376385 }
377386 break ;
378387
@@ -386,7 +395,7 @@ void show_full_goto_trace(
386395 }
387396
388397 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);
390399 break ;
391400
392401 case goto_trace_stept::typet::OUTPUT:
0 commit comments