aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/BinaryFormat/Dwarf.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2024-06-07 13:48:17 -0700
committerGitHub <noreply@github.com>2024-06-07 13:48:17 -0700
commit96d01a350ce9875a8f893ecdc1d470caf7ed5bcd (patch)
treee7342c09697993a838a4de71adbaabb466c196ac /llvm/lib/BinaryFormat/Dwarf.cpp
parent75b89cc00c0dcc5694c94dd553c5c5204e2e4192 (diff)
downloadllvm-96d01a350ce9875a8f893ecdc1d470caf7ed5bcd.zip
llvm-96d01a350ce9875a8f893ecdc1d470caf7ed5bcd.tar.gz
llvm-96d01a350ce9875a8f893ecdc1d470caf7ed5bcd.tar.bz2
[lldb] Encode operands and arity in Dwarf.def and use them in LLDB. (#94679)
This PR extends Dwarf.def to include the number of operands and the arity (the number of entries on the DWARF stack). - The arity is used in LLDB's DWARF expression evaluator. - The number of operands is unused, but is present in the table to avoid confusing the arity with the operands. Keeping the latter up to date should be straightforward as it maps directly to a table present in the DWARF standard.
Diffstat (limited to 'llvm/lib/BinaryFormat/Dwarf.cpp')
-rw-r--r--llvm/lib/BinaryFormat/Dwarf.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp
index 0bf4f20..0cd5dfb 100644
--- a/llvm/lib/BinaryFormat/Dwarf.cpp
+++ b/llvm/lib/BinaryFormat/Dwarf.cpp
@@ -139,7 +139,7 @@ StringRef llvm::dwarf::OperationEncodingString(unsigned Encoding) {
switch (Encoding) {
default:
return StringRef();
-#define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR) \
+#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
case DW_OP_##NAME: \
return "DW_OP_" #NAME;
#include "llvm/BinaryFormat/Dwarf.def"
@@ -164,7 +164,7 @@ StringRef llvm::dwarf::OperationEncodingString(unsigned Encoding) {
unsigned llvm::dwarf::getOperationEncoding(StringRef OperationEncodingString) {
return StringSwitch<unsigned>(OperationEncodingString)
-#define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR) \
+#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
.Case("DW_OP_" #NAME, DW_OP_##NAME)
#include "llvm/BinaryFormat/Dwarf.def"
.Case("DW_OP_LLVM_convert", DW_OP_LLVM_convert)
@@ -216,18 +216,44 @@ unsigned llvm::dwarf::OperationVersion(dwarf::LocationAtom Op) {
switch (Op) {
default:
return 0;
-#define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR) \
+#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
case DW_OP_##NAME: \
return VERSION;
#include "llvm/BinaryFormat/Dwarf.def"
}
}
+std::optional<unsigned> llvm::dwarf::OperationOperands(dwarf::LocationAtom Op) {
+ switch (Op) {
+ default:
+ return std::nullopt;
+#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
+ case DW_OP_##NAME: \
+ if (OPERANDS == -1) \
+ return std::nullopt; \
+ return OPERANDS;
+#include "llvm/BinaryFormat/Dwarf.def"
+ }
+}
+
+std::optional<unsigned> llvm::dwarf::OperationArity(dwarf::LocationAtom Op) {
+ switch (Op) {
+ default:
+ return std::nullopt;
+#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
+ case DW_OP_##NAME: \
+ if (ARITY == -1) \
+ return std::nullopt; \
+ return ARITY;
+#include "llvm/BinaryFormat/Dwarf.def"
+ }
+}
+
unsigned llvm::dwarf::OperationVendor(dwarf::LocationAtom Op) {
switch (Op) {
default:
return 0;
-#define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR) \
+#define HANDLE_DW_OP(ID, NAME, OPERANDS, ARITY, VERSION, VENDOR) \
case DW_OP_##NAME: \
return DWARF_VENDOR_##VENDOR;
#include "llvm/BinaryFormat/Dwarf.def"