From ba87a2cde7795081bc1b956de0f9f978c44788fd Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Wed, 28 Feb 2018 23:37:05 +0100 Subject: cscope: ignore EINTR while reading the prompt (#8079) The following code.. au VimEnter,DirChanged * if filereadable('.git/cscope.out') | \ exe 'cs add .git/cscope.out' | endif ..would lead to this issue: Error detected while processing VimEnter Auto commands for "*": cs_read_prompt EOF: Interrupted system call Error detected while processing VimEnter Auto commands for "*": E262: error reading cscope connection 0 A signal, in this case SIGCHLD, during a system call leads to errno being set to EINTR. Ignore it. This is merely a workaround for the time being. We don't block SIGCHLD signals, since they're needed by libuv. The proper fix would be to rewrite if_cscope.c to use libuv for handling processes. --- src/nvim/if_cscope.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index 773e29693c..793142f153 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -1685,8 +1685,15 @@ static int cs_read_prompt(size_t i) assert(IOSIZE >= cs_emsg_len); size_t maxlen = IOSIZE - cs_emsg_len; - for (;; ) { - while ((ch = getc(csinfo[i].fr_fp)) != EOF && ch != CSCOPE_PROMPT[0]) { + while (1) { + while (1) { + do { + errno = 0; + ch = fgetc(csinfo[i].fr_fp); + } while (ch == EOF && errno == EINTR && ferror(csinfo[i].fr_fp)); + if (ch == EOF || ch == CSCOPE_PROMPT[0]) { + break; + } // if there is room and char is printable if (bufpos < maxlen - 1 && vim_isprintc(ch)) { // lazy buffer allocation @@ -1715,9 +1722,13 @@ static int cs_read_prompt(size_t i) } } - for (size_t n = 0; n < strlen(CSCOPE_PROMPT); ++n) { - if (n > 0) - ch = (char)getc(csinfo[i].fr_fp); + for (size_t n = 0; n < strlen(CSCOPE_PROMPT); n++) { + if (n > 0) { + do { + errno = 0; + ch = fgetc(csinfo[i].fr_fp); + } while (ch == EOF && errno == EINTR && ferror(csinfo[i].fr_fp)); + } if (ch == EOF) { PERROR("cs_read_prompt EOF"); if (buf != NULL && buf[0] != NUL) -- cgit From 3d2f4154b1d5d0bb063951c830e009505bdce359 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Thu, 1 Mar 2018 10:23:21 +0100 Subject: third-party: build all deps with debugging symbols (#8042) When building with CMAKE_BUILD_TYPE=Debug, the dependencies are built like this: | Dep | Defaults | Debug | |------------|-----------|---------------------------------------------| | unibilium | `-O2` | `make CFLAGS=-O0 DEBUG=1` | | msgpack | `-g -O3` | `cmake . -DCMAKE_C_FLAGS_DEBUG="-O0 -ggdb"` | | libuv | `-g -O2` | `./configure CFLAGS="-O0 -ggdb"` | | luv | `-g -O2` | `cmake . -DCMAKE_C_FLAGS_DEBUG="-O0 -ggdb"` | | libvterm | not set | `make CFLAGS=-O0 DEBUG=1` | | libtermkey | not set | `make CFLAGS=-O0 DEBUG=1` | | jemalloc | `-g3 -O3` | `./configure CFLAGS="-O0 -ggdb"` | | gperf | `-g -O2` | `./configure CXXFLAGS="-O0 -ggdb"` | | luajit | `-g -O2` | haven't checked yet | This means that only unibilium, libtermkey, and libvterm don't build with debugging symbols by default. Build them with debugging symbols and optimisations that don't hinder debugging: -Og -g --- third-party/CMakeLists.txt | 10 ++++++++++ third-party/cmake/BuildLibtermkey.cmake | 1 + third-party/cmake/BuildLibvterm.cmake | 7 ++++--- third-party/cmake/BuildUnibilium.cmake | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index ceebb4cf1d..c523ecea00 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -2,6 +2,9 @@ cmake_minimum_required (VERSION 2.8.7) project(NVIM_DEPS) +# Needed for: check_c_compiler_flag() +include(CheckCCompilerFlag) + # Point CMake at any custom modules we may ship list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") @@ -11,6 +14,13 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() +set(DEFAULT_MAKE_CFLAGS CFLAGS+=-g) + +check_c_compiler_flag(-Og HAS_OG_FLAG) +if(HAS_OG_FLAG) + set(DEFAULT_MAKE_CFLAGS CFLAGS+=-Og ${DEFAULT_MAKE_CFLAGS}) +endif() + set(DEPS_INSTALL_DIR "${CMAKE_BINARY_DIR}/usr" CACHE PATH "Dependencies install directory.") set(DEPS_BIN_DIR "${DEPS_INSTALL_DIR}/bin" CACHE PATH "Dependencies binary install directory.") set(DEPS_LIB_DIR "${DEPS_INSTALL_DIR}/lib" CACHE PATH "Dependencies library install directory.") diff --git a/third-party/cmake/BuildLibtermkey.cmake b/third-party/cmake/BuildLibtermkey.cmake index 4b581c2a01..bc4db4c9b1 100644 --- a/third-party/cmake/BuildLibtermkey.cmake +++ b/third-party/cmake/BuildLibtermkey.cmake @@ -43,6 +43,7 @@ ExternalProject_Add(libtermkey PREFIX=${DEPS_INSTALL_DIR} PKG_CONFIG_PATH=${DEPS_LIB_DIR}/pkgconfig CFLAGS=-fPIC + ${DEFAULT_MAKE_CFLAGS} install) endif() diff --git a/third-party/cmake/BuildLibvterm.cmake b/third-party/cmake/BuildLibvterm.cmake index 5ea8314da5..12e8fdd7d0 100644 --- a/third-party/cmake/BuildLibvterm.cmake +++ b/third-party/cmake/BuildLibvterm.cmake @@ -47,9 +47,10 @@ if(WIN32) set(LIBVTERM_INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE}) else() set(LIBVTERM_INSTALL_COMMAND ${MAKE_PRG} CC=${DEPS_C_COMPILER} - PREFIX=${DEPS_INSTALL_DIR} - CFLAGS=-fPIC - install) + PREFIX=${DEPS_INSTALL_DIR} + CFLAGS=-fPIC + ${DEFAULT_MAKE_CFLAGS} + install) endif() BuildLibvterm(CONFIGURE_COMMAND ${LIBVTERM_CONFIGURE_COMMAND} diff --git a/third-party/cmake/BuildUnibilium.cmake b/third-party/cmake/BuildUnibilium.cmake index a5ec6c01eb..a1b9a39bb6 100644 --- a/third-party/cmake/BuildUnibilium.cmake +++ b/third-party/cmake/BuildUnibilium.cmake @@ -20,6 +20,7 @@ ExternalProject_Add(unibilium BUILD_COMMAND ${MAKE_PRG} CC=${DEPS_C_COMPILER} PREFIX=${DEPS_INSTALL_DIR} CFLAGS=-fPIC + ${DEFAULT_MAKE_CFLAGS} INSTALL_COMMAND ${MAKE_PRG} PREFIX=${DEPS_INSTALL_DIR} install) list(APPEND THIRD_PARTY_DEPS unibilium) -- cgit