Commit Graph

732 Commits

Author SHA1 Message Date
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
Daniel Poetzl 3872df2941 Disable sharing stats when using msvc to avert msvc crash 2019-03-26 16:51:07 +00:00
Daniel Poetzl dc661c4149 Adapt unit test Makefile to not count disabled tests 2019-03-26 16:51:07 +00:00
Daniel Poetzl a1d7024441 Update unit tests for new sharing map interface 2019-03-26 16:51:07 +00:00
Daniel Poetzl 19d3c5c88e Refactor sharing_node_leaft
Add move constructors and remove unnecessary methods.
2019-03-26 10:28:19 +00:00
xbauch 01da544262 Add check that gdb is on the path
No functional change.  Only wraps the test cases in an if-statements checking
the presence of gdb.
2019-03-24 17:03:08 +00:00
Peter Schrammel 2e04b54cfc
Merge pull request #4217 from peterschrammel/move-bmct-jbmc
Move cbmc/bmc and all_properties to jbmc
2019-03-21 14:15:43 +00:00
Daniel Poetzl 468717f39e Make the shared pointers and write_* methods of the sharing nodes protected
The data member and the write_* methods of sharing_node_innert and
sharing_node_leaft are made protected and existing external callers are
refactored to not use write_* directly.
2019-03-21 11:15:12 +00:00
Daniel Poetzl 2614c5bac9 Add reset() method to small_shared_two_way_ptrt
This adds a reset() method which clears the contents of the shared pointer.
Furthermore, the code to remove a reference to the pointed-to object is factored
out into a method destruct(). The method is used both by the destructor and by
reset().
2019-03-21 10:59:59 +00:00
Michael Tautschnig d61900d41c
Merge pull request #4370 from tautschnig/fix-cudd-Makefile-build
Fix Makefile-based build for with CUDD
2019-03-21 10:12:16 +00:00
Peter Schrammel 14109a48ba Fix path explorer unit test
Cannot use deprecated bmct anymore.
2019-03-21 09:57:38 +00:00
Peter Schrammel 90a041da9c Move bmct and all_properties to jbmc/
These aren't used by CBMC anymore, but only
for the symex-driven lazy-loading mode of JBMC.
2019-03-21 09:54:48 +00:00
Daniel Poetzl 6533631183
Merge pull request #3983 from danpoe/feature/gdb-api
GDB API [blocks: #4261]
2019-03-19 17:04:26 +00:00
Petr Bauch d803bde3c9 Fix based on comments 2019-03-19 16:01:40 +00:00
Daniel Poetzl fcbe7b933b Add new unit tests for the gdb api
This adds new unit tests for gdb_apit. The tests compile a test file test.c and
then run gdb on it (via gdb_apit).
2019-03-19 15:52:32 +00:00
Daniel Poetzl aece5a5644 Enable and update gdb api unit tests
This enables the gdb api unit tests (in memory-analyzer/gdb_api.cpp) and adapts
them to include use_catch.h instead of catch.hpp.
2019-03-19 15:52:32 +00:00
Daniel Poetzl 7e6bd17018 Replace #ifdef __linux__ by guards allowing more Unices
We require the Unix fork() system call (in unistd.h)
2019-03-19 15:52:32 +00:00
Daniel Poetzl 0b9480bb40 Update banners for gdb api files 2019-03-19 13:42:01 +00:00
Daniel Poetzl d44dfb99c9 Adapt gdb interaction exception to cprover style 2019-03-19 13:42:01 +00:00
Malte Mues 1e71fd7fbc Add an api to analyze a core dump with gdb
Applying CBMC on large code bases
requires sometimes to model a test environment.
Running a program until a certain point and let it
crash, allows to analyze the memory state at this point in time.
In continuation, the memory state might be reconstructed as base for
the test environment model.

By using gdb to analyze the core dump, I don't have to take
care of reading and interpreting the core dump myself.
2019-03-19 13:42:01 +00:00
Chris Smowton c5d7bae08d Symex: propagate constants implied by assumptions and conditions
When passing `assume(symbol == constant)` or `if symbol == constant then GOTO`, we can populate the
constant propagator and value-set accordingly and use that information until the next merge point without
that constraint. We implement this by allocating and defining a fresh L2 generation on this path, which
will be merged as "real", assignment-derived generations are. Symbols are subject to propagation under
the same conditions as they are on assignment (e.g. requiring that they are not subject to concurrent
modification by other threads).
2019-03-18 16:15:59 +00:00
Michael Tautschnig c7db0c9e6f Fix Makefile-based build for with CUDD
The previous set-up failed to compile (as cudd.h was not found), and
first fixes to make it compile and link resulted in persistent
segmentation faults. These were caused by inconsistent includes as
HAVE_CUDD was only set in selected directories (unlike the CMake
configuration).
2019-03-14 21:41:47 +00:00
Michael Tautschnig 4fa790bdc2
Merge pull request #4385 from smowton/smowton/fix/expr-iterator-mutated
Expr-depth-iterator: support iterating over mutated expressions
2019-03-14 20:37:18 +00:00
Chris Smowton 17bee52504 Add unit tests for expr_iterator 2019-03-14 18:09:17 +00:00
Michael Tautschnig 027760b479 Pass irept by value in modifying irept::add/set operations
This should enable use (with performance benefit) of rvalue references in
higher-level APIs.
2019-03-14 15:03:12 +00:00
Romain Brenguier e80340d31a Unit test for ranget drop
This tests that these operations behave as expected and gives examples
on how to use them.
2019-03-08 14:13:53 +00:00
Romain Brenguier f9a698ce24 Remove root field of bdd_exprt
Instead the result of from_exprt and the input of as_expr should be
BDDs.
This makes it possible to reuse the same manager for several exprt
conversion and to combine the results obtain from the from_expr
conversion with BDD operations.
2019-03-07 11:02:35 +00:00
Romain Brenguier 4da4bd3dbe Remove unused field ns field of bdd_exprt
A reference to a namespace was stored without being ever used.
2019-03-07 11:02:35 +00:00