[Lldb-commits] [lldb] r335710 - Move AddressClass to private enums since API doesn't provide any functions to manage it.

Tatyana Krasnukha via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 26 23:50:10 PDT 2018


Author: tkrasnukha
Date: Tue Jun 26 23:50:10 2018
New Revision: 335710

URL: http://llvm.org/viewvc/llvm-project?rev=335710&view=rev
Log:
Move AddressClass to private enums since API doesn't provide any functions to manage it.

This change allows to make AddressClass strongly typed enum and not to have issues with old versions of SWIG that don't support enum classes.

Modified:
    lldb/trunk/include/lldb/API/SBAddress.h
    lldb/trunk/include/lldb/API/SBInstruction.h
    lldb/trunk/include/lldb/Core/Address.h
    lldb/trunk/include/lldb/Core/Disassembler.h
    lldb/trunk/include/lldb/Symbol/ObjectFile.h
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/include/lldb/lldb-enumerations.h
    lldb/trunk/include/lldb/lldb-private-enumerations.h
    lldb/trunk/scripts/interface/SBAddress.i
    lldb/trunk/scripts/interface/SBInstruction.i
    lldb/trunk/source/API/SBAddress.cpp
    lldb/trunk/source/API/SBInstruction.cpp
    lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h

Modified: lldb/trunk/include/lldb/API/SBAddress.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBAddress.h (original)
+++ lldb/trunk/include/lldb/API/SBAddress.h Tue Jun 26 23:50:10 2018
@@ -80,8 +80,6 @@ public:
 
   lldb::SBLineEntry GetLineEntry();
 
-  lldb::AddressClass GetAddressClass();
-
 protected:
   friend class SBBlock;
   friend class SBBreakpointLocation;

Modified: lldb/trunk/include/lldb/API/SBInstruction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBInstruction.h?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBInstruction.h (original)
+++ lldb/trunk/include/lldb/API/SBInstruction.h Tue Jun 26 23:50:10 2018
@@ -36,8 +36,6 @@ public:
 
   SBAddress GetAddress();
 
-  lldb::AddressClass GetAddressClass();
-
   const char *GetMnemonic(lldb::SBTarget target);
 
   const char *GetOperands(lldb::SBTarget target);

Modified: lldb/trunk/include/lldb/Core/Address.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Address.h (original)
+++ lldb/trunk/include/lldb/Core/Address.h Tue Jun 26 23:50:10 2018
@@ -11,8 +11,8 @@
 #define liblldb_Address_h_
 
 #include "lldb/lldb-defines.h"      // for LLDB_INVALID_ADDRESS
-#include "lldb/lldb-enumerations.h" // for AddressClass::eInvalid
 #include "lldb/lldb-forward.h"      // for SectionWP, SectionSP, ModuleSP
+#include "lldb/lldb-private-enumerations.h" // for AddressClass
 #include "lldb/lldb-types.h"        // for addr_t
 
 #include <stddef.h> // for size_t
@@ -270,7 +270,7 @@ public:
             DumpStyle fallback_style = DumpStyleInvalid,
             uint32_t addr_byte_size = UINT32_MAX) const;
 
-  lldb::AddressClass GetAddressClass() const;
+  AddressClass GetAddressClass() const;
 
   //------------------------------------------------------------------
   /// Get the file address.
@@ -338,7 +338,7 @@ public:
   //------------------------------------------------------------------
   lldb::addr_t GetOpcodeLoadAddress(
       Target *target,
-      lldb::AddressClass addr_class = lldb::AddressClass::eInvalid) const;
+      AddressClass addr_class = AddressClass::eInvalid) const;
 
   //------------------------------------------------------------------
   /// Get the section relative offset value.
@@ -432,7 +432,7 @@ public:
 
   bool SetOpcodeLoadAddress(
       lldb::addr_t load_addr, Target *target,
-      lldb::AddressClass addr_class = lldb::AddressClass::eInvalid,
+      AddressClass addr_class = AddressClass::eInvalid,
       bool allow_section_end = false);
 
   bool SetCallableLoadAddress(lldb::addr_t load_addr, Target *target);

