LLDB mainline
AppleObjCRuntime.h
Go to the documentation of this file.
1//===-- AppleObjCRuntime.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_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIME_H
10#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIME_H
11
12
16#include "lldb/lldb-private.h"
17
19#include <optional>
20
21namespace lldb_private {
22
24public:
26
27 // Static Functions
28 // Note there is no CreateInstance, Initialize & Terminate functions here,
29 // because
30 // you can't make an instance of this generic runtime.
31
32 static char ID;
33
34 static void Initialize();
35
36 static void Terminate();
37
38 bool isA(const void *ClassID) const override {
39 return ClassID == &ID || ObjCLanguageRuntime::isA(ClassID);
40 }
41
42 static bool classof(const LanguageRuntime *runtime) {
43 return runtime->isA(&ID);
44 }
45
46 // These are generic runtime functions:
47 llvm::Error GetObjectDescription(Stream &str, Value &value,
48 ExecutionContextScope *exe_scope) override;
49
50 llvm::Error GetObjectDescription(Stream &str, ValueObject &object) override;
51
52 bool CouldHaveDynamicValue(ValueObject &in_value) override;
53
55 lldb::DynamicValueType use_dynamic,
56 TypeAndOrName &class_type_or_name,
57 Address &address,
58 Value::ValueType &value_type) override;
59
60 TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
61 ValueObject &static_value) override;
62
63 // These are the ObjC specific functions.
64
65 bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) override;
66
67 bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) override;
68
69 bool HasReadObjCLibrary() override { return m_read_objc_library; }
70
72 bool stop_others) override;
73
74 // Get the "libobjc.A.dylib" module from the current target if we can find
75 // it, also cache it once it is found to ensure quick lookups.
77
78 // Sync up with the target
79
80 void ModulesDidLoad(const ModuleList &module_list) override;
81
82 void SetExceptionBreakpoints() override;
83
84 void ClearExceptionBreakpoints() override;
85
86 bool ExceptionBreakpointsAreSet() override;
87
88 bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
89
91
92 static std::tuple<FileSpec, ConstString> GetExceptionThrowLocation();
93
95 lldb::ThreadSP thread_sp) override;
96
98 lldb::ValueObjectSP thread_sp) override;
99
100 uint32_t GetFoundationVersion();
101
102 virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true,
103 lldb::addr_t &cf_false);
104
105 virtual bool IsTaggedPointer (lldb::addr_t addr) { return false; }
106
107protected:
108 // Call CreateInstance instead.
109 AppleObjCRuntime(Process *process);
110
112
113 static bool AppleIsModuleObjCLibrary(const lldb::ModuleSP &module_sp);
114
116 lldb::ModuleSP &objc_module_sp);
117
118 void ReadObjCLibraryIfNeeded(const ModuleList &module_list);
119
121
122 std::unique_ptr<Address> m_PrintForDebugger_addr;
124 std::unique_ptr<lldb_private::AppleObjCTrampolineHandler>
128 std::unique_ptr<FunctionCaller> m_print_object_caller_up;
129
130 std::optional<uint32_t> m_Foundation_major;
131};
132
133} // namespace lldb_private
134
135#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIME_H
A section + offset based address class.
Definition: Address.h:62
virtual bool IsTaggedPointer(lldb::addr_t addr)
virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, lldb::addr_t &cf_false)
lldb::ThreadSP GetBacktraceThreadFromException(lldb::ValueObjectSP thread_sp) override
static bool classof(const LanguageRuntime *runtime)
bool CalculateHasNewLiteralsAndIndexing() override
bool isA(const void *ClassID) const override
static bool AppleIsModuleObjCLibrary(const lldb::ModuleSP &module_sp)
bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) override
bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override
bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, Address &address, Value::ValueType &value_type) override
TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name, ValueObject &static_value) override
std::optional< uint32_t > m_Foundation_major
std::unique_ptr< Address > m_PrintForDebugger_addr
static std::tuple< FileSpec, ConstString > GetExceptionThrowLocation()
lldb::BreakpointSP m_objc_exception_bp_sp
void ReadObjCLibraryIfNeeded(const ModuleList &module_list)
lldb::SearchFilterSP CreateExceptionSearchFilter() override
static ObjCRuntimeVersions GetObjCVersion(Process *process, lldb::ModuleSP &objc_module_sp)
llvm::Error GetObjectDescription(Stream &str, Value &value, ExecutionContextScope *exe_scope) override
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, bool stop_others) override
bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) override
lldb::ValueObjectSP GetExceptionObjectForThread(lldb::ThreadSP thread_sp) override
std::unique_ptr< lldb_private::AppleObjCTrampolineHandler > m_objc_trampoline_handler_up
void ModulesDidLoad(const ModuleList &module_list) override
Called when modules have been loaded in the process.
bool CouldHaveDynamicValue(ValueObject &in_value) override
std::unique_ptr< FunctionCaller > m_print_object_caller_up
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
virtual bool isA(const void *ClassID) const
A collection class for Module objects.
Definition: ModuleList.h:103
bool isA(const void *ClassID) const override
A plug-in interface definition class for debugging a process.
Definition: Process.h:341
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Sometimes you can find the name of the type corresponding to an object, but we don't have debug infor...
Definition: Type.h:745
ValueType
Type that describes Value::m_value.
Definition: Value.h:41
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
Definition: lldb-forward.h:449
std::shared_ptr< lldb_private::SearchFilter > SearchFilterSP
Definition: lldb-forward.h:418
std::weak_ptr< lldb_private::Module > ModuleWP
Definition: lldb-forward.h:372
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:446
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:480
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
Definition: lldb-forward.h:319
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
Definition: lldb-forward.h:427
uint64_t addr_t
Definition: lldb-types.h:80
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:371