1 //===-- ItaniumABILanguageRuntime.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_ItaniumABILanguageRuntime_h_
11 #define liblldb_ItaniumABILanguageRuntime_h_
12 
13 #include <map>
14 #include <mutex>
15 #include <vector>
16 
17 #include "lldb/Breakpoint/BreakpointResolver.h"
18 #include "lldb/Core/Value.h"
19 #include "lldb/Symbol/Type.h"
20 #include "lldb/Target/CPPLanguageRuntime.h"
21 #include "lldb/Target/LanguageRuntime.h"
22 #include "lldb/lldb-private.h"
23 
24 namespace lldb_private {
25 
26 class ItaniumABILanguageRuntime : public lldb_private::CPPLanguageRuntime {
27 public:
28   ~ItaniumABILanguageRuntime() override = default;
29 
30   //------------------------------------------------------------------
31   // Static Functions
32   //------------------------------------------------------------------
33   static void Initialize();
34 
35   static void Terminate();
36 
37   static lldb_private::LanguageRuntime *
38   CreateInstance(Process *process, lldb::LanguageType language);
39 
40   static lldb_private::ConstString GetPluginNameStatic();
41 
42   bool IsVTableName(const char *name) override;
43 
44   bool GetDynamicTypeAndAddress(ValueObject &in_value,
45                                 lldb::DynamicValueType use_dynamic,
46                                 TypeAndOrName &class_type_or_name,
47                                 Address &address,
48                                 Value::ValueType &value_type) override;
49 
50   TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
51                                  ValueObject &static_value) override;
52 
53   bool CouldHaveDynamicValue(ValueObject &in_value) override;
54 
55   void SetExceptionBreakpoints() override;
56 
57   void ClearExceptionBreakpoints() override;
58 
59   bool ExceptionBreakpointsAreSet() override;
60 
61   bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
62 
63   lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt,
64                                                      bool catch_bp,
65                                                      bool throw_bp) override;
66 
67   lldb::SearchFilterSP CreateExceptionSearchFilter() override;
68 
69   lldb::ValueObjectSP GetExceptionObjectForThread(
70       lldb::ThreadSP thread_sp) override;
71 
72   //------------------------------------------------------------------
73   // PluginInterface protocol
74   //------------------------------------------------------------------
75   lldb_private::ConstString GetPluginName() override;
76 
77   uint32_t GetPluginVersion() override;
78 
79 protected:
80   lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt,
81                                                      bool catch_bp,
82                                                      bool throw_bp,
83                                                      bool for_expressions);
84 
85   lldb::BreakpointSP CreateExceptionBreakpoint(bool catch_bp, bool throw_bp,
86                                                bool for_expressions,
87                                                bool is_internal);
88 
89 private:
90   typedef std::map<lldb_private::Address, TypeAndOrName> DynamicTypeCache;
91 
ItaniumABILanguageRuntime(Process * process)92   ItaniumABILanguageRuntime(Process *process)
93       : // Call CreateInstance instead.
94         lldb_private::CPPLanguageRuntime(process),
95         m_cxx_exception_bp_sp(), m_dynamic_type_map(),
96         m_dynamic_type_map_mutex() {}
97 
98   lldb::BreakpointSP m_cxx_exception_bp_sp;
99   DynamicTypeCache m_dynamic_type_map;
100   std::mutex m_dynamic_type_map_mutex;
101 
102   TypeAndOrName GetTypeInfoFromVTableAddress(ValueObject &in_value,
103                                              lldb::addr_t original_ptr,
104                                              lldb::addr_t vtable_addr);
105 
106   TypeAndOrName GetDynamicTypeInfo(const lldb_private::Address &vtable_addr);
107 
108   void SetDynamicTypeInfo(const lldb_private::Address &vtable_addr,
109                           const TypeAndOrName &type_info);
110 };
111 
112 } // namespace lldb_private
113 
114 #endif // liblldb_ItaniumABILanguageRuntime_h_
115