2010-07-07 06:52:00 +08:00
|
|
|
"""
|
|
|
|
Test that breakpoint works correctly in the presence of dead-code stripping.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os, time
|
2010-08-06 07:42:46 +08:00
|
|
|
import unittest2
|
2010-07-07 06:52:00 +08:00
|
|
|
import lldb
|
2010-08-10 07:44:24 +08:00
|
|
|
from lldbtest import *
|
2010-07-07 06:52:00 +08:00
|
|
|
|
2010-09-02 03:59:58 +08:00
|
|
|
class DeadStripTestCase(TestBase):
|
2010-07-07 06:52:00 +08:00
|
|
|
|
|
|
|
mydir = "dead-strip"
|
|
|
|
|
2010-09-01 07:12:15 +08:00
|
|
|
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
|
|
|
|
def test_with_dsym(self):
|
|
|
|
"""Test breakpoint works correctly with dead-code stripping."""
|
|
|
|
self.buildDsym()
|
|
|
|
self.dead_strip()
|
|
|
|
|
|
|
|
def test_with_dwarf(self):
|
|
|
|
"""Test breakpoint works correctly with dead-code stripping."""
|
|
|
|
self.buildDwarf()
|
|
|
|
self.dead_strip()
|
|
|
|
|
|
|
|
def dead_strip(self):
|
2010-07-07 06:52:00 +08:00
|
|
|
"""Test breakpoint works correctly with dead-code stripping."""
|
|
|
|
exe = os.path.join(os.getcwd(), "a.out")
|
2010-08-21 01:04:20 +08:00
|
|
|
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
2010-07-07 06:52:00 +08:00
|
|
|
|
|
|
|
# Break by function name f1 (live code).
|
2010-08-21 01:04:20 +08:00
|
|
|
self.expect("breakpoint set -s a.out -n f1", BREAKPOINT_CREATED,
|
|
|
|
startstr = "Breakpoint created: 1: name = 'f1', module = a.out, locations = 1")
|
2010-07-07 06:52:00 +08:00
|
|
|
|
|
|
|
# Break by function name f2 (dead code).
|
2010-08-21 01:04:20 +08:00
|
|
|
self.expect("breakpoint set -s a.out -n f2", BREAKPOINT_PENDING_CREATED,
|
|
|
|
startstr = "Breakpoint created: 2: name = 'f2', module = a.out, locations = 0 (pending)")
|
2010-07-07 06:52:00 +08:00
|
|
|
|
|
|
|
# Break by function name f3 (live code).
|
2010-08-21 01:04:20 +08:00
|
|
|
self.expect("breakpoint set -s a.out -n f3", BREAKPOINT_CREATED,
|
|
|
|
startstr = "Breakpoint created: 3: name = 'f3', module = a.out, locations = 1")
|
2010-07-07 06:52:00 +08:00
|
|
|
|
2010-08-28 07:47:36 +08:00
|
|
|
self.runCmd("run", RUN_SUCCEEDED)
|
2010-07-07 06:52:00 +08:00
|
|
|
|
|
|
|
# The stop reason of the thread should be breakpoint (breakpoint #1).
|
2010-08-21 01:04:20 +08:00
|
|
|
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
2010-10-18 23:44:42 +08:00
|
|
|
substrs = ['state is stopped',
|
2010-09-03 06:25:47 +08:00
|
|
|
'a.out`f1',
|
2010-08-21 01:04:20 +08:00
|
|
|
'stop reason = breakpoint'])
|
2010-07-07 06:52:00 +08:00
|
|
|
|
|
|
|
# The breakpoint should have a hit count of 1.
|
2011-02-05 06:59:41 +08:00
|
|
|
self.expect("breakpoint list -f 1", BREAKPOINT_HIT_ONCE,
|
2010-08-21 01:04:20 +08:00
|
|
|
substrs = [' resolved, hit count = 1'])
|
2010-07-07 06:52:00 +08:00
|
|
|
|
2010-08-21 01:04:20 +08:00
|
|
|
self.runCmd("continue")
|
2010-07-07 06:52:00 +08:00
|
|
|
|
|
|
|
# The stop reason of the thread should be breakpoint (breakpoint #3).
|
2010-08-21 01:04:20 +08:00
|
|
|
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
2010-10-18 23:44:42 +08:00
|
|
|
substrs = ['state is stopped',
|
2010-09-03 06:25:47 +08:00
|
|
|
'a.out`f3',
|
2010-08-21 01:04:20 +08:00
|
|
|
'stop reason = breakpoint'])
|
2010-07-07 06:52:00 +08:00
|
|
|
|
|
|
|
# The breakpoint should have a hit count of 1.
|
2011-02-05 06:59:41 +08:00
|
|
|
self.expect("breakpoint list -f 3", BREAKPOINT_HIT_ONCE,
|
2010-08-21 01:04:20 +08:00
|
|
|
substrs = [' resolved, hit count = 1'])
|
2010-07-07 06:52:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2010-08-06 05:23:45 +08:00
|
|
|
import atexit
|
2010-07-07 06:52:00 +08:00
|
|
|
lldb.SBDebugger.Initialize()
|
2010-08-06 05:23:45 +08:00
|
|
|
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
2010-08-06 07:42:46 +08:00
|
|
|
unittest2.main()
|