]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/SectionLoadList.h
Import to 0.6.1
[FreeBSD/FreeBSD.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/Core/Section.h"
22 #include "lldb/Host/Mutex.h"
23
24 namespace lldb_private {
25
26 class SectionLoadList
27 {
28 public:
29     //------------------------------------------------------------------
30     // Constructors and Destructors
31     //------------------------------------------------------------------
32     SectionLoadList () :
33         m_addr_to_sect (),
34         m_sect_to_addr (),
35         m_mutex (Mutex::eMutexTypeRecursive)
36
37     {
38     }
39
40     SectionLoadList (const SectionLoadList& rhs);
41
42     ~SectionLoadList()
43     {
44         // Call clear since this takes a lock and clears the section load list
45         // in case another thread is currently using this section load list
46         Clear();
47     }
48
49     void
50     operator=(const SectionLoadList &rhs);
51     
52     bool
53     IsEmpty() const;
54
55     void
56     Clear ();
57
58     lldb::addr_t
59     GetSectionLoadAddress (const lldb::SectionSP &section_sp) const;
60
61     bool
62     ResolveLoadAddress (lldb::addr_t load_addr, Address &so_addr) const;
63
64     bool
65     SetSectionLoadAddress (const lldb::SectionSP &section_sp, lldb::addr_t load_addr, bool warn_multiple = false);
66
67     // The old load address should be specified when unloading to ensure we get
68     // the correct instance of the section as a shared library could be loaded
69     // at more than one location.
70     bool
71     SetSectionUnloaded (const lldb::SectionSP &section_sp, lldb::addr_t load_addr);
72
73     // Unload all instances of a section. This function can be used on systems
74     // that don't support multiple copies of the same shared library to be
75     // loaded at the same time.
76     size_t
77     SetSectionUnloaded (const lldb::SectionSP &section_sp);
78
79     void
80     Dump (Stream &s, Target *target);
81
82 protected:
83     typedef std::map<lldb::addr_t, lldb::SectionSP> addr_to_sect_collection;
84     typedef llvm::DenseMap<const Section *, lldb::addr_t> sect_to_addr_collection;
85     addr_to_sect_collection m_addr_to_sect;
86     sect_to_addr_collection m_sect_to_addr;
87     mutable Mutex m_mutex;
88 };
89
90 } // namespace lldb_private
91
92 #endif  // liblldb_SectionLoadList_h_