Modified: lldb/trunk/include/lldb/Core/Disassembler.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Disassembler.h?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Disassembler.h (original)
+++ lldb/trunk/include/lldb/Core/Disassembler.h Tue Jun 26 23:50:10 2018
@@ -22,8 +22,8 @@
 #include "lldb/Utility/ConstString.h" // for ConstString
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/lldb-defines.h"      // for DISALLOW_COPY_AND_ASSIGN
-#include "lldb/lldb-enumerations.h" // for AddressClass, AddressClass...
 #include "lldb/lldb-forward.h"      // for InstructionSP, DisassemblerSP
+#include "lldb/lldb-private-enumerations.h" // for AddressClass
 #include "lldb/lldb-types.h"        // for addr_t, offset_t
 
 #include "llvm/ADT/StringRef.h" // for StringRef
@@ -78,7 +78,7 @@ namespace lldb_private {
 class Instruction {
 public:
   Instruction(const Address &address,
-              lldb::AddressClass addr_class = lldb::AddressClass::eInvalid);
+              AddressClass addr_class = AddressClass::eInvalid);
 
   virtual ~Instruction();
 
@@ -102,11 +102,11 @@ public:
   virtual void
   CalculateMnemonicOperandsAndComment(const ExecutionContext *exe_ctx) = 0;
 
-  lldb::AddressClass GetAddressClass();
+  AddressClass GetAddressClass();
 
   void SetAddress(const Address &addr) {
     // Invalidate the address class to lazily discover it if we need to.
-    m_address_class = lldb::AddressClass::eInvalid;
+    m_address_class = AddressClass::eInvalid;
     m_address = addr;
   }
 
@@ -241,8 +241,8 @@ protected:
                      // when disassembling memory, you might run into data.
                      // This can help us to disassemble appropriately.
 private:
-  lldb::AddressClass
-      m_address_class; // Use GetAddressClass () accessor function!
+  AddressClass m_address_class; // Use GetAddressClass () accessor function!
+
 protected:
   Opcode m_opcode; // The opcode for this instruction
   std::string m_opcode_name;

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Tue Jun 26 23:50:10 2018
@@ -241,7 +241,7 @@ public:
   ///     architecture (and object for archives). Returns zero if no
   ///     architecture or object has been selected.
   //------------------------------------------------------------------
-  virtual lldb::AddressClass GetAddressClass(lldb::addr_t file_addr);
+  virtual AddressClass GetAddressClass(lldb::addr_t file_addr);
 
   //------------------------------------------------------------------
   /// Extract the dependent modules from an object file.

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Tue Jun 26 23:50:10 2018
@@ -739,7 +739,7 @@ public:
   //------------------------------------------------------------------
   lldb::addr_t GetCallableLoadAddress(
       lldb::addr_t load_addr,
-      lldb::AddressClass addr_class = lldb::AddressClass::eInvalid) const;
+      AddressClass addr_class = AddressClass::eInvalid) const;
 
   //------------------------------------------------------------------
   /// Get \a load_addr as an opcode for this target.
@@ -755,7 +755,7 @@ public:
   //------------------------------------------------------------------
   lldb::addr_t GetOpcodeLoadAddress(
       lldb::addr_t load_addr,
-      lldb::AddressClass addr_class = lldb::AddressClass::eInvalid) const;
+      AddressClass addr_class = AddressClass::eInvalid) const;
 
   // Get load_addr as breakable load address for this target. Take a addr and
   // check if for any reason there is a better address than this to put a

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Tue Jun 26 23:50:10 2018
@@ -814,26 +814,6 @@ enum FrameComparison {
 };
 
 //----------------------------------------------------------------------
-// Address Class
-//
-// A way of classifying an address used for disassembling and setting
-// breakpoints. Many object files can track exactly what parts of their object
-// files are code, data and other information. This is of course above and
-// beyond just looking at the section types. For example, code might contain PC
-// relative data and the object file might be able to tell us that an address
-// in code is data.
-//----------------------------------------------------------------------
-enum AddressClass {
-  eInvalid,
-  eUnknown,
-  eCode,
-  eCodeAlternateISA,
-  eData,
-  eDebug,
-  eRuntime
-};
-
-//----------------------------------------------------------------------
 // File Permissions
 //
 // Designed to mimic the unix file permission bits so they can be used with

Modified: lldb/trunk/include/lldb/lldb-private-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-enumerations.h?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-private-enumerations.h Tue Jun 26 23:50:10 2018
@@ -43,6 +43,26 @@ typedef enum AddressType {
 } AddressType;
 
 //----------------------------------------------------------------------
