Commit Graph

88 Commits

Author SHA1 Message Date
Alessandro Di Federico cc28786000 DwarfToModelConverter: match existing functions
Unfortunately, in DWARF, there's no widespread indicator on whether a
function is regular ARM or Thumb. Therefore, in this commit, instead of
blindly creating a new function, we first check if, in the model, we
already have a function at that address.

This means that, if we have a Thumb function in DWARF, but it doesn't
already exist in the model, we will import as regular ARM, which is
wrong.
Specifically, this can happen with `revng model import debug-info`.
2026-05-15 11:27:34 +02:00
Alessandro Di Federico f11b9727b2 DwarfToModelConverter: detect cycles in getName
DW_AT_abstract_origin chains are walked recursively to find a DIE's
name, with no cycle check. Some binaries (e.g. debian-bookworm-mipsel
/usr/sbin/pwck) ship DWARF with a cycle in that chain, so getName ended
up in infinite recursion.

Make the walk iterative.
2026-05-15 11:27:33 +02:00
Alessandro Di Federico a10cb152fd DwarfToModelConverter: skip invalid child DIEs 2026-05-15 11:27:33 +02:00
Alessandro Di Federico 6894862ef2 Implement platform roots support
Refactor the binary import and dependency resolution infrastructure to
support multiple platforms (Linux, Windows, macOS) via a
configuration-driven root system.

Major changes:

* Overhaul PDB and DWARF importers for platform-aware debug info
  loading.
* Refactor LDDTree into a template-based architecture with
  platform-specific implementations (ELF, PE/COFF).
* Mostly rewrite the PDB importer, which had significant limitations.
2026-04-24 17:54:09 +02:00
Ivan Krysak b5f98fcae9 check-conventions: ban anonymous header namespaces 2026-02-25 12:47:27 +01:00
Alessandro Di Federico d9123fcd49 PECOFFImporter: fix handling of relocations
This commit ensures relocations imported from PE/COFF binaries have
generic `Address`. The fact that this was not the case lead to not
detecting dynamic calls.

