summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/functionalities/unwind
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/unwind')
-rw-r--r--packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py17
-rw-r--r--packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c32
-rw-r--r--packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py26
-rw-r--r--packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py40
-rw-r--r--packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py78
5 files changed, 136 insertions, 57 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py
index e17d5d36d394..a855be7536ca 100644
--- a/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py
+++ b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py
@@ -5,20 +5,20 @@ Test that we can backtrace correctly from Non ABI functions on the stack
from __future__ import print_function
-
-import os, time
+import os
+import time
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class EHFrameBasedUnwind(TestBase):
mydir = TestBase.compute_mydir(__file__)
-
@skipUnlessPlatform(['linux'])
@skipIf(archs=["aarch64", "arm", "i386", "i686"])
- def test (self):
+ def test(self):
"""Test that we can backtrace correctly from Non ABI functions on the stack"""
self.build()
self.setTearDownCleanup()
@@ -28,9 +28,10 @@ class EHFrameBasedUnwind(TestBase):
self.assertTrue(target, VALID_TARGET)
- lldbutil.run_break_set_by_symbol (self, "func")
+ lldbutil.run_break_set_by_symbol(self, "func")
- process = target.LaunchSimple (["abc", "xyz"], None, self.get_process_working_directory())
+ process = target.LaunchSimple(
+ ["abc", "xyz"], None, self.get_process_working_directory())
if not process:
self.fail("SBTarget.Launch() failed")
@@ -42,10 +43,10 @@ class EHFrameBasedUnwind(TestBase):
stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
self.expect(stacktraces, exe=False,
- substrs = ['(int)argc=3'])
+ substrs=['(int)argc=3'])
self.runCmd("thread step-inst")
stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
self.expect(stacktraces, exe=False,
- substrs = ['(int)argc=3'])
+ substrs=['(int)argc=3'])
diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
index f62f7d814f38..ae8060124ab2 100644
--- a/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
+++ b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
@@ -1,4 +1,6 @@
void func() {
+
+#ifndef __mips__
__asm__ (
"pushq $0x10;"
".cfi_def_cfa_offset 16;"
@@ -10,11 +12,35 @@ void func() {
"movq $0x48, %rax;"
"popq %rax;"
);
-
+#elif __mips64
+ __asm__ (
+ "daddiu $sp,$sp,-16;"
+ ".cfi_def_cfa_offset 16;"
+ "sd $ra,8($sp);"
+ ".cfi_offset 31, -8;"
+ "daddiu $ra,$zero,0;"
+ "ld $ra,8($sp);"
+ "daddiu $sp, $sp,16;"
+ ".cfi_restore 31;"
+ ".cfi_def_cfa_offset 0;"
+ );
+#else
+ // For MIPS32
+ __asm__ (
+ "addiu $sp,$sp,-8;"
+ ".cfi_def_cfa_offset 8;"
+ "sw $ra,4($sp);"
+ ".cfi_offset 31, -4;"
+ "addiu $ra,$zero,0;"
+ "lw $ra,4($sp);"
+ "addiu $sp,$sp,8;"
+ ".cfi_restore 31;"
+ ".cfi_def_cfa_offset 0;"
+ );
+#endif
}
-
int main(int argc, char const *argv[])
{
func();
-} \ No newline at end of file
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
index 62c6c16080a3..5946f3ffa211 100644
--- a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
+++ b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
@@ -5,18 +5,20 @@ Test that we can backtrace correctly with 'noreturn' functions on the stack
from __future__ import print_function
-
-import os, time
+import os
+import time
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class NoreturnUnwind(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows # clang-cl does not support gcc style attributes.
- def test (self):
+ @skipIfWindows # clang-cl does not support gcc style attributes.
+ @expectedFailureAndroid(bugnumber="llvm.org/pr31192", archs=["x86_64"])
+ def test(self):
"""Test that we can backtrace correctly with 'noreturn' functions on the stack"""
self.build()
self.setTearDownCleanup()
@@ -25,7 +27,8 @@ class NoreturnUnwind(TestBase):
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
- process = target.LaunchSimple (None, None, self.get_process_working_directory())
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
if not process:
self.fail("SBTarget.Launch() failed")
@@ -55,22 +58,27 @@ class NoreturnUnwind(TestBase):
self.fail("Unable to find abort() in backtrace.")
func_c_frame_number = abort_frame_number + 1
- if thread.GetFrameAtIndex (func_c_frame_number).GetFunctionName() != "func_c":
+ if thread.GetFrameAtIndex(
+ func_c_frame_number).GetFunctionName() != "func_c":
self.fail("Did not find func_c() above abort().")
# This depends on whether we see the func_b inlined function in the backtrace
# or not. I'm not interested in testing that aspect of the backtrace here
# right now.
- if thread.GetFrameAtIndex (func_c_frame_number + 1).GetFunctionName() == "func_b":
+ if thread.GetFrameAtIndex(
+ func_c_frame_number +
+ 1).GetFunctionName() == "func_b":
func_a_frame_number = func_c_frame_number + 2
else:
func_a_frame_number = func_c_frame_number + 1
- if thread.GetFrameAtIndex (func_a_frame_number).GetFunctionName() != "func_a":
+ if thread.GetFrameAtIndex(
+ func_a_frame_number).GetFunctionName() != "func_a":
self.fail("Did not find func_a() above func_c().")
main_frame_number = func_a_frame_number + 1
- if thread.GetFrameAtIndex (main_frame_number).GetFunctionName() != "main":
+ if thread.GetFrameAtIndex(
+ main_frame_number).GetFunctionName() != "main":
self.fail("Did not find main() above func_a().")
diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py
index d2b36412f1f0..e35bb966c918 100644
--- a/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py
+++ b/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py
@@ -5,20 +5,21 @@ Test that we can backtrace correctly with 'sigtramp' functions on the stack
from __future__ import print_function
-
-import os, time
+import os
+import time
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
+
class SigtrampUnwind(TestBase):
mydir = TestBase.compute_mydir(__file__)
# On different platforms the "_sigtramp" and "__kill" frames are likely to be different.
# This test could probably be adapted to run on linux/*bsd easily enough.
@skipUnlessDarwin
- def test (self):
+ def test(self):
"""Test that we can backtrace correctly with _sigtramp on the stack"""
self.build()
self.setTearDownCleanup()
@@ -27,10 +28,11 @@ class SigtrampUnwind(TestBase):
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
+ lldbutil.run_break_set_by_file_and_line(self, "main.c", line_number(
+ 'main.c', '// Set breakpoint here'), num_expected_locations=1)
- lldbutil.run_break_set_by_file_and_line (self, "main.c", line_number('main.c', '// Set breakpoint here'), num_expected_locations=1)
-
- process = target.LaunchSimple (None, None, self.get_process_working_directory())
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
if not process:
self.fail("SBTarget.Launch() failed")
@@ -40,10 +42,20 @@ class SigtrampUnwind(TestBase):
"instead the actual state is: '%s'" %
lldbutil.state_type_to_str(process.GetState()))
- self.expect("pro handle -n false -p true -s false SIGUSR1", "Have lldb pass SIGUSR1 signals",
- substrs = ["SIGUSR1", "true", "false", "false"])
-
- lldbutil.run_break_set_by_symbol (self, "handler", num_expected_locations=1, module_name="a.out")
+ self.expect(
+ "pro handle -n false -p true -s false SIGUSR1",
+ "Have lldb pass SIGUSR1 signals",
+ substrs=[
+ "SIGUSR1",
+ "true",
+ "false",
+ "false"])
+
+ lldbutil.run_break_set_by_symbol(
+ self,
+ "handler",
+ num_expected_locations=1,
+ module_name="a.out")
self.runCmd("continue")
@@ -69,14 +81,14 @@ class SigtrampUnwind(TestBase):
for f in thread.frames:
print(" %d %s" % (f.GetFrameID(), f.GetFunctionName()))
- if found_handler == False:
+ if not found_handler:
self.fail("Unable to find handler() in backtrace.")
- if found_sigtramp == False:
+ if not found_sigtramp:
self.fail("Unable to find _sigtramp() in backtrace.")
- if found_kill == False:
+ if not found_kill:
self.fail("Unable to find kill() in backtrace.")
- if found_main == False:
+ if not found_main:
self.fail("Unable to find main() in backtrace.")
diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py
index 20532c6fc675..2416128d2efa 100644
--- a/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py
+++ b/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py
@@ -13,9 +13,9 @@ after escaping some special characters).
from __future__ import print_function
-
import unittest2
-import os, time
+import os
+import time
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
@@ -23,10 +23,11 @@ from lldbsuite.test import lldbutil
test_source_dirs = ["."]
+
class StandardUnwindTest(TestBase):
mydir = TestBase.compute_mydir(__file__)
- def standard_unwind_tests (self):
+ def standard_unwind_tests(self):
# The following variables have to be defined for each architecture and OS we testing for:
# base_function_names: List of function names where we accept that the stack unwinding is
# correct if they are on the stack. It should include the bottom most
@@ -36,20 +37,27 @@ class StandardUnwindTest(TestBase):
# instruction by instruction for any reason. (A valid reason is if
# it is impossible to step through a function instruction by
# instruction because it is special for some reason.) For these
- # functions we will immediately do a step-out when we hit them.
+ # functions we will immediately do a step-out when we hit them.
triple = self.dbg.GetSelectedPlatform().GetTriple()
if re.match("arm-.*-.*-android", triple):
base_function_names = [
"_start", # Base function on the stack
"__memcpy_base", # Function reached by a fall through from the previous function
- "__memcpy_base_aligned", # Function reached by a fall through from the previous function
+ "__memcpy_base_aligned",
+ # Function reached by a fall through from the previous function
]
no_step_function_names = [
- "__sync_fetch_and_add_4", # Calls into a special SO where we can't set a breakpoint
- "pthread_mutex_lock", # Uses ldrex and strex what interferes with the software single stepping
- "pthread_mutex_unlock", # Uses ldrex and strex what interferes with the software single stepping
- "pthread_once", # Uses ldrex and strex what interferes with the software single stepping
+ "__sync_fetch_and_add_4", # Calls into a special SO where we can't set a breakpoint
+ "pthread_mutex_lock",
+ # Uses ldrex and strex what interferes with the software single
+ # stepping
+ "pthread_mutex_unlock",
+ # Uses ldrex and strex what interferes with the software single
+ # stepping
+ "pthread_once",
+ # Uses ldrex and strex what interferes with the software single
+ # stepping
]
elif re.match("aarch64-.*-.*-android", triple):
base_function_names = [
@@ -57,11 +65,21 @@ class StandardUnwindTest(TestBase):
]
no_step_function_names = [
None,
- "__cxa_guard_acquire", # Uses ldxr and stxr what interferes with the software single stepping
- "__cxa_guard_release", # Uses ldxr and stxr what interferes with the software single stepping
- "pthread_mutex_lock", # Uses ldxr and stxr what interferes with the software single stepping
- "pthread_mutex_unlock", # Uses ldxr and stxr what interferes with the software single stepping
- "pthread_once", # Uses ldxr and stxr what interferes with the software single stepping
+ "__cxa_guard_acquire",
+ # Uses ldxr and stxr what interferes with the software single
+ # stepping
+ "__cxa_guard_release",
+ # Uses ldxr and stxr what interferes with the software single
+ # stepping
+ "pthread_mutex_lock",
+ # Uses ldxr and stxr what interferes with the software single
+ # stepping
+ "pthread_mutex_unlock",
+ # Uses ldxr and stxr what interferes with the software single
+ # stepping
+ "pthread_once",
+ # Uses ldxr and stxr what interferes with the software single
+ # stepping
]
else:
self.skipTest("No expectations for the current architecture")
@@ -72,17 +90,23 @@ class StandardUnwindTest(TestBase):
target.BreakpointCreateByName("main")
- process = target.LaunchSimple (None, None, self.get_process_working_directory())
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
self.assertTrue(process is not None, "SBTarget.Launch() failed")
- self.assertEqual(process.GetState(), lldb.eStateStopped, "The process didn't hit main")
+ self.assertEqual(
+ process.GetState(),
+ lldb.eStateStopped,
+ "The process didn't hit main")
index = 0
while process.GetState() == lldb.eStateStopped:
index += 1
if process.GetNumThreads() > 1:
# In case of a multi threaded inferior if one of the thread is stopped in a blocking
- # syscall and we try to step it then SBThread::StepInstruction() will block forever
- self.skipTest("Multi threaded inferiors are not supported by this test")
+ # syscall and we try to step it then
+ # SBThread::StepInstruction() will block forever
+ self.skipTest(
+ "Multi threaded inferiors are not supported by this test")
thread = process.GetThreadAtIndex(0)
@@ -97,9 +121,11 @@ class StandardUnwindTest(TestBase):
if f.GetFunctionName() in base_function_names:
found_main = True
break
- self.assertTrue(found_main, "Main function isn't found on the backtrace")
+ self.assertTrue(found_main,
+ "Main function isn't found on the backtrace")
- if thread.GetFrameAtIndex(0).GetFunctionName() in no_step_function_names:
+ if thread.GetFrameAtIndex(
+ 0).GetFunctionName() in no_step_function_names:
thread.StepOut()
else:
thread.StepInstruction(False)
@@ -113,13 +139,16 @@ for d in test_source_dirs:
dirname = os.path.join(os.path.dirname(__file__), d)
for root, _, files in os.walk(dirname):
- test_source_files = test_source_files | set(os.path.abspath(os.path.join(root, f)) for f in files)
+ test_source_files = test_source_files | set(
+ os.path.abspath(os.path.join(root, f)) for f in files)
# Generate test cases based on the collected source files
for f in test_source_files:
if f.endswith(".cpp") or f.endswith(".c"):
@add_test_categories(["dwarf"])
- @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test")
+ @unittest2.skipIf(
+ TestBase.skipLongRunningTest(),
+ "Skip this long running test")
def test_function_dwarf(self, f=f):
if f.endswith(".cpp"):
d = {'CXX_SOURCES': f}
@@ -143,4 +172,7 @@ for f in test_source_files:
test_name = test_name.replace(c, '_')
test_function_dwarf.__name__ = test_name
- setattr(StandardUnwindTest, test_function_dwarf.__name__, test_function_dwarf)
+ setattr(
+ StandardUnwindTest,
+ test_function_dwarf.__name__,
+ test_function_dwarf)