Skip to content

Commit f7bd5bf

Browse files
committed
ProcessInstanceInfoMatch: Don't match processes with no name if a name match was requested
Since D68289, a couple of tests on linux started being extremely flaky. All of them were doing name-based attaching and were failing because they couldn't find an unambiguous process to attach to. The patch above changed the process finding logic, so that failure to find a process name does not constitute an error. This meant that a lot more transient processes showed up in the process list during the test suite run. Previously, these processes would not appear as they would be gone by the time we went to read their executable name, arguments, etc. Now, this alone should not cause an issue were it not for the fact that we were considering a process with no name as if it matched by default (even if we were explicitly searching for a process with a specified name). This meant that any of the "transient" processes with no name would make the name match ambiguous. That clearly seems like a bug to me so I fix that. llvm-svn: 373925
1 parent de85997 commit f7bd5bf

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lldb/source/Utility/ProcessInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void ProcessInstanceInfo::DumpAsTableRow(Stream &s, UserIDResolver &resolver,
244244
}
245245

246246
bool ProcessInstanceInfoMatch::NameMatches(const char *process_name) const {
247-
if (m_name_match_type == NameMatch::Ignore || process_name == nullptr)
247+
if (m_name_match_type == NameMatch::Ignore)
248248
return true;
249249
const char *match_name = m_match_info.GetName();
250250
if (!match_name)

lldb/unittests/Utility/ProcessInstanceInfoTest.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,20 @@ TEST(ProcessInstanceInfo, DumpTable_invalidUID) {
9191
)",
9292
s.GetData());
9393
}
94+
95+
TEST(ProcessInstanceInfoMatch, Name) {
96+
ProcessInstanceInfo info_bar, info_empty;
97+
info_bar.GetExecutableFile().SetFile("/foo/bar", FileSpec::Style::posix);
98+
99+
ProcessInstanceInfoMatch match;
100+
match.SetNameMatchType(NameMatch::Equals);
101+
match.GetProcessInfo().GetExecutableFile().SetFile("bar",
102+
FileSpec::Style::posix);
103+
104+
EXPECT_TRUE(match.Matches(info_bar));
105+
EXPECT_FALSE(match.Matches(info_empty));
106+
107+
match.GetProcessInfo().GetExecutableFile() = FileSpec();
108+
EXPECT_TRUE(match.Matches(info_bar));
109+
EXPECT_TRUE(match.Matches(info_empty));
110+
}

0 commit comments

Comments
 (0)