1 //===-- Address.cpp ---------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Core/Address.h"
11 #include "lldb/Core/Module.h"
12 #include "lldb/Core/Section.h"
13 #include "lldb/Symbol/Block.h"
14 #include "lldb/Symbol/ObjectFile.h"
15 #include "lldb/Symbol/Variable.h"
16 #include "lldb/Symbol/VariableList.h"
17 #include "lldb/Target/ExecutionContext.h"
18 #include "lldb/Target/Process.h"
19 #include "lldb/Target/SectionLoadList.h"
20 #include "lldb/Target/Target.h"
21 #include "lldb/Symbol/SymbolVendor.h"
23 #include "llvm/ADT/Triple.h"
26 using namespace lldb_private;
29 ReadBytes (ExecutionContextScope *exe_scope, const Address &address, void *dst, size_t dst_len)
31 if (exe_scope == NULL)
34 TargetSP target_sp (exe_scope->CalculateTarget());
38 bool prefer_file_cache = false;
39 return target_sp->ReadMemory (address, prefer_file_cache, dst, dst_len, error);
45 GetByteOrderAndAddressSize (ExecutionContextScope *exe_scope, const Address &address, ByteOrder& byte_order, uint32_t& addr_size)
47 byte_order = eByteOrderInvalid;
49 if (exe_scope == NULL)
52 TargetSP target_sp (exe_scope->CalculateTarget());
55 byte_order = target_sp->GetArchitecture().GetByteOrder();
56 addr_size = target_sp->GetArchitecture().GetAddressByteSize();
59 if (byte_order == eByteOrderInvalid || addr_size == 0)
61 ModuleSP module_sp (address.GetModule());
64 byte_order = module_sp->GetArchitecture().GetByteOrder();
65 addr_size = module_sp->GetArchitecture().GetAddressByteSize();
68 return byte_order != eByteOrderInvalid && addr_size != 0;
72 ReadUIntMax64 (ExecutionContextScope *exe_scope, const Address &address, uint32_t byte_size, bool &success)
75 if (exe_scope == NULL || byte_size > sizeof(uint64_t))
82 success = ReadBytes (exe_scope, address, &buf, byte_size) == byte_size;
85 ByteOrder byte_order = eByteOrderInvalid;
86 uint32_t addr_size = 0;
87 if (GetByteOrderAndAddressSize (exe_scope, address, byte_order, addr_size))
89 DataExtractor data (&buf, sizeof(buf), byte_order, addr_size);
90 lldb::offset_t offset = 0;
91 uval64 = data.GetU64(&offset);
100 ReadAddress (ExecutionContextScope *exe_scope, const Address &address, uint32_t pointer_size, Address &deref_so_addr)
102 if (exe_scope == NULL)
106 bool success = false;
107 addr_t deref_addr = ReadUIntMax64 (exe_scope, address, pointer_size, success);
110 ExecutionContext exe_ctx;
111 exe_scope->CalculateExecutionContext(exe_ctx);
112 // If we have any sections that are loaded, try and resolve using the
114 Target *target = exe_ctx.GetTargetPtr();
115 if (target && !target->GetSectionLoadList().IsEmpty())
117 if (target->GetSectionLoadList().ResolveLoadAddress (deref_addr, deref_so_addr))
122 // If we were not running, yet able to read an integer, we must
124 ModuleSP module_sp (address.GetModule());
127 if (module_sp->ResolveFileAddress(deref_addr, deref_so_addr))
131 // We couldn't make "deref_addr" into a section offset value, but we were
132 // able to read the address, so we return a section offset address with
133 // no section and "deref_addr" as the offset (address).
134 deref_so_addr.SetRawAddress(deref_addr);
141 DumpUInt (ExecutionContextScope *exe_scope, const Address &address, uint32_t byte_size, Stream* strm)
143 if (exe_scope == NULL || byte_size == 0)
145 std::vector<uint8_t> buf(byte_size, 0);
147 if (ReadBytes (exe_scope, address, &buf[0], buf.size()) == buf.size())
149 ByteOrder byte_order = eByteOrderInvalid;
150 uint32_t addr_size = 0;
151 if (GetByteOrderAndAddressSize (exe_scope, address, byte_order, addr_size))
153 DataExtractor data (&buf.front(), buf.size(), byte_order, addr_size);
156 0, // Start offset in "data"
157 eFormatHex, // Print as characters
158 buf.size(), // Size of item
160 UINT32_MAX, // num per line
161 LLDB_INVALID_ADDRESS,// base address
162 0, // bitfield bit size
163 0); // bitfield bit offset
173 ReadCStringFromMemory (ExecutionContextScope *exe_scope, const Address &address, Stream *strm)
175 if (exe_scope == NULL)
177 const size_t k_buf_len = 256;
178 char buf[k_buf_len+1];
179 buf[k_buf_len] = '\0'; // NULL terminate
181 // Byte order and address size don't matter for C string dumping..
182 DataExtractor data (buf, sizeof(buf), lldb::endian::InlHostByteOrder(), 4);
183 size_t total_len = 0;
185 Address curr_address(address);
187 while ((bytes_read = ReadBytes (exe_scope, curr_address, buf, k_buf_len)) > 0)
189 size_t len = strlen(buf);
192 if (len > bytes_read)
196 0, // Start offset in "data"
197 eFormatChar, // Print as characters
198 1, // Size of item (1 byte for a char!)
199 len, // How many bytes to print?
200 UINT32_MAX, // num per line
201 LLDB_INVALID_ADDRESS,// base address
202 0, // bitfield bit size
204 0); // bitfield bit offset
206 total_len += bytes_read;
210 curr_address.SetOffset (curr_address.GetOffset() + bytes_read);
216 Address::Address (lldb::addr_t abs_addr) :
222 Address::Address (addr_t address, const SectionList *section_list) :
224 m_offset (LLDB_INVALID_ADDRESS)
226 ResolveAddressUsingFileSections(address, section_list);
230 Address::operator= (const Address& rhs)
234 m_section_wp = rhs.m_section_wp;
235 m_offset = rhs.m_offset.load();
241 Address::ResolveAddressUsingFileSections (addr_t file_addr, const SectionList *section_list)
245 SectionSP section_sp (section_list->FindSectionContainingFileAddress(file_addr));
246 m_section_wp = section_sp;
249 assert( section_sp->ContainsFileAddress(file_addr) );
250 m_offset = file_addr - section_sp->GetFileAddress();
251 return true; // Successfully transformed addr into a section offset address
254 m_offset = file_addr;
255 return false; // Failed to resolve this address to a section offset value
259 Address::GetModule () const
261 lldb::ModuleSP module_sp;
262 SectionSP section_sp (GetSection());
264 module_sp = section_sp->GetModule();
269 Address::GetFileAddress () const
271 SectionSP section_sp (GetSection());
274 addr_t sect_file_addr = section_sp->GetFileAddress();
275 if (sect_file_addr == LLDB_INVALID_ADDRESS)
277 // Section isn't resolved, we can't return a valid file address
278 return LLDB_INVALID_ADDRESS;
280 // We have a valid file range, so we can return the file based
281 // address by adding the file base address to our offset
282 return sect_file_addr + m_offset;
284 else if (SectionWasDeletedPrivate())
286 // Used to have a valid section but it got deleted so the
287 // offset doesn't mean anything without the section
288 return LLDB_INVALID_ADDRESS;
290 // No section, we just return the offset since it is the value in this case
295 Address::GetLoadAddress (Target *target) const
297 SectionSP section_sp (GetSection());
302 addr_t sect_load_addr = section_sp->GetLoadBaseAddress (target);
304 if (sect_load_addr != LLDB_INVALID_ADDRESS)
306 // We have a valid file range, so we can return the file based
307 // address by adding the file base address to our offset
308 return sect_load_addr + m_offset;
312 else if (SectionWasDeletedPrivate())
314 // Used to have a valid section but it got deleted so the
315 // offset doesn't mean anything without the section
316 return LLDB_INVALID_ADDRESS;
320 // We don't have a section so the offset is the load address
323 // The section isn't resolved or an invalid target was passed in
324 // so we can't return a valid load address.
325 return LLDB_INVALID_ADDRESS;
329 Address::GetCallableLoadAddress (Target *target, bool is_indirect) const
331 addr_t code_addr = LLDB_INVALID_ADDRESS;
333 if (is_indirect && target)
335 ProcessSP processSP = target->GetProcessSP();
339 code_addr = processSP->ResolveIndirectFunction(this, error);
340 if (!error.Success())
341 code_addr = LLDB_INVALID_ADDRESS;
346 code_addr = GetLoadAddress (target);
349 if (code_addr == LLDB_INVALID_ADDRESS)
353 return target->GetCallableLoadAddress (code_addr, GetAddressClass());
358 Address::SetCallableLoadAddress (lldb::addr_t load_addr, Target *target)
360 if (SetLoadAddress (load_addr, target))
363 m_offset = target->GetCallableLoadAddress(m_offset, GetAddressClass());
370 Address::GetOpcodeLoadAddress (Target *target) const
372 addr_t code_addr = GetLoadAddress (target);
373 if (code_addr != LLDB_INVALID_ADDRESS)
374 code_addr = target->GetOpcodeLoadAddress (code_addr, GetAddressClass());
379 Address::SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target)
381 if (SetLoadAddress (load_addr, target))
384 m_offset = target->GetOpcodeLoadAddress (m_offset, GetAddressClass());
391 Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style, uint32_t addr_size) const
393 // If the section was NULL, only load address is going to work unless we are
394 // trying to deref a pointer
395 SectionSP section_sp (GetSection());
396 if (!section_sp && style != DumpStyleResolvedPointerDescription)
397 style = DumpStyleLoadAddress;
399 ExecutionContext exe_ctx (exe_scope);
400 Target *target = exe_ctx.GetTargetPtr();
401 // If addr_byte_size is UINT32_MAX, then determine the correct address
402 // byte size for the process or default to the size of addr_t
403 if (addr_size == UINT32_MAX)
406 addr_size = target->GetArchitecture().GetAddressByteSize ();
408 addr_size = sizeof(addr_t);
414 case DumpStyleInvalid:
417 case DumpStyleSectionNameOffset:
420 section_sp->DumpName(s);
421 s->Printf (" + %" PRIu64, m_offset.load());
425 s->Address(m_offset, addr_size);
429 case DumpStyleSectionPointerOffset:
430 s->Printf("(Section *)%p + ", static_cast<void*>(section_sp.get()));
431 s->Address(m_offset, addr_size);
434 case DumpStyleModuleWithFileAddress:
437 s->Printf("%s[", section_sp->GetModule()->GetFileSpec().GetFilename().AsCString("<Unknown>"));
440 case DumpStyleFileAddress:
442 addr_t file_addr = GetFileAddress();
443 if (file_addr == LLDB_INVALID_ADDRESS)
445 if (fallback_style != DumpStyleInvalid)
446 return Dump (s, exe_scope, fallback_style, DumpStyleInvalid, addr_size);
449 s->Address (file_addr, addr_size);
450 if (style == DumpStyleModuleWithFileAddress && section_sp)
455 case DumpStyleLoadAddress:
457 addr_t load_addr = GetLoadAddress (target);
458 if (load_addr == LLDB_INVALID_ADDRESS)
460 if (fallback_style != DumpStyleInvalid)
461 return Dump (s, exe_scope, fallback_style, DumpStyleInvalid, addr_size);
464 s->Address (load_addr, addr_size);
468 case DumpStyleResolvedDescription:
469 case DumpStyleResolvedDescriptionNoModule:
470 case DumpStyleResolvedDescriptionNoFunctionArguments:
471 if (IsSectionOffset())
473 uint32_t pointer_size = 4;
474 ModuleSP module_sp (GetModule());
476 pointer_size = target->GetArchitecture().GetAddressByteSize();
478 pointer_size = module_sp->GetArchitecture().GetAddressByteSize();
480 bool showed_info = false;
483 SectionType sect_type = section_sp->GetType();
486 case eSectionTypeData:
489 SymbolVendor *sym_vendor = module_sp->GetSymbolVendor();
492 Symtab *symtab = sym_vendor->GetSymtab();
495 const addr_t file_Addr = GetFileAddress();
496 Symbol *symbol = symtab->FindSymbolContainingFileAddress (file_Addr);
499 const char *symbol_name = symbol->GetName().AsCString();
502 s->PutCString(symbol_name);
503 addr_t delta = file_Addr - symbol->GetAddress().GetFileAddress();
505 s->Printf(" + %" PRIu64, delta);
514 case eSectionTypeDataCString:
515 // Read the C string from memory and display it
517 ReadCStringFromMemory (exe_scope, *this, s);
520 case eSectionTypeDataCStringPointers:
522 if (ReadAddress (exe_scope, *this, pointer_size, so_addr))
525 s->PutCString("(char *)");
526 so_addr.Dump(s, exe_scope, DumpStyleLoadAddress, DumpStyleFileAddress);
530 ReadCStringFromMemory (exe_scope, so_addr, s);
535 case eSectionTypeDataObjCMessageRefs:
537 if (ReadAddress (exe_scope, *this, pointer_size, so_addr))
539 if (target && so_addr.IsSectionOffset())
541 SymbolContext func_sc;
542 target->GetImages().ResolveSymbolContextForAddress (so_addr,
543 eSymbolContextEverything,
545 if (func_sc.function || func_sc.symbol)
549 s->PutCString ("(objc_msgref *) -> { (func*)");
550 so_addr.Dump(s, exe_scope, DumpStyleLoadAddress, DumpStyleFileAddress);
552 s->PutCString ("{ ");
554 Address cstr_addr(*this);
555 cstr_addr.SetOffset(cstr_addr.GetOffset() + pointer_size);
556 func_sc.DumpStopContext(s, exe_scope, so_addr, true, true, false, true);
557 if (ReadAddress (exe_scope, cstr_addr, pointer_size, so_addr))
560 s->PutCString("), (char *)");
561 so_addr.Dump(s, exe_scope, DumpStyleLoadAddress, DumpStyleFileAddress);
566 ReadCStringFromMemory (exe_scope, so_addr, s);
569 s->PutCString(") }");
579 case eSectionTypeDataObjCCFStrings:
581 Address cfstring_data_addr(*this);
582 cfstring_data_addr.SetOffset(cfstring_data_addr.GetOffset() + (2 * pointer_size));
583 if (ReadAddress (exe_scope, cfstring_data_addr, pointer_size, so_addr))
586 s->PutCString("(CFString *) ");
587 cfstring_data_addr.Dump(s, exe_scope, DumpStyleLoadAddress, DumpStyleFileAddress);
588 s->PutCString(" -> @");
592 if (so_addr.Dump(s, exe_scope, DumpStyleResolvedDescription))
598 case eSectionTypeData4:
599 // Read the 4 byte data and display it
601 s->PutCString("(uint32_t) ");
602 DumpUInt (exe_scope, *this, 4, s);
605 case eSectionTypeData8:
606 // Read the 8 byte data and display it
608 s->PutCString("(uint64_t) ");
609 DumpUInt (exe_scope, *this, 8, s);
612 case eSectionTypeData16:
613 // Read the 16 byte data and display it
615 s->PutCString("(uint128_t) ");
616 DumpUInt (exe_scope, *this, 16, s);
619 case eSectionTypeDataPointers:
620 // Read the pointer data and display it
622 if (ReadAddress (exe_scope, *this, pointer_size, so_addr))
624 s->PutCString ("(void *)");
625 so_addr.Dump(s, exe_scope, DumpStyleLoadAddress, DumpStyleFileAddress);
628 if (so_addr.IsSectionOffset())
630 SymbolContext pointer_sc;
633 target->GetImages().ResolveSymbolContextForAddress (so_addr,
634 eSymbolContextEverything,
636 if (pointer_sc.function || pointer_sc.symbol)
639 pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false, false, true);
657 module_sp->ResolveSymbolContextForAddress(*this, eSymbolContextEverything, sc);
658 if (sc.function || sc.symbol)
660 bool show_stop_context = true;
661 const bool show_module = (style == DumpStyleResolvedDescription);
662 const bool show_fullpaths = false;
663 const bool show_inlined_frames = true;
664 const bool show_function_arguments = (style != DumpStyleResolvedDescriptionNoFunctionArguments);
665 if (sc.function == NULL && sc.symbol != NULL)
667 // If we have just a symbol make sure it is in the right section
668 if (sc.symbol->ValueIsAddress())
670 if (sc.symbol->GetAddress().GetSection() != GetSection())
672 // don't show the module if the symbol is a trampoline symbol
673 show_stop_context = false;
677 if (show_stop_context)
679 // We have a function or a symbol from the same
680 // sections as this address.
681 sc.DumpStopContext (s,
687 show_function_arguments);
691 // We found a symbol but it was in a different
692 // section so it isn't the symbol we should be
693 // showing, just show the section name + offset
694 Dump (s, exe_scope, DumpStyleSectionNameOffset);
702 if (fallback_style != DumpStyleInvalid)
703 return Dump (s, exe_scope, fallback_style, DumpStyleInvalid, addr_size);
708 case DumpStyleDetailedSymbolContext:
709 if (IsSectionOffset())
711 ModuleSP module_sp (GetModule());
715 module_sp->ResolveSymbolContextForAddress(*this, eSymbolContextEverything, sc);
718 // If we have just a symbol make sure it is in the same section
719 // as our address. If it isn't, then we might have just found
720 // the last symbol that came before the address that we are
721 // looking up that has nothing to do with our address lookup.
722 if (sc.symbol->ValueIsAddress() && sc.symbol->GetAddress().GetSection() != GetSection())
725 sc.GetDescription(s, eDescriptionLevelBrief, target);
729 bool can_create = true;
730 bool get_parent_variables = true;
731 bool stop_if_block_is_inlined_function = false;
732 VariableList variable_list;
733 sc.block->AppendVariables (can_create,
734 get_parent_variables,
735 stop_if_block_is_inlined_function,
738 const size_t num_variables = variable_list.GetSize();
739 for (size_t var_idx = 0; var_idx < num_variables; ++var_idx)
741 Variable *var = variable_list.GetVariableAtIndex (var_idx).get();
742 if (var && var->LocationIsValidForAddress (*this))
745 s->Printf (" Variable: id = {0x%8.8" PRIx64 "}, name = \"%s\", type= \"%s\", location =",
747 var->GetName().GetCString(),
748 var->GetType()->GetName().GetCString());
749 var->DumpLocationForAddress(s, *this);
750 s->PutCString(", decl = ");
751 var->GetDeclaration().DumpStopContext(s, false);
760 if (fallback_style != DumpStyleInvalid)
761 return Dump (s, exe_scope, fallback_style, DumpStyleInvalid, addr_size);
765 case DumpStyleResolvedPointerDescription:
767 Process *process = exe_ctx.GetProcessPtr();
770 addr_t load_addr = GetLoadAddress (target);
771 if (load_addr != LLDB_INVALID_ADDRESS)
774 addr_t dereferenced_load_addr = process->ReadPointerFromMemory(load_addr, memory_error);
775 if (dereferenced_load_addr != LLDB_INVALID_ADDRESS)
777 Address dereferenced_addr;
778 if (dereferenced_addr.SetLoadAddress(dereferenced_load_addr, target))
781 if (dereferenced_addr.Dump (&strm, exe_scope, DumpStyleResolvedDescription, DumpStyleInvalid, addr_size))
783 s->Address (dereferenced_load_addr, addr_size, " -> ", " ");
784 s->Write(strm.GetData(), strm.GetSize());
791 if (fallback_style != DumpStyleInvalid)
792 return Dump (s, exe_scope, fallback_style, DumpStyleInvalid, addr_size);
802 Address::SectionWasDeleted() const
806 return SectionWasDeletedPrivate();
810 Address::SectionWasDeletedPrivate() const
812 lldb::SectionWP empty_section_wp;
814 // If either call to "std::weak_ptr::owner_before(...) value returns true, this
815 // indicates that m_section_wp once contained (possibly still does) a reference
816 // to a valid shared pointer. This helps us know if we had a valid reference to
817 // a section which is now invalid because the module it was in was unloaded/deleted,
818 // or if the address doesn't have a valid reference to a section.
819 return empty_section_wp.owner_before(m_section_wp) || m_section_wp.owner_before(empty_section_wp);
823 Address::CalculateSymbolContext (SymbolContext *sc, uint32_t resolve_scope) const
826 // Absolute addresses don't have enough information to reconstruct even their target.
828 SectionSP section_sp (GetSection());
831 ModuleSP module_sp (section_sp->GetModule());
834 sc->module_sp = module_sp;
836 return sc->module_sp->ResolveSymbolContextForAddress (*this, resolve_scope, *sc);
843 Address::CalculateSymbolContextModule () const
845 SectionSP section_sp (GetSection());
847 return section_sp->GetModule();
852 Address::CalculateSymbolContextCompileUnit () const
854 SectionSP section_sp (GetSection());
858 sc.module_sp = section_sp->GetModule();
861 sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextCompUnit, sc);
869 Address::CalculateSymbolContextFunction () const
871 SectionSP section_sp (GetSection());
875 sc.module_sp = section_sp->GetModule();
878 sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextFunction, sc);
886 Address::CalculateSymbolContextBlock () const
888 SectionSP section_sp (GetSection());
892 sc.module_sp = section_sp->GetModule();
895 sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextBlock, sc);
903 Address::CalculateSymbolContextSymbol () const
905 SectionSP section_sp (GetSection());
909 sc.module_sp = section_sp->GetModule();
912 sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextSymbol, sc);
920 Address::CalculateSymbolContextLineEntry (LineEntry &line_entry) const
922 SectionSP section_sp (GetSection());
926 sc.module_sp = section_sp->GetModule();
929 sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextLineEntry, sc);
930 if (sc.line_entry.IsValid())
932 line_entry = sc.line_entry;
942 Address::CompareFileAddress (const Address& a, const Address& b)
944 addr_t a_file_addr = a.GetFileAddress();
945 addr_t b_file_addr = b.GetFileAddress();
946 if (a_file_addr < b_file_addr)
948 if (a_file_addr > b_file_addr)
955 Address::CompareLoadAddress (const Address& a, const Address& b, Target *target)
957 assert (target != NULL);
958 addr_t a_load_addr = a.GetLoadAddress (target);
959 addr_t b_load_addr = b.GetLoadAddress (target);
960 if (a_load_addr < b_load_addr)
962 if (a_load_addr > b_load_addr)
968 Address::CompareModulePointerAndOffset (const Address& a, const Address& b)
970 ModuleSP a_module_sp (a.GetModule());
971 ModuleSP b_module_sp (b.GetModule());
972 Module *a_module = a_module_sp.get();
973 Module *b_module = b_module_sp.get();
974 if (a_module < b_module)
976 if (a_module > b_module)
978 // Modules are the same, just compare the file address since they should
980 addr_t a_file_addr = a.GetFileAddress();
981 addr_t b_file_addr = b.GetFileAddress();
982 if (a_file_addr < b_file_addr)
984 if (a_file_addr > b_file_addr)
991 Address::MemorySize () const
993 // Noting special for the memory size of a single Address object,
994 // it is just the size of itself.
995 return sizeof(Address);
999 //----------------------------------------------------------------------
1000 // NOTE: Be careful using this operator. It can correctly compare two
1001 // addresses from the same Module correctly. It can't compare two
1002 // addresses from different modules in any meaningful way, but it will
1003 // compare the module pointers.
1005 // To sum things up:
1006 // - works great for addresses within the same module
1007 // - it works for addresses across multiple modules, but don't expect the
1008 // address results to make much sense
1010 // This basically lets Address objects be used in ordered collection
1012 //----------------------------------------------------------------------
1015 lldb_private::operator< (const Address& lhs, const Address& rhs)
1017 ModuleSP lhs_module_sp (lhs.GetModule());
1018 ModuleSP rhs_module_sp (rhs.GetModule());
1019 Module *lhs_module = lhs_module_sp.get();
1020 Module *rhs_module = rhs_module_sp.get();
1021 if (lhs_module == rhs_module)
1023 // Addresses are in the same module, just compare the file addresses
1024 return lhs.GetFileAddress() < rhs.GetFileAddress();
1028 // The addresses are from different modules, just use the module
1029 // pointer value to get consistent ordering
1030 return lhs_module < rhs_module;
1035 lldb_private::operator> (const Address& lhs, const Address& rhs)
1037 ModuleSP lhs_module_sp (lhs.GetModule());
1038 ModuleSP rhs_module_sp (rhs.GetModule());
1039 Module *lhs_module = lhs_module_sp.get();
1040 Module *rhs_module = rhs_module_sp.get();
1041 if (lhs_module == rhs_module)
1043 // Addresses are in the same module, just compare the file addresses
1044 return lhs.GetFileAddress() > rhs.GetFileAddress();
1048 // The addresses are from different modules, just use the module
1049 // pointer value to get consistent ordering
1050 return lhs_module > rhs_module;
1055 // The operator == checks for exact equality only (same section, same offset)
1057 lldb_private::operator== (const Address& a, const Address& rhs)
1059 return a.GetOffset() == rhs.GetOffset() &&
1060 a.GetSection() == rhs.GetSection();
1062 // The operator != checks for exact inequality only (differing section, or
1063 // different offset)
1065 lldb_private::operator!= (const Address& a, const Address& rhs)
1067 return a.GetOffset() != rhs.GetOffset() ||
1068 a.GetSection() != rhs.GetSection();
1072 Address::GetAddressClass () const
1074 ModuleSP module_sp (GetModule());
1077 ObjectFile *obj_file = module_sp->GetObjectFile();
1080 // Give the symbol vendor a chance to add to the unified section list.
1081 module_sp->GetSymbolVendor();
1082 return obj_file->GetAddressClass (GetFileAddress());
1085 return eAddressClassUnknown;
1089 Address::SetLoadAddress (lldb::addr_t load_addr, Target *target)
1091 if (target && target->GetSectionLoadList().ResolveLoadAddress(load_addr, *this))
1093 m_section_wp.reset();
1094 m_offset = load_addr;