1"""
2Test that the target.process.thread.max-backtrace-depth setting works.
3"""
4
5import unittest2
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class BacktraceLimitSettingTest(TestBase):
13
14    mydir = TestBase.compute_mydir(__file__)
15    NO_DEBUG_INFO_TESTCASE = True
16
17    def test_backtrace_depth(self):
18        """Test that the max-backtrace-depth setting limits backtraces."""
19        self.build()
20        self.main_source_file = lldb.SBFileSpec("main.cpp")
21        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
22                "Set a breakpoint here", self.main_source_file)
23        interp = self.dbg.GetCommandInterpreter()
24        result = lldb.SBCommandReturnObject()
25        interp.HandleCommand("settings set target.process.thread.max-backtrace-depth 30", result)
26        self.assertEqual(True, result.Succeeded())
27        self.assertEqual(30, thread.GetNumFrames())
28