+// Address Class
+//
+// A way of classifying an address used for disassembling and setting
+// breakpoints. Many object files can track exactly what parts of their object
+// files are code, data and other information. This is of course above and
+// beyond just looking at the section types. For example, code might contain PC
+// relative data and the object file might be able to tell us that an address
+// in code is data.
+//----------------------------------------------------------------------
+enum class AddressClass {
+  eInvalid,
+  eUnknown,
+  eCode,
+  eCodeAlternateISA,
+  eData,
+  eDebug,
+  eRuntime
+};
+
+//----------------------------------------------------------------------
 // Votes - Need a tri-state, yes, no, no opinion...
 //----------------------------------------------------------------------
 typedef enum Vote { eVoteNo = -1, eVoteNoOpinion = 0, eVoteYes = 1 } Vote;

Modified: lldb/trunk/scripts/interface/SBAddress.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBAddress.i?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBAddress.i (original)
+++ lldb/trunk/scripts/interface/SBAddress.i Tue Jun 26 23:50:10 2018
@@ -89,12 +89,8 @@ public:
     SBAddress::GetOffset ();
 
     void
-    SetAddress (lldb::SBSection section, 
+    SetAddress (lldb::SBSection section,
                 lldb::addr_t offset);
-             
-
-    lldb::AddressClass
-    GetAddressClass ();
 
     %feature("docstring", "
     //------------------------------------------------------------------

Modified: lldb/trunk/scripts/interface/SBInstruction.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBInstruction.i?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBInstruction.i (original)
+++ lldb/trunk/scripts/interface/SBInstruction.i Tue Jun 26 23:50:10 2018
@@ -30,8 +30,6 @@ public:
     lldb::SBAddress
     GetAddress();
 
-    lldb::AddressClass
-    GetAddressClass ();
     
     const char *
     GetMnemonic (lldb::SBTarget target);

Modified: lldb/trunk/source/API/SBAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/source/API/SBAddress.cpp (original)
+++ lldb/trunk/source/API/SBAddress.cpp Tue Jun 26 23:50:10 2018
@@ -240,9 +240,3 @@ SBLineEntry SBAddress::GetLineEntry() {
   }
   return sb_line_entry;
 }
-
-AddressClass SBAddress::GetAddressClass() {
-  if (m_opaque_ap->IsValid())
-    return m_opaque_ap->GetAddressClass();
-  return AddressClass::eInvalid;
-}

Modified: lldb/trunk/source/API/SBInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBInstruction.cpp?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/source/API/SBInstruction.cpp (original)
+++ lldb/trunk/source/API/SBInstruction.cpp Tue Jun 26 23:50:10 2018
@@ -274,10 +274,3 @@ bool SBInstruction::TestEmulation(lldb::
     return inst_sp->TestEmulation(output_stream.get(), test_file);
   return false;
 }
-
-lldb::AddressClass SBInstruction::GetAddressClass() {
-  lldb::InstructionSP inst_sp(GetOpaque());
-  if (inst_sp)
-    return inst_sp->GetAddressClass();
-  return AddressClass::eInvalid;
-}

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h Tue Jun 26 23:50:10 2018
@@ -113,7 +113,7 @@ public:
 
   uint32_t GetAddressByteSize() const override;
 
-  lldb::AddressClass GetAddressClass(lldb::addr_t file_addr) override;
+  lldb_private::AddressClass GetAddressClass(lldb::addr_t file_addr) override;
 
   lldb_private::Symtab *GetSymtab() override;
 
@@ -191,7 +191,7 @@ private:
   typedef DynamicSymbolColl::iterator DynamicSymbolCollIter;
   typedef DynamicSymbolColl::const_iterator DynamicSymbolCollConstIter;
 
-  typedef std::map<lldb::addr_t, lldb::AddressClass>
+  typedef std::map<lldb::addr_t, lldb_private::AddressClass>
       FileAddressToAddressClassMap;
 
   /// Version of this reader common to all plugins based on this class.

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h?rev=335710&r1=335709&r2=335710&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h Tue Jun 26 23:50:10 2018
@@ -86,7 +86,7 @@ public:
 
   uint32_t GetAddressByteSize() const override;
 
-  lldb::AddressClass GetAddressClass(lldb::addr_t file_addr) override;
+  lldb_private::AddressClass GetAddressClass(lldb::addr_t file_addr) override;
 
   lldb_private::Symtab *GetSymtab() override;
 




More information about the lldb-commits mailing list