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 LLDB_TARGET_SECTIONLOADHISTORY_H
10#define LLDB_TARGET_SECTIONLOADHISTORY_H
11
12#include <map>
13#include <mutex>
14
15#include "lldb/lldb-public.h"
16
17namespace lldb_private {
18
20public:
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
27 SectionLoadHistory() = default;
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
44 lldb::addr_t GetSectionLoadAddress(uint32_t 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
69protected:
71 bool read_only);
72
73 typedef std::map<uint32_t, lldb::SectionLoadListSP> StopIDToSectionLoadList;
75 mutable std::recursive_mutex m_mutex;
76
77private:
80};
81
82} // namespace lldb_private
83
84#endif // LLDB_TARGET_SECTIONLOADHISTORY_H
A section + offset based address class.
Definition: Address.h:62
bool ResolveLoadAddress(uint32_t stop_id, lldb::addr_t load_addr, Address &so_addr)
bool SetSectionLoadAddress(uint32_t stop_id, const lldb::SectionSP &section_sp, lldb::addr_t load_addr, bool warn_multiple=false)
lldb::addr_t GetSectionLoadAddress(uint32_t stop_id, const lldb::SectionSP &section_sp)
void Dump(Stream &s, Target *target)
std::map< uint32_t, lldb::SectionLoadListSP > StopIDToSectionLoadList
StopIDToSectionLoadList m_stop_id_to_section_load_list
bool SetSectionUnloaded(uint32_t stop_id, const lldb::SectionSP &section_sp, lldb::addr_t load_addr)
const SectionLoadHistory & operator=(const SectionLoadHistory &)=delete
SectionLoadList & GetCurrentSectionLoadList()
SectionLoadList * GetSectionLoadListForStopID(uint32_t stop_id, bool read_only)
SectionLoadHistory(const SectionLoadHistory &)=delete
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Section > SectionSP
Definition: lldb-forward.h:409
uint64_t addr_t
Definition: lldb-types.h:80