Skip to content

[LLDB][NFC] Remove unneeded conditional #138321

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 1 commit into from
May 3, 2025
Merged
Changes from all commits
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
133 changes: 65 additions & 68 deletions lldb/source/Commands/CommandObjectPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1231,77 +1231,74 @@ class CommandObjectPlatformProcessList : public CommandObjectParsed {
}

if (platform_sp) {
Status error;
if (platform_sp) {
Stream &ostrm = result.GetOutputStream();

lldb::pid_t pid = m_options.match_info.GetProcessInfo().GetProcessID();
if (pid != LLDB_INVALID_PROCESS_ID) {
ProcessInstanceInfo proc_info;
if (platform_sp->GetProcessInfo(pid, proc_info)) {
ProcessInstanceInfo::DumpTableHeader(ostrm, m_options.show_args,
m_options.verbose);
proc_info.DumpAsTableRow(ostrm, platform_sp->GetUserIDResolver(),
m_options.show_args, m_options.verbose);
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
result.AppendErrorWithFormat(
"no process found with pid = %" PRIu64 "\n", pid);
}
Stream &ostrm = result.GetOutputStream();

lldb::pid_t pid = m_options.match_info.GetProcessInfo().GetProcessID();
if (pid != LLDB_INVALID_PROCESS_ID) {
ProcessInstanceInfo proc_info;
if (platform_sp->GetProcessInfo(pid, proc_info)) {
ProcessInstanceInfo::DumpTableHeader(ostrm, m_options.show_args,
m_options.verbose);
proc_info.DumpAsTableRow(ostrm, platform_sp->GetUserIDResolver(),
m_options.show_args, m_options.verbose);
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
ProcessInstanceInfoList proc_infos;
const uint32_t matches =
platform_sp->FindProcesses(m_options.match_info, proc_infos);
const char *match_desc = nullptr;
const char *match_name =
m_options.match_info.GetProcessInfo().GetName();
if (match_name && match_name[0]) {
switch (m_options.match_info.GetNameMatchType()) {
case NameMatch::Ignore:
break;
case NameMatch::Equals:
match_desc = "matched";
break;
case NameMatch::Contains:
match_desc = "contained";
break;
case NameMatch::StartsWith:
match_desc = "started with";
break;
case NameMatch::EndsWith:
match_desc = "ended with";
break;
case NameMatch::RegularExpression:
match_desc = "matched the regular expression";
break;
}
result.AppendErrorWithFormat(
"no process found with pid = %" PRIu64 "\n", pid);
}
} else {
ProcessInstanceInfoList proc_infos;
const uint32_t matches =
platform_sp->FindProcesses(m_options.match_info, proc_infos);
const char *match_desc = nullptr;
const char *match_name =
m_options.match_info.GetProcessInfo().GetName();
if (match_name && match_name[0]) {
switch (m_options.match_info.GetNameMatchType()) {
case NameMatch::Ignore:
break;
case NameMatch::Equals:
match_desc = "matched";
break;
case NameMatch::Contains:
match_desc = "contained";
break;
case NameMatch::StartsWith:
match_desc = "started with";
break;
case NameMatch::EndsWith:
match_desc = "ended with";
break;
case NameMatch::RegularExpression:
match_desc = "matched the regular expression";
break;
}
}

if (matches == 0) {
if (match_desc)
result.AppendErrorWithFormatv(
"no processes were found that {0} \"{1}\" on the \"{2}\" "
"platform\n",
match_desc, match_name, platform_sp->GetName());
else
result.AppendErrorWithFormatv(
"no processes were found on the \"{0}\" platform\n",
platform_sp->GetName());
} else {
result.AppendMessageWithFormatv(
"{0} matching process{1} found on \"{2}\"", matches,
matches > 1 ? "es were" : " was", platform_sp->GetName());
if (match_desc)
result.AppendMessageWithFormat(" whose name %s \"%s\"",
match_desc, match_name);
result.AppendMessageWithFormat("\n");
ProcessInstanceInfo::DumpTableHeader(ostrm, m_options.show_args,
m_options.verbose);
for (uint32_t i = 0; i < matches; ++i) {
proc_infos[i].DumpAsTableRow(
ostrm, platform_sp->GetUserIDResolver(), m_options.show_args,
m_options.verbose);
}
if (matches == 0) {
if (match_desc)
result.AppendErrorWithFormatv(
"no processes were found that {0} \"{1}\" on the \"{2}\" "
"platform\n",
match_desc, match_name, platform_sp->GetName());
else
result.AppendErrorWithFormatv(
"no processes were found on the \"{0}\" platform\n",
platform_sp->GetName());
} else {
result.AppendMessageWithFormatv(
"{0} matching process{1} found on \"{2}\"", matches,
matches > 1 ? "es were" : " was", platform_sp->GetName());
if (match_desc)
result.AppendMessageWithFormat(" whose name %s \"%s\"", match_desc,
match_name);
result.AppendMessageWithFormat("\n");
ProcessInstanceInfo::DumpTableHeader(ostrm, m_options.show_args,
m_options.verbose);
for (uint32_t i = 0; i < matches; ++i) {
proc_infos[i].DumpAsTableRow(
ostrm, platform_sp->GetUserIDResolver(), m_options.show_args,
m_options.verbose);
}
}
}
Expand Down
Loading