summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/cmake/modules/LLDBGenerateConfig.cmake19
-rw-r--r--lldb/include/lldb/Host/Config.h4
-rw-r--r--lldb/include/lldb/Host/Config.h.cmake4
-rw-r--r--lldb/include/lldb/Host/Editline.h20
4 files changed, 33 insertions, 14 deletions
diff --git a/lldb/cmake/modules/LLDBGenerateConfig.cmake b/lldb/cmake/modules/LLDBGenerateConfig.cmake
index 33b7e98318e..7586eda30d6 100644
--- a/lldb/cmake/modules/LLDBGenerateConfig.cmake
+++ b/lldb/cmake/modules/LLDBGenerateConfig.cmake
@@ -4,6 +4,7 @@ include(CheckSymbolExists)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckLibraryExists)
+include(CheckTypeSize)
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
check_symbol_exists(ppoll poll.h HAVE_PPOLL)
@@ -27,6 +28,24 @@ if(NOT UNIX)
set(LLDB_DISABLE_POSIX 1)
endif()
+if (NOT LLDB_DISABLE_LIBEDIT)
+ # Check if we libedit capable of handling wide characters (built with
+ # '--enable-widec').
+ set(CMAKE_REQUIRED_LIBRARIES ${libedit_LIBRARIES})
+ set(CMAKE_REQUIRED_INCLUDES ${libedit_INCLUDE_DIRS})
+ check_symbol_exists(el_winsertstr histedit.h LLDB_EDITLINE_USE_WCHAR)
+ set(CMAKE_EXTRA_INCLUDE_FILES histedit.h)
+ check_type_size(el_rfunc_t LLDB_EL_RFUNC_T_SIZE)
+ if (LLDB_EL_RFUNC_T_SIZE STREQUAL "")
+ set(LLDB_HAVE_EL_RFUNC_T 0)
+ else()
+ set(LLDB_HAVE_EL_RFUNC_T 1)
+ endif()
+ set(CMAKE_REQUIRED_LIBRARIES)
+ set(CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_EXTRA_INCLUDE_FILES)
+endif()
+
if(NOT LLDB_CONFIG_HEADER_INPUT)
set(LLDB_CONFIG_HEADER_INPUT ${LLDB_INCLUDE_ROOT}/lldb/Host/Config.h.cmake)
endif()
diff --git a/lldb/include/lldb/Host/Config.h b/lldb/include/lldb/Host/Config.h
index 3fa19e77452..771937498b3 100644
--- a/lldb/include/lldb/Host/Config.h
+++ b/lldb/include/lldb/Host/Config.h
@@ -16,6 +16,10 @@
// absence of a configuration step.
#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
+#define LLDB_EDITLINE_USE_WCHAR 1
+
+#define LLDB_HAVE_EL_RFUNC_T 1
+
#define HAVE_SYS_EVENT_H 1
#define HAVE_PPOLL 0
diff --git a/lldb/include/lldb/Host/Config.h.cmake b/lldb/include/lldb/Host/Config.h.cmake
index 7fe7ec8ce6c..d6575578262 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -12,6 +12,10 @@
#cmakedefine LLDB_CONFIG_TERMIOS_SUPPORTED
+#cmakedefine01 LLDB_EDITLINE_USE_WCHAR
+
+#cmakedefine01 LLDB_HAVE_EL_RFUNC_T
+
#cmakedefine LLDB_DISABLE_POSIX
#define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h
index f06fc06f9ca..cb40f1e6917 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -33,23 +33,11 @@
#define liblldb_Editline_h_
#if defined(__cplusplus)
+#include <codecvt>
#include <locale>
#include <sstream>
#include <vector>
-// components needed to handle wide characters ( <codecvt>, codecvt_utf8,
-// libedit built with '--enable-widec' ) are available on some platforms. The
-// wchar_t versions of libedit functions will only be used in cases where this
-// is true. This is a compile time dependecy, for now selected per target
-// Platform
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
- defined(__OpenBSD__)
-#define LLDB_EDITLINE_USE_WCHAR 1
-#include <codecvt>
-#else
-#define LLDB_EDITLINE_USE_WCHAR 0
-#endif
-
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/lldb-private.h"
@@ -81,7 +69,11 @@ using EditLineStringStreamType = std::stringstream;
using EditLineCharType = char;
#endif
-#ifdef EL_CLIENTDATA /* editline with wide support + wide char read function */
+// At one point the callback type of el_set getchar callback changed from char
+// to wchar_t. It is not possible to detect differentiate between the two
+// versions exactly, but this is a pretty good approximation and allows us to
+// build against almost any editline version out there.
+#if LLDB_EDITLINE_USE_WCHAR || defined(EL_CLIENTDATA) || LLDB_HAVE_EL_RFUNC_T
using EditLineGetCharType = wchar_t;
#else
using EditLineGetCharType = char;
OpenPOWER on IntegriCloud