aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/lang/c/bitfields
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/c/bitfields')
-rw-r--r--packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py21
-rw-r--r--packages/Python/lldbsuite/test/lang/c/bitfields/main.c14
2 files changed, 28 insertions, 7 deletions
diff --git a/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py b/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
index de7a333a18fa..30175c5e1c15 100644
--- a/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
+++ b/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
@@ -6,8 +6,9 @@ from __future__ import print_function
import os, time
import lldb
+from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test import lldbutil
class BitfieldsTestCase(TestBase):
@@ -95,8 +96,17 @@ class BitfieldsTestCase(TestBase):
self.expect("expr (more_bits.d)", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ['uint8_t', '\\0'])
+ self.expect("expr (packed.a)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs = ['char', "'a'"])
+ self.expect("expr (packed.b)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs = ['uint32_t', "10"])
+ self.expect("expr/x (packed.c)", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs = ['uint32_t', "7112233"])
+
+
@add_test_categories(['pyapi'])
@skipIfWindows # BitFields exhibit crashes in record layout on Windows (http://llvm.org/pr21800)
+ @expectedFailureAll("llvm.org/pr27510", oslist=["linux"], compiler="clang", compiler_version=[">=", "3.9"])
def test_and_python_api(self):
"""Use Python APIs to inspect a bitfields variable."""
self.build()
@@ -112,14 +122,11 @@ class BitfieldsTestCase(TestBase):
self.assertTrue(process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint.
- thread = target.GetProcess().GetThreadAtIndex(0)
- if thread.GetStopReason() != lldb.eStopReasonBreakpoint:
- from lldbsuite.test.lldbutil import stop_reason_to_str
- self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS %
- stop_reason_to_str(thread.GetStopReason()))
+ thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+ self.assertIsNotNone(thread)
# The breakpoint should have a hit count of 1.
- self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE)
+ self.assertEqual(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE)
# Lookup the "bits" variable which contains 8 bitfields.
frame = thread.GetFrameAtIndex(0)
diff --git a/packages/Python/lldbsuite/test/lang/c/bitfields/main.c b/packages/Python/lldbsuite/test/lang/c/bitfields/main.c
index 26c0176d759c..236c926d81bd 100644
--- a/packages/Python/lldbsuite/test/lang/c/bitfields/main.c
+++ b/packages/Python/lldbsuite/test/lang/c/bitfields/main.c
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include <stdint.h>
#include <stdio.h>
+
int main (int argc, char const *argv[])
{
struct Bits
@@ -62,6 +63,19 @@ int main (int argc, char const *argv[])
more_bits.c = 1;
more_bits.d = 0;
+#pragma pack(1)
+ struct PackedBits
+ {
+ char a;
+ uint32_t b : 5,
+ c : 27;
+ };
+#pragma pack()
+ struct PackedBits packed;
+ packed.a = 'a';
+ packed.b = 10;
+ packed.c = 0x7112233;
+
return 0; //// Set break point at this line.
}