[Lldb-commits] [lldb] r319443 - Add a test case for open bug 35480

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 30 11:26:10 PST 2017


This test actually almost succeeds on macOS.  The problem is that your breakpoint in the Foo constructor produces two line table entries so we hit the foo breakpoint twice.  If you change the test file to:

Index: packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp
===================================================================
--- packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp	(revision 319461)
+++ packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp	(working copy)
@@ -1,5 +1,7 @@
 #include "foo.h"
 
-Foo::Foo() : x(42) {} // !BR_foo
+Foo::Foo() : x(42) {
+    bool some_code = x == 42;  // !BR_foo
+} 
 
 Foo FooObj;

then there is only one location and we do hit that breakpoint and the test succeeds.

Jim

> On Nov 30, 2017, at 7:39 AM, Pavel Labath via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> Author: labath
> Date: Thu Nov 30 07:39:57 2017
> New Revision: 319443
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=319443&view=rev
> Log:
> Add a test case for open bug 35480
> 
> The test is about failing to hit breakpoints in global constructors in
> shared libraries.
> 
> Added:
>    lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/
>    lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile
>    lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
>    lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp
>    lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.h
>    lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/main.cpp
> 
> Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile?rev=319443&view=auto
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile (added)
> +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile Thu Nov 30 07:39:57 2017
> @@ -0,0 +1,8 @@
> +LEVEL = ../../../make
> +
> +DYLIB_NAME := foo
> +DYLIB_CXX_SOURCES := foo.cpp
> +CXX_SOURCES := main.cpp
> +CFLAGS_EXTRAS := -fPIC
> +
> +include $(LEVEL)/Makefile.rules
> 
> Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py?rev=319443&view=auto
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py (added)
> +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py Thu Nov 30 07:39:57 2017
> @@ -0,0 +1,46 @@
> +"""
> +Test that we can hit breakpoints in global constructors
> +"""
> +
> +from __future__ import print_function
> +
> +
> +import os
> +import lldb
> +from lldbsuite.test.decorators import *
> +from lldbsuite.test.lldbtest import *
> +from lldbsuite.test import lldbutil
> +
> +
> +class TestBreakpointInGlobalConstructors(TestBase):
> +
> +    mydir = TestBase.compute_mydir(__file__)
> +    NO_DEBUG_INFO_TESTCASE = True
> +
> +    def setUp(self):
> +        TestBase.setUp(self)
> +        self.line_foo = line_number('foo.cpp', '// !BR_foo')
> +        self.line_main = line_number('main.cpp', '// !BR_main')
> +
> +    @expectedFailureAll(bugnumber="llvm.org/pr35480", oslist=["linux"])
> +    def test(self):
> +        self.build()
> +        exe = os.path.join(os.getcwd(), "a.out")
> +        self.runCmd("file %s" % exe)
> +
> +        bp_main = lldbutil.run_break_set_by_file_and_line(
> +            self, 'main.cpp', self.line_main)
> +        bp_foo = lldbutil.run_break_set_by_file_and_line(
> +            self, 'foo.cpp', self.line_foo)
> +
> +        self.runCmd("run")
> +
> +        self.assertIsNotNone(
> +            lldbutil.get_one_thread_stopped_at_breakpoint_id(
> +                self.process(), bp_foo))
> +
> +        self.runCmd("continue")
> +
> +        self.assertIsNotNone(
> +            lldbutil.get_one_thread_stopped_at_breakpoint_id(
> +                self.process(), bp_main))
> 
> Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp?rev=319443&view=auto
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp (added)
> +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp Thu Nov 30 07:39:57 2017
> @@ -0,0 +1,5 @@
> +#include "foo.h"
> +
> +Foo::Foo() : x(42) {} // !BR_foo
> +
> +Foo FooObj;
> 
> Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.h?rev=319443&view=auto
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.h (added)
> +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.h Thu Nov 30 07:39:57 2017
> @@ -0,0 +1,11 @@
> +#ifndef FOO_H
> +#define FOO_H
> +
> +struct LLDB_TEST_API Foo {
> +  Foo();
> +  int x;
> +};
> +
> +extern LLDB_TEST_API Foo FooObj;
> +
> +#endif
> 
> Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/main.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/main.cpp?rev=319443&view=auto
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/main.cpp (added)
> +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/main.cpp Thu Nov 30 07:39:57 2017
> @@ -0,0 +1,12 @@
> +#include "foo.h"
> +
> +struct Main {
> +  Main();
> +  int x;
> +};
> +
> +Main::Main() : x(47) {} // !BR_main
> +
> +Main MainObj;
> +
> +int main() { return MainObj.x + FooObj.x; }
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits



More information about the lldb-commits mailing list