LLDB  mainline
SectionLoadHistory.h
Go to the documentation of this file.
1 //===-- SectionLoadHistory.h ------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_SectionLoadHistory_h_
10 #define liblldb_SectionLoadHistory_h_
11 
12 #include <map>
13 #include <mutex>
14 
15 #include "lldb/lldb-public.h"
16 
17 namespace lldb_private {
18 
20 public:
21  enum : unsigned {
22  // Pass eStopIDNow to any function that takes a stop ID to get the current
23  // value.
25  };
26  // Constructors and Destructors
28 
30  // Call clear since this takes a lock and clears the section load list in
31  // case another thread is currently using this section load list
32  Clear();
33  }
34 
36 
37  bool IsEmpty() const;
38 
39  void Clear();
40 
41  uint32_t GetLastStopID() const;
42 
43  // Get the section load address given a process stop ID
45  const lldb::SectionSP &section_sp);
46 
47  bool ResolveLoadAddress(uint32_t stop_id, lldb::addr_t load_addr,
48  Address &so_addr);
49 
50  bool SetSectionLoadAddress(uint32_t stop_id,
51  const lldb::SectionSP &section_sp,
52  lldb::addr_t load_addr,
53  bool warn_multiple = false);
54 
55  // The old load address should be specified when unloading to ensure we get
56  // the correct instance of the section as a shared library could be loaded at
57  // more than one location.
58  bool SetSectionUnloaded(uint32_t stop_id, const lldb::SectionSP &section_sp,
59  lldb::addr_t load_addr);
60 
61  // Unload all instances of a section. This function can be used on systems
62  // that don't support multiple copies of the same shared library to be loaded
63  // at the same time.
64  size_t SetSectionUnloaded(uint32_t stop_id,
65  const lldb::SectionSP &section_sp);
66 
67  void Dump(Stream &s, Target *target);
68 
69 protected:
71  bool read_only);
72 
73  typedef std::map<uint32_t, lldb::SectionLoadListSP> StopIDToSectionLoadList;
74  StopIDToSectionLoadList m_stop_id_to_section_load_list;
75  mutable std::recursive_mutex m_mutex;
76 
77 private:
78  DISALLOW_COPY_AND_ASSIGN(SectionLoadHistory);
79 };
80 
81 } // namespace lldb_private
82 
83 #endif // liblldb_SectionLoadHistory_h_
lldb::addr_t GetSectionLoadAddress(uint32_t stop_id, const lldb::SectionSP &section_sp)
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
bool SetSectionUnloaded(uint32_t stop_id, const lldb::SectionSP &section_sp, lldb::addr_t load_addr)
std::map< uint32_t, lldb::SectionLoadListSP > StopIDToSectionLoadList
#define UINT32_MAX
Definition: lldb-defines.h:31
bool SetSectionLoadAddress(uint32_t stop_id, const lldb::SectionSP &section_sp, lldb::addr_t load_addr, bool warn_multiple=false)
bool ResolveLoadAddress(uint32_t stop_id, lldb::addr_t load_addr, Address &so_addr)
A section + offset based address class.
Definition: Address.h:80
uint64_t addr_t
Definition: lldb-types.h:83
SectionLoadList & GetCurrentSectionLoadList()
void Dump(Stream &s, Target *target)
SectionLoadList * GetSectionLoadListForStopID(uint32_t stop_id, bool read_only)
StopIDToSectionLoadList m_stop_id_to_section_load_list