]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/SectionLoadHistory.h
MFV r330973: 9164 assert: newds == os->os_dsl_dataset
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Target / SectionLoadHistory.h
1 //===-- SectionLoadHistory.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_SectionLoadHistory_h_
11 #define liblldb_SectionLoadHistory_h_
12
13 // C Includes
14 // C++ Includes
15 #include <map>
16 #include <mutex>
17
18 // Project includes
19 #include "lldb/lldb-public.h"
20
21 namespace lldb_private {
22
23 class SectionLoadHistory {
24 public:
25   enum : unsigned {
26     // Pass eStopIDNow to any function that takes a stop ID to get
27     // the current value.
28     eStopIDNow = UINT32_MAX
29   };
30   //------------------------------------------------------------------
31   // Constructors and Destructors
32   //------------------------------------------------------------------
33   SectionLoadHistory() : m_stop_id_to_section_load_list(), m_mutex() {}
34
35   ~SectionLoadHistory() {
36     // Call clear since this takes a lock and clears the section load list
37     // in case another thread is currently using this section load list
38     Clear();
39   }
40
41   SectionLoadList &GetCurrentSectionLoadList();
42
43   bool IsEmpty() const;
44
45   void Clear();
46
47   uint32_t GetLastStopID() const;
48
49   // Get the section load address given a process stop ID
50   lldb::addr_t GetSectionLoadAddress(uint32_t stop_id,
51                                      const lldb::SectionSP &section_sp);
52
53   bool ResolveLoadAddress(uint32_t stop_id, lldb::addr_t load_addr,
54                           Address &so_addr);
55
56   bool SetSectionLoadAddress(uint32_t stop_id,
57                              const lldb::SectionSP &section_sp,
58                              lldb::addr_t load_addr,
59                              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 SetSectionUnloaded(uint32_t stop_id, const lldb::SectionSP &section_sp,
65                           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 SetSectionUnloaded(uint32_t stop_id,
71                             const lldb::SectionSP &section_sp);
72
73   void Dump(Stream &s, Target *target);
74
75 protected:
76   SectionLoadList *GetSectionLoadListForStopID(uint32_t stop_id,
77                                                bool read_only);
78
79   typedef std::map<uint32_t, lldb::SectionLoadListSP> StopIDToSectionLoadList;
80   StopIDToSectionLoadList m_stop_id_to_section_load_list;
81   mutable std::recursive_mutex m_mutex;
82
83 private:
84   DISALLOW_COPY_AND_ASSIGN(SectionLoadHistory);
85 };
86
87 } // namespace lldb_private
88
89 #endif // liblldb_SectionLoadHistory_h_