Skip to content

Commit a0ba821

Browse files
committed
Add test case that capture's the llvm-mingw hello-exeception.cpp
test failure with this change in breakpoint behavior.
1 parent 0d51d68 commit a0ba821

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
C_SOURCES := main.c
2+
3+
include Makefile.rules
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
Test finish out of an empty function (may be one-instruction long)
3+
"""
4+
5+
import lldb
6+
from lldbsuite.test.decorators import *
7+
from lldbsuite.test.lldbtest import *
8+
from lldbsuite.test import lldbutil
9+
10+
11+
class FinishFromEmptyFunctionTestCase(TestBase):
12+
NO_DEBUG_INFO_TESTCASE = True
13+
14+
def test_finish_from_empty_function(self):
15+
"""Test that when stopped at a breakpoint in an empty function, finish leaves it correctly."""
16+
self.build()
17+
exe = self.getBuildArtifact("a.out")
18+
target, process, thread, _ = lldbutil.run_to_name_breakpoint(
19+
self, "done", exe_name=exe
20+
)
21+
if self.TraceOn():
22+
self.runCmd("bt")
23+
24+
correct_stepped_out_line = line_number("main.c", "leaving main")
25+
return_statement_line = line_number("main.c", "return 0")
26+
safety_bp = target.BreakpointCreateByLocation(
27+
lldb.SBFileSpec("main.c"), return_statement_line
28+
)
29+
self.assertTrue(safety_bp.IsValid())
30+
31+
error = lldb.SBError()
32+
thread.StepOut(error)
33+
self.assertTrue(error.Success())
34+
35+
if self.TraceOn():
36+
self.runCmd("bt")
37+
38+
frame = thread.GetSelectedFrame()
39+
self.assertEqual(
40+
frame.line_entry.GetLine(),
41+
correct_stepped_out_line,
42+
"Step-out lost control of execution, ran too far",
43+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdio.h>
2+
void done() { }
3+
int main() {
4+
puts ("in main");
5+
done();
6+
puts ("leaving main");
7+
return 0;
8+
}

0 commit comments

Comments
 (0)