LLDB mainline
AppleObjCRuntime.cpp
Go to the documentation of this file.
1//===-- AppleObjCRuntime.cpp ----------------------------------------------===//
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#include "AppleObjCRuntime.h"
10#include "AppleObjCRuntimeV2.h"
16#include "lldb/Core/Module.h"
19#include "lldb/Core/Section.h"
25#include "lldb/Target/Process.h"
28#include "lldb/Target/Target.h"
29#include "lldb/Target/Thread.h"
33#include "lldb/Utility/Log.h"
34#include "lldb/Utility/Scalar.h"
35#include "lldb/Utility/Status.h"
39#include "clang/AST/Type.h"
40
42
43#include "llvm/Support/Error.h"
44
45#include <vector>
46
47using namespace lldb;
48using namespace lldb_private;
49
51
53
55
61
63
65
67 ValueObject &valobj) {
68 CompilerType compiler_type(valobj.GetCompilerType());
69 bool is_signed;
70 // ObjC objects can only be pointers (or numbers that actually represents
71 // pointers but haven't been typecast, because reasons..)
72 if (!compiler_type.IsIntegerType(is_signed) && !compiler_type.IsPointerType())
73 return llvm::createStringError("not a pointer type");
74
75 // Make the argument list: we pass one arg, the address of our pointer, to
76 // the print function.
77 Value val;
78
79 if (!valobj.ResolveValue(val.GetScalar()))
80 return llvm::createStringError("pointer value could not be resolved");
81
82 // Value Objects may not have a process in their ExecutionContextRef. But we
83 // need to have one in the ref we pass down to eventually call description.
84 // Get it from the target if it isn't present.
85 ExecutionContext exe_ctx;
86 if (valobj.GetProcessSP()) {
87 exe_ctx = ExecutionContext(valobj.GetExecutionContextRef());
88 } else {
89 exe_ctx.SetContext(valobj.GetTargetSP(), true);
90 if (!exe_ctx.HasProcessScope())
91 return llvm::createStringError("no process");
92 }
93 return GetObjectDescription(str, val, exe_ctx.GetBestExecutionContextScope());
94}
95
96llvm::Error
98 ExecutionContextScope *exe_scope) {
100 return llvm::createStringError("Objective-C runtime not loaded");
101
102 ExecutionContext exe_ctx;
103 exe_scope->CalculateExecutionContext(exe_ctx);
104 Process *process = exe_ctx.GetProcessPtr();
105 if (!process)
106 return llvm::createStringError("no process");
107
108 // We need other parts of the exe_ctx, but the processes have to match.
109 assert(m_process == process);
110
111 // Get the function address for the print function.
112 const Address *function_address = GetPrintForDebuggerAddr();
113 if (!function_address)
114 return llvm::createStringError("no print function");
115
116 Target *target = exe_ctx.GetTargetPtr();
117 CompilerType compiler_type = value.GetCompilerType();
118 if (compiler_type) {
120 return llvm::createStringError(
121 "Value doesn't point to an ObjC object.\n");
122 } else {
123 // If it is not a pointer, see if we can make it into a pointer.
124 TypeSystemClangSP scratch_ts_sp =
126 if (!scratch_ts_sp)
127 return llvm::createStringError("no scratch type system");
128
129 CompilerType opaque_type = scratch_ts_sp->GetBasicType(eBasicTypeObjCID);
130 if (!opaque_type)
131 opaque_type =
132 scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
133 // value.SetContext(Value::eContextTypeClangType, opaque_type_ptr);
134 value.SetCompilerType(opaque_type);
135 }
136
137 ValueList arg_value_list;
138 arg_value_list.PushValue(value);
139
140 // This is the return value:
141 TypeSystemClangSP scratch_ts_sp =
143 if (!scratch_ts_sp)
144 return llvm::createStringError("no scratch type system");
145
146 CompilerType return_compiler_type = scratch_ts_sp->GetCStringType(true);
147 Value ret;
148 // ret.SetContext(Value::eContextTypeClangType, return_compiler_type);
149 ret.SetCompilerType(return_compiler_type);
150
151 if (!exe_ctx.GetFramePtr()) {
152 Thread *thread = exe_ctx.GetThreadPtr();
153 if (thread == nullptr) {
154 exe_ctx.SetThreadSP(process->GetThreadList().GetSelectedThread());
155 thread = exe_ctx.GetThreadPtr();
156 }
157 if (thread) {
158 exe_ctx.SetFrameSP(thread->GetSelectedFrame(DoNoSelectMostRelevantFrame));
159 }
160 }
161
162 // Now we're ready to call the function:
163
164 DiagnosticManager diagnostics;
165 lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS;
166
170 exe_scope->CalculateTarget()->GetFunctionCallerForLanguage(
171 eLanguageTypeObjC, return_compiler_type, *function_address,
172 arg_value_list, "objc-object-description", error));
173 if (error.Fail()) {
175 return llvm::createStringError(
176 llvm::Twine(
177 "could not get function runner to call print for debugger "
178 "function: ") +
179 error.AsCString());
180 }
181 m_print_object_caller_up->InsertFunction(exe_ctx, wrapper_struct_addr,
182 diagnostics);
183 } else {
184 m_print_object_caller_up->WriteFunctionArguments(
185 exe_ctx, wrapper_struct_addr, arg_value_list, diagnostics);
186 }
187
189 options.SetUnwindOnError(true);
190 options.SetTryAllThreads(true);
191 options.SetStopOthers(true);
192 options.SetIgnoreBreakpoints(true);
193 options.SetTimeout(process->GetUtilityExpressionTimeout());
194 options.SetIsForUtilityExpr(true);
195
196 ExpressionResults results = m_print_object_caller_up->ExecuteFunction(
197 exe_ctx, &wrapper_struct_addr, options, diagnostics, ret);
198 if (results != eExpressionCompleted)
199 return llvm::createStringError(
200 "could not evaluate print object function: " + toString(results));
201
203
204 char buf[512];
205 size_t cstr_len = 0;
206 size_t full_buffer_len = sizeof(buf) - 1;
207 size_t curr_len = full_buffer_len;
208 while (curr_len == full_buffer_len) {
210 curr_len = process->ReadCStringFromMemory(result_ptr + cstr_len, buf,
211 sizeof(buf), error);
212 strm.Write(buf, curr_len);
213 cstr_len += curr_len;
214 }
215 if (cstr_len > 0)
216 return llvm::Error::success();
217 return llvm::createStringError("empty object description");
218}
219
221 ModuleSP module_sp(m_objc_module_wp.lock());
222 if (module_sp)
223 return module_sp;
224
225 Process *process = GetProcess();
226 if (process) {
227 const ModuleList &modules = process->GetTarget().GetImages();
228 for (uint32_t idx = 0; idx < modules.GetSize(); idx++) {
229 module_sp = modules.GetModuleAtIndex(idx);
231 m_objc_module_wp = module_sp;
232 return module_sp;
233 }
234 }
235 }
236 return ModuleSP();
237}
238
241 const ModuleList &modules = m_process->GetTarget().GetImages();
242
243 SymbolContextList contexts;
244 SymbolContext context;
245
246 modules.FindSymbolsWithNameAndType(ConstString("_NSPrintForDebugger"),
247 eSymbolTypeCode, contexts);
248 if (contexts.IsEmpty()) {
249 modules.FindSymbolsWithNameAndType(ConstString("_CFPrintForDebugger"),
250 eSymbolTypeCode, contexts);
251 if (contexts.IsEmpty())
252 return nullptr;
253 }
254
255 contexts.GetContextAtIndex(0, context);
256
258 std::make_unique<Address>(context.symbol->GetAddress());
259 }
260
261 return m_PrintForDebugger_addr.get();
262}
263
265 return in_value.GetCompilerType().IsPossibleDynamicType(
266 nullptr,
267 false, // do not check C++
268 true); // check ObjC
269}
270
272 ValueObject &in_value, lldb::DynamicValueType use_dynamic,
273 TypeAndOrName &class_type_or_name, Address &address,
274 Value::ValueType &value_type, llvm::ArrayRef<uint8_t> &local_buffer) {
275 return false;
276}
277
280 ValueObject &static_value) {
281 CompilerType static_type(static_value.GetCompilerType());
282 Flags static_type_flags(static_type.GetTypeInfo());
283
284 TypeAndOrName ret(type_and_or_name);
285 if (type_and_or_name.HasType()) {
286 // The type will always be the type of the dynamic object. If our parent's
287 // type was a pointer, then our type should be a pointer to the type of the
288 // dynamic object. If a reference, then the original type should be
289 // okay...
290 CompilerType orig_type = type_and_or_name.GetCompilerType();
291 CompilerType corrected_type = orig_type;
292 if (static_type_flags.AllSet(eTypeIsPointer))
293 corrected_type = orig_type.GetPointerType();
294 ret.SetCompilerType(corrected_type);
295 } else {
296 // If we are here we need to adjust our dynamic type name to include the
297 // correct & or * symbol
298 std::string corrected_name(type_and_or_name.GetName().GetCString());
299 if (static_type_flags.AllSet(eTypeIsPointer))
300 corrected_name.append(" *");
301 // the parent type should be a correctly pointer'ed or referenc'ed type
302 ret.SetCompilerType(static_type);
303 ret.SetName(corrected_name.c_str());
304 }
305 return ret;
306}
307
309 if (module_sp) {
310 const FileSpec &module_file_spec = module_sp->GetFileSpec();
311 static ConstString ObjCName("libobjc.A.dylib");
312
313 if (module_file_spec) {
314 if (module_file_spec.GetFilename() == ObjCName)
315 return true;
316 }
317 }
318 return false;
319}
320
321// we use the version of Foundation to make assumptions about the ObjC runtime
322// on a target
324 if (!m_Foundation_major) {
325 const ModuleList &modules = m_process->GetTarget().GetImages();
326 for (uint32_t idx = 0; idx < modules.GetSize(); idx++) {
327 lldb::ModuleSP module_sp = modules.GetModuleAtIndex(idx);
328 if (!module_sp)
329 continue;
330 if (module_sp->GetFileSpec().GetFilename() == "Foundation") {
331 m_Foundation_major = module_sp->GetVersion().getMajor();
332 return *m_Foundation_major;
333 }
334 }
336 } else
337 return *m_Foundation_major;
338}
339
341 lldb::addr_t &cf_false) {
342 cf_true = cf_false = LLDB_INVALID_ADDRESS;
343}
344
346 return AppleIsModuleObjCLibrary(module_sp);
347}
348
350 // Maybe check here and if we have a handler already, and the UUID of this
351 // module is the same as the one in the current module, then we don't have to
352 // reread it?
353 m_objc_trampoline_handler_up = std::make_unique<AppleObjCTrampolineHandler>(
354 m_process->shared_from_this(), module_sp);
355 if (m_objc_trampoline_handler_up != nullptr) {
356 m_read_objc_library = true;
357 return true;
358 } else
359 return false;
360}
361
363 bool stop_others) {
364 ThreadPlanSP thread_plan_sp;
366 thread_plan_sp = m_objc_trampoline_handler_up->GetStepThroughDispatchPlan(
367 thread, stop_others);
368 return thread_plan_sp;
369}
370
371// Static Functions
374 if (!process)
376
377 Target &target = process->GetTarget();
378 if (target.GetArchitecture().GetTriple().getVendor() !=
379 llvm::Triple::VendorType::Apple)
381
382 for (ModuleSP module_sp : target.GetImages().Modules()) {
383 // One tricky bit here is that we might get called as part of the initial
384 // module loading, but before all the pre-run libraries get winnowed from
385 // the module list. So there might actually be an old and incorrect ObjC
386 // library sitting around in the list, and we don't want to look at that.
387 // That's why we call IsLoadedInTarget.
388
389 if (AppleIsModuleObjCLibrary(module_sp) &&
390 module_sp->IsLoadedInTarget(&target)) {
391 objc_module_sp = module_sp;
392 ObjectFile *ofile = module_sp->GetObjectFile();
393 if (!ofile)
395
396 SectionList *sections = module_sp->GetSectionList();
397 if (!sections)
399 SectionSP v1_telltale_section_sp = sections->FindSectionByName("__OBJC");
400 if (v1_telltale_section_sp) {
402 "GetObjCVersion returning eAppleObjC_V1, which is no longer "
403 "supported");
405 }
407 }
408 }
409
411}
412
414 const bool catch_bp = false;
415 const bool throw_bp = true;
416 const bool is_internal = true;
417
420 m_process->GetTarget(), GetLanguageType(), catch_bp, throw_bp,
421 is_internal);
423 m_objc_exception_bp_sp->SetBreakpointKind("ObjC exception");
424 } else
425 m_objc_exception_bp_sp->SetEnabled(true);
426}
427
429 if (!m_process)
430 return;
431
432 if (m_objc_exception_bp_sp.get()) {
433 m_objc_exception_bp_sp->SetEnabled(false);
434 }
435}
436
440
442 lldb::StopInfoSP stop_reason) {
443 if (!m_process)
444 return false;
445
446 if (!stop_reason || stop_reason->GetStopReason() != eStopReasonBreakpoint)
447 return false;
448
449 uint64_t break_site_id = stop_reason->GetValue();
450 return m_process->GetBreakpointSiteList().StopPointSiteContainsBreakpoint(
451 break_site_id, m_objc_exception_bp_sp->GetID());
452}
453
455 if (!m_process)
456 return false;
457
458 static ConstString s_method_signature(
459 "-[NSDictionary objectForKeyedSubscript:]");
460 // NSDictionary is toll-free bridged with CFDictionary, so the
461 // implementation lives in CoreFoundation, not Foundation.
462 static ModuleSpec corefoundation_module_spec(FileSpec("CoreFoundation"));
463
464 Target &target = m_process->GetTarget();
465 if (ModuleSP corefoundation_module_sp =
466 target.GetImages().FindFirstModule(corefoundation_module_spec)) {
467 if (corefoundation_module_sp->FindFirstSymbolWithNameAndType(
468 s_method_signature, eSymbolTypeCode))
469 return true;
470 }
471
472 return false;
473}
474
476 Target &target = m_process->GetTarget();
477
478 FileSpecList filter_modules;
479 if (target.GetArchitecture().GetTriple().getVendor() == llvm::Triple::Apple) {
480 filter_modules.Append(std::get<0>(GetExceptionThrowLocation()));
481 }
482 return target.GetSearchFilterForModuleList(&filter_modules);
483}
484
486 ThreadSP thread_sp) {
487 auto *cpp_runtime = m_process->GetLanguageRuntime(eLanguageTypeC_plus_plus);
488 if (!cpp_runtime) return ValueObjectSP();
489 auto cpp_exception = cpp_runtime->GetExceptionObjectForThread(thread_sp);
490 if (!cpp_exception) return ValueObjectSP();
491
492 auto descriptor = GetClassDescriptor(*cpp_exception);
493 if (!descriptor || !descriptor->IsValid()) return ValueObjectSP();
494
495 while (descriptor) {
496 ConstString class_name(descriptor->GetClassName());
497 if (class_name == "NSException")
498 return cpp_exception;
499 descriptor = descriptor->GetSuperclass();
500 }
501
502 return ValueObjectSP();
503}
504
505/// Utility method for error handling in GetBacktraceThreadFromException.
506/// \param msg The message to add to the log.
507/// \return An invalid ThreadSP to be returned from
508/// GetBacktraceThreadFromException.
509[[nodiscard]]
510static ThreadSP FailExceptionParsing(llvm::StringRef msg) {
512 LLDB_LOG(log, "Failed getting backtrace from exception: {0}", msg);
513 return ThreadSP();
514}
515
517 lldb::ValueObjectSP exception_sp) {
518 ValueObjectSP reserved_dict =
519 exception_sp->GetChildMemberWithName("reserved");
520 if (!reserved_dict)
521 return FailExceptionParsing("Failed to get 'reserved' member.");
522
523 reserved_dict = reserved_dict->GetSyntheticValue();
524 if (!reserved_dict)
525 return FailExceptionParsing("Failed to get synthetic value.");
526
527 TypeSystemClangSP scratch_ts_sp =
528 ScratchTypeSystemClang::GetForTarget(*exception_sp->GetTargetSP());
529 if (!scratch_ts_sp)
530 return FailExceptionParsing("Failed to get scratch AST.");
531 CompilerType objc_id = scratch_ts_sp->GetBasicType(lldb::eBasicTypeObjCID);
532 ValueObjectSP return_addresses;
533
534 auto objc_object_from_address = [&exception_sp, &objc_id](uint64_t addr,
535 const char *name) {
536 Value value(addr);
537 value.SetCompilerType(objc_id);
538 auto object = ValueObjectConstResult::Create(
539 exception_sp->GetTargetSP().get(), value, ConstString(name));
540 object = object->GetDynamicValue(eDynamicDontRunTarget);
541 return object;
542 };
543
544 for (size_t idx = 0; idx < reserved_dict->GetNumChildrenIgnoringErrors();
545 idx++) {
546 ValueObjectSP dict_entry = reserved_dict->GetChildAtIndex(idx);
547
548 DataExtractor data;
549 data.SetAddressByteSize(dict_entry->GetProcessSP()->GetAddressByteSize());
551 dict_entry->GetData(data, error);
552 if (error.Fail()) return ThreadSP();
553
554 lldb::offset_t data_offset = 0;
555 auto dict_entry_key = data.GetAddress(&data_offset);
556 auto dict_entry_value = data.GetAddress(&data_offset);
557
558 auto key_nsstring = objc_object_from_address(dict_entry_key, "key");
559 StreamString key_summary;
561 *key_nsstring, key_summary, TypeSummaryOptions()) &&
562 !key_summary.Empty()) {
563 if (key_summary.GetString() == "\"callStackReturnAddresses\"") {
564 return_addresses = objc_object_from_address(dict_entry_value,
565 "callStackReturnAddresses");
566 break;
567 }
568 }
569 }
570
571 if (!return_addresses)
572 return FailExceptionParsing("Failed to get return addresses.");
573 auto frames_value = return_addresses->GetChildMemberWithName("_frames");
574 if (!frames_value)
575 return FailExceptionParsing("Failed to get frames_value.");
576 addr_t frames_addr = frames_value->GetValueAsUnsigned(0);
577 auto count_value = return_addresses->GetChildMemberWithName("_cnt");
578 if (!count_value)
579 return FailExceptionParsing("Failed to get count_value.");
580 size_t count = count_value->GetValueAsUnsigned(0);
581 auto ignore_value = return_addresses->GetChildMemberWithName("_ignore");
582 if (!ignore_value)
583 return FailExceptionParsing("Failed to get ignore_value.");
584 size_t ignore = ignore_value->GetValueAsUnsigned(0);
585
586 size_t ptr_size = m_process->GetAddressByteSize();
587 std::vector<lldb::addr_t> pcs;
588 for (size_t idx = 0; idx < count; idx++) {
589 // Record unreadable frames as invalid rather than dropping them, so the
590 // history thread keeps one entry per frame in the exception.
591 pcs.push_back(
592 llvm::expectedToOptional(m_process->ReadPointerFromMemory(
593 frames_addr + (ignore + idx) * ptr_size))
594 .value_or(LLDB_INVALID_ADDRESS));
595 }
596
597 if (pcs.empty())
598 return FailExceptionParsing("Failed to get PC list.");
599
600 ThreadSP new_thread_sp(new HistoryThread(*m_process, 0, pcs));
601 m_process->GetExtendedThreadList().AddThread(new_thread_sp);
602 return new_thread_sp;
603}
604
605std::tuple<FileSpec, ConstString>
607 return std::make_tuple(
608 FileSpec("libobjc.A.dylib"), ConstString("objc_exception_throw"));
609}
610
612 if (!HasReadObjCLibrary()) {
613 std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
614
615 size_t num_modules = module_list.GetSize();
616 for (size_t i = 0; i < num_modules; i++) {
617 auto mod = module_list.GetModuleAtIndex(i);
618 if (IsModuleObjCLibrary(mod)) {
619 ReadObjCLibrary(mod);
620 break;
621 }
622 }
623 }
624}
625
627 ReadObjCLibraryIfNeeded(module_list);
628}
static ThreadSP FailExceptionParsing(llvm::StringRef msg)
Utility method for error handling in GetBacktraceThreadFromException.
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:375
#define LLDB_PLUGIN_DEFINE(PluginName)
A section + offset based address class.
Definition Address.h:62
virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, lldb::addr_t &cf_false)
lldb::ThreadSP GetBacktraceThreadFromException(lldb::ValueObjectSP thread_sp) override
bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, Address &address, Value::ValueType &value_type, llvm::ArrayRef< uint8_t > &local_buffer) override
This call should return true if it could set the name and/or the type Sets address to the address of ...
bool CalculateHasNewLiteralsAndIndexing() override
static bool AppleIsModuleObjCLibrary(const lldb::ModuleSP &module_sp)
bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) override
bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) 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
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition ArchSpec.h:545
Generic representation of a type in a programming language.
bool IsPossibleDynamicType(CompilerType *target_type, bool check_cplusplus, bool check_objc) const
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
bool IsIntegerType(bool &is_signed) const
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
bool IsPointerType(CompilerType *pointee_type=nullptr) const
A uniqued constant string class.
Definition ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
An data extractor class.
uint64_t GetAddress(lldb::offset_t *offset_ptr) const
Extract an address from *offset_ptr.
void SetAddressByteSize(uint32_t addr_size)
Set the address byte size.
void SetUnwindOnError(bool unwind=false)
Definition Target.h:402
void SetTryAllThreads(bool try_others=true)
Definition Target.h:435
void SetTimeout(const Timeout< std::micro > &timeout)
Definition Target.h:423
void SetStopOthers(bool stop_others=true)
Definition Target.h:439
void SetIgnoreBreakpoints(bool ignore=false)
Definition Target.h:406
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
virtual void CalculateExecutionContext(ExecutionContext &exe_ctx)=0
Reconstruct the object's execution context into sc.
virtual lldb::TargetSP CalculateTarget()=0
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void SetFrameSP(const lldb::StackFrameSP &frame_sp)
Set accessor to set only the frame shared pointer.
bool HasProcessScope() const
Returns true the ExecutionContext object contains a valid target and process.
ExecutionContextScope * GetBestExecutionContextScope() const
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
void SetContext(const lldb::TargetSP &target_sp, bool get_process)
Target * GetTargetPtr() const
Returns a pointer to the target object.
void SetThreadSP(const lldb::ThreadSP &thread_sp)
Set accessor to set only the thread shared pointer.
Process * GetProcessPtr() const
Returns a pointer to the process object.
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
A file collection class.
void Append(const FileSpec &file)
Append a FileSpec object to the list.
A file utility class.
Definition FileSpec.h:56
llvm::StringRef GetFilename() const
Filename string const get accessor.
Definition FileSpec.h:248
A class to manage flags.
Definition Flags.h:22
bool AllSet(ValueType mask) const
Test if all bits in mask are 1 in the current flags.
Definition Flags.h:83
A thread object representing a backtrace from a previous point in the process execution.
static lldb::BreakpointSP CreateExceptionBreakpoint(Target &target, lldb::LanguageType language, bool catch_bp, bool throw_bp, bool is_internal=false)
A collection class for Module objects.
Definition ModuleList.h:125
std::recursive_mutex & GetMutex() const
Definition ModuleList.h:252
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Finds the first module whose file specification matches module_spec.
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
ModuleIterable Modules() const
Definition ModuleList.h:571
size_t GetSize() const
Gets the size of the module list.
virtual ClassDescriptorSP GetClassDescriptor(ValueObject &in_value)
lldb::LanguageType GetLanguageType() const override
A plug-in interface definition class for object file parsers.
Definition ObjectFile.h:46
std::chrono::seconds GetUtilityExpressionTimeout() const
Definition Process.cpp:361
A plug-in interface definition class for debugging a process.
Definition Process.h:367
ThreadList & GetThreadList()
Definition Process.h:2408
size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr, size_t cstr_max_len, Status &error)
Read a NULL terminated C string from memory.
Definition Process.cpp:2381
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1266
Process * m_process
Definition Runtime.h:29
Process * GetProcess()
Definition Runtime.h:22
unsigned long long ULongLong(unsigned long long fail_value=0) const
Definition Scalar.cpp:366
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
lldb::SectionSP FindSectionByName(llvm::StringRef section_name) const
Definition Section.cpp:562
An error handling class.
Definition Status.h:118
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
Definition Stream.h:28
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
Definition Stream.h:111
Defines a list of symbol context objects.
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
Defines a symbol context baton that can be handed other debug core functions.
Symbol * symbol
The Symbol for a given query.
Address GetAddress() const
Definition Symbol.h:98
lldb::SearchFilterSP GetSearchFilterForModuleList(const FileSpecList *containingModuleList)
Definition Target.cpp:706
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition Target.h:1254
const ArchSpec & GetArchitecture() const
Definition Target.h:1296
lldb::ThreadSP GetSelectedThread()
Sometimes you can find the name of the type corresponding to an object, but we don't have debug infor...
Definition Type.h:780
void SetName(ConstString type_name)
Definition Type.cpp:911
CompilerType GetCompilerType() const
Definition Type.h:794
ConstString GetName() const
Definition Type.cpp:903
void SetCompilerType(CompilerType compiler_type)
Definition Type.cpp:931
bool HasType() const
Definition Type.h:812
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
void PushValue(const Value &value)
Definition Value.cpp:698
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS, ValueObjectManager *manager=nullptr)
These routines create ValueObjectConstResult ValueObjects from various data sources.
lldb::ProcessSP GetProcessSP() const
lldb::TargetSP GetTargetSP() const
CompilerType GetCompilerType()
virtual bool ResolveValue(Scalar &scalar)
const ExecutionContextRef & GetExecutionContextRef() const
const Scalar & GetScalar() const
See comment on m_scalar to understand what GetScalar returns.
Definition Value.h:114
ValueType
Type that describes Value::m_value.
Definition Value.h:42
void SetCompilerType(const CompilerType &compiler_type)
Definition Value.cpp:276
const CompilerType & GetCompilerType()
Definition Value.cpp:247
#define LLDB_INVALID_MODULE_VERSION
#define LLDB_INVALID_ADDRESS
@ DoNoSelectMostRelevantFrame
bool NSStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition NSString.cpp:35
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:338
std::string toString(FormatterBytecode::OpCodes op)
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::SearchFilter > SearchFilterSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
uint64_t offset_t
Definition lldb-types.h:86
@ eLanguageTypeObjC
Objective-C.
@ eLanguageTypeC_plus_plus
ISO C++:1998.
ExpressionResults
The results of expression evaluation.
@ eExpressionCompleted
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
std::shared_ptr< lldb_private::Section > SectionSP
uint64_t addr_t
Definition lldb-types.h:80
@ eStopReasonBreakpoint
@ eDynamicDontRunTarget
std::shared_ptr< lldb_private::Module > ModuleSP