]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/SectionLoadList.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Target / SectionLoadList.h
1 //===-- SectionLoadList.h -----------------------------------------------*- C++
2 //-*-===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef liblldb_SectionLoadList_h_
12 #define liblldb_SectionLoadList_h_
13
14 // C Includes
15 // C++ Includes
16 #include <map>
17 #include <mutex>
18
19 // Other libraries and framework includes
20 #include "llvm/ADT/DenseMap.h"
21 // Project includes
22 #include "lldb/Core/Section.h"
23 #include "lldb/lldb-public.h"
24
25 namespace lldb_private {
26
27 class SectionLoadList {
28 public:
29   //------------------------------------------------------------------
30   // Constructors and Destructors
31   //------------------------------------------------------------------
32   SectionLoadList() : m_addr_to_sect(), m_sect_to_addr(), m_mutex() {}
33
34   SectionLoadList(const SectionLoadList &rhs);
35
36   ~SectionLoadList() {
37     // Call clear since this takes a lock and clears the section load list in
38     // case another thread is currently using this section load list
39     Clear();
40   }
41
42   void operator=(const SectionLoadList &rhs);
43
44   bool IsEmpty() const;
45
46   void Clear();
47
48   lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP &section_sp) const;
49
50   bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr,
51                           bool allow_section_end = false) const;
52
53   bool SetSectionLoadAddress(const lldb::SectionSP &section_sp,
54                              lldb::addr_t load_addr,
55                              bool warn_multiple = false);
56
57   // The old load address should be specified when unloading to ensure we get
58   // the correct instance of the section as a shared library could be loaded at
59   // more than one location.
60   bool SetSectionUnloaded(const lldb::SectionSP &section_sp,
61                           lldb::addr_t load_addr);
62
63   // Unload all instances of a section. This function can be used on systems
64   // that don't support multiple copies of the same shared library to be loaded
65   // at the same time.
66   size_t SetSectionUnloaded(const lldb::SectionSP &section_sp);
67
68   void Dump(Stream &s, Target *target);
69
70 protected:
71   typedef std::map<lldb::addr_t, lldb::SectionSP> addr_to_sect_collection;
72   typedef llvm::DenseMap<const Section *, lldb::addr_t> sect_to_addr_collection;
73   addr_to_sect_collection m_addr_to_sect;
74   sect_to_addr_collection m_sect_to_addr;
75   mutable std::recursive_mutex m_mutex;
76 };
77
78 } // namespace lldb_private
79
80 #endif // liblldb_SectionLoadList_h_