diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/macosx/order')
5 files changed, 104 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/macosx/order/Makefile b/packages/Python/lldbsuite/test/macosx/order/Makefile new file mode 100644 index 0000000..52fae2d --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/order/Makefile @@ -0,0 +1,7 @@ +LEVEL = ../../make + +C_SOURCES := main.c +LDFLAGS = $(CFLAGS) -Xlinker -order_file -Xlinker ./order-file +MAKE_DSYM := NO + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/macosx/order/TestOrderFile.py b/packages/Python/lldbsuite/test/macosx/order/TestOrderFile.py new file mode 100644 index 0000000..6541169 --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/order/TestOrderFile.py @@ -0,0 +1,36 @@ +""" +Test that debug symbols have the correct order as specified by the order file. +""" + +from __future__ import print_function + + + +import os, time +import re +import lldb +from lldbsuite.test.lldbtest import * + +class OrderFileTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessDarwin + def test(self): + """Test debug symbols follow the correct order by the order file.""" + self.build() + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Test that the debug symbols have Function f3 before Function f1. + # Use "-s address" option to sort by address. + self.runCmd("image dump symtab -s address a.out") + output = self.res.GetOutput() + mo_f3 = re.search("Code +.+f3", output) + mo_f1 = re.search("Code +.+f1", output) + + # Match objects for f3 and f1 must exist and f3 must come before f1. + self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(), + "Symbols have correct order by the order file") + + self.runCmd("run", RUN_COMPLETED) diff --git a/packages/Python/lldbsuite/test/macosx/order/cmds.txt b/packages/Python/lldbsuite/test/macosx/order/cmds.txt new file mode 100644 index 0000000..8c51dd7 --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/order/cmds.txt @@ -0,0 +1,3 @@ +b main.c:41 +c +lines -shlib a.out main.c diff --git a/packages/Python/lldbsuite/test/macosx/order/main.c b/packages/Python/lldbsuite/test/macosx/order/main.c new file mode 100644 index 0000000..cd1ea58 --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/order/main.c @@ -0,0 +1,54 @@ +//===-- 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 <stdio.h> + + +int f1 (char *s); +int f2 (char *s); +int f3 (char *s); + + +// We want f1 to start on line 20 +int f1 (char *s) +{ + return printf("f1: %s\n", s); +} + + + + + +// We want f2 to start on line 30 +int f2 (char *s) +{ + return printf("f2: %s\n", s); +} + + + + + +// We want f3 to start on line 40 +int f3 (char *s) +{ + return printf("f3: %s\n", s); +} + + + + + +// We want main to start on line 50 +int main (int argc, const char * argv[]) +{ + f1("carp"); + f2("ding"); + f3("dong"); + return 0; +} diff --git a/packages/Python/lldbsuite/test/macosx/order/order-file b/packages/Python/lldbsuite/test/macosx/order/order-file new file mode 100644 index 0000000..0cf8ecd --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/order/order-file @@ -0,0 +1,4 @@ +main.o:_f3 +main.o:_main +main.o:_f2 +main.o:_f1 |