aboutsummaryrefslogtreecommitdiff
path: root/llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupportPlugin.h
blob: af092b3287d356ed4444767b41738f699c571021 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//===--- DebugerSupportPlugin.h -- Utils for debugger support ---*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Generates debug objects and registers them using the jit-loader-gdb protocol.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_EXECUTIONENGINE_ORC_DEBUGGERSUPPORT_H
#define LLVM_EXECUTIONENGINE_ORC_DEBUGGERSUPPORT_H

#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"

namespace llvm {
namespace orc {

/// For each object containing debug info, installs JITLink passes to synthesize
/// a debug object and then register it via the GDB JIT-registration interface.
///
/// Currently MachO only. For ELF use DebugObjectManagerPlugin. These two
/// plugins will be merged in the near future.
class GDBJITDebugInfoRegistrationPlugin : public ObjectLinkingLayer::Plugin {
public:
  class DebugSectionSynthesizer {
  public:
    virtual ~DebugSectionSynthesizer() {}
    virtual Error startSynthesis() = 0;
    virtual Error completeSynthesisAndRegister() = 0;
  };

  static Expected<std::unique_ptr<GDBJITDebugInfoRegistrationPlugin>>
  Create(ExecutionSession &ES, JITDylib &ProcessJD, const Triple &TT);

  GDBJITDebugInfoRegistrationPlugin(ExecutorAddr RegisterActionAddr)
      : RegisterActionAddr(RegisterActionAddr) {}

  Error notifyFailed(MaterializationResponsibility &MR) override;
  Error notifyRemovingResources(ResourceKey K) override;

  void notifyTransferringResources(ResourceKey DstKey,
                                   ResourceKey SrcKey) override;

  void modifyPassConfig(MaterializationResponsibility &MR,
                        jitlink::LinkGraph &LG,
                        jitlink::PassConfiguration &PassConfig) override;

private:
  void modifyPassConfigForMachO(MaterializationResponsibility &MR,
                                jitlink::LinkGraph &LG,
                                jitlink::PassConfiguration &PassConfig);

  ExecutorAddr RegisterActionAddr;
};

} // namespace orc
} // namespace llvm

#endif // LLVM_EXECUTIONENGINE_ORC_DEBUGGERSUPPORT_H