1 //===-- SectionLoadList.h -----------------------------------------------*- C++
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef liblldb_SectionLoadList_h_
12 #define liblldb_SectionLoadList_h_
17 #include "llvm/ADT/DenseMap.h"
18 #include "lldb/Core/Section.h"
19 #include "lldb/lldb-public.h"
21 namespace lldb_private {
23 class SectionLoadList {
25 //------------------------------------------------------------------
26 // Constructors and Destructors
27 //------------------------------------------------------------------
28 SectionLoadList() : m_addr_to_sect(), m_sect_to_addr(), m_mutex() {}
30 SectionLoadList(const SectionLoadList &rhs);
33 // Call clear since this takes a lock and clears the section load list in
34 // case another thread is currently using this section load list
38 void operator=(const SectionLoadList &rhs);
44 lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP §ion_sp) const;
46 bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr,
47 bool allow_section_end = false) const;
49 bool SetSectionLoadAddress(const lldb::SectionSP §ion_sp,
50 lldb::addr_t load_addr,
51 bool warn_multiple = false);
53 // The old load address should be specified when unloading to ensure we get
54 // the correct instance of the section as a shared library could be loaded at
55 // more than one location.
56 bool SetSectionUnloaded(const lldb::SectionSP §ion_sp,
57 lldb::addr_t load_addr);
59 // Unload all instances of a section. This function can be used on systems
60 // that don't support multiple copies of the same shared library to be loaded
62 size_t SetSectionUnloaded(const lldb::SectionSP §ion_sp);
64 void Dump(Stream &s, Target *target);
67 typedef std::map<lldb::addr_t, lldb::SectionSP> addr_to_sect_collection;
68 typedef llvm::DenseMap<const Section *, lldb::addr_t> sect_to_addr_collection;
69 addr_to_sect_collection m_addr_to_sect;
70 sect_to_addr_collection m_sect_to_addr;
71 mutable std::recursive_mutex m_mutex;
74 } // namespace lldb_private
76 #endif // liblldb_SectionLoadList_h_