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/functionalities/set-data | |
| 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/functionalities/set-data')
3 files changed, 88 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/set-data/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/set-data/Makefile new file mode 100644 index 00000000000..9e1d63a183b --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/set-data/Makefile @@ -0,0 +1,7 @@ +LEVEL = ../../make + +OBJC_SOURCES := main.m + +include $(LEVEL)/Makefile.rules + +LDFLAGS += -framework Foundation diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py b/lldb/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py new file mode 100644 index 00000000000..720dae003e4 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py @@ -0,0 +1,62 @@ +""" +Set the contents of variables and registers using raw data +""" + +from __future__ import print_function + +import use_lldb_suite + +import os, time +import lldb +from lldbtest import * +import lldbutil + +class SetDataTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessDarwin + def test_set_data(self): + """Test setting the contents of variables and registers using raw data.""" + self.build() + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + self.runCmd("br s -p First"); + self.runCmd("br s -p Second"); + + self.runCmd("run", RUN_SUCCEEDED) + + self.expect("p myFoo.x", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['2']) + + process = self.dbg.GetSelectedTarget().GetProcess() + frame = process.GetSelectedThread().GetFrameAtIndex(0) + + x = frame.FindVariable("myFoo").GetChildMemberWithName("x") + + my_data = lldb.SBData.CreateDataFromSInt32Array(lldb.eByteOrderLittle, 8, [4]) + err = lldb.SBError() + + self.assertTrue (x.SetData(my_data, err)) + + self.runCmd("continue") + + self.expect("p myFoo.x", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['4']) + + frame = process.GetSelectedThread().GetFrameAtIndex(0) + + x = frame.FindVariable("string") + + if process.GetAddressByteSize() == 8: + my_data = lldb.SBData.CreateDataFromUInt64Array(process.GetByteOrder(), 8, [0]) + else: + my_data = lldb.SBData.CreateDataFromUInt32Array(process.GetByteOrder(), 4, [0]) + + err = lldb.SBError() + + self.assertTrue (x.SetData(my_data, err)) + + self.expect("fr var -d run-target string", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['NSString *', 'nil']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/set-data/main.m b/lldb/packages/Python/lldbsuite/test/functionalities/set-data/main.m new file mode 100644 index 00000000000..e1e69dc5571 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/set-data/main.m @@ -0,0 +1,19 @@ +#import <Foundation/Foundation.h> + +int main () +{ + @autoreleasepool + { + struct foo { + int x; + int y; + } myFoo; + + myFoo.x = 2; + myFoo.y = 3; // First breakpoint + + NSString *string = [NSString stringWithFormat:@"%s", "Hello world!"]; + + NSLog(@"%d %@", myFoo.x, string); // Second breakpoint + } +} |

