470 Commits

Author SHA1 Message Date
Ivan Krysak 541643afc3 Move function type conversion to librevngABI 2022-02-24 23:56:30 +01:00
Filippo Cremonese 09a995ba51 python-model: generate from jsonschema 2022-02-23 18:03:35 +01:00
Alessandro Di Federico b7f5884f8c DynamicFunction::name: no OriginalName direct use 2022-02-14 17:54:32 +01:00
Ivan Krysak 9771ae29d6 Move RegisterState to ABI 2022-02-14 13:35:37 +01:00
Ivan Krysak 8d876b0def ABI: introduce bulk function conversion 2022-02-14 13:35:37 +01:00
Ivan Krysak e20e65ca9a Require a description when registering a pass 2022-02-14 13:35:36 +01:00
Ivan Krysak 7369e49eba Implement "best effort" function type convertion 2022-02-14 13:35:36 +01:00
Alessandro Di Federico ec6d4dbe74 Ensure all files end with a newline 2022-02-14 10:56:15 +01:00
Pietro Fezzardi 29c50fa909 Model: reserve names defined in stdint.h
This commit adds a bunch of type names and macro names to the set of
reserved keywords that cannot be used for names in the revng Model.
These are the names defined in the stdint.h standard C header, that is
included automatically by the decompiler in decompiled code.

We need to reserve these names otherwise it would be possible to add
things to the revng Model with names that clash with the names defined
in stdint.h, which would in turn break recompilation of decompiled code
because of conflicting definitions.
2022-02-08 15:54:02 +01:00
Alessandro Di Federico 280848484e SerializeModelPass: verify model 2022-01-31 16:28:17 +01:00
Alessandro Di Federico a353e00ac1 Introduce model passes 2022-01-31 16:28:14 +01:00
Alessandro Di Federico b3d6c721ad Introduce purgeUnnamedAndUnreachableTypes 2022-01-27 11:51:03 +01:00
Alessandro Di Federico f14e722c86 Introduce deduplicateEquivalentTypes 2022-01-27 11:51:03 +01:00
Alessandro Di Federico dd7477664c Update CustomName verification criteria
This commit ensures `CustomName` is unambiguous according to C symbols
rules.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 74a7496020 deduplicateNames -> promoteOriginalName
This commit switches from `deduplicateNames`, which changed certain
`CustomName` values, to `promoteOriginalName`, which updates empty
`CustomName` using non-ambiguous versions of `OriginalName`.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 863652f480 Introduce OriginalName in the type system
The goal of `OriginalName` is to keep track of the original name of a
symbol upon import.

In future, this will also be used to promote it to `CustomName`.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 8d22c5205f Push CustomName to model::Type
Before this commit `CustomName` was in each inheritor, except for
`model::PrimitiveType`.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico b31e7b1f5e Introduce model::Type::edges()
This makes building a graph for the type system very easy.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 80ed065206 model::Type: move makeTypeWithID to .cpp
It needs to see the full declaration of all concrete types.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 92ea78b0a8 Fix ReservedKeywords list
Commas were missing.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico c9d47d4ee7 Drop model::EnumEntry::Aliases
They turn out to be problematic to handle in the model and not very
usable in practice.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 1ce1f1cbd6 model::Function::verify: relax assumptions
Now `model::Function` can miss the CFG, the `Prototype` and have
`Invalid` type.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 3799f1e973 Whitespace and other minor changes 2022-01-25 21:27:05 +01:00
Alessandro Di Federico 3ab32cd2ef tuple_tree_generator: make fully standalone 2022-01-21 18:05:51 +01:00
Alessandro Di Federico d19879d4e8 Minor changes 2022-01-17 16:30:42 +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
Alessandro Di Federico 546efa345a More verbose model verification failures 2022-01-09 19:00:57 +01:00
Massimo Fioravanti fdfeb2b6e9 LoadModelPass: support for external model 2022-01-05 14:45:01 +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 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 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 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
Alessandro Di Federico 09914e56cf model::Type::dump: upcast 2021-12-17 18:48:52 +01:00
Antonio Frighetto f1ac5e4075 Model: handle NoReturn functions in CallEdge 2021-12-15 18:03:30 +01:00
Alvise de Faveri 2f4b716e6b Add Model::toString() and writeToFile()
These functions can be used in conjunction to dump the Model on a
file during a gdb session, for example:

```
(gdb)  p  writeToFile(Model->toString(), "/tmp/model.yaml")
```
2021-11-19 10:17:09 +01:00
Pietro Fezzardi c050dcb621 Handle missing model in SerializeModelPass
Before this commit, SerializeModelPass and SerializeModelWrapperPass had
hard dependencies on the passes that load the model from LLVM-IR.

This commit makes this dependency optional. When the passes for model
serialization are executed, if they see that nobody requested to load
the model, they will not try to serialize it.

This prevents them from crashing when running in pipelines that only
contain passes that ignore the model.

This is particularly beneficial because `revng opt` automatically adds
`-serialize-model` at the end of each pipeline and, before this commit,
this meant that `revng opt` could not be used for unit-testing simple
llvm passes that do not use the model.

With this commit, `revng opt` can be used for unit-tests, even on LLVM IR
with missing model.
2021-10-21 15:02:01 +02:00
Alessandro Di Federico 83f420abda Introduce dump method for model structs 2021-10-21 15:02:00 +02:00
Alessandro Di Federico 8546a0c786 CallEdge: only indirect calls have a prototype 2021-10-21 15:01:59 +02:00
Alessandro Di Federico 89532890ed Introduce support for importing DWARF information 2021-10-21 15:01:20 +02:00
Alessandro Di Federico 3a3eea0cf5 Introduce support for dynamic functions 2021-10-21 15:01:19 +02:00
Alessandro Di Federico a023bfa7f5 Introduce ABI handling 2021-10-18 20:44:58 +02:00
Alessandro Di Federico 0dfc81da41 Minor model improvements
* Introduce some documentation for the model.
* Improve the way enums are serialized/deserialized.
* Mark certain fields of model data structures as optional.
* introduces some error messages during model validation.
2021-10-18 20:44:58 +02:00
Alessandro Di Federico 34ae75c800 model: handle 80 bits floats (12 bytes) 2021-10-18 20:44:58 +02:00
Alessandro Di Federico 2fec214959 Fix QualifiedType::isScalar 2021-10-18 20:44:58 +02:00
Pietro Fezzardi a0dbea19e5 Prevent model::Type CustomNames from colliding
This commit reserves the "unnamed_" prefix for revng.
The first use of this reserved prefix is in `model::Type`s
`CustomName`s and `model::Identifier`s.
This commit also makes the `verify()` method stricter for
`model::Identifier` so that an `Identifier` whose name starts with the
reserved prefix does fails verification.
2021-09-02 14:55:47 +02:00
Pietro Fezzardi 3d38451abd Enable error checking on Model deserialization
This commit changes the `TupleTree::deserialize` method to return an
`llvm::ErrorOr<TupleTree>`, enabling users to choose their policies on
error reporting.
2021-09-02 14:42:51 +02:00
Pietro Fezzardi bae9214652 Stricten verification for model::Identifier
Now only `Identifier`s that are valid C identifiers are guaranteed to
verify.
The `fromString` factory is updated accordingly.
2021-09-02 14:42:47 +02:00
Pietro Fezzardi aa46b03050 Add name() members to various Model types 2021-09-02 14:39:23 +02:00