Skip to content

Commit 264d964

Browse files
committed
[lldb][test] Workaround older systems that lack gettid
Older glibc versions do not have `gettid`. Provide our own `gettid` in these cases. Fixes a build failure caused by #104109.
1 parent 6e0fc15 commit 264d964

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lldb/unittests/Process/elf-core/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
include(CheckSymbolExists)
2+
include(CMakePushCheckState)
3+
4+
cmake_push_check_state()
5+
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
6+
check_symbol_exists(gettid "unistd.h" HAVE_GETTID)
7+
if(HAVE_GETTID)
8+
add_compile_definitions(-DHAVE_GETTID)
9+
endif()
10+
cmake_pop_check_state()
11+
112
add_lldb_unittest(ProcessElfCoreTests
213
ThreadElfCoreTest.cpp
314

lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
#include <mutex>
2424
#include <unistd.h>
2525

26+
#ifndef HAVE_GETTID
27+
#include <sys/syscall.h>
28+
pid_t gettid() { return ((pid_t)syscall(SYS_gettid)); }
29+
#endif
30+
2631
using namespace lldb_private;
2732

2833
namespace {

0 commit comments

Comments
 (0)