From 7e81512fe0b86751170b3023fa06c299aafe40a8 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Thu, 11 Jun 2026 15:19:00 -0700 Subject: [PATCH] Add depth property to inlined functions --- cle/backends/elf/elf.py | 10 +++++++++- cle/backends/inlined_function.py | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cle/backends/elf/elf.py b/cle/backends/elf/elf.py index a712af4d..52ee410c 100644 --- a/cle/backends/elf/elf.py +++ b/cle/backends/elf/elf.py @@ -938,7 +938,7 @@ def _load_die_lex_block( if sub_block is not None: block.child_blocks.append(sub_block) elif sub_die.tag == "DW_TAG_inlined_subroutine": - subr = InlinedFunction(sub_die.offset) + subr = InlinedFunction(sub_die.offset, _die_depth(sub_die)) low_pc, high_pc = self._load_low_high_pc_form_die(sub_die) if "DW_AT_entry_pc" in sub_die.attributes: subr.entry = sub_die.attributes["DW_AT_entry_pc"].value @@ -1663,4 +1663,12 @@ def _get_compatible_pcode_languages(reader): return languages +def _die_depth(die: DIE | None) -> int: + result = 0 + while die is not None: + die = die.get_parent() + result += 1 + return result + + register_backend("elf", ELF) diff --git a/cle/backends/inlined_function.py b/cle/backends/inlined_function.py index f2b6b495..19d6e156 100644 --- a/cle/backends/inlined_function.py +++ b/cle/backends/inlined_function.py @@ -10,6 +10,7 @@ class InlinedFunction: """ dwoffset: int + depth: int name: str | None = None ranges: list[tuple[int, int]] = field(default_factory=list) extern: bool = False