LLDB mainline
DYLDRendezvous.cpp
Go to the documentation of this file.
1//===-- DYLDRendezvous.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 "lldb/Core/Module.h"
11#include "lldb/Symbol/Symbol.h"
14#include "lldb/Target/Process.h"
15#include "lldb/Target/Target.h"
18#include "lldb/Utility/Log.h"
19#include "lldb/Utility/Status.h"
20
21#include "llvm/Support/Error.h"
22#include "llvm/Support/Path.h"
23
24#include "DYLDRendezvous.h"
25
26using namespace lldb;
27using namespace lldb_private;
28
30 switch (state) {
32 return "eConsistent";
34 return "eAdd";
36 return "eDelete";
37 }
38 return "<invalid RendezvousState>";
39}
40
42 switch (action) {
44 return "eTakeSnapshot";
46 return "eAddModules";
48 return "eRemoveModules";
50 return "eNoAction";
51 }
52 return "<invalid RendezvousAction>";
53}
54
63
66 addr_t info_location;
67 addr_t info_addr;
68
69 if (!m_process) {
70 LLDB_LOGF(log, "%s null process provided", __FUNCTION__);
72 }
73
74 // Try to get it from our process. This might be a remote process and might
75 // grab it via some remote-specific mechanism.
76 info_location = m_process->GetImageInfoAddress();
77 LLDB_LOGF(log, "%s info_location = 0x%" PRIx64, __FUNCTION__, info_location);
78
79 // If the process fails to return an address, fall back to seeing if the
80 // local object file can help us find it.
81 if (info_location == LLDB_INVALID_ADDRESS) {
82 Target *target = &m_process->GetTarget();
83 if (target) {
84 ObjectFile *obj_file = target->GetExecutableModule()->GetObjectFile();
85 Address addr = obj_file->GetImageInfoAddress(target);
86
87 if (addr.IsValid()) {
88 info_location = addr.GetLoadAddress(target);
89 LLDB_LOGF(log,
90 "%s resolved via direct object file approach to 0x%" PRIx64,
91 __FUNCTION__, info_location);
92 } else {
93 const Symbol *_r_debug =
94 target->GetExecutableModule()->FindFirstSymbolWithNameAndType(
95 ConstString("_r_debug"));
96 if (_r_debug) {
97 info_addr = _r_debug->GetAddress().GetLoadAddress(target);
98 if (info_addr != LLDB_INVALID_ADDRESS) {
99 LLDB_LOGF(log,
100 "%s resolved by finding symbol '_r_debug' whose value is "
101 "0x%" PRIx64,
102 __FUNCTION__, info_addr);
104 return info_addr;
105 }
106 }
107 LLDB_LOGF(log,
108 "%s FAILED - direct object file approach did not yield a "
109 "valid address",
110 __FUNCTION__);
111 }
112 }
113 }
114
115 if (info_location == LLDB_INVALID_ADDRESS) {
116 LLDB_LOGF(log, "%s FAILED - invalid info address", __FUNCTION__);
118 }
119
120 LLDB_LOGF(log, "%s reading pointer (%" PRIu32 " bytes) from 0x%" PRIx64,
121 __FUNCTION__, m_process->GetAddressByteSize(), info_location);
122
123 llvm::Expected<lldb::addr_t> info_addr_or_err =
124 m_process->ReadPointerFromMemory(info_location);
125 if (!info_addr_or_err) {
126 LLDB_LOG_ERROR(log, info_addr_or_err.takeError(),
127 "{1} FAILED - could not read from the info location: {0}",
128 __FUNCTION__);
130 }
131 info_addr = *info_addr_or_err;
132
133 if (info_addr == 0) {
134 LLDB_LOGF(log,
135 "%s FAILED - the rendezvous address contained at 0x%" PRIx64
136 " returned a null value",
137 __FUNCTION__, info_location);
139 }
140
141 return info_addr;
142}
143
145 if (m_process) {
147 Module *exe_mod = m_process->GetTarget().GetExecutableModulePointer();
148 if (exe_mod) {
150 LLDB_LOGF(log, "DYLDRendezvous::%s exe module executable path set: '%s'",
151 __FUNCTION__, m_exe_file_spec.GetPath().c_str());
152 } else {
153 LLDB_LOGF(log,
154 "DYLDRendezvous::%s cannot cache exe module path: null "
155 "executable module pointer",
156 __FUNCTION__);
157 }
158 }
159}
160
161void DYLDRendezvous::Rendezvous::DumpToLog(Log *log, const char *label) {
162 LLDB_LOGF(log, "%s Rendezvous: version = %" PRIu64 ", map_addr = 0x%16.16"
163 PRIx64 ", brk = 0x%16.16" PRIx64 ", state = %" PRIu64
164 " (%s), ldbase = 0x%16.16" PRIx64, label ? label : "", version,
166}
167
170
171 const size_t word_size = 4;
172 Rendezvous info;
173 size_t address_size;
174 size_t padding;
175 addr_t info_addr;
176 addr_t cursor;
177
178 address_size = m_process->GetAddressByteSize();
179 padding = address_size - word_size;
180 LLDB_LOGF(log,
181 "DYLDRendezvous::%s address size: %" PRIu64 ", padding %" PRIu64,
182 __FUNCTION__, uint64_t(address_size), uint64_t(padding));
183
185 cursor = info_addr =
187 else
188 cursor = info_addr = m_rendezvous_addr;
189 LLDB_LOGF(log, "DYLDRendezvous::%s cursor = 0x%" PRIx64, __FUNCTION__,
190 cursor);
191
192 if (cursor == LLDB_INVALID_ADDRESS)
193 return false;
194
195 if (!(cursor = ReadWord(cursor, &info.version, word_size)))
196 return false;
197
198 if (!(cursor = ReadPointer(cursor + padding, &info.map_addr)))
199 return false;
200
201 if (!(cursor = ReadPointer(cursor, &info.brk)))
202 return false;
203
204 if (!(cursor = ReadWord(cursor, &info.state, word_size)))
205 return false;
206
207 if (!(cursor = ReadPointer(cursor + padding, &info.ldbase)))
208 return false;
209
210 // The rendezvous was successfully read. Update our internal state.
211 m_rendezvous_addr = info_addr;
213 m_current = info;
214
215 m_previous.DumpToLog(log, "m_previous");
216 m_current.DumpToLog(log, "m_current ");
217
218 if (m_current.map_addr == 0)
219 return false;
220
222 return true;
223
224 return UpdateSOEntries();
225}
226
230
232 // If we have a core file, we will read the current rendezvous state
233 // from the core file's memory into m_current which can be in an inconsistent
234 // state, so we can't rely on its state to determine what we should do. We
235 // always need it to load all of the shared libraries one time when we attach
236 // to a core file.
237 if (IsCoreFile())
238 return eTakeSnapshot;
239
240 switch (m_current.state) {
241
242 case eConsistent:
243 switch (m_previous.state) {
244 // When the previous and current states are consistent this is the first
245 // time we have been asked to update. Just take a snapshot of the
246 // currently loaded modules.
247 case eConsistent:
248 return eTakeSnapshot;
249 // If we are about to add or remove a shared object clear out the current
250 // state and take a snapshot of the currently loaded images.
251 case eAdd:
252 return eAddModules;
253 case eDelete:
254 return eRemoveModules;
255 }
256 break;
257
258 case eAdd:
259 // If the main executable or a shared library defines a publicly visible
260 // symbol named "_r_debug", then it will cause problems once the executable
261 // that contains the symbol is loaded into the process. The correct
262 // "_r_debug" structure is currently found by LLDB by looking through
263 // the .dynamic section in the main executable and finding the DT_DEBUG tag
264 // entry.
265 //
266 // An issue comes up if someone defines another publicly visible "_r_debug"
267 // struct in their program. Sample code looks like:
268 //
269 // #include <link.h>
270 // r_debug _r_debug;
271 //
272 // If code like this is in an executable or shared library, this creates a
273 // new "_r_debug" structure and it causes problems once the executable is
274 // loaded due to the way symbol lookups happen in linux: the shared library
275 // list from _r_debug.r_map will be searched for a symbol named "_r_debug"
276 // and the first match will be the new version that is used. The dynamic
277 // loader is always last in this list. So at some point the dynamic loader
278 // will start updating the copy of "_r_debug" that gets found first. The
279 // issue is that LLDB will only look at the copy that is pointed to by the
280 // DT_DEBUG entry, or the initial version from the ld.so binary.
281 //
282 // Steps that show the problem are:
283 //
284 // - LLDB finds the "_r_debug" structure via the DT_DEBUG entry in the
285 // .dynamic section and this points to the "_r_debug" in ld.so
286 // - ld.so uodates its copy of "_r_debug" with "state = eAdd" before it
287 // loads the dependent shared libraries for the main executable and
288 // any dependencies of all shared libraries from the executable's list
289 // and ld.so code calls the debugger notification function
290 // that LLDB has set a breakpoint on.
291 // - LLDB hits the breakpoint and the breakpoint has a callback function
292 // where we read the _r_debug.state (eAdd) state and we do nothing as the
293 // "eAdd" state indicates that the shared libraries are about to be added.
294 // - ld.so finishes loading the main executable and any dependent shared
295 // libraries and it will update the "_r_debug.state" member with a
296 // "eConsistent", but it now updates the "_r_debug" in the a.out program
297 // and it calls the debugger notification function.
298 // - lldb hits the notification breakpoint and checks the ld.so copy of
299 // "_r_debug.state" which still has a state of "eAdd", but LLDB needs to see a
300 // "eConsistent" state to trigger the shared libraries to get loaded into
301 // the debug session, but LLDB the ld.so _r_debug.state which still
302 // contains "eAdd" and doesn't do anyhing and library load is missed.
303 // The "_r_debug" in a.out has the state set correctly to "eConsistent"
304 // but LLDB is still looking at the "_r_debug" from ld.so.
305 //
306 // So if we detect two "eAdd" states in a row, we assume this is the issue
307 // and we now load shared libraries correctly and will emit a log message
308 // in the "log enable lldb dyld" log channel which states there might be
309 // multiple "_r_debug" structs causing problems.
310 //
311 // The correct solution is that no one should be adding a duplicate
312 // publicly visible "_r_debug" symbols to their binaries, but we have
313 // programs that are doing this already and since it can be done, we should
314 // be able to work with this and keep debug sessions working as expected.
315 //
316 // If a user includes the <link.h> file, they can just use the existing
317 // "_r_debug" structure as it is defined in this header file as "extern
318 // struct r_debug _r_debug;" and no local copies need to be made.
319 if (m_previous.state == eAdd) {
321 LLDB_LOG(log, "DYLDRendezvous::GetAction() found two eAdd states in a "
322 "row, check process for multiple \"_r_debug\" symbols. "
323 "Returning eAddModules to ensure shared libraries get loaded "
324 "correctly");
325 return eAddModules;
326 }
327 return eNoAction;
328 case eDelete:
329 return eNoAction;
330 }
331
332 return eNoAction;
333}
334
336 const auto action = GetAction();
338 LLDB_LOG(log, "{0} action = {1}", LLVM_PRETTY_FUNCTION, ActionToCStr(action));
339
340 if (action == eNoAction)
341 return false;
342
343 m_added_soentries.clear();
344 m_removed_soentries.clear();
345 if (action == eTakeSnapshot) {
346 // We already have the loaded list from the previous update so no need to
347 // find all the modules again.
348 if (!m_loaded_modules.m_list.empty())
349 return true;
350 }
351
352 llvm::Expected<LoadedModuleInfoList> module_list =
353 m_process->GetLoadedModuleList();
354 if (!module_list) {
355 llvm::consumeError(module_list.takeError());
356 return false;
357 }
358
359 switch (action) {
360 case eTakeSnapshot:
361 m_soentries.clear();
362 return SaveSOEntriesFromRemote(*module_list);
363 case eAddModules:
364 return AddSOEntriesFromRemote(*module_list);
365 case eRemoveModules:
366 return RemoveSOEntriesFromRemote(*module_list);
367 case eNoAction:
368 return false;
369 }
370 llvm_unreachable("Fully covered switch above!");
371}
372
374 m_added_soentries.clear();
375 m_removed_soentries.clear();
376 const auto action = GetAction();
378 LLDB_LOG(log, "{0} action = {1}", LLVM_PRETTY_FUNCTION, ActionToCStr(action));
379 switch (action) {
380 case eTakeSnapshot:
381 m_soentries.clear();
383 case eAddModules:
384 return AddSOEntries();
385 case eRemoveModules:
386 return RemoveSOEntries();
387 case eNoAction:
388 return false;
389 }
390 llvm_unreachable("Fully covered switch above!");
391}
392
394 LoadedModuleInfoList::LoadedModuleInfo const &modInfo, SOEntry &entry) {
395 addr_t link_map_addr;
396 addr_t base_addr;
397 addr_t dyn_addr;
398 std::string name;
399
400 if (!modInfo.get_link_map(link_map_addr) || !modInfo.get_base(base_addr) ||
401 !modInfo.get_dynamic(dyn_addr) || !modInfo.get_name(name))
402 return false;
403
404 entry.link_addr = link_map_addr;
405 entry.base_addr = base_addr;
406 entry.dyn_addr = dyn_addr;
407
408 entry.file_spec.SetFile(name, FileSpec::Style::native);
409
410 UpdateBaseAddrIfNecessary(entry, name);
411
412 // not needed if we're using ModuleInfos
413 entry.next = 0;
414 entry.prev = 0;
415 entry.path_addr = 0;
416
417 return true;
418}
419
421 const LoadedModuleInfoList &module_list) {
422 for (auto const &modInfo : module_list.m_list) {
423 SOEntry entry;
424 if (!FillSOEntryFromModuleInfo(modInfo, entry))
425 return false;
426
427 // Only add shared libraries and not the executable.
428 if (!SOEntryIsMainExecutable(entry)) {
430 m_soentries.push_back(entry);
431 }
432 }
433
434 m_loaded_modules = module_list;
435 return true;
436}
437
439 const LoadedModuleInfoList &module_list) {
440 for (auto const &modInfo : module_list.m_list) {
441 bool found = false;
442 for (auto const &existing : m_loaded_modules.m_list) {
443 if (modInfo == existing) {
444 found = true;
445 break;
446 }
447 }
448
449 if (found)
450 continue;
451
452 SOEntry entry;
453 if (!FillSOEntryFromModuleInfo(modInfo, entry))
454 return false;
455
456 // Only add shared libraries and not the executable.
457 if (!SOEntryIsMainExecutable(entry)) {
459 m_soentries.push_back(entry);
460 m_added_soentries.push_back(entry);
461 }
462 }
463
464 m_loaded_modules = module_list;
465 return true;
466}
467
469 const LoadedModuleInfoList &module_list) {
470 for (auto const &existing : m_loaded_modules.m_list) {
471 bool found = false;
472 for (auto const &modInfo : module_list.m_list) {
473 if (modInfo == existing) {
474 found = true;
475 break;
476 }
477 }
478
479 if (found)
480 continue;
481
482 SOEntry entry;
483 if (!FillSOEntryFromModuleInfo(existing, entry))
484 return false;
485
486 // Only add shared libraries and not the executable.
487 if (!SOEntryIsMainExecutable(entry)) {
488 auto pos = llvm::find(m_soentries, entry);
489 if (pos == m_soentries.end())
490 return false;
491
492 m_soentries.erase(pos);
493 m_removed_soentries.push_back(entry);
494 }
495 }
496
497 m_loaded_modules = module_list;
498 return true;
499}
500
502 SOEntry entry;
503
504 assert(m_previous.state == eAdd);
505
506 if (m_current.map_addr == 0)
507 return false;
508
509 for (addr_t cursor = m_current.map_addr; cursor != 0; cursor = entry.next) {
510 if (!ReadSOEntryFromMemory(cursor, entry))
511 return false;
512
513 // Only add shared libraries and not the executable.
514 if (SOEntryIsMainExecutable(entry))
515 continue;
516
518
519 if (!llvm::is_contained(m_soentries, entry)) {
520 m_soentries.push_back(entry);
521 m_added_soentries.push_back(entry);
522 }
523 }
524
525 return true;
526}
527
529 SOEntryList entry_list;
530
531 assert(m_previous.state == eDelete);
532
533 if (!TakeSnapshot(entry_list))
534 return false;
535
536 for (iterator I = begin(); I != end(); ++I) {
537 if (!llvm::is_contained(entry_list, *I))
538 m_removed_soentries.push_back(*I);
539 }
540
541 m_soentries = entry_list;
542 return true;
543}
544
546 // On some systes the executable is indicated by an empty path in the entry.
547 // On others it is the full path to the executable.
548
549 auto triple = m_process->GetTarget().GetArchitecture().GetTriple();
550 switch (triple.getOS()) {
551 case llvm::Triple::FreeBSD:
552 case llvm::Triple::NetBSD:
553 case llvm::Triple::OpenBSD:
554 return entry.file_spec == m_exe_file_spec;
555 case llvm::Triple::Linux:
556 if (triple.isAndroid())
557 return entry.file_spec == m_exe_file_spec;
558 // If we are debugging ld.so, then all SOEntries should be treated as
559 // libraries, including the "main" one (denoted by an empty string).
561 return false;
562 return !entry.file_spec;
563 default:
564 return false;
565 }
566}
567
569 SOEntry entry;
570
571 if (m_current.map_addr == 0)
572 return false;
573
574 // Clear previous entries since we are about to obtain an up to date list.
575 entry_list.clear();
576
577 for (addr_t cursor = m_current.map_addr; cursor != 0; cursor = entry.next) {
578 if (!ReadSOEntryFromMemory(cursor, entry))
579 return false;
580
581 // Only add shared libraries and not the executable.
582 if (SOEntryIsMainExecutable(entry))
583 continue;
584
586
587 entry_list.push_back(entry);
588 }
589
590 return true;
591}
592
593addr_t DYLDRendezvous::ReadWord(addr_t addr, uint64_t *dst, size_t size) {
595
596 *dst = m_process->ReadUnsignedIntegerFromMemory(addr, size, 0, error);
597 if (error.Fail())
598 return 0;
599
600 return addr + size;
601}
602
604 llvm::Expected<lldb::addr_t> dst_or_err =
605 m_process->ReadPointerFromMemory(addr);
606 if (!dst_or_err) {
607 llvm::consumeError(dst_or_err.takeError());
608 return 0;
609 }
610 *dst = *dst_or_err;
611
612 return addr + m_process->GetAddressByteSize();
613}
614
616 std::string str;
618
619 if (addr == LLDB_INVALID_ADDRESS)
620 return std::string();
621
622 m_process->ReadCStringFromMemory(addr, str, error);
623
624 return str;
625}
626
627// Returns true if the load bias reported by the linker is incorrect for the
628// given entry. This function is used to handle cases where we want to work
629// around a bug in the system linker.
630static bool isLoadBiasIncorrect(Target &target, const std::string &file_path) {
631 // On Android L (API 21, 22) the load address of the "/system/bin/linker"
632 // isn't filled in correctly.
633 unsigned os_major = target.GetPlatform()->GetOSVersion().getMajor();
634 return target.GetArchitecture().GetTriple().isAndroid() &&
635 (os_major == 21 || os_major == 22) &&
636 (file_path == "/system/bin/linker" ||
637 file_path == "/system/bin/linker64");
638}
639
641 std::string const &file_path) {
642 // If the load bias reported by the linker is incorrect then fetch the load
643 // address of the file from the proc file system.
644 if (isLoadBiasIncorrect(m_process->GetTarget(), file_path)) {
646 bool is_loaded = false;
647 Status error =
648 m_process->GetFileLoadAddress(entry.file_spec, is_loaded, load_addr);
649 if (error.Success() && is_loaded)
650 entry.base_addr = load_addr;
651 }
652}
653
655 // Updates filename if empty. It is useful while debugging ld.so,
656 // when the link map returns empty string for the main executable.
657 if (!entry.file_spec) {
658 MemoryRegionInfo region;
659 Status region_status =
660 m_process->GetMemoryRegionInfo(entry.dyn_addr, region);
661 if (!region.GetName().IsEmpty())
662 entry.file_spec.SetFile(region.GetName().GetStringRef(),
663 FileSpec::Style::native);
664 }
665}
666
668 entry.clear();
669
670 entry.link_addr = addr;
671
672 if (!(addr = ReadPointer(addr, &entry.base_addr)))
673 return false;
674
675 // mips adds an extra load offset field to the link map struct on FreeBSD and
676 // NetBSD (need to validate other OSes).
677 // http://svnweb.freebsd.org/base/head/sys/sys/link_elf.h?revision=217153&view=markup#l57
678 const ArchSpec &arch = m_process->GetTarget().GetArchitecture();
679 if ((arch.GetTriple().getOS() == llvm::Triple::FreeBSD ||
680 arch.GetTriple().getOS() == llvm::Triple::NetBSD) &&
681 arch.IsMIPS()) {
682 addr_t mips_l_offs;
683 if (!(addr = ReadPointer(addr, &mips_l_offs)))
684 return false;
685 if (mips_l_offs != 0 && mips_l_offs != entry.base_addr)
686 return false;
687 }
688
689 if (!(addr = ReadPointer(addr, &entry.path_addr)))
690 return false;
691
692 if (!(addr = ReadPointer(addr, &entry.dyn_addr)))
693 return false;
694
695 if (!(addr = ReadPointer(addr, &entry.next)))
696 return false;
697
698 if (!(addr = ReadPointer(addr, &entry.prev)))
699 return false;
700
701 std::string file_path = ReadStringFromMemory(entry.path_addr);
702 entry.file_spec.SetFile(file_path, FileSpec::Style::native);
703
704 UpdateBaseAddrIfNecessary(entry, file_path);
705
706 return true;
707}
708
709bool DYLDRendezvous::FindMetadata(const char *name, PThreadField field,
710 uint32_t &value) {
711 Target &target = m_process->GetTarget();
712
715 eSymbolTypeAny, list);
716 if (list.IsEmpty())
717 return false;
718
719 Address address = list[0].symbol->GetAddress();
720 // eSize, eNElem, and eOffset correspond to the fields of the DESC structure.
721 // eStructSize instructs to read a value generated by DB_STRUCT.
722 int field_num = (field == eStructSize) ? 0 : field;
723 address.Slide(field_num * sizeof(uint32_t));
724
725 // Read from target memory as this allows us to try process memory and
726 // fallback to reading from read only sections from the object files. Here we
727 // are reading read only data from libpthread.so to find data in the thread
728 // specific area for the data we want and this won't be saved into process
729 // memory due to it being read only.
731 value =
732 target.ReadUnsignedIntegerFromMemory(address, sizeof(uint32_t), 0, error);
733 if (error.Fail())
734 return false;
735
736 if (field == eSize)
737 value /= 8; // convert bits to bytes
738
739 return true;
740}
741
743 if (!m_thread_info.valid) {
744 bool ok = true;
745
746 ok &= FindMetadata("_thread_db_sizeof_pthread", eStructSize,
747 m_thread_info.pthread_size);
748 ok &= FindMetadata("_thread_db_pthread_dtvp", eOffset,
749 m_thread_info.dtv_offset);
750 ok &=
751 FindMetadata("_thread_db_dtv_dtv", eSize, m_thread_info.dtv_slot_size);
752 ok &= FindMetadata("_thread_db_link_map_l_tls_modid", eOffset,
753 m_thread_info.modid_offset);
754 ok &= FindMetadata("_thread_db_dtv_t_pointer_val", eOffset,
755 m_thread_info.tls_offset);
756
757 if (ok)
758 m_thread_info.valid = true;
759 }
760
761 return m_thread_info;
762}
763
765 int state = GetState();
766
767 if (!log)
768 return;
769
770 log->PutCString("DYLDRendezvous:");
771 LLDB_LOGF(log, " Address: %" PRIx64, GetRendezvousAddress());
772 LLDB_LOGF(log, " Version: %" PRIu64, GetVersion());
773 LLDB_LOGF(log, " Link : %" PRIx64, GetLinkMapAddress());
774 LLDB_LOGF(log, " Break : %" PRIx64, GetBreakAddress());
775 LLDB_LOGF(log, " LDBase : %" PRIx64, GetLDBase());
776 LLDB_LOGF(log, " State : %s",
777 (state == eConsistent)
778 ? "consistent"
779 : (state == eAdd) ? "add"
780 : (state == eDelete) ? "delete" : "unknown");
781
782 iterator I = begin();
783 iterator E = end();
784
785 if (I != E)
786 log->PutCString("DYLDRendezvous SOEntries:");
787
788 for (int i = 1; I != E; ++I, ++i) {
789 LLDB_LOGF(log, "\n SOEntry [%d] %s", i, I->file_spec.GetPath().c_str());
790 LLDB_LOGF(log, " Base : %" PRIx64, I->base_addr);
791 LLDB_LOGF(log, " Path : %" PRIx64, I->path_addr);
792 LLDB_LOGF(log, " Dyn : %" PRIx64, I->dyn_addr);
793 LLDB_LOGF(log, " Next : %" PRIx64, I->next);
794 LLDB_LOGF(log, " Prev : %" PRIx64, I->prev);
795 }
796}
797
799 return !m_process->IsLiveDebugSession();
800}
static const size_t word_size
static llvm::raw_ostream & error(Stream &strm)
static bool isLoadBiasIncorrect(Target &target, const std::string &file_path)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:375
#define LLDB_LOGF(log,...)
Definition Log.h:389
#define LLDB_LOG_ERROR(log, error,...)
Definition Log.h:405
bool FindMetadata(const char *name, PThreadField field, uint32_t &value)
lldb::addr_t ReadPointer(lldb::addr_t addr, lldb::addr_t *dst)
Reads an address from the inferior's address space starting at addr.
static const char * ActionToCStr(RendezvousAction action)
std::string ReadStringFromMemory(lldb::addr_t addr)
Reads a null-terminated C string from the memory location starting at addr.
std::list< SOEntry > SOEntryList
bool ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry)
Reads an SOEntry starting at addr.
lldb::addr_t GetBreakAddress() const
A breakpoint should be set at this address and Resolve called on each hit.
lldb_private::Process * m_process
void UpdateExecutablePath()
Update the cached executable path.
bool UpdateSOEntries()
Updates the current set of SOEntries, the set of added entries, and the set of removed entries.
bool m_executable_interpreter
uint64_t GetState() const
Returns the current state of the rendezvous structure.
lldb::addr_t GetLinkMapAddress() const
DYLDRendezvous(lldb_private::Process *process)
LoadedModuleInfoList m_loaded_modules
List of currently loaded SO modules.
bool UpdateSOEntriesFromRemote()
Same as UpdateSOEntries but it gets the list of loaded modules from the remote debug server (faster w...
bool IsCoreFile() const
static const char * StateToCStr(RendezvousState state)
bool Resolve()
Update the internal snapshot of runtime linker rendezvous and recompute the currently loaded modules.
RendezvousAction GetAction() const
Returns the current action to be taken given the current and previous state.
bool AddSOEntriesFromRemote(const LoadedModuleInfoList &module_list)
SOEntryList m_added_soentries
List of SOEntry's added to the link map since the last call to Resolve().
lldb::addr_t ResolveRendezvousAddress()
Locates the address of the rendezvous structure.
bool FillSOEntryFromModuleInfo(LoadedModuleInfoList::LoadedModuleInfo const &modInfo, SOEntry &entry)
RendezvousState
Constants describing the state of the rendezvous.
lldb::addr_t m_rendezvous_addr
Location of the r_debug structure in the inferiors address space.
iterator begin() const
Iterators over all currently loaded modules.
SOEntryList m_soentries
List of SOEntry objects corresponding to the current link map state.
void DumpToLog(lldb_private::Log *log) const
uint64_t GetVersion() const
lldb_private::FileSpec m_exe_file_spec
const ThreadInfo & GetThreadInfo()
void UpdateBaseAddrIfNecessary(SOEntry &entry, std::string const &file_path)
Rendezvous m_previous
lldb::addr_t GetLDBase() const
bool TakeSnapshot(SOEntryList &entry_list)
Reads the current list of shared objects according to the link map supplied by the runtime linker.
void UpdateFileSpecIfNecessary(SOEntry &entry)
bool SOEntryIsMainExecutable(const SOEntry &entry)
PThreadField
For the definitions of the metadata entries, see <glibc>/nptl_db/(db_info.c, structs....
lldb::addr_t GetRendezvousAddress() const
lldb::addr_t ReadWord(lldb::addr_t addr, uint64_t *dst, size_t size)
Reads an unsigned integer of size bytes from the inferior's address space starting at addr.
Rendezvous m_current
Current and previous snapshots of the rendezvous structure.
bool RemoveSOEntriesFromRemote(const LoadedModuleInfoList &module_list)
SOEntryList m_removed_soentries
List of SOEntry's removed from the link map since the last call to Resolve().
bool SaveSOEntriesFromRemote(const LoadedModuleInfoList &module_list)
SOEntryList::const_iterator iterator
ThreadInfo m_thread_info
Threading metadata read from the inferior.
iterator end() const
A section + offset based address class.
Definition Address.h:62
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition Address.cpp:303
bool Slide(int64_t offset)
Definition Address.h:446
bool IsValid() const
Check if the object state is valid.
Definition Address.h:355
An architecture specification class.
Definition ArchSpec.h:32
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition ArchSpec.h:545
bool IsMIPS() const
if MIPS architecture return true.
Definition ArchSpec.cpp:749
A uniqued constant string class.
Definition ConstString.h:40
bool IsEmpty() const
Test for empty string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition FileSpec.cpp:174
std::vector< LoadedModuleInfo > m_list
void PutCString(const char *cstr)
Definition Log.cpp:162
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:91
const FileSpec & GetPlatformFileSpec() const
Get accessor for the module platform file specification.
Definition Module.h:461
A plug-in interface definition class for object file parsers.
Definition ObjectFile.h:46
virtual lldb_private::Address GetImageInfoAddress(Target *target)
Similar to Process::GetImageInfoAddress().
Definition ObjectFile.h:448
A plug-in interface definition class for debugging a process.
Definition Process.h:367
An error handling class.
Definition Status.h:118
Defines a list of symbol context objects.
Address GetAddress() const
Definition Symbol.h:98
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition Target.cpp:1625
lldb::PlatformSP GetPlatform()
Definition Target.h:1980
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition Target.h:1254
const ArchSpec & GetArchitecture() const
Definition Target.h:1296
uint64_t ReadUnsignedIntegerFromMemory(const Address &addr, size_t integer_byte_size, uint64_t fail_value, Status &error, bool force_live_memory=false)
Definition Target.cpp:2409
#define LLDB_INVALID_ADDRESS
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
uint64_t addr_t
Definition lldb-types.h:80
void DumpToLog(lldb_private::Log *log, const char *label)
Structure representing the shared objects currently loaded into the inferior process.
lldb::addr_t path_addr
String naming the shared object.
lldb::addr_t base_addr
Base address of the loaded object.
lldb::addr_t link_addr
Address of this link_map.
lldb_private::FileSpec file_spec
File spec of shared object.
lldb::addr_t prev
Address of previous so_entry.
lldb::addr_t next
Address of next so_entry.
lldb::addr_t dyn_addr
Dynamic section of shared object.