diff options
| author | Bill Wendling <isanbard@gmail.com> | 2012-04-18 21:39:23 +0000 |
|---|---|---|
| committer | Bill Wendling <isanbard@gmail.com> | 2012-04-18 21:39:23 +0000 |
| commit | 392e4fbdd9b152efff4c051286f6b2c21270c902 (patch) | |
| tree | 4ac339be2c4c7c596f068b59d5e512b157c7b433 /lldb/test/lang/cpp | |
| parent | eb1c2bdc1f55fbc5d1e7bb86e9f0e038b0f5adb7 (diff) | |
Creating release_31 branchllvmorg-3.1.0-rc1
llvm-svn: 155059
llvm-svn: 155053
llvm-svn: 155051
Diffstat (limited to 'lldb/test/lang/cpp')
46 files changed, 0 insertions, 2781 deletions
diff --git a/lldb/test/lang/cpp/breakpoints/Makefile b/lldb/test/lang/cpp/breakpoints/Makefile deleted file mode 100644 index 1d1f38f7fd0e..000000000000 --- a/lldb/test/lang/cpp/breakpoints/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := nested.cpp - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/breakpoints/TestCPPBreakpoints.py b/lldb/test/lang/cpp/breakpoints/TestCPPBreakpoints.py deleted file mode 100644 index 367d75de8111..000000000000 --- a/lldb/test/lang/cpp/breakpoints/TestCPPBreakpoints.py +++ /dev/null @@ -1,104 +0,0 @@ -""" -Test lldb breakpoint command for CPP methods & functions in a namespace. -""" - -import os, time -import unittest2 -import lldb -from lldbtest import * - -class CPPBreakpointTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "breakpoints") - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @dsym_test - def test_with_dsym(self): - """Test a sequence of breakpoint command add, list, and delete.""" - self.buildDsym() - self.cpp_breakpoints() - - @dwarf_test - def test_with_dwarf(self): - """Test a sequence of breakpoint command add, list, and delete.""" - self.buildDwarf() - self.cpp_breakpoints() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - - def cpp_breakpoints (self): - """Test a sequence of breakpoint command add, list, and delete.""" - exe = os.path.join(os.getcwd(), "a.out") - - # Create a target from the debugger. - - target = self.dbg.CreateTarget (exe) - self.assertTrue(target, VALID_TARGET) - - a_out_module = lldb.SBFileSpecList() - a_out_module.Append(lldb.SBFileSpec(exe)) - - nested_comp_unit = lldb.SBFileSpecList() - nested_comp_unit.Append (lldb.SBFileSpec("nested.cpp")) - - # First provide ONLY the method name. This should get everybody... - auto_break = target.BreakpointCreateByName ("Function", - lldb.eFunctionNameTypeAuto, - a_out_module, - nested_comp_unit) - self.assertTrue (auto_break.GetNumLocations() == 5) - - # Now add the Baz class specifier. This should get the version contained in Bar, - # AND the one contained in :: - auto_break = target.BreakpointCreateByName ("Baz::Function", - lldb.eFunctionNameTypeAuto, - a_out_module, - nested_comp_unit) - self.assertTrue (auto_break.GetNumLocations() == 2) - - # Then add the Bar::Baz specifier. This should get the version contained in Bar only - auto_break = target.BreakpointCreateByName ("Bar::Baz::Function", - lldb.eFunctionNameTypeAuto, - a_out_module, - nested_comp_unit) - self.assertTrue (auto_break.GetNumLocations() == 1) - - plain_method_break = target.BreakpointCreateByName ("Function", - lldb.eFunctionNameTypeMethod, - a_out_module, - nested_comp_unit) - self.assertTrue (plain_method_break.GetNumLocations() == 3) - - plain_method_break = target.BreakpointCreateByName ("Baz::Function", - lldb.eFunctionNameTypeMethod, - a_out_module, - nested_comp_unit) - self.assertTrue (plain_method_break.GetNumLocations() == 2) - - plain_method_break = target.BreakpointCreateByName ("Bar::Baz::Function", - lldb.eFunctionNameTypeMethod, - a_out_module, - nested_comp_unit) - self.assertTrue (plain_method_break.GetNumLocations() == 1) - - plain_method_break = target.BreakpointCreateByName ("Function", - lldb.eFunctionNameTypeBase, - a_out_module, - nested_comp_unit) - self.assertTrue (plain_method_break.GetNumLocations() == 2) - - plain_method_break = target.BreakpointCreateByName ("Bar::Function", - lldb.eFunctionNameTypeBase, - a_out_module, - nested_comp_unit) - self.assertTrue (plain_method_break.GetNumLocations() == 1) - - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/breakpoints/nested.cpp b/lldb/test/lang/cpp/breakpoints/nested.cpp deleted file mode 100644 index 29d4b4cb19e7..000000000000 --- a/lldb/test/lang/cpp/breakpoints/nested.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include <stdio.h> - -namespace Foo -{ - namespace Bar - { - class Baz - { - public: - Baz (int value):m_value(value) {} - int Function () - { - printf ("%s returning: %d.\n", __FUNCTION__, m_value); - return m_value; - } - private: - int m_value; - }; - - class Baz2 - { - public: - Baz2 (int value):m_value(value) {} - int Function () - { - printf ("%s returning: %d.\n", __FUNCTION__, m_value); - return m_value; - } - private: - int m_value; - }; - - static int bar_value = 20; - int Function () - { - printf ("%s returning: %d.\n", __FUNCTION__, bar_value); - return bar_value; - } - } -} - -class Baz -{ -public: - Baz (int value):m_value(value) {} - int Function () - { - printf ("%s returning: %d.\n", __FUNCTION__, m_value); - return m_value; - } -private: - int m_value; -}; - -int -Function () -{ - printf ("I am a global function, I return 333.\n"); - return 333; -} - -int main () -{ - Foo::Bar::Baz mine(200); - Foo::Bar::Baz2 mine2(300); - ::Baz bare_baz (500); - - printf ("Yup, got %d from Baz.\n", mine.Function()); - printf ("Yup, got %d from Baz.\n", mine2.Function()); - printf ("Yup, got %d from Baz.\n", bare_baz.Function()); - printf ("And got %d from Bar.\n", Foo::Bar::Function()); - printf ("And got %d from ::.\n", ::Function()); - - return 0; - -} diff --git a/lldb/test/lang/cpp/class_static/Makefile b/lldb/test/lang/cpp/class_static/Makefile deleted file mode 100644 index 314f1cb2f077..000000000000 --- a/lldb/test/lang/cpp/class_static/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/class_static/TestStaticVariables.py b/lldb/test/lang/cpp/class_static/TestStaticVariables.py deleted file mode 100644 index e995bf636c38..000000000000 --- a/lldb/test/lang/cpp/class_static/TestStaticVariables.py +++ /dev/null @@ -1,150 +0,0 @@ -""" -Test display and Python APIs on file and class static variables. -""" - -import os, time -import unittest2 -import lldb -from lldbtest import * - -class StaticVariableTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "class_static") - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @dsym_test - def test_with_dsym_and_run_command(self): - """Test that file and class static variables display correctly.""" - self.buildDsym() - self.static_variable_commands() - - @dwarf_test - def test_with_dwarf_and_run_command(self): - """Test that file and class static variables display correctly.""" - self.buildDwarf() - self.static_variable_commands() - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - #rdar://problem/9980907 - @expectedFailureClang - @python_api_test - @dsym_test - def test_with_dsym_and_python_api(self): - """Test Python APIs on file and class static variables.""" - self.buildDsym() - self.static_variable_python() - - #rdar://problem/9980907 - @expectedFailureClang - @python_api_test - @dwarf_test - def test_with_dwarf_and_python_api(self): - """Test Python APIs on file and class static variables.""" - self.buildDwarf() - self.static_variable_python() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to break at. - self.line = line_number('main.cpp', '// Set break point at this line.') - - def static_variable_commands(self): - """Test that that file and class static variables display correctly.""" - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - self.expect("breakpoint set -f main.cpp -l %d" % self.line, - BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" % - self.line) - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - - # global variables are no longer displayed with the "frame variable" command. - self.expect('target variable A::g_points', VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['(PointType [2]) A::g_points']) - self.expect('target variable g_points', VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['(PointType [2]) g_points']) - - # On Mac OS X, gcc 4.2 emits the wrong debug info for A::g_points. - # A::g_points is an array of two elements. - if sys.platform.startswith("darwin") and self.getCompiler() in ['clang', 'llvm-gcc']: - self.expect("target variable A::g_points[1].x", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "(int) A::g_points[1].x = 11") - - def static_variable_python(self): - """Test Python APIs on file and class static variables.""" - exe = os.path.join(os.getcwd(), "a.out") - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line) - self.assertTrue(breakpoint, VALID_BREAKPOINT) - - # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple(None, None, os.getcwd()) - self.assertTrue(process, PROCESS_IS_VALID) - - # The stop reason of the thread should be breakpoint. - thread = process.GetThreadAtIndex(0) - if thread.GetStopReason() != lldb.eStopReasonBreakpoint: - from lldbutil import stop_reason_to_str - self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % - stop_reason_to_str(thread.GetStopReason())) - - # Get the SBValue of 'A::g_points' and 'g_points'. - frame = thread.GetFrameAtIndex(0) - - # arguments => False - # locals => False - # statics => True - # in_scope_only => False - valList = frame.GetVariables(False, False, True, False) - - for val in valList: - self.DebugSBValue(val) - self.assertTrue(val.GetValueType() == lldb.eValueTypeVariableGlobal) - name = val.GetName() - self.assertTrue(name in ['g_points', 'A::g_points']) - if name == 'g_points': - self.assertTrue(val.GetNumChildren() == 2) - elif name == 'A::g_points' and self.getCompiler() in ['clang', 'llvm-gcc']: - # On Mac OS X, gcc 4.2 emits the wrong debug info for A::g_points. - self.assertTrue(val.GetNumChildren() == 2) - child1 = val.GetChildAtIndex(1) - self.DebugSBValue(child1) - child1_x = child1.GetChildAtIndex(0) - self.DebugSBValue(child1_x) - self.assertTrue(child1_x.GetTypeName() == 'int' and - child1_x.GetValue() == '11') - - # SBFrame.FindValue() should also work. - val = frame.FindValue("A::g_points", lldb.eValueTypeVariableGlobal) - self.DebugSBValue(val) - self.assertTrue(val.GetName() == 'A::g_points') - - # Also exercise the "parameter" and "local" scopes while we are at it. - val = frame.FindValue("argc", lldb.eValueTypeVariableArgument) - self.DebugSBValue(val) - self.assertTrue(val.GetName() == 'argc') - - val = frame.FindValue("argv", lldb.eValueTypeVariableArgument) - self.DebugSBValue(val) - self.assertTrue(val.GetName() == 'argv') - - val = frame.FindValue("hello_world", lldb.eValueTypeVariableLocal) - self.DebugSBValue(val) - self.assertTrue(val.GetName() == 'hello_world') - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/class_static/main.cpp b/lldb/test/lang/cpp/class_static/main.cpp deleted file mode 100644 index 2068eadcac5f..000000000000 --- a/lldb/test/lang/cpp/class_static/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// I made this example after noting that I was unable to display an unsized -// static class array. It turns out that gcc 4.2 will emit DWARF that correctly -// describes the PointType, but it will incorrectly emit debug info for the -// "g_points" array where the following things are wrong: -// - the DW_TAG_array_type won't have a subrange info -// - the DW_TAG_variable for "g_points" won't have a valid byte size, so even -// though we know the size of PointType, we can't infer the actual size -// of the array by dividing the size of the variable by the number of -// elements. - -#include <stdio.h> - -typedef struct PointType -{ - int x, y; -} PointType; - -class A -{ -public: - static PointType g_points[]; -}; - -PointType A::g_points[] = -{ - { 1, 2 }, - { 11, 22 } -}; - -static PointType g_points[] = -{ - { 3, 4 }, - { 33, 44 } -}; - -int -main (int argc, char const *argv[]) -{ - const char *hello_world = "Hello, world!"; - printf ("A::g_points[1].x = %i\n", A::g_points[1].x); // Set break point at this line. - printf ("::g_points[1].x = %i\n", g_points[1].x); - printf ("%s\n", hello_world); - return 0; -} diff --git a/lldb/test/lang/cpp/class_types/Makefile b/lldb/test/lang/cpp/class_types/Makefile deleted file mode 100644 index 314f1cb2f077..000000000000 --- a/lldb/test/lang/cpp/class_types/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/class_types/TestClassTypes.py b/lldb/test/lang/cpp/class_types/TestClassTypes.py deleted file mode 100644 index fca19bce6d45..000000000000 --- a/lldb/test/lang/cpp/class_types/TestClassTypes.py +++ /dev/null @@ -1,216 +0,0 @@ -"""Test breakpoint on a class constructor; and variable list the this object.""" - -import os, time -import unittest2 -import lldb -import lldbutil -from lldbtest import * - -class ClassTypesTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "class_types") - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @dsym_test - def test_with_dsym_and_run_command(self): - """Test 'frame variable this' when stopped on a class constructor.""" - self.buildDsym() - self.class_types() - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @python_api_test - @dsym_test - def test_with_dsym_and_python_api(self): - """Use Python APIs to create a breakpoint by (filespec, line).""" - self.buildDsym() - self.breakpoint_creation_by_filespec_python() - - # rdar://problem/8378863 - # "frame variable this" returns - # error: unable to find any variables named 'this' - @dwarf_test - def test_with_dwarf_and_run_command(self): - """Test 'frame variable this' when stopped on a class constructor.""" - self.buildDwarf() - self.class_types() - - @python_api_test - @dwarf_test - def test_with_dwarf_and_python_api(self): - """Use Python APIs to create a breakpoint by (filespec, line).""" - self.buildDwarf() - self.breakpoint_creation_by_filespec_python() - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - # rdar://problem/8557478 - # test/class_types test failures: runCmd: expr this->m_c_int - @dsym_test - def test_with_dsym_and_expr_parser(self): - """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" - self.buildDsym() - self.class_types_expr_parser() - - # rdar://problem/8557478 - # test/class_types test failures: runCmd: expr this->m_c_int - @dwarf_test - def test_with_dwarf_and_expr_parser(self): - """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" - self.buildDwarf() - self.class_types_expr_parser() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to break for main.cpp. - self.line = line_number('main.cpp', '// Set break point at this line.') - - def class_types(self): - """Test 'frame variable this' when stopped on a class constructor.""" - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # Break on the ctor function of class C. - self.expect("breakpoint set -f main.cpp -l %d" % self.line, - BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = %d" % - self.line) - - self.runCmd("run", RUN_SUCCEEDED) - - # The test suite sometimes shows that the process has exited without stopping. - # - # CC=clang ./dotest.py -v -t class_types - # ... - # Process 76604 exited with status = 0 (0x00000000) - self.runCmd("process status") - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - - # The breakpoint should have a hit count of 1. - self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) - - # We should be stopped on the ctor function of class C. - self.expect("frame variable -T this", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['C *', - ' this = ']) - - def breakpoint_creation_by_filespec_python(self): - """Use Python APIs to create a breakpoint by (filespec, line).""" - exe = os.path.join(os.getcwd(), "a.out") - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - filespec = target.GetExecutable() - self.assertTrue(filespec, VALID_FILESPEC) - - fsDir = filespec.GetDirectory() - fsFile = filespec.GetFilename() - - self.assertTrue(fsDir == os.getcwd() and fsFile == "a.out", - "FileSpec matches the executable") - - bpfilespec = lldb.SBFileSpec("main.cpp", False) - - breakpoint = target.BreakpointCreateByLocation(bpfilespec, self.line) - self.assertTrue(breakpoint, VALID_BREAKPOINT) - - # Verify the breakpoint just created. - self.expect(str(breakpoint), BREAKPOINT_CREATED, exe=False, - substrs = ['main.cpp', - str(self.line)]) - - # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple(None, None, os.getcwd()) - - if not process: - self.fail("SBTarget.Launch() failed") - - if process.GetState() != lldb.eStateStopped: - self.fail("Process should be in the 'stopped' state, " - "instead the actual state is: '%s'" % - lldbutil.state_type_to_str(process.GetState())) - - # The stop reason of the thread should be breakpoint. - thread = process.GetThreadAtIndex(0) - if thread.GetStopReason() != lldb.eStopReasonBreakpoint: - from lldbutil import stop_reason_to_str - self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % - stop_reason_to_str(thread.GetStopReason())) - - # The filename of frame #0 should be 'main.cpp' and the line number - # should be 93. - self.expect("%s:%d" % (lldbutil.get_filenames(thread)[0], - lldbutil.get_line_numbers(thread)[0]), - "Break correctly at main.cpp:%d" % self.line, exe=False, - startstr = "main.cpp:") - ### clang compiled code reported main.cpp:94? - ### startstr = "main.cpp:93") - - # We should be stopped on the breakpoint with a hit count of 1. - self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) - - process.Continue() - - def class_types_expr_parser(self): - """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # rdar://problem/8516141 - # Is this a case of clang (116.1) generating bad debug info? - # - # Break on the ctor function of class C. - #self.expect("breakpoint set -M C", BREAKPOINT_CREATED, - # startstr = "Breakpoint created: 1: name = 'C'") - - # Make the test case more robust by using line number to break, instead. - self.expect("breakpoint set -l %d" % self.line, BREAKPOINT_CREATED, - startstr = "Breakpoint created") - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - - # The breakpoint should have a hit count of 1. - self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) - - # Continue on inside the ctor() body... - self.runCmd("register read pc") - self.runCmd("thread step-over") - - # Verify that 'frame variable this' gets the data type correct. - self.expect("frame variable this",VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['C *']) - - # Verify that frame variable -T this->m_c_int behaves correctly. - self.runCmd("register read pc") - self.runCmd("expr m_c_int") - self.expect("frame variable -T this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY, - startstr = '(int) this->m_c_int = 66') - - # Verify that 'expression this' gets the data type correct. - self.expect("expression this", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['C *']) - - # rdar://problem/8430916 - # expr this->m_c_int returns an incorrect value - # - # Verify that expr this->m_c_int behaves correctly. - self.expect("expression this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY, - patterns = ['\(int\) \$[0-9]+ = 66']) - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/class_types/TestClassTypesDisassembly.py b/lldb/test/lang/cpp/class_types/TestClassTypesDisassembly.py deleted file mode 100644 index 6fbd2ad8fbd6..000000000000 --- a/lldb/test/lang/cpp/class_types/TestClassTypesDisassembly.py +++ /dev/null @@ -1,122 +0,0 @@ -""" -Test the lldb disassemble command on each call frame when stopped on C's ctor. -""" - -import os, time -import unittest2 -import lldb -from lldbtest import * - -class IterateFrameAndDisassembleTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "class_types") - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @dsym_test - def test_with_dsym_and_run_command(self): - """Disassemble each call frame when stopped on C's constructor.""" - self.buildDsym() - self.disassemble_call_stack() - - @dwarf_test - def test_with_dwarf_and_run_command(self): - """Disassemble each call frame when stopped on C's constructor.""" - self.buildDwarf() - self.disassemble_call_stack() - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @python_api_test - @dsym_test - def test_with_dsym_and_python_api(self): - """Disassemble each call frame when stopped on C's constructor.""" - self.buildDsym() - self.disassemble_call_stack_python() - - @python_api_test - @dwarf_test - def test_with_dwarf_and_python_api(self): - """Disassemble each call frame when stopped on C's constructor.""" - self.buildDwarf() - self.disassemble_call_stack_python() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to break for main.cpp. - self.line = line_number('main.cpp', '// Set break point at this line.') - - def breakOnCtor(self): - """Setup/run the program so it stops on C's constructor.""" - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # Break on the ctor function of class C. - self.expect("breakpoint set -f main.cpp -l %d" % self.line, - BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = %d" % - self.line) - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - - # We should be stopped on the ctor function of class C. - self.expect("thread backtrace", BACKTRACE_DISPLAYED_CORRECTLY, - substrs = ['C::C']) - - def disassemble_call_stack(self): - """Disassemble each call frame when stopped on C's constructor.""" - self.breakOnCtor() - - raw_output = self.res.GetOutput() - frameRE = re.compile(r""" - ^\s\sframe # heading for the frame info, - .* # wildcard, and - 0x[0-9a-f]{16} # the frame pc, and - \sa.out`(.+) # module`function, and - \s\+\s # the rest ' + ....' - """, re.VERBOSE) - for line in raw_output.split(os.linesep): - match = frameRE.search(line) - if match: - function = match.group(1) - #print "line:", line - #print "function:", function - self.runCmd("disassemble -n '%s'" % function) - - def disassemble_call_stack_python(self): - """Disassemble each call frame when stopped on C's constructor.""" - self.breakOnCtor() - - # Now use the Python API to get at each function on the call stack and - # disassemble it. - target = self.dbg.GetSelectedTarget() - process = target.GetProcess() - thread = process.GetThreadAtIndex(0) - depth = thread.GetNumFrames() - for i in range(depth - 1): - frame = thread.GetFrameAtIndex(i) - function = frame.GetFunction() - # Print the function header. - if self.TraceOn(): - print - print function - if function: - # Get all instructions for this function and print them out. - insts = function.GetInstructions(target) - for inst in insts: - # We could simply do 'print inst' to print out the disassembly. - # But we want to print to stdout only if self.TraceOn() is True. - disasm = str(inst) - if self.TraceOn(): - print disasm - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/class_types/cmds.txt b/lldb/test/lang/cpp/class_types/cmds.txt deleted file mode 100644 index 1c7ef9f1c8ad..000000000000 --- a/lldb/test/lang/cpp/class_types/cmds.txt +++ /dev/null @@ -1,3 +0,0 @@ -b main.cpp:97 -c -var diff --git a/lldb/test/lang/cpp/class_types/main.cpp b/lldb/test/lang/cpp/class_types/main.cpp deleted file mode 100644 index 251e66c3c9f7..000000000000 --- a/lldb/test/lang/cpp/class_types/main.cpp +++ /dev/null @@ -1,126 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -class Conversion -{ -public: - Conversion (int i) : - m_i (i) - {} - - operator bool() - { - return m_i != 0; - } - -private: - int m_i; -}; - -class A -{ -public: - A(int i=0): - m_a_int(i), - m_aa_int(i+1) - { - } - - //virtual - ~A() - { - } - - int - GetInteger() const - { - return m_a_int; - } - void - SetInteger(int i) - { - m_a_int = i; - } - -protected: - int m_a_int; - int m_aa_int; -}; - -class B : public A -{ -public: - B(int ai, int bi) : - A(ai), - m_b_int(bi) - { - } - - //virtual - ~B() - { - } - - int - GetIntegerB() const - { - return m_b_int; - } - void - SetIntegerB(int i) - { - m_b_int = i; - } - -protected: - int m_b_int; -}; - -#include <cstdio> -class C : public B -{ -public: - C(int ai, int bi, int ci) : - B(ai, bi), - m_c_int(ci) - { - printf("Within C::ctor() m_c_int=%d\n", m_c_int); // Set break point at this line. - } - - //virtual - ~C() - { - } - - int - GetIntegerC() const - { - return m_c_int; - } - void - SetIntegerC(int i) - { - m_c_int = i; - } - -protected: - int m_c_int; -}; - -int -main (int argc, char const *argv[]) -{ - A a(12); - B b(22,33); - C c(44,55,66); - Conversion conv(1); - if (conv) - return b.GetIntegerB() - a.GetInteger() + c.GetInteger(); - return 0; -} diff --git a/lldb/test/lang/cpp/dynamic-value/Makefile b/lldb/test/lang/cpp/dynamic-value/Makefile deleted file mode 100644 index 8770b2343ef0..000000000000 --- a/lldb/test/lang/cpp/dynamic-value/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := pass-to-base.cpp - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/dynamic-value/TestCppValueCast.py b/lldb/test/lang/cpp/dynamic-value/TestCppValueCast.py deleted file mode 100644 index c11a35107125..000000000000 --- a/lldb/test/lang/cpp/dynamic-value/TestCppValueCast.py +++ /dev/null @@ -1,154 +0,0 @@ -""" -Test lldb Python API SBValue::Cast(SBType) for C++ types. -""" - -import os, time -import re -import unittest2 -import lldb, lldbutil -from lldbtest import * - -class CppValueCastTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "dynamic-value") - - # rdar://problem/10808472 SBValue::Cast test case is failing (virtual inheritance) - @unittest2.expectedFailure - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @python_api_test - @dsym_test - def test_value_cast_with_dsym_and_virtual_inheritance(self): - """Test SBValue::Cast(SBType) API for C++ types with virtual inheritance.""" - self.buildDsym(dictionary=self.d_virtual) - self.setTearDownCleanup(dictionary=self.d_virtual) - self.do_sbvalue_cast(self.exe_name) - - # rdar://problem/10808472 SBValue::Cast test case is failing (virtual inheritance) - @unittest2.expectedFailure - @python_api_test - @dwarf_test - def test_value_cast_with_dwarf_and_virtual_inheritance(self): - """Test SBValue::Cast(SBType) API for C++ types with virtual inheritance.""" - self.buildDwarf(dictionary=self.d_virtual) - self.setTearDownCleanup(dictionary=self.d_virtual) - self.do_sbvalue_cast(self.exe_name) - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @python_api_test - @dsym_test - def test_value_cast_with_dsym_and_regular_inheritance(self): - """Test SBValue::Cast(SBType) API for C++ types with regular inheritance.""" - self.buildDsym(dictionary=self.d_regular) - self.setTearDownCleanup(dictionary=self.d_regular) - self.do_sbvalue_cast(self.exe_name) - - @python_api_test - @dwarf_test - def test_value_cast_with_dwarf_and_regular_inheritance(self): - """Test SBValue::Cast(SBType) API for C++ types with regular inheritance.""" - self.buildDwarf(dictionary=self.d_regular) - self.setTearDownCleanup(dictionary=self.d_regular) - self.do_sbvalue_cast(self.exe_name) - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - - # Find the line number to break for main.c. - self.source = 'sbvalue-cast.cpp'; - self.line = line_number(self.source, '// Set breakpoint here.') - self.exe_name = self.testMethodName - self.d_virtual = {'CXX_SOURCES': self.source, 'EXE': self.exe_name, 'CFLAGS_EXTRAS': '-DDO_VIRTUAL_INHERITANCE'} - self.d_regular = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} - - def do_sbvalue_cast (self, exe_name): - """Test SBValue::Cast(SBType) API for C++ types.""" - exe = os.path.join(os.getcwd(), exe_name) - - # Create a target from the debugger. - - target = self.dbg.CreateTarget (exe) - self.assertTrue(target, VALID_TARGET) - - # Set up our breakpoints: - - breakpoint = target.BreakpointCreateByLocation(self.source, self.line) - self.assertTrue(breakpoint, VALID_BREAKPOINT) - - # Now launch the process, and do not stop at the entry point. - process = target.LaunchSimple (None, None, os.getcwd()) - - self.assertTrue(process.GetState() == lldb.eStateStopped, - PROCESS_STOPPED) - - # Find DerivedA and DerivedB types. - typeA = target.FindFirstType('DerivedA') - typeB = target.FindFirstType('DerivedB') - self.DebugSBType(typeA) - self.DebugSBType(typeB) - self.assertTrue(typeA) - self.assertTrue(typeB) - error = lldb.SBError() - - # First stop is for DerivedA instance. - threads = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint) - self.assertTrue (len(threads) == 1) - thread = threads[0] - frame0 = thread.GetFrameAtIndex(0) - - tellerA = frame0.FindVariable('teller', lldb.eNoDynamicValues) - self.DebugSBValue(tellerA) - self.assertTrue(tellerA.GetChildMemberWithName('m_base_val').GetValueAsUnsigned(error, 0) == 20) - - if self.TraceOn(): - for child in tellerA: - print "child name:", child.GetName() - print child - - # Call SBValue.Cast() to obtain instanceA. - instanceA = tellerA.Cast(typeA.GetPointerType()) - self.DebugSBValue(instanceA) - - # Iterate through all the children and print their values. - if self.TraceOn(): - for child in instanceA: - print "child name:", child.GetName() - print child - a_member_val = instanceA.GetChildMemberWithName('m_a_val') - self.DebugSBValue(a_member_val) - self.assertTrue(a_member_val.GetValueAsUnsigned(error, 0) == 10) - - # Second stop is for DerivedB instance. - threads = lldbutil.continue_to_breakpoint (process, breakpoint) - self.assertTrue (len(threads) == 1) - thread = threads[0] - frame0 = thread.GetFrameAtIndex(0) - - tellerB = frame0.FindVariable('teller', lldb.eNoDynamicValues) - self.DebugSBValue(tellerB) - self.assertTrue(tellerB.GetChildMemberWithName('m_base_val').GetValueAsUnsigned(error, 0) == 12) - - if self.TraceOn(): - for child in tellerB: - print "child name:", child.GetName() - print child - - # Call SBValue.Cast() to obtain instanceB. - instanceB = tellerB.Cast(typeB.GetPointerType()) - self.DebugSBValue(instanceB) - - # Iterate through all the children and print their values. - if self.TraceOn(): - for child in instanceB: - print "child name:", child.GetName() - print child - b_member_val = instanceB.GetChildMemberWithName('m_b_val') - self.DebugSBValue(b_member_val) - self.assertTrue(b_member_val.GetValueAsUnsigned(error, 0) == 36) - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/dynamic-value/TestDynamicValue.py b/lldb/test/lang/cpp/dynamic-value/TestDynamicValue.py deleted file mode 100644 index a40479cf3973..000000000000 --- a/lldb/test/lang/cpp/dynamic-value/TestDynamicValue.py +++ /dev/null @@ -1,234 +0,0 @@ -""" -Use lldb Python API to test dynamic values in C++ -""" - -import os, time -import re -import unittest2 -import lldb, lldbutil -from lldbtest import * - -class DynamicValueTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "dynamic-value") - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @python_api_test - @dsym_test - def test_get_dynamic_vals_with_dsym(self): - """Test fetching C++ dynamic values from pointers & references.""" - self.buildDsym() - self.do_get_dynamic_vals() - - @python_api_test - @dwarf_test - def test_get_dynamic_vals_with_dwarf(self): - """Test fetching C++ dynamic values from pointers & references.""" - self.buildDwarf() - self.do_get_dynamic_vals() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - - # Find the line number to break for main.c. - - self.do_something_line = line_number('pass-to-base.cpp', '// Break here in doSomething.') - self.main_first_call_line = line_number('pass-to-base.cpp', - '// Break here and get real addresses of myB and otherB.') - self.main_second_call_line = line_number('pass-to-base.cpp', - '// Break here and get real address of reallyA.') - - def examine_value_object_of_this_ptr (self, this_static, this_dynamic, dynamic_location): - - # Get "this" as its static value - - self.assertTrue (this_static) - this_static_loc = int (this_static.GetValue(), 16) - - # Get "this" as its dynamic value - - self.assertTrue (this_dynamic) - this_dynamic_typename = this_dynamic.GetTypeName() - self.assertTrue (this_dynamic_typename.find('B') != -1) - this_dynamic_loc = int (this_dynamic.GetValue(), 16) - - # Make sure we got the right address for "this" - - self.assertTrue (this_dynamic_loc == dynamic_location) - - # And that the static address is greater than the dynamic one - - self.assertTrue (this_static_loc > this_dynamic_loc) - - # Now read m_b_value which is only in the dynamic value: - - use_dynamic = lldb.eDynamicCanRunTarget - no_dynamic = lldb.eNoDynamicValues - - this_dynamic_m_b_value = this_dynamic.GetChildMemberWithName('m_b_value', use_dynamic) - self.assertTrue (this_dynamic_m_b_value) - - m_b_value = int (this_dynamic_m_b_value.GetValue(), 0) - self.assertTrue (m_b_value == 10) - - # Make sure it is not in the static version - - this_static_m_b_value = this_static.GetChildMemberWithName('m_b_value', no_dynamic) - self.assertFalse (this_static_m_b_value) - - # Okay, now let's make sure that we can get the dynamic type of a child element: - - contained_auto_ptr = this_dynamic.GetChildMemberWithName ('m_client_A', use_dynamic) - self.assertTrue (contained_auto_ptr) - contained_b = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', use_dynamic) - self.assertTrue (contained_b) - - contained_b_static = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', no_dynamic) - self.assertTrue (contained_b_static) - - contained_b_addr = int (contained_b.GetValue(), 16) - contained_b_static_addr = int (contained_b_static.GetValue(), 16) - - self.assertTrue (contained_b_addr < contained_b_static_addr) - - def do_get_dynamic_vals(self): - """Get argument vals for the call stack when stopped on a breakpoint.""" - exe = os.path.join(os.getcwd(), "a.out") - - # Create a target from the debugger. - - target = self.dbg.CreateTarget (exe) - self.assertTrue(target, VALID_TARGET) - - # Set up our breakpoints: - - do_something_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.do_something_line) - self.assertTrue(do_something_bpt, - VALID_BREAKPOINT) - - first_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_first_call_line) - self.assertTrue(first_call_bpt, - VALID_BREAKPOINT) - - second_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_second_call_line) - self.assertTrue(second_call_bpt, - VALID_BREAKPOINT) - - # Now launch the process, and do not stop at the entry point. - process = target.LaunchSimple (None, None, os.getcwd()) - - self.assertTrue(process.GetState() == lldb.eStateStopped, - PROCESS_STOPPED) - - threads = lldbutil.get_threads_stopped_at_breakpoint (process, first_call_bpt) - self.assertTrue (len(threads) == 1) - thread = threads[0] - - frame = thread.GetFrameAtIndex(0) - - # Now find the dynamic addresses of myB and otherB so we can compare them - # with the dynamic values we get in doSomething: - - use_dynamic = lldb.eDynamicCanRunTarget - no_dynamic = lldb.eNoDynamicValues - - myB = frame.FindVariable ('myB', no_dynamic); - self.assertTrue (myB) - myB_loc = int (myB.GetLocation(), 16) - - otherB = frame.FindVariable('otherB', no_dynamic) - self.assertTrue (otherB) - otherB_loc = int (otherB.GetLocation(), 16) - - # Okay now run to doSomething: - - threads = lldbutil.continue_to_breakpoint (process, do_something_bpt) - self.assertTrue (len(threads) == 1) - thread = threads[0] - - frame = thread.GetFrameAtIndex(0) - - # Get "this" using FindVariable: - - this_static = frame.FindVariable ('this', no_dynamic) - this_dynamic = frame.FindVariable ('this', use_dynamic) - self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) - - # Now make sure that the "GetDynamicValue" works: - # This doesn't work currently because we can't get dynamic values from ConstResult objects. - fetched_dynamic_value = this_static.GetDynamicValue(use_dynamic) - self.examine_value_object_of_this_ptr (this_static, fetched_dynamic_value, myB_loc) - - # And conversely that the GetDynamicValue() interface also works: - fetched_static_value = this_dynamic.GetStaticValue() - self.examine_value_object_of_this_ptr (fetched_static_value, this_dynamic, myB_loc) - - # Get "this" using FindValue, make sure that works too: - this_static = frame.FindValue ('this', lldb.eValueTypeVariableArgument, no_dynamic) - this_dynamic = frame.FindValue ('this', lldb.eValueTypeVariableArgument, use_dynamic) - self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) - - # Get "this" using the EvaluateExpression: - this_static = frame.EvaluateExpression ('this', False) - this_dynamic = frame.EvaluateExpression ('this', True) - self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) - - # The "frame var" code uses another path to get into children, so let's - # make sure that works as well: - - self.expect('frame var -d run-target anotherA.m_client_A._M_ptr', 'frame var finds its way into a child member', - patterns = ['\(B \*\)']) - - # Now make sure we also get it right for a reference as well: - - anotherA_static = frame.FindVariable ('anotherA', False) - self.assertTrue (anotherA_static) - anotherA_static_addr = int (anotherA_static.GetValue(), 16) - - anotherA_dynamic = frame.FindVariable ('anotherA', True) - self.assertTrue (anotherA_dynamic) - anotherA_dynamic_addr = int (anotherA_dynamic.GetValue(), 16) - anotherA_dynamic_typename = anotherA_dynamic.GetTypeName() - self.assertTrue (anotherA_dynamic_typename.find('B') != -1) - - self.assertTrue(anotherA_dynamic_addr < anotherA_static_addr) - - anotherA_m_b_value_dynamic = anotherA_dynamic.GetChildMemberWithName('m_b_value', True) - self.assertTrue (anotherA_m_b_value_dynamic) - anotherA_m_b_val = int (anotherA_m_b_value_dynamic.GetValue(), 10) - self.assertTrue (anotherA_m_b_val == 300) - - anotherA_m_b_value_static = anotherA_static.GetChildMemberWithName('m_b_value', True) - self.assertFalse (anotherA_m_b_value_static) - - # Okay, now continue again, and when we hit the second breakpoint in main - - threads = lldbutil.continue_to_breakpoint (process, second_call_bpt) - self.assertTrue (len(threads) == 1) - thread = threads[0] - - frame = thread.GetFrameAtIndex(0) - reallyA_value = frame.FindVariable ('reallyA', False) - self.assertTrue(reallyA_value) - reallyA_loc = int (reallyA_value.GetLocation(), 16) - - # Finally continue to doSomething again, and make sure we get the right value for anotherA, - # which this time around is just an "A". - - threads = lldbutil.continue_to_breakpoint (process, do_something_bpt) - self.assertTrue(len(threads) == 1) - thread = threads[0] - - frame = thread.GetFrameAtIndex(0) - anotherA_value = frame.FindVariable ('anotherA', True) - self.assertTrue(anotherA_value) - anotherA_loc = int (anotherA_value.GetValue(), 16) - self.assertTrue (anotherA_loc == reallyA_loc) - self.assertTrue (anotherA_value.GetTypeName().find ('B') == -1) - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/dynamic-value/pass-to-base.cpp b/lldb/test/lang/cpp/dynamic-value/pass-to-base.cpp deleted file mode 100644 index a817bade9416..000000000000 --- a/lldb/test/lang/cpp/dynamic-value/pass-to-base.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include <stdio.h> -#include <memory> - -class Extra -{ -public: - Extra (int in_one, int in_two) : m_extra_one(in_one), m_extra_two(in_two) {} - -private: - int m_extra_one; - int m_extra_two; -}; - -class A -{ -public: - A(int value) : m_a_value (value) {} - A(int value, A* client_A) : m_a_value (value), m_client_A (client_A) {} - - virtual ~A() {} - - virtual void - doSomething (A &anotherA) - { - printf ("In A %p doing something with %d.\n", this, m_a_value); - printf ("Also have another A at %p: %d.\n", &anotherA, anotherA.Value()); // Break here in doSomething. - } - - int - Value() - { - return m_a_value; - } - -private: - int m_a_value; - std::auto_ptr<A> m_client_A; -}; - -class B : public Extra, public virtual A -{ -public: - B (int b_value, int a_value) : Extra(b_value, a_value), A(a_value), m_b_value(b_value) {} - B (int b_value, int a_value, A *client_A) : Extra(b_value, a_value), A(a_value, client_A), m_b_value(b_value) {} - - virtual ~B () {} - -private: - int m_b_value; -}; - -static A* my_global_A_ptr; - -int -main (int argc, char **argv) -{ - my_global_A_ptr = new B (100, 200); - B myB (10, 20, my_global_A_ptr); - B *second_fake_A_ptr = new B (150, 250); - B otherB (300, 400, second_fake_A_ptr); - - myB.doSomething(otherB); // Break here and get real addresses of myB and otherB. - - A reallyA (500); - myB.doSomething (reallyA); // Break here and get real address of reallyA. - - return 0; -} diff --git a/lldb/test/lang/cpp/dynamic-value/sbvalue-cast.cpp b/lldb/test/lang/cpp/dynamic-value/sbvalue-cast.cpp deleted file mode 100644 index 00fd7dad438c..000000000000 --- a/lldb/test/lang/cpp/dynamic-value/sbvalue-cast.cpp +++ /dev/null @@ -1,80 +0,0 @@ -//===-- sbvalue-cast.cpp ----------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#ifdef DO_VIRTUAL_INHERITANCE -#define VIRTUAL virtual -#else -#define VIRTUAL -#endif - -#include <stdio.h> - -class Base -{ -public: - Base(int val) : m_base_val (val) {} - virtual ~Base() {} - - virtual void - forcast(int input) { - int future_val = m_base_val + input * 1; - printf("Forcasting %d\n", future_val); - } - -protected: - int m_base_val; -}; - -class DerivedA : public VIRTUAL Base -{ -public: - DerivedA(int val) : Base(val*2), m_a_val(val) { - printf("DerivedA::ctor()->\n"); - printf("m_base_val=%d\n", m_base_val); - printf("m_a_val=%d\n", m_a_val); - } - virtual ~DerivedA() {} - -private: - int m_a_val; -}; - -class DerivedB : public VIRTUAL Base -{ -public: - DerivedB(int val) : Base(val), m_b_val(val*3) { - printf("DerivedB::ctor()->\n"); - printf("m_base_val=%d\n", m_base_val); - printf("m_b_val=%d\n", m_b_val); - } - virtual ~DerivedB() {} - - virtual void - forcast(int input) { - int future_val = m_b_val + input * 2; - printf("Forcasting %d\n", future_val); - } - -private: - int m_b_val; -}; - -int -main(int argc, char **argv) -{ - DerivedA* dA = new DerivedA(10); - DerivedB* dB = new DerivedB(12); - Base *array[2] = {dA, dB}; - Base *teller = NULL; - for (int i = 0; i < 2; ++i) { - teller = array[i]; - teller->forcast(i); // Set breakpoint here. - } - - return 0; -} diff --git a/lldb/test/lang/cpp/exceptions/Makefile b/lldb/test/lang/cpp/exceptions/Makefile deleted file mode 100644 index a6bd8463ad54..000000000000 --- a/lldb/test/lang/cpp/exceptions/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := exceptions.cpp - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py b/lldb/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py deleted file mode 100644 index c294b54dd6e4..000000000000 --- a/lldb/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py +++ /dev/null @@ -1,81 +0,0 @@ -""" -Test lldb exception breakpoint command for CPP. -""" - -import os, time -import unittest2 -import lldb -import lldbutil -from lldbtest import * - -class CPPBreakpointTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "exceptions") - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @dsym_test - def test_with_dsym(self): - """Test lldb exception breakpoint command for CPP.""" - self.buildDsym() - self.cpp_exceptions() - - @dwarf_test - def test_with_dwarf(self): - """Test lldb exception breakpoint command for CPP.""" - self.buildDwarf() - self.cpp_exceptions() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - self.source = 'exceptions.cpp' - self.catch_line = line_number(self.source, '// This is the line you should stop at for catch') - - def cpp_exceptions (self): - """Test lldb exception breakpoint command for CPP.""" - exe = os.path.join(os.getcwd(), "a.out") - - # Create a target from the debugger. - - target = self.dbg.CreateTarget (exe) - self.assertTrue(target, VALID_TARGET) - - exception_bkpt = target.BreakpointCreateForException (lldb.eLanguageTypeC_plus_plus, True, True) - self.assertTrue (exception_bkpt, "Made an exception breakpoint") - - # Now run, and make sure we hit our breakpoint: - process = target.LaunchSimple (None, None, os.getcwd()) - self.assertTrue (process, "Got a valid process") - - stopped_threads = [] - stopped_threads = lldbutil.get_threads_stopped_at_breakpoint (process, exception_bkpt) - self.assertTrue (len(stopped_threads) == 1, "Stopped at our exception breakpoint.") - thread = stopped_threads[0] - # Make sure our throw function is still above us on the stack: - - frame_functions = lldbutil.get_function_names(thread) - self.assertTrue (frame_functions.count ("throws_exception_on_even(int)") == 1, "Our throw function is still on the stack.") - - # Okay we hit our exception throw breakpoint, now make sure we get our catch breakpoint. - # One potential complication is that we might hit a couple of the exception breakpoints in getting out of the throw. - # so loop till we don't see the throws function on the stack. We should stop one more time for our exception breakpoint - # and that should be the catch... - - while frame_functions.count ("throws_exception_on_even(int)") == 1: - stopped_threads = lldbutil.continue_to_breakpoint (process, exception_bkpt) - self.assertTrue (len(stopped_threads) == 1) - - thread = stopped_threads[0] - frame_functions = lldbutil.get_function_names(thread) - - self.assertTrue (frame_functions.count ("throws_exception_on_even(int)") == 0, "At catch our throw function is off the stack") - self.assertTrue (frame_functions.count ("intervening_function(int)") == 0, "At catch our intervening function is off the stack") - self.assertTrue (frame_functions.count ("catches_exception(int)") == 1, "At catch our catch function is on the stack") - - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/exceptions/exceptions.cpp b/lldb/test/lang/cpp/exceptions/exceptions.cpp deleted file mode 100644 index 150d420b241b..000000000000 --- a/lldb/test/lang/cpp/exceptions/exceptions.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include <exception> -#include <stdio.h> - -int throws_exception_on_even (int value); -int intervening_function (int value); -int catches_exception (int value); - -int -catches_exception (int value) -{ - try - { - return intervening_function(value); // This is the line you should stop at for catch - } - catch (int value) - { - return value; - } -} - -int -intervening_function (int value) -{ - return throws_exception_on_even (2 * value); -} - -int -throws_exception_on_even (int value) -{ - printf ("Mod two works: %d.\n", value%2); - if (value % 2 == 0) - throw 30; - else - return value; -} - -int -main () -{ - catches_exception (10); // Stop here - return 5; -} diff --git a/lldb/test/lang/cpp/namespace/Makefile b/lldb/test/lang/cpp/namespace/Makefile deleted file mode 100644 index 314f1cb2f077..000000000000 --- a/lldb/test/lang/cpp/namespace/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/namespace/TestNamespace.py b/lldb/test/lang/cpp/namespace/TestNamespace.py deleted file mode 100644 index b52bdcb126ae..000000000000 --- a/lldb/test/lang/cpp/namespace/TestNamespace.py +++ /dev/null @@ -1,115 +0,0 @@ -""" -Test the printing of anonymous and named namespace variables. -""" - -import os, time -import unittest2 -import lldb -from lldbtest import * - -class NamespaceTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "namespace") - - # rdar://problem/8668674 - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @dsym_test - def test_with_dsym_and_run_command(self): - """Test that anonymous and named namespace variables display correctly.""" - self.buildDsym() - self.namespace_variable_commands() - - # rdar://problem/8668674 - @dwarf_test - def test_with_dwarf_and_run_command(self): - """Test that anonymous and named namespace variables display correctly.""" - self.buildDwarf() - self.namespace_variable_commands() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line numbers for declarations of namespace variables i and j. - self.line_var_i = line_number('main.cpp', - '// Find the line number for anonymous namespace variable i.') - self.line_var_j = line_number('main.cpp', - '// Find the line number for named namespace variable j.') - # And the line number to break at. - self.line_break = line_number('main.cpp', - '// Set break point at this line.') - - def namespace_variable_commands(self): - """Test that anonymous and named namespace variables display correctly.""" - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - self.expect("breakpoint set -f main.cpp -l %d" % self.line_break, - BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" % - self.line_break) - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - - # On Mac OS X, gcc 4.2 emits the wrong debug info with respect to types. - slist = ['(int) a = 12', 'anon_uint', 'a_uint', 'b_uint', 'y_uint'] - if sys.platform.startswith("darwin") and self.getCompiler() in ['clang', 'llvm-gcc']: - slist = ['(int) a = 12', - '::my_uint_t', 'anon_uint = 0', - '(A::uint_t) a_uint = 1', - '(A::B::uint_t) b_uint = 2', - '(Y::uint_t) y_uint = 3'] - - # 'frame variable' displays the local variables with type information. - self.expect('frame variable', VARIABLES_DISPLAYED_CORRECTLY, - substrs = slist) - - # 'frame variable' with basename 'i' should work. - self.expect("frame variable -c -g i", - startstr = "main.cpp:%d: (int) (anonymous namespace)::i = 3" % self.line_var_i) - # main.cpp:12: (int) (anonymous namespace)::i = 3 - - # 'frame variable' with basename 'j' should work, too. - self.expect("frame variable -c -g j", - startstr = "main.cpp:%d: (int) A::B::j = 4" % self.line_var_j) - # main.cpp:19: (int) A::B::j = 4 - - # 'frame variable' should support address-of operator. - self.runCmd("frame variable &i") - - # 'frame variable' with fully qualified name 'A::B::j' should work. - self.expect("frame variable A::B::j", VARIABLES_DISPLAYED_CORRECTLY, - startstr = '(int) A::B::j = 4', - patterns = [' = 4$']) - - # So should the anonymous namespace case. - self.expect("frame variable '(anonymous namespace)::i'", VARIABLES_DISPLAYED_CORRECTLY, - startstr = '(int) (anonymous namespace)::i = 3', - patterns = [' = 3$']) - - # rdar://problem/8660275 - # test/namespace: 'expression -- i+j' not working - # This has been fixed. - self.expect("expression -- i + j", - startstr = "(int) $0 = 7") - # (int) $0 = 7 - - self.runCmd("expression -- i") - self.runCmd("expression -- j") - - # rdar://problem/8668674 - # expression command with fully qualified namespace for a variable does not work - self.expect("expression -- ::i", VARIABLES_DISPLAYED_CORRECTLY, - patterns = [' = 3$']) - self.expect("expression -- A::B::j", VARIABLES_DISPLAYED_CORRECTLY, - patterns = [' = 4$']) - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/namespace/cmds.txt b/lldb/test/lang/cpp/namespace/cmds.txt deleted file mode 100644 index 76bb1bcba759..000000000000 --- a/lldb/test/lang/cpp/namespace/cmds.txt +++ /dev/null @@ -1,3 +0,0 @@ -b main.cpp:54 -c -var diff --git a/lldb/test/lang/cpp/namespace/main.cpp b/lldb/test/lang/cpp/namespace/main.cpp deleted file mode 100644 index dfa7a69c4e67..000000000000 --- a/lldb/test/lang/cpp/namespace/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -namespace { - typedef unsigned int my_uint_t; - int i; // Find the line number for anonymous namespace variable i. -} - -namespace A { - typedef unsigned int uint_t; - namespace B { - typedef unsigned int uint_t; - int j; // Find the line number for named namespace variable j. - int myfunc (int a); - int myfunc2(int a) - { - return a + 2; - } - float myfunc (float f) - { - return f - 2.0; - } - } -} - -namespace Y -{ - typedef unsigned int uint_t; - using A::B::j; - int foo; -} - -using A::B::j; // using declaration - -namespace Foo = A::B; // namespace alias - -using Foo::myfunc; // using declaration - -using namespace Foo; // using directive - -namespace A { - namespace B { - using namespace Y; - int k; - } -} - -#include <stdio.h> -int Foo::myfunc(int a) -{ - ::my_uint_t anon_uint = 0; - A::uint_t a_uint = 1; - B::uint_t b_uint = 2; - Y::uint_t y_uint = 3; - i = 3; - j = 4; - printf("::i=%d\n", ::i); - printf("A::B::j=%d\n", A::B::j); - return myfunc2(3) + j + i + a + 2 + anon_uint + a_uint + b_uint + y_uint; // Set break point at this line. -} - -int -main (int argc, char const *argv[]) -{ - return Foo::myfunc(12); -} diff --git a/lldb/test/lang/cpp/signed_types/Makefile b/lldb/test/lang/cpp/signed_types/Makefile deleted file mode 100644 index 314f1cb2f077..000000000000 --- a/lldb/test/lang/cpp/signed_types/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/signed_types/TestSignedTypes.py b/lldb/test/lang/cpp/signed_types/TestSignedTypes.py deleted file mode 100644 index e1aa3c6e08ee..000000000000 --- a/lldb/test/lang/cpp/signed_types/TestSignedTypes.py +++ /dev/null @@ -1,71 +0,0 @@ -""" -Test that variables with signed types display correctly. -""" - -import os, time -import re -import unittest2 -import lldb -from lldbtest import * - -class UnsignedTypesTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "signed_types") - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @dsym_test - def test_with_dsym(self): - """Test that variables with signed types display correctly.""" - self.buildDsym() - self.signed_types() - - @dwarf_test - def test_with_dwarf(self): - """Test that variables with signed types display correctly.""" - self.buildDwarf() - self.signed_types() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to break inside main(). - self.line = line_number('main.cpp', '// Set break point at this line.') - - def signed_types(self): - """Test that variables with signed types display correctly.""" - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # Break on line 22 in main() aftre the variables are assigned values. - self.expect("breakpoint set -f main.cpp -l %d" % self.line, - BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" % - self.line) - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', 'stop reason = breakpoint']) - - # The breakpoint should have a hit count of 1. - self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) - - # Execute the assignment statement. - self.runCmd("thread step-over") - - # Test that signed types display correctly. - self.expect("frame variable -T -a", VARIABLES_DISPLAYED_CORRECTLY, - patterns = ["\((short int|short)\) the_signed_short = 99"], - substrs = ["(signed char) the_signed_char = 'c'", - "(int) the_signed_int = 99", - "(long) the_signed_long = 99", - "(long long) the_signed_long_long = 99"]) - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/signed_types/main.cpp b/lldb/test/lang/cpp/signed_types/main.cpp deleted file mode 100644 index 3e40f3aa3dcc..000000000000 --- a/lldb/test/lang/cpp/signed_types/main.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -int main (int argc, char const *argv[]) -{ - char the_char = 'c'; - short the_short = 'c'; - wchar_t the_wchar_t = 'c'; - int the_int = 'c'; - long the_long = 'c'; - long long the_long_long = 'c'; - - signed char the_signed_char = 'c'; - signed short the_signed_short = 'c'; - signed int the_signed_int = 'c'; - signed long the_signed_long = 'c'; - signed long long the_signed_long_long = 'c'; // Set break point at this line. - - return the_char - the_signed_char + - the_short - the_signed_short + - the_int - the_signed_int + - the_long - the_signed_long + - the_long_long - the_signed_long_long; //// break $source:$line; c - //// var the_int - //// val -set 22 1 -} diff --git a/lldb/test/lang/cpp/static_methods/Makefile b/lldb/test/lang/cpp/static_methods/Makefile deleted file mode 100644 index 314f1cb2f077..000000000000 --- a/lldb/test/lang/cpp/static_methods/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/static_methods/TestCPPStaticMethods.py b/lldb/test/lang/cpp/static_methods/TestCPPStaticMethods.py deleted file mode 100644 index 027dea285749..000000000000 --- a/lldb/test/lang/cpp/static_methods/TestCPPStaticMethods.py +++ /dev/null @@ -1,53 +0,0 @@ -""" -Tests expressions that distinguish between static and non-static methods. -""" - -from lldbtest import * - -class CPPStaticMethodsTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "static_methods") - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @dsym_test - def test_with_dsym_and_run_command(self): - """Test that static methods are properly distinguished from regular methods""" - self.buildDsym() - self.static_method_commands() - - @dwarf_test - def test_with_dwarf_and_run_command(self): - """Test that static methods are properly distinguished from regular methods""" - self.buildDwarf() - self.static_method_commands() - - def setUp(self): - TestBase.setUp(self) - self.line = line_number('main.cpp', '// Break at this line') - - def static_method_commands(self): - """Test that static methods are properly distinguished from regular methods""" - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - self.expect("breakpoint set -f main.cpp -l %d" % self.line, - BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" % self.line) - - self.runCmd("process launch", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", - STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', 'stop reason = breakpoint']) - - self.expect("expression -- A::getStaticValue()", - startstr = "(int) $0 = 5") - - self.expect("expression -- my_a.getMemberValue()", - startstr = "(int) $1 = 3") - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/static_methods/main.cpp b/lldb/test/lang/cpp/static_methods/main.cpp deleted file mode 100644 index 5141a407d111..000000000000 --- a/lldb/test/lang/cpp/static_methods/main.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include <stdio.h> - -class A -{ -public: - static int getStaticValue(); - int getMemberValue(); - int a; -}; - -int A::getStaticValue() -{ - return 5; -} - -int A::getMemberValue() -{ - return a; -} - -int main() -{ - A my_a; - - my_a.a = 3; - - printf("%d\n", A::getStaticValue()); // Break at this line - printf("%d\n", my_a.getMemberValue()); -} diff --git a/lldb/test/lang/cpp/stl/Makefile b/lldb/test/lang/cpp/stl/Makefile deleted file mode 100644 index 355e3121b7d5..000000000000 --- a/lldb/test/lang/cpp/stl/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp -CFLAGS :=-arch x86_64 -gdwarf-2 -O0 - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/stl/TestSTL.py b/lldb/test/lang/cpp/stl/TestSTL.py deleted file mode 100644 index 8b4f55666fbe..000000000000 --- a/lldb/test/lang/cpp/stl/TestSTL.py +++ /dev/null @@ -1,149 +0,0 @@ -""" -Test some expressions involving STL data types. -""" - -import os, time -import unittest2 -import lldb -import lldbutil -from lldbtest import * - -class STLTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "stl") - - # rdar://problem/10400981 - @unittest2.expectedFailure - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @dsym_test - def test_with_dsym(self): - """Test some expressions involving STL data types.""" - self.buildDsym() - self.step_stl_exprs() - - # rdar://problem/10400981 - @unittest2.expectedFailure - @dwarf_test - def test_with_dwarf(self): - """Test some expressions involving STL data types.""" - self.buildDwarf() - self.step_stl_exprs() - - @python_api_test - @dsym_test - def test_SBType_template_aspects_with_dsym(self): - """Test APIs for getting template arguments from an SBType.""" - self.buildDsym() - self.sbtype_template_apis() - - @python_api_test - @dwarf_test - def test_SBType_template_aspects_with_dwarf(self): - """Test APIs for getting template arguments from an SBType.""" - self.buildDwarf() - self.sbtype_template_apis() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to break inside main(). - self.source = 'main.cpp' - self.line = line_number(self.source, '// Set break point at this line.') - - def step_stl_exprs(self): - """Test some expressions involving STL data types.""" - exe = os.path.join(os.getcwd(), "a.out") - - # The following two lines, if uncommented, will enable loggings. - #self.ci.HandleCommand("log enable -f /tmp/lldb.log lldb default", res) - #self.assertTrue(res.Succeeded()) - - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # rdar://problem/8543077 - # test/stl: clang built binaries results in the breakpoint locations = 3, - # is this a problem with clang generated debug info? - self.expect("breakpoint set -f %s -l %d" % (self.source, self.line), - BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = %d" % - self.line) - - self.runCmd("run", RUN_SUCCEEDED) - - # Stop at 'std::string hello_world ("Hello World!");'. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['main.cpp:%d' % self.line, - 'stop reason = breakpoint']) - - # The breakpoint should have a hit count of 1. - self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) - - # Now try some expressions.... - - self.runCmd('expr for (int i = 0; i < hello_world.length(); ++i) { (void)printf("%c\\n", hello_world[i]); }') - - # rdar://problem/10373783 - # rdar://problem/10400981 - self.expect('expr associative_array.size()', - substrs = [' = 3']) - self.expect('expr associative_array.count(hello_world)', - substrs = [' = 1']) - self.expect('expr associative_array[hello_world]', - substrs = [' = 1']) - self.expect('expr associative_array["hello"]', - substrs = [' = 2']) - - def sbtype_template_apis(self): - """Test APIs for getting template arguments from an SBType.""" - exe = os.path.join(os.getcwd(), 'a.out') - - # Create a target by the debugger. - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - # Create the breakpoint inside function 'main'. - breakpoint = target.BreakpointCreateByLocation(self.source, self.line) - self.assertTrue(breakpoint, VALID_BREAKPOINT) - - # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple(None, None, os.getcwd()) - self.assertTrue(process, PROCESS_IS_VALID) - - # Get Frame #0. - self.assertTrue(process.GetState() == lldb.eStateStopped) - thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) - self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") - frame0 = thread.GetFrameAtIndex(0) - - # Get the type for variable 'associative_array'. - associative_array = frame0.FindVariable('associative_array') - self.DebugSBValue(associative_array) - self.assertTrue(associative_array, VALID_VARIABLE) - map_type = associative_array.GetType() - self.DebugSBType(map_type) - self.assertTrue(map_type, VALID_TYPE) - num_template_args = map_type.GetNumberOfTemplateArguments() - self.assertTrue(num_template_args > 0) - - # We expect the template arguments to contain at least 'string' and 'int'. - expected_types = { 'string': False, 'int': False } - for i in range(num_template_args): - t = map_type.GetTemplateArgumentType(i) - self.DebugSBType(t) - self.assertTrue(t, VALID_TYPE) - name = t.GetName() - if 'string' in name: - expected_types['string'] = True - elif 'int' == name: - expected_types['int'] = True - - # Check that both entries of the dictionary have 'True' as the value. - self.assertTrue(all(expected_types.values())) - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/stl/TestStdCXXDisassembly.py b/lldb/test/lang/cpp/stl/TestStdCXXDisassembly.py deleted file mode 100644 index 80a224e53072..000000000000 --- a/lldb/test/lang/cpp/stl/TestStdCXXDisassembly.py +++ /dev/null @@ -1,114 +0,0 @@ -""" -Test the lldb disassemble command on lib stdc++. -""" - -import os, time -import unittest2 -import lldb -from lldbtest import * - -class StdCXXDisassembleTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "stl") - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to break inside main(). - self.line = line_number('main.cpp', '// Set break point at this line.') - - # rdar://problem/8504895 - # Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]" - @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") - def test_stdcxx_disasm(self): - """Do 'disassemble' on each and every 'Code' symbol entry from the std c++ lib.""" - self.buildDefault() - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # rdar://problem/8543077 - # test/stl: clang built binaries results in the breakpoint locations = 3, - # is this a problem with clang generated debug info? - # - # Break on line 13 of main.cpp. - self.expect("breakpoint set -f main.cpp -l %d" % self.line, - BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = %d" % - self.line) - - self.runCmd("run", RUN_SUCCEEDED) - - # Now let's get the target as well as the process objects. - target = self.dbg.GetSelectedTarget() - process = target.GetProcess() - - # The process should be in a 'stopped' state. - self.expect(str(process), STOPPED_DUE_TO_BREAKPOINT, exe=False, - substrs = ["a.out", - "stopped"]) - - # Disassemble the functions on the call stack. - self.runCmd("thread backtrace") - thread = process.GetThreadAtIndex(0) - depth = thread.GetNumFrames() - for i in range(depth - 1): - frame = thread.GetFrameAtIndex(i) - function = frame.GetFunction() - self.runCmd("disassemble -n '%s'" % function.GetName()) - - # Iterate through the available modules, looking for stdc++ library... - for i in range(target.GetNumModules()): - module = target.GetModuleAtIndex(i) - fs = module.GetFileSpec() - if (fs.GetFilename().startswith("libstdc++")): - lib_stdcxx = str(fs) - break - - # At this point, lib_stdcxx is the full path to the stdc++ library and - # module is the corresponding SBModule. - - self.expect(fs.GetFilename(), "Libraray StdC++ is located", exe=False, - substrs = ["libstdc++"]) - - self.runCmd("image dump symtab %s" % str(fs)) - raw_output = self.res.GetOutput() - # Now, look for every 'Code' symbol and feed its load address into the - # command: 'disassemble -s load_address -e end_address', where the - # end_address is taken from the next consecutive 'Code' symbol entry's - # load address. - # - # The load address column comes after the file address column, with both - # looks like '0xhhhhhhhh', i.e., 8 hexadecimal digits. - codeRE = re.compile(r""" - \ Code\ {9} # ' Code' followed by 9 SPCs, - 0x[0-9a-f]{16} # the file address column, and - \ # a SPC, and - (0x[0-9a-f]{16}) # the load address column, and - .* # the rest. - """, re.VERBOSE) - # Maintain a start address variable; if we arrive at a consecutive Code - # entry, then the load address of the that entry is fed as the end - # address to the 'disassemble -s SA -e LA' command. - SA = None - for line in raw_output.split(os.linesep): - match = codeRE.search(line) - if match: - LA = match.group(1) - if self.TraceOn(): - print "line:", line - print "load address:", LA - print "SA:", SA - if SA and LA: - if int(LA, 16) > int(SA, 16): - self.runCmd("disassemble -s %s -e %s" % (SA, LA)) - SA = LA - else: - # This entry is not a Code entry. Reset SA = None. - SA = None - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/stl/cmds.txt b/lldb/test/lang/cpp/stl/cmds.txt deleted file mode 100644 index 9c9c2e3db57b..000000000000 --- a/lldb/test/lang/cpp/stl/cmds.txt +++ /dev/null @@ -1,3 +0,0 @@ -b main.cpp:6 -continue -var diff --git a/lldb/test/lang/cpp/stl/main.cpp b/lldb/test/lang/cpp/stl/main.cpp deleted file mode 100644 index 1ef7d7222a02..000000000000 --- a/lldb/test/lang/cpp/stl/main.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#include <iostream> -#include <string> -#include <map> -int main (int argc, char const *argv[]) -{ - std::string hello_world ("Hello World!"); - std::cout << hello_world << std::endl; - std::cout << hello_world.length() << std::endl; - std::cout << hello_world[11] << std::endl; - - std::map<std::string, int> associative_array; - std::cout << "size of upon construction associative_array: " << associative_array.size() << std::endl; - associative_array[hello_world] = 1; - associative_array["hello"] = 2; - associative_array["world"] = 3; - - std::cout << "size of associative_array: " << associative_array.size() << std::endl; - printf("associative_array[\"hello\"]=%d\n", associative_array["hello"]); - - printf("before returning....\n"); // Set break point at this line. -} diff --git a/lldb/test/lang/cpp/this/Makefile b/lldb/test/lang/cpp/this/Makefile deleted file mode 100644 index 314f1cb2f077..000000000000 --- a/lldb/test/lang/cpp/this/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/this/TestCPPThis.py b/lldb/test/lang/cpp/this/TestCPPThis.py deleted file mode 100644 index fa535c77fb83..000000000000 --- a/lldb/test/lang/cpp/this/TestCPPThis.py +++ /dev/null @@ -1,73 +0,0 @@ -""" -Tests that C++ member and static variables are available where they should be. -""" - -from lldbtest import * - -class CPPThisTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "this") - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - #rdar://problem/9962849 - #@expectedFailureClang - @dsym_test - def test_with_dsym_and_run_command(self): - """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" - self.buildDsym() - self.static_method_commands() - - #rdar://problem/9962849 - #@expectedFailureClang - @dwarf_test - def test_with_dwarf_and_run_command(self): - """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" - self.buildDwarf() - self.static_method_commands() - - def setUp(self): - TestBase.setUp(self) - - def set_breakpoint(self, line): - self.expect("breakpoint set -f main.cpp -l %d" % line, - BREAKPOINT_CREATED, - startstr = "Breakpoint created") - - def static_method_commands(self): - """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - self.set_breakpoint(line_number('main.cpp', '// breakpoint 1')) - self.set_breakpoint(line_number('main.cpp', '// breakpoint 2')) - self.set_breakpoint(line_number('main.cpp', '// breakpoint 3')) - self.set_breakpoint(line_number('main.cpp', '// breakpoint 4')) - - self.runCmd("process launch", RUN_SUCCEEDED) - - self.expect("expression -- m_a = 2", - startstr = "(int) $0 = 2") - - self.runCmd("process continue") - - # This would be disallowed if we enforced const. But we don't. - self.expect("expression -- m_a = 2", - startstr = "(int) $1 = 2") - - self.expect("expression -- m_a", - startstr = "(int) $2 = 2") - - self.runCmd("process continue") - - self.expect("expression -- s_a", - startstr = "(int) $3 = 5") - - self.runCmd("process continue") - - self.expect("expression -- m_a", - startstr = "(int) $4 = 2") - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/this/main.cpp b/lldb/test/lang/cpp/this/main.cpp deleted file mode 100644 index e70823b9a3ad..000000000000 --- a/lldb/test/lang/cpp/this/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include <stdio.h> - -class A -{ -public: - void accessMember(int a); - int accessMemberConst() const; - static int accessStaticMember(); - - void accessMemberInline(int a) __attribute__ ((always_inline)) - { - m_a = a; // breakpoint 4 - } - - int m_a; - static int s_a; -}; - -int A::s_a = 5; - -void A::accessMember(int a) -{ - m_a = a; // breakpoint 1 -} - -int A::accessMemberConst() const -{ - return m_a; // breakpoint 2 -} - -int A::accessStaticMember() -{ - return s_a; // breakpoint 3 -} - -int main() -{ - A my_a; - - my_a.accessMember(3); - my_a.accessMemberConst(); - A::accessStaticMember(); - my_a.accessMemberInline(5); -} diff --git a/lldb/test/lang/cpp/unique-types/Makefile b/lldb/test/lang/cpp/unique-types/Makefile deleted file mode 100644 index 314f1cb2f077..000000000000 --- a/lldb/test/lang/cpp/unique-types/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py b/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py deleted file mode 100644 index 66b871e230ff..000000000000 --- a/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py +++ /dev/null @@ -1,89 +0,0 @@ -""" -Test that template instaniations of std::vector<long> and <short> in the same module have the correct types. -""" - -import unittest2 -import lldb -import lldbutil -from lldbtest import * - -class UniqueTypesTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "unique-types") - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @dsym_test - def test_with_dsym(self): - """Test for unique types of std::vector<long> and std::vector<short>.""" - self.buildDsym() - self.unique_types() - - @dwarf_test - def test_with_dwarf(self): - """Test for unique types of std::vector<long> and std::vector<short>.""" - self.buildDwarf() - self.unique_types() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number inside main.cpp. - self.line = line_number("main.cpp", - "// Set breakpoint here to verify that std::vector 'longs' and 'shorts' have unique types.") - - def unique_types(self): - """Test for unique types of std::vector<long> and std::vector<short>.""" - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - self.expect("breakpoint set -f main.cpp -l %d" % self.line, - BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" % - self.line) - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - - if self.getCompiler().endswith('clang'): - import re - clang_version_output = system([lldbutil.which(self.getCompiler()), "-v"])[1] - #print "my output:", clang_version_output - for line in clang_version_output.split(os.linesep): - m = re.search('clang version ([0-9]+)\.', line) - #print "line:", line - if m: - clang_version = int(m.group(1)) - #print "clang version:", clang_version - if clang_version < 3: - self.skipTest("rdar://problem/9173060 lldb hangs while running unique-types for clang version < 3") - - # Do a "frame variable -T longs" and verify "long" is in each line of output. - self.runCmd("frame variable -T longs") - output = self.res.GetOutput() - for x in [line.strip() for line in output.split(os.linesep)]: - # Skip empty line or closing brace. - if not x or x == '}': - continue - self.expect(x, "Expect type 'long'", exe=False, - substrs = ['long']) - - # Do a "frame variable -T shorts" and verify "short" is in each line of output. - self.runCmd("frame variable -T shorts") - output = self.res.GetOutput() - for x in [line.strip() for line in output.split(os.linesep)]: - # Skip empty line or closing brace. - if not x or x == '}': - continue - self.expect(x, "Expect type 'short'", exe=False, - substrs = ['short']) - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/unique-types/main.cpp b/lldb/test/lang/cpp/unique-types/main.cpp deleted file mode 100644 index c551c0e2c0d4..000000000000 --- a/lldb/test/lang/cpp/unique-types/main.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===-- main.c --------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#include <vector> - -#include <stdio.h> -#include <stdint.h> - -int main (int argc, char const *argv[], char const *envp[]) -{ - std::vector<long> longs; - std::vector<short> shorts; - for (int i=0; i<12; i++) - { - longs.push_back(i); - shorts.push_back(i); - } - return 0; // Set breakpoint here to verify that std::vector 'longs' and 'shorts' have unique types. -} diff --git a/lldb/test/lang/cpp/unsigned_types/Makefile b/lldb/test/lang/cpp/unsigned_types/Makefile deleted file mode 100644 index 314f1cb2f077..000000000000 --- a/lldb/test/lang/cpp/unsigned_types/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/unsigned_types/TestUnsignedTypes.py b/lldb/test/lang/cpp/unsigned_types/TestUnsignedTypes.py deleted file mode 100644 index efa829c60e3f..000000000000 --- a/lldb/test/lang/cpp/unsigned_types/TestUnsignedTypes.py +++ /dev/null @@ -1,69 +0,0 @@ -""" -Test that variables with unsigned types display correctly. -""" - -import os, time -import re -import unittest2 -import lldb -from lldbtest import * - -class UnsignedTypesTestCase(TestBase): - - mydir = os.path.join("lang", "cpp", "unsigned_types") - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @dsym_test - def test_with_dsym(self): - """Test that variables with unsigned types display correctly.""" - self.buildDsym() - self.unsigned_types() - - @dwarf_test - def test_with_dwarf(self): - """Test that variables with unsigned types display correctly.""" - self.buildDwarf() - self.unsigned_types() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to break inside main(). - self.line = line_number('main.cpp', '// Set break point at this line.') - - def unsigned_types(self): - """Test that variables with unsigned types display correctly.""" - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # Break on line 19 in main() aftre the variables are assigned values. - self.expect("breakpoint set -f main.cpp -l %d" % self.line, - BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" % - self.line) - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', 'stop reason = breakpoint']) - - # The breakpoint should have a hit count of 1. - self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) - - # Test that unsigned types display correctly. - self.expect("frame variable -T -a", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "(unsigned char) the_unsigned_char = 'c'", - patterns = ["\((short unsigned int|unsigned short)\) the_unsigned_short = 99"], - substrs = ["(unsigned int) the_unsigned_int = 99", - "(unsigned long) the_unsigned_long = 99", - "(unsigned long long) the_unsigned_long_long = 99", - "(uint32_t) the_uint32 = 99"]) - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/lang/cpp/unsigned_types/main.cpp b/lldb/test/lang/cpp/unsigned_types/main.cpp deleted file mode 100644 index b0d68377e983..000000000000 --- a/lldb/test/lang/cpp/unsigned_types/main.cpp +++ /dev/null @@ -1,22 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -int main (int argc, char const *argv[]) -{ - typedef unsigned int uint32_t; - unsigned char the_unsigned_char = 'c'; - unsigned short the_unsigned_short = 'c'; - unsigned int the_unsigned_int = 'c'; - unsigned long the_unsigned_long = 'c'; - unsigned long long the_unsigned_long_long = 'c'; - uint32_t the_uint32 = 'c'; - - return the_unsigned_char - the_unsigned_short + // Set break point at this line. - the_unsigned_int - the_unsigned_long + - the_unsigned_long_long - the_uint32; -} diff --git a/lldb/test/lang/cpp/virtual/Makefile b/lldb/test/lang/cpp/virtual/Makefile deleted file mode 100644 index 314f1cb2f077..000000000000 --- a/lldb/test/lang/cpp/virtual/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/lang/cpp/virtual/TestVirtual.py b/lldb/test/lang/cpp/virtual/TestVirtual.py deleted file mode 100644 index 9ba7fd642c14..000000000000 --- a/lldb/test/lang/cpp/virtual/TestVirtual.py +++ /dev/null @@ -1,86 +0,0 @@ -""" -Test C++ virtual function and virtual inheritance. -""" - -import os, time -import re -import lldb -from lldbtest import * - -def Msg(expr, val): - return "'expression %s' matches the output (from compiled code): %s" % (expr, val) - -class CppVirtualMadness(TestBase): - - mydir = os.path.join("lang", "cpp", "virtual") - - # This is the pattern by design to match the "my_expr = 'value'" output from - # printf() stmts (see main.cpp). - pattern = re.compile("^([^=]*) = '([^=]*)'$") - - # Assert message. - PRINTF_OUTPUT_GROKKED = "The printf output from compiled code is parsed correctly" - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - def test_virtual_madness_dsym(self): - """Test that expression works correctly with virtual inheritance as well as virtual function.""" - self.buildDsym() - self.virtual_madness_test() - - def test_virtual_madness_dwarf(self): - """Test that expression works correctly with virtual inheritance as well as virtual function.""" - self.buildDwarf() - self.virtual_madness_test() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to break for main.cpp. - self.line = line_number('main.cpp', '// Set first breakpoint here.') - - def virtual_madness_test(self): - """Test that variable expressions with basic types are evaluated correctly.""" - - # First, capture the golden output emitted by the oracle, i.e., the - # series of printf statements. - go = system("./a.out", sender=self)[0] - # This golden list contains a list of "my_expr = 'value' pairs extracted - # from the golden output. - gl = [] - - # Scan the golden output line by line, looking for the pattern: - # - # my_expr = 'value' - # - for line in go.split(os.linesep): - match = self.pattern.search(line) - if match: - my_expr, val = match.group(1), match.group(2) - gl.append((my_expr, val)) - #print "golden list:", gl - - # Bring the program to the point where we can issue a series of - # 'expression' command to compare against the golden output. - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - self.runCmd("breakpoint set -f main.cpp -l %d" % self.line) - self.runCmd("run", RUN_SUCCEEDED) - - # Now iterate through the golden list, comparing against the output from - # 'expression var'. - for my_expr, val in gl: - # Don't overwhelm the expression mechanism. - # This slows down the test suite quite a bit, to enable it, define - # the environment variable LLDB_TYPES_EXPR_TIME_WAIT. For example: - # - # export LLDB_TYPES_EXPR_TIME_WAIT=0.5 - # - # causes a 0.5 second delay between 'expression' commands. - if "LLDB_TYPES_EXPR_TIME_WAIT" in os.environ: - time.sleep(float(os.environ["LLDB_TYPES_EXPR_TIME_WAIT"])) - - self.runCmd("expression %s" % my_expr) - output = self.res.GetOutput() - - # The expression output must match the oracle. - self.expect(output, Msg(my_expr, val), exe=False, - substrs = [val]) diff --git a/lldb/test/lang/cpp/virtual/main.cpp b/lldb/test/lang/cpp/virtual/main.cpp deleted file mode 100644 index 0c3d29202a7e..000000000000 --- a/lldb/test/lang/cpp/virtual/main.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include <stdio.h> -#include <stdint.h> - -class A -{ -public: - A () : m_pad ('c') {} - - virtual ~A () {} - - virtual const char * a() - { - return __PRETTY_FUNCTION__; - } - - virtual const char * b() - { - return __PRETTY_FUNCTION__; - } - - virtual const char * c() - { - return __PRETTY_FUNCTION__; - } -protected: - char m_pad; -}; - -class AA -{ -public: - AA () : m_pad('A') {} - virtual ~AA () {} - - virtual const char * aa() - { - return __PRETTY_FUNCTION__; - } - -protected: - char m_pad; -}; - -class B : virtual public A, public AA -{ -public: - B () : m_pad ('c') {} - - virtual ~B () {} - - virtual const char * a() - { - return __PRETTY_FUNCTION__; - } - - virtual const char * b() - { - return __PRETTY_FUNCTION__; - } -protected: - char m_pad; -}; - -class C : public B, virtual public A -{ -public: - C () : m_pad ('c') {} - - virtual ~C () {} - - virtual const char * a() - { - return __PRETTY_FUNCTION__; - } -protected: - char m_pad; -}; - -int main (int argc, char const *argv[], char const *envp[]) -{ - A *a_as_A = new A(); - B *b_as_B = new B(); - A *b_as_A = b_as_B; - C *c_as_C = new C(); - A *c_as_A = c_as_C; - - // Set first breakpoint here. - // then evaluate: - // expression a_as_A->a() - // expression a_as_A->b() - // expression a_as_A->c() - // expression b_as_A->a() - // expression b_as_A->b() - // expression b_as_A->c() - // expression b_as_B->aa() - // expression c_as_A->a() - // expression c_as_A->b() - // expression c_as_A->c() - // expression c_as_C->aa() - printf ("a_as_A->a() = '%s'\n", a_as_A->a()); - printf ("a_as_A->b() = '%s'\n", a_as_A->b()); - printf ("a_as_A->c() = '%s'\n", a_as_A->c()); - printf ("b_as_A->a() = '%s'\n", b_as_A->a()); - printf ("b_as_A->b() = '%s'\n", b_as_A->b()); - printf ("b_as_A->c() = '%s'\n", b_as_A->c()); - printf ("b_as_B->aa() = '%s'\n", b_as_B->aa()); - printf ("c_as_A->a() = '%s'\n", c_as_A->a()); - printf ("c_as_A->b() = '%s'\n", c_as_A->b()); - printf ("c_as_A->c() = '%s'\n", c_as_A->c()); - printf ("c_as_C->aa() = '%s'\n", c_as_C->aa()); - return 0; -} |
