1 //===-- SectionLoadHistory.h ------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_SectionLoadHistory_h_
11 #define liblldb_SectionLoadHistory_h_
19 #include "lldb/lldb-public.h"
21 namespace lldb_private {
23 class SectionLoadHistory {
26 // Pass eStopIDNow to any function that takes a stop ID to get
28 eStopIDNow = UINT32_MAX
30 //------------------------------------------------------------------
31 // Constructors and Destructors
32 //------------------------------------------------------------------
33 SectionLoadHistory() : m_stop_id_to_section_load_list(), m_mutex() {}
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
41 SectionLoadList &GetCurrentSectionLoadList();
47 uint32_t GetLastStopID() const;
49 // Get the section load address given a process stop ID
50 lldb::addr_t GetSectionLoadAddress(uint32_t stop_id,
51 const lldb::SectionSP §ion_sp);
53 bool ResolveLoadAddress(uint32_t stop_id, lldb::addr_t load_addr,
56 bool SetSectionLoadAddress(uint32_t stop_id,
57 const lldb::SectionSP §ion_sp,
58 lldb::addr_t load_addr,
59 bool warn_multiple = false);
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 §ion_sp,
65 lldb::addr_t load_addr);
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 §ion_sp);
73 void Dump(Stream &s, Target *target);
76 SectionLoadList *GetSectionLoadListForStopID(uint32_t stop_id,
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;
84 DISALLOW_COPY_AND_ASSIGN(SectionLoadHistory);
87 } // namespace lldb_private
89 #endif // liblldb_SectionLoadHistory_h_