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