Commit Graph

2491 Commits

Author SHA1 Message Date
Massimo Fioravanti 7804dab1d5 Add model tracking visits
Implement the core visits that are able to inspect the model bypassing
the instrumentation.
2023-04-21 17:30:33 +02:00
Massimo Fioravanti fbb978629d Instrument model generator to track acceses 2023-04-21 17:30:33 +02:00
Massimo Fioravanti 776294cfe0 Fix: add missing methods of TrackingContainer
TrackingContainer was missing some methods needed to implement visits
2023-04-21 17:30:33 +02:00
Alessandro Di Federico 89fd543cc8 Merge branch 'feature/c-api-tracing' 2023-04-20 15:31:54 +02:00
Giacomo Vercesi a2b7d0e0bf PipelineC: add tracing
Add support for tracing onto the PipelineC. This is done by:
1. Creating wrapper functions for each PipelineC function with the
   script in `scripts/PipelineC_add_tracing.py`. These will call a
   special function called `wrap` which will ultimately call a method
   with a `_` prepended to the name
2. Conversion of all PipelineC methods in `PipelineC.cpp` to `static`
   and their rename with a `_` in front, in order for them to work with
   the wrapper function in (1)
3. Generation of 2 additional include files, one for types and one for
   functions, to be used by users of tracing files in order to have
   introspection.

These steps allow the creation of a trace file with the use of the
`REVNG_C_API_TRACE_PATH` environment variable. The traces can then be
used in conjunction with the `revng trace run` and `revng trace
inspect` commands.
2023-04-20 14:43:13 +02:00
Giacomo Vercesi 19bb38d32b PipelineC: fix UAF on rp_targets_list
The underlying rp_target pointer was not stable, switch to returning a
copy of the target instead.
2023-04-20 14:43:13 +02:00
Giacomo Vercesi 566cb6310b PipelineC: make indexed object stably sorted
Many Pipeline objects (Globals, Ranks, Kinds, Targets in a TargetList)
were ordered by load order, this makes the playback of traces difficult.
Moreover the order of loading of pipeline files also influences the
ordering of other elements (Step, Analys{is,esLists}). These are also
ordered to prevent incosistent ordering.
2023-04-20 14:43:13 +02:00
Giacomo Vercesi 8d89c6a318 PipelineC: rp_initialize: only use argc and argv
Switch from specifying `libraries` and `pipelines` in `rp_initialize`
and `rp_manager_create` to the use of command-line options that are to
be passed via `argc` and `argv` in `rp_initialize`.
2023-04-20 14:43:12 +02:00
Giacomo Vercesi 9a972009d1 PipelineC: size and const-correctness
Fix the return type (often mismatched from uint64_t to int) and the
const-correctness of many functions in PipelineC
2023-04-20 14:43:12 +02:00
Giacomo Vercesi 3bfdb95d92 revng.api: Improve Manager.run_analyses_list
Fix the case where the return of `rp_manager_run_analyses_list` returns
nullptr.
2023-04-20 14:43:12 +02:00
Giacomo Vercesi 07be2c1cae Allow the use of valgrind with python
This commit does 2 main things:
* Adds PYTHONMALLOC=1 environment variable when `--valgrind` is used
  to force python to use normal malloc instead of the custom allocator
  python normally uses that's not friendly with valgrind
* Add a suppression file to remove a couple of false-positives that
  happen consistently and generate useless noise
2023-04-20 14:43:12 +02:00
Giacomo Vercesi 4400924312 revng.cli: allow non-ELFs to be run with gdb
If needed, wrap the execution of scripts in `exec` to allow running
them with gdb. This is especially useful for running python scripts
that use cffi and being able to inspect the C/C++ side.
2023-04-20 14:43:11 +02:00
Giacomo Vercesi 59175e9925 daemon-self-test: do not fail() twice
There was a codepath in `revng-check-conventions` that would cause
`fail(e)` to be called twice. This would cause an exception on the
second invocation due to the undelying process being already terminated.
2023-04-20 14:43:11 +02:00
Giacomo Vercesi cf0921ab31 revng-check-conventions: allow ignoring InitRevng
Add an additional `rcc-ignore` rule to ignore the absence of `InitRevng`
in a `Main.cpp` file
2023-04-20 14:43:11 +02:00
Giacomo Vercesi 87543f835a revng.cli._commands: drop shebangs
Remove leftover shebangs from python files in `revng.cli._commands` as
those files are no longer executable on their own
2023-04-20 14:43:11 +02:00
Giacomo Vercesi a06df16b73 rcc: handle empty files gracefully
Fix two corner cases in `revng-check-conventions` where it would error
out when processing an empty file
2023-04-20 14:43:10 +02:00
Alessandro Di Federico 7ef337d825 Merge branch 'feature/llvm-16' 2023-04-19 14:44:01 +02:00
Alessandro Di Federico 8fd34ff0f7 pruneDICompileUnits: delegate to DIFinder 2023-04-14 08:36:05 +02:00
Alessandro Di Federico 5b8d5a8a41 Introduce OpaqueFunctionsPool::initializeFromName 2023-04-14 08:36:05 +02:00
Alessandro Di Federico 416c59c43b support.py: rework get_command
We introduce two paths where we can hard code search prefixes
(`/additional-search-prefixes`) and additional binaries paths
(`/share/revng/additional-bin-paths`).

