Commit Graph

3168 Commits

Author SHA1 Message Date
Giacomo Vercesi dc90bca33e revng/Support: split part of Statistics in OnQuit
Split the OnQuit functionality of Statistics as a separate header and
object file. Rework the interface to use lambdas instead of the
OnQuitInterface.
2023-09-06 15:23:43 +02:00
Pietro Fezzardi 851771eaa5 Improve tracing 2023-09-06 12:59:10 +02:00
Giacomo Vercesi 9223ada54f ImportModelFromCAnalysis: use TemporaryFile
Remove the usage of `createUniqueDirectory` that does not run cleanup on
crash/shutdown and instead use `TemporaryFile`.
2023-08-24 10:30:27 +02:00
Giacomo Vercesi e719b3b7e5 Add components to revng cli driver
This commit introduces the concept of `Component` to a pipeline step.
This, in turn, can be used by clients to figure out which artifacts are
produced by which revng component.
Additionally, this commit overhauls the `revng daemon-self-test`
command, renaming it to `revng graphql` and adding extra flexibility.
2023-08-23 17:45:36 +02:00
Alessandro Di Federico f3d6bbb047 s/ThePTMLCBuilder/B/g 2023-08-23 16:40:54 +02:00
Alessandro Di Federico 76984c9e8b Doxygen: strip trailing \param whitespace 2023-08-23 16:40:51 +02:00
Alessandro Di Federico cc126f63b9 Adopt model::PrimitiveType::fromName 2023-08-23 16:37:39 +02:00
Alessandro Di Federico 4a9329ebdd s/getIncommingTypesForT/getIncomingTypesFor/ 2023-08-23 16:37:39 +02:00
Alessandro Di Federico 17bf31526a Drop Revng prefixes 2023-08-23 16:37:39 +02:00
Alessandro Di Federico eaed9c7302 HeaderToModel: s/DILogger/Log/ 2023-08-23 16:37:39 +02:00
Alessandro Di Federico 4e1fed5fa0 ModelToHeader: omit _enum_max_value_* when editing 2023-08-23 16:37:39 +02:00
Alessandro Di Federico 489dddd0e7 TupleTreeReference::isValid is for assertions only 2023-08-23 16:37:39 +02:00
Alessandro Di Federico 2b97576ebb HeaderToModel: do not hardcode clang paths 2023-08-23 16:37:39 +02:00
Alessandro Di Federico 100a27bb1c HeaderToModel: emit forward declaration later
We used to emit the forward declaration for the type we were editing
*before* `#pragma once`. This was not good per se, but it also lead to
failures due to the introduction of `_PACKED`, which is not yet defined
at that stage.
2023-08-23 16:37:39 +02:00
Alessandro Di Federico c623e2d9d6 HeaderToModel: fix a couple of std::optional bugs 2023-08-23 16:37:39 +02:00
Alessandro Di Federico 5ab0659966 HeaderToModel: change CustomName only if different
This commit fixes two problems with HeaderToModel: we no longer emit
fields for padding and do not change the name if it's identical to the
old `.name()`.

This issues led to create fields for padding and, in case the entity was
originally missing the `CustomName`, to set `CustomName`s to the
generated name.
2023-08-23 16:37:39 +02:00
Alessandro Di Federico 330d2b6cc7 Model: rework how we name things
This commit:

* Introduces `_` as a prefix for all non-user entities we emit in
  decompiled code.
  Also, some names have been changed to be more concise.
  Specifically, the following entities have changed:
  `_ENUM_UNDERLYING`, `_ABI`, `_REG`, `_padding_at_`,
  `_artificial_struct_`, `_artificial_wrapper_`, `_stack`,
  `_break_from_loop_`, `_var_`, `_stack_arguments`,
  `_artificial_struct_returned_`, `_enum_max_value_`.
* Introduce _PACKED for `__attribute__((packed))`.
* `EnumEntry` name: drop the `EnumType` name prefix.
2023-08-23 16:37:39 +02:00
Alessandro Di Federico f81e9d615b dumpModelToHeader: introduce struct for options
This commit also introduces a new option for emitting code right after
the `#include` section.
2023-08-23 16:37:39 +02:00
Alessandro Di Federico f406e978e3 Adopt progressive model::Type::IDs 2023-08-23 16:37:39 +02:00
Alessandro Di Federico b5aa75f1f1 Introduce model::PrimitiveType::fromName 2023-08-23 16:14:05 +02:00
Alessandro Di Federico f51af94e8f TupleTreeReference::isValid is for assertions only 2023-08-23 16:14:05 +02:00
Alessandro Di Federico 0654d1d08f LLVMContainer: verify loaded module
This commit forces verification of the loaded `llvm::Module`, since
`llvm::parseIR` does not do it.
It also improves reporting parsing errors while loading the module.
2023-08-23 16:14:05 +02:00
Alessandro Di Federico f584308ead Introduce getLibrariesFullPath 2023-08-23 16:14:05 +02:00
Alessandro Di Federico 60733dc3af ConvertToCABIFunctionType: fix verification 2023-08-23 16:14:04 +02:00
Alessandro Di Federico a5b380b201 Model: rework how we name things
This commit improves the formalization of how we handle names.

The main changes are:

* Now `_` is a reserved prefix and all the generated names start with
  `_`.
* The model verification routine now checks that `CustomName`s in the
  global scope do not collide with any local namespace (e.g., fields of
  a `StructType`).
* We changed the prefix `prefix_` to `unreserved_` to better convey the
  fact that the prefix has been introduce to use an non-reserved name.
2023-08-23 16:14:04 +02:00
Alessandro Di Federico 247879f7fc model::Type::ID: switch to progressive IDs
This commit switches `model::Type::ID` from being a GUID to be a
progressive number, in order to make things easier for humans.

