[Lldb-commits] [PATCH] D88728: [lldb] Check for and use ptsname_r if available

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 2 04:49:06 PDT 2020


labath created this revision.
labath added reviewers: mgorny, MaskRay.
Herald added a subscriber: emaste.
Herald added a project: LLDB.
labath requested review of this revision.
Herald added a subscriber: JDevlieghere.

ptsname is not thread-safe. ptsname_r is available on most (but not all)
systems -- use it preferentially.

In the patch I also improve the thread-safety of the ptsname fallback
path by wrapping it in a mutex. This should guarantee the safety of a
typical ptsname implementation using a single static buffer, as long as
all callers go through this function.

I also remove the error arguments, as the only way this function can
fail is if the "primary" fd is not valid. This is a programmer error as
this requirement is documented, and all callers ensure that is the case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88728

Files:
  lldb/cmake/modules/LLDBGenerateConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/PseudoTerminal.h
  lldb/source/Host/common/ProcessLaunchInfo.cpp
  lldb/source/Host/common/PseudoTerminal.cpp
  lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
  lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88728.295793.patch
Type: text/x-patch
Size: 8851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20201002/06f35a23/attachment-0001.bin>


More information about the lldb-commits mailing list