File tree Expand file tree Collapse file tree 3 files changed +48
-1
lines changed
regression/contracts-dfcc/skip_unused_instrumentation
src/goto-instrument/contracts/dynamic-frames Expand file tree Collapse file tree 3 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 1+ // Using a forward declaration rather than including netdb.h to make sure we do
2+ // not have the compiled body of functions from header files available right
3+ // away.
4+ struct hostent ;
5+ struct hostent * gethostbyname (const char * name );
6+
7+ int main ()
8+ {
9+ (void )gethostbyname ("x" );
10+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ ^VERIFICATION SUCCESSFUL$
7+ --
8+ --
9+ This test checks that functions brought in from header files when loading
10+ entries from the model library are not subject to instrumentation (when those
11+ functions are never used). Else we end up with invariant failures like:
12+ [...]
13+ Instrumenting '__bswap_16'
14+ --- begin invariant violation report ---
15+ Invariant check failed
16+ File: /src/goto-instrument/contracts/dynamic-frames/dfcc_instrument.cpp:329 function: instrument_function
17+ Condition: Precondition
18+ Reason: found != goto_model.goto_functions.function_map.end()
19+ Backtrace:
20+ build/bin/goto-instrument(+0xbfe182) [0x649c3d22b182]
21+ [...]
22+ /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x78dc2f029d90]
23+ /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x78dc2f029e40]
24+ build/bin/goto-instrument(+0x363cb5) [0x649c3c990cb5]
25+
26+ Diagnostics:
27+ << EXTRA DIAGNOSTICS >>
28+ Function '__bswap_16' must exist in the model.
29+ << END EXTRA DIAGNOSTICS >>
30+
31+ --- end invariant violation report ---
Original file line number Diff line number Diff line change @@ -257,6 +257,12 @@ void dfcct::partition_function_symbols(
257257 std::set<irep_idt> &contract_symbols,
258258 std::set<irep_idt> &other_symbols)
259259{
260+ std::set<irep_idt> called_functions;
261+ find_used_functions (
262+ goto_functionst::entry_point (),
263+ goto_model.goto_functions ,
264+ called_functions);
265+
260266 // collect contract and other symbols
261267 for (auto &entry : goto_model.symbol_table )
262268 {
@@ -272,7 +278,7 @@ void dfcct::partition_function_symbols(
272278 {
273279 contract_symbols.insert (sym_name);
274280 }
275- else
281+ else if (called_functions. find (sym_name) != called_functions. end ())
276282 {
277283 // it is not a contract
278284 other_symbols.insert (sym_name);
You can’t perform that action at this time.
0 commit comments