* tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
tuiCommand.h, tuiIO.c, tuiIO.h, tuiData.h, tuiData.c: Likewise.
tuiDataWin.c, tuiDataWin.h, tuiDisassem.c, tuiDisassem.h: Likewise.
tuiGeneralWin.c, tuiGeneralWin.h, tuiLayout.c, tuiLayout.h: Likewise.
tuiRegs.c, tuiRegs.h, tuiSource.c, tuiSource.h: Likewise.
tuiSouceWin.c, tuiSourceWin.h, tuiStack.c, tuiStack.h: Likewise.
2001-07-14 21:01:25 +02:00
|
|
|
/* TUI support I/O functions.
|
2002-03-01 07:19:28 +01:00
|
|
|
|
2015-01-01 10:32:14 +01:00
|
|
|
Copyright (C) 1998-2015 Free Software Foundation, Inc.
|
2002-03-01 07:19:28 +01:00
|
|
|
|
* tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
tuiCommand.h, tuiIO.c, tuiIO.h, tuiData.h, tuiData.c: Likewise.
tuiDataWin.c, tuiDataWin.h, tuiDisassem.c, tuiDisassem.h: Likewise.
tuiGeneralWin.c, tuiGeneralWin.h, tuiLayout.c, tuiLayout.h: Likewise.
tuiRegs.c, tuiRegs.h, tuiSource.c, tuiSource.h: Likewise.
tuiSouceWin.c, tuiSourceWin.h, tuiStack.c, tuiStack.h: Likewise.
2001-07-14 21:01:25 +02:00
|
|
|
Contributed by Hewlett-Packard Company.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-23 20:08:50 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
* tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
tuiCommand.h, tuiIO.c, tuiIO.h, tuiData.h, tuiData.c: Likewise.
tuiDataWin.c, tuiDataWin.h, tuiDisassem.c, tuiDisassem.h: Likewise.
tuiGeneralWin.c, tuiGeneralWin.h, tuiLayout.c, tuiLayout.h: Likewise.
tuiRegs.c, tuiRegs.h, tuiSource.c, tuiSource.h: Likewise.
tuiSouceWin.c, tuiSourceWin.h, tuiStack.c, tuiStack.h: Likewise.
2001-07-14 21:01:25 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 20:08:50 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
#include "defs.h"
|
2001-07-21 21:56:54 +02:00
|
|
|
#include "target.h"
|
|
|
|
#include "event-loop.h"
|
2002-08-31 14:02:14 +02:00
|
|
|
#include "event-top.h"
|
2001-07-21 21:56:54 +02:00
|
|
|
#include "command.h"
|
|
|
|
#include "top.h"
|
2004-01-19 05:31:53 +01:00
|
|
|
#include "tui/tui.h"
|
|
|
|
#include "tui/tui-data.h"
|
|
|
|
#include "tui/tui-io.h"
|
|
|
|
#include "tui/tui-command.h"
|
|
|
|
#include "tui/tui-win.h"
|
|
|
|
#include "tui/tui-wingeneral.h"
|
|
|
|
#include "tui/tui-file.h"
|
2001-07-21 21:56:54 +02:00
|
|
|
#include "ui-out.h"
|
|
|
|
#include "cli-out.h"
|
|
|
|
#include <fcntl.h>
|
2001-07-22 00:35:40 +02:00
|
|
|
#include <signal.h>
|
PR gdb/7912:
* Makefile.in (SFILES): Add filestuff.c
(COMMON_OBS): Add filestuff.o.
(filestuff.o): New target.
* auto-load.c (auto_load_objfile_script_1): Use
gdb_fopen_cloexec.
* auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec.
* cli/cli-cmds.c (shell_escape): Call close_most_fds.
* cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec.
* common/agent.c (gdb_connect_sync_socket): Use
gdb_socket_cloexec.
* common/filestuff.c: New file.
* common/filestuff.h: New file.
* common/linux-osdata.c (linux_common_core_of_thread)
(command_from_pid, commandline_from_pid, print_source_lines)
(linux_xfer_osdata_shm, linux_xfer_osdata_sem)
(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use
gdb_fopen_cloexec.
* common/linux-procfs.c (linux_proc_get_int)
(linux_proc_pid_has_state): Use gdb_fopen_cloexec.
* config.in, configure: Rebuild.
* configure.ac: Don't check for sys/socket.h. Check for
fdwalk, pipe2.
* corelow.c (core_open): Use gdb_open_cloexec.
* dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec.
* fork-child.c (fork_inferior): Call close_most_fds.
* gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec.
* inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec.
* linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals):
Use gdb_fopen_cloexec.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use
gdb_open_cloexec.
(linux_async_pipe): Use gdb_pipe_cloexec.
* remote-fileio.c (remote_fileio_func_open): Use
gdb_open_cloexec.
* remote.c (remote_file_put, remote_file_get): Use
gdb_fopen_cloexec.
* ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec,
close_most_fds.
* ser-tcp.c (net_open): Use gdb_socket_cloexec.
* ser-unix.c (hardwire_open): Use gdb_open_cloexec.
* solib.c (solib_find): Use gdb_open_cloexec.
* source.c (openp, find_and_open_source): Use gdb_open_cloexec.
* tracepoint.c (tfile_start): Use gdb_fopen_cloexec.
(tfile_open): Use gdb_open_cloexec.
* tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec.
* ui-file.c (gdb_fopen): Use gdb_fopen_cloexec.
* xml-support.c (xml_fetch_content_from_file): Use
gdb_fopen_cloexec.
* main.c (captured_main): Call notice_open_fds.
gdbserver
* Makefile.in (SFILES): Add filestuff.c.
(OBS): Add filestuff.o.
(filestuff.o): New target.
* config.in, configure: Rebuild.
* configure.ac: Check for fdwalk, pipe2.
2013-04-22 18:46:15 +02:00
|
|
|
#include "filestuff.h"
|
2003-06-22 17:21:39 +02:00
|
|
|
|
2004-02-10 Andrew Cagney <cagney@redhat.com>
* defs.h: Do not include "tui.h".
* gdb_curses.h: New file.
* tui/tui-hooks.h: New file.
* tui/tui.h (tui_update_all_exec_infos): Delete declaration.
(tui_install_hooks, tui_remove_hooks): Delete declarations.
(tui_initialize_io): Delete declaration.
(tui_initialize_readline: Delete redundant declaration.
(struct tui_point): Delete definition.
* tui/tui-data.h (struct tui_point): Define.
* cli/cli-decode.c [TUI]: Include "tui/tui.h".
* utils.c: Include "tui/tui.h".
* tui/tui-data.h: Include "tui/tui.h" and "gdb_curses.h".
* printcmd.c [TUI]: Include "tui/tui.h".
* cli/cli-cmds.c [TUI]: Include "tui/tui.h".
* tui/tui-command.c: Include "gdb_curses.h".
* tui/tui.c, tui/tui-winsource.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-windata.c, tui/tui-win.c, tui/tui-stack.c: Ditto.
* tui/tui-source.c, tui/tui-regs.c, tui/tui-layout.c: Ditto.
* tui/tui-io.c, tui/tui-disasm.c, tui/tui-data.c: : Ditto.
* tui/tui-hooks.c: Include "tui-hooks.h" and "gdb_curses.h".
* Makefile.in: Update all dependencies.
(tui_hooks_h, gdb_curses_h): Define.
(SUBDIR_TUI_CFLAGS): Remove -I${srcdir}/tui.
2004-02-10 20:08:19 +01:00
|
|
|
#include "gdb_curses.h"
|
2001-07-21 21:56:54 +02:00
|
|
|
|
2004-04-09 15:54:34 +02:00
|
|
|
/* This redefines CTRL if it is not already defined, so it must come
|
|
|
|
after terminal state releated include files like <term.h> and
|
|
|
|
"gdb_curses.h". */
|
|
|
|
#include "readline/readline.h"
|
|
|
|
|
2004-01-18 Andrew Cagney <cagney@redhat.com>
* tui/tui-io.c: Update copyright.
(key_is_end_sequence, key_is_backspace): New functions.
(key_is_command_char, key_is_start_sequence): New function.
(tui_getc): Update references.
* tui/tui-io.h: Update copyright.
(m_tuiStartNewLine): Delete macro.
(m_isBackspace, m_isDeleteChar): Delete macros.
(m_isDeleteLine, m_isDeleteToEol): Delete macros.
(m_isNextPage, m_isPrevPage): Delete macros.
(m_isLeftArrow, m_isRightArrow): Delete macros.
(m_isXdbStyleCommandChar): Delete macro.
(key_is_start_sequence): Declare, replace m_isStartSequence.
(key_is_end_sequence): Declare, replace m_isEndSequence.
(key_is_backspace): Declare ,replace m_isBackspace.
(key_is_command_char): Declare, replace m_isCommandChar.
* tui/tui-command.c: Update copyright.
(tuiDispatchCtrlChar): Update references.
2004-01-19 06:06:34 +01:00
|
|
|
int
|
|
|
|
key_is_start_sequence (int ch)
|
|
|
|
{
|
|
|
|
return (ch == 27);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
key_is_end_sequence (int ch)
|
|
|
|
{
|
|
|
|
return (ch == 126);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
key_is_backspace (int ch)
|
|
|
|
{
|
|
|
|
return (ch == 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
key_is_command_char (int ch)
|
|
|
|
{
|
|
|
|
return ((ch == KEY_NPAGE) || (ch == KEY_PPAGE)
|
|
|
|
|| (ch == KEY_LEFT) || (ch == KEY_RIGHT)
|
|
|
|
|| (ch == KEY_UP) || (ch == KEY_DOWN)
|
|
|
|
|| (ch == KEY_SF) || (ch == KEY_SR)
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-disasm.c, tui-file.c, tui-io.c,
tui-layout.c, tui-regs.c, tui-source.c, tui-win.c, tui-windata.c,
tui-wingeneral.c, tui-winsource.c: Coding standard, && and ||
go at beginning of new line.
2007-08-15 02:19:44 +02:00
|
|
|
|| (ch == (int)'\f')
|
|
|
|
|| key_is_start_sequence (ch));
|
2004-01-18 Andrew Cagney <cagney@redhat.com>
* tui/tui-io.c: Update copyright.
(key_is_end_sequence, key_is_backspace): New functions.
(key_is_command_char, key_is_start_sequence): New function.
(tui_getc): Update references.
* tui/tui-io.h: Update copyright.
(m_tuiStartNewLine): Delete macro.
(m_isBackspace, m_isDeleteChar): Delete macros.
(m_isDeleteLine, m_isDeleteToEol): Delete macros.
(m_isNextPage, m_isPrevPage): Delete macros.
(m_isLeftArrow, m_isRightArrow): Delete macros.
(m_isXdbStyleCommandChar): Delete macro.
(key_is_start_sequence): Declare, replace m_isStartSequence.
(key_is_end_sequence): Declare, replace m_isEndSequence.
(key_is_backspace): Declare ,replace m_isBackspace.
(key_is_command_char): Declare, replace m_isCommandChar.
* tui/tui-command.c: Update copyright.
(tuiDispatchCtrlChar): Update references.
2004-01-19 06:06:34 +01:00
|
|
|
}
|
|
|
|
|
2002-08-27 22:58:27 +02:00
|
|
|
/* Use definition from readline 4.3. */
|
|
|
|
#undef CTRL_CHAR
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-data.c, tui-data.h, tui-disasm.c, tui-disasm.h, tui-hooks.c,
tui-io.c, tui-layout.c, tui-layout.h, tui-out.c, tui-regs.c,
tui-source.c, tui-source.h, tui-stack.c, tui-win.c, tui-win.h,
tui-windata.c, tui-windata.h, tui-wingeneral.c, tui-winsource.c,
tui-winsource.h, tui.c, tui.h: Function declarations and
definitions, wrap long lines.
2007-08-15 01:50:39 +02:00
|
|
|
#define CTRL_CHAR(c) \
|
|
|
|
((c) < control_character_threshold && (((c) & 0x80) == 0))
|
2002-08-27 22:58:27 +02:00
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
/* This file controls the IO interactions between gdb and curses.
|
|
|
|
When the TUI is enabled, gdb has two modes a curses and a standard
|
|
|
|
mode.
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
In curses mode, the gdb outputs are made in a curses command
|
|
|
|
window. For this, the gdb_stdout and gdb_stderr are redirected to
|
|
|
|
the specific ui_file implemented by TUI. The output is handled by
|
|
|
|
tui_puts(). The input is also controlled by curses with
|
|
|
|
tui_getc(). The readline library uses this function to get its
|
|
|
|
input. Several readline hooks are installed to redirect readline
|
|
|
|
output to the TUI (see also the note below).
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
In normal mode, the gdb outputs are restored to their origin, that
|
|
|
|
is as if TUI is not used. Readline also uses its original getc()
|
|
|
|
function with stdin.
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
Note SCz/2001-07-21: the current readline is not clean in its
|
|
|
|
management of the output. Even if we install a redisplay handler,
|
|
|
|
it sometimes writes on a stdout file. It is important to redirect
|
|
|
|
every output produced by readline, otherwise the curses window will
|
|
|
|
be garbled. This is implemented with a pipe that TUI reads and
|
|
|
|
readline writes to. A gdb input handler is created so that reading
|
|
|
|
the pipe is handled automatically. This will probably not work on
|
|
|
|
non-Unix platforms. The best fix is to make readline clean enougth
|
|
|
|
so that is never write on stdout.
|
|
|
|
|
|
|
|
Note SCz/2002-09-01: we now use more readline hooks and it seems
|
|
|
|
that with them we don't need the pipe anymore (verified by creating
|
|
|
|
the pipe and closing its end so that write causes a SIGPIPE). The
|
|
|
|
old pipe code is still there and can be conditionally removed by
|
2002-09-03 22:47:48 +02:00
|
|
|
#undef TUI_USE_PIPE_FOR_READLINE. */
|
|
|
|
|
|
|
|
/* For gdb 5.3, prefer to continue the pipe hack as a backup wheel. */
|
2009-07-20 17:24:55 +02:00
|
|
|
#ifdef HAVE_PIPE
|
2002-09-03 22:47:48 +02:00
|
|
|
#define TUI_USE_PIPE_FOR_READLINE
|
2009-07-20 17:24:55 +02:00
|
|
|
#endif
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* #undef TUI_USE_PIPE_FOR_READLINE */
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* TUI output files. */
|
|
|
|
static struct ui_file *tui_stdout;
|
|
|
|
static struct ui_file *tui_stderr;
|
2002-09-10 21:59:31 +02:00
|
|
|
struct ui_out *tui_out;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* GDB output files in non-curses mode. */
|
|
|
|
static struct ui_file *tui_old_stdout;
|
|
|
|
static struct ui_file *tui_old_stderr;
|
2002-09-10 21:59:31 +02:00
|
|
|
struct ui_out *tui_old_uiout;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Readline previous hooks. */
|
2014-06-20 17:43:56 +02:00
|
|
|
static rl_getc_func_t *tui_old_rl_getc_function;
|
|
|
|
static rl_voidfunc_t *tui_old_rl_redisplay_function;
|
|
|
|
static rl_vintfunc_t *tui_old_rl_prep_terminal;
|
|
|
|
static rl_voidfunc_t *tui_old_rl_deprep_terminal;
|
2011-05-12 01:38:44 +02:00
|
|
|
static int tui_old_rl_echoing_p;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Readline output stream.
|
|
|
|
Should be removed when readline is clean. */
|
|
|
|
static FILE *tui_rl_outstream;
|
|
|
|
static FILE *tui_old_rl_outstream;
|
2002-09-03 22:47:48 +02:00
|
|
|
#ifdef TUI_USE_PIPE_FOR_READLINE
|
2001-07-21 21:56:54 +02:00
|
|
|
static int tui_readline_pipe[2];
|
2002-09-03 22:47:48 +02:00
|
|
|
#endif
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2002-10-26 12:38:57 +02:00
|
|
|
/* The last gdb prompt that was registered in readline.
|
|
|
|
This may be the main gdb prompt or a secondary prompt. */
|
|
|
|
static char *tui_rl_saved_prompt;
|
|
|
|
|
2004-02-08 01:05:16 +01:00
|
|
|
static unsigned int tui_handle_resize_during_io (unsigned int);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2002-09-03 22:47:48 +02:00
|
|
|
static void
|
|
|
|
tui_putc (char c)
|
|
|
|
{
|
|
|
|
char buf[2];
|
|
|
|
|
|
|
|
buf[0] = c;
|
|
|
|
buf[1] = 0;
|
|
|
|
tui_puts (buf);
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Print the string in the curses command window. */
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
2001-07-21 21:56:54 +02:00
|
|
|
tui_puts (const char *string)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2001-07-21 21:56:54 +02:00
|
|
|
static int tui_skip_line = -1;
|
|
|
|
char c;
|
|
|
|
WINDOW *w;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
w = TUI_CMD_WIN->generic.handle;
|
2001-07-21 21:56:54 +02:00
|
|
|
while ((c = *string++) != 0)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Catch annotation and discard them. We need two \032 and
|
|
|
|
discard until a \n is seen. */
|
|
|
|
if (c == '\032')
|
|
|
|
{
|
|
|
|
tui_skip_line++;
|
|
|
|
}
|
|
|
|
else if (tui_skip_line != 1)
|
|
|
|
{
|
|
|
|
tui_skip_line = -1;
|
|
|
|
waddch (w, c);
|
|
|
|
}
|
|
|
|
else if (c == '\n')
|
|
|
|
tui_skip_line = -1;
|
|
|
|
}
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
getyx (w, TUI_CMD_WIN->detail.command_info.cur_line,
|
|
|
|
TUI_CMD_WIN->detail.command_info.curch);
|
2011-01-06 01:57:05 +01:00
|
|
|
TUI_CMD_WIN->detail.command_info.start_line
|
|
|
|
= TUI_CMD_WIN->detail.command_info.cur_line;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* We could defer the following. */
|
|
|
|
wrefresh (w);
|
|
|
|
fflush (stdout);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Readline callback.
|
|
|
|
Redisplay the command line with its prompt after readline has
|
|
|
|
changed the edited text. */
|
2002-08-31 14:02:14 +02:00
|
|
|
void
|
2001-07-21 21:56:54 +02:00
|
|
|
tui_redisplay_readline (void)
|
|
|
|
{
|
|
|
|
int prev_col;
|
|
|
|
int height;
|
|
|
|
int col, line;
|
|
|
|
int c_pos;
|
|
|
|
int c_line;
|
|
|
|
int in;
|
|
|
|
WINDOW *w;
|
|
|
|
char *prompt;
|
|
|
|
int start_line;
|
2002-09-13 22:06:56 +02:00
|
|
|
|
|
|
|
/* Detect when we temporarily left SingleKey and now the readline
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
edit buffer is empty, automatically restore the SingleKey
|
2012-11-10 14:12:18 +01:00
|
|
|
mode. The restore must only be done if the command has finished.
|
|
|
|
The command could call prompt_for_continue and we must not
|
|
|
|
restore SingleKey so that the prompt and normal keymap are used. */
|
|
|
|
if (tui_current_key_mode == TUI_ONE_COMMAND_MODE && rl_end == 0
|
|
|
|
&& immediate_quit == 0)
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
tui_set_key_mode (TUI_SINGLE_KEY_MODE);
|
2002-09-13 22:06:56 +02:00
|
|
|
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
if (tui_current_key_mode == TUI_SINGLE_KEY_MODE)
|
2002-08-31 14:02:14 +02:00
|
|
|
prompt = "";
|
|
|
|
else
|
2002-10-26 12:38:57 +02:00
|
|
|
prompt = tui_rl_saved_prompt;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
c_pos = -1;
|
|
|
|
c_line = -1;
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
w = TUI_CMD_WIN->generic.handle;
|
|
|
|
start_line = TUI_CMD_WIN->detail.command_info.start_line;
|
2001-07-21 21:56:54 +02:00
|
|
|
wmove (w, start_line, 0);
|
|
|
|
prev_col = 0;
|
|
|
|
height = 1;
|
|
|
|
for (in = 0; prompt && prompt[in]; in++)
|
|
|
|
{
|
|
|
|
waddch (w, prompt[in]);
|
|
|
|
getyx (w, line, col);
|
2015-01-09 19:27:56 +01:00
|
|
|
if (col <= prev_col)
|
2001-07-21 21:56:54 +02:00
|
|
|
height++;
|
|
|
|
prev_col = col;
|
|
|
|
}
|
2015-01-09 19:27:56 +01:00
|
|
|
for (in = 0; in <= rl_end; in++)
|
2001-07-21 21:56:54 +02:00
|
|
|
{
|
|
|
|
unsigned char c;
|
|
|
|
|
|
|
|
if (in == rl_point)
|
|
|
|
{
|
|
|
|
getyx (w, c_line, c_pos);
|
|
|
|
}
|
|
|
|
|
2015-01-09 19:27:56 +01:00
|
|
|
if (in == rl_end)
|
|
|
|
break;
|
|
|
|
|
|
|
|
c = (unsigned char) rl_line_buffer[in];
|
2001-07-21 21:56:54 +02:00
|
|
|
if (CTRL_CHAR (c) || c == RUBOUT)
|
|
|
|
{
|
|
|
|
waddch (w, '^');
|
|
|
|
waddch (w, CTRL_CHAR (c) ? UNCTRL (c) : '?');
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
else
|
|
|
|
{
|
2001-07-21 21:56:54 +02:00
|
|
|
waddch (w, c);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2001-07-21 21:56:54 +02:00
|
|
|
if (c == '\n')
|
|
|
|
{
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
getyx (w, TUI_CMD_WIN->detail.command_info.start_line,
|
|
|
|
TUI_CMD_WIN->detail.command_info.curch);
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|
|
|
|
getyx (w, line, col);
|
|
|
|
if (col < prev_col)
|
|
|
|
height++;
|
|
|
|
prev_col = col;
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2001-07-21 21:56:54 +02:00
|
|
|
wclrtobot (w);
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
getyx (w, TUI_CMD_WIN->detail.command_info.start_line,
|
|
|
|
TUI_CMD_WIN->detail.command_info.curch);
|
2001-07-21 21:56:54 +02:00
|
|
|
if (c_line >= 0)
|
2001-07-23 23:16:20 +02:00
|
|
|
{
|
|
|
|
wmove (w, c_line, c_pos);
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
TUI_CMD_WIN->detail.command_info.cur_line = c_line;
|
|
|
|
TUI_CMD_WIN->detail.command_info.curch = c_pos;
|
2001-07-23 23:16:20 +02:00
|
|
|
}
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
TUI_CMD_WIN->detail.command_info.start_line -= height - 1;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
wrefresh (w);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Readline callback to prepare the terminal. It is called once each
|
|
|
|
time we enter readline. Terminal is already setup in curses
|
|
|
|
mode. */
|
2001-07-21 21:56:54 +02:00
|
|
|
static void
|
2003-02-12 16:14:36 +01:00
|
|
|
tui_prep_terminal (int notused1)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2002-10-26 12:38:57 +02:00
|
|
|
/* Save the prompt registered in readline to correctly display it.
|
|
|
|
(we can't use gdb_prompt() due to secondary prompts and can't use
|
|
|
|
rl_prompt because it points to an alloca buffer). */
|
|
|
|
xfree (tui_rl_saved_prompt);
|
Fix pagination crash when the TUI is active
The TUI currently crashes when the user types <return> in response to
a pagination prompt:
$ gdb --tui ...
*the TUI is now active*
(gdb) set height 2
(gdb) help
List of classes of commands:
Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/x86_64/strlen.S:106
106 movdqu (%rax), %xmm12
(top-gdb) bt
#0 strlen () at ../sysdeps/x86_64/strlen.S:106
#1 0x000000000086be5f in xstrdup (s=0x0) at ../src/libiberty/xstrdup.c:33
#2 0x00000000005163f9 in tui_prep_terminal (notused1=1) at ../src/gdb/tui/tui-io.c:296
#3 0x000000000077a7ee in _rl_callback_newline () at ../src/readline/callback.c:82
#4 0x000000000077a853 in rl_callback_handler_install (prompt=0x0, linefunc=0x618b60 <command_line_handler>) at ../src/readline/callback.c:102
#5 0x0000000000718a5c in gdb_readline_wrapper_cleanup (arg=0xfd14d0) at ../src/gdb/top.c:788
#6 0x0000000000596d08 in do_my_cleanups (pmy_chain=0xcf0b38 <cleanup_chain>, old_chain=0x1043d10) at ../src/gdb/cleanups.c:155
#7 0x0000000000596d75 in do_cleanups (old_chain=0x1043d10) at ../src/gdb/cleanups.c:177
#8 0x0000000000718bd9 in gdb_readline_wrapper (prompt=0x7fffffffcfa0 "---Type <return> to continue, or q <return> to quit---")
at ../src/gdb/top.c:835
#9 0x000000000071cf74 in prompt_for_continue () at ../src/gdb/utils.c:1894
#10 0x000000000071d434 in fputs_maybe_filtered (linebuffer=0x1043db0 "List of classes of commands:\n\n", stream=0xf72e20, filter=1)
at ../src/gdb/utils.c:2111
#11 0x000000000071da0f in vfprintf_maybe_filtered (stream=0xf72e20, format=0x89aef8 "List of classes of %scommands:\n\n", args=0x7fffffffd118, filter=1)
at ../src/gdb/utils.c:2339
#12 0x000000000071da4a in vfprintf_filtered (stream=0xf72e20, format=0x89aef8 "List of classes of %scommands:\n\n", args=0x7fffffffd118)
at ../src/gdb/utils.c:2347
#13 0x000000000071dc72 in fprintf_filtered (stream=0xf72e20, format=0x89aef8 "List of classes of %scommands:\n\n") at ../src/gdb/utils.c:2399
#14 0x00000000004f90ab in help_list (list=0xe6d100, cmdtype=0x89ad8c "", class=all_classes, stream=0xf72e20)
at ../src/gdb/cli/cli-decode.c:1038
#15 0x00000000004f8dba in help_cmd (arg=0x0, stream=0xf72e20) at ../src/gdb/cli/cli-decode.c:946
Git 0017922 added:
@@ -776,6 +777,12 @@ gdb_readline_wrapper_cleanup (void *arg)
gdb_assert (input_handler == gdb_readline_wrapper_line);
input_handler = cleanup->handler_orig;
+
+ /* Reinstall INPUT_HANDLER in readline, without displaying a
+ prompt. */
+ if (async_command_editing_p)
+ rl_callback_handler_install (NULL, input_handler);
and tui_prep_terminal simply misses handling the case of a NULL
rl_prompt.
I also checked that readline's sources do similar checks.
gdb/
2014-07-24 Pedro Alves <palves@redhat.com>
* tui/tui-io.c (tui_prep_terminal): Handle NULL rl_prompt.
2014-07-24 16:51:21 +02:00
|
|
|
tui_rl_saved_prompt = rl_prompt != NULL ? xstrdup (rl_prompt) : NULL;
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Readline callback to restore the terminal. It is called once each
|
|
|
|
time we leave readline. There is nothing to do in curses mode. */
|
2001-07-21 21:56:54 +02:00
|
|
|
static void
|
|
|
|
tui_deprep_terminal (void)
|
|
|
|
{
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2002-09-03 22:47:48 +02:00
|
|
|
#ifdef TUI_USE_PIPE_FOR_READLINE
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Read readline output pipe and feed the command window with it.
|
|
|
|
Should be removed when readline is clean. */
|
|
|
|
static void
|
2010-05-25 17:48:44 +02:00
|
|
|
tui_readline_output (int error, gdb_client_data data)
|
2001-07-21 21:56:54 +02:00
|
|
|
{
|
|
|
|
int size;
|
|
|
|
char buf[256];
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
size = read (tui_readline_pipe[0], buf, sizeof (buf) - 1);
|
|
|
|
if (size > 0 && tui_active)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2001-07-21 21:56:54 +02:00
|
|
|
buf[size] = 0;
|
|
|
|
tui_puts (buf);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|
2002-09-03 22:47:48 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Return the portion of PATHNAME that should be output when listing
|
|
|
|
possible completions. If we are hacking filename completion, we
|
|
|
|
are only interested in the basename, the portion following the
|
|
|
|
final slash. Otherwise, we return what we were passed.
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
Comes from readline/complete.c. */
|
2011-03-09 13:48:56 +01:00
|
|
|
static const char *
|
|
|
|
printable_part (const char *pathname)
|
2002-09-03 22:47:48 +02:00
|
|
|
{
|
2011-03-09 13:48:56 +01:00
|
|
|
return rl_filename_completion_desired ? lbasename (pathname) : pathname;
|
2002-09-03 22:47:48 +02:00
|
|
|
}
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Output TO_PRINT to rl_outstream. If VISIBLE_STATS is defined and
|
|
|
|
we are using it, check for and output a single character for
|
|
|
|
`special' filenames. Return the number of characters we
|
|
|
|
output. */
|
2002-09-03 22:47:48 +02:00
|
|
|
|
|
|
|
#define PUTX(c) \
|
|
|
|
do { \
|
|
|
|
if (CTRL_CHAR (c)) \
|
|
|
|
{ \
|
|
|
|
tui_puts ("^"); \
|
|
|
|
tui_putc (UNCTRL (c)); \
|
|
|
|
printed_len += 2; \
|
|
|
|
} \
|
|
|
|
else if (c == RUBOUT) \
|
|
|
|
{ \
|
|
|
|
tui_puts ("^?"); \
|
|
|
|
printed_len += 2; \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
tui_putc (c); \
|
|
|
|
printed_len++; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
static int
|
2011-03-09 13:48:56 +01:00
|
|
|
print_filename (const char *to_print, const char *full_pathname)
|
2002-09-03 22:47:48 +02:00
|
|
|
{
|
|
|
|
int printed_len = 0;
|
2011-03-09 13:48:56 +01:00
|
|
|
const char *s;
|
2002-09-03 22:47:48 +02:00
|
|
|
|
|
|
|
for (s = to_print; *s; s++)
|
|
|
|
{
|
|
|
|
PUTX (*s);
|
|
|
|
}
|
|
|
|
return printed_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The user must press "y" or "n". Non-zero return means "y" pressed.
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
Comes from readline/complete.c. */
|
2002-09-03 22:47:48 +02:00
|
|
|
static int
|
2004-02-08 02:32:26 +01:00
|
|
|
get_y_or_n (void)
|
2002-09-03 22:47:48 +02:00
|
|
|
{
|
|
|
|
extern int _rl_abort_internal ();
|
|
|
|
int c;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = rl_read_key ();
|
|
|
|
if (c == 'y' || c == 'Y' || c == ' ')
|
|
|
|
return (1);
|
|
|
|
if (c == 'n' || c == 'N' || c == RUBOUT)
|
|
|
|
return (0);
|
|
|
|
if (c == ABORT_CHAR)
|
|
|
|
_rl_abort_internal ();
|
|
|
|
beep ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* A convenience function for displaying a list of strings in
|
|
|
|
columnar format on readline's output stream. MATCHES is the list
|
|
|
|
of strings, in argv format, LEN is the number of strings in MATCHES,
|
|
|
|
and MAX is the length of the longest string in MATCHES.
|
|
|
|
|
|
|
|
Comes from readline/complete.c and modified to write in
|
|
|
|
the TUI command window using tui_putc/tui_puts. */
|
|
|
|
static void
|
2004-02-08 02:32:26 +01:00
|
|
|
tui_rl_display_match_list (char **matches, int len, int max)
|
2002-09-03 22:47:48 +02:00
|
|
|
{
|
|
|
|
typedef int QSFUNC (const void *, const void *);
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-data.c, tui-data.h, tui-disasm.c, tui-disasm.h, tui-hooks.c,
tui-io.c, tui-layout.c, tui-layout.h, tui-out.c, tui-regs.c,
tui-source.c, tui-source.h, tui-stack.c, tui-win.c, tui-win.h,
tui-windata.c, tui-windata.h, tui-wingeneral.c, tui-winsource.c,
tui-winsource.h, tui.c, tui.h: Function declarations and
definitions, wrap long lines.
2007-08-15 01:50:39 +02:00
|
|
|
extern int _rl_qsort_string_compare (const void *,
|
|
|
|
const void *);
|
2002-09-03 22:47:48 +02:00
|
|
|
extern int _rl_print_completions_horizontally;
|
|
|
|
|
|
|
|
int count, limit, printed_len;
|
|
|
|
int i, j, k, l;
|
2011-03-09 13:48:56 +01:00
|
|
|
const char *temp;
|
2002-09-03 22:47:48 +02:00
|
|
|
|
|
|
|
/* Screen dimension correspond to the TUI command window. */
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
int screenwidth = TUI_CMD_WIN->generic.width;
|
2002-09-03 22:47:48 +02:00
|
|
|
|
|
|
|
/* If there are many items, then ask the user if she really wants to
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
see them all. */
|
2002-09-03 22:47:48 +02:00
|
|
|
if (len >= rl_completion_query_items)
|
|
|
|
{
|
|
|
|
char msg[256];
|
|
|
|
|
2012-11-20 23:51:05 +01:00
|
|
|
xsnprintf (msg, sizeof (msg),
|
|
|
|
"\nDisplay all %d possibilities? (y or n)", len);
|
2002-09-03 22:47:48 +02:00
|
|
|
tui_puts (msg);
|
|
|
|
if (get_y_or_n () == 0)
|
|
|
|
{
|
|
|
|
tui_puts ("\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* How many items of MAX length can we fit in the screen window? */
|
2002-09-03 22:47:48 +02:00
|
|
|
max += 2;
|
|
|
|
limit = screenwidth / max;
|
|
|
|
if (limit != 1 && (limit * max == screenwidth))
|
|
|
|
limit--;
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Avoid a possible floating exception. If max > screenwidth, limit
|
|
|
|
will be 0 and a divide-by-zero fault will result. */
|
2002-09-03 22:47:48 +02:00
|
|
|
if (limit == 0)
|
|
|
|
limit = 1;
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* How many iterations of the printing loop? */
|
2002-09-03 22:47:48 +02:00
|
|
|
count = (len + (limit - 1)) / limit;
|
|
|
|
|
|
|
|
/* Watch out for special case. If LEN is less than LIMIT, then
|
|
|
|
just do the inner printing loop.
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
0 < len <= limit implies count = 1. */
|
2002-09-03 22:47:48 +02:00
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Sort the items if they are not already sorted. */
|
2002-09-03 22:47:48 +02:00
|
|
|
if (rl_ignore_completion_duplicates == 0)
|
|
|
|
qsort (matches + 1, len, sizeof (char *),
|
|
|
|
(QSFUNC *)_rl_qsort_string_compare);
|
|
|
|
|
|
|
|
tui_putc ('\n');
|
|
|
|
|
|
|
|
if (_rl_print_completions_horizontally == 0)
|
|
|
|
{
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Print the sorted items, up-and-down alphabetically, like ls. */
|
2002-09-03 22:47:48 +02:00
|
|
|
for (i = 1; i <= count; i++)
|
|
|
|
{
|
|
|
|
for (j = 0, l = i; j < limit; j++)
|
|
|
|
{
|
|
|
|
if (l > len || matches[l] == 0)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
temp = printable_part (matches[l]);
|
|
|
|
printed_len = print_filename (temp, matches[l]);
|
|
|
|
|
|
|
|
if (j + 1 < limit)
|
|
|
|
for (k = 0; k < max - printed_len; k++)
|
|
|
|
tui_putc (' ');
|
|
|
|
}
|
|
|
|
l += count;
|
|
|
|
}
|
|
|
|
tui_putc ('\n');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Print the sorted items, across alphabetically, like ls -x. */
|
2002-09-03 22:47:48 +02:00
|
|
|
for (i = 1; matches[i]; i++)
|
|
|
|
{
|
|
|
|
temp = printable_part (matches[i]);
|
|
|
|
printed_len = print_filename (temp, matches[i]);
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Have we reached the end of this line? */
|
2002-09-03 22:47:48 +02:00
|
|
|
if (matches[i+1])
|
|
|
|
{
|
|
|
|
if (i && (limit > 1) && (i % limit) == 0)
|
|
|
|
tui_putc ('\n');
|
|
|
|
else
|
|
|
|
for (k = 0; k < max - printed_len; k++)
|
|
|
|
tui_putc (' ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tui_putc ('\n');
|
|
|
|
}
|
|
|
|
}
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Setup the IO for curses or non-curses mode.
|
|
|
|
- In non-curses mode, readline and gdb use the standard input and
|
|
|
|
standard output/error directly.
|
|
|
|
- In curses mode, the standard output/error is controlled by TUI
|
|
|
|
with the tui_stdout and tui_stderr. The output is redirected in
|
|
|
|
the curses command window. Several readline callbacks are installed
|
|
|
|
so that readline asks for its input to the curses command window
|
|
|
|
with wgetch(). */
|
|
|
|
void
|
|
|
|
tui_setup_io (int mode)
|
|
|
|
{
|
2011-05-12 01:38:44 +02:00
|
|
|
extern int _rl_echoing_p;
|
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
if (mode)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Redirect readline to TUI. */
|
|
|
|
tui_old_rl_redisplay_function = rl_redisplay_function;
|
|
|
|
tui_old_rl_deprep_terminal = rl_deprep_term_function;
|
|
|
|
tui_old_rl_prep_terminal = rl_prep_term_function;
|
|
|
|
tui_old_rl_getc_function = rl_getc_function;
|
|
|
|
tui_old_rl_outstream = rl_outstream;
|
2011-05-12 01:38:44 +02:00
|
|
|
tui_old_rl_echoing_p = _rl_echoing_p;
|
2001-07-21 21:56:54 +02:00
|
|
|
rl_redisplay_function = tui_redisplay_readline;
|
|
|
|
rl_deprep_term_function = tui_deprep_terminal;
|
|
|
|
rl_prep_term_function = tui_prep_terminal;
|
|
|
|
rl_getc_function = tui_getc;
|
2011-05-12 01:38:44 +02:00
|
|
|
_rl_echoing_p = 0;
|
2001-07-21 21:56:54 +02:00
|
|
|
rl_outstream = tui_rl_outstream;
|
|
|
|
rl_prompt = 0;
|
2002-09-03 22:47:48 +02:00
|
|
|
rl_completion_display_matches_hook = tui_rl_display_match_list;
|
|
|
|
rl_already_prompted = 0;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Keep track of previous gdb output. */
|
|
|
|
tui_old_stdout = gdb_stdout;
|
|
|
|
tui_old_stderr = gdb_stderr;
|
2011-08-04 Pedro Alves <pedro@codesourcery.com>
* ui-out.h (uiout): Rename to ...
(current_uiout): ... this.
* ui-out.c (uiout): Rename to ...
(current_uiout): ... this.
* ada-lang.c (print_it_exception, print_one_exception)
(print_mention_exception): Adjust.
* breakpoint.c (watchpoint_check): Adjust.
(print_breakpoint_location, print_one_breakpoint, breakpoint_1)
(default_collect_info, watchpoints_info, print_one_catch_fork)
(print_one_catch_vfork, print_one_catch_syscall)
(print_one_catch_exec, mention, print_it_ranged_breakpoint)
(print_one_ranged_breakpoint, print_mention_ranged_breakpoint)
(print_it_watchpoint, print_mention_watchpoint)
(print_it_masked_watchpoint, print_mention_masked_watchpoint)
(print_it_exception_catchpoint, print_one_exception_catchpoint)
(print_mention_exception_catchpoint, say_where, bkpt_print_it)
(bkpt_print_mention, momentary_bkpt_print_it)
(tracepoint_print_mention, update_static_tracepoint)
(tracepoints_info, save_breakpoints): Adjust.
* cli-out.c (field_separator): Adjust.
* cp-abi.c (list_cp_abis, show_cp_abi_cmd): Adjust.
* exceptions.c (catch_exceptions_with_msg, catch_errors): Adjust.
* frame.c (get_current_frame): Adjust.
* infcmd.c (run_command_1, print_return_value): Adjust.
* inferior.c (inferior_command, info_inferiors_command): Adjust.
* infrun.c (print_end_stepping_range_reason): Adjust.
(print_signal_exited_reason, print_exited_reason): Adjust.
(print_signal_received_reason, print_no_history_reason): Adjust.
* interps.c (interp_set): Adjust.
* osdata.c (info_osdata_command): Adjust.
* progspace.c (maintenance_info_program_spaces_command): Adjust.
* remote-fileio.c (remote_fileio_request): Adjust.
* remote.c (show_remote_cmd): Adjust.
* solib.c (info_sharedlibrary_command): Adjust.
* source.c (print_source_lines_base): Adjust.
* stack.c (print_stack_frame): Adjust.
(do_gdb_disassembly, print_frame_info, print_frame): Adjust.
* symfile-mem.c (add_vsyscall_page): Adjust.
* symfile.c (load_progress, generic_load)
(print_transfer_performance): Adjust.
* thread.c (info_threads_command, restore_selected_frame)
(thread_command): Adjust.
* top.c (make_cleanup_restore_ui_file): Adjust.
* tracepoint.c (tvariables_info_1, trace_status_mi, tfind_1)
(print_one_static_tracepoint_marker): Adjust.
* cli/cli-cmds.c (print_disassembly): Adjust.
* cli/cli-decode.c (print_doc_line): Adjust.
* cli/cli-interp.c (safe_execute_command): Adjust.
* cli/cli-logging.c (set_logging_redirect, pop_output_files)
(handle_redirections): Adjust.
* cli/cli-script.c (show_user_1): Adjust.
* cli/cli-setshow.c (do_setshow_command, cmd_show_list): Adjust.
* mi/mi-cmd-break.c (breakpoint_notify): Adjust.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Adjust.
* mi/mi-cmd-env.c (mi_cmd_env_pwd, mi_cmd_env_path)
(mi_cmd_env_dir): Adjust.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
(print_partial_file_name, mi_cmd_file_list_exec_source_files): Adjust.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames)
(mi_cmd_stack_info_depth, mi_cmd_stack_list_args)
(list_args_or_locals): Adjust.
* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_create)
(mi_cmd_var_delete, mi_cmd_var_set_format, mi_cmd_var_set_frozen)
(mi_cmd_var_show_format, mi_cmd_var_info_num_children)
(mi_cmd_var_list_children, mi_cmd_var_info_type)
(mi_cmd_var_info_path_expression, mi_cmd_var_info_expression)
(mi_cmd_var_show_attributes, mi_cmd_var_evaluate_expression)
(mi_cmd_var_assign, mi_cmd_var_update, varobj_update_one): Adjust.
* mi/mi-interp.c (mi_on_normal_stop): Adjust.
* mi/mi-main.c (mi_cmd_gdb_exit, mi_cmd_thread_select)
(mi_cmd_thread_list_ids, mi_cmd_thread_info, print_one_inferior)
(list_available_thread_groups, mi_cmd_list_thread_groups)
(mi_cmd_data_list_register_names)
(mi_cmd_data_list_changed_registers)
(mi_cmd_data_list_register_values, get_register)
(mi_cmd_data_evaluate_expression, mi_cmd_data_read_memory)
(mi_cmd_data_read_memory_bytes, mi_cmd_list_features)
(mi_cmd_list_target_features, mi_cmd_add_inferior)
(mi_execute_command, mi_load_progress): Adjust.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Adjust.
* python/py-auto-load.c (print_script, info_auto_load_scripts):
Adjust.
* python/py-breakpoint.c (bppy_get_commands): Adjust.
* tui/tui-interp.c (tui_command_loop): Adjust.
* tui/tui-io.c (tui_setup_io, tui_initialize_io): Adjust.
2011-08-04 21:10:14 +02:00
|
|
|
tui_old_uiout = current_uiout;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Reconfigure gdb output. */
|
|
|
|
gdb_stdout = tui_stdout;
|
|
|
|
gdb_stderr = tui_stderr;
|
|
|
|
gdb_stdlog = gdb_stdout; /* for moment */
|
|
|
|
gdb_stdtarg = gdb_stderr; /* for moment */
|
2010-09-11 18:00:27 +02:00
|
|
|
gdb_stdtargerr = gdb_stderr; /* for moment */
|
2011-08-04 Pedro Alves <pedro@codesourcery.com>
* ui-out.h (uiout): Rename to ...
(current_uiout): ... this.
* ui-out.c (uiout): Rename to ...
(current_uiout): ... this.
* ada-lang.c (print_it_exception, print_one_exception)
(print_mention_exception): Adjust.
* breakpoint.c (watchpoint_check): Adjust.
(print_breakpoint_location, print_one_breakpoint, breakpoint_1)
(default_collect_info, watchpoints_info, print_one_catch_fork)
(print_one_catch_vfork, print_one_catch_syscall)
(print_one_catch_exec, mention, print_it_ranged_breakpoint)
(print_one_ranged_breakpoint, print_mention_ranged_breakpoint)
(print_it_watchpoint, print_mention_watchpoint)
(print_it_masked_watchpoint, print_mention_masked_watchpoint)
(print_it_exception_catchpoint, print_one_exception_catchpoint)
(print_mention_exception_catchpoint, say_where, bkpt_print_it)
(bkpt_print_mention, momentary_bkpt_print_it)
(tracepoint_print_mention, update_static_tracepoint)
(tracepoints_info, save_breakpoints): Adjust.
* cli-out.c (field_separator): Adjust.
* cp-abi.c (list_cp_abis, show_cp_abi_cmd): Adjust.
* exceptions.c (catch_exceptions_with_msg, catch_errors): Adjust.
* frame.c (get_current_frame): Adjust.
* infcmd.c (run_command_1, print_return_value): Adjust.
* inferior.c (inferior_command, info_inferiors_command): Adjust.
* infrun.c (print_end_stepping_range_reason): Adjust.
(print_signal_exited_reason, print_exited_reason): Adjust.
(print_signal_received_reason, print_no_history_reason): Adjust.
* interps.c (interp_set): Adjust.
* osdata.c (info_osdata_command): Adjust.
* progspace.c (maintenance_info_program_spaces_command): Adjust.
* remote-fileio.c (remote_fileio_request): Adjust.
* remote.c (show_remote_cmd): Adjust.
* solib.c (info_sharedlibrary_command): Adjust.
* source.c (print_source_lines_base): Adjust.
* stack.c (print_stack_frame): Adjust.
(do_gdb_disassembly, print_frame_info, print_frame): Adjust.
* symfile-mem.c (add_vsyscall_page): Adjust.
* symfile.c (load_progress, generic_load)
(print_transfer_performance): Adjust.
* thread.c (info_threads_command, restore_selected_frame)
(thread_command): Adjust.
* top.c (make_cleanup_restore_ui_file): Adjust.
* tracepoint.c (tvariables_info_1, trace_status_mi, tfind_1)
(print_one_static_tracepoint_marker): Adjust.
* cli/cli-cmds.c (print_disassembly): Adjust.
* cli/cli-decode.c (print_doc_line): Adjust.
* cli/cli-interp.c (safe_execute_command): Adjust.
* cli/cli-logging.c (set_logging_redirect, pop_output_files)
(handle_redirections): Adjust.
* cli/cli-script.c (show_user_1): Adjust.
* cli/cli-setshow.c (do_setshow_command, cmd_show_list): Adjust.
* mi/mi-cmd-break.c (breakpoint_notify): Adjust.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Adjust.
* mi/mi-cmd-env.c (mi_cmd_env_pwd, mi_cmd_env_path)
(mi_cmd_env_dir): Adjust.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
(print_partial_file_name, mi_cmd_file_list_exec_source_files): Adjust.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames)
(mi_cmd_stack_info_depth, mi_cmd_stack_list_args)
(list_args_or_locals): Adjust.
* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_create)
(mi_cmd_var_delete, mi_cmd_var_set_format, mi_cmd_var_set_frozen)
(mi_cmd_var_show_format, mi_cmd_var_info_num_children)
(mi_cmd_var_list_children, mi_cmd_var_info_type)
(mi_cmd_var_info_path_expression, mi_cmd_var_info_expression)
(mi_cmd_var_show_attributes, mi_cmd_var_evaluate_expression)
(mi_cmd_var_assign, mi_cmd_var_update, varobj_update_one): Adjust.
* mi/mi-interp.c (mi_on_normal_stop): Adjust.
* mi/mi-main.c (mi_cmd_gdb_exit, mi_cmd_thread_select)
(mi_cmd_thread_list_ids, mi_cmd_thread_info, print_one_inferior)
(list_available_thread_groups, mi_cmd_list_thread_groups)
(mi_cmd_data_list_register_names)
(mi_cmd_data_list_changed_registers)
(mi_cmd_data_list_register_values, get_register)
(mi_cmd_data_evaluate_expression, mi_cmd_data_read_memory)
(mi_cmd_data_read_memory_bytes, mi_cmd_list_features)
(mi_cmd_list_target_features, mi_cmd_add_inferior)
(mi_execute_command, mi_load_progress): Adjust.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Adjust.
* python/py-auto-load.c (print_script, info_auto_load_scripts):
Adjust.
* python/py-breakpoint.c (bppy_get_commands): Adjust.
* tui/tui-interp.c (tui_command_loop): Adjust.
* tui/tui-io.c (tui_setup_io, tui_initialize_io): Adjust.
2011-08-04 21:10:14 +02:00
|
|
|
current_uiout = tui_out;
|
2001-07-22 00:35:40 +02:00
|
|
|
|
|
|
|
/* Save tty for SIGCONT. */
|
|
|
|
savetty ();
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2001-07-21 21:56:54 +02:00
|
|
|
else
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Restore gdb output. */
|
|
|
|
gdb_stdout = tui_old_stdout;
|
|
|
|
gdb_stderr = tui_old_stderr;
|
|
|
|
gdb_stdlog = gdb_stdout; /* for moment */
|
|
|
|
gdb_stdtarg = gdb_stderr; /* for moment */
|
2010-09-11 18:00:27 +02:00
|
|
|
gdb_stdtargerr = gdb_stderr; /* for moment */
|
2011-08-04 Pedro Alves <pedro@codesourcery.com>
* ui-out.h (uiout): Rename to ...
(current_uiout): ... this.
* ui-out.c (uiout): Rename to ...
(current_uiout): ... this.
* ada-lang.c (print_it_exception, print_one_exception)
(print_mention_exception): Adjust.
* breakpoint.c (watchpoint_check): Adjust.
(print_breakpoint_location, print_one_breakpoint, breakpoint_1)
(default_collect_info, watchpoints_info, print_one_catch_fork)
(print_one_catch_vfork, print_one_catch_syscall)
(print_one_catch_exec, mention, print_it_ranged_breakpoint)
(print_one_ranged_breakpoint, print_mention_ranged_breakpoint)
(print_it_watchpoint, print_mention_watchpoint)
(print_it_masked_watchpoint, print_mention_masked_watchpoint)
(print_it_exception_catchpoint, print_one_exception_catchpoint)
(print_mention_exception_catchpoint, say_where, bkpt_print_it)
(bkpt_print_mention, momentary_bkpt_print_it)
(tracepoint_print_mention, update_static_tracepoint)
(tracepoints_info, save_breakpoints): Adjust.
* cli-out.c (field_separator): Adjust.
* cp-abi.c (list_cp_abis, show_cp_abi_cmd): Adjust.
* exceptions.c (catch_exceptions_with_msg, catch_errors): Adjust.
* frame.c (get_current_frame): Adjust.
* infcmd.c (run_command_1, print_return_value): Adjust.
* inferior.c (inferior_command, info_inferiors_command): Adjust.
* infrun.c (print_end_stepping_range_reason): Adjust.
(print_signal_exited_reason, print_exited_reason): Adjust.
(print_signal_received_reason, print_no_history_reason): Adjust.
* interps.c (interp_set): Adjust.
* osdata.c (info_osdata_command): Adjust.
* progspace.c (maintenance_info_program_spaces_command): Adjust.
* remote-fileio.c (remote_fileio_request): Adjust.
* remote.c (show_remote_cmd): Adjust.
* solib.c (info_sharedlibrary_command): Adjust.
* source.c (print_source_lines_base): Adjust.
* stack.c (print_stack_frame): Adjust.
(do_gdb_disassembly, print_frame_info, print_frame): Adjust.
* symfile-mem.c (add_vsyscall_page): Adjust.
* symfile.c (load_progress, generic_load)
(print_transfer_performance): Adjust.
* thread.c (info_threads_command, restore_selected_frame)
(thread_command): Adjust.
* top.c (make_cleanup_restore_ui_file): Adjust.
* tracepoint.c (tvariables_info_1, trace_status_mi, tfind_1)
(print_one_static_tracepoint_marker): Adjust.
* cli/cli-cmds.c (print_disassembly): Adjust.
* cli/cli-decode.c (print_doc_line): Adjust.
* cli/cli-interp.c (safe_execute_command): Adjust.
* cli/cli-logging.c (set_logging_redirect, pop_output_files)
(handle_redirections): Adjust.
* cli/cli-script.c (show_user_1): Adjust.
* cli/cli-setshow.c (do_setshow_command, cmd_show_list): Adjust.
* mi/mi-cmd-break.c (breakpoint_notify): Adjust.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Adjust.
* mi/mi-cmd-env.c (mi_cmd_env_pwd, mi_cmd_env_path)
(mi_cmd_env_dir): Adjust.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
(print_partial_file_name, mi_cmd_file_list_exec_source_files): Adjust.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames)
(mi_cmd_stack_info_depth, mi_cmd_stack_list_args)
(list_args_or_locals): Adjust.
* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_create)
(mi_cmd_var_delete, mi_cmd_var_set_format, mi_cmd_var_set_frozen)
(mi_cmd_var_show_format, mi_cmd_var_info_num_children)
(mi_cmd_var_list_children, mi_cmd_var_info_type)
(mi_cmd_var_info_path_expression, mi_cmd_var_info_expression)
(mi_cmd_var_show_attributes, mi_cmd_var_evaluate_expression)
(mi_cmd_var_assign, mi_cmd_var_update, varobj_update_one): Adjust.
* mi/mi-interp.c (mi_on_normal_stop): Adjust.
* mi/mi-main.c (mi_cmd_gdb_exit, mi_cmd_thread_select)
(mi_cmd_thread_list_ids, mi_cmd_thread_info, print_one_inferior)
(list_available_thread_groups, mi_cmd_list_thread_groups)
(mi_cmd_data_list_register_names)
(mi_cmd_data_list_changed_registers)
(mi_cmd_data_list_register_values, get_register)
(mi_cmd_data_evaluate_expression, mi_cmd_data_read_memory)
(mi_cmd_data_read_memory_bytes, mi_cmd_list_features)
(mi_cmd_list_target_features, mi_cmd_add_inferior)
(mi_execute_command, mi_load_progress): Adjust.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Adjust.
* python/py-auto-load.c (print_script, info_auto_load_scripts):
Adjust.
* python/py-breakpoint.c (bppy_get_commands): Adjust.
* tui/tui-interp.c (tui_command_loop): Adjust.
* tui/tui-io.c (tui_setup_io, tui_initialize_io): Adjust.
2011-08-04 21:10:14 +02:00
|
|
|
current_uiout = tui_old_uiout;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Restore readline. */
|
|
|
|
rl_redisplay_function = tui_old_rl_redisplay_function;
|
|
|
|
rl_deprep_term_function = tui_old_rl_deprep_terminal;
|
|
|
|
rl_prep_term_function = tui_old_rl_prep_terminal;
|
|
|
|
rl_getc_function = tui_old_rl_getc_function;
|
|
|
|
rl_outstream = tui_old_rl_outstream;
|
2002-09-03 22:47:48 +02:00
|
|
|
rl_completion_display_matches_hook = 0;
|
2011-05-12 01:38:44 +02:00
|
|
|
_rl_echoing_p = tui_old_rl_echoing_p;
|
2002-09-13 21:47:21 +02:00
|
|
|
rl_already_prompted = 0;
|
2001-07-22 00:35:40 +02:00
|
|
|
|
|
|
|
/* Save tty for SIGCONT. */
|
|
|
|
savetty ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SIGCONT
|
|
|
|
/* Catch SIGCONT to restore the terminal and refresh the screen. */
|
|
|
|
static void
|
|
|
|
tui_cont_sig (int sig)
|
|
|
|
{
|
|
|
|
if (tui_active)
|
|
|
|
{
|
|
|
|
/* Restore the terminal setting because another process (shell)
|
|
|
|
might have changed it. */
|
|
|
|
resetty ();
|
|
|
|
|
|
|
|
/* Force a refresh of the screen. */
|
2004-02-07 02:02:54 +01:00
|
|
|
tui_refresh_all_win ();
|
2001-07-23 23:16:20 +02:00
|
|
|
|
|
|
|
/* Update cursor position on the screen. */
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
wmove (TUI_CMD_WIN->generic.handle,
|
|
|
|
TUI_CMD_WIN->detail.command_info.start_line,
|
|
|
|
TUI_CMD_WIN->detail.command_info.curch);
|
|
|
|
wrefresh (TUI_CMD_WIN->generic.handle);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2001-07-22 00:35:40 +02:00
|
|
|
signal (sig, tui_cont_sig);
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|
2001-07-22 00:35:40 +02:00
|
|
|
#endif
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Initialize the IO for gdb in curses mode. */
|
|
|
|
void
|
2004-02-08 02:32:26 +01:00
|
|
|
tui_initialize_io (void)
|
2001-07-21 21:56:54 +02:00
|
|
|
{
|
2001-07-22 00:35:40 +02:00
|
|
|
#ifdef SIGCONT
|
|
|
|
signal (SIGCONT, tui_cont_sig);
|
|
|
|
#endif
|
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Create tui output streams. */
|
|
|
|
tui_stdout = tui_fileopen (stdout);
|
|
|
|
tui_stderr = tui_fileopen (stderr);
|
|
|
|
tui_out = tui_out_new (tui_stdout);
|
|
|
|
|
2013-09-06 12:12:20 +02:00
|
|
|
/* Create the default UI. */
|
2011-09-12 23:25:22 +02:00
|
|
|
tui_old_uiout = cli_out_new (gdb_stdout);
|
2001-07-21 21:56:54 +02:00
|
|
|
|
2002-09-03 22:47:48 +02:00
|
|
|
#ifdef TUI_USE_PIPE_FOR_READLINE
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Temporary solution for readline writing to stdout: redirect
|
|
|
|
readline output in a pipe, read that pipe and output the content
|
|
|
|
in the curses command window. */
|
PR gdb/7912:
* Makefile.in (SFILES): Add filestuff.c
(COMMON_OBS): Add filestuff.o.
(filestuff.o): New target.
* auto-load.c (auto_load_objfile_script_1): Use
gdb_fopen_cloexec.
* auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec.
* cli/cli-cmds.c (shell_escape): Call close_most_fds.
* cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec.
* common/agent.c (gdb_connect_sync_socket): Use
gdb_socket_cloexec.
* common/filestuff.c: New file.
* common/filestuff.h: New file.
* common/linux-osdata.c (linux_common_core_of_thread)
(command_from_pid, commandline_from_pid, print_source_lines)
(linux_xfer_osdata_shm, linux_xfer_osdata_sem)
(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use
gdb_fopen_cloexec.
* common/linux-procfs.c (linux_proc_get_int)
(linux_proc_pid_has_state): Use gdb_fopen_cloexec.
* config.in, configure: Rebuild.
* configure.ac: Don't check for sys/socket.h. Check for
fdwalk, pipe2.
* corelow.c (core_open): Use gdb_open_cloexec.
* dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec.
* fork-child.c (fork_inferior): Call close_most_fds.
* gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec.
* inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec.
* linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals):
Use gdb_fopen_cloexec.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use
gdb_open_cloexec.
(linux_async_pipe): Use gdb_pipe_cloexec.
* remote-fileio.c (remote_fileio_func_open): Use
gdb_open_cloexec.
* remote.c (remote_file_put, remote_file_get): Use
gdb_fopen_cloexec.
* ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec,
close_most_fds.
* ser-tcp.c (net_open): Use gdb_socket_cloexec.
* ser-unix.c (hardwire_open): Use gdb_open_cloexec.
* solib.c (solib_find): Use gdb_open_cloexec.
* source.c (openp, find_and_open_source): Use gdb_open_cloexec.
* tracepoint.c (tfile_start): Use gdb_fopen_cloexec.
(tfile_open): Use gdb_open_cloexec.
* tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec.
* ui-file.c (gdb_fopen): Use gdb_fopen_cloexec.
* xml-support.c (xml_fetch_content_from_file): Use
gdb_fopen_cloexec.
* main.c (captured_main): Call notice_open_fds.
gdbserver
* Makefile.in (SFILES): Add filestuff.c.
(OBS): Add filestuff.o.
(filestuff.o): New target.
* config.in, configure: Rebuild.
* configure.ac: Check for fdwalk, pipe2.
2013-04-22 18:46:15 +02:00
|
|
|
if (gdb_pipe_cloexec (tui_readline_pipe) != 0)
|
2014-08-04 15:03:21 +02:00
|
|
|
error (_("Cannot create pipe for readline"));
|
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
tui_rl_outstream = fdopen (tui_readline_pipe[1], "w");
|
|
|
|
if (tui_rl_outstream == 0)
|
2014-08-04 15:03:21 +02:00
|
|
|
error (_("Cannot redirect readline output"));
|
|
|
|
|
2002-10-25 21:24:01 +02:00
|
|
|
setvbuf (tui_rl_outstream, (char*) NULL, _IOLBF, 0);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
#ifdef O_NONBLOCK
|
|
|
|
(void) fcntl (tui_readline_pipe[0], F_SETFL, O_NONBLOCK);
|
1999-04-16 03:35:26 +02:00
|
|
|
#else
|
2001-07-21 21:56:54 +02:00
|
|
|
#ifdef O_NDELAY
|
|
|
|
(void) fcntl (tui_readline_pipe[0], F_SETFL, O_NDELAY);
|
1999-04-16 03:35:26 +02:00
|
|
|
#endif
|
2001-07-21 21:56:54 +02:00
|
|
|
#endif
|
|
|
|
add_file_handler (tui_readline_pipe[0], tui_readline_output, 0);
|
2002-09-03 22:47:48 +02:00
|
|
|
#else
|
|
|
|
tui_rl_outstream = stdout;
|
|
|
|
#endif
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Get a character from the command window. This is called from the
|
|
|
|
readline package. */
|
2001-07-21 21:56:54 +02:00
|
|
|
int
|
|
|
|
tui_getc (FILE *fp)
|
|
|
|
{
|
|
|
|
int ch;
|
|
|
|
WINDOW *w;
|
|
|
|
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
w = TUI_CMD_WIN->generic.handle;
|
2001-07-21 21:56:54 +02:00
|
|
|
|
2002-09-03 22:47:48 +02:00
|
|
|
#ifdef TUI_USE_PIPE_FOR_READLINE
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Flush readline output. */
|
2010-05-25 17:48:44 +02:00
|
|
|
tui_readline_output (0, 0);
|
2002-09-03 22:47:48 +02:00
|
|
|
#endif
|
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
ch = wgetch (w);
|
2004-02-08 01:05:16 +01:00
|
|
|
ch = tui_handle_resize_during_io (ch);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* The \n must be echoed because it will not be printed by
|
|
|
|
readline. */
|
2001-07-21 21:56:54 +02:00
|
|
|
if (ch == '\n')
|
|
|
|
{
|
|
|
|
/* When hitting return with an empty input, gdb executes the last
|
|
|
|
command. If we emit a newline, this fills up the command window
|
|
|
|
with empty lines with gdb prompt at beginning. Instead of that,
|
|
|
|
stay on the same line but provide a visual effect to show the
|
|
|
|
user we recognized the command. */
|
|
|
|
if (rl_end == 0)
|
|
|
|
{
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
wmove (w, TUI_CMD_WIN->detail.command_info.cur_line, 0);
|
2001-07-21 21:56:54 +02:00
|
|
|
|
|
|
|
/* Clear the line. This will blink the gdb prompt since
|
|
|
|
it will be redrawn at the same line. */
|
|
|
|
wclrtoeol (w);
|
|
|
|
wrefresh (w);
|
|
|
|
napms (20);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
wmove (w, TUI_CMD_WIN->detail.command_info.cur_line,
|
|
|
|
TUI_CMD_WIN->detail.command_info.curch);
|
2001-07-21 21:56:54 +02:00
|
|
|
waddch (w, ch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-18 Andrew Cagney <cagney@redhat.com>
* tui/tui-io.c: Update copyright.
(key_is_end_sequence, key_is_backspace): New functions.
(key_is_command_char, key_is_start_sequence): New function.
(tui_getc): Update references.
* tui/tui-io.h: Update copyright.
(m_tuiStartNewLine): Delete macro.
(m_isBackspace, m_isDeleteChar): Delete macros.
(m_isDeleteLine, m_isDeleteToEol): Delete macros.
(m_isNextPage, m_isPrevPage): Delete macros.
(m_isLeftArrow, m_isRightArrow): Delete macros.
(m_isXdbStyleCommandChar): Delete macro.
(key_is_start_sequence): Declare, replace m_isStartSequence.
(key_is_end_sequence): Declare, replace m_isEndSequence.
(key_is_backspace): Declare ,replace m_isBackspace.
(key_is_command_char): Declare, replace m_isCommandChar.
* tui/tui-command.c: Update copyright.
(tuiDispatchCtrlChar): Update references.
2004-01-19 06:06:34 +01:00
|
|
|
if (key_is_command_char (ch))
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
{ /* Handle prev/next/up/down here. */
|
2004-01-21 05:16:53 +01:00
|
|
|
ch = tui_dispatch_ctrl_char (ch);
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2001-07-21 21:56:54 +02:00
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
if (ch == '\n' || ch == '\r' || ch == '\f')
|
2004-02-07 Andrew Cagney <cagney@redhat.com>
* tui/tui.h: Do not include <stdarg.h>, <string.h>, and
"ansidecl.h". Do not undef "reg" and "chtype". Fix case of
fields and variables.
* tui/tui-wingeneral.h (m_beVisible): Delete macro.
(m_beInvisible): Delete macro.
* tui/tui-data.h: Fix case case fields and variables.
(m_genWinPtrIsNull): Delete macro.
(tui_win_list): Rename winList.
(TUI_SRC_WIN): Rename srcWin.
(TUI_DISASM_WIN): Rename disassemWin.
(TUI_DATA_WIN): Rename dataWin.
(TUI_CMD_WIN): Rename cmdWin.
(m_genWinPtrNotNull): Delete macro.
(m_winPtrIsNull): Delete macro.
(m_winPtrNotNull): Delete macro.
(tui_win_is_source_type): Replace m_winIsSourceType
(tui_win_is_auxillary): Replace m_winIsAuzillary.
(tui_win_has_locator): Replace m_hasLocator.
(tui_set_win_highlight): Replace m_setWinHighlightOn and
m_setWinHighlightOff.
* tui/tui-data.c: Update references.
(tui_win_is_source_type, tui_set_win_highlight): New functions.
(tui_win_has_locator, tui_win_is_auxillary): New functions.
* tui/tui-command.c, tui/tui-disasm.c: Update references.
* tui/tui-io.c, tui/tui-layout.c, tui/tui-regs.c: Ditto.
* tui/tui-regs.h, tui/tui-source.c, tui/tui-stack.c: Ditto.
* tui/tui-win.c, tui/tui-windata.c, tui/tui-wingeneral.c: Ditto.
* tui/tui-winsource.c, tui/tui.c: Ditto.
2004-02-07 21:57:02 +01:00
|
|
|
TUI_CMD_WIN->detail.command_info.curch = 0;
|
2001-07-21 21:56:54 +02:00
|
|
|
if (ch == KEY_BACKSPACE)
|
|
|
|
return '\b';
|
2014-11-23 11:03:39 +01:00
|
|
|
|
|
|
|
if (async_command_editing_p && key_is_start_sequence (ch))
|
|
|
|
{
|
|
|
|
int ch_pending;
|
|
|
|
|
|
|
|
nodelay (w, TRUE);
|
|
|
|
ch_pending = wgetch (w);
|
|
|
|
nodelay (w, FALSE);
|
|
|
|
|
|
|
|
/* If we have pending input following a start sequence, call the stdin
|
|
|
|
event handler again because ncurses may have already read and stored
|
|
|
|
the input into its internal buffer, meaning that we won't get an stdin
|
|
|
|
event for it. If we don't compensate for this missed stdin event, key
|
|
|
|
sequences as Alt_F (^[f) will not behave promptly.
|
|
|
|
|
|
|
|
(We only compensates for the missed 2nd byte of a key sequence because
|
|
|
|
2-byte sequences are by far the most commonly used. ncurses may have
|
|
|
|
buffered a larger, 3+-byte key sequence though it remains to be seen
|
|
|
|
whether it is useful to compensate for all the bytes of such
|
|
|
|
sequences.) */
|
|
|
|
if (ch_pending != ERR)
|
|
|
|
{
|
|
|
|
ungetch (ch_pending);
|
|
|
|
call_stdin_event_handler_again_p = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
return ch;
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
2001-07-21 21:56:54 +02:00
|
|
|
/* Cleanup when a resize has occured.
|
|
|
|
Returns the character that must be processed. */
|
1999-04-16 03:35:26 +02:00
|
|
|
static unsigned int
|
2004-02-08 01:05:16 +01:00
|
|
|
tui_handle_resize_during_io (unsigned int original_ch)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2004-02-07 05:40:36 +01:00
|
|
|
if (tui_win_resized ())
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2010-07-28 13:56:30 +02:00
|
|
|
tui_resize_all ();
|
2004-02-07 02:02:54 +01:00
|
|
|
tui_refresh_all_win ();
|
1999-04-16 03:35:26 +02:00
|
|
|
dont_repeat ();
|
2004-02-07 05:40:36 +01:00
|
|
|
tui_set_win_resized_to (FALSE);
|
1999-04-16 03:35:26 +02:00
|
|
|
return '\n';
|
|
|
|
}
|
|
|
|
else
|
2004-02-08 01:05:16 +01:00
|
|
|
return original_ch;
|
2001-07-21 21:56:54 +02:00
|
|
|
}
|