diff options
author | dim <dim@FreeBSD.org> | 2016-01-06 20:12:03 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-01-06 20:12:03 +0000 |
commit | 78b9749c0a4ea980a8b934645da6ae98fcc665e8 (patch) | |
tree | dd2a1ddf0476664c2b823409c36cbccd52662ca7 /packages/Python/lldbsuite/test/tools/lldb-mi/symbol | |
parent | 60cb593f9d55fa5ca7a5372b731f2330345b4b9a (diff) | |
download | FreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.zip FreeBSD-src-78b9749c0a4ea980a8b934645da6ae98fcc665e8.tar.gz |
Vendor import of lldb trunk r256945:
https://llvm.org/svn/llvm-project/lldb/trunk@256945
Diffstat (limited to 'packages/Python/lldbsuite/test/tools/lldb-mi/symbol')
6 files changed, 205 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile new file mode 100644 index 0000000..dde38f4 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp symbol_list_lines_inline_test.cpp symbol_list_lines_inline_test2.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py new file mode 100644 index 0000000..3566b2f --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py @@ -0,0 +1,81 @@ +""" +Test lldb-mi -symbol-xxx commands. +""" + +from __future__ import print_function + + + +import lldbmi_testcase +from lldbsuite.test.lldbtest import * + +class MiSymbolTestCase(lldbmi_testcase.MiTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @expectedFailureLinux # new failure after r256863 + def test_lldbmi_symbol_list_lines_file(self): + """Test that 'lldb-mi --interpreter' works for -symbol-list-lines when file exists.""" + + self.spawnLldbMi(args = None) + + # Load executable + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + self.expect("\^done") + + # Run to main + self.runCmd("-break-insert -f main") + self.expect("\^done,bkpt={number=\"1\"") + self.runCmd("-exec-run") + self.expect("\^running") + self.expect("\*stopped,reason=\"breakpoint-hit\"") + + # Get address of main and its line + self.runCmd("-data-evaluate-expression main") + self.expect("\^done,value=\"0x[0-9a-f]+ \(a.out`main at main.cpp:[0-9]+\)\"") + addr = int(self.child.after.split("\"")[1].split(" ")[0], 16) + line = line_number('main.cpp', '// FUNC_main') + + # Test that -symbol-list-lines works on valid data + self.runCmd("-symbol-list-lines main.cpp") + self.expect("\^done,lines=\[\{pc=\"0x0*%x\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d+\"\})+\]" % (addr, line)) + + # Test that -symbol-list-lines doesn't include lines from other sources + # by checking the first and last line, and making sure the other lines + # are between 30 and 39. + sline = line_number('symbol_list_lines_inline_test2.cpp', '// FUNC_gfunc2') + eline = line_number('symbol_list_lines_inline_test2.cpp', '// END_gfunc2') + self.runCmd("-symbol-list-lines symbol_list_lines_inline_test2.cpp") + self.expect("\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*\]" % (sline, eline)) + ##FIXME: This doesn't work for symbol_list_lines_inline_test.cpp due to clang bug llvm.org/pr24716 (fixed in newer versions of clang) + ##sline = line_number('symbol_list_lines_inline_test.cpp', '// FUNC_gfunc') + ##eline = line_number('symbol_list_lines_inline_test.cpp', '// STRUCT_s') + ##self.runCmd("-symbol-list-lines symbol_list_lines_inline_test.cpp") + ##self.expect("\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}\]" % (sline, eline)) + + # Test that -symbol-list-lines works on header files by checking the first + # and last line, and making sure the other lines are under 29. + sline = line_number('symbol_list_lines_inline_test.h', '// FUNC_ifunc') + eline = line_number('symbol_list_lines_inline_test.h', '// FUNC_mfunc') + self.runCmd("-symbol-list-lines symbol_list_lines_inline_test.h") + self.expect("\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d\"\})*(,\{pc=\"0x[0-9a-f]+\",line=\"1\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"2\d\"\})*\]" % (sline, eline)) + + # Test that -symbol-list-lines fails when file doesn't exist + self.runCmd("-symbol-list-lines unknown_file") + self.expect("\^error,message=\"error: No source filenames matched 'unknown_file'\. \"") + + # Test that -symbol-list-lines fails when file is specified using relative path + self.runCmd("-symbol-list-lines ./main.cpp") + self.expect("\^error,message=\"error: No source filenames matched '\./main\.cpp'\. \"") + + # Test that -symbol-list-lines works when file is specified using absolute path + import os + path = os.path.join(os.getcwd(), "main.cpp") + self.runCmd("-symbol-list-lines \"%s\"" % path) + self.expect("\^done,lines=\[\{pc=\"0x0*%x\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d+\"\})+\]" % (addr, line)) + + # Test that -symbol-list-lines fails when file doesn't exist + self.runCmd("-symbol-list-lines unknown_dir/main.cpp") + self.expect("\^error,message=\"error: No source filenames matched 'unknown_dir/main\.cpp'\. \"") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp new file mode 100644 index 0000000..6d725a5 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp @@ -0,0 +1,18 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +extern int j; +extern int gfunc(int i); +extern int gfunc2(int i); +int +main() +{ // FUNC_main + int i = gfunc(j) + gfunc2(j); + return i == 0; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp new file mode 100644 index 0000000..c432ba8 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp @@ -0,0 +1,39 @@ +// Skip lines so we can make sure we're not seeing any lines from +// symbol_list_lines_inline_test.h included in -symbol-list-lines +// symbol_list_lines_inline_test.cpp, by checking that all the lines +// are between 30 and 39. +// line 5 +// line 6 +// line 7 +// line 8 +// line 9 +// line 10 +// line 11 +// line 12 +// line 13 +// line 14 +// line 15 +// line 16 +// line 17 +// line 18 +// line 19 +// line 20 +// line 21 +// line 22 +// line 23 +// line 24 +// line 25 +// line 26 +// line 27 +// line 28 +// line 29 +#include "symbol_list_lines_inline_test.h" +int +gfunc(int i) +{ // FUNC_gfunc + return ns::ifunc(i); +} +namespace ns +{ +S s; // STRUCT_s +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h new file mode 100644 index 0000000..4b986dc --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h @@ -0,0 +1,24 @@ +namespace ns +{ +inline int +ifunc(int i) +{ // FUNC_ifunc + return i; +} +struct S +{ + int a; + int b; + S() + : a(3) + , b(4) + { + } + int + mfunc() + { // FUNC_mfunc + return a + b; + } +}; +extern S s; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp new file mode 100644 index 0000000..cfedf47 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp @@ -0,0 +1,38 @@ +// Skip lines so we can make sure we're not seeing any lines from +// symbol_list_lines_inline_test.h included in -symbol-list-lines +// symbol_list_lines_inline_test2.cpp, by checking that all the lines +// are between 30 and 39. +// line 5 +// line 6 +// line 7 +// line 8 +// line 9 +// line 10 +// line 11 +// line 12 +// line 13 +// line 14 +// line 15 +// line 16 +// line 17 +// line 18 +// line 19 +// line 20 +// line 21 +// line 22 +// line 23 +// line 24 +// line 25 +// line 26 +// line 27 +// line 28 +// line 29 +#include "symbol_list_lines_inline_test.h" +int j = 2; +int +gfunc2(int i) +{ // FUNC_gfunc2 + i += ns::s.mfunc(); + i += ns::ifunc(i); + return i == 0; // END_gfunc2 +} |