File tree Expand file tree Collapse file tree 13 files changed +97
-1
lines changed
regression/goto-instrument/store_goto_locations Expand file tree Collapse file tree 13 files changed +97
-1
lines changed Original file line number Diff line number Diff line change
1
+ int main (int argc , char * * argv )
2
+ {
3
+ return 0 ;
4
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --show-goto-functions --store-goto-locations
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ Original GOTO location
7
+ --
8
+ --
Original file line number Diff line number Diff line change @@ -169,6 +169,9 @@ jsont ai_baset::output_json(
169
169
location[" sourceLocation" ]=
170
170
json_stringt (i_it->source_location .as_string ());
171
171
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));
172
175
173
176
// Ideally we need output_instruction_json
174
177
std::ostringstream out;
@@ -228,6 +231,13 @@ xmlt ai_baset::output_xml(
228
231
location.set_attribute (
229
232
" source_location" ,
230
233
i_it->source_location .as_string ());
234
+ auto original_location = i_it->source_location .get_goto_location ();
235
+ if (original_location!=" " )
236
+ {
237
+ location.set_attribute (
238
+ " original_GOTO_Location" ,
239
+ id2string (original_location));
240
+ }
231
241
232
242
location.new_element (find_state (i_it).output_xml (*this , ns));
233
243
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ SRC = accelerate/accelerate.cpp \
51
51
undefined_functions.cpp \
52
52
uninitialized.cpp \
53
53
unwind.cpp \
54
+ store_goto_location.cpp \
54
55
wmm/abstract_event.cpp \
55
56
wmm/cycle_collection.cpp \
56
57
wmm/data_dp.cpp \
Original file line number Diff line number Diff line change 95
95
#include " model_argc_argv.h"
96
96
#include " undefined_functions.h"
97
97
#include " remove_function.h"
98
+ #include " store_goto_location.h"
99
+
98
100
void goto_instrument_parse_optionst::eval_verbosity ()
99
101
{
100
102
unsigned int v=8 ;
@@ -432,6 +434,14 @@ int goto_instrument_parse_optionst::doit()
432
434
return 0 ;
433
435
}
434
436
437
+ if (cmdline.isset (" store-goto-locations" ))
438
+ {
439
+ for (auto &function : goto_functions.function_map )
440
+ {
441
+ store_goto_locations (function.second .body );
442
+ }
443
+ }
444
+
435
445
if (cmdline.isset (" check-call-sequence" ))
436
446
{
437
447
do_remove_returns ();
Original file line number Diff line number Diff line change 78
78
" (show-threaded)(list-calls-args)(print-path-lengths)" \
79
79
" (undefined-function-is-assume-false)" \
80
80
" (remove-function-body):" \
81
+ " (store-goto-locations)" \
81
82
" (remove-calls-nobody)"
82
83
83
84
class goto_instrument_parse_optionst :
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ void show_locations(
45
45
l.new_element (" file" ).data =id2string (source_location.get_file ());
46
46
l.new_element (" function" ).data =
47
47
id2string (source_location.get_function ());
48
+ l.new_element (" original_goto_location" ).data =
49
+ id2string (source_location.get_goto_location ());
48
50
49
51
std::cout << xml << ' \n ' ;
50
52
}
@@ -53,7 +55,9 @@ void show_locations(
53
55
case ui_message_handlert::uit::PLAIN:
54
56
std::cout << function_id << " "
55
57
<< it->location_number << " "
56
- << it->source_location << ' \n ' ;
58
+ << it->source_location << " "
59
+ << " (Original GOTO Location:" << " "
60
+ << it->source_location .get_goto_location () << " ) \n " ;
57
61
break ;
58
62
59
63
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 CPROVER_GOTO_INSTRUMENT_STORE_GOTO_LOCATION_H
12
+ #define CPROVER_GOTO_INSTRUMENT_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 // CPROVER_GOTO_INSTRUMENT_STORE_GOTO_LOCATION_H
Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ std::ostream &goto_programt::output_instruction(
49
49
const goto_program_templatet::instructiont &instruction) const
50
50
{
51
51
out << " // " << instruction.location_number << " " ;
52
+ auto original_location=instruction.source_location .get_goto_location ();
53
+ if (original_location!=" " )
54
+ {
55
+ out << " (Original GOTO location: " << original_location << " ) " ;
56
+ }
52
57
53
58
if (!instruction.source_location .is_nil ())
54
59
out << instruction.source_location .as_string ();
Original file line number Diff line number Diff line change @@ -67,6 +67,12 @@ json_objectt show_goto_functions_jsont::convert(
67
67
{
68
68
instruction_entry[" sourceLocation" ]=
69
69
json (instruction.code .source_location ());
70
+
71
+ if (instruction.code .source_location ().get_goto_location ()!=" " )
72
+ {
73
+ instruction_entry[" originalGOTOLocation" ]=
74
+ json_stringt (id2string (instruction.code .source_location ().get_goto_location ()));
75
+ }
70
76
}
71
77
72
78
std::ostringstream instruction_builder;
Original file line number Diff line number Diff line change @@ -810,6 +810,7 @@ IREP_ID_ONE(cprover_string_to_upper_case_func)
810
810
IREP_ID_ONE(cprover_string_trim_func)
811
811
IREP_ID_ONE(cprover_string_value_of_func)
812
812
IREP_ID_ONE(array_replace)
813
+ IREP_ID_ONE(original_GOTO_location)
813
814
814
815
#undef IREP_ID_ONE
815
816
#undef IREP_ID_TWO
Original file line number Diff line number Diff line change @@ -140,6 +140,16 @@ class source_locationt:public irept
140
140
return get_bool (ID_hide);
141
141
}
142
142
143
+ void set_goto_location (unsigned location)
144
+ {
145
+ set (ID_original_GOTO_location, location);
146
+ }
147
+
148
+ const irep_idt get_goto_location () const
149
+ {
150
+ return get (ID_original_GOTO_location);
151
+ }
152
+
143
153
static bool is_built_in (const std::string &s)
144
154
{
145
155
std::string built_in1=" <built-in-" ; // "<built-in-additions>";
You can’t perform that action at this time.
0 commit comments