diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-24 01:01:00 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-24 01:01:00 +0000 |
commit | 23629167fefb8117a4d2cc9213c8a29d5b4a1197 (patch) | |
tree | c410512ef1b5e0f0e81b7f333cafabc3ad716f5d /packages/Python | |
parent | ef5d0b5e97ec8e6fa395d377b09aa7755e345b4f (diff) |
Notes
Diffstat (limited to 'packages/Python')
9 files changed, 129 insertions, 20 deletions
diff --git a/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py b/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py index a6c0c050c4681..4fc2463b25a8b 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py +++ b/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py @@ -42,7 +42,7 @@ class Radar9673644TestCase(TestBase): # rdar://problem/9673664 lldb expression evaluation problem - self.expect('expr char c[] = "foo"; c[0]', + self.expect('expr char str[] = "foo"; str[0]', substrs=["'f'"]) # runCmd: expr char c[] = "foo"; c[0] # output: (char) $0 = 'f' diff --git a/packages/Python/lldbsuite/test/expression_command/top-level/test.cpp b/packages/Python/lldbsuite/test/expression_command/top-level/test.cpp index ce2ea3bbb1318..5a978743596a2 100644 --- a/packages/Python/lldbsuite/test/expression_command/top-level/test.cpp +++ b/packages/Python/lldbsuite/test/expression_command/top-level/test.cpp @@ -42,11 +42,11 @@ public: int i; } s = { 15 }; - int as[4] = { 2, 3, 4, 5 }; + int numbers[4] = { 2, 3, 4, 5 }; - for (signed char a : as) + for (signed char number: numbers) { - s.i -= a; + s.i -= number; } return s.i; @@ -94,14 +94,14 @@ public: int doTest() { - int a = m.memberResult(); - a += MyClass::staticResult(); - a += m.externResult(); - a += MyEnum::myEnumThree; - a += myEnumOne; - a += AnotherClass().complicatedFunction(); - a += DiamondD(3).accessor(); - return a; + int accumulator = m.memberResult(); + accumulator += MyClass::staticResult(); + accumulator += m.externResult(); + accumulator += MyEnum::myEnumThree; + accumulator += myEnumOne; + accumulator += AnotherClass().complicatedFunction(); + accumulator += DiamondD(3).accessor(); + return accumulator; } // -- diff --git a/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py b/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py index 965af3e4910a1..550eae85e1d6d 100644 --- a/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py +++ b/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py @@ -29,12 +29,14 @@ class ExecTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipUnlessDarwin + @expectedFailureAll(oslist=['macosx'], bugnumber="rdar://36134350") # when building with cmake on green gragon or on ci.swift.org, this test fails. @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532") @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems def test_hitting_exec (self): self.do_test(False) @skipUnlessDarwin + @expectedFailureAll(oslist=['macosx'], bugnumber="rdar://36134350") # when building with cmake on green gragon or on ci.swift.org, this test fails. @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532") @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems def test_skipping_exec (self): diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py index 178bb678df7c0..4e587b92c1d26 100644 --- a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py @@ -117,7 +117,7 @@ class MiniDumpNewTestCase(TestBase): thread = self.process.GetThreadAtIndex(0) self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone) stop_description = thread.GetStopDescription(256) - self.assertEqual(stop_description, None) + self.assertEqual(stop_description, "") def do_test_deeper_stack(self, binary, core, pid): target = self.dbg.CreateTarget(binary) diff --git a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py index d3327700bfd20..328c383b38fb0 100644 --- a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py +++ b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py @@ -16,6 +16,13 @@ class TestConflictingSymbols(TestBase): mydir = TestBase.compute_mydir(__file__) NO_DEBUG_INFO_TESTCASE = True + def setUp(self): + TestBase.setUp(self) + + self.One_line = line_number('One/One.c', '// break here') + self.Two_line = line_number('Two/Two.c', '// break here') + self.main_line = line_number('main.c', '// break here') + def test_conflicting_symbols(self): self.build() exe = os.path.join(os.getcwd(), "a.out") @@ -27,15 +34,12 @@ class TestConflictingSymbols(TestBase): environment = self.registerSharedLibrariesWithTarget( target, ['One', 'Two']) - One_line = line_number('One/One.c', '// break here') - Two_line = line_number('Two/Two.c', '// break here') - main_line = line_number('main.c', '// break here') lldbutil.run_break_set_command( - self, 'breakpoint set -f One.c -l %s' % (One_line)) + self, 'breakpoint set -f One.c -l %s' % (self.One_line)) lldbutil.run_break_set_command( - self, 'breakpoint set -f Two.c -l %s' % (Two_line)) + self, 'breakpoint set -f Two.c -l %s' % (self.Two_line)) lldbutil.run_break_set_by_file_and_line( - self, 'main.c', main_line, num_expected_locations=1, loc_exact=True) + self, 'main.c', self.main_line, num_expected_locations=1, loc_exact=True) process = target.LaunchSimple( None, environment, self.get_process_working_directory()) @@ -88,3 +92,32 @@ class TestConflictingSymbols(TestBase): error=True, substrs=[ "Multiple internal symbols"]) + + @expectedFailureAll(bugnumber="llvm.org/pr35043") + def test_shadowed(self): + self.build() + exe = os.path.join(os.getcwd(), "a.out") + target = self.dbg.CreateTarget("a.out") + self.assertTrue(target, VALID_TARGET) + + # Register our shared libraries for remote targets so they get + # automatically uploaded + environment = self.registerSharedLibrariesWithTarget( + target, ['One', 'Two']) + + lldbutil.run_break_set_by_file_and_line(self, 'main.c', self.main_line) + + process = target.LaunchSimple( + None, environment, self.get_process_working_directory()) + self.assertTrue(process, PROCESS_IS_VALID) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs=['stopped', + 'stop reason = breakpoint']) + + # As we are shadowing the conflicting symbol, there should be no + # ambiguity in this expression. + self.expect( + "expr int conflicting_symbol = 474747; conflicting_symbol", + substrs=[ "474747"]) diff --git a/packages/Python/lldbsuite/test/lang/cpp/lambdas/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/lambdas/main.cpp index 3cce3baf2924c..0432cc1357da3 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/lambdas/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/lambdas/main.cpp @@ -11,7 +11,7 @@ int main (int argc, char const *argv[]) { - printf("Stop here\n"); //% self.runCmd("expression auto $add = [](int a, int b) { return a + b; }") + printf("Stop here\n"); //% self.runCmd("expression auto $add = [](int first, int second) { return first + second; }") //% self.expect("expression $add(2,3)", substrs = ['= 5']) return 0; } diff --git a/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/Makefile b/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/Makefile new file mode 100644 index 0000000000000..f3414925f32bc --- /dev/null +++ b/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +C_SOURCES := main.c +EXE := read-mem-cstring + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py b/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py new file mode 100644 index 0000000000000..6302711606c51 --- /dev/null +++ b/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py @@ -0,0 +1,57 @@ +"""Test reading c-strings from memory via SB API.""" + +from __future__ import print_function + +import os +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestReadMemCString(TestBase): + + mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True + + def test_read_memory_c_string(self): + """Test corner case behavior of SBProcess::ReadCStringFromMemory""" + self.build() + self.dbg.SetAsync(False) + + self.main_source = "main.c" + self.main_source_spec = lldb.SBFileSpec(self.main_source) + self.exe = os.path.join(os.getcwd(), "read-mem-cstring") + + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( + self, 'breakpoint here', self.main_source_spec, None, self.exe) + + frame = thread.GetFrameAtIndex(0) + + err = lldb.SBError() + + empty_str_addr = frame.FindVariable("empty_string").GetValueAsUnsigned(err) + self.assertTrue(err.Success()) + self.assertTrue(empty_str_addr != lldb.LLDB_INVALID_ADDRESS) + + one_letter_str_addr = frame.FindVariable("one_letter_string").GetValueAsUnsigned(err) + self.assertTrue(err.Success()) + self.assertTrue(one_letter_str_addr != lldb.LLDB_INVALID_ADDRESS) + + invalid_memory_str_addr = frame.FindVariable("invalid_memory_string").GetValueAsUnsigned(err) + self.assertTrue(err.Success()) + self.assertTrue(invalid_memory_str_addr != lldb.LLDB_INVALID_ADDRESS) + + # Important: An empty (0-length) c-string must come back as a Python string, not a + # None object. + empty_str = process.ReadCStringFromMemory(empty_str_addr, 2048, err) + self.assertTrue(err.Success()) + self.assertTrue(empty_str == "") + + one_letter_string = process.ReadCStringFromMemory(one_letter_str_addr, 2048, err) + self.assertTrue(err.Success()) + self.assertTrue(one_letter_string == "1") + + invalid_memory_string = process.ReadCStringFromMemory(invalid_memory_str_addr, 2048, err) + self.assertTrue(err.Fail()) + self.assertTrue(invalid_memory_string == "" or invalid_memory_string == None) diff --git a/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/main.c b/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/main.c new file mode 100644 index 0000000000000..03c6674171298 --- /dev/null +++ b/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/main.c @@ -0,0 +1,11 @@ +#include <stdlib.h> +int main () +{ + const char *empty_string = ""; + const char *one_letter_string = "1"; + // This expects that lower 4k of memory will be mapped unreadable, which most + // OSs do (to catch null pointer dereferences). + const char *invalid_memory_string = (char*)0x100; + + return empty_string[0] + one_letter_string[0]; // breakpoint here +} |