-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Add option to pass thread ID to thread select command #73596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
97a6e23
34045b9
3ef88cd
e30a155
e109a2e
2db54f6
e1f1f0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -44,7 +44,7 @@ typedef void (*CompletionCallback)(CommandInterpreter &interpreter, | |||
lldb_private::SearchFilter *searcher); | ||||
|
||||
struct CommonCompletionElement { | ||||
uint32_t type; | ||||
uint64_t type; | ||||
CompletionCallback callback; | ||||
}; | ||||
|
||||
|
@@ -54,6 +54,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks( | |||
bool handled = false; | ||||
|
||||
const CommonCompletionElement common_completions[] = { | ||||
{lldb::eNoCompletion, nullptr}, | ||||
{lldb::eSourceFileCompletion, CommandCompletions::SourceFiles}, | ||||
{lldb::eDiskFileCompletion, CommandCompletions::DiskFiles}, | ||||
{lldb::eDiskDirectoryCompletion, CommandCompletions::DiskDirectories}, | ||||
|
@@ -83,12 +84,13 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks( | |||
CommandCompletions::RemoteDiskDirectories}, | ||||
{lldb::eTypeCategoryNameCompletion, | ||||
CommandCompletions::TypeCategoryNames}, | ||||
{lldb::CompletionType::eNoCompletion, | ||||
{lldb::eThreadIDCompletion, CommandCompletions::ThreadIDs}, | ||||
{lldb::eTerminatorCompletion, | ||||
nullptr} // This one has to be last in the list. | ||||
}; | ||||
|
||||
for (int i = 0;; i++) { | ||||
if (common_completions[i].type == lldb::eNoCompletion) | ||||
if (common_completions[i].type == lldb::eTerminatorCompletion) | ||||
break; | ||||
else if ((common_completions[i].type & completion_mask) == | ||||
common_completions[i].type && | ||||
|
@@ -807,6 +809,23 @@ void CommandCompletions::TypeCategoryNames(CommandInterpreter &interpreter, | |||
}); | ||||
} | ||||
|
||||
void CommandCompletions::ThreadIDs(CommandInterpreter &interpreter, | ||||
CompletionRequest &request, | ||||
SearchFilter *searcher) { | ||||
const ExecutionContext &exe_ctx = interpreter.GetExecutionContext(); | ||||
if (!exe_ctx.HasProcessScope()) | ||||
return; | ||||
|
||||
ThreadList &threads = exe_ctx.GetProcessPtr()->GetThreadList(); | ||||
lldb::ThreadSP thread_sp; | ||||
for (uint32_t idx = 0; (thread_sp = threads.GetThreadAtIndex(idx)); ++idx) { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor nit, don't block the review on this, but why do you have ()s here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's to avoid this warning:
It's also consistent to how it was done in the ThreadIndex completer code:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh wow, I had not noticed what we were doing here, we usually see that pattern in So that means that if one of the thread pointers in the middle of the list is null, we stop processing other threads? This seems counter intuitive, I would have expected the code to be:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (please don't resolve conversations until the author has had a chance to look at the answer) |
||||
StreamString strm; | ||||
thread_sp->GetStatus(strm, 0, 1, 1, true); | ||||
request.TryCompleteCurrentArg(std::to_string(thread_sp->GetID()), | ||||
strm.GetString()); | ||||
} | ||||
} | ||||
|
||||
void CommandCompletions::CompleteModifiableCmdPathArgs( | ||||
CommandInterpreter &interpreter, CompletionRequest &request, | ||||
OptionElementVector &opt_element_vector) { | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't right, eTerminatorCompletion should be
(1ul << 27)
here. I want to be able to write:if (number_passed_in >= eTerminatorCompletion)
error("You passed an invalid completion")
The value of eTerminatorCompletion gets shifted up each time someone adds a new completion, that allows each lldb version to check the input value against the completions it knows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jimingham Thanks for the quick feedback, makes sense. Latest changes update
eTerminatorCompletion
value based on your comments.