[Lldb-commits] [PATCH] D85903: [lldb] Fix a crash when tab-completion an empty line in a function with only one local variable
Raphael Isemann via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Aug 14 00:07:24 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbbe3c479a6ad: [lldb] Fix a crash when tab-completion an empty line in a function with only… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85903/new/
https://reviews.llvm.org/D85903
Files:
lldb/source/Host/common/Editline.cpp
lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
lldb/test/API/commands/expression/multiline-completion/main.c
Index: lldb/test/API/commands/expression/multiline-completion/main.c
===================================================================
--- lldb/test/API/commands/expression/multiline-completion/main.c
+++ lldb/test/API/commands/expression/multiline-completion/main.c
@@ -1,4 +1,11 @@
+int single_local_func() {
+ // This function should always only have a single local variable and no
+ // parameters.
+ int only_local = 3;
+ return only_local; // break in single_local_func
+}
+
int main(int argc, char **argv) {
int to_complete = 0;
- return to_complete;
+ return to_complete + single_local_func();
}
Index: lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
===================================================================
--- lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
+++ lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
@@ -11,6 +11,21 @@
mydir = TestBase.compute_mydir(__file__)
+ def start_expression_editor(self):
+ """ Starts the multiline expression editor. """
+ self.child.send("expression\n")
+ self.child.expect_exact("terminate with an empty line to evaluate")
+
+ def exit_expression_editor(self):
+ """ Exits the multiline expression editor. """
+ # Send a newline to finish the current line. The second newline will
+ # finish the new empty line which will exit the editor. The space at the
+ # start prevents that the first newline already exits the editor (in
+ # case the current line of the editor is already empty when this
+ # function is called).
+ self.child.send(" \n\n")
+ self.expect_prompt()
+
# PExpect uses many timeouts internally and doesn't play well
# under ASAN on a loaded machine..
@skipIfAsan
@@ -21,14 +36,23 @@
self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,500))
self.expect("b main", substrs=["Breakpoint 1", "address ="])
- self.expect("run", substrs=["stop reason ="])
+ self.expect("run", substrs=["stop reason = breakpoint 1"])
- self.child.sendline("expr")
- self.child.expect_exact("terminate with an empty line to evaluate")
+ self.start_expression_editor()
self.child.send("to_\t")
self.child.expect_exact("to_complete")
-
- self.child.send("\n\n")
- self.expect_prompt()
+ self.exit_expression_editor()
+
+ # Check that completion empty input in a function with only one
+ # local variable works.
+ self.expect("breakpoint set -p 'break in single_local_func'",
+ substrs=["Breakpoint 2"])
+ self.expect("continue", substrs=["stop reason = breakpoint 2"])
+ self.start_expression_editor()
+ self.child.send("\t")
+ # Only one local, so this will directly insert 'only_local' with a
+ # trailing space to signal a final completion.
+ self.child.expect_exact("only_local ")
+ self.exit_expression_editor()
self.quit()
Index: lldb/source/Host/common/Editline.cpp
===================================================================
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -1004,7 +1004,8 @@
case CompletionMode::Normal: {
std::string to_add = completion.GetCompletion();
to_add = to_add.substr(request.GetCursorArgumentPrefix().size());
- if (request.GetParsedArg().IsQuoted())
+ // Terminate the current argument with a quote if it started with a quote.
+ if (!request.GetParsedLine().empty() && request.GetParsedArg().IsQuoted())
to_add.push_back(request.GetParsedArg().GetQuoteChar());
to_add.push_back(' ');
el_insertstr(m_editline, to_add.c_str());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85903.285564.patch
Type: text/x-patch
Size: 3851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200814/54c7cc10/attachment-0001.bin>
More information about the lldb-commits
mailing list