On top of this, this commit introduces the following changes:

* TypeCopier: import all the necessary PrimitiveTypes and improve
  handling of CustomName.
* Move Kind as the last field of the key of each TupleTree type used in
  an `UpcastablePointer`.
* Update the ground truth of tests to ignore the `CustomName` in favor
  of focusing on `OriginalName`.
* Increase adoption of `model::Binary::makeType`, equivalent to
  `Binary.recordNewType(makeType<model::*Type>())`.
2023-08-23 16:14:04 +02:00
Alessandro Di Federico 56268e94b0 VerifyHelper: handle fail in type verification
Before this commit, if there was a failure during the verification of a
type (which is recursive), we'd get an assertion in ~VerifyHelper due to
a "pending" type still being verified.
2023-08-23 16:14:04 +02:00
Alessandro Di Federico b8b483d052 Minor changes 2023-08-23 16:14:04 +02:00
Alessandro Di Federico a207ef7c44 Minor changes 2023-08-23 16:12:51 +02:00
Pietro Fezzardi f3bec5673a DLA: emit NonScalar nodes as StructTypes 2023-08-21 16:18:31 +02:00
Pietro Fezzardi 6c78270b6f DLA: CollapseSingleChild preserves NonScalar nodes 2023-08-21 16:18:31 +02:00
Pietro Fezzardi c3b69be618 DLA: ArrangeAccessesHierarchically keeps NonScalar 2023-08-21 16:18:31 +02:00
Pietro Fezzardi 5c132e7956 DLA: CollapseSCC preserves NonScalar nodes 2023-08-21 16:17:36 +02:00
Pietro Fezzardi 4e32f05aba DLA: mergeNodes now uses ArrayRef argument
This allows for a greater flexibility in its users.
2023-08-21 16:17:36 +02:00
Pietro Fezzardi cac7fee07d LayoutTypeSystemNode: add NonScalar field
This field represents that fact that a node of the DLA Graph is not a
scalar and it comes from the Model.
2023-08-21 16:17:36 +02:00
Pietro Fezzardi 552b8a96d9 DLA: print number of collapsed nodes for each Node 2023-08-21 16:17:21 +02:00
Pietro Fezzardi 72bedb7dfd TypeSystemPrinter: print DynamicFunctions 2023-08-21 12:29:31 +02:00
Pietro Fezzardi 659a461b02 TypeSystemPrinter: fix handling of 0-sized types 2023-08-21 12:11:34 +02:00
Pietro Fezzardi dfbb9a15b2 Backend: declare local variables for aggregates 2023-08-18 15:48:55 +02:00
Alessandro Di Federico e9470d6329 Pipeline: improve naming and docs 2023-08-01 12:17:20 +02:00
Alessandro Di Federico 14525d91f5 Adopt llvm::Task 2023-08-01 10:51:16 +02:00
Alessandro Di Federico 2c8c06e4ab Introduce ProgressListeners 2023-08-01 10:49:41 +02:00
Giacomo Vercesi f77d4d6d1f PTML: introduce data-scope-location
Introduce the new `data-scope-location` tag that's to be used for
switching between C and ASM. Include the tag when generating ASM
instructions.
2023-07-31 16:05:51 +02:00
Giacomo Vercesi db7ad24175 PipelineManager: add produceTargets with checks
Move much of the logic of `rp_manager_produce_targets` to a method
inside `PipelineManager`, add additional checks for the existence of the
targets that are requested to be produced.
2023-07-31 16:05:51 +02:00
Kacper Kołodziej 46e9ea0e10 HexDump implementation
HexDumpPipe dumps content of binary file in the similar way as hexdump
tool with addition of PTML markup for instructions addresses.

Continuous parts of binary code are wrapped with <span
data-location-definition=""></span> where data-location-definition
attribute contains Entry/BasicBlock/Instruction addresses in generic
form. <span> tags can be nested if byte(s) belong to many instructions
in code.

At the end of the line every <span> is closed and opened on the next
line again if it still applies to the next byte.

MetaAddress are converted to IntervalMetaAddress (which implements own,
optional-less operator-) and stored in boost::icl::intruval_map. This
map is used to get addresses of instructions to which each byte belongs.
2023-07-31 11:29:41 +02:00
Kacper Kołodziej c0f226fa70 Add const qualifiers to some functions
getJumpTargetBlock takes llvm::BasicBlock * as argument, but doesn't
need to modify it, so const it adds const to it and other functions that
are used by getJumpTargetBlock: findJumpTarget, isTranslated, getType,
isJumpTarget.
2023-07-31 11:29:40 +02:00
Giacomo Vercesi 2d8e11fe74 DecompileFunction: use scope-location
Change debug locations to use the new `scope-location` tag to allow
switching between C and ASM code.
2023-07-31 11:25:45 +02:00
Pietro Fezzardi 7442650396 MarkAssignments: emit LocalVariable for SelectInst
This is a temporary workaround for avoiding strings of exponential size
in the decompiled C code.
It is known not to be very robust, in that it's not guaranteed that it
will completely avoid the problem in the future, but it should cover the
most part of common problems.

A better fix would be to have a dedicated pass that looks at the
dataflow graph and decided where are the best points to inject local
variables, instead of blindly deciding to emit local variables for
SelectInst.
However, this would require much more work, and this problem is already
stalling merging features in revng, so for now we adopted this.
2023-07-26 16:07:26 +02:00
Pietro Fezzardi c94d0cb626 InitModelTypes: traverse BitCast and Freeze 2023-07-26 15:10:23 +02:00
Alessandro Di Federico 8e213ade74 TypeShrinking: shrink zext(value) == constant 2023-07-26 10:16:25 +02:00