summaryrefslogtreecommitdiffstats
path: root/lldb/test/functionalities/inline-stepping
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-10-28 17:43:26 +0000
committerZachary Turner <zturner@google.com>2015-10-28 17:43:26 +0000
commitc432c8f856e0bd84de980a9d9bb2d31b06fa95b1 (patch)
tree4efa528e074a6e2df782345e4cd97f5d85d038c4 /lldb/test/functionalities/inline-stepping
parenta8a3bd210086b50242903ed95048fe5e53897878 (diff)
downloadbcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.tar.gz
bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.zip
Move lldb/test to lldb/packages/Python/lldbsuite/test.
This is the conclusion of an effort to get LLDB's Python code structured into a bona-fide Python package. This has a number of benefits, but most notably the ability to more easily share Python code between different but related pieces of LLDB's Python infrastructure (for example, `scripts` can now share code with `test`). llvm-svn: 251532
Diffstat (limited to 'lldb/test/functionalities/inline-stepping')
-rw-r--r--lldb/test/functionalities/inline-stepping/Makefile9
-rw-r--r--lldb/test/functionalities/inline-stepping/TestInlineStepping.py272
-rw-r--r--lldb/test/functionalities/inline-stepping/calling.cpp136
3 files changed, 0 insertions, 417 deletions
diff --git a/lldb/test/functionalities/inline-stepping/Makefile b/lldb/test/functionalities/inline-stepping/Makefile
deleted file mode 100644
index 532f49555e5..00000000000
--- a/lldb/test/functionalities/inline-stepping/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-LEVEL = ../../make
-
-CXX_SOURCES := calling.cpp
-
-ifneq (,$(findstring icc,$(CC)))
- CXXFLAGS += -debug inline-debug-info
-endif
-
-include $(LEVEL)/Makefile.rules
diff --git a/lldb/test/functionalities/inline-stepping/TestInlineStepping.py b/lldb/test/functionalities/inline-stepping/TestInlineStepping.py
deleted file mode 100644
index 70d92dcca6e..00000000000
--- a/lldb/test/functionalities/inline-stepping/TestInlineStepping.py
+++ /dev/null
@@ -1,272 +0,0 @@
-"""Test stepping over and into inlined functions."""
-
-from __future__ import print_function
-
-import use_lldb_suite
-
-import os, time, sys
-import lldb
-import lldbutil
-from lldbtest import *
-
-class TestInlineStepping(TestBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- @add_test_categories(['pyapi'])
- @expectedFailureFreeBSD('llvm.org/pr17214')
- @expectedFailureIcc # Not really a bug. ICC combines two inlined functions.
- @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", compiler_version=[">=","4.9"], archs=["i386"])
- @expectedFailureWindows("llvm.org/pr24778")
- # failed 1/365 dosep runs, (i386-clang), TestInlineStepping.py:237 failed to stop at first breakpoint in main
- @expectedFailureAll(oslist=["linux"], archs=["i386"])
- def test_with_python_api(self):
- """Test stepping over and into inlined functions."""
- self.build()
- self.inline_stepping()
-
- @add_test_categories(['pyapi'])
- @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", compiler_version=[">=","4.9"], archs=["i386"])
- def test_step_over_with_python_api(self):
- """Test stepping over and into inlined functions."""
- self.build()
- self.inline_stepping_step_over()
-
- @add_test_categories(['pyapi'])
- def test_step_in_template_with_python_api(self):
- """Test stepping in to templated functions."""
- self.build()
- self.step_in_template()
-
- def setUp(self):
- # Call super's setUp().
- TestBase.setUp(self)
- # Find the line numbers that we will step to in main:
- self.main_source = "calling.cpp"
- self.source_lines = {}
- functions = ['caller_ref_1', 'caller_ref_2', 'inline_ref_1', 'inline_ref_2', 'called_by_inline_ref', 'caller_trivial_1', 'caller_trivial_2', 'inline_trivial_1', 'inline_trivial_2', 'called_by_inline_trivial' ]
- for name in functions:
- self.source_lines[name] = line_number(self.main_source, "// In " + name + ".")
- self.main_source_spec = lldb.SBFileSpec (self.main_source)
-
- def do_step(self, step_type, destination_line_entry, test_stack_depth):
- expected_stack_depth = self.thread.GetNumFrames()
- if step_type == "into":
- expected_stack_depth += 1
- self.thread.StepInto()
- elif step_type == "out":
- expected_stack_depth -= 1
- self.thread.StepOut()
- elif step_type == "over":
- self.thread.StepOver()
- else:
- self.fail ("Unrecognized step type: " + step_type)
-
- threads = lldbutil.get_stopped_threads (self.process, lldb.eStopReasonPlanComplete)
- if len(threads) != 1:
- destination_description = lldb.SBStream()
- destination_line_entry.GetDescription(destination_description)
- self.fail ("Failed to stop due to step " + step_type + " operation stepping to: " + destination_description.GetData())
-
- self.thread = threads[0]
-
- stop_line_entry = self.thread.GetFrameAtIndex(0).GetLineEntry()
- self.assertTrue (stop_line_entry.IsValid(), "Stop line entry was not valid.")
-
- # Don't use the line entry equal operator because we don't care about the column number.
- stop_at_right_place = (stop_line_entry.GetFileSpec() == destination_line_entry.GetFileSpec() and stop_line_entry.GetLine() == destination_line_entry.GetLine())
- if stop_at_right_place == False:
- destination_description = lldb.SBStream()
- destination_line_entry.GetDescription(destination_description)
-
- actual_description = lldb.SBStream()
- stop_line_entry.GetDescription(actual_description)
-
- self.fail ("Step " + step_type + " stopped at wrong place: expected: " + destination_description.GetData() + " got: " + actual_description.GetData() + ".")
-
- real_stack_depth = self.thread.GetNumFrames()
-
- if test_stack_depth and real_stack_depth != expected_stack_depth:
- destination_description = lldb.SBStream()
- destination_line_entry.GetDescription(destination_description)
- self.fail ("Step %s to %s got wrong number of frames, should be: %d was: %d."%(step_type, destination_description.GetData(), expected_stack_depth, real_stack_depth))
-
- def run_step_sequence(self, step_sequence):
- """This function takes a list of duples instructing how to run the program. The first element in each duple is
- a source pattern for the target location, and the second is the operation that will take you from the current
- source location to the target location. It will then run all the steps in the sequence.
- It will check that you arrived at the expected source location at each step, and that the stack depth changed
- correctly for the operation in the sequence."""
-
- target_line_entry = lldb.SBLineEntry()
- target_line_entry.SetFileSpec(self.main_source_spec)
-
- test_stack_depth = True
- # Work around for <rdar://problem/16363195>, the darwin unwinder seems flakey about whether it duplicates the first frame
- # or not, which makes counting stack depth unreliable.
- if self.platformIsDarwin():
- test_stack_depth = False
-
- for step_pattern in step_sequence:
- step_stop_line = line_number (self.main_source, step_pattern[0])
- target_line_entry.SetLine(step_stop_line)
- self.do_step (step_pattern[1], target_line_entry, test_stack_depth)
-
- def inline_stepping(self):
- """Use Python APIs to test stepping over and hitting breakpoints."""
- exe = os.path.join(os.getcwd(), "a.out")
-
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- break_1_in_main = target.BreakpointCreateBySourceRegex ('// Stop here and step over to set up stepping over.', self.main_source_spec)
- self.assertTrue(break_1_in_main, VALID_BREAKPOINT)
-
- # Now launch the process, and do not stop at entry point.
- self.process = target.LaunchSimple (None, None, self.get_process_working_directory())
-
- self.assertTrue(self.process, PROCESS_IS_VALID)
-
- # The stop reason of the thread should be breakpoint.
- threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, break_1_in_main)
-
- if len(threads) != 1:
- self.fail ("Failed to stop at first breakpoint in main.")
-
- self.thread = threads[0]
-
- # Step over the inline_value = 0 line to get us to inline_trivial_1 called from main. Doing it this way works
- # around a bug in lldb where the breakpoint on the containing line of an inlined function with no return value
- # gets set past the insertion line in the function.
- # Then test stepping over a simple inlined function. Note, to test all the parts of the inlined stepping
- # the calls inline_stepping_1 and inline_stepping_2 should line up at the same address, that way we will test
- # the "virtual" stepping.
- # FIXME: Put in a check to see if that is true and warn if it is not.
-
- step_sequence = [["// At inline_trivial_1 called from main.", "over"],
- ["// At first call of caller_trivial_1 in main.", "over"]]
- self.run_step_sequence(step_sequence)
-
- # Now step from caller_ref_1 all the way into called_by_inline_trivial
-
- step_sequence = [["// In caller_trivial_1.", "into"],
- ["// In caller_trivial_2.", "into"],
- ["// In inline_trivial_1.", "into"],
- ["// In inline_trivial_2.", "into"],
- ["// At caller_by_inline_trivial in inline_trivial_2.", "over"],
- ["// In called_by_inline_trivial.", "into"]]
- self.run_step_sequence(step_sequence)
-
- # Now run to the inline_trivial_1 just before the immediate step into inline_trivial_2:
-
- break_2_in_main = target.BreakpointCreateBySourceRegex ('// At second call of caller_trivial_1 in main.', self.main_source_spec)
- self.assertTrue(break_2_in_main, VALID_BREAKPOINT)
-
- threads = lldbutil.continue_to_breakpoint (self.process, break_2_in_main)
- self.assertTrue (len(threads) == 1, "Successfully ran to call site of second caller_trivial_1 call.")
- self.thread = threads[0]
-
- step_sequence = [["// In caller_trivial_1.", "into"],
- ["// In caller_trivial_2.", "into"],
- ["// In inline_trivial_1.", "into"]]
- self.run_step_sequence(step_sequence)
-
- # Then call some trivial function, and make sure we end up back where we were in the inlined call stack:
-
- frame = self.thread.GetFrameAtIndex(0)
- before_line_entry = frame.GetLineEntry()
- value = frame.EvaluateExpression ("function_to_call()")
- after_line_entry = frame.GetLineEntry()
-
- self.assertTrue (before_line_entry.GetLine() == after_line_entry.GetLine(), "Line entry before and after function calls are the same.")
-
- # Now make sure stepping OVER in the middle of the stack works, and then check finish from the inlined frame:
-
- step_sequence = [["// At increment in inline_trivial_1.", "over"],
- ["// At increment in caller_trivial_2.", "out"]]
- self.run_step_sequence(step_sequence)
-
-
- # Now run to the place in main just before the first call to caller_ref_1:
-
- break_3_in_main = target.BreakpointCreateBySourceRegex ('// At first call of caller_ref_1 in main.', self.main_source_spec)
- self.assertTrue(break_3_in_main, VALID_BREAKPOINT)
-
- threads = lldbutil.continue_to_breakpoint (self.process, break_3_in_main)
- self.assertTrue (len(threads) == 1, "Successfully ran to call site of first caller_ref_1 call.")
- self.thread = threads[0]
-
- step_sequence = [["// In caller_ref_1.", "into"],
- ["// In caller_ref_2.", "into"],
- ["// In inline_ref_1.", "into"],
- ["// In inline_ref_2.", "into"],
- ["// In called_by_inline_ref.", "into"],
- ["// In inline_ref_2.", "out"],
- ["// In inline_ref_1.", "out"],
- ["// At increment in inline_ref_1.", "over"],
- ["// In caller_ref_2.", "out"],
- ["// At increment in caller_ref_2.", "over"]]
- self.run_step_sequence (step_sequence)
-
- def inline_stepping_step_over(self):
- """Use Python APIs to test stepping over and hitting breakpoints."""
- exe = os.path.join(os.getcwd(), "a.out")
-
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- break_1_in_main = target.BreakpointCreateBySourceRegex ('// At second call of caller_ref_1 in main.', self.main_source_spec)
- self.assertTrue(break_1_in_main, VALID_BREAKPOINT)
-
- # Now launch the process, and do not stop at entry point.
- self.process = target.LaunchSimple (None, None, self.get_process_working_directory())
-
- self.assertTrue(self.process, PROCESS_IS_VALID)
-
- # The stop reason of the thread should be breakpoint.
- threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, break_1_in_main)
-
- if len(threads) != 1:
- self.fail ("Failed to stop at first breakpoint in main.")
-
- self.thread = threads[0]
-
- step_sequence = [["// In caller_ref_1.", "into"],
- ["// In caller_ref_2.", "into"],
- ["// At increment in caller_ref_2.", "over"]]
- self.run_step_sequence (step_sequence)
-
- def step_in_template(self):
- """Use Python APIs to test stepping in to templated functions."""
- exe = os.path.join(os.getcwd(), "a.out")
-
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- break_1_in_main = target.BreakpointCreateBySourceRegex ('// Call max_value template', self.main_source_spec)
- self.assertTrue(break_1_in_main, VALID_BREAKPOINT)
-
- break_2_in_main = target.BreakpointCreateBySourceRegex ('// Call max_value specialized', self.main_source_spec)
- self.assertTrue(break_2_in_main, VALID_BREAKPOINT)
-
- # Now launch the process, and do not stop at entry point.
- self.process = target.LaunchSimple (None, None, self.get_process_working_directory())
- self.assertTrue(self.process, PROCESS_IS_VALID)
-
- # The stop reason of the thread should be breakpoint.
- threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, break_1_in_main)
-
- if len(threads) != 1:
- self.fail ("Failed to stop at first breakpoint in main.")
-
- self.thread = threads[0]
-
- step_sequence = [["// In max_value template", "into"]]
- self.run_step_sequence(step_sequence)
-
- threads = lldbutil.continue_to_breakpoint (self.process, break_2_in_main)
- self.assertEqual(len(threads), 1, "Successfully ran to call site of second caller_trivial_1 call.")
- self.thread = threads[0]
-
- step_sequence = [["// In max_value specialized", "into"]]
- self.run_step_sequence(step_sequence)
diff --git a/lldb/test/functionalities/inline-stepping/calling.cpp b/lldb/test/functionalities/inline-stepping/calling.cpp
deleted file mode 100644
index 9982fbf4273..00000000000
--- a/lldb/test/functionalities/inline-stepping/calling.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-#include <algorithm>
-#include <cstdio>
-#include <string>
-
-inline int inline_ref_1 (int &value) __attribute__((always_inline));
-inline int inline_ref_2 (int &value) __attribute__((always_inline));
-
-int caller_ref_1 (int &value);
-int caller_ref_2 (int &value);
-
-int called_by_inline_ref (int &value);
-
-inline void inline_trivial_1 () __attribute__((always_inline));
-inline void inline_trivial_2 () __attribute__((always_inline));
-
-void caller_trivial_1 ();
-void caller_trivial_2 ();
-
-void called_by_inline_trivial ();
-
-static int inline_value;
-
-int
-function_to_call ()
-{
- return inline_value;
-}
-
-int
-caller_ref_1 (int &value)
-{
- int increment = caller_ref_2(value); // In caller_ref_1.
- value += increment; // At increment in caller_ref_1.
- return value;
-}
-
-int
-caller_ref_2 (int &value)
-{
- int increment = inline_ref_1 (value); // In caller_ref_2.
- value += increment; // At increment in caller_ref_2.
- return value;
-}
-
-int
-called_by_inline_ref (int &value)
-{
- value += 1; // In called_by_inline_ref.
- return value;
-}
-
-int
-inline_ref_1 (int &value)
-{
- int increment = inline_ref_2(value); // In inline_ref_1.
- value += increment; // At increment in inline_ref_1.
- return value;
-}
-
-int
-inline_ref_2 (int &value)
-{
- int increment = called_by_inline_ref (value); // In inline_ref_2.
- value += 1; // At increment in inline_ref_2.
- return value;
-}
-
-void
-caller_trivial_1 ()
-{
- caller_trivial_2(); // In caller_trivial_1.
- inline_value += 1;
-}
-
-void
-caller_trivial_2 ()
-{
- inline_trivial_1 (); // In caller_trivial_2.
- inline_value += 1; // At increment in caller_trivial_2.
-}
-
-void
-called_by_inline_trivial ()
-{
- inline_value += 1; // In called_by_inline_trivial.
-}
-
-void
-inline_trivial_1 ()
-{
- inline_trivial_2(); // In inline_trivial_1.
- inline_value += 1; // At increment in inline_trivial_1.
-}
-
-void
-inline_trivial_2 ()
-{
- inline_value += 1; // In inline_trivial_2.
- called_by_inline_trivial (); // At caller_by_inline_trivial in inline_trivial_2.
-}
-
-template<typename T> T
-max_value(const T& lhs, const T& rhs)
-{
- return std::max(lhs, rhs); // In max_value template
-}
-
-template<> std::string
-max_value(const std::string& lhs, const std::string& rhs)
-{
- return (lhs.size() > rhs.size()) ? lhs : rhs; // In max_value specialized
-}
-
-int
-main (int argc, char **argv)
-{
-
- inline_value = 0; // Stop here and step over to set up stepping over.
-
- inline_trivial_1 (); // At inline_trivial_1 called from main.
-
- caller_trivial_1(); // At first call of caller_trivial_1 in main.
-
- caller_trivial_1(); // At second call of caller_trivial_1 in main.
-
- caller_ref_1 (argc); // At first call of caller_ref_1 in main.
-
- caller_ref_1 (argc); // At second call of caller_ref_1 in main.
-
- function_to_call (); // Make sure debug info for this function gets generated.
-
- max_value(123, 456); // Call max_value template
- max_value(std::string("abc"), std::string("0022")); // Call max_value specialized
-
- return 0; // About to return from main.
-}
OpenPOWER on IntegriCloud