Commit Graph

6947 Commits

Author SHA1 Message Date
Lauri Vasama c93e9f17fc Add CTokenEmitter documentation 2026-02-13 08:41:39 +02:00
Lauri Vasama 61cbd93bab Overhaul PTMLEmitter
* PTMLEmitter is now a concept subsuming Emitter.
* PTMLStreamEmitter is a concrete emitter implementing PTMLEmitter.
* Indentation no longer includes PTML tags.
* PTMLTagEmitter is no longer default-constructible or reusable.
2026-02-13 08:39:03 +02:00
Lauri Vasama e127f433ad Factor indentation out of ptml::Emitter 2026-02-11 12:50:40 +02:00
Lauri Vasama 21fa80f831 Introduce ptml::Emitter concept 2026-02-11 12:48:33 +02:00
Lauri Vasama 021d99cc39 Rename ptml::Emitter to ptml::PTMLEmitter 2026-02-11 12:48:33 +02:00
Lauri Vasama 04b035749b Add ptml::tokens::Punctuation 2026-02-11 12:48:33 +02:00
Lauri Vasama f65ca96368 Add clift op interface descriptions 2026-02-11 12:48:33 +02:00
Lauri Vasama 8cbc0e6d24 Move CTokenEmitter into namespace ptml 2026-02-11 12:48:33 +02:00
Lauri Vasama 6b764ccbd1 Use octal escapes instead of hexadecimal
A hexadecimal escape sequences consume an unlimited number of
hexadecimal digits, causing invalid code emission in the case that the
sequence is followed by an unrelated hexadecimal digit.
2026-02-11 12:48:33 +02:00
Alessandro Di Federico 3976ba5859 Merge branch 'feature/pypeline-improve-memory-usage' 2026-02-05 15:01:41 +01:00
Giacomo Vercesi 01e9de1c34 compare_isolate.sh: don't compare declarations 2026-02-05 10:20:45 +01:00
Giacomo Vercesi 637e0771f9 isolate: further optimize isolated output
After eagerly splitting there's still some data remaining on the module
that should be deleted. Run a simple optimization pipeline on the split
module that should remove all the unneeded data and thus save memory.
2026-02-05 10:20:45 +01:00
Giacomo Vercesi d578bc6cd2 isolate: clone root module conservatively
In the new pipeline the root module is split off in its individual
isolated modules at the end of `isolate`. Before splitting, there are a
lot of global variables in the root module and only a small part is
going to be needed after splitting for each module. To avoid excessive
memory usage employ `ConservativeModuleCloner` in `Isolate` so that
only the needed global variables are actually cloned when splitting off.
2026-02-05 10:20:45 +01:00
Giacomo Vercesi 8654dafecd isolate: postpone dynamic function bodies
Postpone creating bodies of dynamic functions from the `isolate` pipe to
the `invoke-isolated-functions` pipe, since the body is only relevant in
the recompilation pipeline.
2026-02-05 10:20:45 +01:00
Giacomo Vercesi 798af62b87 Introduce helpers declarations
Re-organize the variants of `libtcg-helpers-*.bc` as such:
* `libtcg-helpers-full-$ARCH.bc`: unchanged, contains all helper
  function with their bodies and all CSVs.
* `libtcg-helpers-declarations-only-$ARCH.bc`: all helper
  functions have been turned to declarations. All CSVs (except a couple
  of special ones) have been dropped.
* `libtcg-helpers-to-inline-$ARCH.bc`: only functions with the
  `revng_inline` section retain their body. Only CSVs that are used by
  these functions are present.

