Commit Graph

759 Commits

Author SHA1 Message Date
Michael Tautschnig 4d020ce447 Revert "Use std::forward_list instead of std::map in irept by default"
This reverts commit 2b9849af73.
2019-05-29 23:53:39 +00:00
Michael Tautschnig c4ffbeeb40
Merge pull request #4458 from tautschnig/forward-list
Use std::forward_list instead of std::map in irept by default [blocks: #3486]
2019-05-28 16:01:35 +01:00
Daniel Poetzl 37c3439cdb Return reference from methods that cannot return a nullpointer
Previously some methods returned a pointer but would never return nullptr. This
changes their return type to references instead.
2019-05-23 14:26:14 +01:00
Daniel Poetzl a2f32bffc8 Add new unit tests which check the shape of the map and adapt existing ones
The shape of a sharing map is now different than before, as now leafs can be
directly attached to internal nodes. This adapts the various unit tests that
check that the map has a certain shape.
2019-05-23 14:26:14 +01:00
Daniel Poetzl 8243434515 Unify leaf nodes with internal nodes and container nodes
Previously the leaf nodes were a separate type, and internal nodes and container
nodes were represented by the same type. This changes the representation such
that all nodes are represented by sharing_nodet. This will allow an internal
node to directly point to a leaf node (instead of having to point to a container
node which in turn points to a leaf node).
2019-05-23 12:23:57 +01:00
Petr Bauch 3d9a71b66a
Merge pull request #4482 from xbauch/feature/user-control-havoc
User controlled havoc(ing) for memory-snapshot harness
2019-05-20 12:49:19 +01:00
Petr Bauch 93f4ee40a0 Optionalize the results of querying gdb
Not all queried values are sensible if we ask past allocated
memory (malloc_usable_size doesn't return exact values).
2019-05-20 11:03:47 +01:00
Michael Tautschnig 2b9849af73 Use std::forward_list instead of std::map in irept by default
This reduces the size of an irept by 5 pointers (i.e., 40 bytes on
64-bit systems). On SV-COMP's ReachSafety-ECA with this change we can
perform 3819.81 symex_step calls per second, compared to 2752.28 calls
per second with the std::map configuration. The performance improvements
are spread across various `irept`-related operations.
2019-05-19 17:03:01 +00:00
Daniel Poetzl 35b91f44e9 Move sharing map unit test sections into more appropriate test cases 2019-05-18 13:55:19 +01:00
Daniel Poetzl d70636d02b Add comment to explain sharing map shape unit tests 2019-05-16 18:34:55 +01:00
Daniel Poetzl f82e08e43d Use plain std::size_t as key in sharing map hash collision unit tests 2019-05-16 16:41:59 +01:00
Daniel Poetzl 13f792e276 Fix bug where an item was not added to the delta view of the sharing map
The bug could appear when there are hash collisions between the keys stored in
the sharing map.
2019-05-16 16:28:20 +01:00
Michael Tautschnig 09875c350c
Merge pull request #4261 from danpoe/feature/memory-analyzer
Memory analyzer to take memory snapshots [blocks: #2649, #4438]
2019-05-16 15:10:45 +02:00
Petr Bauch 9703af15bf Update unit test
to the new interface.
2019-05-16 11:57:18 +01:00
Hannes Steffenhagen 856aa5c201 Make memory analyzer optional
We were doing this in multiple places, this should make it a bit easier to keep
set properties consistent among different places.

Ideally we could eventually move away from mentioning targets from modules here
on the top level (and instead have each module call cprover_default_properties)
but this isn't done in this commit.

Because memory analyzer depends on GDB being present and further uses platform
specific functionality at the moment it had some ifdef functionality to disable
itself.

This made the code a bit more complicated than it needed to be, and also lead to
the code effectively building defunct executables. This removes these ifdefs and
instead excludes memory-analyzer (and related tests) from the build unless
requested (via WITH_MEMORY_ANALYZER environment variable or CMake option
depending on whether it is a Make or CMake build respectively).

Also force building memory-analyzer on Linux and test it there by
default (unless explicitly unset). Behaviour on other platforms should be
preserved.
2019-05-16 11:56:04 +01:00
Daniel Poetzl 4c3967e260 Update gdb api to return more information about pointed-to objects
This update the gdb api to return more information about pointers (via the
method get_memory() which returns an object of type pointer_valuet describing
the pointer and pointed-to data). Unit tests for the new functionality are
included.
2019-05-16 11:17:20 +01:00
Malte Mues 767a3858a7 Add Makefiles enabeling memory-analyzer and tests 2019-05-16 11:17:20 +01:00
Daniel Poetzl 86c5a3fab6 Sharing map variable height trees
Previously the sharing map was a fixed-height tree (with height 6 by default).
This changes the sharing map to a variable-height tree.
2019-05-15 14:00:51 +01:00
Daniel Poetzl c1dae4aca1
Merge pull request #4654 from danpoe/feature/small-shared-n-way-ptr
Small shared n-way pointer
2019-05-15 13:20:15 +01:00
Daniel Poetzl 922adf0576 Small shared n-way pointer
This replaces small_shared_two_way_ptrt with small_shared_n_way_ptrt. The new
shared pointer type allows more than two types for the managed objects. This can
be useful e.g. for implementing graph data structures with sharing where there
are more than two different node types.
2019-05-15 11:14:15 +01:00
Petr Bauch 16e2a14009 Unify the remove-returns query
between goto-program/remove-return and the respective validation check. Update
the unit-test accordingly.
2019-05-14 11:25:37 +01:00
Michael Tautschnig 359a063ca2 Fix simplification of pointer-object comparison
1) pointer_object((T1 *)NULL) equals pointer_object((T2 *)NULL) for any
types T1, T2. Previously, this would return false, unless T1==T2.
2) Do not restrict the above to NULL, but instead let the existing logic
in simplify_inequality fully simplify this.
3) Add a unit test of this code, which highlighted further bugs and
limitations: the unit test previously did not set the instance of the
desired dynamic object, and address-of inequalities over dynamic objects
can also be simplified.
2019-05-12 17:45:26 +00:00
Chris Smowton c1113b3b30 Add is_return_value_* methods
Now that RETURN_VALUE_SUFFIX is hidden, these provide a way to easily differentiate an ordinary global
variable from one introduced by remove_returns.
2019-05-09 16:21:16 +01:00
Michael Tautschnig 8affad0554 Enable HASH_CODE by default to avoid repeated hash computation
On some SV-COMP benchmark categories, hashing accounts for >20% of CPU
time (with profiling enabled) - top five:

