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