Skip to content

Include source location in JSON/XML property output #6696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/assets/xml_spec.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<xs:complexType>
<xs:attribute name="file" type="xs:string" use="optional"/>
<xs:attribute name="line" type="xs:int" use="optional"/>
<xs:attribute name="column" type="xs:int" use="optional"/>
<xs:attribute name="working-directory" type="xs:string"
use="optional"/>
<xs:attribute name="function" type="xs:string" use="optional"/>
Expand Down Expand Up @@ -164,6 +165,7 @@
<xs:element name="result">
<xs:complexType>
<xs:sequence>
<xs:element ref="location" minOccurs="0"/>
<xs:element ref="goto_trace" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="property" type="xs:string"/>
Expand Down
4 changes: 2 additions & 2 deletions regression/cbmc/json-interface1/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ activate-multi-line-match
^EXIT=10$
^SIGNAL=0$
Not unwinding loop foo\.0 iteration 3 file main\.c line 5 function foo thread 0
\{\n\s*"description": "assertion 0",\n\s*"property": "foo\.assertion\.(1|3)",\n\s*"status": "SUCCESS"\n\s*\}
\{\n\s*"description": "assertion 0",\n\s*"property": "foo\.assertion\.(1|3)",\n\s*"status": "FAILURE",\n\s*"trace": \[
\{\n\s*"description": "assertion 0",\n\s*"property": "foo\.assertion\.(1|3)",\n\s*"sourceLocation": \{\n\s*"file": "main.c",\n\s*"function": "foo",\n\s*"line": "(8|11)",\n\s*"workingDirectory": ".*json-interface1"\n\s*\},\n\s*"status": "SUCCESS"\n\s*\}
\{\n\s*"description": "assertion 0",\n\s*"property": "foo\.assertion\.(1|3)",\n\s*"sourceLocation": \{\n\s*"file": "main.c",\n\s*"function": "foo",\n\s*"line": "(8|11)",\n\s*"workingDirectory": ".*json-interface1"\n\s*\},\n\s*"status": "FAILURE",\n\s*"trace": \[
VERIFICATION FAILED
--
"property": "foo\.assertion\.2"
2 changes: 1 addition & 1 deletion regression/cbmc/xml-interface1/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CORE
^EXIT=10$
^SIGNAL=0$
Not unwinding loop foo\.0 iteration 3 file main\.c line 5 function foo thread 0
<result property="foo\.assertion\.3" status="SUCCESS"/>
<result property="foo\.assertion\.3" status="SUCCESS">
<result property="foo\.assertion\.1" status="FAILURE">
<goto_trace>
VERIFICATION FAILED
Expand Down
4 changes: 4 additions & 0 deletions src/goto-checker/properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ Author: Daniel Kroening, Peter Schrammel
#include <util/exit_codes.h>
#include <util/invariant.h>
#include <util/json.h>
#include <util/json_irep.h>
#include <util/json_stream.h>
#include <util/xml.h>
#include <util/xml_irep.h>

#include <goto-programs/abstract_goto_model.h>

Expand Down Expand Up @@ -110,6 +112,7 @@ xmlt xml(const irep_idt &property_id, const property_infot &property_info)
xmlt xml_result("result");
xml_result.set_attribute("property", id2string(property_id));
xml_result.set_attribute("status", as_string(property_info.status));
xml_result.new_element(xml(property_info.pc->source_location()));
return xml_result;
}

Expand All @@ -122,6 +125,7 @@ static void json(
result["property"] = json_stringt(property_id);
result["description"] = json_stringt(property_info.description);
result["status"] = json_stringt(as_string(property_info.status));
result["sourceLocation"] = json(property_info.pc->source_location());
}

json_objectt
Expand Down