From 78b9749c0a4ea980a8b934645da6ae98fcc665e8 Mon Sep 17 00:00:00 2001 From: dim Date: Wed, 6 Jan 2016 20:12:03 +0000 Subject: Vendor import of lldb trunk r256945: https://llvm.org/svn/llvm-project/lldb/trunk@256945 --- .../data-formatter/data-formatter-globals/Makefile | 5 ++ .../TestDataFormatterGlobals.py | 67 ++++++++++++++++++++++ .../data-formatter/data-formatter-globals/main.cpp | 27 +++++++++ 3 files changed, 99 insertions(+) create mode 100644 packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/Makefile create mode 100644 packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py create mode 100644 packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/main.cpp (limited to 'packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals') diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/Makefile new file mode 100644 index 0000000..314f1cb --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py new file mode 100644 index 0000000..df3bef0 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py @@ -0,0 +1,67 @@ +""" +Test lldb data formatter subsystem. +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + +class GlobalsDataFormatterTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + 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 test_with_run_command(self): + """Test that that file and class static variables display correctly.""" + self.build() + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + + # This is the function to remove the custom formats in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('type format clear', check=False) + self.runCmd('type summary clear', check=False) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + self.runCmd("type summary add --summary-string \"JustATest\" Point") + + # Simply check we can get at global variables + self.expect("target variable g_point", + substrs = ['JustATest']) + + self.expect("target variable g_point_pointer", + substrs = ['(Point *) g_point_pointer =']) + + # Print some information about the variables + # (we ignore the actual values) + self.runCmd("type summary add --summary-string \"(x=${var.x},y=${var.y})\" Point") + + self.expect("target variable g_point", + substrs = ['x=', + 'y=']) + + self.expect("target variable g_point_pointer", + substrs = ['(Point *) g_point_pointer =']) + + # Test Python code on resulting SBValue + self.runCmd("type summary add --python-script \"return 'x=' + str(valobj.GetChildMemberWithName('x').GetValue());\" Point") + + self.expect("target variable g_point", + substrs = ['x=']) + + self.expect("target variable g_point_pointer", + substrs = ['(Point *) g_point_pointer =']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/main.cpp new file mode 100644 index 0000000..521f7a6 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/main.cpp @@ -0,0 +1,27 @@ +//===-- 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 +#include +#include + +struct Point { + int x; + int y; + Point(int X = 3, int Y = 2) : x(X), y(Y) {} +}; + +Point g_point(3,4); +Point* g_point_pointer = new Point(7,5); + +int main (int argc, const char * argv[]) +{ + return 0; // Set break point at this line. +} + -- cgit v1.1