Lift now loads only the `declarations-only` variant of helpers, as
their body is not required until `inline-helpers`. In `inline-helpers`
the `to-inline` variant is loaded and linked, which then allows the
helpers to be inlined.
2026-02-05 10:20:45 +01:00
Giacomo Vercesi 5250ffbb6b Introduce SimplePassManager
Add the `SimplePassManager` and `SimpleFunctionPassManager` classes
which add wrappers around the new LLVM pass manager. Change all the
applicable uses of the legacy pass manager with the wrapper.
2026-02-05 09:25:42 +01:00
Giacomo Vercesi 0ba82ce4f9 GCBI: explicitly store module reference
When calling `programCounterHandler`, instead of relying on the presence
of the `root` function, which might be absent, use a guaranteed
reference to the module.
2026-02-05 09:25:42 +01:00
Giacomo Vercesi 723ae8d801 GCBI: rework members and constructor
Move member declaration to the top of the class definition of
`GeneratedCodeBasicInfo` and initialize primitive members.
Merge the `run` method into the constructor since all uses have them
happening close to each other.
2026-02-05 09:25:42 +01:00
Alessandro Di Federico 2d8e7f78bb Merge branch 'feature/pypeline-tracing' 2026-02-04 15:39:40 +01:00
Giacomo Vercesi d7e605fe63 pypeline: add debug mode
Add the functionality the the pipeline infrastructure and CLI to run
individual pipe and analyses as subcommands instead of in-process. This
allow better debuggability of individual pipes.
2026-01-29 15:00:12 +01:00
Giacomo Vercesi 8f2d0191d7 Pipe: add needed_files functions
In preparation for debugging individual pipes add an additional method
to the `Pipe` interface, `needed_files`, which allows the pipe to
statically report which files it will request ahead of time.
2026-01-29 14:54:24 +01:00
Giacomo Vercesi 1b732501ae revng2 quick: swap artifact and binary args 2026-01-29 14:54:24 +01:00
Giacomo Vercesi 62c1b44a54 revng: allow execution while in a venv
If a venv is running, the `revng` script should re-exec to allow the
correct modules to be loaded and allow running the `main` function of
the respective modules.
2026-01-29 14:54:24 +01:00
Giacomo Vercesi 9d8845de95 revng2: do not print stacktrace on SIGINT 2026-01-29 14:54:06 +01:00
Giacomo Vercesi cda0a9e508 revng2: allow execution in build directory
Change the logic in `python/scripts/revng` to allow executing it as
`revng2`. This allows running `revng2` in the build directory.
2026-01-29 14:26:42 +01:00
Giacomo Vercesi 93a998ce93 TraceProgressListener: also record memory usage
Add the additional optional functionality to `TraceProgressListener` to
periodically poll the memory usage of the current process to plot as a
separate counter as part of the trace.
2026-01-20 12:29:12 +01:00
Giacomo Vercesi 54b84de3ea CUniquePtr: add missing #include 2026-01-20 12:29:12 +01:00
Giacomo Vercesi fd14580619 pipebox: improve signal handling
Improve the handling of signals by leveraging the `Py_AtExit`
functionality to trigger cleanup when the interpreter exits.
When receiving SIGINT handle it specially because exceptions in python
are only thrown when the interpreter is running and not when C code is.
2026-01-20 12:29:12 +01:00
Alessandro Di Federico 4093628b39 Merge branch 'feature/pre-segment-references' 2025-12-22 12:33:20 +01:00
Alessandro Di Federico 69e3d4bd9b revng_undefined_local_sp: mark as read-only
`revng_undefined_local_sp` was previously initially marked as using
inaccessible memory and, later on, marked as reading only memory.

Doing the latter right away is fine.

This commit also does not assume that function is always available.
2025-12-22 11:34:47 +01:00
Alessandro Di Federico afa52dfbd5 BinaryImporterHelper: use executableRanges
This ensures we don't create functions at addresses in a zone where
executable code is not allowed, despite being in a +x segment.
2025-12-22 11:34:47 +01:00
Alessandro Di Federico 250e69fdc7 Introduce MetaAddressRange 2025-12-22 11:34:47 +01:00
Alessandro Di Federico 4d5183a0ac Make layoutToLLVMFunctionType self-contained
`layoutToLLVMFunctionType` no longer needs to know the old return type.
2025-12-22 11:34:47 +01:00
Alessandro Di Federico 0bf97a9e68 getPointerSizedInteger: use model::Architecture
No need to get model::Binary.
2025-12-22 11:34:47 +01:00
Alessandro Di Federico 0aefce73e1 Drop dead: JumpTargetManager::isExecutableRange 2025-12-22 11:34:47 +01:00
Alessandro Di Federico 3118c4b6f7 CodeGenerator: drop NoMoreCodeBoundaries
It was unused code.
2025-12-22 11:34:47 +01:00
Alessandro Di Federico d79c66cb1b Introduce getOrCreateGlobal 2025-12-22 11:34:47 +01:00
Alessandro Di Federico b94e21a06e Handle inexistent --debug-log gracefully 2025-12-22 11:34:47 +01:00
Alessandro Di Federico 6b472471bf InvokeIsolatedFunctions: handle missing functions 2025-12-22 11:34:47 +01:00
Alessandro Di Federico 557baea6db Clifter: fix handling of Scalar returnMethod 2025-12-22 11:34:46 +01:00
Alessandro Di Federico 7d6c007d71 Progress: check ioctl(TIOCGWINSZ) result 2025-12-22 11:34:46 +01:00
Alessandro Di Federico 2c04325670 yield::Function::verify: allow empty blocks list 2025-12-22 11:34:46 +01:00
Alessandro Di Federico f443bcc6da Model migration tests: suppress output 2025-12-22 11:34:46 +01:00
Alessandro Di Federico ce4f6ef996 llvmName: turn into a free function 2025-12-22 11:34:46 +01:00
Alessandro Di Federico a1f9bd2d16 Minor changes 2025-12-22 11:34:46 +01:00
Alessandro Di Federico a36690b25a Merge branch 'feature/pe-dynamic-calls' 2025-12-22 11:32:17 +01:00
Alessandro Di Federico 9d76a2ff52 for-collect-cfg: test Windows dynamic calls 2025-12-22 11:31:54 +01:00
Alessandro Di Federico 87c61b021a importWellKnownModels: do not shadow class field
This led to a memory corruption.
2025-12-19 14:44:09 +01:00
Alessandro Di Federico 79a7df6bd0 RootAnalyzer: do not mark exitTB as noreturn 2025-12-19 14:44:09 +01:00
Alessandro Di Federico a394b1f7f5 RootAnalyzer: promote all PC-affecting CSVs 2025-12-19 14:44:09 +01:00