[lldb] Fix heap.py crashes on recent Darwin embedded targets

Two fixes for the ptr_refs/cstr_refs/find_variable heap commands:

1. Move the `task` variable declaration into the common expression
  preamble. Previously it was only declared inside the `search_heap`
  code path, causing compilation errors when using `--ignore-heap`
  with stack or segment scanning.

2. On recent iOS, some shared cache __DATA_CONST pages are remapped to
  non-accessible at runtime, even though the Mach-O section metadata
  still marks them as readable. The segment scan would crash with
  EXC_BAD_ACCESS when reading these pages. Fix by querying actual
  VM region permissions via SBProcess.GetMemoryRegionInfo() and
  splitting sections at region boundaries to only scan readable
  portions.

rdar://172543652

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
GitOrigin-RevId: 9c254f182517a9bce0017beb575706004f978f23
1 file changed