LanguageRuntime.h revision 293b98f5e24ef736766db37feedfefd3b215a0ce
1//===-- LanguageRuntime.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_LanguageRuntime_h_ 11#define liblldb_LanguageRuntime_h_ 12 13// C Includes 14// C++ Includes 15// Other libraries and framework includes 16// Project includes 17#include "lldb/lldb-public.h" 18#include "lldb/Breakpoint/BreakpointResolver.h" 19#include "lldb/Breakpoint/BreakpointResolverName.h" 20#include "lldb/Core/PluginInterface.h" 21#include "lldb/lldb-private.h" 22#include "lldb/Core/ValueObject.h" 23#include "lldb/Core/Value.h" 24#include "lldb/Target/ExecutionContextScope.h" 25 26namespace lldb_private { 27 28class LanguageRuntime : 29 public PluginInterface 30{ 31public: 32 virtual 33 ~LanguageRuntime(); 34 35 static LanguageRuntime* 36 FindPlugin (Process *process, lldb::LanguageType language); 37 38 virtual lldb::LanguageType 39 GetLanguageType () const = 0; 40 41 virtual bool 42 GetObjectDescription (Stream &str, ValueObject &object) = 0; 43 44 virtual bool 45 GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope) = 0; 46 47 virtual bool 48 GetDynamicTypeAndAddress (ValueObject &in_value, 49 lldb::DynamicValueType use_dynamic, 50 TypeAndOrName &class_type_or_name, 51 Address &address) = 0; 52 53 // This should be a fast test to determine whether it is likely that this value would 54 // have a dynamic type. 55 virtual bool 56 CouldHaveDynamicValue (ValueObject &in_value) = 0; 57 58 virtual void 59 SetExceptionBreakpoints () 60 { 61 } 62 63 virtual void 64 ClearExceptionBreakpoints () 65 { 66 } 67 68 virtual bool 69 ExceptionBreakpointsExplainStop (lldb::StopInfoSP stop_reason) 70 { 71 return false; 72 } 73 74 static lldb::BreakpointSP 75 CreateExceptionBreakpoint (Target &target, 76 lldb::LanguageType language, 77 bool catch_bp, 78 bool throw_bp, 79 bool is_internal = false); 80 81 static lldb::LanguageType 82 GetLanguageTypeFromString (const char *string); 83 84 static const char * 85 GetNameForLanguageType (lldb::LanguageType language); 86 87protected: 88 //------------------------------------------------------------------ 89 // Classes that inherit from LanguageRuntime can see and modify these 90 //------------------------------------------------------------------ 91 92 // The Target is the one that knows how to create breakpoints, so this function is meant to be used either 93 // by the target or internally in Set/ClearExceptionBreakpoints. 94 class ExceptionBreakpointResolver : public BreakpointResolver 95 { 96 public: 97 ExceptionBreakpointResolver (Breakpoint *bkpt, 98 lldb::LanguageType language, 99 bool catch_bp, 100 bool throw_bp); 101 102 virtual ~ExceptionBreakpointResolver() {} 103 104 virtual Searcher::CallbackReturn 105 SearchCallback (SearchFilter &filter, 106 SymbolContext &context, 107 Address *addr, 108 bool containing); 109 110 virtual Searcher::Depth 111 GetDepth (); 112 113 virtual void 114 GetDescription (Stream *s); 115 116 virtual void 117 Dump (Stream *s) const {} 118 119 /// Methods for support type inquiry through isa, cast, and dyn_cast: 120 static inline bool classof(const BreakpointResolverName *) { return true; } 121 static inline bool classof(const BreakpointResolver *V) { 122 return V->getResolverID() == BreakpointResolver::ExceptionResolver; 123 } 124 protected: 125 bool SetActualResolver(); 126 127 lldb::BreakpointResolverSP m_actual_resolver_sp; 128 lldb::ProcessWP m_process_wp; 129 lldb::LanguageType m_language; 130 bool m_catch_bp; 131 bool m_throw_bp; 132 }; 133 134 virtual lldb::BreakpointResolverSP 135 CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0; 136 137 LanguageRuntime(Process *process); 138 Process *m_process; 139private: 140 DISALLOW_COPY_AND_ASSIGN (LanguageRuntime); 141}; 142 143} // namespace lldb_private 144 145#endif // liblldb_LanguageRuntime_h_ 146