Home | History | Annotate | Download | only in Target
      1 //===-- CPPLanguageRuntime.h ---------------------------------------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #ifndef liblldb_CPPLanguageRuntime_h_
     11 #define liblldb_CPPLanguageRuntime_h_
     12 
     13 // C Includes
     14 // C++ Includes
     15 #include <vector>
     16 // Other libraries and framework includes
     17 // Project includes
     18 #include "lldb/Core/PluginInterface.h"
     19 #include "lldb/lldb-private.h"
     20 #include "lldb/Target/LanguageRuntime.h"
     21 
     22 namespace lldb_private {
     23 
     24 class CPPLanguageRuntime :
     25     public LanguageRuntime
     26 {
     27 public:
     28 
     29     class MethodName
     30     {
     31     public:
     32         enum Type
     33         {
     34             eTypeInvalid,
     35             eTypeUnknownMethod,
     36             eTypeClassMethod,
     37             eTypeInstanceMethod
     38         };
     39 
     40         MethodName () :
     41             m_full(),
     42             m_basename(),
     43             m_context(),
     44             m_arguments(),
     45             m_qualifiers(),
     46             m_type (eTypeInvalid),
     47             m_parsed (false),
     48             m_parse_error (false)
     49         {
     50         }
     51 
     52         MethodName (const ConstString &s) :
     53             m_full(s),
     54             m_basename(),
     55             m_context(),
     56             m_arguments(),
     57             m_qualifiers(),
     58             m_type (eTypeInvalid),
     59             m_parsed (false),
     60             m_parse_error (false)
     61         {
     62         }
     63 
     64         void
     65         Clear();
     66 
     67         bool
     68         IsValid () const
     69         {
     70             if (m_parse_error)
     71                 return false;
     72             if (m_type == eTypeInvalid)
     73                 return false;
     74             return (bool)m_full;
     75         }
     76 
     77         Type
     78         GetType () const
     79         {
     80             return m_type;
     81         }
     82 
     83         const ConstString &
     84         GetFullName () const
     85         {
     86             return m_full;
     87         }
     88 
     89         llvm::StringRef
     90         GetBasename ();
     91 
     92         llvm::StringRef
     93         GetContext ();
     94 
     95         llvm::StringRef
     96         GetArguments ();
     97 
     98         llvm::StringRef
     99         GetQualifiers ();
    100 
    101     protected:
    102         void
    103         Parse();
    104 
    105         ConstString     m_full;         // Full name:    "lldb::SBTarget::GetBreakpointAtIndex(unsigned int) const"
    106         llvm::StringRef m_basename;     // Basename:     "GetBreakpointAtIndex"
    107         llvm::StringRef m_context;      // Decl context: "lldb::SBTarget"
    108         llvm::StringRef m_arguments;    // Arguments:    "(unsigned int)"
    109         llvm::StringRef m_qualifiers;   // Qualifiers:   "const"
    110         Type m_type;
    111         bool m_parsed;
    112         bool m_parse_error;
    113     };
    114 
    115     virtual
    116     ~CPPLanguageRuntime();
    117 
    118     virtual lldb::LanguageType
    119     GetLanguageType () const
    120     {
    121         return lldb::eLanguageTypeC_plus_plus;
    122     }
    123 
    124     virtual bool
    125     IsVTableName (const char *name) = 0;
    126 
    127     virtual bool
    128     GetObjectDescription (Stream &str, ValueObject &object);
    129 
    130     virtual bool
    131     GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope);
    132 
    133     static bool
    134     IsCPPMangledName(const char *name);
    135 
    136     static bool
    137     StripNamespacesFromVariableName (const char *name, const char *&base_name_start, const char *&base_name_end);
    138 
    139     // in some cases, compilers will output different names for one same type. when tht happens, it might be impossible
    140     // to construct SBType objects for a valid type, because the name that is available is not the same as the name that
    141     // can be used as a search key in FindTypes(). the equivalents map here is meant to return possible alternative names
    142     // for a type through which a search can be conducted. Currently, this is only enabled for C++ but can be extended
    143     // to ObjC or other languages if necessary
    144     static uint32_t
    145     FindEquivalentNames(ConstString type_name, std::vector<ConstString>& equivalents);
    146 
    147 protected:
    148     //------------------------------------------------------------------
    149     // Classes that inherit from CPPLanguageRuntime can see and modify these
    150     //------------------------------------------------------------------
    151     CPPLanguageRuntime(Process *process);
    152 private:
    153     DISALLOW_COPY_AND_ASSIGN (CPPLanguageRuntime);
    154 };
    155 
    156 } // namespace lldb_private
    157 
    158 #endif  // liblldb_CPPLanguageRuntime_h_
    159