24 : m_addr_to_sect(), m_sect_to_addr(), m_mutex() {
25 std::lock_guard<std::recursive_mutex> guard(rhs.
m_mutex);
32 std::lock_guard<std::recursive_mutex> lhs_guard(
m_mutex, std::adopt_lock);
33 std::lock_guard<std::recursive_mutex> rhs_guard(rhs.
m_mutex, std::adopt_lock);
39 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
44 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
54 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
55 sect_to_addr_collection::const_iterator pos =
59 section_load_addr = pos->second;
61 return section_load_addr;
68 ModuleSP module_sp(section->GetModule());
71 LLDB_LOGV(log,
"(section = {0} ({1}.{2}), load_addr = {3:x}) module = {4}",
72 section.get(), module_sp->GetFileSpec(), section->GetName(),
73 load_addr, module_sp.get());
75 if (section->GetByteSize() == 0)
79 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
80 sect_to_addr_collection::iterator sta_pos =
83 if (load_addr == sta_pos->second)
86 sta_pos->second = load_addr;
91 addr_to_sect_collection::iterator ats_pos =
m_addr_to_sect.find(load_addr);
103 if (warn_multiple && section != ats_pos->second) {
104 ModuleSP module_sp(section->GetModule());
106 ModuleSP curr_module_sp(ats_pos->second->GetModule());
107 if (curr_module_sp) {
108 module_sp->ReportWarning(
109 "address {0:x16} maps to more than one section: {1}.{2} and "
111 load_addr, module_sp->GetFileSpec().GetFilename().GetCString(),
112 section->GetName().GetCString(),
113 curr_module_sp->GetFileSpec().GetFilename().GetCString(),
114 ats_pos->second->GetName().GetCString());
118 ats_pos->second = section;
123 if (entry.second == section) {
137 "SectionLoadList::%s (section = %p (%s), load_addr = 0x%16.16" PRIx64
138 ") error: module has been deleted",
139 __FUNCTION__,
static_cast<void *
>(section.get()),
140 section->GetName().AsCString(), load_addr);
147 size_t unload_count = 0;
153 ModuleSP module_sp = section_sp->GetModule();
154 std::string module_name(
"<Unknown>");
157 section_sp->GetModule()->GetFileSpec());
158 module_name = module_file_spec.
GetPath();
160 LLDB_LOGF(log,
"SectionLoadList::%s (section = %p (%s.%s))", __FUNCTION__,
161 static_cast<void *
>(section_sp.get()), module_name.c_str(),
162 section_sp->GetName().AsCString());
165 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
167 sect_to_addr_collection::iterator sta_pos =
171 addr_t load_addr = sta_pos->second;
174 addr_to_sect_collection::iterator ats_pos =
188 ModuleSP module_sp = section_sp->GetModule();
189 std::string module_name(
"<Unknown>");
191 const FileSpec &module_file_spec(section_sp->GetModule()->GetFileSpec());
192 module_name = module_file_spec.
GetPath();
196 "SectionLoadList::%s (section = %p (%s.%s), load_addr = 0x%16.16" PRIx64
198 __FUNCTION__,
static_cast<void *
>(section_sp.get()),
199 module_name.c_str(), section_sp->GetName().AsCString(), load_addr);
202 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
203 sect_to_addr_collection::iterator sta_pos =
210 addr_to_sect_collection::iterator ats_pos =
m_addr_to_sect.find(load_addr);
220 bool allow_section_end)
const {
222 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
224 addr_to_sect_collection::const_iterator pos =
229 const addr_t pos_load_addr = pos->first;
230 if (load_addr >= pos_load_addr) {
231 addr_t offset = load_addr - pos_load_addr;
232 if (offset < pos->second->GetByteSize() + (allow_section_end ? 1 : 0)) {
235 return pos->second->ResolveContainedAddress(offset, so_addr,
242 addr_to_sect_collection::const_reverse_iterator rpos =
244 if (load_addr >= rpos->first) {
245 addr_t offset = load_addr - rpos->first;
247 rpos->second->GetByteSize() + (allow_section_end ? 1 : 0)) {
250 return rpos->second->ResolveContainedAddress(offset, so_addr,
261 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
262 addr_to_sect_collection::const_iterator pos, end;
265 s.
Printf(
"addr = 0x%16.16" PRIx64
", section = %p: ", pos->first,
266 static_cast<void *
>(pos->second.get()));
#define LLDB_LOGF(log,...)
#define LLDB_LOGV(log,...)
A section + offset based address class.
void Clear()
Clear the object's state.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void Dump(Stream &s, Target *target)
bool SetSectionUnloaded(const lldb::SectionSP §ion_sp, lldb::addr_t load_addr)
void operator=(const SectionLoadList &rhs)
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, bool allow_section_end=false) const
std::recursive_mutex m_mutex
addr_to_sect_collection m_addr_to_sect
SectionLoadList()=default
bool SetSectionLoadAddress(const lldb::SectionSP §ion_sp, lldb::addr_t load_addr, bool warn_multiple=false)
lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP §ion_sp) const
sect_to_addr_collection m_sect_to_addr
A stream class that can stream formatted output to a file.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
unsigned GetIndentLevel() const
Get the current indentation level.
#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.
std::shared_ptr< lldb_private::Section > SectionSP
std::shared_ptr< lldb_private::Module > ModuleSP