Commit Graph

1642 Commits

Author SHA1 Message Date
Massimo Fioravanti 6421aeed3e Support: depend on generated model headers
renvg.h should not use model headers, however, currently it does. This,
combined with the fact that the revngSupport library did not depend on
revngModel or the header generation led to non-deterministic build
failures.

Before this commit the bug can be found by:

    orc clean revng
    orc uninstall revng
    orc configure revng
    orc shell -c revng ninja renvgSupport

The error should manifest itself as some generated headers missing.

The proper fix would be to rewrite revng.h so that it does not uses the
model.
2022-01-17 18:17:45 +01:00
Filippo Cremonese 0a70383e12 tuple_tree_generator: Jinja2 compatibility issue
This commit fixes a compatibility issue with Jinja2 2.10.
2022-01-17 16:35:01 +01:00
Alessandro Di Federico d19879d4e8 Minor changes 2022-01-17 16:30:42 +01:00
Alessandro Di Federico b92d99e0a3 Merge branch 'feature/model-classes-generator' 2022-01-13 17:12:49 +01:00
Alessandro Di Federico fc02a84436 Test generated model can be loaded
This ensure we catch bugs in model deserialization early, while usually
they pop up in revng-c, which doesn't make much sense.
2022-01-13 14:34:11 +01:00
Filippo Cremonese 6e7439ad6d Check Python requirements at configure time 2022-01-13 14:34:11 +01:00
Filippo Cremonese 74217b4fe5 Generate C++ model from YAML definition
Model classes are now described by a YAML document, which is used to
generate C++ headers containing classes and all the boilerplate
required for YAML serialization/deserialization, usage in
SortedVectors, etc. See the README in include/revng/Model for more
info.
2022-01-13 14:34:11 +01:00
Filippo Cremonese fbeee896e1 Rename model::abi -> model::ABI 2022-01-10 10:31:27 +01:00
Filippo Cremonese a97efbaaf7 Add missing <map> include 2022-01-10 10:31:27 +01:00
Alessandro Di Federico 738637b673 Suggest DISABLE_RECURSIVE_COROUTINES usage 2022-01-09 19:00:57 +01:00
Alessandro Di Federico 546efa345a More verbose model verification failures 2022-01-09 19:00:57 +01:00
Alessandro Di Federico 7d4ef44cb7 DwarfImporter: ignore 0-sized arrays 2022-01-09 19:00:57 +01:00
Alessandro Di Federico 441a5552b7 ProgramRunner: do not depend on main
`main` is not in all cases a dynamically exported symbol, therefore,
it's not safe to rely on it.

This commit switches to use `PathList`'s `getCurrentExecutableFullPath`,
which reads `/proc/self/exe`.
2022-01-09 19:00:57 +01:00
Alessandro Di Federico cfb47157b9 clang-tidy: readability-identifier-naming
This commit fixes all the non-compliance with our preliminary clang-tidy
configuration, which will be merged soon.
2022-01-07 09:18:05 +01:00
Alessandro Di Federico 40198d9659 Merge branch 'feature/pipeline-preliminary' 2022-01-05 15:44:47 +01:00
Massimo Fioravanti b8f6303101 Fix wrong usages of StringRef::data
StringRef::data() does not ensure that the string is zero terminated,
thus when printed it can contain more data than expected.

Specifically, this triggered the reported name of the registers to be
incorrect, and this manifested itself as wrong inline assembly emitted.
2022-01-05 14:47:25 +01:00
Massimo Fioravanti bdcc1d2e30 BinaryFile::BinaryFile: accept object::Binary
The constructor now accepts a llvm::object::Binary directly rather than
a path. Will be used by the revng-pipeline which will retain ownership
of the binary.
2022-01-05 14:47:25 +01:00
Massimo Fioravanti 889b076828 AdvancedValueInfo: fix wrong NDEBUG check
A extra check was performed in release only rather than in debug only.
2022-01-05 14:47:25 +01:00
Massimo Fioravanti ec0fcfbe63 Model: separate mipsel from mips 2022-01-05 14:47:25 +01:00
Massimo Fioravanti fdfeb2b6e9 LoadModelPass: support for external model 2022-01-05 14:45:01 +01:00
Massimo Fioravanti 79d5ca1e27 Introduce FunctionTags::IsolatedRoot
This will be used by the revng-pipeline to tell apart a `root` calling
isolated functions from a regular one.
2022-01-05 14:45:01 +01:00
Massimo Fioravanti ca4c7e2c09 Add dereferenceIterator and mapToValueIterator
A dereference iterator is used to map a pointer-like object to the
pointee, as an example given a `vector<unique_ptr<int>> Vector`, using
`dereferenceRange(Vector)` will present a range of `int &` rather than a
range of `unique_ptr<int> &`.

