Fixes buggy readline 7 in GDB, Alexpux/MINGW-packages#1952 (#2105)
We revert to using Readline from GDB We apply a patch from GDB master related to Readline and Mingw TUI works too.
This commit is contained in:
committed by
Алексей
parent
4e0e462a51
commit
eea0a04b2f
@@ -8,7 +8,7 @@ pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
|
||||
# Until https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62279 is
|
||||
# fixed, we will stick with 7.6.2 which hasn't got this bug..
|
||||
pkgver=7.12
|
||||
pkgrel=1
|
||||
pkgrel=3
|
||||
pkgdesc="GNU Debugger (mingw-w64)"
|
||||
arch=('any')
|
||||
url="https://www.gnu.org/software/gdb/"
|
||||
@@ -17,8 +17,7 @@ groups=("${MINGW_PACKAGE_PREFIX}-toolchain")
|
||||
depends=("${MINGW_PACKAGE_PREFIX}-expat"
|
||||
"${MINGW_PACKAGE_PREFIX}-libiconv"
|
||||
"${MINGW_PACKAGE_PREFIX}-python2"
|
||||
"${MINGW_PACKAGE_PREFIX}-zlib"
|
||||
"${MINGW_PACKAGE_PREFIX}-readline")
|
||||
"${MINGW_PACKAGE_PREFIX}-zlib")
|
||||
checkdepends=('dejagnu' 'bc')
|
||||
makedepends=("${MINGW_PACKAGE_PREFIX}-iconv"
|
||||
"${MINGW_PACKAGE_PREFIX}-ncurses"
|
||||
@@ -31,7 +30,8 @@ source=(https://ftp.gnu.org/gnu/gdb/${_realname}-${pkgver}.tar.xz{,.sig}
|
||||
'gdb-7.8.1-mingw-gcc-4.7.patch'
|
||||
'gdb-7.6.2-mingw-gcc-4.7.patch'
|
||||
'gdb-perfomance.patch'
|
||||
'gdb-fix-using-gnu-print.patch')
|
||||
'gdb-fix-using-gnu-print.patch'
|
||||
'gdb-7.12-readline-mingw.patch')
|
||||
sha256sums=('834ff3c5948b30718343ea57b11cbc3235d7995c6a4f3a5cecec8c8114164f94'
|
||||
'SKIP'
|
||||
'dea2bbad4967280910559c6a11b865aeec19cab34647fb5894cb498b24b14462'
|
||||
@@ -39,7 +39,8 @@ sha256sums=('834ff3c5948b30718343ea57b11cbc3235d7995c6a4f3a5cecec8c8114164f94'
|
||||
'225608a1e486ee98641611804b07209915367c6767a735ae928175ad45b93060'
|
||||
'82ea717b628c8970055a9cbb8edaed8fbebc2cac27467337426dfc4b4c514a6b'
|
||||
'6be0f95483e02d5447c93ab5e2c9554d254c6888b1fa3f3a4c011cd6a0a403ad'
|
||||
'264eba33ef71c4762514a634dcf94fdb778914dbba6ce99e63804fe063225d97')
|
||||
'264eba33ef71c4762514a634dcf94fdb778914dbba6ce99e63804fe063225d97'
|
||||
'db047e044a573b6cd1cc154a6a505a1f1b80ec5654f3779c2486cdea24c13feb')
|
||||
|
||||
prepare() {
|
||||
cd ${srcdir}/${_realname}-${pkgver}
|
||||
@@ -54,6 +55,9 @@ prepare() {
|
||||
|
||||
patch -p1 -i ${srcdir}/gdb-fix-using-gnu-print.patch
|
||||
|
||||
# https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=7f3c5ec870943f7f32c946ff9459dfd04fcb8e07
|
||||
patch -p1 -i ${srcdir}/gdb-7.12-readline-mingw.patch
|
||||
|
||||
# hack! - libiberty configure tests for header files using "$CPP $CPPFLAGS"
|
||||
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" libiberty/configure
|
||||
}
|
||||
@@ -76,7 +80,6 @@ build() {
|
||||
--with-system-gdbinit=${MINGW_PREFIX}/etc/gdbinit \
|
||||
--with-python=${MINGW_PREFIX}/bin/python-config-u.sh \
|
||||
--with-expat \
|
||||
--with-system-readline \
|
||||
--with-libiconv-prefix=${MINGW_PREFIX} \
|
||||
--with-zlib \
|
||||
--with-lzma \
|
||||
|
||||
387
mingw-w64-gdb/gdb-7.12-readline-mingw.patch
Normal file
387
mingw-w64-gdb/gdb-7.12-readline-mingw.patch
Normal file
@@ -0,0 +1,387 @@
|
||||
From 7f3c5ec870943f7f32c946ff9459dfd04fcb8e07 Mon Sep 17 00:00:00 2001
|
||||
From: Eli Zaretskii <eliz@gnu.org>
|
||||
Date: Sat, 17 Sep 2016 11:50:37 +0300
|
||||
Subject: [PATCH] Improve MinGW support in Readline
|
||||
|
||||
These changes were already accepted upstream in Readline,
|
||||
but GDB did not yet import a newer Readline version.
|
||||
|
||||
readline/Changelog.gdb:
|
||||
|
||||
* util.c: Include rlshell.h.
|
||||
(_rl_tropen) [_WIN32 && !__CYGWIN__]: Open the trace file in the
|
||||
user's temporary directory.
|
||||
* tcap.h [HAVE_NCURSES_TERMCAP_H]: Include ncurses/termcap.h.
|
||||
* input.c (w32_isatty) [_WIN32 && !__CYGWIN__]: New function, to
|
||||
replace isatty that is not reliable enough on MS-Windows.
|
||||
(isatty) [_WIN32 && !__CYGWIN__]: Redirect to w32_isatty.
|
||||
(rl_getc): Call _getch, not getch, which could be an ncurses
|
||||
function when linked with ncurses, in which case getch will return
|
||||
EOF for any keystroke, because there's no curses window.
|
||||
* tilde.c (tilde_expand_word) [_WIN32]:
|
||||
* histfile.c (history_filename) [_WIN32]: Windows-specific
|
||||
environment variable to replace HOME if that is undefined.
|
||||
* funmap.c (default_funmap): Compile rl_paste_from_clipboard on
|
||||
all Windows platforms, not just Cygwin.
|
||||
* readline.h (rl_paste_from_clipboard): Include declaration for
|
||||
all Windows platforms.
|
||||
* display.c (insert_some_chars, delete_chars): Don't use the
|
||||
MinGW-specific code if linked with ncurses.
|
||||
* configure.in:
|
||||
* config.h.in: Support ncurses/termcap.h. The configure script
|
||||
was updated accordingly.
|
||||
* complete.c [_WIN32 && !__CYGWIN__]: Initialize
|
||||
_rl_completion_case_fold to 1.
|
||||
(printable_part, rl_filename_completion_function)
|
||||
[_WIN32 && !__CYGWIN__]: Handle the drive letter.
|
||||
---
|
||||
readline/ChangeLog.gdb | 37 +++++++++++++++++++++++++++++++++++++
|
||||
readline/complete.c | 9 +++++----
|
||||
readline/config.h.in | 3 +++
|
||||
readline/configure | 17 +++++++++++++++++
|
||||
readline/configure.in | 3 +++
|
||||
readline/display.c | 4 ++--
|
||||
readline/funmap.c | 2 +-
|
||||
readline/histfile.c | 4 ++++
|
||||
readline/input.c | 34 +++++++++++++++++++++++++++++++++-
|
||||
readline/kill.c | 2 +-
|
||||
readline/readline.h | 4 ++--
|
||||
readline/tcap.h | 2 ++
|
||||
readline/tilde.c | 4 ++++
|
||||
readline/util.c | 11 +++++++++++
|
||||
14 files changed, 125 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/readline/ChangeLog.gdb b/readline/ChangeLog.gdb
|
||||
index 43abd19..91e1dbd 100644
|
||||
--- a/readline/ChangeLog.gdb
|
||||
+++ b/readline/ChangeLog.gdb
|
||||
@@ -1,3 +1,40 @@
|
||||
+2016-09-17 Eli Zaretskii <eliz@gnu.org>
|
||||
+
|
||||
+ * util.c: Include rlshell.h.
|
||||
+ (_rl_tropen) [_WIN32 && !__CYGWIN__]: Open the trace file in the
|
||||
+ user's temporary directory.
|
||||
+
|
||||
+ * tcap.h [HAVE_NCURSES_TERMCAP_H]: Include ncurses/termcap.h.
|
||||
+
|
||||
+ * input.c (w32_isatty) [_WIN32 && !__CYGWIN__]: New function, to
|
||||
+ replace isatty that is not reliable enough on MS-Windows.
|
||||
+ (isatty) [_WIN32 && !__CYGWIN__]: Redirect to w32_isatty.
|
||||
+ (rl_getc): Call _getch, not getch, which could be an ncurses
|
||||
+ function when linked with ncurses, in which case getch will return
|
||||
+ EOF for any keystroke, because there's no curses window.
|
||||
+
|
||||
+ * tilde.c (tilde_expand_word) [_WIN32]:
|
||||
+ * histfile.c (history_filename) [_WIN32]: Windows-specific
|
||||
+ environment variable to replace HOME if that is undefined.
|
||||
+
|
||||
+ * funmap.c (default_funmap): Compile rl_paste_from_clipboard on
|
||||
+ all Windows platforms, not just Cygwin.
|
||||
+
|
||||
+ * readline.h (rl_paste_from_clipboard): Include declaration for
|
||||
+ all Windows platforms.
|
||||
+
|
||||
+ * display.c (insert_some_chars, delete_chars): Don't use the
|
||||
+ MinGW-specific code if linked with ncurses.
|
||||
+
|
||||
+ * configure.in:
|
||||
+ * config.h.in: Support ncurses/termcap.h. The configure script
|
||||
+ was updated accordingly.
|
||||
+
|
||||
+ * complete.c [_WIN32 && !__CYGWIN__]: Initialize
|
||||
+ _rl_completion_case_fold to 1.
|
||||
+ (printable_part, rl_filename_completion_function)
|
||||
+ [_WIN32 && !__CYGWIN__]: Handle the drive letter.
|
||||
+
|
||||
2014-12-30 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* complete.c (stat_char) [_WIN32]: Don't use 'access' and X_OK on
|
||||
diff --git a/readline/complete.c b/readline/complete.c
|
||||
index a5ce803..5733d4e 100644
|
||||
--- a/readline/complete.c
|
||||
+++ b/readline/complete.c
|
||||
@@ -156,7 +156,8 @@ int _rl_complete_mark_symlink_dirs = 0;
|
||||
int _rl_print_completions_horizontally;
|
||||
|
||||
/* Non-zero means that case is not significant in filename completion. */
|
||||
-#if defined (__MSDOS__) && !defined (__DJGPP__)
|
||||
+#if defined (__MSDOS__) && !defined (__DJGPP__) \
|
||||
+ || (defined (_WIN32) && !defined (__CYGWIN__))
|
||||
int _rl_completion_case_fold = 1;
|
||||
#else
|
||||
int _rl_completion_case_fold = 0;
|
||||
@@ -636,7 +637,7 @@ printable_part (pathname)
|
||||
return (pathname);
|
||||
|
||||
temp = strrchr (pathname, '/');
|
||||
-#if defined (__MSDOS__)
|
||||
+#if defined (__MSDOS__) || defined (_WIN32)
|
||||
if (temp == 0 && ISALPHA ((unsigned char)pathname[0]) && pathname[1] == ':')
|
||||
temp = pathname + 1;
|
||||
#endif
|
||||
@@ -2186,7 +2187,7 @@ rl_filename_completion_function (text, state)
|
||||
|
||||
temp = strrchr (dirname, '/');
|
||||
|
||||
-#if defined (__MSDOS__)
|
||||
+#if defined (__MSDOS__) || defined (_WIN32)
|
||||
/* special hack for //X/... */
|
||||
if (dirname[0] == '/' && dirname[1] == '/' && ISALPHA ((unsigned char)dirname[2]) && dirname[3] == '/')
|
||||
temp = strrchr (dirname + 3, '/');
|
||||
@@ -2197,7 +2198,7 @@ rl_filename_completion_function (text, state)
|
||||
strcpy (filename, ++temp);
|
||||
*temp = '\0';
|
||||
}
|
||||
-#if defined (__MSDOS__)
|
||||
+#if defined (__MSDOS__) || (defined (_WIN32) && !defined (__CYGWIN__))
|
||||
/* searches from current directory on the drive */
|
||||
else if (ISALPHA ((unsigned char)dirname[0]) && dirname[1] == ':')
|
||||
{
|
||||
diff --git a/readline/config.h.in b/readline/config.h.in
|
||||
index 8560c4b..86d86cf 100644
|
||||
--- a/readline/config.h.in
|
||||
+++ b/readline/config.h.in
|
||||
@@ -186,6 +186,9 @@
|
||||
/* Define if you have the <termcap.h> header file. */
|
||||
#undef HAVE_TERMCAP_H
|
||||
|
||||
+/* Define if you have the <ncurses/termcap.h> header file. */
|
||||
+#undef HAVE_NCURSES_TERMCAP_H
|
||||
+
|
||||
/* Define if you have the <termio.h> header file. */
|
||||
#undef HAVE_TERMIO_H
|
||||
|
||||
diff --git a/readline/configure b/readline/configure
|
||||
index 09de45d..249ab7b 100755
|
||||
--- a/readline/configure
|
||||
+++ b/readline/configure
|
||||
@@ -5845,6 +5845,23 @@ if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
+if test "$TERMCAP_LIB" = "-lncurses"; then
|
||||
+
|
||||
+for ac_header in ncurses/termcap.h
|
||||
+do :
|
||||
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
|
||||
+eval as_val=\$$as_ac_Header
|
||||
+ if test "x$as_val" = x""yes; then :
|
||||
+ cat >>confdefs.h <<_ACEOF
|
||||
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
|
||||
+_ACEOF
|
||||
+
|
||||
+fi
|
||||
+
|
||||
+done
|
||||
+
|
||||
+fi
|
||||
|
||||
for ac_header in wctype.h
|
||||
do :
|
||||
diff --git a/readline/configure.in b/readline/configure.in
|
||||
index b395af4..b6d7167 100644
|
||||
--- a/readline/configure.in
|
||||
+++ b/readline/configure.in
|
||||
@@ -198,6 +198,9 @@ if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then
|
||||
TERMCAP_LIB=-ltermcap #default
|
||||
fi
|
||||
fi
|
||||
+if test "$TERMCAP_LIB" = "-lncurses"; then
|
||||
+ AC_CHECK_HEADERS(ncurses/termcap.h)
|
||||
+fi
|
||||
|
||||
BASH_CHECK_MULTIBYTE
|
||||
|
||||
diff --git a/readline/display.c b/readline/display.c
|
||||
index 7653d87..9044305 100644
|
||||
--- a/readline/display.c
|
||||
+++ b/readline/display.c
|
||||
@@ -2374,7 +2374,7 @@ insert_some_chars (string, count, col)
|
||||
char *string;
|
||||
int count, col;
|
||||
{
|
||||
-#if defined (__MSDOS__) || defined (__MINGW32__)
|
||||
+#if defined (__MSDOS__) || (defined (__MINGW32__) && !defined (NCURSES_VERSION))
|
||||
_rl_output_some_chars (string, count);
|
||||
#else
|
||||
/* DEBUGGING */
|
||||
@@ -2426,7 +2426,7 @@ delete_chars (count)
|
||||
if (count > _rl_screenwidth) /* XXX */
|
||||
return;
|
||||
|
||||
-#if !defined (__MSDOS__) && !defined (__MINGW32__)
|
||||
+#if !defined (__MSDOS__) && !(defined (__MINGW32__) && !defined (NCURSES_VERSION))
|
||||
if (_rl_term_DC && *_rl_term_DC)
|
||||
{
|
||||
char *buffer;
|
||||
diff --git a/readline/funmap.c b/readline/funmap.c
|
||||
index 86e375f..e61d69f 100644
|
||||
--- a/readline/funmap.c
|
||||
+++ b/readline/funmap.c
|
||||
@@ -113,7 +113,7 @@ static const FUNMAP default_funmap[] = {
|
||||
{ "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
|
||||
{ "old-menu-complete", rl_old_menu_complete },
|
||||
{ "overwrite-mode", rl_overwrite_mode },
|
||||
-#ifdef __CYGWIN__
|
||||
+#ifdef _WIN32
|
||||
{ "paste-from-clipboard", rl_paste_from_clipboard },
|
||||
#endif
|
||||
{ "possible-completions", rl_possible_completions },
|
||||
diff --git a/readline/histfile.c b/readline/histfile.c
|
||||
index 30a6182..fffeb3f 100644
|
||||
--- a/readline/histfile.c
|
||||
+++ b/readline/histfile.c
|
||||
@@ -123,6 +123,10 @@ history_filename (filename)
|
||||
return (return_val);
|
||||
|
||||
home = sh_get_env_value ("HOME");
|
||||
+#ifdef _WIN32
|
||||
+ if (!home)
|
||||
+ home = sh_get_env_value ("APPDATA");
|
||||
+#endif
|
||||
|
||||
if (home == 0)
|
||||
{
|
||||
diff --git a/readline/input.c b/readline/input.c
|
||||
index 7c74c99..e35277f 100644
|
||||
--- a/readline/input.c
|
||||
+++ b/readline/input.c
|
||||
@@ -86,6 +86,36 @@ static int ibuffer_space PARAMS((void));
|
||||
static int rl_get_char PARAMS((int *));
|
||||
static int rl_gather_tyi PARAMS((void));
|
||||
|
||||
+#if defined (_WIN32) && !defined (__CYGWIN__)
|
||||
+
|
||||
+/* 'isatty' in the Windows runtime returns non-zero for every
|
||||
+ character device, including the null device. Repair that. */
|
||||
+#include <io.h>
|
||||
+#define WIN32_LEAN_AND_MEAN 1
|
||||
+#include <windows.h>
|
||||
+
|
||||
+int w32_isatty (int fd)
|
||||
+{
|
||||
+ if (_isatty(fd))
|
||||
+ {
|
||||
+ HANDLE h = (HANDLE) _get_osfhandle (fd);
|
||||
+ DWORD ignored;
|
||||
+
|
||||
+ if (h == INVALID_HANDLE_VALUE)
|
||||
+ {
|
||||
+ errno = EBADF;
|
||||
+ return 0;
|
||||
+ }
|
||||
+ if (GetConsoleMode (h, &ignored) != 0)
|
||||
+ return 1;
|
||||
+ }
|
||||
+ errno = ENOTTY;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#define isatty(x) w32_isatty(x)
|
||||
+#endif
|
||||
+
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Character Input Buffering */
|
||||
@@ -465,8 +495,10 @@ rl_getc (stream)
|
||||
RL_CHECK_SIGNALS ();
|
||||
|
||||
#if defined (__MINGW32__)
|
||||
+ /* Use _getch to make sure we call the function from MS runtime,
|
||||
+ even if some curses library is linked in. */
|
||||
if (isatty (fileno (stream)))
|
||||
- return (getch ());
|
||||
+ return (_getch ());
|
||||
#endif
|
||||
result = read (fileno (stream), &c, sizeof (unsigned char));
|
||||
|
||||
diff --git a/readline/kill.c b/readline/kill.c
|
||||
index 1a78783..ce26d0a 100644
|
||||
--- a/readline/kill.c
|
||||
+++ b/readline/kill.c
|
||||
@@ -657,7 +657,7 @@ rl_yank_last_arg (count, key)
|
||||
}
|
||||
|
||||
/* A special paste command for users of Cygnus's cygwin32. */
|
||||
-#if defined (__CYGWIN__)
|
||||
+#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
|
||||
int
|
||||
diff --git a/readline/readline.h b/readline/readline.h
|
||||
index 0de168c..9772746 100644
|
||||
--- a/readline/readline.h
|
||||
+++ b/readline/readline.h
|
||||
@@ -172,8 +172,8 @@ extern int rl_yank PARAMS((int, int));
|
||||
extern int rl_yank_pop PARAMS((int, int));
|
||||
extern int rl_yank_nth_arg PARAMS((int, int));
|
||||
extern int rl_yank_last_arg PARAMS((int, int));
|
||||
-/* Not available unless __CYGWIN__ is defined. */
|
||||
-#ifdef __CYGWIN__
|
||||
+/* Not available unless _WIN32 is defined. */
|
||||
+#ifdef _WIN32
|
||||
extern int rl_paste_from_clipboard PARAMS((int, int));
|
||||
#endif
|
||||
|
||||
diff --git a/readline/tcap.h b/readline/tcap.h
|
||||
index 9d09b7a..dbc1789 100644
|
||||
--- a/readline/tcap.h
|
||||
+++ b/readline/tcap.h
|
||||
@@ -31,6 +31,8 @@
|
||||
# include "rltty.h"
|
||||
# endif
|
||||
# include <termcap.h>
|
||||
+#elif defined (HAVE_NCURSES_TERMCAP_H)
|
||||
+# include <ncurses/termcap.h>
|
||||
#else
|
||||
|
||||
/* On Solaris2, sys/types.h #includes sys/reg.h, which #defines PC.
|
||||
diff --git a/readline/tilde.c b/readline/tilde.c
|
||||
index 1c53a45..d4c1da9 100644
|
||||
--- a/readline/tilde.c
|
||||
+++ b/readline/tilde.c
|
||||
@@ -360,6 +360,10 @@ tilde_expand_word (filename)
|
||||
{
|
||||
/* Prefix $HOME to the rest of the string. */
|
||||
expansion = sh_get_env_value ("HOME");
|
||||
+#ifdef _WIN32
|
||||
+ if (!expansion)
|
||||
+ expansion = sh_get_env_value ("APPDATA");
|
||||
+#endif
|
||||
|
||||
/* If there is no HOME variable, look up the directory in
|
||||
the password database. */
|
||||
diff --git a/readline/util.c b/readline/util.c
|
||||
index 321dee2..d402fce 100644
|
||||
--- a/readline/util.c
|
||||
+++ b/readline/util.c
|
||||
@@ -55,6 +55,7 @@
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
+#include "rlshell.h"
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
@@ -507,7 +508,17 @@ _rl_tropen ()
|
||||
|
||||
if (_rl_tracefp)
|
||||
fclose (_rl_tracefp);
|
||||
+#if defined (_WIN32) && !defined (__CYGWIN__)
|
||||
+ /* Windows doesn't have /var/tmp, so open the trace file in the
|
||||
+ user's temporary directory instead. */
|
||||
+ sprintf (fnbuf, "%s/rltrace.%ld",
|
||||
+ (sh_get_env_value ("TEMP")
|
||||
+ ? sh_get_env_value ("TEMP")
|
||||
+ : "."),
|
||||
+ getpid());
|
||||
+#else
|
||||
sprintf (fnbuf, "/var/tmp/rltrace.%ld", getpid());
|
||||
+#endif
|
||||
unlink(fnbuf);
|
||||
_rl_tracefp = fopen (fnbuf, "w+");
|
||||
return _rl_tracefp != 0;
|
||||
--
|
||||
1.7.1
|
||||
|
||||
Reference in New Issue
Block a user