Skip to content

Commit ae72cc2

Browse files
labathJDevlieghere
authored andcommitted
[lldb] Fix ^C handling in IOHandlerProcessSTDIO
D120762 accidentally moved the interrupt check into the block which was reading stdio. This meant that a ^C only took effect after a regular character has been pressed. This patch fixes that and adds a (pexpect) test. Differential revision: https://reviews.llvm.org/D121912 (cherry picked from commit f93d861)
1 parent b65cf35 commit ae72cc2

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include Makefile.rules
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
Test sending SIGINT Process IOHandler
3+
"""
4+
5+
import os
6+
7+
import lldb
8+
from lldbsuite.test.decorators import *
9+
from lldbsuite.test.lldbtest import *
10+
from lldbsuite.test.lldbpexpect import PExpectTest
11+
12+
class TestCase(PExpectTest):
13+
14+
mydir = TestBase.compute_mydir(__file__)
15+
16+
def test(self):
17+
self.build(dictionary={"CXX_SOURCES":"cat.cpp"})
18+
self.launch(executable=self.getBuildArtifact(), timeout=5)
19+
20+
self.child.sendline("process launch")
21+
self.child.expect("Process .* launched")
22+
23+
self.child.sendline("Hello cat")
24+
self.child.expect_exact("read: Hello cat")
25+
26+
self.child.sendintr()
27+
self.child.expect("Process .* stopped")
28+
self.expect_prompt()
29+
30+
self.expect("bt", substrs=["input_copy_loop"])
31+
32+
self.child.sendline("continue")
33+
self.child.expect("Process .* resuming")
34+
35+
self.child.sendline("Goodbye cat")
36+
self.child.expect_exact("read: Goodbye cat")
37+
38+
self.child.sendeof()
39+
self.child.expect("Process .* exited")
40+
self.expect_prompt()
41+
42+
self.quit()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <iostream>
2+
3+
void input_copy_loop() {
4+
std::string str;
5+
while (std::getline(std::cin, str))
6+
std::cout << "read: " << str << std::endl;
7+
}
8+
9+
int main() {
10+
input_copy_loop();
11+
return 0;
12+
}

0 commit comments

Comments
 (0)