jasonmolenda updated this revision to Diff 550924.
jasonmolenda added a comment.

Updated back to my most recent version of this patch, thanks for the help all.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155905/new/

https://reviews.llvm.org/D155905

Files:
  lldb/include/lldb/API/SBProcess.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/API/SBProcess.cpp

Index: lldb/source/API/SBProcess.cpp
===================================================================
--- lldb/source/API/SBProcess.cpp
+++ lldb/source/API/SBProcess.cpp
@@ -1244,6 +1244,73 @@
   return sb_proc_info;
 }
 
+addr_t SBProcess::GetAddressMask(lldb::AddressMaskType type) {
+  LLDB_INSTRUMENT_VA(this, type);
+  addr_t default_mask = 0;
+  if (ProcessSP process_sp = GetSP()) {
+    switch (type) {
+    case eMaskTypeCode:
+      return process_sp->GetCodeAddressMask();
+    case eMaskTypeData:
+      return process_sp->GetDataAddressMask();
+    case eMaskTypeHighmemCode:
+      return process_sp->GetHighmemCodeAddressMask();
+    case eMaskTypeHighmemData:
+      return process_sp->GetHighmemDataAddressMask();
+    case eMaskTypeAny:
+      return process_sp->GetDataAddressMask();
+    }
+  }
+  return default_mask;
+}
+
+void SBProcess::SetAddressMask(lldb::AddressMaskType type, addr_t mask) {
+  LLDB_INSTRUMENT_VA(this, type, mask);
+  if (ProcessSP process_sp = GetSP()) {
+    switch (type) {
+    case eMaskTypeCode:
+      process_sp->SetCodeAddressMask(mask);
+      break;
+    case eMaskTypeData:
+      process_sp->SetDataAddressMask(mask);
+      break;
+    case eMaskTypeHighmemCode:
+      process_sp->SetHighmemCodeAddressMask(mask);
+      break;
+    case eMaskTypeHighmemData:
+      process_sp->SetHighmemDataAddressMask(mask);
+      break;
+    case eMaskTypeAll:
+      process_sp->SetCodeAddressMask(mask);
+      process_sp->SetDataAddressMask(mask);
+      process_sp->SetHighmemCodeAddressMask(mask);
+      process_sp->SetHighmemDataAddressMask(mask);
+      break;
+    }
+  }
+}
+
+addr_t SBProcess::FixCodeAddress(addr_t addr) {
+  LLDB_INSTRUMENT_VA(this, addr);
+  if (ProcessSP process_sp = GetSP())
+    return process_sp->FixCodeAddress(addr);
+  return addr;
+}
+
+addr_t SBProcess::FixDataAddress(addr_t addr) {
+  LLDB_INSTRUMENT_VA(this, addr);
+  if (ProcessSP process_sp = GetSP())
+    return process_sp->FixDataAddress(addr);
+  return addr;
+}
+
+addr_t SBProcess::FixAnyAddress(addr_t addr) {
+  LLDB_INSTRUMENT_VA(this, addr);
+  if (ProcessSP process_sp = GetSP())
+    return process_sp->FixAnyAddress(addr);
+  return addr;
+}
+
 lldb::addr_t SBProcess::AllocateMemory(size_t size, uint32_t permissions,
                                        lldb::SBError &sb_error) {
   LLDB_INSTRUMENT_VA(this, size, permissions, sb_error);
Index: lldb/include/lldb/lldb-enumerations.h
===================================================================
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -1283,6 +1283,15 @@
   eCustomCompletion = (1u << 25)
 };
 
+enum AddressMaskType {
+  eMaskTypeCode = 0,
+  eMaskTypeData,
+  eMaskTypeHighmemCode,
+  eMaskTypeHighmemData,
+  eMaskTypeAny,
+  eMaskTypeAll = eMaskTypeAny
+};
+
 } // namespace lldb
 
 #endif // LLDB_LLDB_ENUMERATIONS_H
Index: lldb/include/lldb/API/SBProcess.h
===================================================================
--- lldb/include/lldb/API/SBProcess.h
+++ lldb/include/lldb/API/SBProcess.h
@@ -398,6 +398,52 @@
   /// valid.
   lldb::SBProcessInfo GetProcessInfo();
 
+  /// Get the current address mask that may be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  ///     lldb may have different address masks for code and data
+  ///     addresses.  And it may have different masks for code
+  ///     and data in high memory, which differ from the low memory
+  ///     code/data masks.  Each of these can be requested, or
+  ///     most commonly, eMaskTypeAny can be requested, with the
+  ///     assumption that the masks are all identical.
+  ///
+  /// \return
+  ///     The address mask currently in use.  Bits which are not used
+  ///     for addressing will be set to 1 in the mask.
+  lldb::addr_t GetAddressMask(lldb::AddressMaskType type);
+
+  /// Set the current address mask that may be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  ///     lldb can have different address masks for code and data
+  ///     addresses.  And it can have different masks for code
+  ///     and data in high memory, which differ from the low memory
+  ///     code/data masks.  Each of these can be set, or
+  ///     most commonly, eMaskTypeall can be set, when all masks are
+  ///     identical.
+  ///
+  /// \param[in] mask
+  ///     The address mask to set.  Bits which are not used for addressing
+  ///     should be set to 1 in the mask.
+  void SetAddressMask(lldb::AddressMaskType type, lldb::addr_t mask);
+
+  /// Clear the non-addressable bits of an \a addr value and return a
+  /// virtual address in memory.
+  ///
+  /// Bits that are not used in addressing may be used for other purposes;
+  /// pointer authentication, or metadata in the top byte, or the 0th bit
+  /// of armv7 code addresses to indicate arm/thumb are common examples.
+  ///
+  /// When the target has provided an address mask of which bits are
+  /// valid for addressing, lldb can clear (or set, for high-memory addresses)
+  /// these bits.
+  lldb::addr_t FixCodeAddress(lldb::addr_t addr);
+  lldb::addr_t FixDataAddress(lldb::addr_t addr);
+  lldb::addr_t FixAnyAddress(lldb::addr_t addr);
+
   /// Allocate memory within the process.
   ///
   /// This function will allocate memory in the process's address space.
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to