summaryrefslogtreecommitdiffstats
path: root/packages/Python/lldbsuite/test/lang/c/set_values
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/c/set_values
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/c/set_values')
-rw-r--r--packages/Python/lldbsuite/test/lang/c/set_values/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py111
-rw-r--r--packages/Python/lldbsuite/test/lang/c/set_values/main.c116
3 files changed, 232 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/lang/c/set_values/Makefile b/packages/Python/lldbsuite/test/lang/c/set_values/Makefile
new file mode 100644
index 0000000..b09a579
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/set_values/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py b/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py
new file mode 100644
index 0000000..ab81024
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py
@@ -0,0 +1,111 @@
+"""Test settings and readings of program variables."""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class SetValuesTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line numbers to break inside main().
+ self.line1 = line_number('main.c', '// Set break point #1.')
+ self.line2 = line_number('main.c', '// Set break point #2.')
+ self.line3 = line_number('main.c', '// Set break point #3.')
+ self.line4 = line_number('main.c', '// Set break point #4.')
+ self.line5 = line_number('main.c', '// Set break point #5.')
+
+ @expectedFailureWindows("llvm.org/pr21765")
+ def test(self):
+ """Test settings and readings of program variables."""
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Set breakpoints on several places to set program variables.
+ lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line1, num_expected_locations=1, loc_exact=True)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line2, num_expected_locations=1, loc_exact=True)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line3, num_expected_locations=1, loc_exact=True)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line4, num_expected_locations=1, loc_exact=True)
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line5, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs = [' resolved, hit count = 1'])
+
+ # main.c:15
+ # Check that 'frame variable --show-types' displays the correct data type and value.
+ self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY,
+ startstr = "(char) i = 'a'")
+
+ # Now set variable 'i' and check that it is correctly displayed.
+ self.runCmd("expression i = 'b'")
+ self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY,
+ startstr = "(char) i = 'b'")
+
+ self.runCmd("continue")
+
+ # main.c:36
+ # Check that 'frame variable --show-types' displays the correct data type and value.
+ self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY,
+ patterns = ["\((short unsigned int|unsigned short)\) i = 33"])
+
+ # Now set variable 'i' and check that it is correctly displayed.
+ self.runCmd("expression i = 333")
+ self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY,
+ patterns = ["\((short unsigned int|unsigned short)\) i = 333"])
+
+ self.runCmd("continue")
+
+ # main.c:57
+ # Check that 'frame variable --show-types' displays the correct data type and value.
+ self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY,
+ startstr = "(long) i = 33")
+
+ # Now set variable 'i' and check that it is correctly displayed.
+ self.runCmd("expression i = 33333")
+ self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY,
+ startstr = "(long) i = 33333")
+
+ self.runCmd("continue")
+
+ # main.c:78
+ # Check that 'frame variable --show-types' displays the correct data type and value.
+ self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY,
+ startstr = "(double) i = 2.25")
+
+ # Now set variable 'i' and check that it is correctly displayed.
+ self.runCmd("expression i = 1.5")
+ self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY,
+ startstr = "(double) i = 1.5")
+
+ self.runCmd("continue")
+
+ # main.c:85
+ # Check that 'frame variable --show-types' displays the correct data type and value.
+ self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY,
+ startstr = "(long double) i = 2.25")
+
+ # Now set variable 'i' and check that it is correctly displayed.
+ self.runCmd("expression i = 1.5")
+ self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY,
+ startstr = "(long double) i = 1.5")
diff --git a/packages/Python/lldbsuite/test/lang/c/set_values/main.c b/packages/Python/lldbsuite/test/lang/c/set_values/main.c
new file mode 100644
index 0000000..64f01a9
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/set_values/main.c
@@ -0,0 +1,116 @@
+//===-- 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 <stdio.h>
+
+void set_char(void)
+{
+ char i = 'a';
+ printf("before (char) i = %c\n", i);
+ printf("after (char) i = %c\n", i); // Set break point #1. //// break $source:$line
+}
+
+void set_uchar(void)
+{
+ unsigned char i = 'a';
+ printf("before (unsigned char) i = %c\n", i);
+ printf("after (unsigned char) i = %c\n", i); //// break $source:$line
+}
+
+void set_short(void)
+{
+ short i = 33;
+ printf("before (short) i = %i\n", i);
+ printf("after (short) i = %i\n", i); //// break $source:$line
+}
+
+void set_ushort(void)
+{
+ unsigned short i = 33;
+ printf("before (unsigned short) i = %i\n", i);
+ printf("after (unsigned short) i = %i\n", i); // Set break point #2. //// break $source:$line
+}
+
+void set_int(void)
+{
+ int i = 33;
+ printf("before (int) i = %i\n", i);
+ printf("after (int) i = %i\n", i); //// break $source:$line
+}
+
+void set_uint(void)
+{
+ unsigned int i = 33;
+ printf("before (unsigned int) i = %u\n", i);
+ printf("after (unsigned int) i = %u\n", i); //// break $source:$line
+}
+
+void set_long(void)
+{
+ long i = 33;
+ printf("before (long) i = %li\n", i);
+ printf("after (long) i = %li\n", i); // Set break point #3. //// break $source:$line
+}
+
+void set_ulong(void)
+{
+ unsigned long i = 33;
+ printf("before (unsigned long) i = %lu\n", i);
+ printf("after (unsigned long) i = %lu\n", i); //// break $source:$line
+}
+
+void set_float(void)
+{
+ float i = 2.25;
+ printf("before (float) i = %g\n", i);
+ printf("after (float) i = %g\n", i); //// break $source:$line
+}
+
+void set_double(void)
+{
+ double i = 2.25;
+ printf("before (double) i = %g\n", i);
+ printf("after (double) i = %g\n", i); // Set break point #4. //// break $source:$line
+}
+
+void set_long_double(void)
+{
+ long double i = 2.25;
+ printf("before (long double) i = %Lg\n", i);
+ printf("after (long double) i = %Lg\n", i); // Set break point #5. //// break $source:$line
+}
+
+void set_point (void)
+{
+ struct point_tag {
+ int x;
+ int y;
+ };
+ struct point_tag points_2[2] = {
+ {1,2},
+ {3,4}
+ };
+}
+
+int main (int argc, char const *argv[])
+{
+ // Continue to the breakpoint in set_char()
+ set_char(); //// continue; var i; val -set 99 1
+ set_uchar(); //// continue; var i; val -set 99 2
+ set_short(); //// continue; var i; val -set -42 3
+ set_ushort(); //// continue; var i; val -set 42 4
+ set_int(); //// continue; var i; val -set -42 5
+ set_uint(); //// continue; var i; val -set 42 6
+ set_long(); //// continue; var i; val -set -42 7
+ set_ulong(); //// continue; var i; val -set 42 8
+ set_float(); //// continue; var i; val -set 123.456 9
+ set_double(); //// continue; var i; val -set 123.456 10
+ set_long_double(); //// continue; var i; val -set 123.456 11
+ set_point (); //// continue
+ return 0;
+}
OpenPOWER on IntegriCloud