diff options
| author | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
| commit | c432c8f856e0bd84de980a9d9bb2d31b06fa95b1 (patch) | |
| tree | 4efa528e074a6e2df782345e4cd97f5d85d038c4 /lldb/packages/Python/lldbsuite/test/expression_command/two-files | |
| parent | a8a3bd210086b50242903ed95048fe5e53897878 (diff) | |
| download | bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.tar.gz bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.zip | |
Move lldb/test to lldb/packages/Python/lldbsuite/test.
This is the conclusion of an effort to get LLDB's Python code
structured into a bona-fide Python package. This has a number
of benefits, but most notably the ability to more easily share
Python code between different but related pieces of LLDB's Python
infrastructure (for example, `scripts` can now share code with
`test`).
llvm-svn: 251532
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/expression_command/two-files')
4 files changed, 96 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/two-files/Makefile b/lldb/packages/Python/lldbsuite/test/expression_command/two-files/Makefile new file mode 100644 index 00000000000..5974461e256 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/two-files/Makefile @@ -0,0 +1,7 @@ +LEVEL = ../../make + +OBJC_SOURCES := main.m foo.m + +include $(LEVEL)/Makefile.rules + +LDFLAGS += -framework Foundation
\ No newline at end of file diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py b/lldb/packages/Python/lldbsuite/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py new file mode 100644 index 00000000000..7e67b334e4d --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py @@ -0,0 +1,39 @@ +""" +Regression test for <rdar://problem/8981098>: + +The expression parser's type search only looks in the current compilation unit for types. +""" + +from __future__ import print_function + +import use_lldb_suite + +import lldb +from lldbtest import * +import lldbutil + +class ObjCTypeQueryTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break for main.m. + self.line = line_number('main.m', + "// Set breakpoint here, then do 'expr (NSArray*)array_token'.") + + @skipUnlessDarwin + def test(self): + """The expression parser's type search should be wider than the current compilation unit.""" + self.build() + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + # Now do a NSArry type query from the 'main.m' compile uint. + self.expect("expression (NSArray*)array_token", + substrs = ['(NSArray *) $0 = 0x']) + # (NSArray *) $0 = 0x00007fff70118398 diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/two-files/foo.m b/lldb/packages/Python/lldbsuite/test/expression_command/two-files/foo.m new file mode 100644 index 00000000000..1609ebd838f --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/two-files/foo.m @@ -0,0 +1,28 @@ +#import <Foundation/Foundation.h> + +NSMutableArray * +GetArray () +{ + static NSMutableArray *the_array = NULL; + if (the_array == NULL) + the_array = [[NSMutableArray alloc] init]; + return the_array; +} + +int +AddElement (char *value) +{ + NSString *element = [NSString stringWithUTF8String: value]; + int cur_elem = [GetArray() count]; + [GetArray() addObject: element]; + return cur_elem; +} + +const char * +GetElement (int idx) +{ + if (idx >= [GetArray() count]) + return NULL; + else + return [[GetArray() objectAtIndex: idx] UTF8String]; +} diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/two-files/main.m b/lldb/packages/Python/lldbsuite/test/expression_command/two-files/main.m new file mode 100644 index 00000000000..3f5738314e6 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/two-files/main.m @@ -0,0 +1,22 @@ +#import <Foundation/Foundation.h> +#include <stdio.h> + +extern int AddElement (char *value); +extern char *GetElement (int idx); +extern void *GetArray(); + +int +main () +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + int idx = AddElement ("some string"); + void *array_token = GetArray(); + + char *string = GetElement (0); // Set breakpoint here, then do 'expr (NSArray*)array_token'. + if (string) + printf ("This: %s.\n", string); + + [pool release]; + return 0; +} |

