608 Commits

Author SHA1 Message Date
Giacomo Vercesi f281b5930b revng.daemon: rework schema_generator.py
Rework both classes in schema_generator.py, main changes:
* Drop manager.pipeline_artifact_structure as it was used exclusively
  by SchemaGenerator and is no longer needed
* Rename SchemaGen and BindableGen to SchemaGenerator and
  DynamicBindableGenerator to better express their role, add
  docstrings that explain what they do
* Decouple Artifacts and Analyses discovery, since a step can have
  analyses and no artifacts (and vice-versa)
2022-08-26 09:50:37 +02:00
Massimo Fioravanti 42b623db06 Pipeline: rework CLI organization 2022-08-10 09:49:24 +02:00
Massimo Fioravanti 261a114d6d Pipeline: corner-case fix in backward deduction 2022-08-10 09:49:24 +02:00
Massimo Fioravanti 0bb115a4f3 revng-pipeline: rework syntax for targets
Was: step:container:p/a/t/h:kind
Now: step/container/p/a/t/h:kind
2022-08-10 09:49:24 +02:00
Massimo Fioravanti 4cd5abe2b0 revng-pipeline: introduce --produce and --analyze 2022-08-10 09:49:24 +02:00
Massimo Fioravanti 9c13f8dbdd Introduce revng-artifact 2022-08-10 09:49:24 +02:00
Massimo Fioravanti 96bd5835d8 revng-pipeline: rework file-to-container syntax 2022-08-10 09:49:24 +02:00
Giacomo Vercesi e23d238e85 revng.cli: explicitly initialize Commands
Commands now require a `setup` function, where the will register the
command instance manually
2022-08-10 09:49:24 +02:00
Alessandro Di Federico 45d563bc15 revng: use ld.so --preload instead of LD_PRELOAD 2022-08-08 13:55:25 +02:00
Alessandro Di Federico 82771be9b5 revng-model-dump: emit YAML 2022-08-08 13:55:25 +02:00
Djordje Todorovic 1243d1061c Introduce revng model hard-purge
In addition, introduce a new model Pass:

  revng model opt -prune-unsused-types
2022-07-28 15:02:55 +02:00
Djordje Todorovic fdb12947a2 Introduce revng model download-pdb 2022-07-28 14:52:50 +02:00
Giacomo Vercesi 7a9c88e9e7 Introduce revng ptml
This Oython tool will be used to easily work with PTML.

It currently features two subcommands:

* `cat` prints a PTML to the terminal, with color formatting if
  possible;
* `strip` will strip a file of the PTML markup;
2022-07-28 08:49:09 +02:00
Giacomo Vercesi 1a7503183a revng.cli: dynamically load commands
Now `revng.cli` houses the core command-line driver while the individual
commands have been moved to `revng.cli._commands` and are dynamically
loaded.
2022-07-28 08:48:30 +02:00
Giacomo Vercesi 09009836a1 PipelineC: expose globals verification 2022-07-28 08:47:46 +02:00
Giacomo Vercesi 3ec42fb3f8 _capi.py: don't wrap NULL in ffi.gc 2022-07-28 08:43:55 +02:00
Davide Depau 6dd80c7167 Fix lint issues from signal handler changes 2022-07-26 09:52:30 +02:00
Davide Depau 363fa21fe0 Introduce PipelineC API shutdown method 2022-07-22 21:04:03 +02:00
Giacomo Vercesi 152a624f47 revng.model: drop last version autodetection
revng.model.__init__ would dynamically import the latest version of
the model when imported, however this would break IDE hints as the
classes would not be properly detected. Instead we now manually
specify the last version in the __init__.py file.
2022-07-22 15:07:14 +02:00
Giacomo Vercesi 4486167d92 revng.model: add TypedList
Add a specialized list class to be used in the model. This will do
runtime instance checking to make sure that list-like fields in the
model only contain object of the correct type.
2022-07-22 14:56:15 +02:00
Giacomo Vercesi 93e1b1a9e8 revng.model: use safe version of yaml.Loader 2022-07-22 14:56:15 +02:00
Giacomo Vercesi 116d965117 revng.model: implement kw_only
Implement a constructor override for model classes that checks that the
constructor does not have positional arguments passed to it. This can
be dropped post-3.10 since it is implemented natively by kw_only.
2022-07-22 14:56:15 +02:00
Giacomo Vercesi 2329201ba1 revng.model: import contents of MetaAddress
This allows to have all the classes needed for model manipulation to
be available with `from revng.model import *`.
2022-07-22 14:56:15 +02:00
Giacomo Vercesi 018518d783 revng.model: remove tags from dumper
Tags in the yaml have been deprecated for a while, remove them from
being outputted from YAML dumper.
2022-07-22 14:56:15 +02:00
Alessandro Di Federico f84b87e63e Minor changes 2022-07-21 19:01:37 +02:00
Davide Depau d02237ea5e python: import CIterable from collections.abc
Importing from `collection` has been deprecated for a while now.
2022-07-05 10:31:36 +02:00
Giacomo Vercesi 80afd71721 Add singleTargetFilename to pipelines
A step's artifacts now include singleTargetFilename, which gives a
suggested filename to use when a single element is extracted from the
underlying container.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi f02aecfccb Python API: produce now returns a dict
When requesting a produce for multiple targets the result will be a
dictionary mapping "<target>:<result>". This also changes the GraphQL
API where a json-serialized string is returned.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 30ef77e6fa GraphQL: introduce queries to retrieve globals
Change the schema to allow introspection of context globals.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 636299785d GraphQL: introduce artifacts introspection
Allow artifacts information (container and kind) to be retrieved from
the Step type.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 62e9baeddb GraphQL: rework schema to be camelCase
GraphQL conventions, encourage the use of camelCase for query fields
and PascalCase for types, as detailed here:

    https://graphql-rules.com/rules/naming-fields-args
