diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 67679310672..88c18e07af3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-10-29 Pedro Alves + + * tui/tui.c (tui_rl_switch_mode): Wrap tui_enable/tui_disable in + TRY_CATCH. + 2014-10-29 Joel Brobecker * arm-tdep.c (arm_skip_stack_protector): Return early if diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index ca66ccd0f4f..cb85fb02200 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -90,15 +90,30 @@ static Keymap tui_readline_standard_keymap; static int tui_rl_switch_mode (int notused1, int notused2) { - if (tui_active) + volatile struct gdb_exception ex; + + /* Don't let exceptions escape. We're in the middle of a readline + callback that isn't prepared for that. */ + TRY_CATCH (ex, RETURN_MASK_ALL) { - tui_disable (); - rl_prep_terminal (0); + if (tui_active) + { + tui_disable (); + rl_prep_terminal (0); + } + else + { + /* If tui_enable throws, we'll re-prep below. */ + rl_deprep_terminal (); + tui_enable (); + } } - else + if (ex.reason < 0) { - rl_deprep_terminal (); - tui_enable (); + exception_print (gdb_stderr, ex); + + if (!tui_active) + rl_prep_terminal (0); } /* Clear the readline in case switching occurred in middle of