diff options
author | Sean Callanan <scallanan@apple.com> | 2016-07-05 22:06:01 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2016-07-05 22:06:01 +0000 |
commit | 8ba1654d488398d56c4a1c7514fa70216af929d7 (patch) | |
tree | b3a1801339a6bffae385cc00771d374fba8c9776 /lldb/packages/Python/lldbsuite/test | |
parent | b395d7271d11ba9e0337fb18f617e6c21cfeae9c (diff) | |
download | bcm5719-llvm-8ba1654d488398d56c4a1c7514fa70216af929d7.tar.gz bcm5719-llvm-8ba1654d488398d56c4a1c7514fa70216af929d7.zip |
Fixed a bug where we report a single type multiple times in namespaces.
Also added a testcase.
<rdar://problem/22786569>
llvm-svn: 274580
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
8 files changed, 156 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile new file mode 100644 index 00000000000..0041add935a --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile @@ -0,0 +1,19 @@ +LEVEL := ../../../make + +LD_EXTRAS := -L. -l$(LIB_PREFIX)a -l$(LIB_PREFIX)b +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules + +.PHONY: +a.out: lib_a lib_b + +lib_%: + $(MAKE) -f $*.mk + +hidden_lib_d: + $(MAKE) -C hidden + +clean:: + $(MAKE) -f a.mk clean + $(MAKE) -f b.mk clean diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py new file mode 100644 index 00000000000..f4596942900 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py @@ -0,0 +1,57 @@ +"""Test that forward declarations don't cause bogus conflicts in namespaced types""" + +from __future__ import print_function + + + +import unittest2 +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + +class NamespaceDefinitionsTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def test_expr(self): + self.build() + self.common_setup() + + self.expect("expression -- Foo::MyClass()", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['thing = ']) + + 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 breakpoint here') + self.shlib_names = ["a", "b"] + + def common_setup(self): + # Run in synchronous mode + self.dbg.SetAsync(False) + + # Create a target by the debugger. + target = self.dbg.CreateTarget("a.out") + self.assertTrue(target, VALID_TARGET) + + # Break inside the foo function which takes a bar_ptr argument. + lldbutil.run_break_set_by_file_and_line (self, self.source, self.line, num_expected_locations=1, loc_exact=True) + + # Register our shared libraries for remote targets so they get automatically uploaded + environment = self.registerSharedLibrariesWithTarget(target, self.shlib_names) + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple (None, environment, self.get_process_working_directory()) + self.assertTrue(process, PROCESS_IS_VALID) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # The breakpoint should have a hit count of 1. + self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, + substrs = [' resolved, hit count = 1']) + diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp new file mode 100644 index 00000000000..2ea0d2df2ec --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp @@ -0,0 +1,16 @@ +//===-- a.cpp ---------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "foo.h" + +class ThingInside { + int a; +}; + +Foo::MyClass a_class; diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk new file mode 100644 index 00000000000..5943e5077c5 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk @@ -0,0 +1,9 @@ +LEVEL := ../../../make + +DYLIB_NAME := a +DYLIB_CXX_SOURCES := a.cpp +DYLIB_ONLY := YES + +CXXFLAGS += -fPIC + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp new file mode 100644 index 00000000000..6e7b41e0016 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp @@ -0,0 +1,12 @@ +//===-- b.cpp ---------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "foo.h" + +Foo::MyClass b_class; diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk new file mode 100644 index 00000000000..8ee2a13b129 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk @@ -0,0 +1,9 @@ +LEVEL := ../../../make + +DYLIB_NAME := b +DYLIB_CXX_SOURCES := b.cpp +DYLIB_ONLY := YES + +CXXFLAGS += -fPIC + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h new file mode 100644 index 00000000000..76b8e70880e --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h @@ -0,0 +1,18 @@ +//===-- foo.h ---------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +class ThingInside; + +namespace Foo { + class MyClass { + ThingInside *thing; + public: + MyClass() { } + }; +} diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp new file mode 100644 index 00000000000..076814eae1d --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp @@ -0,0 +1,16 @@ +//===-- 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> + +int +main (int argc, char const *argv[]) +{ + return 0; // Set breakpoint here +} |