Commit Graph

6113 Commits

Author SHA1 Message Date
Giacomo Vercesi 89b17d2325 Python client: add user manual 2025-05-07 12:04:15 +02:00
Giacomo Vercesi 890a735610 test_docs: add ignoreoutput option for python
Sometimes the output of a command is not important, in these cases
`doctest` complains nonetheless. This commit introduces a
`IGNORE_OUTPUT` option which still allows checking that the command
executes correctly but skips the checking of the output with the
expected one. In addition to this the `test_docs` command now can parse
a `ignoreoutput` option in the python block which will:
* if numbers are specified (e.g. `ignoreoutput=1,2`): the specified
  line numbers will have `# doctest: +IGNORE_OUTPUT` added at the end
  of the specified line numbers.
* Without numbers (e.g. `{python ignoreoutput}`) then all lines will
  have a `# doctest: +IGNORE_OUTPUT` appended.
2025-05-07 10:48:54 +02:00
Giacomo Vercesi 3e3779498e Implement python interface for revng
Add a python interface (`revng.profile`) for interacting with the rev.ng
infrastructure as a whole; either through the CLI (`CLIProject`) or the
GraphQL API (`DaemonProject`).
2025-05-07 10:48:51 +02:00
Giacomo Vercesi de997ca2e4 python TTG: add mixins infrastructure
Add the infrastructure code needed to allow to add mixins to Tuple-Tree
Generated classes in python.
2025-05-07 10:48:50 +02:00
Ivan Krysak 31068f3d43 Pipeline: introduce an optional model path 2025-05-07 10:48:49 +02:00
Giacomo Vercesi 0f6b6e00bd Add revng init
Add a new `revng` command that allows to initialize a resume directory.
2025-05-07 10:48:49 +02:00
Giacomo Vercesi e3074ec29a revng artifact: omit kind
When working with `revng artifact`, omit the kind in both the output of
`--list` and the parameters taken specifying which targets to produce.
2025-05-07 10:48:48 +02:00
Giacomo Vercesi 8ba134bb45 TypedList: also implement mapping functions
Allow `TypedList`s to also be used as a dictionary-like structure if
the base class is keyable.
2025-05-07 10:48:47 +02:00
Giacomo Vercesi d8fffc0980 Improve Python's TTG typing
Improve the typing signatures in a few place in the `revng.tupletree`
package and in the auto-generated python TTGs.
2025-05-07 10:48:46 +02:00
Jurij Srebrnič 3050b291b1 Implement diff and apply for python model wrapper
Add the necessary code for the python model wrapper to allow diffing and
applying a diff.
2025-05-07 10:48:45 +02:00
Giacomo Vercesi 9d017ec94d TTG python: change template variable delimiter
Change the variable delimiter for the template used to generate the
tuple-tree wrapper from `'` to `#{` and `}#`.
2025-05-07 10:48:44 +02:00
Jurij Srebrnič 3bc63b833e Fixed python and typescript doc-test not executing 2025-05-07 10:48:23 +02:00
Giacomo Vercesi 6b7af19817 tuple_tree.ts: rename TypeHints to TypesMetadata
Rename the `TypeHints` to `TypesMetadata` (and related function
arguments) to better convey their contents.
2025-05-07 10:47:27 +02:00
Giacomo Vercesi 80ad54cc1d CMake: fix dependencies in typescript_module
The `typescript_module` function did not declare all its files
dependencies, leading to build errors. Add those dependencies to the
`DEPENDS` field.
2025-05-07 10:47:27 +02:00
Jurij Srebrnič c9731dc722 tuple_tree.ts: remove dead code in _applyDiff
Remove a branch from `_applyDiff` as the conditions for it to happen are
impossible.
2025-05-07 10:47:27 +02:00
Alessandro Di Federico 3db971b8b4 Pipeline: invalidate if *any* input is invalidated
We used to invalidate only if *all* inputs were invalidated.
2025-05-07 08:36:44 +02:00
Alessandro Di Federico 58b7144d53 Merge branch 'feature/llm-rename' 2025-05-06 16:25:03 +02:00
Giacomo Vercesi d63bba17c6 Implement LLMRenameAnalysis
Implement an analysis in revng which allows renaming the variables of a
C function via an LLM.
2025-05-06 09:59:46 +02:00
Giacomo Vercesi 50caf5ef9e Pipeline: allow analyses to not be available
An analysis can implement the `isAvailable` function which can tell
users if the analysis is available or not to be run.
2025-05-05 17:28:48 +02:00
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 e95ad01ff8 Implement revng llm-rename 2025-05-05 17:28:48 +02:00
Giacomo Vercesi 4e7469c1eb ModelTypeNames: fix context-action
The `data-action-context-location` applies to only the variable portion
of a function argument, not the type and the variable.
2025-05-05 17:28:48 +02:00
Giacomo Vercesi 591107cdce Overhaul PTML functionality
The logic of the `revng ptml` command was too tightly coupled with the
parsing of the xml. Overhaul the structure of the ptml code and split it
in two locations:
* `revng.ptml`: this module contains functions that allow easy
  manipulation of PTML, both for printing it and for obtaining the split
  metadata/text version.
