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/Path.h"
22
23#include "DYLDRendezvous.h"
24
25using namespace lldb;
26using namespace lldb_private;
27
29 switch (state) {
31 return "eConsistent";
33 return "eAdd";
35 return "eDelete";
36 }
37 return "<invalid RendezvousState>";
38}
39
41 switch (action) {
43 return "eTakeSnapshot";
45 return "eAddModules";
47 return "eRemoveModules";
49 return "eNoAction";
50 }
51 return "<invalid RendezvousAction>";
52}
53
62
65 addr_t info_location;
66 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 info_addr = m_process->ReadPointerFromMemory(info_location, error);
124 if (error.Fail()) {
125 LLDB_LOGF(log, "%s FAILED - could not read from the info location: %s",
126 __FUNCTION__, error.AsCString());
128 }
129
130 if (info_addr == 0) {
131 LLDB_LOGF(log,
132 "%s FAILED - the rendezvous address contained at 0x%" PRIx64
133 " returned a null value",
134 __FUNCTION__, info_location);
136 }
137
138 return info_addr;
139}
140
142 if (m_process) {
144 Module *exe_mod = m_process->GetTarget().GetExecutableModulePointer();
145 if (exe_mod) {
147 LLDB_LOGF(log, "DYLDRendezvous::%s exe module executable path set: '%s'",
148 __FUNCTION__, m_exe_file_spec.GetPath().c_str());
149 } else {
150 LLDB_LOGF(log,
151 "DYLDRendezvous::%s cannot cache exe module path: null "
152 "executable module pointer",
153 __FUNCTION__);
154 }
155 }
156}
157
158void DYLDRendezvous::Rendezvous::DumpToLog(Log *log, const char *label) {
159 LLDB_LOGF(log, "%s Rendezvous: version = %" PRIu64 ", map_addr = 0x%16.16"
160 PRIx64 ", brk = 0x%16.16" PRIx64 ", state = %" PRIu64
161 " (%s), ldbase = 0x%16.16" PRIx64, label ? label : "", version,
163}
164
167
168 const size_t word_size = 4;
169 Rendezvous info;
170 size_t address_size;
171 size_t padding;
172 addr_t info_addr;
173 addr_t cursor;
174
175 address_size = m_process->GetAddressByteSize();
176 padding = address_size - word_size;
177 LLDB_LOGF(log,
178 "DYLDRendezvous::%s address size: %" PRIu64 ", padding %" PRIu64,
179 __FUNCTION__, uint64_t(address_size), uint64_t(padding));
180
182 cursor = info_addr =
184 else
185 cursor = info_addr = m_rendezvous_addr;
186 LLDB_LOGF(log, "DYLDRendezvous::%s cursor = 0x%" PRIx64, __FUNCTION__,
187 cursor);
188
189 if (cursor == LLDB_INVALID_ADDRESS)
190 return false;
191
192 if (!(cursor = ReadWord(cursor, &info.version, word_size)))
193 return false;
194
195 if (!(cursor = ReadPointer(cursor + padding, &info.map_addr)))
196 return false;
197
198 if (!(cursor = ReadPointer(cursor, &info.brk)))
199 return false;
200
201 if (!(cursor = ReadWord(cursor, &info.state, word_size)))
202 return false;
203
204 if (!(cursor = ReadPointer(cursor + padding, &info.ldbase)))
205 return false;
206
207 // The rendezvous was successfully read. Update our internal state.
208 m_rendezvous_addr = info_addr;
210 m_current = info;
211
212 m_previous.DumpToLog(log, "m_previous");
213 m_current.DumpToLog(log, "m_current ");
214
215 if (m_current.map_addr == 0)
216 return false;
217
219 return true;
220
221 return UpdateSOEntries();
222}
223
227
229 // If we have a core file, we will read the current rendezvous state
230 // from the core file's memory into m_current which can be in an inconsistent
231 // state, so we can't rely on its state to determine what we should do. We
232 // always need it to load all of the shared libraries one time when we attach
233 // to a core file.
234 if (IsCoreFile())
235 return eTakeSnapshot;
236
237 switch (m_current.state) {
238
239 case eConsistent:
240 switch (m_previous.state) {
241 // When the previous and current states are consistent this is the first
242 // time we have been asked to update. Just take a snapshot of the
243 // currently loaded modules.
244 case eConsistent:
245 return eTakeSnapshot;
246 // If we are about to add or remove a shared object clear out the current
247 // state and take a snapshot of the currently loaded images.
248 case eAdd:
249 return eAddModules;
250 case eDelete:
251 return eRemoveModules;
252 }
253 break;
254
255 case eAdd:
256 // If the main executable or a shared library defines a publicly visible
257 // symbol named "_r_debug", then it will cause problems once the executable
258 // that contains the symbol is loaded into the process. The correct
259 // "_r_debug" structure is currently found by LLDB by looking through
260 // the .dynamic section in the main executable and finding the DT_DEBUG tag
261 // entry.
262 //
263 // An issue comes up if someone defines another publicly visible "_r_debug"
264 // struct in their program. Sample code looks like:
265 //
266 // #include <link.h>
267 // r_debug _r_debug;
268 //
269 // If code like this is in an executable or shared library, this creates a
270 // new "_r_debug" structure and it causes problems once the executable is
271 // loaded due to the way symbol lookups happen in linux: the shared library
272 // list from _r_debug.r_map will be searched for a symbol named "_r_debug"
273 // and the first match will be the new version that is used. The dynamic
274 // loader is always last in this list. So at some point the dynamic loader
275 // will start updating the copy of "_r_debug" that gets found first. The
276 // issue is that LLDB will only look at the copy that is pointed to by the
277 // DT_DEBUG entry, or the initial version from the ld.so binary.
278 //
279 // Steps that show the problem are:
280 //
281 // - LLDB finds the "_r_debug" structure via the DT_DEBUG entry in the
282 // .dynamic section and this points to the "_r_debug" in ld.so
283 // - ld.so uodates its copy of "_r_debug" with "state = eAdd" before it
284 // loads the dependent shared libraries for the main executable and
285 // any dependencies of all shared libraries from the executable's list
286 // and ld.so code calls the debugger notification function
287 // that LLDB has set a breakpoint on.
288 // - LLDB hits the breakpoint and the breakpoint has a callback function
289 // where we read the _r_debug.state (eAdd) state and we do nothing as the
290 // "eAdd" state indicates that the shared libraries are about to be added.
291 // - ld.so finishes loading the main executable and any dependent shared
292 // libraries and it will update the "_r_debug.state" member with a
293 // "eConsistent", but it now updates the "_r_debug" in the a.out program
294 // and it calls the debugger notification function.
295 // - lldb hits the notification breakpoint and checks the ld.so copy of
296 // "_r_debug.state" which still has a state of "eAdd", but LLDB needs to see a
297 // "eConsistent" state to trigger the shared libraries to get loaded into
298 // the debug session, but LLDB the ld.so _r_debug.state which still
299 // contains "eAdd" and doesn't do anyhing and library load is missed.
300 // The "_r_debug" in a.out has the state set correctly to "eConsistent"
301 // but LLDB is still looking at the "_r_debug" from ld.so.
302 //
303 // So if we detect two "eAdd" states in a row, we assume this is the issue
304 // and we now load shared libraries correctly and will emit a log message
305 // in the "log enable lldb dyld" log channel which states there might be
306 // multiple "_r_debug" structs causing problems.
307 //
308 // The correct solution is that no one should be adding a duplicate
309 // publicly visible "_r_debug" symbols to their binaries, but we have
310 // programs that are doing this already and since it can be done, we should
311 // be able to work with this and keep debug sessions working as expected.
312 //
313 // If a user includes the <link.h> file, they can just use the existing
314 // "_r_debug" structure as it is defined in this header file as "extern
315 // struct r_debug _r_debug;" and no local copies need to be made.
316 if (m_previous.state == eAdd) {
318 LLDB_LOG(log, "DYLDRendezvous::GetAction() found two eAdd states in a "
319 "row, check process for multiple \"_r_debug\" symbols. "
320 "Returning eAddModules to ensure shared libraries get loaded "
321 "correctly");
322 return eAddModules;
323 }
324 return eNoAction;
325 case eDelete:
326 return eNoAction;
327 }
328
329 return eNoAction;
330}
331
333 const auto action = GetAction();
335 LLDB_LOG(log, "{0} action = {1}", LLVM_PRETTY_FUNCTION, ActionToCStr(action));
336
337 if (action == eNoAction)
338 return false;
339
340 m_added_soentries.clear();
341 m_removed_soentries.clear();
342 if (action == eTakeSnapshot) {
343 // We already have the loaded list from the previous update so no need to
344 // find all the modules again.
345 if (!m_loaded_modules.m_list.empty())
346 return true;
347 }
348
349 llvm::Expected<LoadedModuleInfoList> module_list =
350 m_process->GetLoadedModuleList();
351 if (!module_list) {
352 llvm::consumeError(module_list.takeError());
353 return false;
354 }
355
356 switch (action) {
357 case eTakeSnapshot:
358 m_soentries.clear();
359 return SaveSOEntriesFromRemote(*module_list);
360 case eAddModules:
361 return AddSOEntriesFromRemote(*module_list);
362 case eRemoveModules:
363 return RemoveSOEntriesFromRemote(*module_list);
364 case eNoAction:
365 return false;
366 }
367 llvm_unreachable("Fully covered switch above!");
368}
369
371 m_added_soentries.clear();
372 m_removed_soentries.clear();
373 const auto action = GetAction();
375 LLDB_LOG(log, "{0} action = {1}", LLVM_PRETTY_FUNCTION, ActionToCStr(action));
376 switch (action) {
377 case eTakeSnapshot:
378 m_soentries.clear();
380 case eAddModules:
381 return AddSOEntries();
382 case eRemoveModules:
383 return RemoveSOEntries();
384 case eNoAction:
385 return false;
386 }
387 llvm_unreachable("Fully covered switch above!");
388}
389
391 LoadedModuleInfoList::LoadedModuleInfo const &modInfo, SOEntry &entry) {
392 addr_t link_map_addr;
393 addr_t base_addr;
394 addr_t dyn_addr;
395 std::string name;
396
397 if (!modInfo.get_link_map(link_map_addr) || !modInfo.get_base(base_addr) ||
398 !modInfo.get_dynamic(dyn_addr) || !modInfo.get_name(name))
399 return false;
400
401 entry.link_addr = link_map_addr;
402 entry.base_addr = base_addr;
403 entry.dyn_addr = dyn_addr;
404
405 entry.file_spec.SetFile(name, FileSpec::Style::native);
406
407 UpdateBaseAddrIfNecessary(entry, name);
408
409 // not needed if we're using ModuleInfos
410 entry.next = 0;
411 entry.prev = 0;
412 entry.path_addr = 0;
413
414 return true;
415}
416
418 const LoadedModuleInfoList &module_list) {
419 for (auto const &modInfo : module_list.m_list) {
420 SOEntry entry;
421 if (!FillSOEntryFromModuleInfo(modInfo, entry))
422 return false;
423
424 // Only add shared libraries and not the executable.
425 if (!SOEntryIsMainExecutable(entry)) {
427 m_soentries.push_back(entry);
428 }
429 }
430
431 m_loaded_modules = module_list;
432 return true;
433}
434
436 const LoadedModuleInfoList &module_list) {
437 for (auto const &modInfo : module_list.m_list) {
438 bool found = false;
439 for (auto const &existing : m_loaded_modules.m_list) {
440 if (modInfo == existing) {
441 found = true;
442 break;
443 }
444 }
445
446 if (found)
447 continue;
448
449 SOEntry entry;
450 if (!FillSOEntryFromModuleInfo(modInfo, entry))
451 return false;
452
453 // Only add shared libraries and not the executable.
454 if (!SOEntryIsMainExecutable(entry)) {
456 m_soentries.push_back(entry);
457 m_added_soentries.push_back(entry);
458 }
459 }
460
461 m_loaded_modules = module_list;
462 return true;
463}
464
466 const LoadedModuleInfoList &module_list) {
467 for (auto const &existing : m_loaded_modules.m_list) {
468 bool found = false;
469 for (auto const &modInfo : module_list.m_list) {
470 if (modInfo == existing) {
471 found = true;
472 break;
473 }
474 }
475
476 if (found)
477 continue;
478
479 SOEntry entry;
480 if (!FillSOEntryFromModuleInfo(existing, entry))
481 return false;
482
483 // Only add shared libraries and not the executable.
484 if (!SOEntryIsMainExecutable(entry)) {
485 auto pos = llvm::find(m_soentries, entry);
486 if (pos == m_soentries.end())
487 return false;
488
489 m_soentries.erase(pos);
490 m_removed_soentries.push_back(entry);
491 }
492 }
493
494 m_loaded_modules = module_list;
495 return true;
496}
497
499 SOEntry entry;
500
501 assert(m_previous.state == eAdd);
502
503 if (m_current.map_addr == 0)
504 return false;
505
506 for (addr_t cursor = m_current.map_addr; cursor != 0; cursor = entry.next) {
507 if (!ReadSOEntryFromMemory(cursor, entry))
508 return false;
509
510 // Only add shared libraries and not the executable.
511 if (SOEntryIsMainExecutable(entry))
512 continue;
513
515
516 if (!llvm::is_contained(m_soentries, entry)) {
517 m_soentries.push_back(entry);
518 m_added_soentries.push_back(entry);
519 }
520 }
521
522 return true;
523}
524
526 SOEntryList entry_list;
527
528 assert(m_previous.state == eDelete);
529
530 if (!TakeSnapshot(entry_list))
531 return false;
532
533 for (iterator I = begin(); I != end(); ++I) {
534 if (!llvm::is_contained(entry_list, *I))
535 m_removed_soentries.push_back(*I);
536 }
537
538 m_soentries = entry_list;
539 return true;
540}
541
543 // On some systes the executable is indicated by an empty path in the entry.
544 // On others it is the full path to the executable.
545
546 auto triple = m_process->GetTarget().GetArchitecture().GetTriple();
547 switch (triple.getOS()) {
548 case llvm::Triple::FreeBSD:
549 case llvm::Triple::NetBSD:
550 case llvm::Triple::OpenBSD:
551 return entry.file_spec == m_exe_file_spec;
552 case llvm::Triple::Linux:
553 if (triple.isAndroid())
554 return entry.file_spec == m_exe_file_spec;
555 // If we are debugging ld.so, then all SOEntries should be treated as
556 // libraries, including the "main" one (denoted by an empty string).
558 return false;
559 return !entry.file_spec;
560 default:
561 return false;
562 }
563}
564
566 SOEntry entry;
567
568 if (m_current.map_addr == 0)
569 return false;
570
571 // Clear previous entries since we are about to obtain an up to date list.
572 entry_list.clear();
573
574 for (addr_t cursor = m_current.map_addr; cursor != 0; cursor = entry.next) {
575 if (!ReadSOEntryFromMemory(cursor, entry))
576 return false;
577
578 // Only add shared libraries and not the executable.
579 if (SOEntryIsMainExecutable(entry))
580 continue;
581
583
584 entry_list.push_back(entry);
585 }
586
587 return true;
588}
589
590addr_t DYLDRendezvous::ReadWord(addr_t addr, uint64_t *dst, size_t size) {
592
593 *dst = m_process->ReadUnsignedIntegerFromMemory(addr, size, 0, error);
594 if (error.Fail())
595 return 0;
596
597 return addr + size;
598}
599
602
603 *dst = m_process->ReadPointerFromMemory(addr, error);
604 if (error.Fail())
605 return 0;
606
607 return addr + m_process->GetAddressByteSize();
608}
609
611 std::string str;
613
614 if (addr == LLDB_INVALID_ADDRESS)
615 return std::string();
616
617 m_process->ReadCStringFromMemory(addr, str, error);
618
619 return str;
620}
621
622// Returns true if the load bias reported by the linker is incorrect for the
623// given entry. This function is used to handle cases where we want to work
624// around a bug in the system linker.
625static bool isLoadBiasIncorrect(Target &target, const std::string &file_path) {
626 // On Android L (API 21, 22) the load address of the "/system/bin/linker"
627 // isn't filled in correctly.
628 unsigned os_major = target.GetPlatform()->GetOSVersion().getMajor();
629 return target.GetArchitecture().GetTriple().isAndroid() &&
630 (os_major == 21 || os_major == 22) &&
631 (file_path == "/system/bin/linker" ||
632 file_path == "/system/bin/linker64");
633}
634
636 std::string const &file_path) {
637 // If the load bias reported by the linker is incorrect then fetch the load
638 // address of the file from the proc file system.
639 if (isLoadBiasIncorrect(m_process->GetTarget(), file_path)) {
641 bool is_loaded = false;
642 Status error =
643 m_process->GetFileLoadAddress(entry.file_spec, is_loaded, load_addr);
644 if (error.Success() && is_loaded)
645 entry.base_addr = load_addr;
646 }
647}
648
650 // Updates filename if empty. It is useful while debugging ld.so,
651 // when the link map returns empty string for the main executable.
652 if (!entry.file_spec) {
653 MemoryRegionInfo region;
654 Status region_status =
655 m_process->GetMemoryRegionInfo(entry.dyn_addr, region);
656 if (!region.GetName().IsEmpty())
657 entry.file_spec.SetFile(region.GetName().GetStringRef(),
658 FileSpec::Style::native);
659 }
660}
661
663 entry.clear();
664
665 entry.link_addr = addr;
666
667 if (!(addr = ReadPointer(addr, &entry.base_addr)))
668 return false;
669
670 // mips adds an extra load offset field to the link map struct on FreeBSD and
671 // NetBSD (need to validate other OSes).
672 // http://svnweb.freebsd.org/base/head/sys/sys/link_elf.h?revision=217153&view=markup#l57
673 const ArchSpec &arch = m_process->GetTarget().GetArchitecture();
674 if ((arch.GetTriple().getOS() == llvm::Triple::FreeBSD ||
675 arch.GetTriple().getOS() == llvm::Triple::NetBSD) &&
676 arch.IsMIPS()) {
677 addr_t mips_l_offs;
678 if (!(addr = ReadPointer(addr, &mips_l_offs)))
679 return false;
680 if (mips_l_offs != 0 && mips_l_offs != entry.base_addr)
681 return false;
682 }
683
684 if (!(addr = ReadPointer(addr, &entry.path_addr)))
685 return false;
686
687 if (!(addr = ReadPointer(addr, &entry.dyn_addr)))
688 return false;
689
690 if (!(addr = ReadPointer(addr, &entry.next)))
691 return false;
692
693 if (!(addr = ReadPointer(addr, &entry.prev)))
694 return false;
695
696 std::string file_path = ReadStringFromMemory(entry.path_addr);
697 entry.file_spec.SetFile(file_path, FileSpec::Style::native);
698
699 UpdateBaseAddrIfNecessary(entry, file_path);
700
701 return true;
702}
703
704bool DYLDRendezvous::FindMetadata(const char *name, PThreadField field,
705 uint32_t &value) {
706 Target &target = m_process->GetTarget();
707
710 eSymbolTypeAny, list);
711 if (list.IsEmpty())
712 return false;
713
714 Address address = list[0].symbol->GetAddress();
715 // eSize, eNElem, and eOffset correspond to the fields of the DESC structure.
716 // eStructSize instructs to read a value generated by DB_STRUCT.
717 int field_num = (field == eStructSize) ? 0 : field;
718 address.Slide(field_num * sizeof(uint32_t));
719
720 // Read from target memory as this allows us to try process memory and
721 // fallback to reading from read only sections from the object files. Here we
722 // are reading read only data from libpthread.so to find data in the thread
723 // specific area for the data we want and this won't be saved into process
724 // memory due to it being read only.
726 value =
727 target.ReadUnsignedIntegerFromMemory(address, sizeof(uint32_t), 0, error);
728 if (error.Fail())
729 return false;
730
731 if (field == eSize)
732 value /= 8; // convert bits to bytes
733
734 return true;
735}
736
738 if (!m_thread_info.valid) {
739 bool ok = true;
740
741 ok &= FindMetadata("_thread_db_sizeof_pthread", eStructSize,
742 m_thread_info.pthread_size);
743 ok &= FindMetadata("_thread_db_pthread_dtvp", eOffset,
744 m_thread_info.dtv_offset);
745 ok &=
746 FindMetadata("_thread_db_dtv_dtv", eSize, m_thread_info.dtv_slot_size);
747 ok &= FindMetadata("_thread_db_link_map_l_tls_modid", eOffset,
748 m_thread_info.modid_offset);
749 ok &= FindMetadata("_thread_db_dtv_t_pointer_val", eOffset,
750 m_thread_info.tls_offset);
751
752 if (ok)
753 m_thread_info.valid = true;
754 }
755
756 return m_thread_info;
757}
758
760 int state = GetState();
761
762 if (!log)
763 return;
764
765 log->PutCString("DYLDRendezvous:");
766 LLDB_LOGF(log, " Address: %" PRIx64, GetRendezvousAddress());
767 LLDB_LOGF(log, " Version: %" PRIu64, GetVersion());
768 LLDB_LOGF(log, " Link : %" PRIx64, GetLinkMapAddress());
769 LLDB_LOGF(log, " Break : %" PRIx64, GetBreakAddress());
770 LLDB_LOGF(log, " LDBase : %" PRIx64, GetLDBase());
771 LLDB_LOGF(log, " State : %s",
772 (state == eConsistent)
773 ? "consistent"
774 : (state == eAdd) ? "add"
775 : (state == eDelete) ? "delete" : "unknown");
776
777 iterator I = begin();
778 iterator E = end();
779
780 if (I != E)
781 log->PutCString("DYLDRendezvous SOEntries:");
782
783 for (int i = 1; I != E; ++I, ++i) {
784 LLDB_LOGF(log, "\n SOEntry [%d] %s", i, I->file_spec.GetPath().c_str());
785 LLDB_LOGF(log, " Base : %" PRIx64, I->base_addr);
786 LLDB_LOGF(log, " Path : %" PRIx64, I->path_addr);
787 LLDB_LOGF(log, " Dyn : %" PRIx64, I->dyn_addr);
788 LLDB_LOGF(log, " Next : %" PRIx64, I->next);
789 LLDB_LOGF(log, " Prev : %" PRIx64, I->prev);
790 }
791}
792
794 return !m_process->IsLiveDebugSession();
795}
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:376
#define LLDB_LOGF(log,...)
Definition Log.h:390
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:301
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:544
bool IsMIPS() const
if MIPS architecture return true.
Definition ArchSpec.cpp:747
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:442
A plug-in interface definition class for debugging a process.
Definition Process.h:359
An error handling class.
Definition Status.h:118
Defines a list of symbol context objects.
Address GetAddress() const
Definition Symbol.h:89
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition Target.cpp:1625
lldb::PlatformSP GetPlatform()
Definition Target.h:1971
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition Target.h:1243
const ArchSpec & GetArchitecture() const
Definition Target.h:1285
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:2400
#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:339
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.