Skip to content

Commit 8dd3bd9

Browse files
Fix for GetName() (#61)
Need to access process/main-thread name from psinfo on aix rather than comm on linux. (0) root @ unobosdev002: /home/dhruv/dio_fs/LLDB/build-lldb # bin/lldb ../tests/1 (lldb) target create "../tests/1" Current executable set to '/home/dhruv/dio_fs/LLDB/tests/1' (powerpc64). (lldb) b main Breakpoint 1: where = 1`main + 8 at 1.c:3, address = 0x0000000100000928 (lldb) r Process 44433678 launched: '/home/dhruv/dio_fs/LLDB/tests/1' (powerpc64) Process 44433678 stopped * thread #1, name = '1', stop reason = breakpoint 1.1 frame #0: 0x0000000100000928 1`main at 1.c:3 1 int main() 2 { -> 3 int x = 10; 4 x++; 5 return x; 6 } (lldb) thread info thread #1: tid = 0x2a6010e, 0x0000000100000928 1`main at 1.c:3, name = '1', stop reason = breakpoint 1.1
1 parent 5dcc4aa commit 8dd3bd9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
#include "llvm/ADT/SmallString.h"
2525

2626
#include "Plugins/Process/POSIX/CrashReason.h"
27-
27+
#include <procinfo.h>
28+
#include <sys/procfs.h>
2829
#include <sys/types.h>
2930
#include <sys/ptrace.h>
3031
#include <signal.h>
@@ -102,11 +103,15 @@ NativeThreadAIX::NativeThreadAIX(NativeProcessAIX &process,
102103

103104
std::string NativeThreadAIX::GetName() {
104105
NativeProcessAIX &process = GetProcess();
105-
106-
auto BufferOrError = getProcFile(process.GetID(), GetID(), "comm");
106+
auto BufferOrError = getProcFile(process.GetID(), "psinfo");
107107
if (!BufferOrError)
108108
return "";
109-
return std::string(BufferOrError.get()->getBuffer().rtrim('\n'));
109+
auto &Buffer = *BufferOrError;
110+
if (Buffer->getBufferSize() < sizeof(psinfo_t))
111+
return "";
112+
const psinfo_t *psinfo =
113+
reinterpret_cast<const psinfo_t *>(Buffer->getBufferStart());
114+
return std::string(psinfo->pr_fname);
110115
}
111116

112117
lldb::StateType NativeThreadAIX::GetState() { return m_state; }

0 commit comments

Comments
 (0)