Skip to content

Commit 38fd003

Browse files
peterschrammelThomas Kiley
authored andcommitted
Do not suppress loop head locations in the trace
In the trace, we only output the first location of a sequence of same locations. However, we don't want to suppress loop head locations because they might come from different loop iterations. If we suppressed them it would be impossible to know in which loop iteration we are in.
1 parent 818afcc commit 38fd003

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/goto-programs/xml_goto_trace.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Author: Daniel Kroening
1818
#include <util/symbol.h>
1919
#include <util/xml_irep.h>
2020

21+
#include <algorithm>
2122
#include <langapi/language_util.h>
2223
#include <util/arith_tools.h>
2324

@@ -237,12 +238,23 @@ void convert(
237238
case goto_trace_stept::typet::GOTO:
238239
case goto_trace_stept::typet::ASSUME:
239240
case goto_trace_stept::typet::NONE:
240-
if(source_location!=previous_source_location)
241+
{
242+
// If this is just a source location then we output only the first
243+
// location of a sequence of same locations.
244+
// However, we don't want to suppress loop head locations because
245+
// they might come from different loop iterations. If we suppressed
246+
// them it would be impossible to know in which loop iteration
247+
// we are in.
248+
const bool is_loophead = std::any_of(
249+
step.pc->incoming_edges.begin(),
250+
step.pc->incoming_edges.end(),
251+
[](goto_programt::targett t) { return t->is_backwards_goto(); });
252+
if(source_location != previous_source_location || is_loophead)
241253
{
242-
// just the source location
243254
if(!xml_location.name.empty())
244255
{
245-
xmlt &xml_location_only=dest.new_element("location-only");
256+
xmlt &xml_location_only =
257+
dest.new_element(is_loophead ? "loop-head" : "location-only");
246258

247259
xml_location_only.set_attribute_bool("hidden", step.hidden);
248260
xml_location_only.set_attribute(
@@ -253,6 +265,8 @@ void convert(
253265
xml_location_only.new_element().swap(xml_location);
254266
}
255267
}
268+
break;
269+
}
256270
}
257271

258272
if(source_location.is_not_nil() && !source_location.get_file().empty())

0 commit comments

Comments
 (0)