Author: Nick Desaulniers Date: 2026-08-26T17:56:00Z New Revision: f69fbd6415ab3a0743d14f0e345f9b61720ce187
URL: https://github.com/llvm/llvm-project/commit/f69fbd6415ab3a0743d14f0e345f9b61720ce187 DIFF: https://github.com/llvm/llvm-project/commit/f69fbd6415ab3a0743d14f0e345f9b61720ce187.diff LOG: lldb: Linux: delete Ptrace.h pollyfill (#218045) As the comment in sources alludes to: > System includes - They have to be included after framework includes because > they define some macros which collide with variable names in other modules. These collisions would ideally not happen, but they are unlikely to be fixed any time soon. The workaround is to define what we need in the places that we need it. This was done in a previous commit and so the header can now be removed. Link: https://github.com/llvm/llvm-project/pull/217435 Fixes: https://github.com/llvm/llvm-project/issues/217413 Added: Modified: lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64dbreg.cpp lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86.cpp lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp Removed: lldb/include/lldb/Host/linux/Ptrace.h ################################################################################ diff --git a/lldb/include/lldb/Host/linux/Ptrace.h b/lldb/include/lldb/Host/linux/Ptrace.h deleted file mode 100644 index 8b3719113d3c6..0000000000000 --- a/lldb/include/lldb/Host/linux/Ptrace.h +++ /dev/null @@ -1,18 +0,0 @@ -//===-- Ptrace.h ------------------------------------------------*- C++ -*-===// -// -// 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 -// -//===----------------------------------------------------------------------===// - -// This file defines ptrace functions & structures - -#ifndef liblldb_Host_linux_Ptrace_h_ -#define liblldb_Host_linux_Ptrace_h_ - -#include <sys/ptrace.h> - -// Support ptrace extensions even when compiled without required kernel support - -#endif // liblldb_Host_linux_Ptrace_h_ diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index abb408de6406f..0efd781c2ae58 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -20,7 +20,6 @@ #include "lldb/Host/ThreadLauncher.h" #include "lldb/Host/common/NativeRegisterContext.h" #include "lldb/Host/linux/Host.h" -#include "lldb/Host/linux/Ptrace.h" #include "lldb/Host/linux/Uio.h" #include "lldb/Host/posix/ProcessLauncherPosixFork.h" #include "lldb/Symbol/ObjectFile.h" @@ -40,8 +39,12 @@ #include <cerrno> #include <cstdint> #include <cstring> -#include <linux/unistd.h> #include <optional> + +// System includes - They have to be included after framework includes because +// they define some macros which collide with variable names in other modules. +#include <linux/unistd.h> +#include <sys/ptrace.h> #include <sys/socket.h> #include <sys/syscall.h> #include <sys/types.h> diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp index 98a55a7dbe4c7..896a14c6fd261 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp @@ -13,9 +13,11 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Host/common/NativeThreadProtocol.h" -#include "lldb/Host/linux/Ptrace.h" #include "lldb/Utility/RegisterValue.h" +// System includes - They have to be included after framework includes because +// they define some macros which collide with variable names in other modules. +#include <sys/ptrace.h> #include <sys/uio.h> #ifndef PTRACE_GETREGS diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp index 77adefb9462e8..09ae8d38a1416 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp @@ -15,7 +15,6 @@ #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h" #include "lldb/Host/HostInfo.h" -#include "lldb/Host/linux/Ptrace.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegisterValue.h" @@ -25,8 +24,11 @@ #include "Plugins/Process/Linux/NativeRegisterContextLinux_arm64dbreg.h" #endif +// System includes - They have to be included after framework includes because +// they define some macros which collide with variable names in other modules. #include <asm/ptrace.h> #include <elf.h> +#include <sys/ptrace.h> #include <sys/uio.h> #define REG_CONTEXT_SIZE (GetGPRSize() + sizeof(m_fpr) + sizeof(m_tls)) diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp index 22177ac597bfc..a96fd6f832d7e 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp @@ -20,17 +20,18 @@ #include "Plugins/Process/Utility/RegisterTypeDetector_arm64.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/common/NativeProcessProtocol.h" -#include "lldb/Host/linux/Ptrace.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "llvm/BinaryFormat/ELF.h" -// System includes - They have to be included after framework includes because -// they define some macros which collide with variable names in other modules #include <mutex> #include <optional> + +// System includes - They have to be included after framework includes because +// they define some macros which collide with variable names in other modules. +#include <sys/ptrace.h> #include <sys/uio.h> #ifndef HWCAP_PACA diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64dbreg.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64dbreg.cpp index 29862389459f2..e3eab4b266cd4 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64dbreg.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64dbreg.cpp @@ -9,12 +9,12 @@ #if defined(__arm64__) || defined(__aarch64__) #include "NativeRegisterContextLinux_arm64dbreg.h" -#include "lldb/Host/linux/Ptrace.h" // System includes - They have to be included after framework includes because -// they define some macros which collide with variable names in other modules +// they define some macros which collide with variable names in other modules. #include <asm/ptrace.h> #include <elf.h> +#include <sys/ptrace.h> #include <sys/uio.h> #ifndef PTRACE_GETREGSET diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp index cd42dee65a20b..850a380b5cf3f 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp @@ -15,15 +15,15 @@ #include "Plugins/Process/Utility/RegisterInfoPOSIX_loongarch64.h" #include "Plugins/Process/Utility/lldb-loongarch-register-enums.h" #include "lldb/Host/HostInfo.h" -#include "lldb/Host/linux/Ptrace.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" -// NT_PRSTATUS and NT_FPREGSET definition +// System includes - They have to be included after framework includes because +// they define some macros which collide with variable names in other modules. #include <elf.h> -// struct iovec definition +#include <sys/ptrace.h> #include <sys/uio.h> #ifndef PTRACE_GETREGSET diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86.cpp index 40a60311a4f07..261c5b3124152 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86.cpp @@ -15,17 +15,20 @@ #include "Plugins/Process/Utility/RegisterContextLinux_i386.h" #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h" #include "lldb/Host/HostInfo.h" -#include "lldb/Host/linux/Ptrace.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include <algorithm> +#include <optional> + +// System includes - They have to be included after framework includes because +// they define some macros which collide with variable names in other modules. #include <asm/ldt.h> #include <cpuid.h> #include <linux/elf.h> -#include <optional> +#include <sys/ptrace.h> #ifndef PTRACE_GET_THREAD_AREA #define PTRACE_GET_THREAD_AREA 25 diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp index 1072da3890845..d0d0f542c7b3c 100644 --- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -14,7 +14,6 @@ #include "Plugins/Process/POSIX/CrashReason.h" #include "Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h" #include "lldb/Host/HostNativeThread.h" -#include "lldb/Host/linux/Ptrace.h" #include "lldb/Host/linux/Support.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/LLDBLog.h" @@ -25,7 +24,12 @@ #include <csignal> #include <sstream> + +// System includes - They have to be included after framework includes because +// they define some macros which collide with variable names in other modules. +#include <sys/ptrace.h> #include <sys/syscall.h> + // Try to define a macro to encapsulate the tgkill syscall #define tgkill(pid, tid, sig) \ syscall(__NR_tgkill, static_cast<::pid_t>(pid), static_cast<::pid_t>(tid), \ diff --git a/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp b/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp index fe5cb2323aac7..3c2675a1e9732 100644 --- a/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp +++ b/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp @@ -10,13 +10,16 @@ #include "Plugins/Process/Linux/NativeProcessLinux.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" -#include "lldb/Host/linux/Ptrace.h" #include "lldb/Utility/Status.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/Errno.h" #include <csignal> + +// System includes - They have to be included after framework includes because +// they define some macros which collide with variable names in other modules. #include <sched.h> +#include <sys/ptrace.h> #include <sys/wait.h> #include <unistd.h> _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
