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().GetCString(),
121 section->GetName().GetCString(),
122 curr_module_sp->GetFileSpec().GetFilename().GetCString(),
123 ats_pos->second->GetName().GetCString());
126 ats_pos->second = section;
139 size_t unload_count = 0;
145 ModuleSP module_sp = section_sp->GetModule();
146 std::string module_name(
"<Unknown>");
149 section_sp->GetModule()->GetFileSpec());
150 module_name = module_file_spec.
GetPath();
152 LLDB_LOG(log,
"SectionLoadList::{0} (section = {1} ({2}.{3}))",
153 __FUNCTION__,
static_cast<void *
>(section_sp.get()), module_name,
154 section_sp->GetName());
157 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
159 sect_to_addr_collection::iterator sta_pos =
163 addr_t load_addr = sta_pos->second;
166 addr_to_sect_collection::iterator ats_pos =
180 ModuleSP module_sp = section_sp->GetModule();
181 std::string module_name(
"<Unknown>");
183 const FileSpec &module_file_spec(section_sp->GetModule()->GetFileSpec());
184 module_name = module_file_spec.
GetPath();
188 "SectionLoadList::%s (section = %p (%s.%s), load_addr = 0x%16.16" PRIx64
190 __FUNCTION__,
static_cast<void *
>(section_sp.get()),
191 module_name.c_str(), section_sp->GetName().AsCString(
""), load_addr);
194 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
195 sect_to_addr_collection::iterator sta_pos =
202 addr_to_sect_collection::iterator ats_pos =
m_addr_to_sect.find(load_addr);
212 bool allow_section_end)
const {
214 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
216 addr_to_sect_collection::const_iterator pos =
221 const addr_t pos_load_addr = pos->first;
222 if (load_addr >= pos_load_addr) {
223 addr_t offset = load_addr - pos_load_addr;
224 if (offset < pos->second->GetByteSize() + (allow_section_end ? 1 : 0)) {
227 return pos->second->ResolveContainedAddress(offset, so_addr,
234 addr_to_sect_collection::const_reverse_iterator rpos =
236 if (load_addr >= rpos->first) {
237 addr_t offset = load_addr - rpos->first;
239 rpos->second->GetByteSize() + (allow_section_end ? 1 : 0)) {
242 return rpos->second->ResolveContainedAddress(offset, so_addr,
253 std::lock_guard<std::recursive_mutex> guard(
m_mutex);
254 addr_to_sect_collection::const_iterator pos, end;
257 s.
Printf(
"addr = 0x%16.16" PRIx64
", section = %p: ", pos->first,
258 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