================
@@ -0,0 +1,71 @@
+//===-- NativeThreadAIX.cpp ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "NativeThreadAIX.h"
+#include "NativeProcessAIX.h"
+#include "lldb/Utility/State.h"
+#include <procinfo.h>
+#include <sys/procfs.h>
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_aix;
+
+NativeThreadAIX::NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid)
+    : NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid) {}
+
+std::string NativeThreadAIX::GetName() {
+  NativeProcessAIX &process = GetProcess();
+  auto BufferOrError = getProcFile(process.GetID(), "psinfo");
+  if (!BufferOrError)
+    return "";
+  auto &Buffer = *BufferOrError;
+  if (Buffer->getBufferSize() < sizeof(psinfo_t))
+    return "";
+  const psinfo_t *psinfo =
+      reinterpret_cast<const psinfo_t *>(Buffer->getBufferStart());
+  return std::string(psinfo->pr_fname);
+}
----------------
labath wrote:

>  In that case, shall I go ahead with this?

I think we can say it's up to you, but so far I haven't seen anything that 
would make me thing this is necessary. You're right that it causes the name 
field to disappear, but the usefulness of that field comes from the fact that 
it's different for every thread:
```
lldb) thread list
Process 6708 stopped
* thread #1: tid = 6708, 0x00007fffee7201ac libc.so.6`__select + 332, name = 
'lldb', stop reason = signal SIGSTOP
  thread #2: tid = 6759, 0x00007fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'er.alarm-thread'
  thread #3: tid = 6760, 0x00007fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'dbg.evt-handler'
  thread #4: tid = 6765, 0x00007fffee70b15a libc.so.6`wait4 + 90, name = 
'ait4(pid=6764)>'
  thread #5: tid = 6766, 0x00007fffee7201ac libc.so.6`__select + 332, name = 
'b-remote.async>'
  thread #6: tid = 6771, 0x00007fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'intern-state'
  thread #7: tid = 6772, 0x00007fffee7201ac libc.so.6`__select + 332, name = 
'.process.stdio>'
  thread #8: tid = 6773, 0x00007fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-0'
  thread #9: tid = 6774, 0x00007fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-1'
  thread #10: tid = 6775, 0x00007fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-2'
  thread #11: tid = 6776, 0x00007fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-3'
  thread #12: tid = 6777, 0x00007fffee69c0a5 
libc.so.6`__futex_abstimed_wait_common + 261, name = 'llvm-worker-4'
```

If all of these said `name='lldb'`, would the result be useful? I think not. 
And I think the same goes for the single-threaded use case: if there is just a 
single thread, then you don't need names as there's nothing to distinguish.

https://github.com/llvm/llvm-project/pull/139537
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to