Skip to content

Commit d59f304

Browse files
committed
Merge remote-tracking branch 'llvm/master' into upstream-with-swift
apple-llvm-split-commit: ae0a6306d6cfeddfc112ba3a6b15477432446bed apple-llvm-split-dir: lldb/
2 parents daae2aa + e010f6b commit d59f304

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
LEVEL = ../../make
2+
C_SOURCES := main.c
3+
include $(LEVEL)/Makefile.rules
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""
2+
Test completion for multiline expressions.
3+
"""
4+
5+
import lldb
6+
from lldbsuite.test.decorators import *
7+
from lldbsuite.test.lldbtest import *
8+
9+
class MultilineCompletionTest(TestBase):
10+
11+
mydir = TestBase.compute_mydir(__file__)
12+
NO_DEBUG_INFO_TESTCASE = True
13+
14+
def setUp(self):
15+
TestBase.setUp(self)
16+
self.source = 'main.c'
17+
18+
def expect_string(self, string):
19+
import pexpect
20+
"""This expects for "string", with timeout & EOF being test fails."""
21+
try:
22+
self.child.expect_exact(string)
23+
except pexpect.EOF:
24+
self.fail("Got EOF waiting for '%s'" % (string))
25+
except pexpect.TIMEOUT:
26+
self.fail("Timed out waiting for '%s'" % (string))
27+
28+
@expectedFailureAll(
29+
oslist=["windows"],
30+
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
31+
def test_basic_completion(self):
32+
"""Test that we can complete a simple multiline expression"""
33+
self.build()
34+
self.setTearDownCleanup()
35+
36+
import pexpect
37+
exe = self.getBuildArtifact("a.out")
38+
prompt = "(lldb) "
39+
40+
run_commands = ' -o "b main" -o "r"'
41+
self.child = pexpect.spawn(
42+
'%s %s %s %s' %
43+
(lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
44+
child = self.child
45+
46+
self.expect_string(prompt)
47+
self.child.sendline("expr")
48+
self.expect_string("terminate with an empty line to evaluate")
49+
self.child.send("to_\t")
50+
self.expect_string("to_complete")
51+
52+
self.deletePexpectChild()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
int main(int argc, char **argv) {
2+
lldb_enable_attach();
3+
int to_complete = 0;
4+
return to_complete;
5+
}

lldb/source/Core/IOHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ int IOHandlerDelegate::IOHandlerComplete(
233233
matches, descriptions);
234234
case Completion::Expression: {
235235
CompletionResult result;
236-
CompletionRequest request(current_line, current_line - cursor,
236+
CompletionRequest request(current_line, cursor - current_line,
237237
skip_first_n_matches, max_matches, result);
238238
CommandCompletions::InvokeCommonCompletionCallbacks(
239239
io_handler.GetDebugger().GetCommandInterpreter(),

0 commit comments

Comments
 (0)