2022-06-29 14:50:58 +02:00
Giacomo Vercesi df72bb68b0 GraphQL: introduce CORS headers
Add CORS headers to the graphql api. These are set via the REVNG_ORIGINS
environment variable.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 59b01a9f1b revng.daemon: asyncify all PipelineC calls
In typical scenarios most PipelineC calls block for too long, this is
debilitating to the GraphQL API since coroutines are run
cooperatively. This commit moves all PipelineC calls in a separate
thread.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 2df691535d Pipeline: Make recalculateAllPossibleTargets
`recalculateAllPossibleTarget` is now a private member of
PipelineManager This was done since all calls that can trigger a change
in the target list have been isolated and the call is done implicitly.
This removes rp_manager_recompute_all_available_targets from PipelineC,
since it was added as a stopgap until the above was implemented.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 487af0f4b0 Do not pass file paths to revng from PipelineC
Allow deserializing containers from a byte string rather than pointing
to a file, this allows revng to have an opaque workdir.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 2fc11ab055 revng daemon: introduce notifications
Add the possibility of passing a list of FIFOs to `revng daemon`. These
can be used to notify an external program when a non-reproducible change
(binary, context) has occurred.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 93f776217d Split revng.daemon.schema
Splits the module in 2:

* static_handlers: as the name suggests this is where handlers for
  static endpoints (e.g. not dependent on the pipeline) are implemented
* schema_generator: this is where the schema is generated from a
  manager's pipeline definition, together with the handler for the
  autogenerated endpoint
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 05dc27715d Improve pipeline saving capabilities
This commit introduces some changes to how the revng pipeline handles
serializing to disk. Specificaly:

* Pipeline globals (specifically model.yml) are better handled if they
  are in a subdirectory. They are now saved in the "context"
  subdirectory.
* In python:revng.api the pipeline is serialized whenever there is a
  non-reproducible change to the state (e.g. binary upload or model
  change).
  In the case of analyses this is done conservatively by checking that
  the diff produced is not empty.
* The logic for computing a step's subdirectory has been moved to the
  pipeline runner, consequently if a step is asked to serialize it
  will not create any subdirectories.
* Functionality for saving a single step/context has been exposed in
  Pipeline C.
* Finally, all path concatenations are now handled by
  llvm::sys::path::append, for extra os-agnosticism.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi a03547ae66 revng.api: drop wrong exception in get_target
If a step:container does not have any targets, return an empty list
instead of raising an exception.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 6c2d176827 python.api: introduce lock in destructors
Due to the possibly multi-threaded nature of the python C API, use
the C API lock also when invoking destructors.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi ffab18ee48 revng daemon: identify valid port
This commit resolves a non-deterministic test failure in `revng daemon`.

When running daemon tests, `randint` was used for selecting the listen
port, this caused test failures when the same port number was used for
reused. This has been replaced with the use of port 0 that guarantees
the use of an unused port and psutil to find the port number once it has
been bound by the daemon process.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi dd08f2bf96 revng daemon --help: add description
Add an extended description to the command `revng daemon` which
details the the environment variables at play when running it.
2022-06-29 14:50:58 +02:00
Giacomo Vercesi 79c6086d0d revng.api: autodetect files
`revng.api` now autodetects files (libraries, pipeline yamls) for
initialization via the same mechanism used by `revng.cli`. This removes
the need to pass them via environment variables from `revng daemon`
and allows easy interaction with python's C API.
2022-06-29 14:49:29 +02:00
Giacomo Vercesi a741e39f76 revng-check-conventions: introduce prettier
Adds the formatting tool prettier to allow formatting JS, TS, JSON,
YAML and HTML files.
2022-06-28 15:29:09 +02:00
Alessandro Di Federico f4684e244d Switch to new testsuite 2022-06-20 19:04:18 +02:00
Giacomo Vercesi 1cc8c2c20c Fix pyYAML type error
Remove code in revng.cli.model_dump and override_by_name that was used
when the model had tags. The code subclassed the default pyYAML loader
to ignore unknown tags to allow reading the model data easily. Since the
model no longer has tags this code is dead and can be removed.
2022-06-13 18:35:37 +02:00
Alessandro Di Federico d37c3d3dd8 Fix revng --prefix
When running subcommands from a `revng` script the build directory and
the root directory were being swapped.
2022-05-31 11:30:10 +02:00
Giacomo Vercesi 2f0519c3c5 GraphQL: Introduce run_all_analyses 2022-05-24 10:56:04 +02:00
Giacomo Vercesi e5704ede11 Make Python API thread-safe and non-blocking
Since PipelineC is not thread-safe, add a lock to all function calls to
it to avoid any thread safety-related issues.

At the same time, use a thread pool to run "expensive" PipelineC
functions in GraphQL (specifically `produce_target` and `run_analysis`)
to avoid problems due to the cooperative nature of Python coroutines.
2022-05-24 10:56:04 +02:00
Giacomo Vercesi 7052f2a8a0 Support analyses and globals in Python
This commit adds the newly implemented functionality in PipelineC both
in revng.api and the graphql api, allowing:

* retrieval of global variable names
* unwrapping of a single target
* execution of analyses
2022-05-24 10:56:02 +02:00