Commit Graph

66 Commits

Author SHA1 Message Date
Ivan Krysak 79964eac74 Avoid ' misuse in error messages and comments 2025-04-17 16:41:21 +02:00
Ivan Krysak 76ed261375 Use revng_undefined_ instead of init_
Current `init_` prefix used to set the default values of SCVs
is very common in typical code, hence it would cause a lot of
collisions.
2025-04-17 11:19:17 +03:00
Ivan Krysak 1383b0a40a Importers: replace .s in section names 2025-04-17 11:19:17 +03:00
Ivan Krysak 433af9ef6e Adopt the new name deduplication pass 2025-04-17 11:19:17 +03:00
Ivan Krysak dce5c1a02c NamingConfiguration: pull more prefixes inside
Unify additional values that used to be hardcoded in the old backend
under the same naming configuration root.
2025-04-17 11:19:17 +03:00
Ivan Krysak f070f1f1e1 Model: sunset double name system 2025-04-17 11:19:17 +03:00
Ivan Krysak 25790b5a78 NameBuilder: change automatic segment name
Use index within the binary instead of address in order to make these
shorter.
2025-04-15 16:35:42 +03:00
Alessandro Di Federico b576fd1988 CollectFunctions tests: ignore loaded addresses
The tests was testing if a function whose entry address is the target of
load was identified as a function or not (it shouldn't).

This test was passing accidentally. This has not been supported since
the introduction of `RootAnalyzer`.  In order to support this again, we
need to resurrect `processLoadsAndStores`.
2025-01-28 12:19:16 +01:00
Alessandro Di Federico 832840c307 Importers: ignore unmapped code
This commit ensures that parts of the model that must point to code
(specifically `Binary::EntryPoint`, `Binary::ExtraCodeAddresses` and
`Function::Entry`) actually point to a segment mapped as +x.
2024-11-28 15:22:10 +01:00
Alessandro Di Federico 143c315196 Merge revng-c into revng 2024-11-21 10:50:55 +01:00
Ivan Krysak 64446d0453 Adopt name builder across the model users 2024-11-06 19:18:53 +02:00
Alessandro Di Federico 77ed34e633 Minor fixes to tests
Some of these changes are due to non-determinism.
We should find a more appropriate fix next time.
2024-09-27 10:35:10 +02:00
Ivan Krysak b4a6682a3e OperatorPrecedence: introduce forced parentheses 2024-09-10 11:49:42 +03:00
Ivan Krysak a8b5ebdd95 import-from-c: rework testing from the ground up 2024-09-04 16:55:49 +02:00
Ivan Krysak f7fa47fc72 HeaderToModel: add size tag to the other tests 2024-09-04 13:04:44 +03:00
Alessandro Di Federico d28af50f84 DetectStackSize: handle counted loops 2024-08-23 18:01:47 +02:00
Pietro Fezzardi e1b5541462 DLA: depotentiate SimplifyInstanceAtOffset0
The DLAStep SimplifyInstanceAtOffset0 now only triggers if the parent
node has the child-at-offset-0 node as its only successor, or when the
child-at-offset-0 doesn't have other predecessors.

Doing this guarantees that it's impossible for another predecessor of
the child-at-offset-0 to start seeing memory accesses that were
initially relative to the parent.

This condition is slightly more restrictive than the previous one, but
it takes into consideration some far reaching consequences.
If SimplifyInstanceAtOffset0 aggressively like we did before, DLA can
end up inferring types in some memory locations, like executable
segments, for which there aren't clues in the binary.
This isn't bad per se, but if DLA does that, the newly recovered type is
identified as non-executable data, causing misdecompilation because
rev.ng doesn't decompile memory regions that it understands as non
executable.

This commit, making SimplifyInstanceAtOffset0 less aggressive, makes it
play better with the rest of the assumptions of the decompilation
pipeline.

It also relaxes a decompilation test that was previously working by
chance and that was effectively beyond the current expressive power of
reasoning for DLA at the moment.
2024-07-05 00:43:45 +02:00
Ivan Krysak aed53c943c linked-lists: re-enable compute return value 2024-06-27 11:07:02 +02:00
Ivan Krysak 94a0ad6b93 Adopt reworked model::Type 2024-06-27 11:07:01 +02:00
Ivan Krysak 3705906074 Model: rename Type into TypeDefinition 2024-06-27 11:07:01 +02:00
Ivan Krysak dfa7478685 Adopt reworked model::Type 2024-06-27 11:05:51 +02:00
Ivan Krysak ac587cbb4f Model: rename Type into TypeDefinition 2024-06-27 11:05:48 +02:00
Ivan Krysak b2959e36df Minor improvements 2024-06-27 11:05:48 +02:00
Alessandro Di Federico 6e49fed965 FunctionMetadata::{ControlFlowGraph,Blocks} 2024-06-20 10:24:51 +02:00
Alessandro Di Federico d859db08a4 Fix tests 2024-06-20 10:24:51 +02:00
Alessandro Di Federico b350d12ad2 TTG: spread some optional: true around 2024-06-20 10:24:49 +02:00
Pietro Fezzardi 19e3818521 Make test for implicit C casts more robust
Before this commit, the test was implicitly relying on control-flow
recovery and on the specific order of the then/else scopes in an
if-statement.

This commit relaxes that requirement, since it's not part of what the
test is designed to test.
2024-05-30 12:00:50 +02:00
Djordje Todorovic 6d31e1c0a9 Add test for simplify-switch 2024-05-29 16:27:52 +02:00
Djordje Todorovic 46946df1d3 Adjust x86_64 collect-cfg test 2024-05-29 16:25:53 +02:00
Lauri Vasama e2f3f31093 Introduce RawFunctionType::Architecture 2024-05-29 15:43:35 +02:00
Alessandro Di Federico 22c97bce6b Drop model::Segment::Sections 2024-05-21 09:44:04 +02:00
Djordje Todorovic 0f46ec5578 Add tests for C cast expressions 2024-05-16 17:57:22 +02:00
Djordje Todorovic c58fec45e3 Add ImplicitModelCastPass
We introduce a new LLVM Pass that should detect implicit
casts, by marking the 3rd argument of ModelCast as `true`.
The backend will omit printing a cast expression if the
ModelCast is implicit one.
2024-05-16 17:57:22 +02:00
Andrea Gussoni 736e2509c0 Improve switch to if promotion test 2024-05-03 18:09:12 +02:00
Alessandro Di Federico f777eaf00f Introduce tests for RegisterUsageAnalyses 2024-04-19 18:33:00 +02:00
Andrea Gussoni c7b0fb7c06 Introduce switch to if promotion test 2024-04-05 09:10:18 +02:00
Pietro Fezzardi abb9344242 Relax tests to cope with DetectABI nondeterminism
Currently, some non-determinism upstream in the ABI detection pipeline
causes the return type of the `compute` function to be misdetected, even
if only very rarely.
Exclud this return type from tests for now.
Consider to re-add it in the future if we enforce stricter determinism,
or when EFA 4 is ready.
2024-03-25 18:08:35 +01:00
Pietro Fezzardi c48908c6a6 Revamp decompilation tests
Many old unit tests were too rigid, using the model and the LLVM IR.
This commit drops them, and replaces them with decompilation tests based
on revng-qa, relying on `revng model compare` to test model properties,
and on `FileCheck` to test that we emit specific constructs in C.

The new tests cover various features of the decompiler.
* DLA capability to recover complex data structure like linked-lists and
  arrays.
* DLA capability to update segment and section types, so that we emit
  nice looking accesses to segments in C.
* Capability to emit nice looking integer literals in C
* Capability to emit inline string literals in C and update the model
  types of the segments containg such string literals.
2024-03-19 09:44:00 +01:00
Andrea Gussoni 7d8b0139f3 SegregateStack: fix FileCheck directive
Add `%` in order to match precisely the argument LLVMIR value, and not
other spurious characters around.
2024-03-11 18:36:09 +01:00
Alessandro Di Federico 0c212b66d9 Relicense to MIT 2024-02-29 17:03:36 +01:00
Alessandro Di Federico 346b367c19 Drop revng efa-extractcfg 2024-02-09 10:04:25 +01:00
Alessandro Di Federico 23b3bc9e16 s/ImportModelFromC/ImportFromC/g 2024-02-09 09:03:34 +01:00
Alessandro Di Federico 3709deebc8 SegregateStack: use alloca for stack arguments
This commit:

1. Introduces an alloca for stack arguments of a function. This enables
   us to "write" to stack argument. In order to do so, we simply map the
   relevant stack portion to the alloca that, since it's a memory
   object, can be `load`'d from and `store`'d to.

   Note that `llvm::Argument`s are always scalar since if the original
   argument was an aggregate, it would have been passed as a pointer,
   which is a scalar.

   Note also that previously we were using scalar arguments as if they
   were *pointers* to the stack arguments. This commit fixes that too
   (and updates the tests accordingly).

2. Introduces an alloca for *scalar* stack arguments of a call site.
   The alloca is then mapped to the corresponding part of the stack.
   Previously, there was no redirection and negative offsets from
   `_stack_frame` would pop up.
2023-12-12 12:04:15 +01:00
Pietro Fezzardi 24cb43ce9c Make RawFunctionType::StackArgumentsType a TTR
This is homogeneous with all other nullable references to types in the
model, such as the StackFrameType in model::Function, and others.
2023-12-05 16:56:52 +01:00
Alessandro Di Federico 7dff660b36 propagatePrototypesInFunction: propagate names 2023-10-05 10:19:44 +02:00
Alessandro Di Federico 30c127267c Improve ModelToHeader and HeaderToModel tests
* Fix non-PrimitiveTypes with low IDs.
* Ensure we use `revng model compare` to test the model.
* Updates the name to reflect the recent changes in naming convention
  and in the way we represent `model::Type::ID`s.
2023-08-23 16:37:39 +02:00
Alessandro Di Federico 247879f7fc model::Type::ID: switch to progressive IDs
This commit switches `model::Type::ID` from being a GUID to be a
progressive number, in order to make things easier for humans.

On top of this, this commit introduces the following changes:

* TypeCopier: import all the necessary PrimitiveTypes and improve
  handling of CustomName.
* Move Kind as the last field of the key of each TupleTree type used in
  an `UpcastablePointer`.
* Update the ground truth of tests to ignore the `CustomName` in favor
  of focusing on `OriginalName`.
* Increase adoption of `model::Binary::makeType`, equivalent to
  `Binary.recordNewType(makeType<model::*Type>())`.
2023-08-23 16:14:04 +02:00
Pietro Fezzardi 9c755d89e6 Use only compact annotation macros in tests 2023-07-26 10:01:27 +02:00
Djordje Todorovic 1d3cacf6c2 HeaderToModel: support *80_t and *96_t primitives 2023-07-25 12:04:14 +02:00
Djordje Todorovic 943ceff61f Add tests for ImportModelFromC Analysis 2023-07-25 12:04:08 +02:00