File indexing completed on 2026-05-10 08:42:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef LLDB_TARGET_LANGUAGERUNTIME_H
0011 #define LLDB_TARGET_LANGUAGERUNTIME_H
0012
0013 #include "lldb/Breakpoint/BreakpointResolver.h"
0014 #include "lldb/Breakpoint/BreakpointResolverName.h"
0015 #include "lldb/Core/PluginInterface.h"
0016 #include "lldb/Core/Value.h"
0017 #include "lldb/Expression/LLVMUserExpression.h"
0018 #include "lldb/Symbol/DeclVendor.h"
0019 #include "lldb/Target/ExecutionContextScope.h"
0020 #include "lldb/Target/Runtime.h"
0021 #include "lldb/ValueObject/ValueObject.h"
0022 #include "lldb/lldb-private.h"
0023 #include "lldb/lldb-public.h"
0024 #include <optional>
0025
0026 namespace lldb_private {
0027
0028 class ExceptionSearchFilter : public SearchFilter {
0029 public:
0030 ExceptionSearchFilter(const lldb::TargetSP &target_sp,
0031 lldb::LanguageType language,
0032 bool update_module_list = true);
0033
0034 ~ExceptionSearchFilter() override = default;
0035
0036 bool ModulePasses(const lldb::ModuleSP &module_sp) override;
0037
0038 bool ModulePasses(const FileSpec &spec) override;
0039
0040 void Search(Searcher &searcher) override;
0041
0042 void GetDescription(Stream *s) override;
0043
0044 static SearchFilter *
0045 CreateFromStructuredData(Target &target,
0046 const StructuredData::Dictionary &data_dict,
0047 Status &error);
0048
0049 StructuredData::ObjectSP SerializeToStructuredData() override;
0050
0051 protected:
0052 lldb::LanguageType m_language;
0053 LanguageRuntime *m_language_runtime;
0054 lldb::SearchFilterSP m_filter_sp;
0055
0056 lldb::SearchFilterSP DoCreateCopy() override;
0057
0058 void UpdateModuleListIfNeeded();
0059 };
0060
0061 class LanguageRuntime : public Runtime, public PluginInterface {
0062 public:
0063 static LanguageRuntime *FindPlugin(Process *process,
0064 lldb::LanguageType language);
0065
0066 static void InitializeCommands(CommandObject *parent);
0067
0068 virtual lldb::LanguageType GetLanguageType() const = 0;
0069
0070
0071
0072 virtual LanguageRuntime *GetPreferredLanguageRuntime(ValueObject &in_value) {
0073 return nullptr;
0074 }
0075
0076 virtual llvm::Error GetObjectDescription(Stream &str,
0077 ValueObject &object) = 0;
0078
0079 virtual llvm::Error
0080 GetObjectDescription(Stream &str, Value &value,
0081 ExecutionContextScope *exe_scope) = 0;
0082
0083 struct VTableInfo {
0084 Address addr;
0085 Symbol *symbol;
0086 };
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101 virtual llvm::Expected<VTableInfo> GetVTableInfo(ValueObject &in_value,
0102 bool check_type) {
0103 return llvm::createStringError(
0104 std::errc::invalid_argument,
0105 "language doesn't support getting vtable information");
0106 }
0107
0108
0109 virtual bool GetDynamicTypeAndAddress(ValueObject &in_value,
0110 lldb::DynamicValueType use_dynamic,
0111 TypeAndOrName &class_type_or_name,
0112 Address &address,
0113 Value::ValueType &value_type) = 0;
0114
0115
0116
0117
0118 virtual CompilerType GetConcreteType(ExecutionContextScope *exe_scope,
0119 ConstString abstract_type_name) {
0120 return CompilerType();
0121 }
0122
0123
0124
0125 virtual bool CouldHaveDynamicValue(ValueObject &in_value) = 0;
0126
0127
0128
0129
0130
0131
0132 virtual TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
0133 ValueObject &static_value) = 0;
0134
0135 virtual void SetExceptionBreakpoints() {}
0136
0137 virtual void ClearExceptionBreakpoints() {}
0138
0139 virtual bool ExceptionBreakpointsAreSet() { return false; }
0140
0141 virtual bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) {
0142 return false;
0143 }
0144
0145 static lldb::BreakpointSP
0146 CreateExceptionBreakpoint(Target &target, lldb::LanguageType language,
0147 bool catch_bp, bool throw_bp,
0148 bool is_internal = false);
0149
0150 static lldb::BreakpointPreconditionSP
0151 GetExceptionPrecondition(lldb::LanguageType language, bool throw_bp);
0152
0153 virtual lldb::ValueObjectSP GetExceptionObjectForThread(
0154 lldb::ThreadSP thread_sp) {
0155 return lldb::ValueObjectSP();
0156 }
0157
0158 virtual lldb::ThreadSP GetBacktraceThreadFromException(
0159 lldb::ValueObjectSP thread_sp) {
0160 return lldb::ThreadSP();
0161 }
0162
0163 virtual DeclVendor *GetDeclVendor() { return nullptr; }
0164
0165 virtual lldb::BreakpointResolverSP
0166 CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
0167 bool catch_bp, bool throw_bp) = 0;
0168
0169 virtual lldb::SearchFilterSP CreateExceptionSearchFilter() {
0170 return m_process->GetTarget().GetSearchFilterForModule(nullptr);
0171 }
0172
0173 virtual std::optional<uint64_t>
0174 GetTypeBitSize(const CompilerType &compiler_type) {
0175 return {};
0176 }
0177
0178 virtual void SymbolsDidLoad(const ModuleList &module_list) {}
0179
0180 virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
0181 bool stop_others) = 0;
0182
0183
0184
0185 virtual bool IsAllowedRuntimeValue(ConstString name) { return false; }
0186
0187 virtual std::optional<CompilerType> GetRuntimeType(CompilerType base_type) {
0188 return std::nullopt;
0189 }
0190
0191 void ModulesDidLoad(const ModuleList &module_list) override {}
0192
0193
0194
0195
0196 virtual bool GetIRPasses(LLVMUserExpression::IRPasses &custom_passes) {
0197 return false;
0198 }
0199
0200
0201
0202
0203 virtual lldb::addr_t LookupRuntimeSymbol(ConstString name) {
0204 return LLDB_INVALID_ADDRESS;
0205 }
0206
0207 virtual bool isA(const void *ClassID) const { return ClassID == &ID; }
0208 static char ID;
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239 static lldb::UnwindPlanSP
0240 GetRuntimeUnwindPlan(lldb_private::Thread &thread,
0241 lldb_private::RegisterContext *regctx,
0242 bool &behaves_like_zeroth_frame);
0243
0244
0245
0246
0247 virtual StructuredData::ObjectSP GetLanguageSpecificData(SymbolContext sc);
0248
0249 protected:
0250
0251
0252
0253 virtual lldb::UnwindPlanSP
0254 GetRuntimeUnwindPlan(lldb::ProcessSP process_sp,
0255 lldb_private::RegisterContext *regctx,
0256 bool &behaves_like_zeroth_frame) {
0257 return lldb::UnwindPlanSP();
0258 }
0259
0260 LanguageRuntime(Process *process);
0261 };
0262
0263 }
0264
0265 #endif