Commit Graph

369 Commits

Author SHA1 Message Date
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
Alessandro Di Federico c97438c5e4 DynamicHierarchy: ensure we call init last 2024-10-31 17:19:51 +01:00
Giacomo Vercesi 3fc9bbf8fc Uniform GzipStream
Uniform the functions/classes in GzipStream with the ones in ZstdStream.
2024-10-30 21:57:55 +01:00
Giacomo Vercesi 5b200df81a Implement ZstdStream
Implement the `zstdCompress` and `zstdDecompress` functions. Also
implement the `ZstdCompressedOstream` which is a `llvm::raw_ostream`
which compresses data on the fly.
2024-10-30 21:57:55 +01:00
Alessandro Di Federico a0c670652c Improve usages of Expected<T> 2024-10-10 14:50:26 +02:00
Giacomo Vercesi f8ffe38687 Unify cache directory logic
Make the cache directory logic uniform in Python and C++, move the
respective implementations under support since it's project-wide logic
and not exclusive to debug-info.
2024-10-01 13:38:13 +02:00
Alessandro Di Federico 4f1252042c Drop TaggedFunctionPass 2024-09-27 12:07:18 +02:00
Alessandro Di Federico bc064244d6 s/deserialize/fromString/g 2024-09-27 12:07:17 +02:00
Alessandro Di Federico c1cbb4e9a0 Initialize pointers to nullptr 2024-09-27 12:07:17 +02:00
Alessandro Di Federico 2cdedc71f4 s/serialize/toString/
We keep serialize for method dealing with streams.
If it returns a `std::string`, let's use `toString`.
2024-09-27 12:07:17 +02:00
Alessandro Di Federico baa1bd612e Introduce recreateWithoutBody
Similar to moveToNewFunctionType, but doesn't move the BasicBlocks.
2024-09-27 12:07:16 +02:00
Andrea Gussoni 70734496f3 GenericGraph: remove Undirected
Remove the `Undirected` `GraphTraits`
2024-09-20 16:08:50 +02:00
Andrea Gussoni eeca8f781c GenericGraph: introduce Undirected
Introduce the `Undirected` GraphTraits, which treats a `MutableEdgeNode`
`GenericGraph` as an undirected graph.

The trait uses the newly introduced `UndirectedChildIterator`, which is
a special custom iterator to get successors and predecessors
concatenated together.

Add some unit tests for `UndirectedChildIterator`.
2024-08-12 12:32:45 +02:00
Alessandro Di Federico 744184c90c Do not use CallBase::getCalledFunction
Use our wrapper, which does not return nullptr if the `FunctionType`s do
not match.
2024-08-07 16:07:59 +02:00
Alessandro Di Federico 80237078e4 setMetaAddressMetadata: use MDString 2024-08-07 16:07:59 +02:00
Alessandro Di Federico 15d72e580d MetaAddress::address*: simply ignore Type 2024-08-05 17:41:41 +02:00
Alessandro Di Federico 7b00473859 PDBImporter: rework .pdb search 2024-08-05 17:41:34 +02:00
Ivan Krysak 42c1ea30f0 Allow deserialize to be called on non-root types 2024-06-27 11:05:51 +02:00
Ivan Krysak ac587cbb4f Model: rename Type into TypeDefinition 2024-06-27 11:05:48 +02:00
Alessandro Di Federico b62bc8df91 s/FunctionMetadata/ControlFlowGraph/g 2024-06-20 10:24:51 +02:00
Alessandro Di Federico bce1d6c0f3 Adopt invalidation along the core pipeline 2024-06-20 10:24:50 +02:00
Alessandro Di Federico b5f7576573 Rework TupleTreeGenerator tracking 2024-06-20 10:24:50 +02:00