* ReachSafety-BitVectors: 29.29% (470.54 seconds, which reduces to 4.39
  seconds; for benchmarks not timing out we save 170 seconds (25%) in
  non-profiling mode)
* Systems_BusyBox_NoOverflows: 27.98% (284.15 seconds, which reduces to
  1.74 seconds; for the 1 benchmark not timing out we save 23 seconds
  (6%) in non-profiling mode)
* Systems_BusyBox_MemSafety: 24.24% (194.74 seconds, which reduces to
  0.93 seconds; no measurable difference on the 2 benchmarks not
  failing/timing out)
* NoOverflows-Other: 18.84% (1127.61 seconds, which reduces to
  23.57 seconds; for benchmarks not timing out we save 5 seconds (7%) in
  non-profiling mode)
* ReachSafety-ControlFlow: 17.75% (1194.04 seconds, which reduces to
  29.17 seconds; for benchmarks not timing out we save 200 seconds (25%)
  in non-profiling mode)

For ReachSafety-ECA it's only 4.7%, which still amounts to 3006.7
seconds. With this change this reduces to 323.07 seconds. On
ReachSafety-ECA, this enables 3055.35 symex_step calls per second over
2752.28 calls per second without this change.
2019-05-08 15:23:59 +00:00
Chris Smowton ea4ec407f9 Sharing map: don't require a default constructor for mapped_type
Replace the dummy element in its delta views with a pointer + accessor method.
2019-05-03 16:26:12 +01:00
Antonia Lechner 0a3ddf8c0f Add support for whole BMP in the JSON parser
The previous implementation only supported codepoints up to 0x7f as
characters, and all remaining codepoints up to 0xff as integers.
The new implementation supports all codepoints in the BMP, i.e. up to
0xffff.
2019-05-02 10:37:30 +01:00
Michael Tautschnig c1baa03b2e Remove redundant string initialisation
Both std::string and dstringt are default-initialised to an empty string.
2019-04-30 22:30:57 +00:00
Daniel Kroening bef4da35b1 config.main is now optionalt<string>
This avoids the use of 'empty string' as indicator of 'no value'
2019-04-30 14:47:25 +01:00
Antonia Lechner 06e666b802 Implement parsing of Unicode characters from JSON
Previously, if a JSON file contained a string in hexadecimal Unicode
representation, e.g. "\u0001", the JSON parser would discard the "\u"
part and store the string as "0001". This commit fixes this so the
resulting string is equal to "\u0001".
2019-04-30 11:05:10 +01:00
Chris Smowton 0128bb26ec
Merge pull request #4574 from smowton/smowton/fix/brittle-goto-symex-is-constant
goto-symex-is-constant: treat `x * sizeof(t)` and `sizeof(t) * x` alike
2019-04-29 15:52:22 +01:00
Chris Smowton eb7fc4bb7f goto-symex-is-constant: treat `x * sizeof(t)` and `sizeof(t) * x` alike
Previously it would refuse and allow constant propagation respectively.
2019-04-29 13:38:17 +01:00
Daniel Poetzl 4d3cb8c9f5 Add unit test to test iteration over empty sharing map 2019-04-29 11:41:38 +01:00
Peter Schrammel 9d3515bc6c Move xml_interface to xmllang
Enables reuse in other driver programs.
It's not CBMC-specific.
2019-04-28 22:41:24 +01:00
Michael Tautschnig 65e6b6a495
Merge pull request #4547 from danpoe/feature/sharing-map-unit-tests
Add unit tests for sharing map that check that views are not invalidated by modifications
2019-04-18 17:51:07 +03:00
Daniel Poetzl 2b4f0aed2d Use REQUIRE_THROWS_AS() in sharing map unit tests 2019-04-18 14:37:40 +01:00
Daniel Poetzl 2d29291123 Refactor existing tests of error cases to use cbmc_invariants_should_throwt
This adds sharing map unit tests to check that operations fail as expected. For
example, calling map.replace(key, value) when the key does not exist in the map
should fail.
2019-04-18 14:37:40 +01:00
Daniel Poetzl 94bc97ff31 Add unit tests to check that sharing map modifications do not invalidate views
This adds unit tests to check that the references into the sharing map in the
views and delta views remain valid after operations erase(), insert(), and
replace(). The references should remain valid to those elements that are not
changed by the respective operations.
2019-04-18 14:37:40 +01:00
Daniel Poetzl 2e7f41473d Use existing type sharing_map_error_checkt in sharing map unit test 2019-04-18 14:37:40 +01:00
Daniel Poetzl 9e348b735c Fix sharing map unit tests bug that assumed that irep_idts are lexicographically ordered 2019-04-18 14:37:39 +01:00
Romain Brenguier 1d09894a7d Remove unecessary log argument in cbmc_parse_optionst
The messaget can be constructed from the message_handler.
2019-04-17 14:36:21 +01:00
Chris Smowton aa9dbefd14 Add sharing_mapt::iterate
This gives a simple const iterator without copying the whole dataset.
2019-04-16 22:20:06 +01:00
Chris Smowton 4b8e92737d Add sharing_mapt::update
This permits an in-place update, avoiding needless copy-out / mutate / move-in cycles for
expensive-to-copy value types without leaking a non-const reference to a value.
2019-04-16 22:20:06 +01:00
Chris Smowton f0de6395e8 Add convenience method sharing_mapt::erase_if_exists
Just saves repeating the if-has-key-then-erase pattern
2019-04-16 21:58:38 +01:00
Chris Smowton 90145061e6 Restore recognition of dynamic objects
These were accidentally disabled when distinguishing ID_is_dynamic_object (a predicate that tests
whether an object is dynamic) from ID_dynamic_object (a reference to the object itself, similar to
symbol_exprt). I also take the opportunity to restore pretty-printing of dynamic object expressions
(while also keeping pretty-printing of the predicate).
2019-04-15 18:03:45 +01:00
Michael Tautschnig 848e633b67 Use bv_typet to fix type consistency in byte-operator lowering
Previously we fixed the extracted bytes to be unsigned bitvectors, but
we should not actually impose (un)signedness as we do not actually
interpret the bytes as numeric values. This fixes byte operators over
floating-point values, and makes various SMT-solver tests pass as the
SMT back-end is more strict about typing and therefore was more
frequently affected by this bug.