* `revng.internal.cli._commands.ptml`: this implements the actual `revng
  ptml` command. This leverages the new logic in the `revng.ptml` module
  while maintaining the same functionality.
2025-05-05 17:28:48 +02:00
Giacomo Vercesi bfed42ed1e Add revng.support.get_llvmcpy helper
Add the `get_llvmcpy` helper function which returns an instance of
`LLVMCPy` which uses the `llvm-config` that's present in the search
paths.
2025-05-05 16:02:40 +02:00
Giacomo Vercesi 6fc6d38228 Remove argparse.FileType
Python 3.14 will deprecate `argparse.FileType` [1]. This is due to a
variety of factors, one of which is that the class leaks file
descriptors when used. Remove all usages in the codebase and instead
use a wrapper function for `open`.

[1] https://docs.python.org/3.14/library/argparse.html#argparse.FileType
2025-05-05 16:02:40 +02:00
Giacomo Vercesi 57c4f89dd3 python: remove relative imports
Remove all the relative imports from the python code that are not
relative to the current module (e.g. `from .<X> import ...`).
2025-05-05 16:02:40 +02:00
Giacomo Vercesi 101cac84ea FileContainer: use TemporaryFile
Ditch the manual management of the temporary file owned by
`FileContainer` and instead rely on the functionality offered by
`TemporaryFile`.
2025-05-05 16:02:40 +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
Giacomo Vercesi 6f481a3127 docs: fix tip admonition
Fix the tip admonition using the `:::` marker which is incorrect. Use
the `!!!` marker which is the correct one.
2025-05-05 16:02:40 +02:00
Giacomo Vercesi faf448f320 mass-testing-report: fix incorrect duration
Fix missing padding zeros when displaying the runtime of an execution.
2025-05-05 16:02:40 +02:00
Giacomo Vercesi 4757d57d59 StorageSaver: fetch initial credentials
Fetch the credentials contained in the URL from the `Synchronizer` when
initializing `StorageSaver`.
2025-05-05 16:02:40 +02:00
Giacomo Vercesi 19a3eb39c6 tupletree: suppress naming error
Suppress the flake8 error N808, due to the variables beginning with `_`.
2025-05-05 16:02:40 +02:00
Alessandro Di Federico e8947cced0 JTM::purgeTranslation: EliminateUnreachableBlocks 2025-04-30 17:40:55 +02:00
Pietro Fezzardi 5ede3207ba Merge branch 'feature/materialize-trivial-goto' 2025-04-30 16:20:37 +02:00
Andrea Gussoni 928edb0015 Pipeline: introduce materializetrivialgoto 2025-04-30 16:10:54 +02:00
Andrea Gussoni 80df1f3a42 MTGoTo: add unit test leveraging IDS ordering 2025-04-30 16:10:54 +02:00
Andrea Gussoni 8b87854a11 IDS: improve goto exit ordering criterion
Perform the IDS operation for the exit nodes corresponding to `goto`
blocks afterwards the other _standard_ exits have been processed.

In addition, order the `GotoBlock`s according to the `post_order` of the
target blocks of the `goto` themselves. This should maximize the
opportunities for later runs of `MaterializeTrivialGoto`.
2025-04-30 16:10:54 +02:00
Andrea Gussoni 6951611082 MTGoTo: introduce unit test 2025-04-30 16:10:54 +02:00
Andrea Gussoni 5698284bea MTGoTo: introduce the MaterializeTrivialGoto pass
The MaterializeTrivialGoto pass, tries to remove superfluous `goto` from
the `ScopeGraph`, by verifying that the resulting `ScopeGraph` does not
become cyclic or undecided.
In that case, it rolls back the changes.
2025-04-30 16:10:54 +02:00
Andrea Gussoni 307110fcfb ScopeGraph: introduce isScopeGraphDecided helper 2025-04-30 16:10:54 +02:00
Andrea Gussoni 2c19f69a74 ScopeGraph: ScopeGraph manipulation helpers
Introduce some helpers used to manipulate `goto_block` and
`scope_closer` annotations on the `ScopeGraph`.
2025-04-30 16:10:54 +02:00
Andrea Gussoni e093a1c7ed SelectScope: extract reusable helpers
Extract reusable helpers in `ScopeGraphAlgorithms.h`, so they can be
reused.
2025-04-30 16:10:54 +02:00
Andrea Gussoni 10055101c5 ScopeGraph: detail namespace to avoid clash
Define the `getScopeGraphSuccessors` and `getScopeGraphPredecessors`
in the `detail` namespace in order to avoid clashes.
2025-04-30 16:10:54 +02:00
Andrea Gussoni 8ff68174ea ScopeGraph: use snake_case for Markers 2025-04-30 16:10:54 +02:00
Andrea Gussoni 71988af041 Fix MIT license 2025-04-30 16:10:54 +02:00
Alessandro Di Federico 2ac23479a6 Merge branch 'feature/model-upgrade' 2025-04-30 15:10:54 +02:00
Khaled Ismaeel 2d5731b363 Add migration test 2025-04-30 15:08:45 +02:00
Khaled Ismaeel 9d80594ddc Bump model version to v3 2025-04-30 15:08:45 +02:00
Khaled Ismaeel a52f1f17c2 Add automatic migrations in PipelineManager 2025-04-30 15:08:45 +02:00