Commit Graph

6113 Commits

Author SHA1 Message Date
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 642c72ef38 model::Type unit tests: decrease verbosity 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 70136ab7ef pipeline::Global: verify upon load 2023-08-23 16:14:04 +02:00
Alessandro Di Federico e63573ee81 Introduce model::Binary::path 2023-08-23 16:14:04 +02:00
Alessandro Di Federico 67be2c30b8 Introduce PrimitiveType::FirstNonPrimitiveID 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 68157ea370 for-propagated-prototypes: ignore debug info 2023-08-23 16:14:04 +02:00
Alessandro Di Federico fe18317bb7 model compare: introduce $ for exact size match
This commit introduces a change in `revng model compare` so that, for
dictionary entries whose keys start with `$`, it is ensured that the
length of the associated value (be it a list or a dictionary) is the
same.
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 4003269e17 revng analyze: fix typo in argument description
s/ArtifactToProduce/AnalysisToRun

The misspelling on the argument description made the --help option very
unhelpful in discovering the proper usage of the tool.
2023-08-23 15:54:29 +02:00
Pietro Fezzardi fb323592ca Merge branch 'feature/important-dla-improvements' 2023-08-21 16:23:03 +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 2120dd8108 Replace revng_unreachable with revng_abort
This ensures that we always detect nasty failures even in release
builds.
2023-08-18 15:48:55 +02:00
Pietro Fezzardi dfbb9a15b2 Backend: declare local variables for aggregates 2023-08-18 15:48:55 +02:00
Alessandro Di Federico 5b093ae38c Merge branch 'feature/progress-bars' 2023-08-01 14:59:49 +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 b188f91863 Introduce ContainerToTargetsMap::size() 2023-08-01 10:51:15 +02:00
Alessandro Di Federico 2c8c06e4ab Introduce ProgressListeners 2023-08-01 10:49:41 +02:00
Alessandro Di Federico abff5649b8 Merge branch 'feature/improved-navigation-and-look' 2023-07-31 16:05:53 +02:00
Giacomo Vercesi 9ea7d361f6 BinaryCrossRelations: fix mime type
Change the mime type of `BinaryCrossRelations` to `text/x.yaml`, so that
it's not base64-encoded when transmitting over GraphQL.
2023-07-31 16:05:52 +02:00
Giacomo Vercesi 2a99f50040 revng-model.ts: allow individual serdes
Allow the serialization and deserialization of individual model objects,
this is useful when these need to be exchanged individually across an
IPC boundary.
2023-07-31 16:05:52 +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
Giacomo Vercesi 7e96bb2189 revng.api: avoid NULL dereferencing in extract
The call to `rp_container_extract_one` can return a null pointer, add a
check that allows to avoid dereferencing it if this happens.
2023-07-31 16:05:51 +02:00
Alessandro Di Federico db6c6b1f90 Merge branch 'feature/hex-dump-container' 2023-07-31 14:19:10 +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
Kacper Kołodziej 7bec0190e8 Fix spelling in docstring 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
Giacomo Vercesi 878f9efcc8 daemon/test.py: change output capture
Change the way the tests capture the output of the daemon from `PIPE`
to `TemporaryFile`, as the latter avoids deadlocks related to the use of
the `Popen.wait` function in conjunction with `PIPE`.
2023-07-31 10:34:43 +02:00
Alessandro Di Federico aac84a8523 Merge branch 'feature/mass-testing-fixes' 2023-07-26 16:17:30 +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 8ca44dc32a for-propagated-prototypes: disable debug-info 2023-07-26 13:39:10 +02:00
Pietro Fezzardi 755b5176cf Drop unused method LayoutTypeSystem::getNodePtr 2023-07-26 10:41:18 +02:00