File tree Expand file tree Collapse file tree 10 files changed +86
-2
lines changed Expand file tree Collapse file tree 10 files changed +86
-2
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,9 @@ jsont ai_baset::output_json(
169169 location[" sourceLocation" ]=
170170 json_stringt (i_it->source_location .as_string ());
171171 location[" abstractState" ]=find_state (i_it).output_json (*this , ns);
172+ auto original_location = i_it->source_location .get_goto_location ();
173+ if (original_location!=" " )
174+ location[" originalGOTOLocation" ]=json_stringt (id2string (original_location));
172175
173176 // Ideally we need output_instruction_json
174177 std::ostringstream out;
@@ -228,6 +231,11 @@ xmlt ai_baset::output_xml(
228231 location.set_attribute (
229232 " source_location" ,
230233 i_it->source_location .as_string ());
234+ auto original_location = i_it->source_location .get_goto_location ();
235+ if (original_location!=" " )
236+ location.set_attribute (
237+ " originalGOTOLocation" ,
238+ id2string (original_location));
231239
232240 location.new_element (find_state (i_it).output_xml (*this , ns));
233241
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ SRC = accelerate/accelerate.cpp \
5151 undefined_functions.cpp \
5252 uninitialized.cpp \
5353 unwind.cpp \
54+ store_goto_location.cpp \
5455 wmm/abstract_event.cpp \
5556 wmm/cycle_collection.cpp \
5657 wmm/data_dp.cpp \
Original file line number Diff line number Diff line change 9595#include " model_argc_argv.h"
9696#include " undefined_functions.h"
9797#include " remove_function.h"
98+ #include " store_goto_location.h"
99+
98100void goto_instrument_parse_optionst::eval_verbosity ()
99101{
100102 unsigned int v=8 ;
@@ -432,6 +434,15 @@ int goto_instrument_parse_optionst::doit()
432434 return 0 ;
433435 }
434436
437+ if (cmdline.isset (" store-goto-locations" ))
438+ {
439+ Forall_goto_functions (it, goto_functions)
440+ {
441+ auto &function_body = it->second .body ;
442+ store_goto_locations (function_body);
443+ }
444+ }
445+
435446 if (cmdline.isset (" check-call-sequence" ))
436447 {
437448 do_remove_returns ();
Original file line number Diff line number Diff line change 7878 " (show-threaded)(list-calls-args)(print-path-lengths)" \
7979 " (undefined-function-is-assume-false)" \
8080 " (remove-function-body):" \
81+ " (store-goto-locations)" \
8182 " (remove-calls-nobody)"
8283
8384class goto_instrument_parse_optionst :
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ void show_locations(
4545 l.new_element (" file" ).data =id2string (source_location.get_file ());
4646 l.new_element (" function" ).data =
4747 id2string (source_location.get_function ());
48+ l.new_element (" original_goto_location" ).data =
49+ id2string (source_location.get_goto_location ());
4850
4951 std::cout << xml << ' \n ' ;
5052 }
@@ -53,7 +55,9 @@ void show_locations(
5355 case ui_message_handlert::uit::PLAIN:
5456 std::cout << function_id << " "
5557 << it->location_number << " "
56- << it->source_location << ' \n ' ;
58+ << it->source_location << " "
59+ << " (Original GOTO Location:" << " "
60+ << it->source_location .get_goto_location () << " ) \n " ;
5761 break ;
5862
5963 default :
Original file line number Diff line number Diff line change 1+ #include " store_goto_location.h"
2+
3+ #include < goto-programs/goto_program.h>
4+ #include < util/source_location.h>
5+
6+ void store_goto_locations (goto_programt &goto_program)
7+ {
8+ for (auto it=goto_program.instructions .begin ();
9+ it!=goto_program.instructions .end ();
10+ it++)
11+ {
12+ auto &source_location = it->source_location ;
13+ auto location_number = it->location_number ;
14+
15+ source_location.set_goto_location (location_number);
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ /*******************************************************************\
2+
3+ Module: Store the location of instructions in the GOTO binary
4+
5+ Author: Diffblue Limited (c) 2017
6+
7+ Date: August 2017
8+
9+ \*******************************************************************/
10+
11+ #ifndef STORE_GOTO_LOCATION_H
12+ #define STORE_GOTO_LOCATION_H
13+
14+
15+ #include <goto-programs/goto_program.h>
16+
17+ void store_goto_locations (goto_programt & goto_program );
18+
19+ #endif // STORE_GOTO_LOCATION_H
Original file line number Diff line number Diff line change @@ -48,7 +48,16 @@ std::ostream &goto_programt::output_instruction(
4848 std::ostream &out,
4949 const goto_program_templatet::instructiont &instruction) const
5050{
51- out << " // " << instruction.location_number << " " ;
51+ auto original_location=instruction.source_location .get_goto_location ();
52+ if (original_location!=" " )
53+ {
54+ out << " // " << instruction.location_number << " "
55+ << " (Original GOTO location: " << original_location << " ) " ;
56+ }
57+ else
58+ {
59+ out << " // " << instruction.location_number << " " ;
60+ }
5261
5362 if (!instruction.source_location .is_nil ())
5463 out << instruction.source_location .as_string ();
Original file line number Diff line number Diff line change @@ -67,6 +67,10 @@ json_objectt show_goto_functions_jsont::convert(
6767 {
6868 instruction_entry[" sourceLocation" ]=
6969 json (instruction.code .source_location ());
70+
71+ if (instruction.code .source_location ().get_goto_location ()!=" " )
72+ instruction_entry[" originalGOTOLocation" ]=
73+ json_stringt (id2string (instruction.code .source_location ().get_goto_location ()));
7074 }
7175
7276 std::ostringstream instruction_builder;
Original file line number Diff line number Diff line change @@ -140,6 +140,16 @@ class source_locationt:public irept
140140 return get_bool (ID_hide);
141141 }
142142
143+ void set_goto_location (unsigned location)
144+ {
145+ set (" GOTO_location" , location);
146+ }
147+
148+ const irep_idt get_goto_location () const
149+ {
150+ return get (" GOTO_location" );
151+ }
152+
143153 static bool is_built_in (const std::string &s)
144154 {
145155 std::string built_in1=" <built-in-" ; // "<built-in-additions>";
You can’t perform that action at this time.
0 commit comments