Skip to content

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

Merged
merged 7 commits into from
Dec 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions lldb/source/Commands/CommandObjectThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1216,15 +1216,18 @@ class CommandObjectThreadSelect : public CommandObjectParsed {
if (process == nullptr) {
result.AppendError("no process");
return;
} else if (m_options.m_thread_id == LLDB_INVALID_THREAD_ID && command.GetArgumentCount() != 1) {
} else if (m_options.m_thread_id == LLDB_INVALID_THREAD_ID &&
command.GetArgumentCount() != 1) {
result.AppendErrorWithFormat(
"'%s' takes exactly one thread index argument, or a thread ID option:\nUsage: %s\n",
"'%s' takes exactly one thread index argument, or a thread ID "
"option:\nUsage: %s\n",
m_cmd_name.c_str(), m_cmd_syntax.c_str());
return;
} else if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID && command.GetArgumentCount() != 0) {
result.AppendErrorWithFormat(
"'%s' cannot take both a thread ID option and a thread index argument:\nUsage: %s\n",
m_cmd_name.c_str(), m_cmd_syntax.c_str());
} else if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID &&
command.GetArgumentCount() != 0) {
result.AppendErrorWithFormat("'%s' cannot take both a thread ID option "
"and a thread index argument:\nUsage: %s\n",
m_cmd_name.c_str(), m_cmd_syntax.c_str());
return;
}

Expand All @@ -1239,11 +1242,12 @@ class CommandObjectThreadSelect : public CommandObjectParsed {
new_thread = process->GetThreadList().FindThreadByIndexID(index_id).get();
if (new_thread == nullptr) {
result.AppendErrorWithFormat("Invalid thread #%s.\n",
command.GetArgumentAtIndex(0));
command.GetArgumentAtIndex(0));
return;
}
} else {
new_thread = process->GetThreadList().FindThreadByID(m_options.m_thread_id).get();
new_thread =
process->GetThreadList().FindThreadByID(m_options.m_thread_id).get();
if (new_thread == nullptr) {
result.AppendErrorWithFormat("Invalid thread ID %lu.\n",
m_options.m_thread_id);
Expand Down