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());
72 log,
"(section = {0} ({1}.{2}), load_addr = {3:x}) module = {4}",
73 section.get(), module_sp->GetFileSpec(), section->GetName(), load_addr,
76 if (section->GetByteSize() == 0)
80 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
81 sect_to_addr_collection::iterator sta_pos =
84 if (load_addr == sta_pos->second)
87 sta_pos->second = load_addr;
92 addr_to_sect_collection::iterator ats_pos =
m_addr_to_sect.find(load_addr);
104 if (warn_multiple && section != ats_pos->second) {
105 ModuleSP module_sp(section->GetModule());
107 ModuleSP curr_module_sp(ats_pos->second->GetModule());
108 if (curr_module_sp) {
109 module_sp->ReportWarning(
110 "address {0:x16} maps to more than one section: {1}.{2} and "
112 load_addr, module_sp->GetFileSpec().GetFilename().GetCString(),
113 section->GetName().GetCString(),
114 curr_module_sp->GetFileSpec().GetFilename().GetCString(),
115 ats_pos->second->GetName().GetCString());
119 ats_pos->second = section;
124 if (entry.second == section) {
136 "SectionLoadList::{0} (section = {1} ({2}), load_addr = {3:x}) "
137 "error: module has been deleted",
138 __FUNCTION__,
static_cast<void *
>(section.get()),
139 section->GetName(), load_addr);
145 size_t unload_count = 0;
151 ModuleSP module_sp = section_sp->GetModule();
152 std::string module_name(
"<Unknown>");
155 section_sp->GetModule()->GetFileSpec());
156 module_name = module_file_spec.
GetPath();
158 LLDB_LOG(log,
"SectionLoadList::{0} (section = {1} ({2}.{3}))",
159 __FUNCTION__,
static_cast<void *
>(section_sp.get()), module_name,
160 section_sp->GetName());
163 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
165 sect_to_addr_collection::iterator sta_pos =
169 addr_t load_addr = sta_pos->second;
172 addr_to_sect_collection::iterator ats_pos =
186 ModuleSP module_sp = section_sp->GetModule();
187 std::string module_name(
"<Unknown>");
189 const FileSpec &module_file_spec(section_sp->GetModule()->GetFileSpec());
190 module_name = module_file_spec.
GetPath();
194 "SectionLoadList::%s (section = %p (%s.%s), load_addr = 0x%16.16" PRIx64
196 __FUNCTION__,
static_cast<void *
>(section_sp.get()),
197 module_name.c_str(), section_sp->GetName().AsCString(
""), load_addr);
200 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
201 sect_to_addr_collection::iterator sta_pos =
208 addr_to_sect_collection::iterator ats_pos =
m_addr_to_sect.find(load_addr);
218 bool allow_section_end)
const {
220 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
222 addr_to_sect_collection::const_iterator pos =
227 const addr_t pos_load_addr = pos->first;
228 if (load_addr >= pos_load_addr) {
229 addr_t offset = load_addr - pos_load_addr;
230 if (offset < pos->second->GetByteSize() + (allow_section_end ? 1 : 0)) {
233 return pos->second->ResolveContainedAddress(offset, so_addr,
240 addr_to_sect_collection::const_reverse_iterator rpos =
242 if (load_addr >= rpos->first) {
243 addr_t offset = load_addr - rpos->first;
245 rpos->second->GetByteSize() + (allow_section_end ? 1 : 0)) {
248 return rpos->second->ResolveContainedAddress(offset, so_addr,
259 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
260 addr_to_sect_collection::const_iterator pos, end;
263 s.
Printf(
"addr = 0x%16.16" PRIx64
", section = %p: ", pos->first,
264 static_cast<void *
>(pos->second.get()));
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
#define LLDB_LOG_VERBOSE(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