2010-07-07 06:52:00 +08:00
|
|
|
"""
|
|
|
|
Test that breakpoint works correctly in the presence of dead-code stripping.
|
|
|
|
"""
|
|
|
|
|
2015-10-24 01:04:29 +08:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2015-11-04 03:20:39 +08:00
|
|
|
|
2015-10-23 04:06:20 +08:00
|
|
|
|
2010-07-07 06:52:00 +08:00
|
|
|
import os, time
|
|
|
|
import lldb
|
2015-11-03 10:06:18 +08:00
|
|
|
from lldbsuite.test.lldbtest import *
|
|
|
|
import lldbsuite.test.lldbutil as lldbutil
|
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
|
|
|
|
2013-12-11 07:19:29 +08:00
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
2010-07-07 06:52:00 +08:00
|
|
|
|
2015-09-12 04:01:24 +08:00
|
|
|
@expectedFailureWindows("llvm.org/pr24778")
|
2015-10-07 18:02:17 +08:00
|
|
|
@expectedFailureDwo("llvm.org/pr25087")
|
2013-07-26 00:53:38 +08:00
|
|
|
@skipIfFreeBSD # The -dead_strip linker option isn't supported on FreeBSD versions of ld.
|
2015-09-30 18:12:40 +08:00
|
|
|
def test(self):
|
2010-07-07 06:52:00 +08:00
|
|
|
"""Test breakpoint works correctly with dead-code stripping."""
|
2015-09-30 18:12:40 +08:00
|
|
|
self.build()
|
2010-07-07 06:52:00 +08:00
|
|
|
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).
|
2013-01-08 08:01:36 +08:00
|
|
|
lldbutil.run_break_set_by_symbol (self, "f1", num_expected_locations=1, module_name="a.out")
|
2010-07-07 06:52:00 +08:00
|
|
|
|
|
|
|
# Break by function name f2 (dead code).
|
2013-01-08 08:01:36 +08:00
|
|
|
lldbutil.run_break_set_by_symbol (self, "f2", num_expected_locations=0, module_name="a.out")
|
2010-07-07 06:52:00 +08:00
|
|
|
|
|
|
|
# Break by function name f3 (live code).
|
2013-01-08 08:01:36 +08:00
|
|
|
lldbutil.run_break_set_by_symbol (self, "f3", num_expected_locations=1, module_name="a.out")
|
2010-07-07 06:52:00 +08:00
|
|
|
|
2015-07-02 07:56:30 +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,
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
substrs = ['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,
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
substrs = ['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'])
|