[all-commits] [llvm/llvm-project] 5d088b: [lldb] Track CFA pointer metadata in StackID (#157...

Felipe de Azevedo Piovezan via All-commits all-commits at lists.llvm.org
Fri Sep 12 09:18:10 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5d088ba30440d37f180f6b2e2f2fcc25d5c77018
      https://github.com/llvm/llvm-project/commit/5d088ba30440d37f180f6b2e2f2fcc25d5c77018
  Author: Felipe de Azevedo Piovezan <fpiovezan at apple.com>
  Date:   2025-09-12 (Fri, 12 Sep 2025)

  Changed paths:
    M lldb/include/lldb/Target/StackID.h
    M lldb/source/API/SBFrame.cpp
    M lldb/source/Expression/DWARFExpression.cpp
    M lldb/source/Target/RegisterContextUnwind.cpp
    M lldb/source/Target/StackFrameList.cpp
    M lldb/source/Target/StackID.cpp
    A lldb/test/API/macosx/arm-pointer-metadata-cfa-dwarf-expr/Makefile
    A lldb/test/API/macosx/arm-pointer-metadata-cfa-dwarf-expr/TestArmPointerMetadataCFADwarfExpr.py
    A lldb/test/API/macosx/arm-pointer-metadata-cfa-dwarf-expr/main.s

  Log Message:
  -----------
  [lldb] Track CFA pointer metadata in StackID (#157498)

[lldb] Track CFA pointer metadata in StackID

    In this commit:

9c8e71644227 [lldb] Make StackID call Fix{Code,Data} pointers (#152796)

We made StackID keep track of the CFA without any pointer metadata in
it. This is necessary when comparing two StackIDs to determine which one
    is "younger".

However, the CFA inside StackIDs is also used in other contexts through
    the method StackID::GetCallFrameAddress. One notable case is
DWARFExpression: the computation of `DW_OP_call_frame_address` is done
    using StackID. This feeds into many other places, e.g. expression
evaluation may require the address of a variable that is computed from
    the CFA; to access the variable without faulting, we may need to
preserve the pointer metadata. As such, StackID must be able to provide
    both versions of the CFA.

    In the spirit of allowing consumers of pointers to decide what to do
with pointer metadata, this patch changes StackID to store both versions
of the cfa pointer. Two getter methods are provided, and all call sites
    except DWARFExpression preserve their existing behavior (stripped
    pointer). Other alternatives were considered:

    * Just store the raw pointer. This would require changing the
comparisong operator `<` to also receive a Process, as the comparison
requires stripped pointers. It wasn't clear if all call-sites had a
non-null process, whereas we know we have a process when creating a
      StackID.

* Store a weak pointer to the process inside the class, and then strip
      metadata as needed. This would require a `weak_ptr::lock` in many
operations of LLDB, and it felt wasteful. It also prevents stripping
      of the pointer if the process has gone away.

This patch also changes RegisterContextUnwind::ReadFrameAddress, which
is the method computing the CFA fed into StackID, to also preserve the
    signature pointers.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list