llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Will Hawkins (hawkinsw)

<details>
<summary>Changes</summary>

Only Linux systems do not have gettid. Provide our own gettid in these cases.

Fixes a build failure caused by #<!-- -->104109.

---
Full diff: https://github.com/llvm/llvm-project/pull/104831.diff


1 Files Affected:

- (modified) lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp (+9-3) 


``````````diff
diff --git a/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp 
b/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp
index ce146f62b0d826..5cf5f9718252d5 100644
--- a/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp
+++ b/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp
@@ -23,6 +23,12 @@
 #include <mutex>
 #include <unistd.h>
 
+#include <sys/syscall.h>
+
+pid_t _workaround_gettid() {
+  return ((pid_t)syscall(SYS_gettid));
+}
+
 using namespace lldb_private;
 
 namespace {
@@ -91,7 +97,7 @@ lldb::TargetSP CreateTarget(lldb::DebuggerSP &debugger_sp, 
ArchSpec &arch) {
 
 lldb::ThreadSP CreateThread(lldb::ProcessSP &process_sp) {
   lldb::ThreadSP thread_sp =
-      std::make_shared<DummyThread>(*process_sp.get(), gettid());
+      std::make_shared<DummyThread>(*process_sp.get(), _workaround_gettid());
   if (thread_sp == nullptr) {
     return nullptr;
   }
@@ -167,8 +173,8 @@ TEST_F(ElfCoreTest, PopulatePrStatusTest) {
   ASSERT_EQ(prstatus_opt->pr_cursig, 0);
   ASSERT_EQ(prstatus_opt->pr_sigpend, 0UL);
   ASSERT_EQ(prstatus_opt->pr_sighold, 0UL);
-  ASSERT_EQ(prstatus_opt->pr_pid, static_cast<uint32_t>(gettid()));
+  ASSERT_EQ(prstatus_opt->pr_pid, static_cast<uint32_t>(_workaround_gettid()));
   ASSERT_EQ(prstatus_opt->pr_ppid, static_cast<uint32_t>(getppid()));
   ASSERT_EQ(prstatus_opt->pr_pgrp, static_cast<uint32_t>(getpgrp()));
-  ASSERT_EQ(prstatus_opt->pr_sid, static_cast<uint32_t>(getsid(gettid())));
+  ASSERT_EQ(prstatus_opt->pr_sid, 
static_cast<uint32_t>(getsid(_workaround_gettid())));
 }

``````````

</details>


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

Reply via email to