This enables us to add to `additional-bin-paths` the configure-time
specified path of the preferred LLVM installation, instead of relying on
`PATH` to look up, e.g., `opt` at run-time.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico 40135aad97 Drop CSVAliasAnalysisPass 2023-04-13 18:11:48 +02:00
Alessandro Di Federico 8ef567471b LLVMContainer::mergeBackImpl: postpone verify
This commit moves module verification after cleanup.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico 060d26f212 Introduce getLocation(Instruction *) 2023-04-13 18:11:48 +02:00
Alessandro Di Federico 8c5f6628d1 Stop considering Instructions Taggable
Adding custom (i.e., non-dbg) metadata to Instructions has proven to be
too brittle.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico bce3555285 Drop CallToLifted tag
This commit drops the `CallToLifted` tag in favor of a
`getCallToIsolatedFunction` function which checks if the call has the
`IsolatedFunction` tag. The function also assumes that indirect calls
are calls to lifted functions.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico 6e0fc63b77 Reschedule AttachDebugInfo after InlineHelpers 2023-04-13 18:11:48 +02:00
Alessandro Di Federico 624cf2f160 AVI: add GVN
We should be able to drop this soon.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico b5607efce0 struct_initializer: mark as pure 2023-04-13 18:11:48 +02:00
Alessandro Di Federico 98b92a5b01 Prevent merging calls to isolated functions
SimplifyCFG with instruction sinking enabled sometimes can merge two
call sites that are identical at LLVM IR level, but originally come from
two distinct addresses in the original binary.

The nomerge attribute prevents this type of problematic deduplication.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico 79d9011b95 InlineHelpers: drop !dbg post-inlining 2023-04-13 18:11:48 +02:00
Alessandro Di Federico 401f731eda AttachDebugInfo: color instructions with a visit
We used to only color instructions in the same BasicBlock as the call to
`newpc`.  However, an instruction in the original binary can span
multiple BasicBlocks.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico 92b9ba5571 Import findPhiTreeLeaves 2023-04-08 08:42:24 +02:00
Alessandro Di Federico dc7f731bef Mark build_PlainMetaAddress as const 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 995d44cf73 Implement Location::{parent,back} 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 52ee85f55f Implement efa::BasicBlock::contains 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 0c991af685 AVI: after function_call, jump to anypc
We used to jump to the dispatcher, however we only sink to an
unreachable `anypc`. We were threfore significantly complicating the CFG
in case of indirect function calls.
2023-04-08 08:42:24 +02:00
Alessandro Di Federico f313a72453 DropHelperCalls: pass in loaded CSVs, not pointers
We used to pass pointers to helper functions, but we just need to pass
the loaded value: no need to leak the pointer to the CSV.
2023-04-08 08:42:24 +02:00
Alessandro Di Federico 19d59ffd73 Implement Segment::dump 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 6564fc0568 Minor changes 2023-04-08 08:42:24 +02:00
Alessandro Di Federico cdf1654f36 CSAA: do not use ptr, use pointee type 2023-04-08 08:42:24 +02:00
Alessandro Di Federico bc4833078c Fix InstCombine constructor invocation
In LLVM 12 the `InstCombine` constructor used to take a `bool`, in LLVM
16 it takes an integer. Implicit promotion was hiding this fact.
2023-04-08 08:42:24 +02:00
Alessandro Di Federico 1fa34fff9e revng opt: force legacy pass manager 2023-04-08 08:42:24 +02:00
Alessandro Di Federico e73543e430 AsmCall: add parameter attribute for element type
Fix calls to inline assembly
2023-04-08 08:42:24 +02:00
Alessandro Di Federico a0c0cd9468 extractFromConstantStringPtr: no stripPointerCasts 2023-04-08 08:42:24 +02:00
Alessandro Di Federico f7f47ceac6 VariableManager: drop autodetection of ${ARCH}CPU 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 71f754f811 PDBImporter: declare our own FilterOptions 2023-04-08 08:42:24 +02:00
Alessandro Di Federico de90eea243 Adopt get{Max,}PointerSizeInBits 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 53715af613 Adopt {PassBuilder::,}OptimizationLevel::O2 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 5be2c94a1b Fix literal signedness in comparisons 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 0570db6873 Drop dead llvm::initialize* invocations 2023-04-08 08:42:24 +02:00