Commit Graph

390 Commits

Author SHA1 Message Date
Giacomo Vercesi fede2f2090 ProgramRunner: allow redirection of streams
Change ProgramRunner's API to allow to optionally provide stdin and
capture stdout/stderr.
2025-05-05 17:28:48 +02:00
Giacomo Vercesi ec3231d7e6 TemporaryFile: fix move assignment
Fix the move assignment operator of `TemporaryFile`, which would behave
incorrectly if the object was moved into itself.
2025-05-05 16:02:40 +02:00
Giacomo Vercesi cf08ae41be Drop usage of llvm::ErrorOr<T>
Remove the last two remaining classes in revng which used the
`llvm::ErrorOr` class, replace them with `llvm::Expected`.
2025-05-05 16:02:40 +02:00
Khaled Ismaeel a52f1f17c2 Add automatic migrations in PipelineManager 2025-04-30 15:08:45 +02:00
Giacomo Vercesi 9ff471409e Remove some asserts from YAMLTraits
More soft-fails instead.
2025-04-28 12:58:27 +02:00
Ivan Krysak 1bce76f511 Bring name mangling out into a support helper 2025-04-24 13:22:14 +02:00
Ivan Krysak 79964eac74 Avoid ' misuse in error messages and comments 2025-04-17 16:41:21 +02:00
Ivan Krysak c6e38cd485 Return to using constant name builders
Because of how name builders used to lazy gather namespaces on the first
requested name, the objects were self mutating. As such only non-const
references could be used to pass them around.

Since that is no longer the case, this restores most of lost const
qualifiers.
2025-04-17 11:19:17 +03:00
Ivan Krysak 48a7822923 FunctionTags: adopt helper registry 2025-04-17 11:19:17 +03:00
Ivan Krysak 24b96e4480 IRHelpers: introduce a const callers helper 2025-04-17 11:19:17 +03:00
Ivan Krysak 76a2bffc94 Introduce an IR helper registry 2025-04-17 11:19:17 +03:00
Ivan Krysak 6a6b34b831 Introduce a general static registry helper 2025-04-17 11:19:17 +03:00
Ivan Krysak aa15d8ca21 Standardize abort-like function usage 2025-04-17 11:19:17 +03:00
Ivan Krysak 7b04cb99ae ptml::Annotations: introduce isMacro helper 2025-04-17 11:19:17 +03:00
Ivan Krysak 795a84dfe6 MetaAddressType: introduce a prefix consumer 2025-04-15 16:35:42 +03:00
Ivan Krysak 2e85653873 MetaAddressType: introduce Count 2025-04-15 16:35:42 +03:00
Ivan Krysak 3ff5b2cd3a Support: introduce unwrapError 2025-04-15 16:35:42 +03:00
Ivan Krysak 169383daa8 MetaAddress: introduce toIdentifier() method
It's equivalent to the existing `toString()` except for the fact that
it uses an identifier-friendly separator (`_`).
2025-04-15 16:35:42 +03:00
Ivan Krysak 3edb6cbb9b Minor improvements 2025-04-15 16:35:42 +03:00
Alessandro Di Federico c5c657d11b Lift: increase determinism 2025-04-15 15:31:10 +02:00
Andrea Gussoni a7e58b2749 GraphAlgorithms: improve return type
Improve the definition of the return type of `nodesBetween`, obtaining
the type of the elements in the `Set`s by passing through the
`GraphTraits::NodeRef` type, which enables us to handle more generic
situations, where `GraphT` includes a `View` over a graph.
2025-04-02 16:47:14 +02:00
Giacomo Vercesi a9a0fdc236 ELFImport: fix input file missing
When using revng through `revng daemon` the variable `InputPath` is not
populated, leading to `lddtree` failing silently. Fall back to the input
binary in the resume directory in case the the `InputPath` variable is
empty.
2025-03-14 13:05:39 +01:00
Giacomo Vercesi 042108bc44 ProgramRunner: cleanup
Clean up the `ProgramRunner` class:
* use llvm-provided wrappers and system-agnostic variables to compute
  the `Paths` variable
* pre-compute the list of path variables so it's not re-computed on
  every invocation of `run` or `isProgramAvailable`
* Wrap the logging code so that it's not triggered if the logger is
  disabled
2025-03-13 16:23:21 +01:00
Giacomo Vercesi 72d9b46e4b Error.h: improve joinErrors
Change the `joinError` functions to have stronger guarantees when used:
* Change the template signature to `RangeOf` to ensure that the
  container has `llvm::Error`s.
* Check that the size of the passed container is actually positive
  before deferencing `.begin()`.
