[Lldb-commits] [lldb] 61a2bda - [lldb/Host] Use cmakedefine01 for LLDB_ENABLE_TERMIOS
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 12 09:36:59 PST 2019
Author: Jonas Devlieghere
Date: 2019-12-12T09:34:11-08:00
New Revision: 61a2bdadb33166950f768ad2c764d2940b9466fb
URL: https://github.com/llvm/llvm-project/commit/61a2bdadb33166950f768ad2c764d2940b9466fb
DIFF: https://github.com/llvm/llvm-project/commit/61a2bdadb33166950f768ad2c764d2940b9466fb.diff
LOG: [lldb/Host] Use cmakedefine01 for LLDB_ENABLE_TERMIOS
This renames LLDB_CONFIG_TERMIOS_SUPPORTED to LLDB_ENABLE_TERMIOS. It
now also uses cmakedefine01 to keep things consistent with out other
optional dependencies. But more importantly it won't silently fail when
you forget to include Config.h.
Added:
Modified:
lldb/cmake/modules/LLDBGenerateConfig.cmake
lldb/include/lldb/Host/Config.h.cmake
lldb/include/lldb/Host/Terminal.h
lldb/source/Host/common/Terminal.cpp
Removed:
################################################################################
diff --git a/lldb/cmake/modules/LLDBGenerateConfig.cmake b/lldb/cmake/modules/LLDBGenerateConfig.cmake
index 119021c587b8..b44f4afdfa69 100644
--- a/lldb/cmake/modules/LLDBGenerateConfig.cmake
+++ b/lldb/cmake/modules/LLDBGenerateConfig.cmake
@@ -23,7 +23,7 @@ check_library_exists(compression compression_encode_buffer "" HAVE_LIBCOMPRESSIO
# These checks exist in LLVM's configuration, so I want to match the LLVM names
# so that the check isn't duplicated, but we translate them into the LLDB names
# so that I don't have to change all the uses at the moment.
-set(LLDB_CONFIG_TERMIOS_SUPPORTED ${HAVE_TERMIOS_H})
+set(LLDB_ENABLE_TERMIOS ${HAVE_TERMIOS_H})
if(NOT UNIX)
set(LLDB_DISABLE_POSIX 1)
endif()
diff --git a/lldb/include/lldb/Host/Config.h.cmake b/lldb/include/lldb/Host/Config.h.cmake
index 7f0588a12f26..057bc085b41e 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -9,8 +9,6 @@
#ifndef LLDB_HOST_CONFIG_H
#define LLDB_HOST_CONFIG_H
-#cmakedefine LLDB_CONFIG_TERMIOS_SUPPORTED
-
#cmakedefine01 LLDB_EDITLINE_USE_WCHAR
#cmakedefine01 LLDB_HAVE_EL_RFUNC_T
@@ -33,6 +31,8 @@
#cmakedefine HAVE_LIBCOMPRESSION
#endif
+#cmakedefine01 LLDB_ENABLE_TERMIOS
+
#cmakedefine01 LLDB_ENABLE_LZMA
#cmakedefine01 LLDB_ENABLE_CURSES
diff --git a/lldb/include/lldb/Host/Terminal.h b/lldb/include/lldb/Host/Terminal.h
index e5e96eeda3fe..671f8d63f89f 100644
--- a/lldb/include/lldb/Host/Terminal.h
+++ b/lldb/include/lldb/Host/Terminal.h
@@ -117,7 +117,7 @@ class TerminalState {
// Member variables
Terminal m_tty; ///< A terminal
int m_tflags; ///< Cached tflags information.
-#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#if LLDB_ENABLE_TERMIOS
std::unique_ptr<struct termios>
m_termios_up; ///< Cached terminal state information.
#endif
diff --git a/lldb/source/Host/common/Terminal.cpp b/lldb/source/Host/common/Terminal.cpp
index 4b536b03d852..0c539f1c8e87 100644
--- a/lldb/source/Host/common/Terminal.cpp
+++ b/lldb/source/Host/common/Terminal.cpp
@@ -15,7 +15,7 @@
#include <fcntl.h>
#include <signal.h>
-#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#if LLDB_ENABLE_TERMIOS
#include <termios.h>
#endif
@@ -25,7 +25,7 @@ bool Terminal::IsATerminal() const { return m_fd >= 0 && ::isatty(m_fd); }
bool Terminal::SetEcho(bool enabled) {
if (FileDescriptorIsValid()) {
-#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#if LLDB_ENABLE_TERMIOS
if (IsATerminal()) {
struct termios fd_termios;
if (::tcgetattr(m_fd, &fd_termios) == 0) {
@@ -47,14 +47,14 @@ bool Terminal::SetEcho(bool enabled) {
return ::tcsetattr(m_fd, TCSANOW, &fd_termios) == 0;
}
}
-#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#endif // #if LLDB_ENABLE_TERMIOS
}
return false;
}
bool Terminal::SetCanonical(bool enabled) {
if (FileDescriptorIsValid()) {
-#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#if LLDB_ENABLE_TERMIOS
if (IsATerminal()) {
struct termios fd_termios;
if (::tcgetattr(m_fd, &fd_termios) == 0) {
@@ -76,7 +76,7 @@ bool Terminal::SetCanonical(bool enabled) {
return ::tcsetattr(m_fd, TCSANOW, &fd_termios) == 0;
}
}
-#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#endif // #if LLDB_ENABLE_TERMIOS
}
return false;
}
@@ -84,7 +84,7 @@ bool Terminal::SetCanonical(bool enabled) {
// Default constructor
TerminalState::TerminalState()
: m_tty(), m_tflags(-1),
-#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#if LLDB_ENABLE_TERMIOS
m_termios_up(),
#endif
m_process_group(-1) {
@@ -96,7 +96,7 @@ TerminalState::~TerminalState() {}
void TerminalState::Clear() {
m_tty.Clear();
m_tflags = -1;
-#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#if LLDB_ENABLE_TERMIOS
m_termios_up.reset();
#endif
m_process_group = -1;
@@ -111,13 +111,13 @@ bool TerminalState::Save(int fd, bool save_process_group) {
#ifndef LLDB_DISABLE_POSIX
m_tflags = ::fcntl(fd, F_GETFL, 0);
#endif
-#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#if LLDB_ENABLE_TERMIOS
if (m_termios_up == nullptr)
m_termios_up.reset(new struct termios);
int err = ::tcgetattr(fd, m_termios_up.get());
if (err != 0)
m_termios_up.reset();
-#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#endif // #if LLDB_ENABLE_TERMIOS
#ifndef LLDB_DISABLE_POSIX
if (save_process_group)
m_process_group = ::tcgetpgrp(0);
@@ -127,7 +127,7 @@ bool TerminalState::Save(int fd, bool save_process_group) {
} else {
m_tty.Clear();
m_tflags = -1;
-#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#if LLDB_ENABLE_TERMIOS
m_termios_up.reset();
#endif
m_process_group = -1;
@@ -144,10 +144,10 @@ bool TerminalState::Restore() const {
if (TFlagsIsValid())
fcntl(fd, F_SETFL, m_tflags);
-#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#if LLDB_ENABLE_TERMIOS
if (TTYStateIsValid())
tcsetattr(fd, TCSANOW, m_termios_up.get());
-#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#endif // #if LLDB_ENABLE_TERMIOS
if (ProcessGroupIsValid()) {
// Save the original signal handler.
@@ -176,7 +176,7 @@ bool TerminalState::TFlagsIsValid() const { return m_tflags != -1; }
// Returns true if m_ttystate is valid
bool TerminalState::TTYStateIsValid() const {
-#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#if LLDB_ENABLE_TERMIOS
return m_termios_up != nullptr;
#else
return false;
More information about the lldb-commits
mailing list