-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5381 from thk123/trace-loop-heads
Add loop heads to the XML and JSON trace output
- Loading branch information
Showing
12 changed files
with
233 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
CORE | ||
test.c | ||
--unwind 6 test.c --trace --json-ui --partial-loops --slice-formula | ||
activate-multi-line-match | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
\s*\{\n\s* .*\n\s* "sourceLocation": \{\n\s* .*,\n\s* .*,\n\s* "line": "5",\n\s* .*\n\s* \},\n\s* "stepType": "loop-head",\n\s* .*\n\s*\},\n\s*\{\n\s* .*\n\s* "sourceLocation": \{\n\s* .*,\n\s* .*,\n\s* "line": "5",\n\s* .*\n\s* \},\n\s* "stepType": "loop-head",\n\s* .*\n\s*\}, | ||
-- | ||
-- | ||
Ensure even with sliced formulas, we get a location only step for | ||
each iteration of the loop (called loop-heads) when using partial loops. | ||
|
||
This test is checking the following json:(deleting the new lines after each \n to obtain | ||
monster regex above). | ||
|
||
\s*\{\n | ||
\s* .*\n | ||
\s* "sourceLocation": \{\n | ||
\s* .*,\n | ||
\s* .*,\n | ||
\s* "line": "5",\n | ||
\s* .*\n | ||
\s* \},\n | ||
\s* "stepType": "loop-head",\n | ||
\s* .*\n | ||
\s*\},\n | ||
\s*\{\n | ||
\s* .*\n | ||
\s* "sourceLocation": \{\n | ||
\s* .*,\n | ||
\s* .*,\n | ||
\s* "line": "5",\n | ||
\s* .*\n | ||
\s* \},\n | ||
\s* "stepType": "loop-head",\n | ||
\s* .*\n | ||
\s*\}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
CORE | ||
test.c | ||
--unwind 6 test.c --trace --xml-ui --partial-loops --slice-formula | ||
activate-multi-line-match | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
\s*<loop-head .*>\n\s* <location .* line="5" .*/>\n\s*</loop-head>\n\s*<loop-head .*>\n\s* <location .* line="5".*/>\n\s*</loop-head>\n | ||
-- | ||
-- | ||
Ensure even with sliced formulas, we get a location only step for | ||
each iteration of the loop (called loop-heads) when using partial loops. | ||
|
||
This test is checking the following XML:(deleting the new lines | ||
after each \n to obtain the monster regex above). | ||
|
||
\s*<loop-head .*> | ||
\s* <location .* line="5" .*/> | ||
\s*</loop-head> | ||
\s*<loop-head .*> | ||
\s* <location .* line="5".*/> | ||
\s*</loop-head> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
void main(void) | ||
{ | ||
int i = 0; | ||
|
||
while(1) | ||
{ | ||
i = 1; | ||
} | ||
|
||
// invalid assertion | ||
assert(i == 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*******************************************************************\ | ||
Author: Diffblue | ||
\*******************************************************************/ | ||
|
||
/// \file | ||
/// Utilities for printing location info steps in the trace in a format | ||
/// agnostic way | ||
|
||
#include "structured_trace_util.h" | ||
#include <algorithm> | ||
|
||
default_step_kindt | ||
default_step_kind(const goto_programt::instructiont &instruction) | ||
{ | ||
const bool is_loophead = std::any_of( | ||
instruction.incoming_edges.begin(), | ||
instruction.incoming_edges.end(), | ||
[](goto_programt::targett t) { return t->is_backwards_goto(); }); | ||
|
||
return is_loophead ? default_step_kindt::LOOP_HEAD | ||
: default_step_kindt::LOCATION_ONLY; | ||
} | ||
std::string default_step_name(const default_step_kindt &step_type) | ||
{ | ||
switch(step_type) | ||
{ | ||
case default_step_kindt::LOCATION_ONLY: | ||
return "location-only"; | ||
case default_step_kindt::LOOP_HEAD: | ||
return "loop-head"; | ||
} | ||
UNREACHABLE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/*******************************************************************\ | ||
Author: Diffblue | ||
\*******************************************************************/ | ||
|
||
/// \file | ||
/// Utilities for printing location info steps in the trace in a format | ||
/// agnostic way | ||
|
||
#ifndef CPROVER_GOTO_PROGRAMS_STRUCTURED_TRACE_UTIL_H | ||
#define CPROVER_GOTO_PROGRAMS_STRUCTURED_TRACE_UTIL_H | ||
|
||
#include "goto_program.h" | ||
#include <string> | ||
|
||
/// There are two kinds of step for location markers - location-only and | ||
/// loop-head (for locations associated with the first step of a loop). | ||
enum class default_step_kindt | ||
{ | ||
LOCATION_ONLY, | ||
LOOP_HEAD | ||
}; | ||
|
||
/// Identify for a given instruction whether it is a loophead or just a location | ||
/// | ||
/// Loopheads are determined by whether there is backwards jump to them. This | ||
/// matches the loop detection used for loop IDs | ||
/// \param instruction: The instruction to inspect. | ||
/// \return LOOP_HEAD if this is a loop head, otherwise LOCATION_ONLY | ||
default_step_kindt | ||
default_step_kind(const goto_programt::instructiont &instruction); | ||
|
||
/// Turns a \ref default_step_kindt into a string that can be used in the trace | ||
/// \param step_type: The kind of step, deduced from \ref default_step_kind | ||
/// \return Either "loop-head" or "location-only" | ||
std::string default_step_name(const default_step_kindt &step_type); | ||
|
||
#endif // CPROVER_GOTO_PROGRAMS_STRUCTURED_TRACE_UTIL_H |
Oops, something went wrong.