summaryrefslogtreecommitdiffstats
path: root/packages/Python/lldbsuite/test/lang/cpp/char1632_t
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2016-01-06 20:12:03 +0000
committerdim <dim@FreeBSD.org>2016-01-06 20:12:03 +0000
commit78b9749c0a4ea980a8b934645da6ae98fcc665e8 (patch)
treedd2a1ddf0476664c2b823409c36cbccd52662ca7 /packages/Python/lldbsuite/test/lang/cpp/char1632_t
parent60cb593f9d55fa5ca7a5372b731f2330345b4b9a (diff)
downloadFreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.zip
FreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.tar.gz
Vendor import of lldb trunk r256945:
https://llvm.org/svn/llvm-project/lldb/trunk@256945
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/cpp/char1632_t')
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/char1632_t/.categories1
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/char1632_t/Makefile8
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py90
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/char1632_t/main.cpp44
4 files changed, 143 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/lang/cpp/char1632_t/.categories b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/.categories
new file mode 100644
index 0000000..fe1da02
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/.categories
@@ -0,0 +1 @@
+dataformatters
diff --git a/packages/Python/lldbsuite/test/lang/cpp/char1632_t/Makefile b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/Makefile
new file mode 100644
index 0000000..932046f
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/Makefile
@@ -0,0 +1,8 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+CFLAGS :=-g -O0 -std=c++11
+
+clean: OBJECTS+=$(wildcard main.d.*)
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py
new file mode 100644
index 0000000..9bb1faf
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py
@@ -0,0 +1,90 @@
+# coding=utf8
+"""
+Test that the C++11 support for char16_t and char32_t works correctly.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class Char1632TestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break for main.cpp.
+ self.source = 'main.cpp'
+ self.lines = [ line_number(self.source, '// breakpoint1'),
+ line_number(self.source, '// breakpoint2') ]
+
+ @expectedFailureIcc # ICC (13.1) does not emit the DW_TAG_base_type for char16_t and char32_t.
+ @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows")
+ def test(self):
+ """Test that the C++11 support for char16_t and char32_t works correctly."""
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Set breakpoints
+ for line in self.lines:
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", line)
+
+ # Now launch the process, and do not stop at entry point and stop at breakpoint1
+ process = target.LaunchSimple (None, None, self.get_process_working_directory())
+
+ if not process:
+ self.fail("SBTarget.Launch() failed")
+
+ if self.TraceOn():
+ self.runCmd("frame variable")
+
+ # Check that we correctly report the const types
+ self.expect("frame variable cs16 cs32",
+ substrs = ['(const char16_t *) cs16 = ','(const char32_t *) cs32 = ','u"hello world ྒྙྐ"','U"hello world ྒྙྐ"'])
+
+ # Check that we correctly report the non-const types
+ self.expect("frame variable s16 s32",
+ substrs = ['(char16_t *) s16 = ','(char32_t *) s32 = ','u"ﺸﺵۻ"','U"ЕЙРГЖО"'])
+
+ # Check that we correctly report the array types
+ self.expect("frame variable as16 as32",
+ patterns = ['\(char16_t \[[0-9]+\]\) as16 = ', '\(char32_t \[[0-9]+\]\) as32 = '],
+ substrs = ['u"ﺸﺵۻ"','U"ЕЙРГЖО"'])
+
+ self.runCmd("next") # step to after the string is nullified
+
+ # check that we don't crash on NULL
+ self.expect("frame variable s32",
+ substrs = ['(char32_t *) s32 = 0x00000000'])
+
+ # continue and hit breakpoint2
+ self.runCmd("continue")
+
+ # check that the new strings show
+ self.expect("frame variable s16 s32",
+ substrs = ['(char16_t *) s16 = 0x','(char32_t *) s32 = ','"色ハ匂ヘト散リヌルヲ"','"෴"'])
+
+ # check the same as above for arrays
+ self.expect("frame variable as16 as32",
+ patterns = ['\(char16_t \[[0-9]+\]\) as16 = ', '\(char32_t \[[0-9]+\]\) as32 = '],
+ substrs = ['"色ハ匂ヘト散リヌルヲ"','"෴"'])
+
+ # check that zero values are properly handles
+ self.expect('frame variable cs16_zero', substrs=["U+0000 u'\\0'"])
+ self.expect('frame variable cs32_zero', substrs=["U+0x00000000 U'\\0'"])
+ self.expect('expression cs16_zero', substrs=["U+0000 u'\\0'"])
+ self.expect('expression cs32_zero', substrs=["U+0x00000000 U'\\0'"])
+
+ # Check that we can run expressions that return charN_t
+ self.expect("expression u'a'",substrs = ['(char16_t) $',"61 u'a'"])
+ self.expect("expression U'a'",substrs = ['(char32_t) $',"61 U'a'"])
diff --git a/packages/Python/lldbsuite/test/lang/cpp/char1632_t/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/main.cpp
new file mode 100644
index 0000000..b92c2d5
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/main.cpp
@@ -0,0 +1,44 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <assert.h>
+#include <string>
+
+#define UASZ 64
+
+template<class T, int N>
+void copy_char_seq (T (&arr)[N], const T* src)
+{
+ size_t src_len = std::char_traits<T>::length(src);
+ assert(src_len < N);
+
+ std::char_traits<T>::copy(arr, src, src_len);
+ arr[src_len] = 0;
+}
+
+int main (int argc, char const *argv[])
+{
+ char16_t as16[UASZ];
+ char32_t as32[UASZ];
+ auto cs16_zero = (char16_t)0;
+ auto cs32_zero = (char32_t)0;
+ auto cs16 = u"hello world ྒྙྐ";
+ auto cs32 = U"hello world ྒྙྐ";
+ char16_t *s16 = (char16_t *)u"ﺸﺵۻ";
+ char32_t *s32 = (char32_t *)U"ЕЙРГЖО";
+ copy_char_seq(as16, s16);
+ copy_char_seq(as32, s32);
+ s32 = nullptr; // breakpoint1
+ s32 = (char32_t *)U"෴";
+ s16 = (char16_t *)u"色ハ匂ヘト散リヌルヲ";
+ copy_char_seq(as16, s16);
+ copy_char_seq(as32, s32);
+ s32 = nullptr; // breakpoint2
+ return 0;
+}
OpenPOWER on IntegriCloud