diff options
author | Patrick Palka <patrick@parcs.ath.cx> | 2015-07-14 20:29:21 -0400 |
---|---|---|
committer | Patrick Palka <patrick@parcs.ath.cx> | 2015-07-25 09:53:01 -0400 |
commit | 4a11f2065906976675808364ddbd1c0f77eea41f (patch) | |
tree | 8b25495190b4d41b1785910c4cc4fd709d0a628a /readline/callback.c | |
parent | a496fbc8802f0a5719db6347a43cc869e03d83c9 (diff) | |
download | gdb-4a11f2065906976675808364ddbd1c0f77eea41f.zip gdb-4a11f2065906976675808364ddbd1c0f77eea41f.tar.gz gdb-4a11f2065906976675808364ddbd1c0f77eea41f.tar.bz2 |
Sync readline/ to version 7.0 alpha
This patch syncs our upstream copy of readline from version 6.2 to the
latest version, 7.0 alpha (released July 10 2015).
I essentially copied what was done the last time readline was synced,
when Jan updated to readline 6.2 in 2011:
http://sourceware.org/ml/gdb-patches/2011-05/msg00003.html
Procedure:
1. I extracted the readline-7.0-alpha tarball on top of readline/.
2. I deleted all the new files under doc/ that were deliberately omitted
before.
3. I regenerated readline/configure and readline/examples/rlfe/configure
using autoconf 2.64. No other configure files need regenerating.
4. I updated the function gdb_printable_part in completer.c with a
trivial change made to the readline function it is based off of,
printable_part in readline/complete.c. There is more work to be done in
completer.c to sync it with readline/complete.c, but it is non-trivial
and should probably be done separately anyway.
Local patches that had to be reapplied:
None. readline 7.0 alpha contains all of our local readline
patches.
New files in readline/:
colors.{c,h}
examples/{hist_erasedups,hist_purgecmd,rl-callbacktest,rlbasic}.c
parse-colors.{c,h}
readline.pc.in
configure.ac
Deleted files in readline/:
configure.in
Regressions:
After the sync there is one testsuite regression, the test
"signal SIGINT" in gdb.gdb/selftest.exp which now FAILs. Previously,
the readline 6.2 SIGINT handler would temporarily reinstall the
underlying application's SIGINT handler and immediately re-raise SIGINT
so that the orginal handler gets invoked. But now (since readline 6.3)
its SIGINT handler does not re-raise SIGINT or directly invoke the
original handler; it now sets a flag marking that SIGINT was raised, and
waits until readline explicitly has control to call the application's
SIGINT handler. Anyway, because SIGINT is no longer re-raised from
within readline's SIGINT handler, doing "signal SIGINT" with a stopped
inferior gdb process will no longer resume and then immediately stop the
process (since there is no 2nd SIGINT to immediately catch). Instead,
the inferior gdb process will now just print "Quit" and continue to run.
So with this commit, this particular test case is adjusted to reflect
this change in behavior (we now have to send a 2nd SIGINT manually to
stop it).
Aside from this one testsuite regression, I personally noticed no
regression in user-visible behavior. Though I only tested on x86_64
and on i686 Debian Stretch.
Getting this kind of change in at the start of the GDB 7.11 development
cycle will allow us to get a lot of passive testing from developers and
from bleeding-edge users.
readline/ChangeLog.gdb:
Import readline 7.0 alpha
* configure: Regenerate.
* examples/rlfe/configure: Regenerate.
gdb/ChangeLog:
* completer.c (gdb_printable_part): Sync with readline function
it is based off of.
gdb/testsuite/ChangeLog:
* gdb.gdb/selftest.exp (test_with_self): Update test to now
expect the GDB inferior to no longer immediately stop after
being resumed with "signal SIGINT".
Diffstat (limited to 'readline/callback.c')
-rw-r--r-- | readline/callback.c | 70 |
1 files changed, 57 insertions, 13 deletions
diff --git a/readline/callback.c b/readline/callback.c index 7682cd0..0fc3f90 100644 --- a/readline/callback.c +++ b/readline/callback.c @@ -62,8 +62,10 @@ _rl_callback_generic_arg *_rl_callback_data = 0; whenever a complete line of input is ready. The user must then call rl_callback_read_char() every time some input is available, and rl_callback_read_char() will call the user's function with the complete - text read in at each end of line. The terminal is kept prepped and - signals handled all the time, except during calls to the user's function. */ + text read in at each end of line. The terminal is kept prepped + all the time, except during calls to the user's function. Signal + handlers are only installed when the application calls back into + readline, so readline doesn't `steal' signals from the application. */ rl_vcpfunc_t *rl_linefunc; /* user callback function */ static int in_handler; /* terminal_prepped and signals set? */ @@ -80,10 +82,6 @@ _rl_callback_newline () if (rl_prep_term_function) (*rl_prep_term_function) (_rl_meta_flag); - -#if defined (HANDLE_SIGNALS) - rl_set_signals (); -#endif } readline_internal_setup (); @@ -102,6 +100,16 @@ rl_callback_handler_install (prompt, linefunc) _rl_callback_newline (); } +#if defined (HANDLE_SIGNALS) +#define CALLBACK_READ_RETURN() \ + do { \ + rl_clear_signals (); \ + return; \ + } while (0) +#else +#define CALLBACK_READ_RETURN() return +#endif + /* Read one character, and dispatch to the handler if it ends the line. */ void rl_callback_read_char () @@ -117,15 +125,24 @@ rl_callback_read_char () } memcpy ((void *)olevel, (void *)_rl_top_level, sizeof (procenv_t)); +#if defined (HAVE_POSIX_SIGSETJMP) + jcode = sigsetjmp (_rl_top_level, 0); +#else jcode = setjmp (_rl_top_level); +#endif if (jcode) { (*rl_redisplay_function) (); _rl_want_redisplay = 0; memcpy ((void *)_rl_top_level, (void *)olevel, sizeof (procenv_t)); - return; + CALLBACK_READ_RETURN (); } +#if defined (HANDLE_SIGNALS) + /* Install signal handlers only when readline has control. */ + rl_set_signals (); +#endif + do { RL_CHECK_SIGNALS (); @@ -135,12 +152,13 @@ rl_callback_read_char () if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING)) rl_callback_read_char (); - return; + CALLBACK_READ_RETURN (); } else if (RL_ISSTATE (RL_STATE_NSEARCH)) { eof = _rl_nsearch_callback (_rl_nscxt); - return; + + CALLBACK_READ_RETURN (); } #if defined (VI_MODE) else if (RL_ISSTATE (RL_STATE_VIMOTION)) @@ -151,7 +169,7 @@ rl_callback_read_char () if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) _rl_internal_char_cleanup (); - return; + CALLBACK_READ_RETURN (); } #endif else if (RL_ISSTATE (RL_STATE_NUMERICARG)) @@ -163,7 +181,7 @@ rl_callback_read_char () else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) _rl_internal_char_cleanup (); - return; + CALLBACK_READ_RETURN (); } else if (RL_ISSTATE (RL_STATE_MULTIKEY)) { @@ -180,7 +198,7 @@ rl_callback_read_char () { /* This allows functions that simply need to read an additional character (like quoted-insert) to register a function to be - called when input is available. _rl_callback_data is simply a + called when input is available. _rl_callback_data is a pointer to a struct that has the argument count originally passed to the registering function and space for any additional parameters. */ @@ -230,6 +248,8 @@ rl_callback_read_char () } } while (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT)); + + CALLBACK_READ_RETURN (); } /* Remove the handler, and make sure the terminal is in its normal state. */ @@ -264,10 +284,34 @@ _rl_callback_data_alloc (count) return arg; } -void _rl_callback_data_dispose (arg) +void +_rl_callback_data_dispose (arg) _rl_callback_generic_arg *arg; { xfree (arg); } +/* Make sure that this agrees with cases in rl_callback_read_char */ +void +rl_callback_sigcleanup () +{ + if (RL_ISSTATE (RL_STATE_CALLBACK) == 0) + return; + + if (RL_ISSTATE (RL_STATE_ISEARCH)) + _rl_isearch_cleanup (_rl_iscxt, 0); + else if (RL_ISSTATE (RL_STATE_NSEARCH)) + _rl_nsearch_cleanup (_rl_nscxt, 0); + else if (RL_ISSTATE (RL_STATE_VIMOTION)) + RL_UNSETSTATE (RL_STATE_VIMOTION); + else if (RL_ISSTATE (RL_STATE_NUMERICARG)) + { + _rl_argcxt = 0; + RL_UNSETSTATE (RL_STATE_NUMERICARG); + } + else if (RL_ISSTATE (RL_STATE_MULTIKEY)) + RL_UNSETSTATE (RL_STATE_MULTIKEY); + + _rl_callback_func = 0; +} #endif |