diff options
Diffstat (limited to 'lldb/test/lang/cpp')
| -rw-r--r-- | lldb/test/lang/cpp/char1632_t/Makefile | 8 | ||||
| -rw-r--r-- | lldb/test/lang/cpp/char1632_t/TestChar1632T.py | 81 | ||||
| -rw-r--r-- | lldb/test/lang/cpp/char1632_t/main.cpp | 21 |
3 files changed, 110 insertions, 0 deletions
diff --git a/lldb/test/lang/cpp/char1632_t/Makefile b/lldb/test/lang/cpp/char1632_t/Makefile new file mode 100644 index 00000000000..397bd743ea6 --- /dev/null +++ b/lldb/test/lang/cpp/char1632_t/Makefile @@ -0,0 +1,8 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp +CFLAGS :=-arch x86_64 -gdwarf-2 -O0 -std=c++11 + +clean: OBJECTS+=$(wildcard main.d.*) + +include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/char1632_t/TestChar1632T.py b/lldb/test/lang/cpp/char1632_t/TestChar1632T.py new file mode 100644 index 00000000000..944c3272e85 --- /dev/null +++ b/lldb/test/lang/cpp/char1632_t/TestChar1632T.py @@ -0,0 +1,81 @@ +# coding=utf8 +""" +Test that the C++11 support for char16_t and char32_t works correctly. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * +import lldbutil + +class Char1632TestCase(TestBase): + + mydir = os.path.join("lang", "cpp", "char1632_t") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @dsym_test + def test_with_dsym(self): + """Test that the C++11 support for char16_t and char32_t works correctly.""" + self.buildDsym() + self.char1632() + + @dwarf_test + def test_with_dwarf(self): + """Test that the C++11 support for char16_t and char32_t works correctly.""" + self.buildDwarf() + self.char1632() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break for main.cpp. + self.source = 'main.cpp' + self.line = line_number(self.source, '// Set break point at this line.') + + def char1632(self): + """Test that the C++11 support for char16_t and char32_t works correctly.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Break on the struct declration statement in main.cpp. + lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line) + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + + 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 = ','"hello world ྒྙྐ"','"hello world ྒྙྐ"']) + + # Check that we correctly report the non-const types + self.expect("frame variable s16 s32", + substrs = ['(char16_t *) s16 = ','(char32_t *) s32 = ','"ﺸﺵۻ"','"ЕЙРГЖО"']) + + 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']) + + self.runCmd("next") + self.runCmd("next") + + # check that the new strings shows + self.expect("frame variable s16 s32", + substrs = ['(char16_t *) s16 = 0x','(char32_t *) s32 = ','"色ハ匂ヘト散リヌルヲ"','"෴"']) + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() diff --git a/lldb/test/lang/cpp/char1632_t/main.cpp b/lldb/test/lang/cpp/char1632_t/main.cpp new file mode 100644 index 00000000000..fda951a7899 --- /dev/null +++ b/lldb/test/lang/cpp/char1632_t/main.cpp @@ -0,0 +1,21 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +int main (int argc, char const *argv[]) +{ + auto cs16 = u"hello world ྒྙྐ"; + auto cs32 = U"hello world ྒྙྐ"; + char16_t *s16 = (char16_t *)u"ﺸﺵۻ"; + char32_t *s32 = (char32_t *)U"ЕЙРГЖО"; + s32 = nullptr; // Set break point at this line. + s32 = (char32_t *)U"෴"; + s16 = (char16_t *)u"色ハ匂ヘト散リヌルヲ"; + return 0; +} |

