summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Sigg <csigg@google.com>2020-01-11 08:47:41 +0100
committerChristian Sigg <csigg@google.com>2020-01-11 09:17:15 +0100
commit60346bdbd73da9c944d50ea5dcecad71a05105ac (patch)
tree53cefe490caed98a4455c44947fa022d7ee7d7a0
parentc2ddfa876fa90008f1b4ff611256ad5dd4b36d96 (diff)
downloadbcm5719-llvm-60346bdbd73da9c944d50ea5dcecad71a05105ac.tar.gz
bcm5719-llvm-60346bdbd73da9c944d50ea5dcecad71a05105ac.zip
Add test for GDB pretty printers.
Reviewers: dblaikie, aprantl, davide, JDevlieghere Reviewed By: aprantl Subscribers: jmorse, aprantl, merge_guards_bot, mgorny, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72321
-rw-r--r--debuginfo-tests/CMakeLists.txt6
-rw-r--r--debuginfo-tests/lit.cfg.py2
-rw-r--r--debuginfo-tests/llvm-prettyprinters/gdb/lit.local.cfg9
-rw-r--r--debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.cpp25
-rw-r--r--debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.gdb41
5 files changed, 83 insertions, 0 deletions
diff --git a/debuginfo-tests/CMakeLists.txt b/debuginfo-tests/CMakeLists.txt
index 36863e030b7..c122d9b27a8 100644
--- a/debuginfo-tests/CMakeLists.txt
+++ b/debuginfo-tests/CMakeLists.txt
@@ -2,6 +2,11 @@
# various types of debug info, and then run those programs under a debugger
# such as GDB or LLDB to verify the results.
+add_llvm_executable(prettyprinters
+ llvm-prettyprinters/gdb/prettyprinters.cpp
+)
+target_link_libraries(prettyprinters PRIVATE LLVMSupport)
+
set(DEBUGINFO_TESTS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(DEBUGINFO_TESTS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
@@ -11,6 +16,7 @@ set(DEBUGINFO_TEST_DEPS
count
llvm-objdump
not
+ prettyprinters
)
# The Windows builder scripts pass -fuse-ld=lld.
diff --git a/debuginfo-tests/lit.cfg.py b/debuginfo-tests/lit.cfg.py
index f5a96c69c4d..837c930ac7f 100644
--- a/debuginfo-tests/lit.cfg.py
+++ b/debuginfo-tests/lit.cfg.py
@@ -44,6 +44,8 @@ llvm_config.use_default_substitutions()
tools = [
ToolSubst('%test_debuginfo', command=os.path.join(
config.debuginfo_tests_src_root, 'llgdb-tests', 'test_debuginfo.pl')),
+ ToolSubst("%llvm_src_root", config.llvm_src_root),
+ ToolSubst("%llvm_tools_dir", config.llvm_tools_dir),
]
def get_required_attr(config, attr_name):
diff --git a/debuginfo-tests/llvm-prettyprinters/gdb/lit.local.cfg b/debuginfo-tests/llvm-prettyprinters/gdb/lit.local.cfg
new file mode 100644
index 00000000000..be053e06f59
--- /dev/null
+++ b/debuginfo-tests/llvm-prettyprinters/gdb/lit.local.cfg
@@ -0,0 +1,9 @@
+import lit.util
+
+# debuginfo-tests are not expected to pass in a cross-compilation setup.
+if 'native' not in config.available_features or lit.util.which('gdb') is None:
+ config.unsupported = True
+
+config.suffixes = ['.gdb']
+
+
diff --git a/debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.cpp b/debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.cpp
new file mode 100644
index 00000000000..03cef4d977d
--- /dev/null
+++ b/debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.cpp
@@ -0,0 +1,25 @@
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Error.h"
+
+int Array[] = {1, 2, 3};
+
+llvm::ArrayRef<int> ArrayRef(Array);
+llvm::MutableArrayRef<int> MutableArrayRef(Array);
+llvm::DenseMap<int, int> DenseMap = {{4, 5}, {6, 7}};
+llvm::Expected<int> ExpectedValue(8);
+llvm::Expected<int> ExpectedError(llvm::createStringError({}, ""));
+llvm::Optional<int> OptionalValue(9);
+llvm::Optional<int> OptionalNone(llvm::None);
+llvm::SmallVector<int, 5> SmallVector = {10, 11, 12};
+llvm::SmallString<5> SmallString("foo");
+llvm::StringRef StringRef = "bar";
+llvm::Twine Twine = llvm::Twine(SmallString) + StringRef;
+
+int main() {
+ return 0;
+}
diff --git a/debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.gdb b/debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.gdb
new file mode 100644
index 00000000000..94213f94143
--- /dev/null
+++ b/debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.gdb
@@ -0,0 +1,41 @@
+# RUN: gdb -q -batch -n -iex 'source %llvm_src_root/utils/gdb-scripts/prettyprinters.py' -x %s %llvm_tools_dir/prettyprinters | FileCheck %s
+
+break main
+run
+
+# CHECK: llvm::ArrayRef of length 3 = {1, 2, 3}
+p ArrayRef
+
+# CHECK: llvm::ArrayRef of length 3 = {1, 2, 3}
+p MutableArrayRef
+
+# CHECK: llvm::DenseMap with 2 elements = {
+# CHECK: [4] = 5,
+# CHECK: [6] = 7,
+# CHECK: }
+p DenseMap
+
+# CHECK: llvm::Expected = {value = 8}
+p ExpectedValue
+
+# CHECK: llvm::Expected is error
+p ExpectedError
+
+# CHECK: llvm::Optional = {value = 9}
+p OptionalValue
+
+# CHECK: llvm::Optional is not initialized
+p OptionalNone
+
+# CHECK: llvm::SmallVector of Size 3, Capacity 5 = {10, 11, 12}
+p SmallVector
+
+# CHECK: "foo"
+p SmallString
+
+# CHECK: "bar"
+p StringRef
+
+# CHECK: "\"foo\"\"bar\""
+p Twine
+
OpenPOWER on IntegriCloud