The commit also improves logging and fixes the handling of maximum depth
visit of the PDB importer.
2025-12-19 14:44:07 +01:00
Giacomo Vercesi 265af3768f Binary importers: fix debug info detection
Fix the behavior of binary importers by propagating the path of the
input binary from revng2 downwards, allowing finding `.debug` files in
the correct paths.
2025-12-19 10:28:29 +01:00
Alessandro Di Federico 5820908675 Remove and ban \file 2025-12-16 17:41:55 +01:00
Giacomo Vercesi 47038d46ec Add ParseBinaryAnalysis to pypeline 2025-12-10 15:05:53 +01:00
Alessandro Di Federico c883bed765 Drop Logger's StaticEnabled feature 2025-10-31 17:25:03 +01:00
Ivan Krysak 256d2310b0 DwarfImporter: drop an unnecessary check 2025-10-13 10:26:41 +03:00
Ivan Krysak df681aa573 Ensure consumed errors are printed somewhere 2025-10-13 10:26:41 +03:00
Ivan Krysak 9bf93d3a30 Importers: add TODOs on diagnostic candidates 2025-10-13 10:26:41 +03:00
Ivan Krysak 77ea07c364 Minor improvements 2025-10-08 12:22:30 +03:00
Ivan Krysak c8de226f56 DwarfImporter: remove an input-dependent assert
Not checking for primitives there doesn't change anything anyway, as
`purge-invalid-types` model pass will clean anything invalid still
left after the importer.
2025-04-17 11:19:17 +03:00
Ivan Krysak c4f071dfe3 Importers: adopt primitive typedef flattening 2025-04-17 11:19:17 +03:00
Ivan Krysak 433af9ef6e Adopt the new name deduplication pass 2025-04-17 11:19:17 +03:00
Ivan Krysak f070f1f1e1 Model: sunset double name system 2025-04-17 11:19:17 +03:00
Giacomo Vercesi 6cdf6b9eda DebugInfo: do --verbose if logger is enabled
Enable running `fetch-debuginfo` in verbose mode if the logger is
enabled.
2025-03-13 18:03:50 +01:00
Alessandro Di Federico d4cd9beb77 Minor changes 2025-03-05 09:57:51 +01:00
Ivan Krysak 705e4a5955 auto [...] -> auto &&[...] 2025-02-13 13:10:51 +02:00
Alessandro Di Federico b523889742 DwarfImporter: try .debug before giving up
Also, improve logging.
2025-01-28 15:20:45 +01:00
Alessandro Di Federico 832840c307 Importers: ignore unmapped code
This commit ensures that parts of the model that must point to code
(specifically `Binary::EntryPoint`, `Binary::ExtraCodeAddresses` and
`Function::Entry`) actually point to a segment mapped as +x.
2024-11-28 15:22:10 +01:00
Alessandro Di Federico a0c670652c Improve usages of Expected<T> 2024-10-10 14:50:26 +02:00
Ivan Krysak 4bdc7f83b5 ABI: drop incomplete pascal support 2024-10-08 13:53:53 +02:00
Ivan Krysak 99e016f120 ABI: reorganize default ABI helpers 2024-10-08 13:53:52 +02:00
Giacomo Vercesi f8ffe38687 Unify cache directory logic
Make the cache directory logic uniform in Python and C++, move the
respective implementations under support since it's project-wide logic
and not exclusive to debug-info.
2024-10-01 13:38:13 +02:00
Alessandro Di Federico c8d4381297 s/Context &Ctx/Context &Context/g 2024-09-27 12:07:17 +02:00
Alessandro Di Federico 5c9b6ed9b3 Rename DILogger into Log 2024-08-16 13:27:00 +02:00
Alessandro Di Federico cba1d6fa51 PDBImporter: fix .pdb path lookup 2024-08-16 13:01:57 +02:00
Alessandro Di Federico 7b00473859 PDBImporter: rework .pdb search 2024-08-05 17:41:34 +02:00
Alessandro Di Federico 1981f5a433 Minor changes 2024-07-09 08:58:51 +02:00
Ivan Krysak 4a2db0ba4f UpcastablePointer: streamline empty behavior 2024-06-27 11:05:52 +02:00
Ivan Krysak dfa7478685 Adopt reworked model::Type 2024-06-27 11:05:51 +02:00
Ivan Krysak b6625e8913 Model: simplify fixModel pass
Instead of getting reimplemented/updated, it now just reuses normal
type verification routines.
2024-06-27 11:05:50 +02:00
Ivan Krysak 927e8006b9 Model: rename TypePath to DefinitionReference 2024-06-27 11:05:49 +02:00
Ivan Krysak ac587cbb4f Model: rename Type into TypeDefinition 2024-06-27 11:05:48 +02:00
Ivan Krysak b2959e36df Minor improvements 2024-06-27 11:05:48 +02:00
Massimo Fioravanti f783868dde Model: adopt tryGet instead of find() != end() 2024-06-20 09:57:36 +02:00
Alessandro Di Federico fe1dffcffd Add some missing includes
This is in preparation of reducing headers in Debug.h.
2024-05-03 21:52:40 +02:00
Alessandro Di Federico 9d12cd35e3 DwarfImporter: improve logging 2024-04-19 18:33:00 +02:00
Alessandro Di Federico 58d965f977 DwarfImporter::getName: consider abstract_origin 2024-04-19 18:33:00 +02:00
Alessandro Di Federico fcd04c163b DwarfImporter: hack to handle transparent unions 2024-04-19 18:33:00 +02:00
Alessandro Di Federico 9bbf1cc144 DwarfImporter: renumber UnionFields after cleanup 2024-04-11 15:29:39 +02:00
Alessandro Di Federico 7f1a15d1bb Model: ignore empty ExportedNames 2024-03-01 14:53:07 +01:00
Alessandro Di Federico 3cfd01e617 DwarfImporter: correctly handle Expected 2024-03-01 14:53:06 +01:00
Alessandro Di Federico 0da9d1e1a4 Model: fix handling of 0-sized arguments
We used to support having a single `void` argument. It was for some
C-compatibility ambitions, but just omitting the argument is perfectly
fine.

Also, the DWARF importer has been fixed to handle typedef'd void as
arguments.

More in general, arguments are now required to always have a size.
2024-03-01 14:53:06 +01:00
Alessandro Di Federico d9e649d272 Importer/Binary: improve logging 2024-03-01 14:53:06 +01:00
Alessandro Di Federico aa882f1bef Importer/Binary: fix default XDG cache path 2024-03-01 14:53:06 +01:00
Alessandro Di Federico 340b02c71e DwarfImporter: improve progress reporting 2024-03-01 14:23:08 +01:00