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 "SectionLoadList::{0} (section = {1} ({2}), load_addr = {3:x}) "
73 "error: module has been deleted",
74 __FUNCTION__,
static_cast<void *
>(section.get()),
75 section->GetName(), load_addr);
80 "(section = {0} ({1}.{2}), load_addr = {3:x}) module = {4}",
81 section.get(), module_sp->GetFileSpec(), section->GetName(),
82 load_addr, module_sp.get());
84 if (section->GetByteSize() == 0)
88 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
89 sect_to_addr_collection::iterator sta_pos =
94 if (load_addr == sta_pos->second)
96 old_load_addr = sta_pos->second;
97 sta_pos->second = load_addr;
103 addr_to_sect_collection::iterator ats_pos =
m_addr_to_sect.find(load_addr);
115 if (warn_multiple && section != ats_pos->second) {
116 if (
ModuleSP curr_module_sp = ats_pos->second->GetModule()) {
117 module_sp->ReportWarning(
118 "address {0:x16} maps to more than one section: {1}.{2} and "
120 load_addr, module_sp->GetFileSpec().GetFilename(),
121 section->GetName(), curr_module_sp->GetFileSpec().GetFilename(),
122 ats_pos->second->GetName());
125 ats_pos->second = section;
133 addr_to_sect_collection::iterator old_pos =
135 if (old_pos !=
m_addr_to_sect.end() && old_pos->second == section)
143 size_t unload_count = 0;
149 ModuleSP module_sp = section_sp->GetModule();
150 std::string module_name(
"<Unknown>");
153 section_sp->GetModule()->GetFileSpec());
154 module_name = module_file_spec.
GetPath();
156 LLDB_LOG(log,
"SectionLoadList::{0} (section = {1} ({2}.{3}))",
157 __FUNCTION__,
static_cast<void *
>(section_sp.get()), module_name,
158 section_sp->GetName());
161 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
163 sect_to_addr_collection::iterator sta_pos =
167 addr_t load_addr = sta_pos->second;
170 addr_to_sect_collection::iterator ats_pos =
184 ModuleSP module_sp = section_sp->GetModule();
185 std::string module_name(
"<Unknown>");
187 const FileSpec &module_file_spec(section_sp->GetModule()->GetFileSpec());
188 module_name = module_file_spec.
GetPath();
191 "SectionLoadList::{0} (section = {1:x} ({2}.{3}), load_addr = "
193 __FUNCTION__,
static_cast<void *
>(section_sp.get()),
194 module_name.c_str(), section_sp->GetName(), load_addr);
197 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
198 sect_to_addr_collection::iterator sta_pos =
205 addr_to_sect_collection::iterator ats_pos =
m_addr_to_sect.find(load_addr);
215 bool allow_section_end)
const {
217 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
219 addr_to_sect_collection::const_iterator pos =
224 const addr_t pos_load_addr = pos->first;
225 if (load_addr >= pos_load_addr) {
226 addr_t offset = load_addr - pos_load_addr;
227 if (offset < pos->second->GetByteSize() + (allow_section_end ? 1 : 0)) {
230 return pos->second->ResolveContainedAddress(offset, so_addr,
237 addr_to_sect_collection::const_reverse_iterator rpos =
239 if (load_addr >= rpos->first) {
240 addr_t offset = load_addr - rpos->first;
242 rpos->second->GetByteSize() + (allow_section_end ? 1 : 0)) {
245 return rpos->second->ResolveContainedAddress(offset, so_addr,
256 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
257 addr_to_sect_collection::const_iterator pos, end;
260 s.
Printf(
"addr = 0x%16.16" PRIx64
", section = %p: ", pos->first,
261 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_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