Commit Graph

61 Commits

Author SHA1 Message Date
Alessandro Di Federico 11d8515f46 ModelToHeader: adjust blank lines 2024-11-27 17:18:12 +01:00
Alessandro Di Federico 143c315196 Merge revng-c into revng 2024-11-21 10:50:55 +01:00
Ivan Krysak 7a827b4ef5 Use doxygen for header grouping 2024-11-06 19:18:53 +02:00
Ivan Krysak 64446d0453 Adopt name builder across the model users 2024-11-06 19:18:53 +02:00
Alessandro Di Federico 98903f6b07 Move Ranks.h to revng 2024-11-04 15:09:56 +01:00
Ivan Krysak 1a35cbcb77 Introduce PTMLCTypeBuilder 2024-10-15 10:45:13 +03:00
Ivan Krysak 8aa7b55e2d PTMLIndentedOstream: rename into IndentedOstream 2024-10-15 09:13:28 +02:00
Ivan Krysak 8288bd68d2 PTMLCBuilder: rename into ptml::CBuilder 2024-10-15 09:13:28 +02:00
Pietro Fezzardi dfe3f4cb47 Rename revng C headers for decompiled code
Strip away the 'revng-' prefix from the filename.
2024-06-27 17:26:18 -04:00
Ivan Krysak 94a0ad6b93 Adopt reworked model::Type 2024-06-27 11:07:01 +02:00
Ivan Krysak c2b4fb70bb Model: rename TypePath to DefinitionReference 2024-06-27 11:07:01 +02:00
Ivan Krysak 3705906074 Model: rename Type into TypeDefinition 2024-06-27 11:07:01 +02:00
Pietro Fezzardi 7e44777c98 ModelToHeader: reduce lifetime of TypeInlineHelper 2024-06-07 17:59:06 +02:00
Pietro Fezzardi 84a40d0239 TypeInlineHelper: clean up members and methods 2024-06-07 17:59:06 +02:00
Pietro Fezzardi 8a7b5d4a25 ModelToHeader: refactor printTypeDefinitions
This refactoring makes the code less redundant, more concise,
and more explicit about how it handle's type inlining, while adding
documentation.
2024-06-07 17:58:36 +02:00
Pietro Fezzardi 746cf5b55d TypeInlineHelper: rename collectStackTypes method
to collectTypesInlinableInStacks and document it.
2024-05-29 15:34:26 +02:00
Alessandro Di Federico 0c212b66d9 Relicense to MIT 2024-02-29 17:03:36 +01:00
Pietro Fezzardi 8acf6c2f94 Allow type-less Segments in the Model 2024-02-09 09:04:23 +01:00
Giacomo Vercesi 7f8a83c34a ModelToHeader: add DisableTypeInlining option
When running ModelToHeader in HeaderToModel, all types need to be
defined in the header for clang to successfully parse the file. Add an
option to `ModelToHeaderOptions` that forces all types to be printed
regardless of stack or inlining rules.
2024-01-26 19:13:58 +01:00
Pietro Fezzardi 842b5e1075 Make Segment::Type a TupleTreeReference
This is homogeneous with all other nullable references to types in the
model, such as the StackFrameType in model::Function, and others.
2023-12-05 16:56:52 +01:00
Pietro Fezzardi a97287cef3 ModelToPTMLTypeHelpers: refactor APIs
This commit reorders the argument passed to various `printDeclaration`
and `printDefinition` helper functions, to make them more uniform across
each other, and to accept the same arguments in the same order.
2023-10-18 15:19:53 +02:00
Alessandro Di Federico 2a7e06df1f printFunctionPrototype: add newline after ABI
This commit forces getLocationAttribute's argument to be false.
2023-10-06 17:14:29 +02:00
Alessandro Di Federico cb8aa3d929 Adopt .prototype()
Also adopt `QualifiedType::getFunctionType` where appropriate in order
to unwrap typedefs.
2023-10-05 19:18:38 +02:00
Pietro Fezzardi 8d9f07d7a7 Change indentation of all decompiled C code
This commit changes the indentation of all the C code we emit, from 4
whitespaces to only 2 whitespaces.
2023-09-21 15:17:44 +02:00
Alessandro Di Federico f3d6bbb047 s/ThePTMLCBuilder/B/g 2023-08-23 16:40:54 +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 a207ef7c44 Minor changes 2023-08-23 16:12:51 +02:00
Djordje Todorovic 5c0167f792 Add ImportModelFromC Analysis
This analysis will be used for the following features:

