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