LLDB mainline
SectionLoadList.h
Go to the documentation of this file.
1//===-- SectionLoadList.h -----------------------------------------------*- C++
2//-*-===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLDB_TARGET_SECTIONLOADLIST_H
11#define LLDB_TARGET_SECTIONLOADLIST_H
12
13#include <map>
14#include <mutex>
15
16#include "llvm/ADT/DenseMap.h"
17#include "lldb/Core/Section.h"
18#include "lldb/lldb-public.h"
19
20namespace lldb_private {
21
23public:
24 // Constructors and Destructors
25 SectionLoadList() = default;
26
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
35 void operator=(const SectionLoadList &rhs);
36
37 bool IsEmpty() const;
38
39 void Clear();
40
41 lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP &section_sp) const;
42
43 bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr,
44 bool allow_section_end = false) const;
45
46 bool SetSectionLoadAddress(const lldb::SectionSP &section_sp,
47 lldb::addr_t load_addr,
48 bool warn_multiple = false);
49
50 // The old load address should be specified when unloading to ensure we get
51 // the correct instance of the section as a shared library could be loaded at
52 // more than one location.
53 bool SetSectionUnloaded(const lldb::SectionSP &section_sp,
54 lldb::addr_t load_addr);
55
56 // Unload all instances of a section. This function can be used on systems
57 // that don't support multiple copies of the same shared library to be loaded
58 // at the same time.
59 size_t SetSectionUnloaded(const lldb::SectionSP &section_sp);
60
61 void Dump(Stream &s, Target *target);
62
63protected:
64 typedef std::map<lldb::addr_t, lldb::SectionSP> addr_to_sect_collection;
65 typedef llvm::DenseMap<const Section *, lldb::addr_t> sect_to_addr_collection;
68 mutable std::recursive_mutex m_mutex;
69};
70
71} // namespace lldb_private
72
73#endif // LLDB_TARGET_SECTIONLOADLIST_H
A section + offset based address class.
Definition: Address.h:62
void Dump(Stream &s, Target *target)
bool SetSectionUnloaded(const lldb::SectionSP &section_sp, lldb::addr_t load_addr)
void operator=(const SectionLoadList &rhs)
std::map< lldb::addr_t, lldb::SectionSP > addr_to_sect_collection
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, bool allow_section_end=false) const
std::recursive_mutex m_mutex
addr_to_sect_collection m_addr_to_sect
llvm::DenseMap< const Section *, lldb::addr_t > sect_to_addr_collection
bool SetSectionLoadAddress(const lldb::SectionSP &section_sp, lldb::addr_t load_addr, bool warn_multiple=false)
lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP &section_sp) const
sect_to_addr_collection m_sect_to_addr
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
std::shared_ptr< lldb_private::Section > SectionSP
Definition: lldb-forward.h:406
uint64_t addr_t
Definition: lldb-types.h:79