mapToValueIterator can be used  on a map range
to access the underlying object directly rather
than the pair<key, object>.
2022-01-05 14:45:01 +01:00
Massimo Fioravanti 80c3121c29 Introduce ProgramRunner
The ProgramRunner will be used by revng-pipeline to invoke the external
linker to operate on object file stored on disk.
2022-01-05 14:45:01 +01:00
Massimo Fioravanti ac20314a92 Helpers to go from llvm:: to model::Function 2022-01-05 14:45:01 +01:00
Alessandro Di Federico d78993ac54 Add TupleTree file (de)serialization
Tuple tree file serialization will be used by the revng-pipeline as a
helper function to load and store the models in the working directory.
2022-01-05 14:44:57 +01:00
Alessandro Di Federico 41008d9a08 Merge branch 'feature/tupletreereference-to-const-model' 2022-01-05 14:38:42 +01:00
Pietro Fezzardi b689f7f0c0 lib/Model/Type.cpp: add global using llvm::Twine
This using was defined many times with local scope.
This commit makes it global.
2022-01-05 14:37:37 +01:00
Pietro Fezzardi 2f524114e8 RecursiveCoroutine: add operator* for ergonomics
This allows e.g. the following programming pattern:

```
RecursiveCoroutine<std::optional<SomeType>> f();

int g() {
  return *f();
}
```

Without operator* defined for `RecursiveCoroutine` this would fail,
requiring an explicit cast such as:

```
int g() {
  return *static_cast<std::optional<SomeType>>(f());
}
```
2022-01-05 14:37:37 +01:00
Pietro Fezzardi 94c1c5323a Improve error reporting for model::UnionType 2022-01-05 14:37:37 +01:00
Pietro Fezzardi 09dd05c975 UnionTypes with zero-sized fields don't verify 2022-01-05 14:37:37 +01:00
Pietro Fezzardi ff4f91a570 Model/Type.h: explicit constructors from uint64_t 2022-01-05 13:33:52 +01:00
Pietro Fezzardi a4c9d6c6fd Allow model::StructType with no fields
This is necessary for how we represent the type of the stack frames when
we know about its size but not yet about its fields.
2022-01-05 13:33:52 +01:00
Pietro Fezzardi e37425c686 TupleTreeReference: add getConst() method 2022-01-05 13:33:52 +01:00
Pietro Fezzardi 0e1402adfc Fix is_specialization<const X<T>, X>
Before this commit `is_specialization<const X<T>, X>` was not
specialized, so that `const X<T>` did not count as a specialization of
`X`. This resulted in bad selection of template specialization based on
concepts that were using `is_specialization_v`, such as
`IsUpcastablePointer`.

This commit fixes the problem, so that now the concept
`IsUpcastablePointer` is true for `const UpcastablePointer<T>` as well.

This also enabled to remove some workarounds for the `IsMutableSet` and
`IsSortedVector` concepts, and treat them uniformly with other concepts
that were using `is_specialization_v`.
2022-01-05 13:33:52 +01:00
Pietro Fezzardi 275959618f TupleTree: make Root a std::variant<T *, const T*>
This enables holding TupleTreeReferences to immutable model objects
2022-01-05 13:33:52 +01:00
Pietro Fezzardi 69715dafed TupleTreePath: add empty() method 2022-01-05 13:33:52 +01:00
Pietro Fezzardi c338e79de7 Extend TupleTreeCompatible concept
Before this commit, it was only matched by types that satisfied the
constraint `IsUpcastablePointer`, which is too strict.
Now also types that match `UpcastablePointerLike` satisfy the
constraints for this concept.
2022-01-05 13:33:40 +01:00
Alessandro Di Federico ed36d2b6ab Merge branch 'feature/convert-revng-lift-to-library' 2021-12-22 17:48:04 +01:00
Alessandro Di Federico 8c0b918ace s/DebugHelper.*/IRAnnotators.*/ 2021-12-22 17:47:54 +01:00
Alessandro Di Federico e7bc0c739b Restore emission of annotated IR 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 88dbc39f29 Reorganize LLVM IR debug annotations emission 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 6073133545 CodeGenerator: drop IR emission duties 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 4d7a175996 Extract TupleTree 2021-12-22 17:47:54 +01:00
Alessandro Di Federico f97f8a880c Drop extra assertions related to debug info 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 27b553f09e CodeGenerator: stop emitting .li.csv and .need.csv 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 777adcbd45 model::Binary: add segments and imported libraries
Now, `scripts/revng` uses the model and we no longer need to emit
.li.csv and .need.csv.
2021-12-22 17:47:54 +01:00
Alessandro Di Federico 5a28bfedea Move SegmentInfo::generateName to BinaryFile.cpp 2021-12-22 13:47:21 +01:00
Alessandro Di Federico 455bf10648 Specialize KeyedObjectTraits for std::string 2021-12-22 13:47:21 +01:00
Alessandro Di Federico 57ae7613e1 Drop obsolete debug files
This commit drops the generation of `.coverage.csv` and `.bbsummary.csv`
files. No one really uses them anymore.
2021-12-22 13:47:21 +01:00
Massimo Fioravanti 9e477d0ada Make a library out of revng-lift 2021-12-22 13:47:21 +01:00