1 //===-- SectionLoadHistory.h ------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_SectionLoadHistory_h_
10 #define liblldb_SectionLoadHistory_h_
15 #include "lldb/lldb-public.h"
17 namespace lldb_private {
19 class SectionLoadHistory {
22 // Pass eStopIDNow to any function that takes a stop ID to get the current
24 eStopIDNow = UINT32_MAX
26 // Constructors and Destructors
27 SectionLoadHistory() : m_stop_id_to_section_load_list(), m_mutex() {}
29 ~SectionLoadHistory() {
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
35 SectionLoadList &GetCurrentSectionLoadList();
41 uint32_t GetLastStopID() const;
43 // Get the section load address given a process stop ID
44 lldb::addr_t GetSectionLoadAddress(uint32_t stop_id,
45 const lldb::SectionSP §ion_sp);
47 bool ResolveLoadAddress(uint32_t stop_id, lldb::addr_t load_addr,
50 bool SetSectionLoadAddress(uint32_t stop_id,
51 const lldb::SectionSP §ion_sp,
52 lldb::addr_t load_addr,
53 bool warn_multiple = false);
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 §ion_sp,
59 lldb::addr_t load_addr);
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
64 size_t SetSectionUnloaded(uint32_t stop_id,
65 const lldb::SectionSP §ion_sp);
67 void Dump(Stream &s, Target *target);
70 SectionLoadList *GetSectionLoadListForStopID(uint32_t stop_id,
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;
78 DISALLOW_COPY_AND_ASSIGN(SectionLoadHistory);
81 } // namespace lldb_private
83 #endif // liblldb_SectionLoadHistory_h_