To make all this work it was also necessary to extend and fix the
simplifier's handling of bv_typet expressions, and also cover one more
case of type casts in the bitvector back-end.

The tests
  Array_operations1/test.desc
  Float-equality1/test_no_equality.desc
  memory_allocation1/test.desc
  union12/test.desc
  union6/test.desc
  union7/test.desc
continue to fail on Windows and thus cannot yet be enabled.
2019-04-11 23:49:19 +00:00
Daniel Poetzl a9565d1eca Remove redundant check of return value of check_for_gdb() in gdb api unit tests
check_for_gdb() could only return true since if the gdb invocation in its body
failed a REQUIRE(...) in its body would fail. This changes check_for_gdb() the
return type of check_for_gdb() to void and refactors its callees.
2019-04-07 20:48:14 +01:00
Daniel Poetzl ac34e7ec01 Redirect stdout/stderr of gdb test in gdb api unit tests to /dev/null 2019-04-07 20:32:45 +01:00
Daniel Poetzl b2a548c6a7 Change erase() method of the sharing map to require that the given key exists
Previously when sharing_map.erase(key) was called, two traversals of the path to
the leaf to erase were done. One to check whether the key was in the map, and if
it was, a second one to copy and detach the nodes on the path to the leaf to
erase. This commit changes erase() to require that the given key exists in the
map. This simplifies the implementation and avoids two traversals of the path to
the leaf to erase when it is known that the key exists. If it is not known
whether the key exists, sharing_map.has_key(key) should be explicitely called
first.
2019-04-04 15:41:15 +01:00
Daniel Kroening f43e786cf1 fix compilation with cygwin
The variant of std::ifstream with a wide character file name is only
available when using Visual Studio but not when using Cygwin.
2019-03-31 17:07:53 +01:00
Peter Schrammel 2096968df9 prop_conv_solvert is not a messaget
Gets a log member instead.
2019-03-27 14:18:12 +00:00