Coverage Report

Created: 2023-09-30 09:22

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Target/SectionLoadList.h
Line
Count
Source
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
20
namespace lldb_private {
21
22
class SectionLoadList {
23
public:
24
  // Constructors and Destructors
25
3.11k
  SectionLoadList() = default;
26
27
  SectionLoadList(const SectionLoadList &rhs);
28
29
5.37k
  ~SectionLoadList() {
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
5.37k
    Clear();
33
5.37k
  }
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
63
protected:
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;
66
  addr_to_sect_collection m_addr_to_sect;
67
  sect_to_addr_collection m_sect_to_addr;
68
  mutable std::recursive_mutex m_mutex;
69
};
70
71
} // namespace lldb_private
72
73
#endif // LLDB_TARGET_SECTIONLOADLIST_H