Skip to content

Commit 3bfcaaa

Browse files
committed
Addressed review comments
1 parent f434632 commit 3bfcaaa

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

lldb/source/Host/aix/Host.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ static bool GetExePathAndIds(::pid_t pid, ProcessInstanceInfo &process_info) {
9393
return false;
9494

9595
std::memcpy(&psinfoData, PsinfoBuffer->getBufferStart(), sizeof(psinfoData));
96-
llvm::StringRef PathRef(&(psinfoData.pr_psargs[0]));
96+
llvm::StringRef PathRef(
97+
psinfoData.pr_psargs,
98+
strnlen(psinfoData.pr_psargs, sizeof(psinfoData.pr_psargs)));
9799
if (PathRef.empty())
98100
return false;
99101

@@ -118,6 +120,8 @@ static bool GetProcessAndStatInfo(::pid_t pid,
118120
process_info.Clear();
119121
process_info.SetProcessID(pid);
120122

123+
if (pid == LLDB_INVALID_PROCESS_ID)
124+
return false;
121125
// Get Executable path/Arch and Get User and Group IDs.
122126
if (!GetExePathAndIds(pid, process_info))
123127
return false;

lldb/unittests/Host/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set (FILES
1515
XMLTest.cpp
1616
)
1717

18-
if (CMAKE_SYSTEM_NAME MATCHES "Linux|Android|AIX")
18+
if (UNIX)
1919
list(APPEND FILES
2020
posix/HostTest.cpp
2121
posix/SupportTest.cpp

lldb/unittests/Host/posix/HostTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ TEST_F(HostTest, GetProcessInfo) {
4040
triple.getEnvironment() == llvm::Triple::EnvironmentType::Android));
4141

4242
ProcessInstanceInfo Info;
43-
#ifndef _AIX
44-
ASSERT_FALSE(Host::GetProcessInfo(0, Info));
45-
#endif /* ifndef _AIX */
43+
44+
ASSERT_FALSE(Host::GetProcessInfo(LLDB_INVALID_PROCESS_ID, Info));
45+
4646
ASSERT_TRUE(Host::GetProcessInfo(getpid(), Info));
4747

4848
ASSERT_TRUE(Info.ProcessIDIsValid());

lldb/unittests/Host/posix/SupportTest.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,16 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "lldb/Host/linux/Support.h"
109
#include "lldb/Host/posix/Support.h"
1110
#include "llvm/Support/Threading.h"
1211
#include "gtest/gtest.h"
1312

1413
using namespace lldb_private;
1514

15+
#ifndef __APPLE__
1616
TEST(Support, getProcFile_Pid) {
1717
auto BufferOrError = getProcFile(getpid(), "status");
1818
ASSERT_TRUE(BufferOrError);
1919
ASSERT_TRUE(*BufferOrError);
2020
}
21-
22-
#ifndef _AIX
23-
#ifdef LLVM_ENABLE_THREADING
24-
TEST(Support, getProcFile_Tid) {
25-
auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(), "comm");
26-
ASSERT_TRUE(BufferOrError);
27-
ASSERT_TRUE(*BufferOrError);
28-
}
29-
#endif /*ifdef LLVM_ENABLE_THREADING */
30-
#endif /*ifndef _AIX */
21+
#endif // #ifndef __APPLE__

lldb/unittests/Process/Linux/ProcfsTests.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "Procfs.h"
1010

11+
#include "lldb/Host/linux/Support.h"
1112
#include "lldb/Host/posix/Support.h"
1213

1314
#include "gmock/gmock.h"
@@ -118,3 +119,11 @@ TEST(Perf, RealPtraceScope) {
118119
ASSERT_LE(*ptrace_scope, 3)
119120
<< "Sensible values of ptrace_scope are between 0 and 3";
120121
}
122+
123+
#ifdef LLVM_ENABLE_THREADING
124+
TEST(Support, getProcFile_Tid) {
125+
auto BufferOrError = getProcFile(getpid(), llvm::get_threadid(), "comm");
126+
ASSERT_TRUE(BufferOrError);
127+
ASSERT_TRUE(*BufferOrError);
128+
}
129+
#endif /*ifdef LLVM_ENABLE_THREADING */

0 commit comments

Comments
 (0)