[Lldb-commits] [PATCH] D124000: [lldb] Add FixAnyAddress to ABI plugins

David Spickett via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 28 06:57:55 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGb809c4cdb70a: [lldb] Add FixAnyAddress to ABI plugins (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124000

Files:
  lldb/include/lldb/Target/ABI.h
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Target/Process.cpp


Index: lldb/source/Target/Process.cpp
===================================================================
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -5831,7 +5831,7 @@
 Status Process::GetMemoryRegionInfo(lldb::addr_t load_addr,
                                     MemoryRegionInfo &range_info) {
   if (const lldb::ABISP &abi = GetABI())
-    load_addr = abi->FixDataAddress(load_addr);
+    load_addr = abi->FixAnyAddress(load_addr);
   return DoGetMemoryRegionInfo(load_addr, range_info);
 }
 
@@ -5866,7 +5866,7 @@
       range_end != LLDB_INVALID_ADDRESS &&
       // If we have non-address bits and some are set then the end
       // is at or beyond the end of mappable memory.
-      !(abi && (abi->FixDataAddress(range_end) != range_end)));
+      !(abi && (abi->FixAnyAddress(range_end) != range_end)));
 
   return error;
 }
Index: lldb/source/Commands/CommandObjectMemory.cpp
===================================================================
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -1688,7 +1688,7 @@
                // address size, etc.), the end of mappable memory will be lower
                // than that. So if we find any non-address bit set, we must be
                // at the end of the mappable range.
-               (abi && (abi->FixDataAddress(load_addr) != load_addr))) {
+               (abi && (abi->FixAnyAddress(load_addr) != load_addr))) {
       result.AppendErrorWithFormat("'%s' takes one argument:\nUsage: %s\n",
                                    m_cmd_name.c_str(), m_cmd_syntax.c_str());
       return false;
Index: lldb/include/lldb/Target/ABI.h
===================================================================
--- lldb/include/lldb/Target/ABI.h
+++ lldb/include/lldb/Target/ABI.h
@@ -126,6 +126,20 @@
   virtual lldb::addr_t FixDataAddress(lldb::addr_t pc) { return pc; }
   /// @}
 
+  /// Use this method when you do not know, or do not care what kind of address
+  /// you are fixing. On platforms where there would be a difference between the
+  /// two types, it will pick the safest option.
+  ///
+  /// Its purpose is to signal that no specific choice was made and provide an
+  /// alternative to randomly picking FixCode/FixData address. Which could break
+  /// platforms where there is a difference (only Arm Thumb at this time).
+  virtual lldb::addr_t FixAnyAddress(lldb::addr_t pc) {
+    // On Arm Thumb fixing a code address zeroes the bottom bit, so FixData is
+    // the safe choice. On any other platform (so far) code and data addresses
+    // are fixed in the same way.
+    return FixDataAddress(pc);
+  }
+
   llvm::MCRegisterInfo &GetMCRegisterInfo() { return *m_mc_register_info_up; }
 
   virtual void


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124000.425767.patch
Type: text/x-patch
Size: 2772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220428/3ffd4f25/attachment.bin>


More information about the lldb-commits mailing list