summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/lang
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/lang')
-rw-r--r--packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile3
-rw-r--r--packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py67
-rw-r--r--packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c25
-rw-r--r--packages/Python/lldbsuite/test/lang/c/register_variables/Makefile2
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile4
5 files changed, 98 insertions, 3 deletions
diff --git a/packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile b/packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile
new file mode 100644
index 0000000000000..cd9ca5c86d84c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile
@@ -0,0 +1,3 @@
+LEVEL = ../../../make
+C_SOURCES := main.c
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py b/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py
new file mode 100644
index 0000000000000..bbe5be67c08d7
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py
@@ -0,0 +1,67 @@
+"""
+Make sure FindTypes finds struct types with the struct prefix.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class TestFindTypesOnStructType(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ # If your test case doesn't stress debug info, the
+ # set this to true. That way it won't be run once for
+ # each debug info format.
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_find_types_struct_type(self):
+ """Make sure FindTypes actually finds 'struct typename' not just 'typename'."""
+ self.build()
+ self.do_test()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def do_test(self):
+ """Make sure FindTypes actually finds 'struct typename' not just 'typename'."""
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Make sure this works with struct
+ type_list = target.FindTypes("struct mytype")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with struct")
+
+ # Make sure this works without the struct:
+ type_list = target.FindTypes("mytype")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without struct")
+
+ # Make sure it works with union
+ type_list = target.FindTypes("union myunion")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with union")
+
+ # Make sure this works without the union:
+ type_list = target.FindTypes("myunion")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without union")
+
+ # Make sure it works with typedef
+ type_list = target.FindTypes("typedef MyType")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with typedef")
+
+ # Make sure this works without the typedef:
+ type_list = target.FindTypes("MyType")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without typedef")
+
+
+
diff --git a/packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c b/packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c
new file mode 100644
index 0000000000000..fa009af27e17e
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdlib.h>
+struct mytype {
+ int c;
+ int d;
+};
+
+union myunion {
+ int num;
+ char *str;
+};
+
+typedef struct mytype MyType;
+
+int main()
+{
+ struct mytype v;
+ MyType *v_ptr = &v;
+
+ union myunion u = {5};
+ v.c = u.num;
+ v.d = 10;
+ return v.c + v.d;
+}
+
diff --git a/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile b/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
index a09f73fb3fa74..a98622100ff4d 100644
--- a/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
+++ b/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
@@ -2,6 +2,6 @@ LEVEL = ../../../make
C_SOURCES := test.c
-CFLAGS_EXTRAS += -O1
+CFLAGS_EXTRAS += -O1 -D_FORTIFY_SOURCE=0
include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
index 6595e33b72697..bea4bf96e601e 100644
--- a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
+++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
@@ -13,10 +13,10 @@ endif
all: limit nolimit
limit: main.o length_limit.o a.o
- $(CXX) $(LDFLAGS) main.o length_limit.o a.o -o limit
+ $(CXX) main.o length_limit.o a.o -o limit $(LDFLAGS)
nolimit: main.o length_nolimit.o a.o
- $(CXX) $(LDFLAGS) main.o length_nolimit.o a.o -o nolimit
+ $(CXX) main.o length_nolimit.o a.o -o nolimit $(LDFLAGS)
main.o: main.cpp
$(CXX) $(CFLAGS_LIMIT) main.cpp -o main.o