xref: /llvm-project/lldb/tools/lldb-server/SystemInitializerLLGS.cpp (revision ca4cd08fb9d7a03fbd00bca05d5dbfa87cd6db4e)
1 //===-- SystemInitializerLLGS.cpp -------------------------------*- 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 #include "SystemInitializerLLGS.h"
10 
11 #if defined(__APPLE__)
12 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
13 using HostObjectFile = ObjectFileMachO;
14 #elif defined(_WIN32)
15 #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
16 using HostObjectFile = ObjectFilePECOFF;
17 #elif defined(_AIX)
18 #include "Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h"
19 using HostObjectFile = ObjectFileXCOFF;
20 #else
21 #include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
22 using HostObjectFile = ObjectFileELF;
23 #endif
24 
25 #if defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
26 #define LLDB_TARGET_ARM64
27 #endif
28 
29 #if defined(__arm__) || defined(__arm) || defined(_ARM) || defined(_M_ARM) ||  \
30     defined(LLDB_TARGET_ARM64)
31 #define LLDB_TARGET_ARM
32 #include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
33 #endif
34 
35 #if defined(__loongarch__)
36 #define LLDB_TARGET_LoongArch
37 #include "Plugins/Instruction/LoongArch/EmulateInstructionLoongArch.h"
38 #endif
39 
40 #if defined(__mips64__) || defined(mips64) || defined(__mips64) ||             \
41     defined(__MIPS64__) || defined(_M_MIPS64)
42 #define LLDB_TARGET_MIPS64
43 #include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
44 #endif
45 
46 #if defined(__mips__) || defined(mips) || defined(__mips) ||                   \
47     defined(__MIPS__) || defined(_M_MIPS) || defined(LLDB_TARGET_MIPS64)
48 #define LLDB_TARGET_MIPS
49 #include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
50 #endif
51 
52 #if defined(__riscv)
53 #define LLDB_TARGET_RISCV
54 #include "Plugins/Instruction/RISCV/EmulateInstructionRISCV.h"
55 #endif
56 
57 using namespace lldb_private;
58 
59 llvm::Error SystemInitializerLLGS::Initialize() {
60   if (auto e = SystemInitializerCommon::Initialize())
61     return e;
62 
63   HostObjectFile::Initialize();
64 
65 #if defined(LLDB_TARGET_ARM) || defined(LLDB_TARGET_ARM64)
66   EmulateInstructionARM::Initialize();
67 #endif
68 #if defined(LLDB_TARGET_LoongArch)
69   EmulateInstructionLoongArch::Initialize();
70 #endif
71 #if defined(LLDB_TARGET_MIPS) || defined(LLDB_TARGET_MIPS64)
72   EmulateInstructionMIPS::Initialize();
73 #endif
74 #if defined(LLDB_TARGET_MIPS64)
75   EmulateInstructionMIPS64::Initialize();
76 #endif
77 #if defined(LLDB_TARGET_RISCV)
78   EmulateInstructionRISCV::Initialize();
79 #endif
80 
81   return llvm::Error::success();
82 }
83 
84 void SystemInitializerLLGS::Terminate() {
85   HostObjectFile::Terminate();
86 
87 #if defined(LLDB_TARGET_ARM) || defined(LLDB_TARGET_ARM64)
88   EmulateInstructionARM::Terminate();
89 #endif
90 #if defined(LLDB_TARGET_LoongArch)
91   EmulateInstructionLoongArch::Terminate();
92 #endif
93 #if defined(LLDB_TARGET_MIPS) || defined(LLDB_TARGET_MIPS64)
94   EmulateInstructionMIPS::Terminate();
95 #endif
96 #if defined(LLDB_TARGET_MIPS64)
97   EmulateInstructionMIPS64::Terminate();
98 #endif
99 #if defined(LLDB_TARGET_RISCV)
100   EmulateInstructionRISCV::Terminate();
101 #endif
102 
103   SystemInitializerCommon::Terminate();
104 }
105