2025-03-13 15:07:25 +01:00
Andrea Gussoni fe127200be GraphAlgorithms: improve comments 2025-03-11 12:25:24 +01:00
Ivan Krysak 705e4a5955 auto [...] -> auto &&[...] 2025-02-13 13:10:51 +02:00
Ivan Krysak fb95595b10 Backend: add comment emission support 2025-02-13 13:09:50 +02:00
Ivan Krysak 255bd256fe Backend: expose isStatement helper 2025-02-13 13:09:50 +02:00
Ivan Krysak ab1da1d986 FunctionTags: introduce Comment 2025-02-13 13:09:50 +02:00
Ivan Krysak d4ab801ab7 Rename range_with_value_type into RangeOf
Original name was reminiscent of the STL, but there's no such concept
in there, as such it's probably better to use revng naming convention
instead.
2025-02-13 13:09:50 +02:00
Ivan Krysak 66688134bf MetaAddress: rework hashing 2025-02-13 13:09:50 +02:00
Ivan Krysak 8841bc7144 Don't include model::NameBuilder from the binary 2025-02-13 13:09:50 +02:00
Giacomo Vercesi a06b380ce0 S3StorageClient: implement parallel upload
Allow uploads to S3 to be executed in parallel, this should reduce the
time it takes for a `save` operation to conclude.
2025-02-06 12:21:23 +01:00
Giacomo Vercesi 761e84fc9f Add revng::cantFail
Add the `revng::cantFail` function which allows to wrap functions with
`std::error_code` and check their result. This is analogous to
`llvm::cantFail` for `llvm::Error`.
2025-02-05 10:46:00 +01:00
Pietro Fezzardi e9528f4647 Fix getCopyType function type
This commit changes the prototype of getCopeType, so that it now takes 2
arguments.
1. The llvm::Type returned by the Copy function. This can be any scalar
   llvm::Type.
2. The llvm::type of the argument representing the reference to the
   value being copied. This should be a pointer-sized integer, where
   pointer-sized means with the same size of a pointer in the
   architecture in the input binary.

The second argument is not strictly necessary for now, because the whole
decompilation framework expects a binary with a single architecture,
hence a well defined unambiguous pointer size.
This will be used fully only when we start supporting multiple binaries.
Whenever that happens, if we haven't already fully dropped the Copy
helper function we will have to update the associated
OpaqueFunctionsPool to a type pair as key: the return type and the type
of the argument.
2025-01-29 15:17:15 +01:00
Pietro Fezzardi 1d7cf58907 Support LoadInst in mayReadMemory 2025-01-29 15:17:15 +01:00
Pietro Fezzardi f37c933ee7 Support StoreInst in hasSideEffects
Before this commit `StoreInst` weren't supported because they weren't
expected to reach the late stages of the decompilation pipeline where
the `hasSideEffects` helper function is used.
They were expected to be replaced by custom opcodes marked with
`FunctionTags::Assign`.

With the upcoming switch to the new decompilation pipeline, this helper
needs to be able to handle `StoreInst`s, because the custom opcode
functions will be dropped in favor of regular LLVM memory accesses.
2025-01-29 15:17:15 +01:00
Alessandro Di Federico 36edf810ef Introduce support for function pointers 2025-01-28 15:20:45 +01:00
Alessandro Di Federico 2128a80cc8 Preserve metadata after Function::deleteBody
Also, introduce and adopt a simple helper class to get this right.
2025-01-28 12:19:16 +01:00
Lauri Vasama bda55aac19 Add Clift C Backend 2025-01-10 08:04:20 +02:00
Lauri Vasama 7dd3743f89 Add missing keywords and operators in CBuilder 2025-01-02 11:25:32 +02:00
Andrea Gussoni 3dc66217a4 GraphAlgorithms: remove unused code 2024-12-18 10:51:36 +01:00
Andrea Gussoni fa69bd24e5 ScopeGraph: introduce the ScopeGraph
Introduce the `ScopeCloser` and `GotoTarget` annotations in the IR, and
the relative necessary machinery, needed to handle scope closer and goto
edges for the new backend.

A specialization of the `llvm::GraphTraits`, called `ScopeGraph`, that
is able to handle both the above mentioned annotations is provided.

For the `llvm::GraphTraits` implementation, we introduce the
`GeneratorIterator` class, which uses a coroutine to store the status of
the iteration.

A debug logger pass is added, so that we are able to test the
functionality with `FileCheck`.
2024-12-05 15:43:57 +01:00
Alessandro Di Federico 035e8e99a2 Minor changes 2024-12-03 12:12:44 +01:00
Alessandro Di Federico 686083bdab Remove mentions to revng-c 2024-11-21 15:54:23 +01:00
Alessandro Di Federico 143c315196 Merge revng-c into revng 2024-11-21 10:50:55 +01:00
Ivan Krysak 1eb80ecd2d Introduce an error creation helper 2024-11-06 15:20:37 +02:00
Alessandro Di Federico 16e01f43d6 Import revng-c's FunctionTags.h 2024-10-31 17:19:51 +01:00
Alessandro Di Federico d72f6413f0 Import revng-c's Support/IRHelpers.h 2024-10-31 17:19:51 +01:00
Alessandro Di Federico 36c344fc62 OpaqueFunctionsPool: improve assertion 2024-10-31 17:19:51 +01:00