LLDB mainline
DynamicLoaderMacOS.cpp
Go to the documentation of this file.
1//===-- DynamicLoaderMacOS.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
10#include "lldb/Core/Debugger.h"
11#include "lldb/Core/Module.h"
13#include "lldb/Core/Section.h"
16#include "lldb/Target/ABI.h"
19#include "lldb/Target/Target.h"
20#include "lldb/Target/Thread.h"
22#include "lldb/Utility/Log.h"
23#include "lldb/Utility/State.h"
24
25#include "DynamicLoaderDarwin.h"
26#include "DynamicLoaderMacOS.h"
27
29
30using namespace lldb;
31using namespace lldb_private;
32
33// Create an instance of this class. This function is filled into the plugin
34// info class that gets handed out by the plugin factory and allows the lldb to
35// instantiate an instance of this class.
37 bool force) {
38 bool create = force;
39 if (!create) {
40 create = true;
41 Module *exe_module = process->GetTarget().GetExecutableModulePointer();
42 if (exe_module) {
43 ObjectFile *object_file = exe_module->GetObjectFile();
44 if (object_file) {
45 create = (object_file->GetStrata() == ObjectFile::eStrataUser);
46 }
47 }
48
49 if (create) {
50 const llvm::Triple &triple_ref =
51 process->GetTarget().GetArchitecture().GetTriple();
52 switch (triple_ref.getOS()) {
53 case llvm::Triple::Darwin:
54 case llvm::Triple::MacOSX:
55 case llvm::Triple::IOS:
56 case llvm::Triple::TvOS:
57 case llvm::Triple::WatchOS:
58 // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
59 create = triple_ref.getVendor() == llvm::Triple::Apple;
60 break;
61 default:
62 create = false;
63 break;
64 }
65 }
66 }
67
68 if (!UseDYLDSPI(process)) {
69 create = false;
70 }
71
72 if (create)
73 return new DynamicLoaderMacOS(process);
74 return nullptr;
75}
76
77// Constructor
79 : DynamicLoaderDarwin(process), m_image_infos_stop_id(UINT32_MAX),
80 m_break_id(LLDB_INVALID_BREAK_ID),
81 m_dyld_handover_break_id(LLDB_INVALID_BREAK_ID), m_mutex(),
82 m_maybe_image_infos_address(LLDB_INVALID_ADDRESS),
83 m_libsystem_fully_initalized(false) {}
84
85// Destructor
91}
92
94 std::lock_guard<std::recursive_mutex> baseclass_guard(GetMutex());
95 bool did_exec = false;
96 if (m_process) {
97 // If we are stopped after an exec, we will have only one thread...
98 if (m_process->GetThreadList().GetSize() == 1) {
99 // Maybe we still have an image infos address around? If so see
100 // if that has changed, and if so we have exec'ed.
102 lldb::addr_t image_infos_address = m_process->GetImageInfoAddress();
103 if (image_infos_address != m_maybe_image_infos_address) {
104 // We don't really have to reset this here, since we are going to
105 // call DoInitialImageFetch right away to handle the exec. But in
106 // case anybody looks at it in the meantime, it can't hurt.
107 m_maybe_image_infos_address = image_infos_address;
108 did_exec = true;
109 }
110 }
111
112 if (!did_exec) {
113 // See if we are stopped at '_dyld_start'
115 if (thread_sp) {
116 lldb::StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0));
117 if (frame_sp) {
118 const Symbol *symbol =
119 frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol;
120 if (symbol) {
121 if (symbol->GetName() == "_dyld_start")
122 did_exec = true;
123 }
124 }
125 }
126 }
127 }
128 }
129
130 if (did_exec) {
134 }
135 return did_exec;
136}
137
138// Clear out the state of this class.
140 std::lock_guard<std::recursive_mutex> guard(m_mutex);
141
146
150}
151
154 return true;
155
156 StructuredData::ObjectSP process_state_sp(
158 if (!process_state_sp)
159 return true;
160 if (process_state_sp->GetAsDictionary()->HasKey("error"))
161 return true;
162 if (!process_state_sp->GetAsDictionary()->HasKey("process_state string"))
163 return true;
164 std::string proc_state = process_state_sp->GetAsDictionary()
165 ->GetValueForKey("process_state string")
166 ->GetAsString()
167 ->GetValue()
168 .str();
169 if (proc_state == "dyld_process_state_not_started" ||
170 proc_state == "dyld_process_state_dyld_initialized" ||
171 proc_state == "dyld_process_state_terminated_before_inits") {
172 return false;
173 }
175 return true;
176}
177
178// Check if we have found DYLD yet
181}
182
187 }
188}
189
190// Try and figure out where dyld is by first asking the Process if it knows
191// (which currently calls down in the lldb::Process to get the DYLD info
192// (available on SnowLeopard only). If that fails, then check in the default
193// addresses.
195 Log *log = GetLog(LLDBLog::DynamicLoader);
196
197 // Remove any binaries we pre-loaded in the Target before
198 // launching/attaching. If the same binaries are present in the process,
199 // we'll get them from the shared module cache, we won't need to re-load them
200 // from disk.
202
203 StructuredData::ObjectSP all_image_info_json_sp(
205 ImageInfo::collection image_infos;
206 if (all_image_info_json_sp.get() &&
207 all_image_info_json_sp->GetAsDictionary() &&
208 all_image_info_json_sp->GetAsDictionary()->HasKey("images") &&
209 all_image_info_json_sp->GetAsDictionary()
210 ->GetValueForKey("images")
211 ->GetAsArray()) {
212 if (JSONImageInformationIntoImageInfo(all_image_info_json_sp,
213 image_infos)) {
214 LLDB_LOGF(log, "Initial module fetch: Adding %" PRId64 " modules.\n",
215 (uint64_t)image_infos.size());
216
218 AddModulesUsingImageInfos(image_infos);
219 }
220 }
221
224}
225
227
228// Static callback function that gets called when our DYLD notification
229// breakpoint gets hit. We update all of our image infos and then let our super
230// class DynamicLoader class decide if we should stop or not (based on global
231// preference).
234 lldb::user_id_t break_id,
235 lldb::user_id_t break_loc_id) {
236 //
237 // Our breakpoint on
238 //
239 // void lldb_image_notifier(enum dyld_image_mode mode, uint32_t infoCount,
240 // const dyld_image_info info[])
241 //
242 // has been hit. We need to read the arguments.
243
244 DynamicLoaderMacOS *dyld_instance = (DynamicLoaderMacOS *)baton;
245
246 ExecutionContext exe_ctx(context->exe_ctx_ref);
247 Process *process = exe_ctx.GetProcessPtr();
248
249 // This is a sanity check just in case this dyld_instance is an old dyld
250 // plugin's breakpoint still lying around.
251 if (process != dyld_instance->m_process)
252 return false;
253
254 if (dyld_instance->m_image_infos_stop_id != UINT32_MAX &&
255 process->GetStopID() < dyld_instance->m_image_infos_stop_id) {
256 return false;
257 }
258
259 const lldb::ABISP &abi = process->GetABI();
260 if (abi) {
261 // Build up the value array to store the three arguments given above, then
262 // get the values from the ABI:
263
264 TypeSystemClangSP scratch_ts_sp =
266 if (!scratch_ts_sp)
267 return false;
268
269 ValueList argument_values;
270
271 Value mode_value; // enum dyld_notify_mode { dyld_notify_adding=0,
272 // dyld_notify_removing=1, dyld_notify_remove_all=2,
273 // dyld_notify_dyld_moved=3 };
274 Value count_value; // uint32_t
275 Value headers_value; // struct dyld_image_info machHeaders[]
276
277 CompilerType clang_void_ptr_type =
278 scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
279 CompilerType clang_uint32_type =
280 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(lldb::eEncodingUint,
281 32);
282 CompilerType clang_uint64_type =
283 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(lldb::eEncodingUint,
284 32);
285
286 mode_value.SetValueType(Value::ValueType::Scalar);
287 mode_value.SetCompilerType(clang_uint32_type);
288
289 count_value.SetValueType(Value::ValueType::Scalar);
290 count_value.SetCompilerType(clang_uint32_type);
291
292 headers_value.SetValueType(Value::ValueType::Scalar);
293 headers_value.SetCompilerType(clang_void_ptr_type);
294
295 argument_values.PushValue(mode_value);
296 argument_values.PushValue(count_value);
297 argument_values.PushValue(headers_value);
298
299 if (abi->GetArgumentValues(exe_ctx.GetThreadRef(), argument_values)) {
300 uint32_t dyld_mode =
301 argument_values.GetValueAtIndex(0)->GetScalar().UInt(-1);
302 if (dyld_mode != static_cast<uint32_t>(-1)) {
303 // Okay the mode was right, now get the number of elements, and the
304 // array of new elements...
305 uint32_t image_infos_count =
306 argument_values.GetValueAtIndex(1)->GetScalar().UInt(-1);
307 if (image_infos_count != static_cast<uint32_t>(-1)) {
308 addr_t header_array =
309 argument_values.GetValueAtIndex(2)->GetScalar().ULongLong(-1);
310 if (header_array != static_cast<uint64_t>(-1)) {
311 std::vector<addr_t> image_load_addresses;
312 // header_array points to an array of image_infos_count elements,
313 // each is
314 // struct dyld_image_info {
315 // const struct mach_header* imageLoadAddress;
316 // const char* imageFilePath;
317 // uintptr_t imageFileModDate;
318 // };
319 //
320 // and we only need the imageLoadAddress fields.
321
322 const int addrsize =
324 for (uint64_t i = 0; i < image_infos_count; i++) {
326 addr_t dyld_image_info = header_array + (addrsize * 3 * i);
327 addr_t addr =
328 process->ReadPointerFromMemory(dyld_image_info, error);
329 if (error.Success()) {
330 image_load_addresses.push_back(addr);
331 } else {
333 "DynamicLoaderMacOS::NotifyBreakpointHit unable "
334 "to read binary mach-o load address at 0x%" PRIx64,
335 addr);
336 }
337 }
338 if (dyld_mode == 0) {
339 // dyld_notify_adding
340 if (process->GetTarget().GetImages().GetSize() == 0) {
341 // When all images have been removed, we're doing the
342 // dyld handover from a launch-dyld to a shared-cache-dyld,
343 // and we've just hit our one-shot address breakpoint in
344 // the sc-dyld. Note that the image addresses passed to
345 // this function are inferior sizeof(void*) not uint64_t's
346 // like our normal notification, so don't even look at
347 // image_load_addresses.
348
349 dyld_instance->ClearDYLDHandoverBreakpoint();
350
351 dyld_instance->DoInitialImageFetch();
352 dyld_instance->SetNotificationBreakpoint();
353 } else {
354 dyld_instance->AddBinaries(image_load_addresses);
355 }
356 } else if (dyld_mode == 1) {
357 // dyld_notify_removing
358 dyld_instance->UnloadImages(image_load_addresses);
359 } else if (dyld_mode == 2) {
360 // dyld_notify_remove_all
361 dyld_instance->UnloadAllImages();
362 } else if (dyld_mode == 3 && image_infos_count == 1) {
363 // dyld_image_dyld_moved
364
365 dyld_instance->ClearNotificationBreakpoint();
366 dyld_instance->UnloadAllImages();
367 dyld_instance->ClearDYLDModule();
368 process->GetTarget().GetImages().Clear();
369 process->GetTarget().GetSectionLoadList().Clear();
370
371 addr_t all_image_infos = process->GetImageInfoAddress();
372 int addr_size =
374 addr_t notification_location = all_image_infos + 4 + // version
375 4 + // infoArrayCount
376 addr_size; // infoArray
378 addr_t notification_addr =
379 process->ReadPointerFromMemory(notification_location, error);
380 if (!error.Success()) {
382 "DynamicLoaderMacOS::NotifyBreakpointHit unable "
383 "to read address of dyld-handover notification function at "
384 "0x%" PRIx64,
385 notification_location);
386 } else {
387 notification_addr = process->FixCodeAddress(notification_addr);
388 dyld_instance->SetDYLDHandoverBreakpoint(notification_addr);
389 }
390 }
391 }
392 }
393 }
394 }
395 } else {
396 Target &target = process->GetTarget();
398 "no ABI plugin located for triple " +
399 target.GetArchitecture().GetTriple().getTriple() +
400 ": shared libraries will not be registered",
401 target.GetDebugger().GetID());
402 }
403
404 // Return true to stop the target, false to just let the target run
405 return dyld_instance->GetStopWhenImagesChange();
406}
407
409 const std::vector<lldb::addr_t> &load_addresses) {
410 Log *log = GetLog(LLDBLog::DynamicLoader);
411 ImageInfo::collection image_infos;
412
413 LLDB_LOGF(log, "Adding %" PRId64 " modules.",
414 (uint64_t)load_addresses.size());
415 StructuredData::ObjectSP binaries_info_sp =
417 if (binaries_info_sp.get() && binaries_info_sp->GetAsDictionary() &&
418 binaries_info_sp->GetAsDictionary()->HasKey("images") &&
419 binaries_info_sp->GetAsDictionary()
420 ->GetValueForKey("images")
421 ->GetAsArray() &&
422 binaries_info_sp->GetAsDictionary()
423 ->GetValueForKey("images")
424 ->GetAsArray()
425 ->GetSize() == load_addresses.size()) {
426 if (JSONImageInformationIntoImageInfo(binaries_info_sp, image_infos)) {
428 AddModulesUsingImageInfos(image_infos);
429 }
431 }
432}
433
434// Dump the _dyld_all_image_infos members and all current image infos that we
435// have parsed to the file handle provided.
437 if (log == nullptr)
438 return;
439}
440
441// Look in dyld's dyld_all_image_infos structure for the address
442// of the notification function.
443// We can find the address of dyld_all_image_infos by a system
444// call, even if we don't have a dyld binary registered in lldb's
445// image list.
446// At process launch time - before dyld has executed any instructions -
447// the address of the notification function is not a resolved vm address
448// yet. dyld_all_image_infos also has a field with its own address
449// in it, and this will also be unresolved when we're at this state.
450// So we can compare the address of the object with this field and if
451// they differ, dyld hasn't started executing yet and we can't get the
452// notification address this way.
454 addr_t notification_addr = LLDB_INVALID_ADDRESS;
455 if (!m_process)
456 return notification_addr;
457
458 addr_t all_image_infos_addr = m_process->GetImageInfoAddress();
459 if (all_image_infos_addr == LLDB_INVALID_ADDRESS)
460 return notification_addr;
461
462 const uint32_t addr_size =
464 offset_t registered_infos_addr_offset =
465 sizeof(uint32_t) + // version
466 sizeof(uint32_t) + // infoArrayCount
467 addr_size + // infoArray
468 addr_size + // notification
469 addr_size + // processDetachedFromSharedRegion +
470 // libSystemInitialized + pad
471 addr_size + // dyldImageLoadAddress
472 addr_size + // jitInfo
473 addr_size + // dyldVersion
474 addr_size + // errorMessage
475 addr_size + // terminationFlags
476 addr_size + // coreSymbolicationShmPage
477 addr_size + // systemOrderFlag
478 addr_size + // uuidArrayCount
479 addr_size; // uuidArray
480 // dyldAllImageInfosAddress
481
482 // If the dyldAllImageInfosAddress does not match
483 // the actual address of this struct, dyld has not started
484 // executing yet. The 'notification' field can't be used by
485 // lldb until it's resolved to an actual address.
487 addr_t registered_infos_addr = m_process->ReadPointerFromMemory(
488 all_image_infos_addr + registered_infos_addr_offset, error);
489 if (!error.Success())
490 return notification_addr;
491 if (registered_infos_addr != all_image_infos_addr)
492 return notification_addr;
493
494 offset_t notification_fptr_offset = sizeof(uint32_t) + // version
495 sizeof(uint32_t) + // infoArrayCount
496 addr_size; // infoArray
497
498 addr_t notification_fptr = m_process->ReadPointerFromMemory(
499 all_image_infos_addr + notification_fptr_offset, error);
500 if (error.Success())
501 notification_addr = m_process->FixCodeAddress(notification_fptr);
502 return notification_addr;
503}
504
505// We want to put a breakpoint on dyld's lldb_image_notifier()
506// but we may have attached to the process during the
507// transition from on-disk-dyld to shared-cache-dyld, so there's
508// officially no dyld binary loaded in the process (libdyld will
509// report none when asked), but the kernel can find the dyld_all_image_infos
510// struct and the function pointer for lldb_image_notifier is in
511// that struct.
513
514 // First try to find the notification breakpoint function by name
516 ModuleSP dyld_sp(GetDYLDModule());
517 if (dyld_sp) {
518 bool internal = true;
519 bool hardware = false;
520 LazyBool skip_prologue = eLazyBoolNo;
521 FileSpecList *source_files = nullptr;
522 FileSpecList dyld_filelist;
523 dyld_filelist.Append(dyld_sp->GetFileSpec());
524
525 Breakpoint *breakpoint =
527 .CreateBreakpoint(&dyld_filelist, source_files,
528 "lldb_image_notifier", eFunctionNameTypeFull,
529 eLanguageTypeUnknown, 0, skip_prologue,
530 internal, hardware)
531 .get();
533 true);
534 breakpoint->SetBreakpointKind("shared-library-event");
535 if (breakpoint->HasResolvedLocations())
536 m_break_id = breakpoint->GetID();
537 else
539
541 Breakpoint *breakpoint =
543 .CreateBreakpoint(&dyld_filelist, source_files,
544 "gdb_image_notifier", eFunctionNameTypeFull,
545 eLanguageTypeUnknown, 0, skip_prologue,
546 internal, hardware)
547 .get();
549 true);
550 breakpoint->SetBreakpointKind("shared-library-event");
551 if (breakpoint->HasResolvedLocations())
552 m_break_id = breakpoint->GetID();
553 else
555 }
556 }
557 }
558
559 // Failing that, find dyld_all_image_infos struct in memory,
560 // read the notification function pointer at the offset.
562 addr_t notification_addr = GetNotificationFuncAddrFromImageInfos();
563 if (notification_addr != LLDB_INVALID_ADDRESS) {
564 Address so_addr;
565 // We may not have a dyld binary mapped to this address yet;
566 // don't try to express the Address object as section+offset,
567 // only as a raw load address.
568 so_addr.SetRawAddress(notification_addr);
569 Breakpoint *dyld_break =
570 m_process->GetTarget().CreateBreakpoint(so_addr, true, false).get();
572 true);
573 dyld_break->SetBreakpointKind("shared-library-event");
574 if (dyld_break->HasResolvedLocations())
575 m_break_id = dyld_break->GetID();
576 else
578 }
579 }
581}
582
584 addr_t notification_address) {
586 BreakpointSP dyld_handover_bp = m_process->GetTarget().CreateBreakpoint(
587 notification_address, true, false);
588 dyld_handover_bp->SetCallback(DynamicLoaderMacOS::NotifyBreakpointHit, this,
589 true);
590 dyld_handover_bp->SetOneShot(true);
591 m_dyld_handover_break_id = dyld_handover_bp->GetID();
592 return true;
593 }
594 return false;
595}
596
601}
602
603addr_t
605 SymbolContext sc;
606 Target &target = m_process->GetTarget();
607 if (Symtab *symtab = module->GetSymtab()) {
608 std::vector<uint32_t> match_indexes;
609 ConstString g_symbol_name("_dyld_global_lock_held");
610 uint32_t num_matches = 0;
611 num_matches =
612 symtab->AppendSymbolIndexesWithName(g_symbol_name, match_indexes);
613 if (num_matches == 1) {
614 Symbol *symbol = symtab->SymbolAtIndex(match_indexes[0]);
615 if (symbol &&
616 (symbol->ValueIsAddress() || symbol->GetAddressRef().IsValid())) {
617 return symbol->GetAddressRef().GetOpcodeLoadAddress(&target);
618 }
619 }
620 }
622}
623
624// Look for this symbol:
625//
626// int __attribute__((visibility("hidden"))) _dyld_global_lock_held =
627// 0;
628//
629// in libdyld.dylib.
632 addr_t symbol_address = LLDB_INVALID_ADDRESS;
633 ConstString g_libdyld_name("libdyld.dylib");
634 Target &target = m_process->GetTarget();
635 const ModuleList &target_modules = target.GetImages();
636 std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
637
638 // Find any modules named "libdyld.dylib" and look for the symbol there first
639 for (ModuleSP module_sp : target.GetImages().ModulesNoLocking()) {
640 if (module_sp) {
641 if (module_sp->GetFileSpec().GetFilename() == g_libdyld_name) {
642 symbol_address = GetDyldLockVariableAddressFromModule(module_sp.get());
643 if (symbol_address != LLDB_INVALID_ADDRESS)
644 break;
645 }
646 }
647 }
648
649 // Search through all modules looking for the symbol in them
650 if (symbol_address == LLDB_INVALID_ADDRESS) {
651 for (ModuleSP module_sp : target.GetImages().Modules()) {
652 if (module_sp) {
653 addr_t symbol_address =
655 if (symbol_address != LLDB_INVALID_ADDRESS)
656 break;
657 }
658 }
659 }
660
661 // Default assumption is that it is OK to load images. Only say that we
662 // cannot load images if we find the symbol in libdyld and it indicates that
663 // we cannot.
664
665 if (symbol_address != LLDB_INVALID_ADDRESS) {
666 {
667 int lock_held =
668 m_process->ReadUnsignedIntegerFromMemory(symbol_address, 4, 0, error);
669 if (lock_held != 0) {
670 error.SetErrorString("dyld lock held - unsafe to load images.");
671 }
672 }
673 } else {
674 // If we were unable to find _dyld_global_lock_held in any modules, or it
675 // is not loaded into memory yet, we may be at process startup (sitting at
676 // _dyld_start) - so we should not allow dlopen calls. But if we found more
677 // than one module then we are clearly past _dyld_start so in that case
678 // we'll default to "it's safe".
679 if (target.GetImages().GetSize() <= 1)
680 error.SetErrorString("could not find the dyld library or "
681 "the dyld lock symbol");
682 }
683 return error;
684}
685
687 lldb::addr_t &base_address, UUID &uuid, LazyBool &using_shared_cache,
688 LazyBool &private_shared_cache) {
689 base_address = LLDB_INVALID_ADDRESS;
690 uuid.Clear();
691 using_shared_cache = eLazyBoolCalculate;
692 private_shared_cache = eLazyBoolCalculate;
693
694 if (m_process) {
696 StructuredData::Dictionary *info_dict = nullptr;
697 if (info.get() && info->GetAsDictionary()) {
698 info_dict = info->GetAsDictionary();
699 }
700
701 // {"shared_cache_base_address":140735683125248,"shared_cache_uuid
702 // ":"DDB8D70C-
703 // C9A2-3561-B2C8-BE48A4F33F96","no_shared_cache":false,"shared_cache_private_cache":false}
704
705 if (info_dict && info_dict->HasKey("shared_cache_uuid") &&
706 info_dict->HasKey("no_shared_cache") &&
707 info_dict->HasKey("shared_cache_base_address")) {
708 base_address = info_dict->GetValueForKey("shared_cache_base_address")
709 ->GetUnsignedIntegerValue(LLDB_INVALID_ADDRESS);
710 std::string uuid_str = std::string(
711 info_dict->GetValueForKey("shared_cache_uuid")->GetStringValue());
712 if (!uuid_str.empty())
713 uuid.SetFromStringRef(uuid_str);
714 if (!info_dict->GetValueForKey("no_shared_cache")->GetBooleanValue())
715 using_shared_cache = eLazyBoolYes;
716 else
717 using_shared_cache = eLazyBoolNo;
718 if (info_dict->GetValueForKey("shared_cache_private_cache")
719 ->GetBooleanValue())
720 private_shared_cache = eLazyBoolYes;
721 else
722 private_shared_cache = eLazyBoolNo;
723
724 return true;
725 }
726 }
727 return false;
728}
729
733}
734
737}
738
740 return "Dynamic loader plug-in that watches for shared library loads/unloads "
741 "in MacOSX user processes.";
742}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
Definition: Log.h:349
bool SetNotificationBreakpoint() override
bool GetSharedCacheInformation(lldb::addr_t &base_address, lldb_private::UUID &uuid, lldb_private::LazyBool &using_shared_cache, lldb_private::LazyBool &private_shared_cache) override
Get information about the shared cache for a process, if possible.
static lldb_private::DynamicLoader * CreateInstance(lldb_private::Process *process, bool force)
lldb_private::Status CanLoadImage() override
Ask if it is ok to try and load or unload an shared library (image).
void PutToLog(lldb_private::Log *log) const
bool IsFullyInitialized() override
Return whether the dynamic loader is fully initialized and it's safe to call its APIs.
lldb::addr_t GetDyldLockVariableAddressFromModule(lldb_private::Module *module)
bool NeedToDoInitialImageFetch() override
std::recursive_mutex m_mutex
void DoInitialImageFetch() override
static llvm::StringRef GetPluginNameStatic()
static llvm::StringRef GetPluginDescriptionStatic()
lldb::user_id_t m_break_id
lldb::addr_t GetNotificationFuncAddrFromImageInfos()
bool SetDYLDHandoverBreakpoint(lldb::addr_t notification_address)
void AddBinaries(const std::vector< lldb::addr_t > &load_addresses)
void ClearNotificationBreakpoint() override
static bool NotifyBreakpointHit(void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
lldb::addr_t m_maybe_image_infos_address
bool ProcessDidExec() override
Called after attaching a process.
lldb::user_id_t m_dyld_handover_break_id
DynamicLoaderMacOS(lldb_private::Process *process)
bool DidSetNotificationBreakpoint() override
A section + offset based address class.
Definition: Address.h:59
void Clear()
Clear the object's state.
Definition: Address.h:178
lldb::addr_t GetOpcodeLoadAddress(Target *target, AddressClass addr_class=AddressClass::eInvalid) const
Get the load address as an opcode load address.
Definition: Address.cpp:368
void SetRawAddress(lldb::addr_t addr)
Definition: Address.h:444
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:345
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition: ArchSpec.cpp:691
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:450
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition: Breakpoint.h:81
void SetBreakpointKind(const char *kind)
Set the "kind" description for a breakpoint.
Definition: Breakpoint.h:452
bool HasResolvedLocations() const
Return whether this breakpoint has any resolved locations.
Definition: Breakpoint.cpp:838
void SetCallback(BreakpointHitCallback callback, void *baton, bool is_synchronous=false)
Set the callback action invoked when the breakpoint is hit.
Definition: Breakpoint.cpp:413
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
A uniqued constant string class.
Definition: ConstString.h:40
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
Definition: Debugger.cpp:1532
void UpdateSpecialBinariesFromNewImageInfos(ImageInfo::collection &image_infos)
std::recursive_mutex & GetMutex() const
bool AddModulesUsingImageInfos(ImageInfo::collection &image_infos)
bool JSONImageInformationIntoImageInfo(lldb_private::StructuredData::ObjectSP image_details, ImageInfo::collection &image_infos)
static bool UseDYLDSPI(lldb_private::Process *process)
lldb_private::Address m_pthread_getspecific_addr
void UnloadImages(const std::vector< lldb::addr_t > &solib_addresses)
A plug-in interface definition class for dynamic loaders.
Definition: DynamicLoader.h:52
Process * m_process
The process that this dynamic loader plug-in is tracking.
bool GetStopWhenImagesChange() const
Get whether the process should stop when images change.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Process * GetProcessPtr() const
Returns a pointer to the process object.
Thread & GetThreadRef() const
Returns a reference to the thread object.
A file collection class.
Definition: FileSpecList.h:24
void Append(const FileSpec &file)
Append a FileSpec object to the list.
A collection class for Module objects.
Definition: ModuleList.h:82
ModuleIterableNoLocking ModulesNoLocking() const
Definition: ModuleList.h:516
std::recursive_mutex & GetMutex() const
Definition: ModuleList.h:209
void Clear()
Clear the object's state.
Definition: ModuleList.cpp:384
ModuleIterable Modules() const
Definition: ModuleList.h:510
size_t GetSize() const
Gets the size of the module list.
Definition: ModuleList.cpp:626
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:88
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
Definition: Module.cpp:1255
Symtab * GetSymtab()
Definition: Module.cpp:1091
A plug-in interface definition class for object file parsers.
Definition: ObjectFile.h:44
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A plug-in interface definition class for debugging a process.
Definition: Process.h:336
ThreadList & GetThreadList()
Definition: Process.h:2155
virtual lldb_private::StructuredData::ObjectSP GetSharedCacheInfo()
Definition: Process.h:1343
virtual lldb_private::StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos(lldb::addr_t image_list_address, lldb::addr_t image_count)
Retrieve the list of shared libraries that are loaded for this process This method is used on pre-mac...
Definition: Process.h:1318
uint64_t ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Status &error)
Reads an unsigned integer of the specified byte size from process memory.
Definition: Process.cpp:2067
virtual lldb::addr_t GetImageInfoAddress()
Get the image information address for the current process.
Definition: Process.cpp:1485
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
Definition: Process.cpp:2089
virtual lldb_private::StructuredData::ObjectSP GetDynamicLoaderProcessState()
Definition: Process.h:1352
lldb::addr_t FixCodeAddress(lldb::addr_t pc)
Some targets might use bits in a code address to indicate a mode switch, ARM uses bit zero to signify...
Definition: Process.cpp:5722
uint32_t GetStopID() const
Definition: Process.h:1427
const lldb::ABISP & GetABI()
Definition: Process.cpp:1487
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1242
unsigned int UInt(unsigned int fail_value=0) const
Definition: Scalar.cpp:321
unsigned long long ULongLong(unsigned long long fail_value=0) const
Definition: Scalar.cpp:335
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.
An error handling class.
Definition: Status.h:44
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
lldb::break_id_t GetID() const
Definition: Stoppoint.cpp:22
ObjectSP GetValueForKey(llvm::StringRef key) const
bool HasKey(llvm::StringRef key) const
std::shared_ptr< Object > ObjectSP
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
bool ValueIsAddress() const
Definition: Symbol.cpp:167
Address & GetAddressRef()
Definition: Symbol.h:71
ConstString GetName() const
Definition: Symbol.cpp:544
Module * GetExecutableModulePointer()
Definition: Target.cpp:1389
SectionLoadList & GetSectionLoadList()
Definition: Target.h:1122
Debugger & GetDebugger()
Definition: Target.h:1050
bool RemoveBreakpointByID(lldb::break_id_t break_id)
Definition: Target.cpp:957
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
Definition: Target.cpp:355
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:967
const ArchSpec & GetArchitecture() const
Definition: Target.h:1009
uint32_t GetSize(bool can_update=true)
Definition: ThreadList.cpp:83
lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update=true)
Definition: ThreadList.cpp:91
bool SetFromStringRef(llvm::StringRef str)
Definition: UUID.cpp:97
void Clear()
Definition: UUID.h:62
void PushValue(const Value &value)
Definition: Value.cpp:680
Value * GetValueAtIndex(size_t idx)
Definition: Value.cpp:684
const Scalar & GetScalar() const
Definition: Value.h:112
void SetCompilerType(const CompilerType &compiler_type)
Definition: Value.cpp:266
void SetValueType(ValueType value_type)
Definition: Value.h:89
#define LLDB_INVALID_BREAK_ID
Definition: lldb-defines.h:37
#define LLDB_BREAK_ID_IS_VALID(bid)
Definition: lldb-defines.h:39
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:76
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:314
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::ABI > ABISP
Definition: lldb-forward.h:300
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
Definition: lldb-forward.h:399
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:425
uint64_t offset_t
Definition: lldb-types.h:83
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
Definition: lldb-forward.h:303
@ eEncodingUint
unsigned integer
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
Definition: lldb-forward.h:445
uint64_t user_id_t
Definition: lldb-types.h:80
uint64_t addr_t
Definition: lldb-types.h:79
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:354
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47