brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · ba6e1f3 Raw
75 lines · c
1//===-- MachVMRegion.h ------------------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9//  Created by Greg Clayton on 6/26/07.10//11//===----------------------------------------------------------------------===//12 13#ifndef LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_MACHVMREGION_H14#define LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_MACHVMREGION_H15 16#include "DNBDefs.h"17#include "DNBError.h"18#include <mach/mach.h>19 20class MachVMRegion {21public:22  MachVMRegion(task_t task);23  ~MachVMRegion();24 25  void Clear();26  mach_vm_address_t StartAddress() const { return m_start; }27  mach_vm_address_t EndAddress() const { return m_start + m_size; }28  mach_vm_size_t GetByteSize() const { return m_size; }29  mach_vm_address_t BytesRemaining(mach_vm_address_t addr) const {30    if (ContainsAddress(addr))31      return m_size - (addr - m_start);32    else33      return 0;34  }35  bool ContainsAddress(mach_vm_address_t addr) const {36    return addr >= StartAddress() && addr < EndAddress();37  }38 39  bool SetProtections(mach_vm_address_t addr, mach_vm_size_t size,40                      vm_prot_t prot);41  bool RestoreProtections();42  bool GetRegionForAddress(nub_addr_t addr);43 44  uint32_t GetDNBPermissions() const;45  std::vector<std::string> GetFlags() const;46  std::vector<std::string> GetMemoryTypes() const;47 48  const DNBError &GetError() { return m_err; }49 50protected:51#if defined(VM_REGION_SUBMAP_SHORT_INFO_COUNT_64)52  typedef vm_region_submap_short_info_data_64_t RegionInfo;53  enum { kRegionInfoSize = VM_REGION_SUBMAP_SHORT_INFO_COUNT_64 };54#else55  typedef vm_region_submap_info_data_64_t RegionInfo;56  enum { kRegionInfoSize = VM_REGION_SUBMAP_INFO_COUNT_64 };57#endif58 59  task_t m_task;60  mach_vm_address_t m_addr;61  DNBError m_err;62  mach_vm_address_t m_start;63  mach_vm_size_t m_size;64  natural_t m_depth;65  RegionInfo m_data;66  vm_prot_t m_curr_protection; // The current, possibly modified protections.67                               // Original value is saved in m_data.protections.68  mach_vm_address_t69      m_protection_addr; // The start address at which protections were changed70  mach_vm_size_t71      m_protection_size; // The size of memory that had its protections changed72};73 74#endif // LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_MACHVMREGION_H75