[Lldb-commits] [PATCH] D154413: [lldb] Fix crash when completing register names after program exit
David Spickett via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 4 03:03:31 PDT 2023
DavidSpickett updated this revision to Diff 537021.
DavidSpickett added a comment.
Added register info to the x86 test cases.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154413/new/
https://reviews.llvm.org/D154413
Files:
lldb/source/Commands/CommandCompletions.cpp
lldb/test/API/functionalities/completion/TestCompletion.py
Index: lldb/test/API/functionalities/completion/TestCompletion.py
===================================================================
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -736,13 +736,25 @@
self.runCmd("type synthetic add -x Hoo -l test")
self.complete_from_to("type synthetic delete ", ["Hoo"])
- @skipIf(archs=no_match(["x86_64"]))
- def test_register_read_and_write_on_x86(self):
- """Test the completion of the commands register read and write on x86"""
-
+ def test_register_no_complete(self):
# The tab completion for "register read/write" won't work without a running process.
self.complete_from_to("register read ", "register read ")
self.complete_from_to("register write ", "register write ")
+ self.complete_from_to("register info ", "register info ")
+
+ self.build()
+ self.runCmd("target create {}".format(self.getBuildArtifact("a.out")))
+ self.runCmd("run")
+
+ # Once a program has finished you have an execution context but no register
+ # context so completion cannot work.
+ self.complete_from_to("register read ", "register read ")
+ self.complete_from_to("register write ", "register write ")
+ self.complete_from_to("register info ", "register info ")
+
+ @skipIf(archs=no_match(["x86_64"]))
+ def test_register_read_and_write_on_x86(self):
+ """Test the completion of the commands register read and write on x86"""
self.build()
self.main_source_spec = lldb.SBFileSpec("main.cpp")
@@ -768,6 +780,14 @@
# register write can only take exact one register name as argument
self.complete_from_to("register write rbx ", [])
+ # test cases for register info
+ self.complete_from_to("register info ", ["rax", "rbx", "rcx"])
+ self.complete_from_to("register info r", ["rax", "rbx", "rcx"])
+ self.complete_from_to("register info ra", "register info rax")
+ self.complete_from_to("register info rb", ["rbx", "rbp"])
+ # register info can only take exact one register name as argument
+ self.complete_from_to("register info rbx ", [])
+
def test_common_completion_target_stophook_ids(self):
subcommands = ["delete", "enable", "disable"]
Index: lldb/source/Commands/CommandCompletions.cpp
===================================================================
--- lldb/source/Commands/CommandCompletions.cpp
+++ lldb/source/Commands/CommandCompletions.cpp
@@ -611,6 +611,9 @@
RegisterContext *reg_ctx =
interpreter.GetExecutionContext().GetRegisterContext();
+ if (!reg_ctx)
+ return;
+
const size_t reg_num = reg_ctx->GetRegisterCount();
for (size_t reg_idx = 0; reg_idx < reg_num; ++reg_idx) {
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_idx);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154413.537021.patch
Type: text/x-patch
Size: 2941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230704/e1e87d6f/attachment.bin>
More information about the lldb-commits
mailing list