1) Edit Type in the Model
2) Edit Function Prototype in the Model
3) Add Type to the Model

It takes C code as an input, parses it and produces a Model
type that represents the C type.
2023-07-24 11:51:47 +02:00
Djordje Todorovic e6b128c17b ModelToHeader: Print annotation __attributes__
This will be useful for `edit/add type` feature,
since we will be able to specify which ABI describes
a function, from the source code written in C.
2023-07-24 09:17:08 +02:00
Ivan Krysak e0b956b1c2 Model: rework edit path helpers from the ground up 2023-07-21 04:58:50 +00:00
Ivan Krysak fe0531868c Use Container::contains() where appropriate 2023-07-05 06:07:09 +00:00
Djordje Todorovic 286eb4d734 c-backend: Introduce PTMLCBuilder
This will be used to generate plain C.
2023-06-09 15:40:23 +02:00
Djordje Todorovic ca7bc2e442 c-backend: Generate Inline Types in PTML
In ModelToHeader generate Inline Types in PTML by handling
Structs, Unions and Enums.

In addition, during the ModelToHeader we avoid producing
Structs that describe stacks, and in the DecompileFunction we
produce the definition of it inline if it is safe (referenced
only once).
2023-05-03 13:13:28 +02:00
Massimo Fioravanti 87aef3fbad revng-c now uses Model accessors 2022-12-12 11:35:52 +01:00
Pietro Fezzardi ee0dc97464 Uniform printing return types of functions 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 7b66b9d7f6 TypeNames: fix redundant whitespaces in types 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 389a184fc2 Handle CABIFunctionTypes returning struct types 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 1bec5bd2ab Define all primitive types in dedicated header
This commit does the following:
- drops revngfloat.h
- disables printing primitive types in ModelToHeader
- creates a new header revng-primitive-types.h which includes all the
  declarations of all revng primitive types
2022-11-30 18:16:13 +01:00
Pietro Fezzardi 8aaa3ca92e Refactor PTML generation for functions 2022-11-16 16:02:09 +01:00
Pietro Fezzardi ff631c5364 PTMLC.h: switch to string-based return values 2022-11-15 15:54:20 +01:00
Pietro Fezzardi 2ec8b7e32c ModelToHeader: refactor creation of PTML Tags 2022-11-15 15:54:20 +01:00
Giacomo Vercesi e516d245c3 ModelToHeader: model functions are referenced
Change the output of ModelToHeader in regards to model functions: they
are referenced there while defined in the function-specific decompiled C
code
2022-11-10 17:27:53 +01:00
Pietro Fezzardi 73210ab4ae Adopt TupleTreeReference caching 2022-10-31 09:08:17 +01:00
Giacomo Vercesi eb2148e157 Add Location info for PrimitiveTypes 2022-10-11 17:36:29 +02:00
Giacomo Vercesi 72050274e2 getNamedCInstance: drop declaration parameter
In all cases this is false
2022-10-11 17:36:29 +02:00
Giacomo Vercesi e53033d0b8 Ranks: remove use of TypeField in locations
Use the new Ranks made available by revng
2022-10-11 17:36:29 +02:00
Giacomo Vercesi 8e996d2394 Output PTML in revng-c
Change the output of the backend of revng-c to PTML
2022-09-01 16:59:29 +02:00
Alessandro Di Federico d9d45fa79b ModelToHeader: fake functions no longer exist 2022-08-08 16:22:14 +02:00
Antonio Frighetto 19d7f8b2c9 Late decompilation: support model::Segment
Backend and InitModelTypes now handle the opaque `segmentRef` marker.
2022-07-19 13:53:21 +02:00