Skip to content

Commit a30a36f

Browse files
committed
[lldb] [ABI/X86] Split base x86 and i386 classes
Split the ABIX86 class into two classes: base ABIX86 class that is common to 32-bit and 64-bit ABIs, and ABIX86_i386 class that is the base for 32-bit ABIs. This removes the confusing concept that ABIX86 initializes 64-bit ABIs but is only the base for 32-bit ABIs. Differential Revision: https://reviews.llvm.org/D111216
1 parent e244a6f commit a30a36f

File tree

8 files changed

+61
-27
lines changed

8 files changed

+61
-27
lines changed

lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABIMACOSX_I386_H
1010
#define LLDB_SOURCE_PLUGINS_ABI_X86_ABIMACOSX_I386_H
1111

12-
#include "Plugins/ABI/X86/ABIX86.h"
12+
#include "Plugins/ABI/X86/ABIX86_i386.h"
1313
#include "lldb/Core/Value.h"
1414
#include "lldb/lldb-private.h"
1515

16-
class ABIMacOSX_i386 : public ABIX86 {
16+
class ABIMacOSX_i386 : public ABIX86_i386 {
1717
public:
1818
~ABIMacOSX_i386() override = default;
1919

@@ -92,7 +92,7 @@ class ABIMacOSX_i386 : public ABIX86 {
9292
}
9393

9494
private:
95-
using ABIX86::ABIX86; // Call CreateInstance instead.
95+
using ABIX86_i386::ABIX86_i386; // Call CreateInstance instead.
9696
};
9797

9898
#endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABIMACOSX_I386_H

lldb/source/Plugins/ABI/X86/ABISysV_i386.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
#ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_I386_H
1010
#define LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_I386_H
1111

12-
#include "Plugins/ABI/X86/ABIX86.h"
12+
#include "Plugins/ABI/X86/ABIX86_i386.h"
1313
#include "lldb/lldb-private.h"
1414

15-
class ABISysV_i386 : public ABIX86 {
15+
class ABISysV_i386 : public ABIX86_i386 {
1616
public:
1717
~ABISysV_i386() override = default;
1818

@@ -95,7 +95,7 @@ class ABISysV_i386 : public ABIX86 {
9595
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
9696

9797
private:
98-
using ABIX86::ABIX86; // Call CreateInstance instead.
98+
using ABIX86_i386::ABIX86_i386; // Call CreateInstance instead.
9999
};
100100

101101
#endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_I386_H

lldb/source/Plugins/ABI/X86/ABIX86.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- X86.h -------------------------------------------------------------===//
1+
//===-- ABIX86.cpp --------------------------------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -28,16 +28,3 @@ void ABIX86::Terminate() {
2828
ABISysV_x86_64::Terminate();
2929
ABIWindows_x86_64::Terminate();
3030
}
31-
32-
uint32_t ABIX86::GetGenericNum(llvm::StringRef name) {
33-
return llvm::StringSwitch<uint32_t>(name)
34-
.Case("eip", LLDB_REGNUM_GENERIC_PC)
35-
.Case("esp", LLDB_REGNUM_GENERIC_SP)
36-
.Case("ebp", LLDB_REGNUM_GENERIC_FP)
37-
.Case("eflags", LLDB_REGNUM_GENERIC_FLAGS)
38-
.Case("edi", LLDB_REGNUM_GENERIC_ARG1)
39-
.Case("esi", LLDB_REGNUM_GENERIC_ARG2)
40-
.Case("edx", LLDB_REGNUM_GENERIC_ARG3)
41-
.Case("ecx", LLDB_REGNUM_GENERIC_ARG4)
42-
.Default(LLDB_INVALID_REGNUM);
43-
}

lldb/source/Plugins/ABI/X86/ABIX86.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- X86.h ---------------------------------------------------*- C++ -*-===//
1+
//===-- ABIX86.h ------------------------------------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,15 +10,15 @@
1010
#define LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_H
1111

1212
#include "lldb/Target/ABI.h"
13+
#include "lldb/lldb-private.h"
1314

1415
class ABIX86 : public lldb_private::MCBasedABI {
1516
public:
1617
static void Initialize();
1718
static void Terminate();
1819

19-
uint32_t GetGenericNum(llvm::StringRef name) override;
20-
2120
private:
2221
using lldb_private::MCBasedABI::MCBasedABI;
2322
};
23+
2424
#endif

lldb/source/Plugins/ABI/X86/ABIX86_64.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99
#ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_64_H
1010
#define LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_64_H
1111

12-
#include "lldb/Target/ABI.h"
13-
#include "lldb/lldb-private.h"
12+
#include "Plugins/ABI/X86/ABIX86.h"
13+
14+
class ABIX86_64 : public ABIX86 {
15+
public:
16+
uint32_t GetGenericNum(llvm::StringRef name) override;
1417

15-
class ABIX86_64 : public lldb_private::MCBasedABI {
1618
protected:
1719
std::string GetMCName(std::string name) override {
1820
MapRegisterName(name, "stmm", "st");
1921
return name;
2022
}
2123

2224
private:
23-
using lldb_private::MCBasedABI::MCBasedABI;
25+
using ABIX86::ABIX86;
2426
};
2527

2628
#endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_64_H
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- ABIX86_i386.cpp ---------------------------------------------------===//
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 "ABIX86_i386.h"
10+
11+
uint32_t ABIX86_i386::GetGenericNum(llvm::StringRef name) {
12+
return llvm::StringSwitch<uint32_t>(name)
13+
.Case("eip", LLDB_REGNUM_GENERIC_PC)
14+
.Case("esp", LLDB_REGNUM_GENERIC_SP)
15+
.Case("ebp", LLDB_REGNUM_GENERIC_FP)
16+
.Case("eflags", LLDB_REGNUM_GENERIC_FLAGS)
17+
.Case("edi", LLDB_REGNUM_GENERIC_ARG1)
18+
.Case("esi", LLDB_REGNUM_GENERIC_ARG2)
19+
.Case("edx", LLDB_REGNUM_GENERIC_ARG3)
20+
.Case("ecx", LLDB_REGNUM_GENERIC_ARG4)
21+
.Default(LLDB_INVALID_REGNUM);
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- ABIX86_i386.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_SOURCE_PLUGINS_ABI_X86_ABIX86_I386_H
10+
#define LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_I386_H
11+
12+
#include "Plugins/ABI/X86/ABIX86.h"
13+
14+
class ABIX86_i386 : public ABIX86 {
15+
public:
16+
uint32_t GetGenericNum(llvm::StringRef name) override;
17+
18+
private:
19+
using ABIX86::ABIX86;
20+
};
21+
22+
#endif

lldb/source/Plugins/ABI/X86/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
add_lldb_library(lldbPluginABIX86 PLUGIN
22
ABIX86.cpp
3+
ABIX86_i386.cpp
34
ABIMacOSX_i386.cpp
45
ABISysV_i386.cpp
56
ABISysV_x86_64.cpp

0 commit comments

Comments
 (0)