LanguageRuntime.h revision 1a469c75c0597abc2a9abdf86b624b2e71ea8650
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    // this call should return true if it could set the name and/or the type
48    virtual bool
49    GetDynamicTypeAndAddress (ValueObject &in_value,
50                              lldb::DynamicValueType use_dynamic,
51                              TypeAndOrName &class_type_or_name,
52                              Address &address) = 0;
53
54    // This should be a fast test to determine whether it is likely that this value would
55    // have a dynamic type.
56    virtual bool
57    CouldHaveDynamicValue (ValueObject &in_value) = 0;
58
59    virtual void
60    SetExceptionBreakpoints ()
61    {
62    }
63
64    virtual void
65    ClearExceptionBreakpoints ()
66    {
67    }
68
69    virtual bool
70    ExceptionBreakpointsExplainStop (lldb::StopInfoSP stop_reason)
71    {
72        return false;
73    }
74
75    static lldb::BreakpointSP
76    CreateExceptionBreakpoint (Target &target,
77                               lldb::LanguageType language,
78                               bool catch_bp,
79                               bool throw_bp,
80                               bool is_internal = false);
81
82    static lldb::LanguageType
83    GetLanguageTypeFromString (const char *string);
84
85    static const char *
86    GetNameForLanguageType (lldb::LanguageType language);
87
88    Process *
89    GetProcess()
90    {
91        return m_process;
92    }
93
94protected:
95    //------------------------------------------------------------------
96    // Classes that inherit from LanguageRuntime can see and modify these
97    //------------------------------------------------------------------
98
99    // The Target is the one that knows how to create breakpoints, so this function is meant to be used either
100    // by the target or internally in Set/ClearExceptionBreakpoints.
101    class ExceptionBreakpointResolver : public BreakpointResolver
102    {
103    public:
104        ExceptionBreakpointResolver (Breakpoint *bkpt,
105                                lldb::LanguageType language,
106                                bool catch_bp,
107                                bool throw_bp);
108
109        virtual ~ExceptionBreakpointResolver() {}
110
111        virtual Searcher::CallbackReturn
112        SearchCallback (SearchFilter &filter,
113                        SymbolContext &context,
114                        Address *addr,
115                        bool containing);
116
117        virtual Searcher::Depth
118        GetDepth ();
119
120        virtual void
121        GetDescription (Stream *s);
122
123        virtual void
124        Dump (Stream *s) const {}
125
126        /// Methods for support type inquiry through isa, cast, and dyn_cast:
127        static inline bool classof(const BreakpointResolverName *) { return true; }
128        static inline bool classof(const BreakpointResolver *V) {
129            return V->getResolverID() == BreakpointResolver::ExceptionResolver;
130        }
131    protected:
132        bool SetActualResolver();
133
134        lldb::BreakpointResolverSP m_actual_resolver_sp;
135        lldb::ProcessWP m_process_wp;
136        lldb::LanguageType m_language;
137        bool m_catch_bp;
138        bool m_throw_bp;
139    };
140
141    virtual lldb::BreakpointResolverSP
142    CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0;
143
144    LanguageRuntime(Process *process);
145    Process *m_process;
146private:
147    DISALLOW_COPY_AND_ASSIGN (LanguageRuntime);
148};
149
150} // namespace lldb_private
151
152#endif  // liblldb_LanguageRuntime_h_
153